[Dart-dev] [6282] DART/trunk/models: Moved the 'cd to tempdir' to after the time determination

nancy at ucar.edu nancy at ucar.edu
Fri Jun 28 16:54:08 MDT 2013


Revision: 6282
Author:   thoar
Date:     2013-06-28 16:54:08 -0600 (Fri, 28 Jun 2013)
Log Message:
-----------
Moved the 'cd to tempdir' to after the time determination
which allows us to use the same relative filename for the
pointer file to use to determine the time. (in both the
CESM-flavor and individual model scripts)

Enabled the use of a cookie file for CAM startup to flag
the first model advance and possible creation of initial
inflation files so you don't have to have initial inflation
files before you startup - and can continue to have the
input.nml 'inf_initial_from_restart' TRUE for the entire 
experiment.

Set the configured ensemble size in the namelists that
are staged in the CASEROOT directory and removed it from
the assimilate.csh scripts. Less mysterious.

Modified Paths:
--------------
    DART/trunk/models/CESM/shell_scripts/CESM1_1_1_setup.csh
    DART/trunk/models/CESM/shell_scripts/CESM_setup_hybrid.csh
    DART/trunk/models/CESM/shell_scripts/CESM_setup_hybrid_from_prev_run.csh
    DART/trunk/models/CESM/shell_scripts/cam_assimilate.csh
    DART/trunk/models/CESM/shell_scripts/clm_assimilate.csh
    DART/trunk/models/CESM/shell_scripts/pop_assimilate.csh
    DART/trunk/models/POP/shell_scripts/CESM1_1_setup_hybrid.csh
    DART/trunk/models/POP/shell_scripts/assimilate.csh
    DART/trunk/models/cam/shell_scripts/CESM_setup_startup.csh
    DART/trunk/models/cam/shell_scripts/assimilate.csh
    DART/trunk/models/clm/shell_scripts/CESM1_1_setup.csh
    DART/trunk/models/clm/shell_scripts/assimilate.csh

-------------- next part --------------
Modified: DART/trunk/models/CESM/shell_scripts/CESM1_1_1_setup.csh
===================================================================
--- DART/trunk/models/CESM/shell_scripts/CESM1_1_1_setup.csh	2013-06-28 21:30:36 UTC (rev 6281)
+++ DART/trunk/models/CESM/shell_scripts/CESM1_1_1_setup.csh	2013-06-28 22:54:08 UTC (rev 6282)
@@ -97,7 +97,7 @@
 setenv rundir       /glade/scratch/${USER}/${case}/run
 setenv archdir      /glade/scratch/${USER}/archive/${case}
 
-setenv DARTroot     /glade/u/home/${USER}/svn/DART/dev
+setenv DARTroot     /glade/u/home/${USER}/svn/DART/trunk
 
 set RTM_stagedir = /glade/scratch/thoar/DART_POP_RESTARTS/2004-01-01-00000
 set CLM_stagedir = /glade/scratch/thoar/DART_POP_RESTARTS/CLM_2004-01-01-00000/cesm_test
@@ -126,6 +126,8 @@
 setenv stop_option   nhours
 setenv stop_n        72
 setenv assim_n       24
+setenv short_term_archiver on
+setenv long_term_archiver  off
 
 # ==============================================================================
 # job settings
@@ -149,7 +151,7 @@
 
 # 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"
@@ -173,6 +175,16 @@
 # some simple error checking before diving into the work
 # ==============================================================================
 
+# fatal idea to make caseroot the same dir as where this setup script is
+# since the build process removes all files in the caseroot dir before
+# populating it.  try to prevent shooting yourself in the foot.
+if ( $caseroot == `dirname $0` ) then
+   echo "ERROR: the setup script should not be located in the caseroot"
+   echo "directory, because all files in the caseroot dir will be removed"
+   echo "before creating the new case.  move the script to a safer place."
+   exit -1
+endif
+
 # make sure these directories exist
 set musthavedirs = "cesm_datadir cesmroot DARTroot"
 foreach VAR ( $musthavedirs )
@@ -185,16 +197,22 @@
    endif
 end
 
-# make sure there is a filter in these dirs
-set musthavefiles = "cam POP clm"
+# make sure there is a filter in these dirs.   try to build
+# them if we can't find filter already built for each model.
+set musthavefiles = "cam POP clm CESM"
 foreach MODEL ( $musthavefiles )
-   set target = $DARTroot/models/$MODEL/work/filter
-   if ( ! -x $target ) then
-      echo "ERROR: executable file 'filter' not found"
-      echo " Looking for: $target "
-      echo " Make sure all DART assimilation executables have "
-      echo " been compiled before running this setup script."
-      exit -1
+   set targetdir = $DARTroot/models/$MODEL/work
+   if ( ! -x $targetdir/filter ) then
+      echo "WARNING: executable file 'filter' not found"
+      echo " Looking for: $targetdir/filter "
+      echo " Trying to rebuild all model files now."
+      (cd $targetdir; ./quickbuild.csh -mpi)
+      if ( ! -x $targetdir/filter ) then
+         echo "ERROR: executable file 'filter' not found"
+         echo " Unsuccessfully tried to rebuild: $targetdir/filter "
+         echo " Required DART assimilation executables are not found "
+         exit -1
+      endif
    endif
 end
 
@@ -233,6 +251,8 @@
    endif
 end
 
+if ( $num_instances < 10) then
+
    # This is only for the purpose of debugging the code.
    # A more efficient layout must be found
    @ atm_pes = $ptile * $num_instances * 4
@@ -243,9 +263,21 @@
    @ rof_pes = $ptile * $num_instances
    @ cpl_pes = $ptile * 4
 
-   @ glc_root = $lnd_pes + $ice_pes
-   @ rof_root = $lnd_pes + $ice_pes + $glc_pes
+else
 
