liptak@umich_edu
New Member
For those of you who want to write new variables to the CAM history files, you can edit the the module "cam_diagnostics.F90" in /working_directory_name/models/atm/cam/src/physics/cam.
I added potential temperature using the following procedure:
1) in the subroutine diag_init, add the line 'call addfld('TH ', 'K' , pver , 'I','potential temperature',phys_decomp)' ---the 'I" denotes instantaneous values. If you want average values, insert 'A'
2) in the subroutine diag_phys_writeout:
add 'cpair' to 'use_physconst'
declare variable as 'real(r8) th(pcols,pver)'
calculate potential temperature
do k = 1, pver
th(:ncol,k) = state%t(:ncol,k)*(state%ps(:ncol)/state%pmid(:ncol,k))**(rair/cpair)
end do
insert the line 'call outfld ('TH ', th , pcols, lchnk)'
3) After creating and configuring your case using the ccsm/cesm scripts (I'm running cam4 with ccsm4 scripts), insert 'TH:I' (or 'TH:A' for average values) after 'fincl1' in the cam_buildnml.csh script in the local Buildconf folder. Or, specify your own history output variable(s) in a file called 'user_nl' and place it in the Sourcemods/src.cam folder before configuring.
Alternately, you can add your variable to one of the default history files by inserting 'call add_default ('TH ', , ' ') in subroutine the diag_init.
4) build and run as usual
Diag_phys_writeout included the necessary state variables to compute potential temperature, but you can compute your variable in another subroutine (or write your own). You may also need to insert additional 'counter' integers such as i, or call other constants from 'physconst'.
I added potential temperature using the following procedure:
1) in the subroutine diag_init, add the line 'call addfld('TH ', 'K' , pver , 'I','potential temperature',phys_decomp)' ---the 'I" denotes instantaneous values. If you want average values, insert 'A'
2) in the subroutine diag_phys_writeout:
add 'cpair' to 'use_physconst'
declare variable as 'real(r8) th(pcols,pver)'
calculate potential temperature
do k = 1, pver
th(:ncol,k) = state%t(:ncol,k)*(state%ps(:ncol)/state%pmid(:ncol,k))**(rair/cpair)
end do
insert the line 'call outfld ('TH ', th , pcols, lchnk)'
3) After creating and configuring your case using the ccsm/cesm scripts (I'm running cam4 with ccsm4 scripts), insert 'TH:I' (or 'TH:A' for average values) after 'fincl1' in the cam_buildnml.csh script in the local Buildconf folder. Or, specify your own history output variable(s) in a file called 'user_nl' and place it in the Sourcemods/src.cam folder before configuring.
Alternately, you can add your variable to one of the default history files by inserting 'call add_default ('TH ', , ' ') in subroutine the diag_init.
4) build and run as usual
Diag_phys_writeout included the necessary state variables to compute potential temperature, but you can compute your variable in another subroutine (or write your own). You may also need to insert additional 'counter' integers such as i, or call other constants from 'physconst'.