[Dart-dev] [6085] DART/branches/development/models/clm/shell_scripts: Is capable of taking a real observation sequence file and running

nancy at ucar.edu nancy at ucar.edu
Thu Apr 25 12:07:30 MDT 2013


Revision: 6085
Author:   thoar
Date:     2013-04-25 12:07:29 -0600 (Thu, 25 Apr 2013)
Log Message:
-----------
Is capable of taking a real observation sequence file and running
a perfect model experiment.

Modified Paths:
--------------
    DART/branches/development/models/clm/shell_scripts/perfect_model.csh

Added Paths:
-----------
    DART/branches/development/models/clm/shell_scripts/CESM1_1_1_pmo_setup.csh

-------------- next part --------------
Added: DART/branches/development/models/clm/shell_scripts/CESM1_1_1_pmo_setup.csh
===================================================================
--- DART/branches/development/models/clm/shell_scripts/CESM1_1_1_pmo_setup.csh	                        (rev 0)
+++ DART/branches/development/models/clm/shell_scripts/CESM1_1_1_pmo_setup.csh	2013-04-25 18:07:29 UTC (rev 6085)
@@ -0,0 +1,638 @@
+#!/bin/csh
+#
+# DART software - Copyright 2004 - 2011 UCAR. This open source software is
+# provided by UCAR, "as is", without charge, subject to all terms of use at
+# http://www.image.ucar.edu/DAReS/DART/DART_download
+#
+# $Id$
+
+# ---------------------
+# Purpose
+# ---------------------
+#
+# This script is designed to configure and build a multi-instance CESM model
+# that has CLM running under a set of data atmospheres (from a DART/CAM assim).
+# and will use DART to assimilate observations at regular intervals.
+# This script does not build DART. It works best if the appropriate DART
+# executables have been built, however.
+#
+# This script relies heavily on the information in:
+# http://www.cesm.ucar.edu/models/cesm1.1/cesm/doc/usersguide/book1.html
+#
+# ---------------------
+# How to set up the script
+# ---------------------
+# -- Either edit and run this script in the $DART/models/clm/shell_scripts
+#    directory where it first appears,
+#    or copy it to somewhere that it will be preserved and run it there.
+#    It will create a 'case' directory, where the model will be built,
+#    and an execution directory, where each forecast and assimilation will
+#    take place.  The short term archiver will use a third directory for
+#    storage of model output until it can be moved to long term storage (HPSS)
+# -- Examine the whole script to identify things to change for your experiments.
+# -- Provide any initial files needed by your run:
+#       inflation
+#       sampling error correction
+#       CLM initial ensemble
+#       ...
+# -- Check to make sure the stream txt files point to the proper stream files for
+#       each ensemble member.
+# -- Run this script.
+# -- Edit the DART input.nml that appears in the $CASEROOT directory.
+# -- Submit the job using $CASEROOT/${case}.submit
+#
+# ---------------------
+# Important features
+# ---------------------
+#
+# If you want to change something in your case other than the runtime
+# settings, it is safest to delete everything and start the run from scratch.
+# For the brave, read
+#
+# http://www.cesm.ucar.edu/models/cesm1.1/cesm/doc/usersguide/x1142.html
+
+# ==============================================================================
+# ====  Set case options
+# ==============================================================================
+
+# 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.
+# num_instances:  Number of ensemble members
+
+setenv case                 clm_pmo
+setenv compset              I_2000_CN
+setenv resolution           0.9x1.25_gx1v6
+setenv cesmtag              cesm1_1_1
+setenv num_instances        1
+
+# ==============================================================================
+# define machines and directories
+#
+# mach            Computer name
+# cesm_datadir    Root path of the public CESM data files
+# cesmroot        Location of the cesm code base
+#                    i.e. cesm1_1_1 on yellowstone
+# DARTroot        Location of DART code tree.
+#                    Executables, scripts and input in $DARTroot/models/clm/...
+# 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.
+# rundir          (Future) Run-time directory; scrubbable, large amount of space needed.
+# exeroot         (Future) directory for executables - scrubbable, large amount of space needed.
+# archdir         (Future) Short-term archive directory
+#                    until the long-term archiver moves it to permanent storage.
+# ==============================================================================
+
+setenv mach         yellowstone
+setenv cesm_datadir /glade/p/cesm/cseg/inputdata
+setenv cesmroot     /glade/p/cesm/cseg/collections/$cesmtag
+setenv caseroot     /glade/p/work/${USER}/cases/${case}
+setenv exeroot      /glade/scratch/${USER}/${case}/bld
+setenv rundir       /glade/scratch/${USER}/${case}/run
+setenv archdir      /glade/scratch/${USER}/archive/${case}
+
+setenv DARTroot     /glade/u/home/${USER}/svn/DART/dev
+
+# ==============================================================================
+# The initial ensemble can be set by specifying the 'finidat' variable in the
+# user_nl_clm_${instance}. A FULL pathname to the file is required. This is nice
+# for two reasons - one is that you don't need to copy the files and rename them
+# (tedious), the second is that the full pathname provides a means of tracking 
+# the origin of the initial ensemble.
+# ==============================================================================
+
+set stagedir = /glade/scratch/afox/bptmp/MD_40_PME/run/MD_40_PME
+set stagedir = /glade/scratch/thoar/DART_POP_RESTARTS/CLM_2004-01-01-00000/cesm_test
+
+# ==============================================================================
+# configure settings
+# ==============================================================================
+
+setenv stream_year_first 2004
+setenv stream_year_last  2004
+setenv stream_year_align 2004
+setenv refyear     2004
+setenv refmon      01
+setenv refday      01
+setenv run_reftod  00000
+setenv run_refdate $refyear-$refmon-$refday
+
+# ==============================================================================
+# runtime settings --  How many assimilation steps will be done after this one
+#
+# stop_option   Units for determining the forecast length between assimilations
+# stop_n        Number of time units in the forecast
+# ==============================================================================
+
+setenv resubmit      0
+setenv stop_option   nhours
+setenv stop_n        24
+
+# ==============================================================================
+# job settings
+#
+# timewall   can be changed during a series by changing the ${case}.run
+# queue      can be changed during a series by changing the ${case}.run
+#
+# TJH How many f19_f19 CLM instances can fit on 1 'regular' node?
+# ==============================================================================
+
+setenv ACCOUNT      P86850054
+setenv timewall     0:20
+setenv queue        regular
+setenv ptile        15
+
+# ==============================================================================
+# set these standard commands based on the machine you are running on.
+# ==============================================================================
+
+switch ("`hostname`")
+   case be*:
+      # NCAR "bluefire"
+      # The FORCE options are not optional.
+      # the VERBOSE options are useful for debugging.
+      set   MOVE = '/usr/local/bin/mv -fv'
+      set   COPY = '/usr/local/bin/cp -fv --preserve=timestamps'
+      set   LINK = '/usr/local/bin/ln -fvs'
+      set REMOVE = '/usr/local/bin/rm -fr'
+
+   breaksw
+   default:
+      # NERSC "hopper", NWSC "yellowstone"
+      set   MOVE = '/bin/mv -fv'
+      set   COPY = '/bin/cp -fv --preserve=timestamps'
+      set   LINK = '/bin/ln -fvs'
+      set REMOVE = '/bin/rm -fr'
+      set nonomatch
+
+   breaksw
+endsw
+
+# ==============================================================================
+# Create the case.
+#
+# For list of the pre-defined cases: ./create_newcase -list
+# To create a variant case, see the CESM documentation and carefully
+# incorporate any needed changes into this script.
+# ==============================================================================
+
+   echo "removing old files from ${caseroot}"
+   echo "removing old files from ${exeroot}"
+   echo "removing old files from ${rundir}"
+   ${REMOVE} ${caseroot}
+   ${REMOVE} ${exeroot}
+   ${REMOVE} ${rundir}
+   ${cesmroot}/scripts/create_newcase -case ${caseroot} -mach ${mach} \
+                   -res ${resolution} -compset ${compset}
+
+   if ( $status != 0 ) then
+      echo "ERROR: Case could not be created."
+      exit -1
+   endif
+
+# ==============================================================================
+# Configure the case - this creates the CASEROOT directory.
+# ==============================================================================
+
+cd ${caseroot}
+
+# Save a copy for debug purposes
+foreach FILE ( *xml )
+   if ( ~ -e        ${FILE}.original ) then
+      ${COPY} $FILE ${FILE}.original
+   endif
+end
+
+   # There may be a more efficient layout
+
+   @ cpl_pes  = $ptile
+   @ atm_pes  = $ptile
+   @ ice_pes  = $ptile
+   @ lnd_pes  = $ptile
+   @ rof_pes  = $ptile
+   @ glc_pes  = $ptile
+   @ ocn_pes  = $ptile
+
+./xmlchange ROOTPE_CPL=0,NTHRDS_CPL=1,NTASKS_CPL=$cpl_pes
+./xmlchange ROOTPE_ATM=0,NTHRDS_ATM=1,NTASKS_ATM=$atm_pes,NINST_ATM=1
+./xmlchange ROOTPE_ICE=0,NTHRDS_ICE=1,NTASKS_ICE=$ice_pes,NINST_ICE=1
+./xmlchange ROOTPE_LND=0,NTHRDS_LND=1,NTASKS_LND=$lnd_pes,NINST_LND=1
+./xmlchange ROOTPE_ROF=0,NTHRDS_ROF=1,NTASKS_ROF=$rof_pes,NINST_ROF=1
+./xmlchange ROOTPE_GLC=0,NTHRDS_GLC=1,NTASKS_GLC=$glc_pes,NINST_GLC=1
+./xmlchange ROOTPE_OCN=0,NTHRDS_OCN=1,NTASKS_OCN=$ocn_pes,NINST_OCN=1
+
+# http://www.cesm.ucar.edu/models/cesm1.1/cesm/doc/usersguide/c1158.html#run_start_stop
+# "A hybrid run indicates that CESM is initialized more like a startup, but uses
+# initialization datasets from a previous case. This is somewhat analogous to a
+# branch run with relaxed restart constraints. A hybrid run allows users to bring
+# together combinations of initial/restart files from a previous case (specified
+# by $RUN_REFCASE) at a given model output date (specified by $RUN_REFDATE).
+# Unlike a branch run, the starting date of a hybrid run (specified by $RUN_STARTDATE)
+# can be modified relative to the reference case. In a hybrid run, the model does not
+# continue in a bit-for-bit fashion with respect to the reference case. The resulting
+# climate, however, should be continuous provided that no model source code or
+# namelists are changed in the hybrid run. In a hybrid initialization, the ocean
+# model does not start until the second ocean coupling (normally the second day),
+# and the coupler does a "cold start" without a restart file.
+
+./xmlchange RUN_TYPE=startup
+./xmlchange RUN_STARTDATE=$run_refdate
+./xmlchange RUN_REFCASE=${case}
+./xmlchange RUN_REFDATE=$run_refdate
+./xmlchange RUN_REFTOD=$run_reftod
+./xmlchange BRNCH_RETAIN_CASENAME=TRUE
+./xmlchange GET_REFCASE=FALSE
+./xmlchange EXEROOT=${exeroot}
+./xmlchange PIO_TYPENAME=pnetcdf
+
+# DOUT_S     is to turn on/off the short-term archiving
+# DOUT_L_MS  is to store to the HPSS (formerly "MSS")
+
+./xmlchange DOUT_S_ROOT=${archdir}
+./xmlchange DOUT_S=FALSE
+./xmlchange DOUT_S_SAVE_INT_REST_FILES=FALSE
+./xmlchange DOUT_L_MS=FALSE
+./xmlchange DOUT_L_MSROOT="csm/${case}"
+./xmlchange DOUT_L_HTAR=FALSE
+
+./xmlchange DATM_MODE=CPLHIST3HrWx
+./xmlchange DATM_CPLHIST_CASE=$case
+./xmlchange DATM_CPLHIST_YR_ALIGN=$refyear
+./xmlchange DATM_CPLHIST_YR_START=$refyear
+./xmlchange DATM_CPLHIST_YR_END=$refyear
+
+# Do not change the CALENDAR or the CONTINUE_RUN
+
+./xmlchange CALENDAR=GREGORIAN
+./xmlchange STOP_OPTION=$stop_option
+./xmlchange STOP_N=$stop_n
+./xmlchange CONTINUE_RUN=FALSE
+./xmlchange RESUBMIT=$resubmit
+
+# The river transport model ON is useful only when using an active ocean or
+# land surface diagnostics. Setting ROF_GRID to 'null' turns off the RTM.
+
+./xmlchange ROF_GRID='null'
+./xmlchange CLM_CONFIG_OPTS='-bgc cn'
+
+# 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.
+# ==============================================================================
+
+./cesm_setup
+
+if ( $status != 0 ) then
+   echo "ERROR: Case could not be set up."
+   exit -2
+endif
+
+# ==============================================================================
+# Create namelist template: user_nl_clm
+# Example user_nl_clm namelist adding and removing fields on primary history file
+# hist_fincl1 = 'COSZEN', 'DECL'
+# hist_fexcl1 = 'TG', 'TV', 'TSOI', 'H2OSOI'
+# DART needs the lon,lat,levgrnd,lonatm,latatm,lonrof,latrof DIMENSION
+# information from the .h0. history file - nothing else.
+#
+# hist_empty_htapes = .true.     suppresses the creation of all history files
+# hist_fincl1 = 'TG',            except the first one, which will have one variable
+# hist_nhtfrq = -$stop_n,        create one every $stop_n HOURS
+# hist_mfilt  =  1,              with precisely one day in it
+# hist_avgflag_pertape = 'I'     use instantaneous values - no average
+#
+# The fincl2 history tape has the half-hourly flux tower observations.
+# The observation operators in obs_def_tower_mod.f90
+# are going to read from the .h1. history file for these values.
+# ==============================================================================
+
+   # ===========================================================================
+   set fname = user_nl_datm
+   # ===========================================================================
+
+   echo "dtlimit = 1.5, 1.5, 1.5"                    >> $fname
+   echo "fillalgo = 'nn', 'nn', 'nn'"                >> $fname
+   echo "fillmask = 'nomask','nomask','nomask'"      >> $fname
+   echo "mapalgo = 'bilinear','bilinear','bilinear'" >> $fname
+   echo "mapmask = 'nomask','nomask','nomask'"       >> $fname
+   echo "streams = 'datm.streams.txt.CPLHIST3HrWx.Solar             $stream_year_align $stream_year_first $stream_year_last'," >> $fname
+   echo "          'datm.streams.txt.CPLHIST3HrWx.Precip            $stream_year_align $stream_year_first $stream_year_last'," >> $fname
+   echo "          'datm.streams.txt.CPLHIST3HrWx.nonSolarNonPrecip $stream_year_align $stream_year_first $stream_year_last'"  >> $fname
+   echo "taxmode = 'cycle','cycle','cycle'"          >> $fname
+   echo "tintalgo = 'coszen','nearest','linear'"     >> $fname
+   echo "restfils = 'unset'"                         >> $fname
+   echo "restfilm = 'unset'"                         >> $fname
+
+   # ===========================================================================
+   set fname = user_nl_clm
+   # ===========================================================================
+
+   # Customize the land namelists
+   # The initial ensemble can be set by specifying the 'finidat' variable in the
+   # user_nl_clm${instance}. A FULL pathname to the file is required. This is nice
+   # for two reasons - one is that you don't need to copy the files and rename them
+   # (tedious), the second is that the full pathname provides a means of tracking 
+   # the origin of the initial ensemble.
+
+   echo "finidat = '${stagedir}.clm2_0001.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 = -$stop_n,1,"                  >> $fname
+   echo "hist_mfilt  = 1,48"                         >> $fname
+   echo "hist_avgflag_pertape = 'A','A'"             >> $fname
+
+
+# ==============================================================================
+# to create custom streamfiles ...
+# "To modify the contents of a stream txt file, first use preview_namelists to
+#  obtain the contents of the stream txt files in CaseDocs, and then place a copy
+#  of the modified stream txt file in $CASEROOT with the string user_ prepended."
+#
+# -or-
+#
+# we copy a template stream txt file from the
+# $DARTroot/models/clm/shell_scripts directory and modify one for each instance.
+#
+# ==============================================================================
+
+./preview_namelists
+
+# This gives us a stream txt file for each instance that we can
+# modify for our own purpose.
+
+foreach FILE (CaseDocs/*streams*)
+   set FNAME = $FILE:t
+
+   switch ( ${FNAME} )
+      case *presaero*:
+         echo "Using default prescribed aerosol stream.txt file ${FNAME}"
+         breaksw
+      case *diatren*:
+         echo "Using default runoff stream.txt file ${FNAME}"
+         breaksw
+      default:
+         ${COPY} $FILE user_$FNAME
+         chmod   644   user_$FNAME
+         breaksw
+   endsw
+
+end
+
+# Replace each default stream txt file with one that uses the CLM DATM
+# conditions for a default year and modify the instance number.
+
+foreach FNAME (user*streams*)
+   set name_parse = `echo $FNAME | sed 's/\_/ /g'`
+ # @ instance_index = $#name_parse
+   @ filename_index = $#name_parse
+   set streamname = $name_parse[$filename_index]
+   set instance   = 0001
+
+   if (-e $DARTroot/models/clm/shell_scripts/user_$streamname*template) then
+
+      echo "Copying DART template for $FNAME and changing instances, refyear"
+
+      ${COPY} $DARTroot/models/clm/shell_scripts/user_$streamname*template $FNAME
+
+      sed s/NINST/$instance/g   $FNAME >! out.$$
+      sed s/REFYEAR/$refyear/g  out.$$ >! $FNAME
+      \rm -f out.$$
+
+   else
+      echo "DIED Looking for a DART stream txt template for $FNAME"
+      echo "DIED Looking for a DART stream txt template for $FNAME"
+      exit -3
+   endif
+
+end
+
+./preview_namelists
+
+# ==============================================================================
+# Update source files if need be
+#    Ideally, using DART will not require any source mods.
+#    Until then, this script accesses source mods from a hard-wired location below.
+#    Those may eventually be packaged into the DART repository.
+#    If you have additional source mods, they will need to be merged into any DART
+#    mods and put in the SourceMods subdirectory found in the 'case' directory.
+# ==============================================================================
+
+if (    -d     ~/${cesmtag}/SourceMods ) then
+   ${COPY} -r  ~/${cesmtag}/SourceMods/* ${caseroot}/SourceMods/
+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 "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"
+   echo "~/cesm_1_1_1  directory with the appropriate SourceMods structure."
+   exit -4
+endif
+
+# ==============================================================================
+# build
+# ==============================================================================
+
+echo ''
+echo 'Building the case'
+echo ''
+
+./${case}.build
+
+if ( $status != 0 ) then
+   echo "ERROR: Case could not be built."
+   exit -5
+endif
+
+# ==============================================================================
+# The initial ensemble was set by specifying the 'finidat' variable in the
+# user_nl_clm_${instance}. A FULL pathname to the file is required.
+# ==============================================================================
+
+# normally this is where you would stage the startup files
+
+# ==============================================================================
+# Edit the run script to reflect project, queue, and wallclock
+# ==============================================================================
+
+echo ''
+echo 'Updating the run script to set wallclock and queue.'
+echo ''
+
+if ( ~ -e  ${case}.run.original ) then
+   ${COPY} ${case}.run ${case}.run.original
+endif
+
+source Tools/ccsm_getenv
+set BATCH = `echo $BATCHSUBMIT | sed 's/ .*$//'`
+switch ( $BATCH )
+   case bsub*:
+      # NCAR "bluefire", "yellowstone"
+      set TIMEWALL=`grep BSUB ${case}.run | grep -e '-W' `
+      set    QUEUE=`grep BSUB ${case}.run | grep -e '-q' `
+      sed -e "s/ptile=[0-9][0-9]*/ptile=$ptile/" \
+          -e "s/$TIMEWALL[3]/$timewall/" \
+          -e "s/$QUEUE[3]/$queue/" < ${case}.run >! temp.$$
+      ${MOVE} temp.$$  ${case}.run
+   breaksw
+
+   default:
+
+   breaksw
+endsw
+
+# ==============================================================================
+# The *.run script must be modified to call the DART assimilate script.
+# The modifications are contained in a "here" document that MUST NOT
+# expand the wildcards etc., before it is run. This is achieved by
+# double-quoting the characters used to delineate the start/stop of
+# the "here" document. No kidding. It has to be "EndOfText",
+# not 'EndOfText' or EndOfText.
+# ==============================================================================
+
+echo ''
+echo 'Adding the call to assimilate.csh to the *.run script.'
+echo ''
+
+cat << "EndOfText" >! add_to_run.txt
+
+# -------------------------------------------------------------------------
+# START OF DART: if CESM finishes correctly (pirated from ccsm_postrun.csh);
+# perform an assimilation with DART.
+
+set CplLogFile = `ls -1t cpl.log* | head -n 1`
+if ($CplLogFile == "") then
+   echo 'ERROR: Model did not complete - no cpl.log file present - exiting.'
+   echo 'ERROR: Creating Synthetic Observations will not be attempted.'
+   exit -1
+endif
+
+grep 'SUCCESSFUL TERMINATION' $CplLogFile
+if ( $status == 0 ) then
+   ${CASEROOT}/perfect_model.csh
+
+   if ( $status == 0 ) then
+      echo "`date` -- DART HAS FINISHED"
+   else
+      echo "`date` -- DART PMO ERROR - ABANDON HOPE"
+      exit -3
+   endif
+else
+   echo 'ERROR: Model did not complete successfully - exiting.'
+   echo 'ERROR: Creating Synthetic Observations will not be attempted.'
+   exit -2
+endif
+
+# END OF DART BLOCK
+# -------------------------------------------------------------------------
+"EndOfText"
+
+# Now that the "here" document is created,
+# determine WHERE to insert it -- ONLY IF it is not already there.
+
+grep "ABANDON HOPE" ${case}.run
+set STATUSCHECK = $status
+
+if ( ${STATUSCHECK} == 0 ) then
+   echo "DART block already present in ${case}.run"
+else if ( ${STATUSCHECK} == 1 ) then
+
+   set MYSTRING = `grep --line-number "CSM EXECUTION HAS FINISHED" ${case}.run`
+   set MYSTRING = `echo $MYSTRING | sed -e "s#:# #g"`
+
+   @ origlen = `cat ${case}.run | wc -l`
+   @ keep = $MYSTRING[1]
+   @ lastlines = $origlen - $keep
+
+   head -n $keep      ${case}.run    >! temp.$$
+   cat                add_to_run.txt >> temp.$$
+   tail -n $lastlines ${case}.run    >> temp.$$
+
+   ${MOVE}   temp.$$ ${case}.run
+   ${REMOVE} add_to_run.txt
+
+else
+   echo "ERROR in grep of ${case}.run: aborting"
+   echo "status was ${STATUSCHECK}"
+   exit -6
+endif
+
+chmod 0755 ${case}.run
+
+# ==============================================================================
+# Stage the required parts of DART in the CASEROOT directory.
+# ==============================================================================
+
+# The standard CESM short-term archiving script may need to be altered
+# to archive addtional or subsets of things, or to reduce the amount of
+# data that is sent to the long-term archive.
+
+if ( ~ -e  Tools/st_archive.sh.original ) then
+   ${COPY} Tools/st_archive.sh Tools/st_archive.sh.original
+endif
+
+# NOTE: the assimilate.csh script and input.nml must be modified for your
+#       situation. The script has variables that point to the location of
+#       the observations sequence files and the DART working directory
+#       and may be customized for a more efficient PE layout for DART.
+#       If you are running this, you know what to do with input.nml.
+#       If you don't, you should give up now. Really.
+
+${COPY} ${DARTroot}/models/clm/shell_scripts/st_archive.sh      Tools/
+${COPY} ${DARTroot}/models/clm/shell_scripts/perfect_model.csh  perfect_model.csh
+${COPY} ${DARTroot}/models/clm/work/input.nml                   input.nml
+
+# ==============================================================================
+# Stage the DART executables in the CESM execution root directory: EXEROOT
+# ==============================================================================
+
+foreach FILE ( perfect_model_obs clm_to_dart dart_to_clm )
+   ${COPY} ${DARTroot}/models/clm/work/${FILE} ${exeroot}/
+   if ( $status != 0 ) then
+      echo "ERROR: ${DARTroot}/models/clm/work/${FILE} not copied to ${exeroot}"
+      echo "ERROR: ${DARTroot}/models/clm/work/${FILE} not copied to ${exeroot}"
+      exit -7
+   endif
+end
+
+# ==============================================================================
+# What to do next
+# ==============================================================================
+
+echo ''
+echo "Time to check the case."
+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 "For continued submissions after the initial startup,"
+echo "make the following changes to the env_run variables:"
+echo ''
+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 "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 ''
+
+exit 0
+
+# <next few lines under version control, do not edit>
+# $URL$
+# $Revision$
+# $Date$
+


Property changes on: DART/branches/development/models/clm/shell_scripts/CESM1_1_1_pmo_setup.csh
___________________________________________________________________
Added: svn:executable
   + *
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author HeadURL Id
Added: svn:eol-style
   + native

Modified: DART/branches/development/models/clm/shell_scripts/perfect_model.csh
===================================================================
--- DART/branches/development/models/clm/shell_scripts/perfect_model.csh	2013-04-25 16:09:07 UTC (rev 6084)
+++ DART/branches/development/models/clm/shell_scripts/perfect_model.csh	2013-04-25 18:07:29 UTC (rev 6085)
@@ -1,4 +1,4 @@
-#!/bin/tcsh
+#!/bin/csh
 #
 # DART software - Copyright 2004 - 2011 UCAR. This open source software is
 # provided by UCAR, "as is", without charge, subject to all terms of use at
@@ -6,15 +6,55 @@
 #
 # $Id$
 
-# The FORCE options are not optional.
-# the VERBOSE options are useful for debugging.
-set   MOVE = '/usr/local/bin/mv -fv'
-set   COPY = '/usr/local/bin/cp -fv --preserve=timestamps'
-set   LINK = '/usr/local/bin/ln -fvs'
-set REMOVE = '/usr/local/bin/rm -fr'
+# This block is an attempt to localize all the machine-specific
+# 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"
+
+switch ("`hostname`")
+   case be*:
+      # NCAR "bluefire"
+      # The FORCE options are not optional.
+      # the VERBOSE options are useful for debugging.
+      set   MOVE = '/usr/local/bin/mv -fv'
+      set   COPY = '/usr/local/bin/cp -fv --preserve=timestamps'
+      set   LINK = '/usr/local/bin/ln -fvs'
+      set REMOVE = '/usr/local/bin/rm -fr'
+
+      set BASEOBSDIR = /glade/proj3/image/Observations/FluxTower
+      set DARTDIR    = ${HOME}/svn/DART/dev
+   breaksw
+
+   case ys*:
+      # NCAR "yellowstone"
+      # The FORCE options are not optional.
+      # the VERBOSE options are useful for debugging.
+      set   MOVE = 'mv -fv'
+      set   COPY = 'cp -fv --preserve=timestamps'
+      set   LINK = 'ln -fvs'
+      set REMOVE = 'rm -fr'
+      set nonomatch
+
+      set BASEOBSDIR = /glade/p/image/Observations/FluxTower
+      set DARTDIR    = ${HOME}/svn/DART/dev
+   breaksw
+
+   default:
+      # NERSC "hopper"
+      set   MOVE = 'mv -fv'
+      set   COPY = 'cp -fv --preserve=timestamps'
+      set   LINK = 'ln -fvs'
+      set REMOVE = 'rm -fr'
+      set nonomatch
+
+      set BASEOBSDIR = /scratch/scratchdirs/nscollin/ACARS
+      set DARTDIR    = ${HOME}/devel
+   breaksw
+endsw
+
 # Create temporary working directory for the assimilation
-set temp_dir = assimilate_dir
+set temp_dir = assimilate_clm
 echo "temp_dir is $temp_dir"
 
 # Create a clean temporary directory and go there
@@ -28,87 +68,125 @@
 #-------------------------------------------------------------------------
 # Determine time of model state ... from file name of first member
 # of the form "./${CASE}.clm2_${ensemble_member}.r.2000-01-06-00000.nc"
+#
+# Piping stuff through 'bc' strips off any preceeding zeros.
 #-------------------------------------------------------------------------
 
 set FILE = `head -1 ../rpointer.lnd`
 set FILE = $FILE:t
 set FILE = $FILE:r
-set MODEL_DATE_EXT = `echo $FILE:e`
-set MODEL_DATE_STR = `echo $FILE:e | sed -e "s#-# #g"`
-set MODEL_DATE = `echo $MODEL_DATE_STR`
-@ MODEL_YEAR    = $MODEL_DATE[1]
-@ MODEL_MONTH   = $MODEL_DATE[2]
-@ MODEL_DAY     = $MODEL_DATE[3]
-@ MODEL_SECONDS = $MODEL_DATE[4]
+set MYCASE = `echo $FILE | sed -e "s#\..*##"`
+set LND_DATE_EXT = `echo $FILE:e`
+set LND_DATE     = `echo $FILE:e | sed -e "s#-# #g"`
+set LND_YEAR     = `echo $LND_DATE[1] | bc`
+set LND_MONTH    = `echo $LND_DATE[2] | bc`
+set LND_DAY      = `echo $LND_DATE[3] | bc`
+set LND_SECONDS  = `echo $LND_DATE[4] | bc`
+set LND_HOUR     = `echo $LND_DATE[4] / 3600 | bc`
 
-echo "valid time of model is $MODEL_YEAR $MODEL_MONTH $MODEL_DAY $MODEL_SECONDS"
+echo "valid time of model is $LND_YEAR $LND_MONTH $LND_DAY $LND_SECONDS (seconds)"
+echo "valid time of model is $LND_YEAR $LND_MONTH $LND_DAY $LND_HOUR (hours)"
 
 #-----------------------------------------------------------------------------
-# Set variables containing various directory names where we will GET things
+# Get observation sequence file ... or die right away.
+# The observation file names have a time that matches the stopping time of CLM.
+# 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.
 #-----------------------------------------------------------------------------
 
-set DARTDIR = ${HOME}/DART/models/clm/work
-set DARTDIR = /glade/home/thoar/clm/models/clm/work
-set  OBSDIR = /glade/scratch/thoar/CLM_PMO_leafc
+set YYYYMMDD = `printf %04d%02d%02d ${LND_YEAR} ${LND_MONTH} ${LND_DAY}`
+set YYYYMM   = `printf %04d%02d     ${LND_YEAR} ${LND_MONTH}`
+set OBSFNAME = `printf obs_seq.%04d-%02d-%02d-%05d ${LND_YEAR} ${LND_MONTH} ${LND_DAY} ${LND_SECONDS}`
+set OBS_FILE = ${BASEOBSDIR}/${YYYYMM}/${OBSFNAME}
 
-#-------------------------------------------------------------------------
-# DART COPY BLOCK
-# Populate a run-time directory with the bits needed to run DART
-# Either get them from the CCSM 'run' directory or some stock repository
-# The grid files are absolute paths ... so they need not move.
-#-------------------------------------------------------------------------
+if (  -e   ${OBS_FILE} ) then
+   ${COPY} ${OBS_FILE} obs_seq.in
+else
+   echo "ERROR ... no observation file $OBS_FILE"
+   echo "ERROR ... no observation file $OBS_FILE"
+   exit -1
+endif
 
-foreach FILE ( input.nml perfect_model_obs clm_to_dart dart_to_clm )
+#=========================================================================
+# Block 1: Populate a run-time directory with the input needed to run DART.
+#=========================================================================
 
-   ${COPY} ${DARTDIR}/${FILE} . || exit 1
+echo "`date` -- BEGIN COPY BLOCK"
 
-end
+if (  -e   ${CASEROOT}/input.nml ) then
+   ${COPY} ${CASEROOT}/input.nml .
+else
+   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
 
-#-------------------------------------------------------------------------
-# Block 1: convert 1 clm restart file to a DART initial conditions file.
+echo "`date` -- END COPY BLOCK"
+
+#=========================================================================
+# 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.ud'
-#-------------------------------------------------------------------------
+# &clm_to_dart_nml:        clm_to_dart_output_file = 'dart_ics'
+#=========================================================================
 
+echo "`date` -- BEGIN CLM-TO-DART"
+
 set member = 1
 
    set MYTEMPDIR = member_${member}
    mkdir -p $MYTEMPDIR
    cd $MYTEMPDIR
 
+   set DART_IC_FILENAME = perfect_ics
+
+   sed -e "s/dart_ics/..\/${DART_IC_FILENAME}/" < ../input.nml >! input.nml
+
    set POINTER_FILENAME = rpointer.lnd
-   set MODEL_RESTART_FILENAME = `head -1 ../../${POINTER_FILENAME}`
-   set MODEL_HISTORY_FILENAME = `echo ${MODEL_RESTART_FILENAME} | sed "s/\.r\./\.h0\./"`
-   ${LINK} ../../$MODEL_RESTART_FILENAME clm_restart.nc
-   ${LINK} ../../$MODEL_HISTORY_FILENAME clm_history.nc
-   ${COPY} ../input.nml                  .
 
+   set  LND_RESTART_FILENAME = `head -1 ../../${POINTER_FILENAME}`
+   set  LND_HISTORY_FILENAME = `echo ${LND_RESTART_FILENAME} | sed "s/\.r\./\.h0\./"`
+   set OBS1_HISTORY_FILENAME = `echo ${LND_RESTART_FILENAME} | sed "s/\.r\./\.h1\./"`
+   set OBS2_HISTORY_FILENAME = `echo ${LND_RESTART_FILENAME} | sed "s/\.r\./_0001\.h1\./"`
+
+   ${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.
-   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
-   ncatted -O -a missing_value,DZSNO,o,d,1.0e+36      clm_restart.nc
-   ncatted -O -a    _FillValue,H2OSOI_LIQ,o,d,1.0e+36 clm_restart.nc
-   ncatted -O -a missing_value,H2OSOI_LIQ,o,d,1.0e+36 clm_restart.nc
-   ncatted -O -a    _FillValue,H2OSOI_ICE,o,d,1.0e+36 clm_restart.nc
-   ncatted -O -a missing_value,H2OSOI_ICE,o,d,1.0e+36 clm_restart.nc
-   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
+#  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
+#  ncatted -O -a missing_value,DZSNO,o,d,1.0e+36      clm_restart.nc
+#  ncatted -O -a    _FillValue,H2OSOI_LIQ,o,d,1.0e+36 clm_restart.nc
+#  ncatted -O -a missing_value,H2OSOI_LIQ,o,d,1.0e+36 clm_restart.nc
+#  ncatted -O -a    _FillValue,H2OSOI_ICE,o,d,1.0e+36 clm_restart.nc
+#  ncatted -O -a missing_value,H2OSOI_ICE,o,d,1.0e+36 clm_restart.nc
+#  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
 
-   echo "starting clm_to_dart for member ${member} at "`date`
-   ../clm_to_dart >! output.${member}.clm_to_dart
-   echo "finished clm_to_dart for member ${member} at "`date`
+   ${EXEROOT}/clm_to_dart >! output.${member}.clm_to_dart
 
-   mv dart.ud ../perfect_ics
+   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
+
    cd ..
 
-#-------------------------------------------------------------------------
-# Block 2: Advance the model and harvest the synthetic observations.
+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.
 #
@@ -126,33 +204,36 @@
 # &perfect_model_obs_nml:           last_obs_days          = -1,
 # &perfect_model_obs_nml:           last_obs_seconds       = -1,
 #
-#-------------------------------------------------------------------------
+#=========================================================================
 
-# clm always needs a clm_restart.nc, and a clm_history.nc to start.
+# clm always needs a clm_restart.nc, clm_history.nc for geometry information, etc.
 
-set MODEL_RESTART_FILENAME = `head -1 ../rpointer.lnd`
-set MODEL_HISTORY_FILENAME = `echo ${MODEL_RESTART_FILENAME} | sed "s/\.r\./\.h0\./"`
+set LND_RESTART_FILENAME = `head -1 ../rpointer.lnd`
+set LND_HISTORY_FILENAME = `echo ${LND_RESTART_FILENAME} | sed "s/\.r\./\.h0\./"`
 
-${LINK} ../$MODEL_RESTART_FILENAME clm_restart.nc
-${LINK} ../$MODEL_HISTORY_FILENAME clm_history.nc
+${LINK} ../$LND_RESTART_FILENAME clm_restart.nc
+${LINK} ../$LND_HISTORY_FILENAME clm_history.nc
 
-# Determine proper observation sequence file.
+echo "`date` -- BEGIN PERFECT_MODEL_OBS"
+${EXEROOT}/perfect_model_obs || exit -4
+echo "`date` -- END PERFECT_MODEL_OBS"
 
-set OBSFNAME = `printf obs_seq.in.0Z.%04d%02d%02d ${MODEL_YEAR} ${MODEL_MONTH} ${MODEL_DAY}`
-set OBS_FILE = ${OBSDIR}/${MODEL_YEAR}/${OBSFNAME}
+${MOVE} True_State.nc    ../clm_True_State.${LND_DATE_EXT}.nc
+${MOVE} obs_seq.out      ../obs_seq.${LND_DATE_EXT}.out
+${MOVE} dart_log.out     ../clm_dart_log.${LND_DATE_EXT}.out
 
-${LINK} ${OBS_FILE}   obs_seq.in
+#=========================================================================
+# Block 4: Update the clm restart files.
+#=========================================================================
 
-./perfect_model_obs || exit 2
+# not needed ... perfect_model_obs does not update the model state.
 
-${MOVE} True_State.nc    ../True_State.${MODEL_DATE_EXT}.nc
-${MOVE} obs_seq.out      ../obs_seq.${MODEL_DATE_EXT}.out
-${MOVE} dart_log.out     ../dart_log.${MODEL_DATE_EXT}.out
-
 #-------------------------------------------------------------------------
 # Cleanup
 #-------------------------------------------------------------------------
 
+echo "`date` -- END   GENERATE TRUE STATE"
+
 exit 0
 
 # <next few lines under version control, do not edit>


More information about the Dart-dev mailing list