+   # This is only for the purpose of debugging the code.
+   # A more efficient layout must be found
+   #
+   @ atm_pes = $ptile * $num_instances * 2
+   @ ocn_pes = $ptile * $num_instances * 2
+   @ lnd_pes = $ptile * $num_instances * 2
+   @ ice_pes = $ptile * $num_instances
+   @ glc_pes = $ptile * $num_instances
+   @ rof_pes = $ptile * $num_instances
+   @ cpl_pes = $ptile * $num_instances
+
+endif
+
 #echo "task partitioning ... atm+ocn // lnd+ice+glc+rof"
 echo ""
 echo "ATM  gets $atm_pes"
@@ -257,16 +289,6 @@
 echo "OCN  gets $ocn_pes"
 echo ""
 
-#   total number of hw pes = 240
-#   cpl hw pe range ~ from 0 to 59
-#   cam hw pe range ~ from 0 to 119
-#   pop2 hw pe range ~ from 120 to 239
-#   clm hw pe range ~ from 0 to 59
-#   cice hw pe range ~ from 60 to 89
-#   sglc hw pe range ~ from 90 to 119
-#   rtm hw pe range ~ from 120 to 149
-#   TJH FIXME ... CLM could use a lot more processors.
-
 ./xmlchange NTHRDS_CPL=1,NTASKS_CPL=$cpl_pes
 ./xmlchange NTHRDS_GLC=1,NTASKS_GLC=$glc_pes,NINST_GLC=1
 ./xmlchange NTHRDS_ATM=1,NTASKS_ATM=$atm_pes,NINST_ATM=$num_instances
@@ -314,18 +336,27 @@
 
 ./xmlchange CLM_CONFIG_OPTS='-bgc cn'
 
-./xmlchange DOUT_S=FALSE
-./xmlchange DOUT_S_ROOT=${archdir}
-./xmlchange DOUT_S_SAVE_INT_REST_FILES=FALSE
-./xmlchange DOUT_L_MS=FALSE
-./xmlchange DOUT_L_MSROOT="csm/${case}"
-./xmlchange DOUT_L_HTAR=FALSE
+if ($short_term_archiver == 'off') then
+   ./xmlchange DOUT_S=FALSE
+else
+   ./xmlchange DOUT_S=TRUE
+   ./xmlchange DOUT_S_ROOT=${archdir}
+   ./xmlchange DOUT_S_SAVE_INT_REST_FILES=FALSE
+endif
+if ($long_term_archiver == 'off') then
+   ./xmlchange DOUT_L_MS=FALSE
+else
+   ./xmlchange DOUT_L_MS=TRUE
+   ./xmlchange DOUT_L_MSROOT="csm/${case}"
+   ./xmlchange DOUT_L_HTAR=FALSE
+endif
 
 # level of debug output, 0=minimum, 1=normal, 2=more, 3=too much, valid values: 0,1,2,3 (integer)
 
 ./xmlchange DEBUG=FALSE
 ./xmlchange INFO_DBUG=0
 
+
 # ==============================================================================
 # Set up the case.
 # This creates the EXEROOT and RUNDIR directories.
@@ -352,7 +383,7 @@
    set fname = "user_nl_cam_${instance}"
    # ===========================================================================
    # For a HOP TEST ... empty_htapes = .false.
-   # For a HOP TEST ... use a default fincl1 
+   # For a HOP TEST ... use a default fincl1
 
    echo " inithist      = 'DAILY'"                      >> ${fname}
    echo " ncdata        = 'cam_initial_${instance}.nc'" >> ${fname}
@@ -377,29 +408,31 @@
    set fname = "user_nl_cice_${instance}"
    # ===========================================================================
    # CICE Namelists
-   
+
    echo "ice_ic = 'b40.20th.005_ens${instance2}.cice.r.2004-01-01-00000.nc'" >> $fname
 
    # ===========================================================================
    set fname = "user_nl_clm_${instance}"
    # ===========================================================================
-   
+
    # Customize the land namelists
    # The history tapes are a work in progress. If you write out the instantaneous
    # flux variables every 30 minutes to the .h1. file, the forward observation
    # operators for these fluxes should just read them from the .h1. file rather
    # than trying to create them from the (incomplete DART) CLM state.
    # For a HOP TEST ... hist_empty_htapes = .false.
-   # For a HOP TEST ... use a default hist_fincl1 
+   # For a HOP TEST ... use a default hist_fincl1
    #
    # old ... stagedir = /glade/scratch/afox/bptmp/MD_40_PME/run/MD_40_PME
 
+   @ thirtymin = $assim_n * 2
+
    echo "finidat = '${CLM_stagedir}.clm2_${instance}.r.${run_refdate}-${run_reftod}.nc'" >> $fname
    echo "hist_empty_htapes = .true."                 >> $fname
    echo "hist_fincl1 = 'NEP'"                        >> $fname
    echo "hist_fincl2 = 'NEP','FSH','EFLX_LH_TOT_R'"  >> $fname
    echo "hist_nhtfrq = -$assim_n,1,"                 >> $fname
-   echo "hist_mfilt  = 1,48"                         >> $fname
+   echo "hist_mfilt  = 1,$thirtymin"                 >> $fname
    echo "hist_avgflag_pertape = 'A','A'"             >> $fname
 
    # ===========================================================================
@@ -428,7 +461,7 @@
 else
    echo "ERROR - No SourceMods for this case."
    echo "ERROR - No SourceMods for this case."
-   echo "DART requires modifications to several src.pop2/ files."
+   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 "untar these into your HOME directory - they will create a"
@@ -473,7 +506,6 @@
    echo "Staging restarts for instance $inst of $num_instances"
 
    ${LINK} ${CAM_stagedir}/cami-mam3_0000-01-01_0.9x1.25_L30_c100618.nc      cam_initial_${n4}.nc
