Chapter 6. Adding a new user-defined grid (EXPERTS ONLY)

Support for numerous out-of-the box model resolutions accompany the CESM1.1 release. (In addition to the link above, you can also view a listing of supported "out-of-the-box" resolutions by running create_newcase -l.) In general, CESM grids are associated with a specific combination of atmosphere, land, land-ice, river-runoff and ocean/ice grids. The naming convention for these grids still only involves atmosphere, land, and ocean/ice grid specifications. The particular naming convention looks like f19_g16 for the f19 atmosphere / land grid combined with the g16 ocean / ice grid, where f19 is the shortname for the 1.9x2.5 finite volume dycore grid and g16 is the shortname for the gx1v6 one-degree displaced pole grid. This will be generalized in CESM1.2.

CESM1.1 provides completely new support for you to add your own specific component grid combinations. To achieve this, CESM1.1 has a new top level directory $CCSMROOT/mapping/. A brief list of the steps needed to add a new component grid to the model system follows. In what follows we assume that the ocean and ice are on the same grid, though no such assumption is made about the atmosphere and land.

  1. Start with SCRIP grid files for atm and ocn.

    You must first create or obtain SCRIP format grid files for the atmosphere and ocean grids. At present there is no supported functionality for creating the SCRIP format file, although that is planned for CESM1.2.

  2. Build the check_map utility.

    When you add new user-defined grid files, you will also need to generate a set of mapping files so the coupler can send data from a component on one grid to a component on another grid. There is an ESMF tool that tests the mapping file by comparing a mapping of a smooth function to its true value on the destination grid. We have tweaked this utility to test a suite of of smooth functions, as well as ensure conservation (when the map is conservative). Before generating mapping functions it is highly recommended that you build this utility.

    To build this tool, follow the instructions in $CCSMROOT/mapping/check_maps/INSTALL. As with many of the steps in this document, you will need to have the ESMF toolkit installed. It is installed by default on most NCAR computers.

  3. generate atm<->ocn and lnd<->rtm mapping files

    Using the SCRIP grid files from step one, you must generate conservative and non-conservative (patch and bilinear) mapping files for ocn->atm and atm->ocn grid mapping, as well as conservative maps for lnd<->rtm. You can do this by calling in $CCSMROOT/mapping/gen_mapping_files/. This directory contains a shell script that generates all the necessary mapping files (except rtm->ocn, which is discussed below). This script uses the ESMF offline weight generation utility, which you must build prior to running (See the README file in this directory for a full discussion.)

$ cd $CCSMROOT/mapping/gen_mapping_files
    $ ./ \
        --fileocn  <input SCRIP ocn_grid full pathname>  \
        --fileatm  <input SCRIP atm grid full pathname>  \
        --filelnd  <input SCRIP lnd grid full pathname>  \
        --filertm  <input SCRIP rtm grid full pathname>  \
        --nameocn  <ocnname in output mapping file> \ 
        --nameatm  <atmname in output mapping file> \ 
        --namelnd  <lndname in output mapping file> \ 
        --namertm  <rtmname in output mapping file> 

    will generate the following mapping files:

    Notes: If you do not include a land grid, then the atmosphere grid will be used to generate lnd<->rtm and rtm<->lnd maps. (If you do not include a runoff grid, then only atm<->ocn and ocn<->atm maps will be generated.) Also, ESMF_RegridWeightGen runs in parallel, and the script has been written to run on bluefire, jaguar, and yellowstone. To run on any other machine, you may need to add some environment variables to $CCSMROOT/mapping/gen_mapping_files/ gen_ESMF_mapping_file/ -- search for hostname to see where to edit the file.

    Example (run on Nov 5, 2012):

$ ./ \
         -focn /CESM/cseg/mapping/grids/ -nocn g37 \
         -fatm /CESM/cseg/mapping/grids/ -natm ne16np4 \
         -frtm /CESM/cseg/mapping/grids/ -nrtm r05

    Results in the following files

