Interpolate CAM output#
In this exercise, you will learn how to interpolate CAM output from the native spectral-element (SE) grid to a regular latitude–longitude grid.
Many analysis and visualization tools work more naturally with regular latitude–longitude grids than with the native SE grid. CAM can perform this interpolation automatically when writing history files.
In this exercise, we will use:
Compset:
B1850C_LTsoResolution:
ne16pg3_t201
We will interpolate CAM history output to a regular 2° × 2° latitude–longitude grid.
Create a case called b1850_interp using the compset B1850C_LTso and resolution ne16pg3_t201. Because the resolution ne16pg3_t201 not yet supported at this stage, use the option: --run-unsupported
Modify the CAM namelist so that history output is interpolated to a regular 2° × 2° latitude–longitude grid.
Run the model for one month and verify that the output files are written on the interpolated grid.
Click here for hints
# How do I compile?
You can compile with the command:
qcmd -- ./case.build
# Which namelist variables control interpolation?
Look at the variables:
interpolate_output
interpolate_nlat
interpolate_nlon
# How many points are on a 2° × 2° grid?
A global 2° × 2° latitude–longitude grid contains:
91 latitude points
180 longitude points
# How do I verify the interpolation?
Use:
ncdump -h <history_file>
and examine the latitude and longitude dimensions.
You should see dimensions similar to:
lat = 91 ;
lon = 180 ;
Click here for the solution
# Create a new case
Create a new case called b1850_interp:
cd /glade/u/home/$USER/code/my_cesm_code/cime/scripts/
./create_newcase --case ~/cases/b1850_interp \
--compset B1850C_LTso \
--res ne16pg3_t201 \
--run-unsupported
# Setup
Invoke case.setup:
cd ~/cases/b1850_interp
./case.setup
# Customize CAM namelist
Edit the file user_nl_cam and add:
interpolate_output = .true.
interpolate_nlat = 91
interpolate_nlon = 180
This tells CAM to interpolate history output from the native SE grid to a regular 2° × 2° latitude–longitude grid.
# Set run length
Run the model for one month:
./xmlchange STOP_N=1,STOP_OPTION=nmonths
# Change the job queue and account number
If needed, change the job queue and project number. For example, to run in the tutorial queue using project UESM0016, use:
./xmlchange JOB_QUEUE=tutorial,PROJECT=UESM0016 --force
Use the project number provided for the tutorial.
# Build and submit
Build the model and submit the case:
qcmd -- ./case.build
./case.submit
# Check the output
When the run is complete, go to the archive directory:
cd /glade/derecho/scratch/$USER/archive/b1850_interp/atm/hist
ls
There are two files:
b1850_interp.cam.h0a.0001-01.nc
b1850_interp.cam.h0i.0001-02-01-00000.nc
Look at the CAM history file header of b1850_interp.cam.h0a.0001-01.nc:
ncdump -h b1850_interp.cam.h0a.0001-01.nc | more
Check that the output is now on a regular latitude–longitude grid. You should see dimensions similar to:
lat = 91 ;
lon = 180 ;
You can also check that CAM variables are written using latitude and longitude dimensions. For example:
float T(time, lev, lat, lon) ;
float PS(time, lat, lon) ;
This confirms that CAM output has been interpolated from the native ne16pg3 grid to the 2° × 2° latitude–longitude grid.