-
    ${LINK} ${POP_stagedir}/b40.20th.005_ens${n2}.pop.r.2004-01-01-00000      .
    ${LINK} ${POP_stagedir}/b40.20th.005_ens${n2}.pop.r.2004-01-01-00000.hdr  .
    ${LINK} ${POP_stagedir}/b40.20th.005_ens${n2}.cice.r.2004-01-01-00000.nc  .
@@ -543,21 +575,21 @@
    echo 'ERROR: Model did not complete - no cpl.log file present - exiting.'
    echo 'ERROR: Assimilation will not be attempted.'
    setenv LSB_PJL_TASK_GEOMETRY "{(0)}"
-   setenv EXITCODE -1 
+   setenv EXITCODE -1
    mpirun.lsf ${CASEROOT}/shell_exit.sh
    exit -1
 endif
 
 grep 'SUCCESSFUL TERMINATION' $CplLogFile
 if ( $status == 0 ) then
-#  ${CASEROOT}/assimilate.csh
+   ${CASEROOT}/assimilate.csh
 
    if ( $status == 0 ) then
       echo "`date` -- DART HAS FINISHED"
    else
       echo "`date` -- DART FILTER ERROR - ABANDON HOPE"
       setenv LSB_PJL_TASK_GEOMETRY "{(0)}"
-      setenv EXITCODE -3 
+      setenv EXITCODE -3
       mpirun.lsf ${CASEROOT}/shell_exit.sh
       exit -3
    endif
@@ -565,7 +597,7 @@
    echo 'ERROR: Model did not complete successfully - exiting.'
    echo 'ERROR: Assimilation will not be attempted.'
    setenv LSB_PJL_TASK_GEOMETRY "{(0)}"
-   setenv EXITCODE -2 
+   setenv EXITCODE -2
    mpirun.lsf ${CASEROOT}/shell_exit.sh
    exit -2
 endif
@@ -635,7 +667,6 @@
 ${COPY} ${DARTroot}/models/cam/work/cam_to_dart   ${exeroot}/.
 ${COPY} ${DARTroot}/models/cam/work/dart_to_cam   ${exeroot}/.
 ${COPY} ${DARTroot}/models/cam/work/filter        ${exeroot}/filter_cam
-${COPY} ${DARTroot}/models/cam/work/filter        ${exeroot}/filter
 ${COPY} ${DARTroot}/models/cam/work/input.nml                cam_input.nml
 
 ${COPY} ${DARTroot}/models/clm/work/clm_to_dart   ${exeroot}/.
@@ -653,37 +684,89 @@
 ${COPY} ${DARTroot}/models/CESM/work/filter       ${exeroot}/filter_cesm
 ${COPY} ${DARTroot}/models/CESM/work/input.nml               input.nml
 
+# Ensure that the input.nml ensemble size matches the number of instances.
+# WARNING: the output files contain ALL ensemble members ==> BIG
+
+ex cam_input.nml <<ex_end
+g;ens_size ;s;= .*;= $num_instances;
+g;num_output_state_members ;s;= .*;= $num_instances;
+g;num_output_obs_members ;s;= .*;= $num_instances;
+wq
+ex_end
+
+ex clm_input.nml <<ex_end
+g;ens_size ;s;= .*;= $num_instances;
+g;num_output_state_members ;s;= .*;= $num_instances;
+g;num_output_obs_members ;s;= .*;= $num_instances;
+g;casename ;s;= .*;= "../$case",;
+wq
+ex_end
+
+# num_output_state_members intentionally not set for POP.
+ex pop_input.nml <<ex_end
+g;ens_size ;s;= .*;= $num_instances;
+g;num_output_obs_members ;s;= .*;= $num_instances;
+wq
+ex_end
+
+ex input.nml <<ex_end
+g;ens_size ;s;= .*;= $num_instances;
+g;num_output_state_members ;s;= .*;= $num_instances;
+g;num_output_obs_members ;s;= .*;= $num_instances;
+wq
+ex_end
+
 # ==============================================================================
+# Initial setup for the default inflation scenario.
+# ==============================================================================
+# CAM usually uses adaptive state-space prior inflation. The initial settings
+# are in the filter_nml and ... during an assimilation experiment, the output
+# from one assimilation is the input for the next. To facilitate this operationally,
+# it is useful to specify an initial file of inflation values for the first
+# assimilation step. However, I can think of no general way to do this. The
+# utility that creates the initial inflation values (fill_inflation_restart)
+# needs the model size from model_mod. To get that, CAM needs a 'cam_phis.nc'
+# file which we generally don't have at this stage of the game (it exists after
+# a model advance). So ... until I think of something better ... I am making a
+# cookie file that indicates this is the very first assimilation. If this
+# cookie file exists, the assimilate.csh script will make the inflation restart
+# file before it performs the assimilation. After the first assimilation takes
+# place, the cookie file must be 'eaten' so that subsequent assimilations do not
+# overwrite whatever _should_ be there.
+
+date >! ${rundir}/make_cam_inflation_cookie
+
+# ==============================================================================
 # What to do next
 # ==============================================================================
 
-echo ''
+echo ""
 echo "Time to check the case."
-echo ''
+echo ""
 echo "cd into ${caseroot}"
 echo "Modify what you like in input.nml, make sure the observation directory"
 echo "names set in assimilate.csh match those on your system, and submit"
 echo "the CESM job by running:"
 echo "./${case}.submit"
-echo ''
+echo ""
 echo "For continued submissions after the initial (hybrid) startup,"
 echo "make the following changes to the env_run variables:"
-echo ''
-echo "  ./xmlchange -file env_run.xml -id STOP_N        -val 24"
-echo "  ./xmlchange -file env_run.xml -id CONTINUE_RUN  -val TRUE"
-echo "  ./xmlchange -file env_run.xml -id RESUBMIT      -val <your_favorite_number>"
-echo ''
+echo ""
+echo "  ./xmlchange CONTINUE_RUN=TRUE"
+echo "  ./xmlchange RESUBMIT=<your_favorite_number>"
+echo "  ./xmlchange STOP_N=$assim_n"
+echo ""
 echo "Once you get to 2004-01-04, there are more things to do ... "