$ ls -1 map*

  4. Generate (atm/lnd) and (ocn/ice) domain files.

    Using the conservative ocean to atmosphere mapping file created in the previous step, you need to create domain files for the land and ocean which will have the correct masks and fractions. You will utilize the above ocean -> atmosphere conservative mapping file as input to gen_domain, which is located in $CCSMROOT/mapping/gen_domain_files. Note that gen_domain is a binary exectuable that must first be built following the instructions in gen_domain_files/INSTALL.

    gen_domain adds "cell fraction" data to the output domain files. The "cell fraction" indicates how much of each grid cell is active. Typically ocean models do not have fractional cells (the fraction is either 0 or 1), where as land models do have fractional cells. This code generates domain files where gridocn has fractions of either 0 or 1 (for grid cells that are masked or unmasked, respectively) and gridlnd has fractions that represent the complement of gridocn fraction data, as computed by the input mapping data. Thus gridocn is intended to be an ocean domain file and gridlnd is intended to be the complementary land domain file. Related, the input mapping data, filemap, should be a conservative mapping: ocean -> atmosphere.

    The input atmosphere grid is assumed to be unmasked (global) and the land and atmosphere grids are assumed to be identical, except for cell fractions and masks. Land cells whose fraction is zero will have land mask = 0.

    If the ocean and atmosphere grids are identical then the mapping file swill simply be unity and the land fraction will be one minus the ocean fraction.

$ cd $CCSMROOT/mapping/gen_domain_files
    $ ./gen_domain -m ../gen_mapping_files/ \
                   -o ocnname -l atmname

    will generate the following output

  5. If you are adding a new ocn or rtm grid, create a new rtm->ocn mapping file. (Otherwise you can skip this step.)

    Discuss rof->ocn mapping file. Key point - if you do not change the ocean grid or the default runoff grid - you can skip this step.

  6. If you are adding a new new lnd grid, create a new CLM surface dataset. (Otherwise you can skip this step.)

    1. Generate mapping files for CLM surface dataset (since this is a non-standard grid).

$ cd $CCSMROOT/models/lnd/clm/tools/mkmapdata
      $ ./ --gridfile <lnd SCRIP grid file> \
                       --res <atm resolution name> \
                       --gridtype global

    2. Generate CLM surface dataset. Below is an example for a current day surface dataset (model year 2000).

      $ cd  $CCSMROOT/models/lnd/clm/tools/mksurfdata_map
      $ ./ -res usrspec -usr_gname <atm resolution name> \
                        -usr_gdate yymmdd -y 2000

  7. Create grid file needed for create_newcase.

    The next step is to create a file - call it mygrid.xml with the following contents

TODO - fill in below
    <?xml version="1.0"?>
    <horiz_grid GLOB_GRID="" nx=" ny="" />
    <horiz_grid GRID="" SHORTNAME=""
                ATM_GRID="" LND_GRID="" OCN_GRID="" ICE_GRID="" 
                ATM_NCPL="" OCN_NCPL=""
                DESC="wrf grid"

  8. Create user_nl_cpl contents for new mapping files.

    One of the many input files generated for the coupler is $RUNDIR/ seq_maps.rc, which contains a list of mapping files. Using an f09_g16 run on bluefire as an example, the file will contain the following (for brevity, some lines have been cut)

 atm2ocnFmapname: '/glade/proj3/cseg/inputdata/cpl/cpl6/'
     atm2ocnSmapname: '/glade/proj3/cseg/inputdata/cpl/cpl6/'
     atm2ocnVmapname: '/glade/proj3/cseg/inputdata/cpl/cpl6/'
     lnd2atmFmapname: 'idmap'
     lnd2atmSmapname: 'idmap'
     lnd2rofFmapname: '/glade/proj3/cseg/inputdata/lnd/clm2/mappingdata/maps/0.9x1.25/'
     lnd2rofFmaptype: 'X'
     ocn2atmFmapname: '/glade/proj3/cseg/inputdata/cpl/cpl6/'
     ocn2atmSmapname: '/glade/proj3/cseg/inputdata/cpl/cpl6/'

    This file is created when you build the model namelists, and the default values are based on the grids specified when you created the case. The model only knows what default values to use for the out-of-the-box resolutions, so you must specify what maps you have created by appending them to $CASE/user_nl_cpl. If, for example, we've introduced a new atmosphere grid with a shortname newatm and created all the necessary mapping files in $MAPPING_FILE_LOC, then to create a newatm_g16 run we would need to add the following to $CASE/user_nl_cpl:


    After running $CASE/preview_namelists these changes will be reflected in $RUNDIR/seq_maps.rc.

  9. Test new grid.

    Below assume that the new grid is an atmosphere grid.

Test the new grid with all data components.
    (write an example)
    Test the new grid with CAM(newgrid), CLM(newgrid), DOCN(gx1v6), DICE(gx1v6)
    (write an example)