CESM exercise II: view and discuss model output

From Interactive System for Ice sheet Simulation
Revision as of 11:30, 10 March 2011 by Lipscomb (Talk | contribs)

Jump to: navigation, search

Back to Thursday, March 24th

View the results

To see output from your run:

> cd /ptmp/logon_name/archive/case_name
> ls
> cd lnd
> ls
> cd hist
> ls

You should have a history file for each month of your run.

Let's say we're interested in the surface mass balance of glaciated gridcells from year 10 of the run, averaged over 12 months.

We can post-process the data using NCO, a suite of programs for useful manipulation of netCDF files. For details, see http://nco.sourceforge.net/.

To average all the history variables over 12 months, use the ncra command:

> ncra -n 12,2,1 infile.nc outfile.nc

The -n command tells NCO to average over files that have the same name as infile.nc, apart from a numerical file identifier.

  • The '12' indicates that there are 12 files to average.
  • The '2' says that the identifier has 2 digits (01, 02, ..., 12)
  • The '1' says that the identifier changes with a stride of 1.

The outfile name is arbitrary. In our case, we can type:

> ncra -n 12,2,1 case_name.clm2.h0.0010-01.nc case_name.clm2.h0.0010-avg.nc
> ls

To view the contents of the new file:

> ncdump -h case_name.clm2.h0.0010-avg.nc | less

Hit the space bar to scroll through the output.

Note the following:

  • The grid dimensions are 96 x 144.
  • There are some time-independent variables (e.g., area, topo) with lower-case names.
  • There are many time-dependent variables (including QICE, the surface mass balance) with names in all caps.

Now we can plot the data.

My favorite netCDF viewer is ferret, but ferret is not installed on bluefire.

Let's use ncview instead:

> ncview case_name.clm2.h0.0010-avg.nc

The ncview GUI should pop up. Click on the 2d vars button.

If the ncview GUI does not pop up, that's probably because your path isn't set up to find it. Try this instead:

> /contrib/bin/ncview case_name.clm2.h0.0010-avg.nc

As a shortcut, you can add an alias in your .cshrc file in your home directory.

alias ncview   '/contrib/bin/ncview'

After you save the new version of .cshrc, you will need to type this:

> source .cshrc

Then the alias should work.

Unfortunately, there are so many variables that we can't get to QICE (one of the limitations of ncview).

Let's make a file that doesn't have so many variables:

> ncra -v QICE -n 12,2,1 case_name.clm2.h0.0010-01.nc case_name.clm2.h0.0010-QICE.nc

Here we have used the -v option to specify the variables to average over.

The resulting file has just one time-dependent variable QICE, a function of lat, lon and time:

> ncdump -h case_name.clm2.h0.0010-QICE.nc

Let's try ncview again:

> ncview case_name.clm2.h0.0010-QICE.nc

You should see a global plot of QICE on the global land grid.

To magnify the plot, left-click as many times as desired on the button that says M X3. To shrink the plot, right-click on this button.

We can see QICE for glaciated cells not only in Greenland and Antarctica, but also in the Himalayas, Canadian archipelago, Alaskan coastal range, and Patagonia (and New Zealand!).

The units of QICE are mm/s (or equivalently, kg/m2/s). If you prefer m/yr, you can change the units in the file using the ncflint command:

> ncflint -w 3.16e4,0 case_name.clm2.h0.0010-QICE.nc case_name.clm2.h0.0010-QICE.nc case_name.clm2.h0.0010-QICEmyr.nc

where the factor 3.16e4 converts from mm/s to m/yr.

(This syntax can be interpreted as follows. The form of the command is

> ncflint -w weight1, weight2 infile1.nc infile2.nc outfile.nc

with the result that variables in the output file have values outfile_var = weight1*infile1_var + weight2*infile2_var. If weight2 = 0, then infile2 is irrelevant and the effect is simply to multiply variables in infile1 by a constant. Perhaps there is a simpler way to do this. In ferret it is easy to multiply data by a constant without changing the netCDF file.)

You may want to look at other data fields in the monthly mean files and in the yearly average file.

As a final exercise, let's compute the surface mass balance integrated over the Greenland ice sheet. NCO has a command for this too:

> ncwa -N -v QICE -a lat,lon -B 'gris_mask > 0.5' -w area -N case_name.clm2.h0.0010-avg.nc outfile.nc 


  • -N says to compute the integrated total as opposed to the average.
  • -v tells which variable(s) to sum and/or average over
  • -a tells which dimensions to sum over
  • -B says to sum only over cells that meet a masking condition (in our case, Greenland cells have gris_mask = 1.0, and all other cells have gris_mask = 0.0)
  • -w says to weight by the variable that follows (grid cell area in this case)

Let's look at the output:

> ncdump outfile.nc

We're interested in the area-integrated value of QICE. Note that area has units of km2, whereas QICE has units of mm/s. To convert to km3/yr, multiply the result by 3.16e7 (the number of seconds in a year) and divide by 1e6 (the number of mm in a km). Recall that 1 km3 (liquid water equivalent) of ice weighs 1 Gigaton.

For the present-day (or at least preindustrial) climate of Greenland, the net surface mass balance is ~300 to 400 km3/y. How do your results compare?