Scheduled Downtime
On Tuesday 24 October 2023 @ 5pm MT the forums will be in read only mode in preparation for the downtime. On Wednesday 25 October 2023 @ 5am MT, this website will be down for maintenance and expected to return online later in the morning.
Normal Operations
The forums are back online with normal operations. If you notice any issues or errors related to the forums, please reach out to help@ucar.edu

CAM Snapshots functionality

David

David
New Member
What version of the code are you using?
git describe:
release-cesm2.2.2-0-g779b0a3



Have you made any changes to files in the source tree?
I added a new machine directly to the cime config on the source tree.

Describe every step you took leading up to the problem:

N/A



If this is a port to a new machine: Please attach any files you added or changed for the machine port (e.g., config_compilers.xml, config_machines.xml, and config_batch.xml) and tell us the compiler version you are using on this machine.
Please attach any log files showing error messages or other useful information.


N/A


Describe your problem or question:
I want to use the new snapshots functionality (the fields in phys_ctl_nl: cam_snapshot_after_num, cam_snapshot_before_num, cam_take_snapshot_after, cam_take_snapshot_before).

Would it be possible to provide an example of how to use it?
 

peverley

Courtney Peverley
Moderator
Staff member
Hi David,

Here's some information on the CAM snapshot functionality.
  • The cam_snapshot feature dumps the entire state/tend/pbuf/cnst arrays to netCDF files.
  • The variables cam_snapshot_before_num and cam_snapshot_after_num are the output history file numbers (offset by 1, meaning setting this to cam_snapshot_before_num=7 will lead to the before snapshot being output on history volume h6).
  • The cam_take_snapshot_before and cam_take_snapshot_after are usually set to the same routine to capture the variables before and after the named routine.
    • To find the snapshot name, look in your source code checkout in bld/namelist_files/namelist_definition.xml.
      • Inside this file, find the “cam_take_snapshot_before” definition. In this definition, it lists all possible routines which can have a snapshot file created around.
        • If your parameterization is there, that will be your cam_take_snapshot_before and _after values in your user_nl_cam
        • If it's not there, you can use the user_set option - i can explain that further if you'd like
  • Make sure to avoid using tape number one (h0) for cam_snapshot_before_num and cam_snapshot_after_num
  • Check your namelist for any extra “fincl” settings added by use cases, as those will add variables that can conflict with the snapshot output.
    • To check this, before you modify the user_nl_cam file, run ./case.setup, run ./preview_namelists and then look at the resulting atm_in file in the run directory. Look for finclX where X is your possible “before” and “after” numbers. Choose a number that is not used.
      • You most likely will see fincl1 which is why it is not an option.
  • Set nhtfrq to 1 so that data is written out on every time step. Note that the nhtfrq and ndens variables are arrays based off of the “tape” number specified in cam_snapshot_before and cam_snapshot_after. (i.e. 6 = the sixth number in these two arrays)
  • Finally, as cam_snapshot writes out all of state, pbuf and other variables at every time step, it is suggested that a limited number of time steps be made in a cam_snapshot run.
    • The run must be at least 2 time steps in order to work in subsequent steps. We recommend 3 to at most 9 time steps. (Note a 3 timestep run using a 2 degree FV grid can produce snapshot files with sizes over 4 Gb each).
    • To change the number of timesteps to 3 use ./xmlchange STOP_OPTION=nsteps and ./xmlchange STOP_N=3
Here's a sample user_nl_cam that will take a snapshot each timestep before and after gravity waves is run. The before snapshot will end up on the h5 file; the after snapshot will be on the h6 file):
Code:
cam_snapshot_before_num=6
cam_snapshot_after_num=7
cam_take_snapshot_before='gw_tend'
cam_take_snapshot_after='gw_tend'
nhtfrq = 0,0,0,0,0,1,1
ndens = 2,2,2,2,2,1,1

Hope that helps!
Courtney
 
Top