[Dart-dev] [6551] DART/trunk/models/clm/shell_scripts: Better staging scripts and more accurate comments.

nancy at ucar.edu nancy at ucar.edu
Fri Oct 25 14:46:25 MDT 2013


Revision: 6551
Author:   thoar
Date:     2013-10-25 14:46:24 -0600 (Fri, 25 Oct 2013)
Log Message:
-----------
Better staging scripts and more accurate comments.
Streamlined perfect_model setup and execution.

Modified Paths:
--------------
    DART/trunk/models/clm/shell_scripts/CESM1_1_1_setup_hybrid
    DART/trunk/models/clm/shell_scripts/CESM1_1_1_setup_pmo
    DART/trunk/models/clm/shell_scripts/CESM_DART_config
    DART/trunk/models/clm/shell_scripts/perfect_model.csh

-------------- next part --------------
Modified: DART/trunk/models/clm/shell_scripts/CESM1_1_1_setup_hybrid
===================================================================
--- DART/trunk/models/clm/shell_scripts/CESM1_1_1_setup_hybrid	2013-10-25 20:46:12 UTC (rev 6550)
+++ DART/trunk/models/clm/shell_scripts/CESM1_1_1_setup_hybrid	2013-10-25 20:46:24 UTC (rev 6551)
@@ -102,7 +102,7 @@
 
 # the value of "case" will be used many ways;
 #    directory and file names, both locally and on HPSS, and
-#    script names; so consider it's length and information content.
+#    script names; so consider its length and information content.
 # num_instances:  Number of ensemble members
 
 setenv case                 clm_hybrid
@@ -117,7 +117,7 @@
 # mach            Computer name
 # cesmroot        Location of the cesm code base
 #                 For cesm1_1_1 on yellowstone
-# caseroot        Your (future) cesm case directory, where this CESM+DART will be built.
+# caseroot        Your (future) CESM case directory, where this CESM+DART will be built.
 #                    Preferably not a frequently scrubbed location.
 #                    This script will delete any existing caseroot, so this script,
 #                    and other useful things should be kept elsewhere.
@@ -130,6 +130,7 @@
 # ==============================================================================
 
 setenv mach         yellowstone
+
 setenv cesmroot     /glade/p/cesm/cseg/collections/$cesmtag
 setenv caseroot     /glade/p/work/${USER}/cases/${case}
 setenv exeroot      /glade/scratch/${USER}/${case}/bld
@@ -169,7 +170,7 @@
 #               this configuration step. The run-time settings can lie.
 #
 # If the long-term archiver is off, you get a chance to examine the files before
-# they get moved to long-term storage. You can always submit $CASE.l_archive
+# they get moved to long-term storage. You can always submit $case.l_archive
 # whenever you want to free up space in the short-term archive directory.
 #
 # ==============================================================================
@@ -245,8 +246,8 @@
 # ==============================================================================
 # Create the case - this creates the CASEROOT directory.
 #
-# For list of the pre-defined cases: ./create_newcase -list
-# To create a variant case, see the CESM documentation and carefully
+# For list of the pre-defined component sets: ./create_newcase -list
+# To create a variant compset, see the CESM documentation and carefully
 # incorporate any needed changes into this script.
 # ==============================================================================
 
@@ -408,6 +409,7 @@
 ./xmlchange DATM_CPLHIST_YR_END=$refyear
 
 ./xmlchange CALENDAR=GREGORIAN
+
 ./xmlchange STOP_OPTION=$stop_option
 ./xmlchange STOP_N=$stop_n
 ./xmlchange CONTINUE_RUN=FALSE
@@ -500,7 +502,7 @@
    echo "ERROR - No SourceMods for this case."
    echo "DART requires modifications to several src files."
    echo "These files can be downloaded from:"
-   echo "http://www.image.ucar.edu/pub/DART/CESM/DART_SourceMods_cesm1_1_1.tar"
+   echo "http://www.image.ucar.edu/pub/DART/CESM/DART_SourceMods_cesm1_1_1_24Oct2013.tar"
    echo "untar these into your HOME directory - they will create a"
    echo "~/cesm_1_1_1  directory with the appropriate SourceMods structure."
    exit -4
@@ -531,9 +533,7 @@
 endif
 
 # ==============================================================================
-# Modify namelist templates for each instance. This is a bit of a nuisance in
-# that we are pulling in restart and initial files from 'all over the place'
-# and each model component has a different strategy.
+# Modify namelist templates for each instance.
 #
 # In a hybrid run with CONTINUE_RUN = FALSE (i.e. just starting up):
 #
