You can also trace the variable you wanted to output in the CAM code itself to see what would have been output. For instance, the variable "Z3" which is "Geopotential Height above sea level" is output in src/physics/cam/cam_diagnostics with an "outfld" call and is calculated as follows:
There is also a file which contains the geopotential calculations: src/physics/cam/geopotential.F90. I believe this is very similar to the file that brianpm mentioned above.
Hopefully one of these suggestions will help you.