-echo "in the CASEROOT directory, uncomment the ncdata in the user_nl_cam* files ..."
+echo 'in the CASEROOT directory, uncomment the ncdata in the user_nl_cam* files ...'
 echo "ncdata       = 'cam_initial_${instance}.nc'" >> ${fname}
 echo "in the run directory, link the current cam initial files ..."
 echo "make sure the history tapes for cam,clm are being created at the right frequency"
-echo ''
+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"
 echo "CaseDocs or ${rundir} directories."
-echo ''
+echo ""
 
 exit 0
 

Modified: DART/trunk/models/CESM/shell_scripts/CESM_setup_hybrid.csh
===================================================================
--- DART/trunk/models/CESM/shell_scripts/CESM_setup_hybrid.csh	2013-06-28 21:30:36 UTC (rev 6281)
+++ DART/trunk/models/CESM/shell_scripts/CESM_setup_hybrid.csh	2013-06-28 22:54:08 UTC (rev 6282)
@@ -64,7 +64,7 @@
 #    script names; so consider it's length and information content.
 # num_instances:  Number of ensemble members
 
-setenv case                 cesm_hybrid
+setenv case                 cesm_standard
 setenv compset              B_2000_CAM5
 setenv resolution           0.9x1.25_gx1v6
 setenv cesmtag              cesm1_1_1
@@ -97,7 +97,7 @@
 setenv rundir       /glade/scratch/${USER}/${case}/run
 setenv archdir      /glade/scratch/${USER}/archive/${case}
 
-setenv DARTroot     /glade/u/home/${USER}/svn/DART/dev
+setenv DARTroot     /glade/u/home/${USER}/svn/DART/trunk
 
 set RTM_stagedir = /glade/scratch/thoar/DART_POP_RESTARTS/2004-01-01-00000
 set CLM_stagedir = /glade/scratch/thoar/DART_POP_RESTARTS/CLM_2004-01-01-00000/cesm_test
@@ -126,6 +126,8 @@
 setenv stop_option   nhours
 setenv stop_n        72
 setenv assim_n       24
+setenv short_term_archiver on
+setenv long_term_archiver  off
 
 # ==============================================================================
 # job settings
@@ -137,8 +139,8 @@
 # ==============================================================================
 
 setenv ACCOUNT      P8685nnnn
-setenv timewall     0:30
-setenv queue        regular
+setenv timewall     0:50
+setenv queue        economy
 setenv ptile        15
 
 # ==============================================================================
@@ -149,7 +151,7 @@
 
 # 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"
@@ -173,6 +175,16 @@
 # some simple error checking before diving into the work
 # ==============================================================================
 
+# fatal idea to make caseroot the same dir as where this setup script is
+# since the build process removes all files in the caseroot dir before
+# populating it.  try to prevent shooting yourself in the foot.
+if ( $caseroot == `dirname $0` ) then
+   echo "ERROR: the setup script should not be located in the caseroot"
+   echo "directory, because all files in the caseroot dir will be removed"
+   echo "before creating the new case.  move the script to a safer place."
+   exit -1
+endif
+
 # make sure these directories exist
 set musthavedirs = "cesm_datadir cesmroot DARTroot"
 foreach VAR ( $musthavedirs )
@@ -185,16 +197,22 @@
    endif
 end
 
-# make sure there is a filter in these dirs
-set musthavefiles = "cam POP clm"
+# make sure there is a filter in these dirs.   try to build
+# them if we can't find filter already built for each model.
+set musthavefiles = "cam POP clm CESM"
 foreach MODEL ( $musthavefiles )
-   set target = $DARTroot/models/$MODEL/work/filter
-   if ( ! -x $target ) then
-      echo "ERROR: executable file 'filter' not found"
-      echo " Looking for: $target "
-      echo " Make sure all DART assimilation executables have "
-      echo " been compiled before running this setup script."
-      exit -1
+   set targetdir = $DARTroot/models/$MODEL/work
+   if ( ! -x $targetdir/filter ) then
+      echo "WARNING: executable file 'filter' not found"
+      echo " Looking for: $targetdir/filter "
+      echo " Trying to rebuild all model files now."
+      (cd $targetdir; ./quickbuild.csh -mpi)
+      if ( ! -x $targetdir/filter ) then
+         echo "ERROR: executable file 'filter' not found"
+         echo " Unsuccessfully tried to rebuild: $targetdir/filter "
+         echo " Required DART assimilation executables are not found "
+         exit -1
+      endif
    endif
 end
 
@@ -318,18 +336,27 @@
 
 ./xmlchange CLM_CONFIG_OPTS='-bgc cn'
 
-./xmlchange DOUT_S=TRUE
-./xmlchange DOUT_S_ROOT=${archdir}
-./xmlchange DOUT_S_SAVE_INT_REST_FILES=FALSE
-./xmlchange DOUT_L_MS=FALSE
-./xmlchange DOUT_L_MSROOT="csm/${case}"
-./xmlchange DOUT_L_HTAR=FALSE
+if ($short_term_archiver == 'off') then
+   ./xmlchange DOUT_S=FALSE
+else
+   ./xmlchange DOUT_S=TRUE
+   ./xmlchange DOUT_S_ROOT=${archdir}
+   ./xmlchange DOUT_S_SAVE_INT_REST_FILES=FALSE
+endif
+if ($long_term_archiver == 'off') then
+   ./xmlchange DOUT_L_MS=FALSE
+else
+   ./xmlchange DOUT_L_MS=TRUE
+   ./xmlchange DOUT_L_MSROOT="csm/${case}"
+   ./xmlchange DOUT_L_HTAR=FALSE
+endif
 
 # level of debug output, 0=minimum, 1=normal, 2=more, 3=too much, valid values: 0,1,2,3 (integer)
 
 ./xmlchange DEBUG=FALSE
 ./xmlchange INFO_DBUG=0
 