@@ -683,41 +683,90 @@
 # ==============================================================================
 # Stage the restarts now that the run directory exists
 # THIS IS THE STAGING SECTION - MAKE SURE THIS MATCHES THE NAMELISTS.
-# POP/CAM/CICE read from pointer files. The others use namelist values initially.
 # ==============================================================================
 
-cat << EndOfText >! stage_initial_cesm_files
-#!/bin/sh
+cat << EndOfText >! stage_cesm_files
+#!/bin/csh -f
+# This script can be used to help restart an experiment from any previous step.
+# The files are copied to the RUN directory.
+# Set the 'restart_time' variable below to define when to restart the experiment.
+# The value of the CESM variable 'env_run.xml:CONTINUE_RUN' is used to determine
+# the origin of the files.
 
-cd ${rundir}
-
+echo 'Copying the required files to the run directory.'
+echo 'No matter what, make sure the restart_time is set to the desired time.'
 echo ''
-echo 'Copying only the required restart files from the staging directory.'
-echo 'With CONTINUE_RUN=FALSE, there are many that are not required.'
+echo 'With CONTINUE_RUN=FALSE, the files are copied from the initial ensemble directory.'
+echo 'When CONTINUE_RUN=TRUE, the files are copied from the short-term archive restart directory.'
+echo 'If the short-term archiver is OFF, all the files are already in the RUN directory and'
+echo 'just the pointer files need to be updated.'
 echo ''
 
-# This copies over only the minimum number of instances.
-# The reference case may more instances than we need,
-# and it certainly has more files than we need.
+cd ${caseroot}
+source ./Tools/ccsm_getenv || exit -2
+cd ${RUNDIR}
 
