Appendix A. Editing Template Files Before Configure

Table of Contents
Outline of the CLM template
Outline of the DATM template
Adding a new DATM_MODE to the DATM template

The last kind of customization that you can do for a case, before configure is run is to edit the templates. The CLM template is in models/lnd/clm/bld/clm.cpl7.template, the DATM template is in models/atm/datm/bld/datm.cpl7.template, and the driver templates are in the models/drv/bld directory and are named: ccsm.template and cpl.template. When a case is created they are also copied to the Tools/Templates directory underneath your case. If you want to make changes that will impact all your cases, you should edit the template files under the models directory, but if you want to make a change ONLY for a particular case you should edit the template under that specific case.

Note: Editing the template files is NOT for the faint of heart! We recommend this ONLY for experts! It's difficult to do because the template is a script that actually creates another script. So part of the script is echoing the script to be created and part of it is a script that is run when "configure -case" is run. As a result any variables in the part of the script that is being echoed have to be escaped like this:


\$VARIABLE
But, in other parts of the script that is run, you can NOT escape variables. So you need to understand if you are in a part of the script that is echoing the script to be created, or in the part of the script that is actually run.

If you can customize your case using: compsets, env_*.xml variables, or a user namelist, as outlined in Chapter 1 you should do so. The main reason to actually edit the template files, is if you are in a situation where the template aborts when you try it run it when "configure -case" is run. The other reason to edit the template is if you are CLM developer and need to make adjustments to the template because of code or script updates. An example of modifying the DATM template is in Example 4-9 where sed is used to modify the path for CPLHIST3HrWx data.

Outline of the CLM template

The outline of the CLM template is as follows:


# set up options for clm configure and then run clm configure
$CODEROOT/lnd/clm*/bld/configure <options>
# set up options for clm build-namelist and then run clm build-namelist
$CODEROOT/lnd/clm*/bld/build-namelist <options>
# echo the $CASEBUILD/clm.buildnml.csh script out
cat >! $CASEBUILD/clm.buildnml.csh << EOF1
# NOTE: variables in this section must be escaped
EOF1
# Remove temporary namelist files

# echo the $CASEBUILD/clm.buildexe.csh script out
cat > $CASEBUILD/clm.buildexe.csh <<EOF2
# NOTE: variables in this section must be escaped
EOF2
# Remove temporary configure files