+
 # ==============================================================================
 # Set up the case.
 # This creates the EXEROOT and RUNDIR directories.
@@ -356,7 +383,7 @@
    set fname = "user_nl_cam_${instance}"
    # ===========================================================================
    # For a HOP TEST ... empty_htapes = .false.
-   # For a HOP TEST ... use a default fincl1 
+   # For a HOP TEST ... use a default fincl1
 
    echo " inithist      = 'DAILY'"                      >> ${fname}
    echo " ncdata        = 'cam_initial_${instance}.nc'" >> ${fname}
@@ -372,8 +399,8 @@
    # POP Namelists
    # init_ts_suboption = 'data_assim'   for non bit-for-bit restarting (assimilation mode)
    # init_ts_suboption = 'rest'         for
-   # init_ts_suboption = 'spunup'       for 
-   # init_ts_suboption = 'null'         for 
+   # init_ts_suboption = 'spunup'       for
+   # init_ts_suboption = 'null'         for
    # For a HOP TEST (untested)... tavg_file_freq_opt = 'nmonth' 'nday' 'once'"
    # For a HOP TEST ... cool to have restart files every day, not just for end.
 
@@ -383,29 +410,31 @@
    set fname = "user_nl_cice_${instance}"
    # ===========================================================================
    # CICE Namelists
-   
+
    echo "ice_ic = 'b40.20th.005_ens${instance2}.cice.r.2004-01-01-00000.nc'" >> $fname
 
    # ===========================================================================
    set fname = "user_nl_clm_${instance}"
    # ===========================================================================
-   
+
    # Customize the land namelists
    # The history tapes are a work in progress. If you write out the instantaneous
    # flux variables every 30 minutes to the .h1. file, the forward observation
    # operators for these fluxes should just read them from the .h1. file rather
    # than trying to create them from the (incomplete DART) CLM state.
    # For a HOP TEST ... hist_empty_htapes = .false.
-   # For a HOP TEST ... use a default hist_fincl1 
+   # For a HOP TEST ... use a default hist_fincl1
    #
 #  set CLM_stagedir = /glade/scratch/afox/bptmp/MD_40_PME/run/MD_40_PME
 
+   @ thirtymin = $assim_n * 2
+
    echo "finidat = '${CLM_stagedir}.clm2_${instance}.r.${run_refdate}-${run_reftod}.nc'" >> $fname
    echo "hist_empty_htapes = .true."                 >> $fname
    echo "hist_fincl1 = 'NEP'"                        >> $fname
    echo "hist_fincl2 = 'NEP','FSH','EFLX_LH_TOT_R'"  >> $fname
    echo "hist_nhtfrq = -$assim_n,1,"                 >> $fname
-   echo "hist_mfilt  = 1,48"                         >> $fname
+   echo "hist_mfilt  = 1,$thirtymin"                 >> $fname
    echo "hist_avgflag_pertape = 'A','A'"             >> $fname
 
    # ===========================================================================
@@ -418,6 +447,10 @@
    @ inst ++
 end
 
+# This is expected to fail at the CLM stage (until clm.buildnml.csh is fixed)
+# "build-namelist ERROR:: Can NOT set both -clm_startfile option AND finidat on namelist"
+# problem is ... I need to specify finidat.
+
 ./preview_namelists
 
 # ==============================================================================
@@ -434,7 +467,7 @@
 else
    echo "ERROR - No SourceMods for this case."
    echo "ERROR - No SourceMods for this case."
-   echo "DART requires modifications to several src.pop2/ files."
+   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 "untar these into your HOME directory - they will create a"
@@ -470,7 +503,7 @@
 echo 'into the CESM run directory and creating the pointer files.'
 echo ''
 
-# TJH FIXME ... simply put full path in the pointer file? traceability? 
+# TJH FIXME ... simply put full path in the pointer file? traceability?
 # TJH FIXME ... what do we do with the *.hdr file
 # After a run completes, the 'normal' pointer files created are:
 # rpointer.drv
@@ -566,7 +599,7 @@
    echo 'ERROR: Model did not complete - no cpl.log file present - exiting.'
    echo 'ERROR: Assimilation will not be attempted.'
    setenv LSB_PJL_TASK_GEOMETRY "{(0)}"
-   setenv EXITCODE -1 
+   setenv EXITCODE -1
    mpirun.lsf ${CASEROOT}/shell_exit.sh
    exit -1
 endif
@@ -580,7 +613,7 @@
    else
       echo "`date` -- DART FILTER ERROR - ABANDON HOPE"
       setenv LSB_PJL_TASK_GEOMETRY "{(0)}"
-      setenv EXITCODE -3 
+      setenv EXITCODE -3
       mpirun.lsf ${CASEROOT}/shell_exit.sh
       exit -3
    endif
@@ -588,7 +621,7 @@
    echo 'ERROR: Model did not complete successfully - exiting.'
    echo 'ERROR: Assimilation will not be attempted.'
    setenv LSB_PJL_TASK_GEOMETRY "{(0)}"
-   setenv EXITCODE -2 
+   setenv EXITCODE -2
    mpirun.lsf ${CASEROOT}/shell_exit.sh
    exit -2
 endif
@@ -658,7 +691,6 @@
 ${COPY} ${DARTroot}/models/cam/work/cam_to_dart   ${exeroot}/.
 ${COPY} ${DARTroot}/models/cam/work/dart_to_cam   ${exeroot}/.
 ${COPY} ${DARTroot}/models/cam/work/filter        ${exeroot}/filter_cam