-let inst=1
-while ((\$inst <= $num_instances)); do
-   inst_string=\`printf _%04d \$inst\`
+set restart_time = $RUN_REFDATE-$RUN_REFTOD
 
-   echo ''
-   echo "Staging restarts for instance \$inst of $num_instances"
+#----------------------------------------------------------------------
+# This block copies over a set of restart files from
+# this experiment and exits. Intended use to restart a failed run.
+#----------------------------------------------------------------------
 
-   ${COPY} ${CLM_stagedir}/${run_refcase}.clm2\${inst_string}.r.${run_refdate}-${run_reftod}.nc .
+echo "continue_run is \$CONTINUE_RUN"
 
-   let inst+=1
-done
+if ( \$CONTINUE_RUN == TRUE ) then
+   if (  \$DOUT_S   == TRUE ) then
 
+      # the restarts should be in the short term archive directory
+      # www.cesm.ucar.edu/models/cesm1.1/cesm/doc/usersguide/x1631.html#running_ccsm_restart_back
+
+      ${COPY} \$DOUT_S_ROOT/rest/\${restart_time}/* . || exit -1
+
+   else
+
+      # All the required files must still be in the run directory.
+      # Just need to update the pointer files.
+
+      @ inst=1
+      while (\$inst <= $num_instances)
+         set inst_string = \`printf _%04d \$inst\`
+         echo "${case}.cpl.r.\${restart_time}.nc"                   >! rpointer.drv
+         echo "${case}.clm2\${inst_string}.r.\${restart_time}.nc"   >! rpointer.lnd\${inst_string}
+         echo "${case}.datm\${inst_string}.r.\${restart_time}.nc"   >! rpointer.atm\${inst_string}
+         echo "${case}.datm\${inst_string}.rs1.\${restart_time}.nc" >> rpointer.atm\${inst_string}
+         @ inst ++
+      end
+
+   endif
+   exit 0
+endif
+
+#----------------------------------------------------------------------
+# This block prepares the initial run directory for a startup run.
+# CLM namelists specify a relative path for the initial file.
+#
+# The reference case may more instances than we need,
+# and it certainly has more files than we need.
+# This stages only the minimum number of instances and files.
+#
+# Remember - in a hybrid case - when CONTINUE_RUN = FALSE,
+# the run_refdate and the time in the filenames can be unrelated.
+#----------------------------------------------------------------------
+
+@ inst=1
+while (\$inst <= $num_instances)
+   set inst_string = \`printf _%04d \$inst\`
+   ${LINK} ${CLM_stagedir}/${run_refcase}.clm2\${inst_string}.r.${run_refdate}-${run_reftod}.nc .
+   @ inst ++
+end
+
 exit 0
 
 EndOfText
-chmod 0755 stage_initial_cesm_files
+chmod 0755 stage_cesm_files
 
-./stage_initial_cesm_files
+./stage_cesm_files
 
 # ==============================================================================
 # build
@@ -755,7 +804,7 @@
 echo "4) Verify the contents of env_run.xml and submit the CESM job:"
 echo "   ./${case}.submit"
 echo ""
-echo "5) After the job has run, make sure it worked "
+echo "5) After the job has run, check to make sure it worked."
 echo ""
 echo "6) To extend the run in $assim_n '"$stop_option"' steps,"
 echo "   change the env_run.xml variables:"
@@ -764,6 +813,9 @@
 echo "   ./xmlchange RESUBMIT=<number_of_cycles_to_run>"
 echo "   ./xmlchange STOP_N=$assim_n"
 echo ""
+echo "   and"
+echo "   ./${case}.submit"
+echo ""
 echo "Check the streams listed in the streams text files.  If more or different"
 echo 'dates need to be added, then do this in the $CASEROOT/user_*files*'
 echo "then invoke 'preview_namelists' so you can check the information in the"

Modified: DART/trunk/models/clm/shell_scripts/CESM1_1_1_setup_pmo
===================================================================
--- DART/trunk/models/clm/shell_scripts/CESM1_1_1_setup_pmo	2013-10-25 20:46:12 UTC (rev 6550)
+++ DART/trunk/models/clm/shell_scripts/CESM1_1_1_setup_pmo	2013-10-25 20:46:24 UTC (rev 6551)
@@ -38,7 +38,7 @@
 #
 # ${CASEROOT}/CESM_DART_config will augment the CESM case with the required setup
 # and configuration to use DART to harvest synthetic observations. CESM_DART_config
-# will insert a few dozen lines into the ${CASE}.run script after it makes a backup
+# will insert a few dozen lines into the ${case}.run script after it makes a backup
 # copy.  This, and the required setup, can be run at a later date. e.g. you can
 # advance an ensemble from 2004-01-01 to 2004-02-01 and then run
 # CESM_DART_config to augment the existing run script, modify STOP_N to 6 hours,
@@ -95,7 +95,7 @@
 
 # the value of "case" will be used many ways;
 #    directory and file names, both locally and on HPSS, and
-#    script names; so consider it's length and information content.
+#    script names; so consider its length and information content.
 
 setenv case                 clm_pmo
 setenv compset              I_2000_CN
@@ -108,7 +108,7 @@
 # mach            Computer name
 # cesmroot        Location of the cesm code base
 #                 For cesm1_1_1 on yellowstone
-# caseroot        Your (future) cesm case directory, where this CESM+DART will be built.
+# caseroot        Your (future) CESM case directory, where this CESM+DART will be built.
 #                    Preferably not a frequently scrubbed location.
 #                    This script will delete any existing caseroot, so this script,
 #                    and other useful things should be kept elsewhere.
@@ -121,6 +121,7 @@
 # ==============================================================================
 
 setenv mach         yellowstone
+
 setenv cesmroot     /glade/p/cesm/cseg/collections/$cesmtag
 setenv caseroot     /glade/p/work/${USER}/cases/${case}
 setenv exeroot      /glade/scratch/${USER}/${case}/bld
@@ -179,7 +180,7 @@
 #               this configuration step. The run-time settings can lie.
 #
 # If the long-term archiver is off, you get a chance to examine the files before
-# they get moved to long-term storage. You can always submit $CASE.l_archive
+# they get moved to long-term storage. You can always submit $case.l_archive
 # whenever you want to free up space in the short-term archive directory.
 #
 # ==============================================================================
@@ -255,8 +256,8 @@
 # ==============================================================================
 # Create the case - this creates the CASEROOT directory.
 #
-# For list of the pre-defined cases: ./create_newcase -list
-# To create a variant case, see the CESM documentation and carefully
+# For list of the pre-defined component sets: ./create_newcase -list
+# To create a variant compset, see the CESM documentation and carefully
 # incorporate any needed changes into this script.
 # ==============================================================================
 
@@ -403,6 +404,7 @@
 ./xmlchange DATM_CPLHIST_YR_END=$refyear
 
 ./xmlchange CALENDAR=GREGORIAN
+
 ./xmlchange STOP_OPTION=$stop_option
 ./xmlchange STOP_N=$stop_n
 ./xmlchange CONTINUE_RUN=FALSE
@@ -485,7 +487,7 @@
 #    Ideally, using DART would not require any modifications to the model source.
 #    Until then, this script accesses sourcemods from a hardwired location.
 #    If you have additional sourcemods, they will need to be merged into any DART
-#    mods and put in the SourceMods subdirectory found in the 'case' directory.
+#    mods and put in the SourceMods subdirectory found in the 'caseroot' directory.
 # ==============================================================================
 
 if (    -d     ~/${cesmtag}/SourceMods ) then
@@ -495,7 +497,7 @@
    echo "ERROR - No SourceMods for this case."
    echo "DART requires modifications to several src files."
    echo "These files can be downloaded from:"
-   echo "http://www.image.ucar.edu/pub/DART/CESM/DART_SourceMods_cesm1_1_1.tar"
+   echo "http://www.image.ucar.edu/pub/DART/CESM/DART_SourceMods_cesm1_1_1_24Oct2013.tar"
    echo "untar these into your HOME directory - they will create a"
    echo "~/cesm_1_1_1  directory with the appropriate SourceMods structure."
    exit -4
@@ -526,9 +528,7 @@
 endif
 
 # ==============================================================================
-# Modify namelist templates for each instance. This is a bit of a nuisance in
-# that we are pulling in restart and initial files from 'all over the place'
-# and each model component has a different strategy.
+# Modify namelist templates for each instance.
 #
 # In a hybrid run with CONTINUE_RUN = FALSE (i.e. just starting up):
 #
@@ -681,41 +681,98 @@
 # ==============================================================================
 # Stage the restarts now that the run directory exists
 # THIS IS THE STAGING SECTION - MAKE SURE THIS MATCHES THE NAMELISTS.
-# POP/CAM/CICE read from pointer files. The others use namelist values initially.
 # ==============================================================================
 
-cat << EndOfText >! stage_initial_cesm_files
-#!/bin/sh
+cat << EndOfText >! stage_cesm_files
+#!/bin/csh -f
+# This script can be used to help restart an experiment from any previous step.
+# The files are copied to the RUN directory.
+# Set the 'restart_time' variable below to define when to restart the experiment.
+# The value of the CESM variable 'env_run.xml:CONTINUE_RUN' is used to determine
+# the origin of the files.
 
-cd ${rundir}
-
+echo 'Copying the required files to the run directory.'
+echo 'No matter what, make sure the restart_time is set to the desired time.'
 echo ''
-echo 'Copying the required restart file from the staging directory.'
-echo 'With CONTINUE_RUN=FALSE, only a single file is required.'
+echo 'With CONTINUE_RUN=FALSE, the files are copied from the initial ensemble directory.'
+echo 'When CONTINUE_RUN=TRUE, the files are copied from the short-term archive restart directory.'
+echo 'If the short-term archiver is OFF, all the files are already in the RUN directory and'
+echo 'just the pointer files need to be updated.'
 echo ''
 
-if (( $SingleInstanceRefcase ))
-then
-   ${COPY} ${CLM_stagedir}/${run_refcase}.clm2.r.${run_refdate}-${run_reftod}.nc .
+cd ${caseroot}
+source ./Tools/ccsm_getenv || exit -2
+cd ${RUNDIR}
+
+set restart_time = $RUN_REFDATE-$RUN_REFTOD
+
+#----------------------------------------------------------------------
+# This block copies over a set of restart files from
+# this experiment and exits. Intended use to restart a failed run.
+#----------------------------------------------------------------------
+
+echo "continue_run is \$CONTINUE_RUN"
+
+if ( \$CONTINUE_RUN == TRUE ) then
+   if (  \$DOUT_S   == TRUE ) then
+
+      # the restarts should be in the short term archive directory
+      # www.cesm.ucar.edu/models/cesm1.1/cesm/doc/usersguide/x1631.html#running_ccsm_restart_back
+
+      ${COPY} \$DOUT_S_ROOT/rest/\${restart_time}/* . || exit -1
+
+   else
+
+      # All the required files must still be in the run directory.
+      # Just need to update the pointer files.
+      # The loop is just to make it similar to the multi-instance case. 
+
+      @ inst=1
+      while (\$inst <= 1)
+         set inst_string = ''
+         echo "${case}.cpl.r.\${restart_time}.nc"                   >! rpointer.drv
+         echo "${case}.clm2\${inst_string}.r.\${restart_time}.nc"   >! rpointer.lnd\${inst_string}
+         echo "${case}.datm\${inst_string}.r.\${restart_time}.nc"   >! rpointer.atm\${inst_string}
+         echo "${case}.datm\${inst_string}.rs1.\${restart_time}.nc" >> rpointer.atm\${inst_string}
+         @ inst ++
+      end
+
+   endif
+   exit 0
+endif
+
+#----------------------------------------------------------------------
+# This block prepares the initial run directory for a startup run.
+# CLM namelists specify a relative path for the initial file.
+#
+# The reference case may more instances than we need,
+# and it certainly has more files than we need.
+# This stages only the minimum number of instances and files.
+#
+# Remember - in a hybrid case - when CONTINUE_RUN = FALSE,
+# the run_refdate and the time in the filenames can be unrelated.
+#----------------------------------------------------------------------
+
+if ( $SingleInstanceRefcase ) then
+
+   ${LINK} ${CLM_stagedir}/${run_refcase}.clm2.r.${run_refdate}-${run_reftod}.nc .
+
 else
 
-   let inst=$TRUTHinstance
+   set inst_string = ''
+   set true_string = `printf _%04d $TRUTHinstance`
 
-   inst_string=\`printf _%04d \$inst\`
+   ${LINK} ${CLM_stagedir}/${run_refcase}.clm2\${true_string}.r.${run_refdate}-${run_reftod}.nc \
+                           ${run_refcase}.clm2\${inst_string}.r.${run_refdate}-${run_reftod}.nc
 
-   echo ''
-   echo "Staging restart for instance \$inst"
+endif
 
-   ${COPY} ${CLM_stagedir}/${run_refcase}.clm2\${inst_string}.r.${run_refdate}-${run_reftod}.nc \
-                           ${run_refcase}.clm2.r.${run_refdate}-${run_reftod}.nc
-fi
-
 exit 0
 
 EndOfText
-chmod 0755 stage_initial_cesm_files
+chmod 0755 stage_cesm_files
 
-./stage_initial_cesm_files
+./stage_cesm_files
 
 # ==============================================================================
 # build
@@ -750,20 +807,21 @@
 echo "3) If you want to create 'perfect obs' 'right away', configure and execute"
 echo "   the ${caseroot}/CESM_DART_config script."
 echo ""
-echo "3) Verify the contents of env_run.xml and submit the CESM job:"
+echo "4) Verify the contents of env_run.xml and submit the CESM job:"
 echo "   ./${case}.submit"
 echo ""
-echo "4) After the run finishes ... check the contents of the DART observation sequence file"
-echo "   ${archdir}/dart/hist/obs_seq.YYYY-MM-DD-SSSSS"
-echo "   to make sure there are good values in the file. (not -888888.)"
+echo "5) After the job has run, check to make sure it worked."
 echo ""
-echo "5) To extend the run in $assim_n '"$stop_option"' steps,"
+echo "6) To extend the run in $assim_n '"$stop_option"' steps,"
 echo "   change the env_run.xml variables:"
 echo ""
 echo "   ./xmlchange CONTINUE_RUN=TRUE"
 echo "   ./xmlchange RESUBMIT=<number_of_cycles_to_run>"
 echo "   ./xmlchange STOP_N=$assim_n"
 echo ""
+echo "   and"
+echo "   ./${case}.submit"
+echo ""
 echo "Check the streams listed in the streams text files.  If more or different"
 echo 'dates need to be added, then do this in the $CASEROOT/user_*files*'
 echo "then invoke 'preview_namelists' so you can check the information in the"

Modified: DART/trunk/models/clm/shell_scripts/CESM_DART_config
===================================================================
--- DART/trunk/models/clm/shell_scripts/CESM_DART_config	2013-10-25 20:46:12 UTC (rev 6550)
+++ DART/trunk/models/clm/shell_scripts/CESM_DART_config	2013-10-25 20:46:24 UTC (rev 6551)
@@ -294,6 +294,7 @@
 
 grep 'SUCCESSFUL TERMINATION' $CplLogFile
 if ( $status == 0 ) then
+
    ${CASEROOT}/DARTSCRIPTNAME
 
    if ( $status == 0 ) then
@@ -321,11 +322,13 @@
 # modify the "here" document to call the logical DART script.
 
 if ( $num_instances == 1 ) then
-   sed -e "s#DARTSCRIPTNAME#perfect_model.csh#" < temp.$$ >! add_to_run.txt
+   set DARTscript = perfect_model.csh
 else
-   sed -e "s#DARTSCRIPTNAME#assimilate.csh#" < temp.$$ >! add_to_run.txt
+   set DARTscript = assimilate.csh
 endif
 
+sed -e "s#DARTSCRIPTNAME#${DARTscript}#" < temp.$$ >! add_to_run.txt
+
 # Now that the "here" document is created,
 # determine WHERE to insert it -- ONLY IF it is not already there.
 
@@ -365,20 +368,41 @@
 # What to do next
 # ==============================================================================
 
-echo "Time to check the DART configuration:"
-echo ""
-echo "1) Modify what you need to in the DART namelists. These are "
-echo "   ${CASEROOT}/input.nml"
-echo ""
-echo "2) If you have recompiled any part of the DART system, 'refresh_dart_files'"
-echo "   will copy them into the correct places."
-echo ""
-echo "3) Make sure the observation directory names in assimilate.csh match"
-echo "   those on your system, and submit the CESM job in the normal way."
-echo ""
-echo "4) Inflation files? Observation files for the time of interest?"
-echo ""
 
+cat << EndOfText >! DART_instructions.txt
+
+-------------------------------------------------------------------------
+
+Check the DART configuration:
+
+1) The default behavior is to _not_ invoke DART and simply run CESM.
+   We recommend that you make sure this works before proceeding.
+
+2) When you want to run DART, make sure the ${CASE}.run script
+   references "$DARTscript".
+
+3) Modify what you need to in the DART namelist file, i.e. ${CASEROOT}/input.nml
+
+4) If you have recompiled any part of the DART system, 'refresh_dart_files'
+   will copy them into the correct places.
+
+5) If you stage your own inflation files, make sure you read the INFLATION section
+   in ${CASEROOT}/CESM_DART_config
+
+6) Make sure the observation directory names in $DARTscript match
+   those on your system.
+
+7) Submit the CESM job in the normal way.
+
+8) You can use ${CASEROOT}/stage_cesm_files
+    to stage files to restart a run.
+
+-------------------------------------------------------------------------
+
+EndOfText
+
+cat DART_instructions.txt
+
 exit 0
 
 # <next few lines under version control, do not edit>

Modified: DART/trunk/models/clm/shell_scripts/perfect_model.csh
===================================================================
--- DART/trunk/models/clm/shell_scripts/perfect_model.csh	2013-10-25 20:46:12 UTC (rev 6550)
+++ DART/trunk/models/clm/shell_scripts/perfect_model.csh	2013-10-25 20:46:24 UTC (rev 6551)
@@ -10,13 +10,13 @@
 # changes to this script such that the same script can be used
 # on multiple platforms. This will help us maintain the script.
 
-echo "`date` -- BEGIN GENERATE TRUE STATE"
+echo "`date` -- BEGIN GENERATE CLM TRUE STATE"
 
 set nonomatch       # suppress "rm" warnings if wildcard does not match anything
 
 # The FORCE options are not optional.
 # The VERBOSE options are useful for debugging though
-# some systems don't like the -v option to any of the following 
+# some systems don't like the -v option to any of the following
 switch ("`hostname`")
    case be*:
       # NCAR "bluefire"
@@ -93,7 +93,7 @@
 # Create temporary working directory for the assimilation and go there
 #-------------------------------------------------------------------------
 
-set temp_dir = assimilate_clm
+set temp_dir = pmo_clm
 echo "temp_dir is $temp_dir"
 
 if ( -d $temp_dir ) then
@@ -113,7 +113,7 @@
 # The only ugly part here is if the first advance and subsequent advances are
 # not the same length. The observations _may_ come from different directories.
 #
-# The contents of the file must match the history file contents if one is using 
+# The contents of the file must match the history file contents if one is using
 # the obs_def_tower_mod or could be the 'traditional' +/- 12Z ... or both.
 # Since the history file contains the previous days' history ... so must the obs file.
 #-----------------------------------------------------------------------------
@@ -127,7 +127,7 @@
 set OBS_FILE = ${BASEOBSDIR}/${OBSDIR}/obs_seq.${LND_DATE_EXT}
 
 if (  -e   ${OBS_FILE} ) then
-   ${COPY} ${OBS_FILE} obs_seq.in
+   ${LINK} ${OBS_FILE} obs_seq.in
 else
    echo "ERROR ... no observation file $OBS_FILE"
    echo "ERROR ... no observation file $OBS_FILE"
@@ -136,58 +136,54 @@
 
 #=========================================================================
 # Block 1: Populate a run-time directory with the input needed to run DART.
+#
+# DART namelist settings required:
+# &perfect_model_obs_nml:  restart_in_file_name    = 'perfect_ics'
+# &perfect_model_obs_nml:  obs_sequence_in_name    = 'obs_seq.in'
+# &perfect_model_obs_nml:  obs_sequence_out_name   = 'obs_seq.perfect'
+# &perfect_model_obs_nml:  init_time_days          = -1,
+# &perfect_model_obs_nml:  init_time_seconds       = -1,
+# &perfect_model_obs_nml:  first_obs_days          = -1,
+# &perfect_model_obs_nml:  first_obs_seconds       = -1,
+# &perfect_model_obs_nml:  last_obs_days           = -1,
+# &perfect_model_obs_nml:  last_obs_seconds        = -1,
+# &clm_to_dart_nml:        clm_to_dart_output_file = 'dart_ics'
+#
 #=========================================================================
 
-echo "`date` -- BEGIN COPY BLOCK"
-
-if (  -e   ${CASEROOT}/input.nml ) then
-   ${COPY} ${CASEROOT}/input.nml .
-else
+if ( ! -e ${CASEROOT}/input.nml ) then
    echo "ERROR ... DART required file ${CASEROOT}/input.nml not found ... ERROR"
    echo "ERROR ... DART required file ${CASEROOT}/input.nml not found ... ERROR"
    exit -2
 endif
 
-echo "`date` -- END COPY BLOCK"
+# DART/CLM routines all need a clm_restart.nc, clm_history.nc, etc.
+# The flux tower forward operator looks for a CLM history file with
+# an instance number in the filename.
 
-#=========================================================================
-# Block 2: convert 1 clm restart file to a DART initial conditions file.
-# At the end of the block, we have a DART restart file  perfect_ics
-# that came from the pointer file ../rpointer.lnd_0001
-#
-# DART namelist settings appropriate/required:
-# &perfect_model_obs_nml:  restart_in_file_name    = 'perfect_ics'
-# &clm_to_dart_nml:        clm_to_dart_output_file = 'dart_ics'
-#=========================================================================
+set  LND_RESTART_FILENAME = ${CASE}.clm2.r.${LND_DATE_EXT}.nc
+set  LND_HISTORY_FILENAME = ${CASE}.clm2.h0.${LND_DATE_EXT}.nc
+set OBS1_HISTORY_FILENAME = ${CASE}.clm2.h1.${LND_DATE_EXT}.nc
+set OBS2_HISTORY_FILENAME = ${CASE}.clm2_0001.h1.${LND_DATE_EXT}.nc
+set      DART_IC_FILENAME = perfect_ics
 
-echo "`date` -- BEGIN CLM-TO-DART"
+${LINK} ../$LND_RESTART_FILENAME clm_restart.nc
+${LINK} ../$LND_HISTORY_FILENAME clm_history.nc
 
-set member = 1
+if (  -e   ../$OBS1_HISTORY_FILENAME) then
+   ${LINK} ../$OBS1_HISTORY_FILENAME $OBS2_HISTORY_FILENAME
+endif
 
-   set MYTEMPDIR = member_${member}
-   mkdir -p $MYTEMPDIR
-   cd $MYTEMPDIR
+sed -e "s#dart_ics#${DART_IC_FILENAME}#" < ${CASEROOT}/input.nml >! input.nml
 
-   # make sure there are no old output logs hanging around
-   $REMOVE output.${member}.clm_to_dart
+#=========================================================================
+# Block 2: convert 1 clm restart file to a DART initial conditions file.
+# At the end of the block, we have a DART file "perfect_ics"
+# that came from the contents of the pointer file ../rpointer.lnd
+#=========================================================================
 
-   set  LND_RESTART_FILENAME = ${CASE}.clm2.r.${LND_DATE_EXT}.nc
-   set  LND_HISTORY_FILENAME = ${CASE}.clm2.h0.${LND_DATE_EXT}.nc
-   set OBS1_HISTORY_FILENAME = ${CASE}.clm2.h1.${LND_DATE_EXT}.nc
-   set OBS2_HISTORY_FILENAME = ${CASE}.clm2_0001.h1.${LND_DATE_EXT}.nc
-   set DART_IC_FILENAME = perfect_ics
-
-   sed -e "s/dart_ics/..\/${DART_IC_FILENAME}/" < ../input.nml >! input.nml
-
-   ${LINK} ../../$LND_RESTART_FILENAME clm_restart.nc
-   ${LINK} ../../$LND_HISTORY_FILENAME clm_history.nc
-
-   if (-e $OBS1_HISTORY_FILENAME) then
-      ${LINK} ../../$OBS1_HISTORY_FILENAME $OBS2_HISTORY_FILENAME
-   endif
-
-   # patch the CLM restart files to ensure they have the proper
-   # _FillValue and missing_value attributes.
+# patch the CLM restart files to ensure they have the proper
+# _FillValue and missing_value attributes.
 #  ncatted -O -a    _FillValue,frac_sno,o,d,1.0e+36   clm_restart.nc
 #  ncatted -O -a missing_value,frac_sno,o,d,1.0e+36   clm_restart.nc
 #  ncatted -O -a    _FillValue,DZSNO,o,d,1.0e+36      clm_restart.nc
@@ -199,67 +195,57 @@
 #  ncatted -O -a    _FillValue,T_SOISNO,o,d,1.0e+36   clm_restart.nc
 #  ncatted -O -a missing_value,T_SOISNO,o,d,1.0e+36   clm_restart.nc
 
-   ${EXEROOT}/clm_to_dart >! output.${member}.clm_to_dart
+echo "`date` -- BEGIN CLM-TO-DART"
 
-   if ($status != 0) then
-      echo "ERROR ... DART died in 'clm_to_dart' ... ERROR"
-      echo "ERROR ... DART died in 'clm_to_dart' ... ERROR"
-      exit -3
-   endif
+${EXEROOT}/clm_to_dart
 
-   cd ..
+if ($status != 0) then
+   echo "ERROR ... DART died in 'clm_to_dart' ... ERROR"
+   echo "ERROR ... DART died in 'clm_to_dart' ... ERROR"
+   exit -3
+endif
 
 echo "`date` -- END CLM-TO-DART"
 
 #=========================================================================
 # Block 3: Advance the model and harvest the synthetic observations.
-# Will result in a single file : 'perfect_restart' which we don't need
-# for a perfect model experiment with CESM.
-#
-# DART namelist settings required:
-# &perfect_model_obs_nml:           async                  = 0,
-# &perfect_model_obs_nml:           adv_ens_command        = "./no_model_advance.csh",
-# &perfect_model_obs_nml:           restart_in_file_name   = 'perfect_ics'
-# &perfect_model_obs_nml:           restart_out_file_name  = 'perfect_restart'
-# &perfect_model_obs_nml:           obs_sequence_in_name   = 'obs_seq.in'
-# &perfect_model_obs_nml:           obs_sequence_out_name  = 'obs_seq.out'
-# &perfect_model_obs_nml:           init_time_days         = -1,
-# &perfect_model_obs_nml:           init_time_seconds      = -1,
-# &perfect_model_obs_nml:           first_obs_days         = -1,
-# &perfect_model_obs_nml:           first_obs_seconds      = -1,
-# &perfect_model_obs_nml:           last_obs_days          = -1,
-# &perfect_model_obs_nml:           last_obs_seconds       = -1,
-#
+# output iles are:
+# True_state.nc   ...... the DART state
+# obs_seq.perfect ...... the synthetic observations
+# dart_log.out    ...... run-time output of all DART routines
+# perfect_restart ...... which we don't need
 #=========================================================================
 
-# clm always needs a clm_restart.nc, clm_history.nc for geometry information, etc.
+echo "`date` -- BEGIN PERFECT_MODEL_OBS"
 
-set LND_RESTART_FILENAME = ${CASE}.clm2.r.${LND_DATE_EXT}.nc
-set LND_HISTORY_FILENAME = ${CASE}.clm2.h0.${LND_DATE_EXT}.nc
+${EXEROOT}/perfect_model_obs
 
-${LINK} ../$LND_RESTART_FILENAME clm_restart.nc
-${LINK} ../$LND_HISTORY_FILENAME clm_history.nc
+if ($status != 0) then
+   echo "ERROR ... DART died in 'perfect_model_obs' ... ERROR"
+   echo "ERROR ... DART died in 'perfect_model_obs' ... ERROR"
+   exit -4
+endif
 
-echo "`date` -- BEGIN PERFECT_MODEL_OBS"
-${EXEROOT}/perfect_model_obs || exit -4
-echo "`date` -- END PERFECT_MODEL_OBS"
-
 ${MOVE} True_State.nc    ../clm_True_State.${LND_DATE_EXT}.nc
-${MOVE} obs_seq.out      ../obs_seq.${LND_DATE_EXT}.out
+${MOVE} obs_seq.perfect  ../clm_obs_seq.${LND_DATE_EXT}.perfect
 ${MOVE} dart_log.out     ../clm_dart_log.${LND_DATE_EXT}.out
 
+echo "`date` -- END PERFECT_MODEL_OBS"
+
 #=========================================================================
 # Block 4: Update the clm restart files.
 #=========================================================================
 
-# not needed ... perfect_model_obs does not update the model state.
+# not needed ... perfect_model_obs does not update the CLM model state.
 
 #-------------------------------------------------------------------------
 # Cleanup
 #-------------------------------------------------------------------------
 
-echo "`date` -- END   GENERATE TRUE STATE"
+${REMOVE} perfect_ics dart_log.nml
 
+echo "`date` -- END   GENERATE CLM TRUE STATE"
+
 exit 0
 
 # <next few lines under version control, do not edit>


More information about the Dart-dev mailing list