-${COPY} ${DARTroot}/models/cam/work/filter        ${exeroot}/filter
 ${COPY} ${DARTroot}/models/cam/work/input.nml                cam_input.nml
 
 ${COPY} ${DARTroot}/models/clm/work/clm_to_dart   ${exeroot}/.
@@ -676,40 +708,86 @@
 ${COPY} ${DARTroot}/models/CESM/work/filter       ${exeroot}/filter_cesm
 ${COPY} ${DARTroot}/models/CESM/work/input.nml               input.nml
 
+# Ensure that the input.nml ensemble size matches the number of instances.
+# WARNING: the output files contain ALL ensemble members ==> BIG
+
+ex cam_input.nml <<ex_end
+g;ens_size ;s;= .*;= $num_instances;
+g;num_output_state_members ;s;= .*;= $num_instances;
+g;num_output_obs_members ;s;= .*;= $num_instances;
+wq
+ex_end
+
+ex clm_input.nml <<ex_end
+g;ens_size ;s;= .*;= $num_instances;
+g;num_output_state_members ;s;= .*;= $num_instances;
+g;num_output_obs_members ;s;= .*;= $num_instances;
+g;casename ;s;= .*;= "../$case",;
+wq
+ex_end
+
+# num_output_state_members intentionally not set for POP.
+ex pop_input.nml <<ex_end
+g;ens_size ;s;= .*;= $num_instances;
+g;num_output_obs_members ;s;= .*;= $num_instances;
+wq
+ex_end
+
+ex input.nml <<ex_end
+g;ens_size ;s;= .*;= $num_instances;
+g;num_output_state_members ;s;= .*;= $num_instances;
+g;num_output_obs_members ;s;= .*;= $num_instances;
+wq
+ex_end
+
 # ==============================================================================
+# Initial setup for the default inflation scenario.
+# ==============================================================================
+# CAM usually uses adaptive state-space prior inflation. The initial settings
+# are in the filter_nml and ... during an assimilation experiment, the output
+# from one assimilation is the input for the next. To facilitate this operationally,
+# it is useful to specify an initial file of inflation values for the first
+# assimilation step. However, I can think of no general way to do this. The
+# utility that creates the initial inflation values (fill_inflation_restart)
+# needs the model size from model_mod. To get that, CAM needs a 'cam_phis.nc'
+# file which we generally don't have at this stage of the game (it exists after
+# a model advance). So ... until I think of something better ... I am making a
+# cookie file that indicates this is the very first assimilation. If this
+# cookie file exists, the assimilate.csh script will make the inflation restart
+# file before it performs the assimilation. After the first assimilation takes
+# place, the cookie file must be 'eaten' so that subsequent assimilations do not
+# overwrite whatever _should_ be there.
+
+date >! ${rundir}/make_cam_inflation_cookie
+
+# ==============================================================================
 # What to do next
 # ==============================================================================
 
-echo ''
+echo ""
 echo "Time to check the case."
-echo ''
+echo ""
 echo "cd into ${caseroot}"
 echo "1) edit ${caseroot}/Buildconf/clm.buildnml.csh ... remove 'hybrid' portion of line 86"
 echo "2) edit ${caseroot}/Buildconf/rtm.buildnml.csh ... comment out line 36"
-echo ''
+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"
+echo "CaseDocs or ${rundir} directories."
+echo ""
 echo "Modify what you like in input.nml, make sure the observation directory"
 echo "names set in assimilate.csh match those on your system, and submit"
 echo "the CESM job by running:"
 echo "./${case}.submit"
-echo ''
+echo ""
 echo "For continued submissions after the initial (hybrid) startup,"
 echo "make the following changes to the env_run variables:"
-echo ''
-echo "  ./xmlchange -file env_run.xml -id STOP_N        -val 24"
-echo "  ./xmlchange -file env_run.xml -id CONTINUE_RUN  -val TRUE"
-echo "  ./xmlchange -file env_run.xml -id RESUBMIT      -val <your_favorite_number>"
-echo ''
-echo "Once you get to 2004-01-04, there are more things to do ... "
-echo "in the CASEROOT directory, uncomment the ncdata in the user_nl_cam* files ..."
-echo "ncdata       = 'cam_initial_${instance}.nc'" >> ${fname}
-echo "in the run directory, link the current cam initial files ..."
-echo "make sure the history tapes for cam,clm are being created at the right frequency"
-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"
-echo "CaseDocs or ${rundir} directories."
-echo ''
+echo ""
+echo "  ./xmlchange CONTINUE_RUN=TRUE"
+echo "  ./xmlchange RESUBMIT=<your_favorite_number>"
+echo "  ./xmlchange STOP_N=$assim_n"
+echo ""
 
 exit 0
 

Modified: DART/trunk/models/CESM/shell_scripts/CESM_setup_hybrid_from_prev_run.csh
===================================================================
--- DART/trunk/models/CESM/shell_scripts/CESM_setup_hybrid_from_prev_run.csh	2013-06-28 21:30:36 UTC (rev 6281)
+++ DART/trunk/models/CESM/shell_scripts/CESM_setup_hybrid_from_prev_run.csh	2013-06-28 22:54:08 UTC (rev 6282)
@@ -106,9 +106,8 @@
 setenv rundir       /glade/scratch/${USER}/${case}/run
 setenv archdir      /glade/scratch/${USER}/archive/${case}
 
-setenv DARTroot     /glade/u/home/${USER}/DART/
+setenv DARTroot     /glade/u/home/${USER}/DART
 
-
 # start a hybrid run off of tim's existing run
 set stagedir = /glade/scratch/thoar/archive/cesm_hybrid/rest/2004-01-10-00000
 
@@ -162,7 +161,7 @@
 
 # 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"
@@ -210,7 +209,7 @@
 
 # make sure there is a filter in these dirs.   try to build
 # them if we can't find filter already built for each model.
-set musthavefiles = "cam POP clm"
+set musthavefiles = "cam POP clm CESM"
 foreach MODEL ( $musthavefiles )
    set targetdir = $DARTroot/models/$MODEL/work
    if ( ! -x $targetdir/filter ) then
@@ -346,7 +345,7 @@
 ./xmlchange RESUBMIT=0
 ./xmlchange PIO_TYPENAME=pnetcdf
 
-# this is to set the ocean coupling time to 6 hours.  
+# this is to set the ocean coupling time to 6 hours.
 # it should set all other related namelists based on
 # this setting.
 ./xmlchange OCN_NCPL=4
@@ -410,7 +409,7 @@
    set fname = "user_nl_cam${instance}"
    # ===========================================================================
    # For a HOP TEST ... empty_htapes = .false.
-   # For a HOP TEST ... use a default fincl1 
+   # For a HOP TEST ... use a default fincl1
 
    echo " inithist      = '6-HOURLY'"                   >> $fname
    echo " ncdata        = 'cam_initial${instance}.nc'"  >> $fname
@@ -437,20 +436,20 @@
    set fname = "user_nl_cice${instance}"
    # ===========================================================================
    # CICE Namelists
-   
+
    echo "ice_ic = '${refcase}.cice${instance}.r.${run_refdate}-${run_reftod}.nc'" >> $fname
 
    # ===========================================================================
    set fname = "user_nl_clm${instance}"
    # ===========================================================================
-   
+
    # Customize the land namelists
    # The history tapes are a work in progress. If you write out the instantaneous
    # flux variables every 30 minutes to the .h1. file, the forward observation
    # operators for these fluxes should just read them from the .h1. file rather
    # than trying to create them from the (incomplete DART) CLM state.
    # For a HOP TEST ... hist_empty_htapes = .false.
-   # For a HOP TEST ... use a default hist_fincl1 
+   # For a HOP TEST ... use a default hist_fincl1
    #
    @ thirtymin = $assim_n * 2
 
@@ -458,7 +457,7 @@
    echo "hist_empty_htapes = .true."                 >> $fname
    echo "hist_fincl1 = 'NEP'"                        >> $fname
    echo "hist_fincl2 = 'NEP','FSH','EFLX_LH_TOT_R'"  >> $fname
-   echo "hist_nhtfrq = -$assim_n,-$assim_n,"         >> $fname
+   echo "hist_nhtfrq = -$assim_n,1,"                 >> $fname
    echo "hist_mfilt  = 1,$thirtymin"                 >> $fname
    echo "hist_avgflag_pertape = 'A','A'"             >> $fname
 
@@ -525,7 +524,7 @@
 echo 'into the CESM run directory and creating the pointer files.'
 echo ''
 
-# TJH FIXME ... simply put full path in the pointer file? traceability? 
+# TJH FIXME ... simply put full path in the pointer file? traceability?
 # TJH FIXME ... what do we do with the *.hdr file
 # After a run completes, the 'normal' pointer files created are:
 # rpointer.drv
@@ -705,7 +704,7 @@
 #  1) resetting the xml files to run (or rerun) the first step of the experiment
 #  2) the xml changes you need to make between steps 1 and 2
 #  3) restage initial case files to start over
-#  4) restore the files from the last successful cesm advance to restart 
+#  4) restore the files from the last successful cesm advance to restart
 #      in the middle of a run
 #  5) restage the dart executables from the dartroot directory to the
 #      CESM bld directory
@@ -856,7 +855,6 @@
 ${COPY} ${DARTroot}/models/cam/work/cam_to_dart   ${exeroot}/.
 ${COPY} ${DARTroot}/models/cam/work/dart_to_cam   ${exeroot}/.
 ${COPY} ${DARTroot}/models/cam/work/filter        ${exeroot}/filter_cam
-#${COPY} ${DARTroot}/models/cam/work/filter        ${exeroot}/filter
 ${COPY} ${DARTroot}/models/cam/work/input.nml                cam_input.nml
 
 ${COPY} ${DARTroot}/models/clm/work/clm_to_dart   ${exeroot}/.

Modified: DART/trunk/models/CESM/shell_scripts/cam_assimilate.csh
===================================================================
--- DART/trunk/models/CESM/shell_scripts/cam_assimilate.csh	2013-06-28 21:30:36 UTC (rev 6281)
+++ DART/trunk/models/CESM/shell_scripts/cam_assimilate.csh	2013-06-28 22:54:08 UTC (rev 6282)
@@ -27,8 +27,8 @@
       set REMOVE = '/usr/local/bin/rm -fr'
 
       set BASEOBSDIR = /glade/proj3/image/Observations/ACARS
-      set DARTDIR    = ${HOME}/svn/DART/dev
-      set LAUNCHCMD  = mpirun.lsf
+      set    DARTDIR = ${HOME}/svn/DART/trunk
+      set  LAUNCHCMD = mpirun.lsf
    breaksw
 
    case ys*:
@@ -39,8 +39,8 @@
       set REMOVE = 'rm -fr'
 
       set BASEOBSDIR = /glade/p/image/Observations/ACARS
-      set DARTDIR    = ${HOME}/svn/DART/dev
-      set LAUNCHCMD  = mpirun.lsf
+      set    DARTDIR = ${HOME}/svn/DART/trunk
+      set  LAUNCHCMD = mpirun.lsf
    breaksw
 
    default:
@@ -51,11 +51,13 @@
       set REMOVE = 'rm -fr'
 
       set BASEOBSDIR = /scratch/scratchdirs/nscollin/ACARS
-      set DARTDIR    = ${HOME}/devel
-      set LAUNCHCMD  = "aprun -n $NTASKS"
+      set    DARTDIR = ${HOME}/trunk
+      set  LAUNCHCMD = "aprun -n $NTASKS"
    breaksw
 endsw
 
+set ensemble_size = ${NINST_ATM}
+
 #-------------------------------------------------------------------------
 # Determine time of model state ... from file name of first member
 # of the form "./${CASE}.cam_${ensemble_member}.i.2000-01-06-00000.nc"
@@ -63,7 +65,7 @@
 # Piping stuff through 'bc' strips off any preceeding zeros.
 #-------------------------------------------------------------------------
 
-set FILE = `head -n 1 ./rpointer.atm_0001`
+set FILE = `head -n 1 rpointer.atm_0001`
 set FILE = $FILE:t
 set FILE = $FILE:r
 set MYCASE = `echo $FILE | sed -e "s#\..*##"`
@@ -92,16 +94,12 @@
 endif
 
 #-------------------------------------------------------------------------
-# we are going to assimilate, so carry on.
+# Create temporary working directory for the assimilation and go there
 #-------------------------------------------------------------------------
 
-set ensemble_size = ${NINST_ATM}
-
-# Create temporary working directory for the assimilation
 set temp_dir = assimilate_cam
 echo "temp_dir is $temp_dir"
 
-# Create a clean temporary directory and go there
 if ( -d $temp_dir ) then
    ${REMOVE} $temp_dir/*
 else
@@ -140,17 +138,6 @@
    exit -2
 endif
 
-# Modify the DART input.nml such that
-# the DART ensemble size matches the CESM number of instances
-# WARNING: the output files contain ALL enemble members ==> BIG
-
-ex input.nml <<ex_end
-g;ens_size ;s;= .*;= $ensemble_size;
-g;num_output_state_members ;s;= .*;= $ensemble_size;
-g;num_output_obs_members ;s;= .*;= $ensemble_size;
-wq
-ex_end
-
 echo "`date` -- END COPY BLOCK"
 
 #=========================================================================
@@ -200,14 +187,24 @@
 # files to be as listed above. When being archived, the filenames get a
 # unique extension (describing the assimilation time) appended to them.
 #
-# The inflation file is essentially a duplicate of the model state ...
-# it is slaved to a specific geometry. The initial files are created
-# offline with values of unity. For the purpose of this script, they are
-# thought to be the output of a previous assimilation, so they should be
-# named something like prior_inflate_restart.YYYY-MM-DD-SSSSS
+# The inflation file is essentially a duplicate of the DART model state ...  
+# For the purpose of this script, they are the output of a previous assimilation, 
+# so they should be named something like prior_inflate_restart.YYYY-MM-DD-SSSSS
 #
-# The first inflation file can be created with 'fill_inflation_restart'
-# which can be built in the usual DART manner.
+# NOTICE: inf_initial_from_restart and inf_sd_initial_from_restart are somewhat
+# problematic. During the bulk of an experiment, these should be FALSE, since
+# we want to read existing inflation files. However, the first assimilation
+# might need these to be TRUE and then subsequently be set to FALSE.
+# There are two ways to handle this.
+# 1) Create the initial files offline with values of unity by using  
+#    'fill_inflation_restart' and stage them with the appropriate names
+#    in the RUNDIR.
+# 2) create a cookie file called RUNDIR/make_cam_inflation_cookie
+#    The existence of this file will cause this script to set the
+#    namelist appropriately. This script will 'eat' the cookie file
+#    to prevent this from happening for subsequent executions. If the
+#    inflation file does not exist for them, and it needs to, this script
+#    should die.
 #
 # The strategy is to use the LATEST inflation file from the CESM 'rundir'.
 # After an assimilation, the new inflation values/files will be moved to
@@ -251,8 +248,25 @@
 if ( $PRIOR_INF > 0 ) then
 
    if ($PRIOR_TF == false) then
+      # we are not using an existing inflation file.
       echo "inf_flavor(1) = $PRIOR_INF, using namelist values."
-   else
+
+   else if ( -e ../make_cam_inflation_cookie ) then
+      # We want to use an existing inflation file, but this is
+      # the first assimilation so there is no existing inflation
+      # file. This is the signal we need to to coerce the namelist 
+      # to have different values for this execution ONLY.
+      # Since the local namelist comes from CASEROOT each time, we're golden.
+
+      set PRIOR_TF = FALSE    
+
+ex input.nml <<ex_end
+g;inf_initial_from_restart ;s;= .*;= .${PRIOR_TF}., .${POSTE_TF}.,;
+g;inf_sd_initial_from_restart ;s;= .*;= .${PRIOR_TF}., .${POSTE_TF}.,;
+wq
+ex_end
+
+   else 
       # Look for the output from the previous assimilation
       (ls -rt1 ../cam_${PRIOR_INF_OFNAME}.* | tail -n 1 >! latestfile) > & /dev/null
       set nfiles = `cat latestfile | wc -l`
@@ -277,9 +291,25 @@
 if ( $POSTE_INF > 0 ) then
 
    if ($POSTE_TF == false) then
+      # we are not using an existing inflation file.
       echo "inf_flavor(2) = $POSTE_INF, using namelist values."
+
+   else if ( -e ../make_cam_inflation_cookie ) then
+      # We want to use an existing inflation file, but this is
+      # the first assimilation so there is no existing inflation
+      # file. This is the signal we need to to coerce the namelist 
+      # to have different values for this execution ONLY.
+      # Since the local namelist comes from CASEROOT each time, we're golden.
+
+      set POSTE_TF = FALSE    
+
+ex input.nml <<ex_end
+g;inf_initial_from_restart ;s;= .*;= .${PRIOR_TF}., .${POSTE_TF}.,;
+g;inf_sd_initial_from_restart ;s;= .*;= .${PRIOR_TF}., .${POSTE_TF}.,;
+wq
+ex_end
+
    else
-
       # Look for the output from the previous assimilation
       (ls -rt1 ../cam_${POSTE_INF_OFNAME}.* | tail -n 1 >! latestfile) > & /dev/null

@@ Diff output truncated at 40000 characters. @@


More information about the Dart-dev mailing list