Skip to content

Commit

Permalink
Merge pull request #396 from NCAR/clm_shell_scripts
Browse files Browse the repository at this point in the history
Fixing dtlimit and single instance bug for clm shell scripts
  • Loading branch information
braczka authored Sep 16, 2022
2 parents cb9cb51 + 938c865 commit a456bf2
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 116 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ individual files.

The changes are now listed with the most recent at the top.

**September 16 2022 :: Bug-fix for CLM shell scripts. Tag: v10.3.2**

- Fixes dtlimit bug in cesm2.2 CLM shell scripts. Loads all CAM
reanalysis files within datm data stream file regardless if it
is single year or multi-year run.
- Fixes single instance bug in cems2.2 CLM shell scripts. Allows
for freerun scripts to generate single instance simulations.

**September 14 2022 :: Bug-fix for POP shell scripts. Tag: v10.3.1**

- Fixes bug in POP CESM2.1 shell scripts in which inflation files were not
Expand Down
2 changes: 1 addition & 1 deletion conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
author = 'Data Assimilation Research Section'

# The full version, including alpha/beta/rc tags
release = '10.3.1'
release = '10.3.2'
master_doc = 'README'

# -- General configuration ---------------------------------------------------
Expand Down
97 changes: 62 additions & 35 deletions models/clm/shell_scripts/cesm2_2/CLM5_hybrid_freerun
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ ${REMOVE} ${rundir}

echo " Starting create_newcase ..."

if (${num_instances} == 1) then
${cesmroot}/cime/scripts/create_newcase --res ${resolution} \
--mach ${machine} \
--compset ${compset} \
--case ${caseroot} \
--project ${project} \
--run-unsupported || exit 2
else

${cesmroot}/cime/scripts/create_newcase --res ${resolution} \
--mach ${machine} \
--compset ${compset} \
Expand All @@ -98,6 +107,9 @@ ${cesmroot}/cime/scripts/create_newcase --res ${resolution} \
--ninst ${num_instances} \
--multi-driver || exit 2

endif


# ==============================================================================
# Preserve a copy of this script and the parameter file as it was run.
# Copy the DART setup script (CESM_DART_config) to CASEROOT.
Expand Down Expand Up @@ -241,46 +253,42 @@ endif
./xmlchange INFO_DBUG=0

# ==============================================================================
# If the experiment only spans one year, copy a stream template for a single year
# otherwise, use 'all' the years.

if (${stream_year_first} == ${stream_year_last}) then
set STREAMFILE_SOLAR = datm.streams.txt.CPLHISTForcing.Solar_single_year
set STREAMFILE_STATE1HR = datm.streams.txt.CPLHISTForcing.State1hr_single_year
set STREAMFILE_STATE3HR = datm.streams.txt.CPLHISTForcing.State3hr_single_year
set STREAMFILE_NONSOLARFLUX = datm.streams.txt.CPLHISTForcing.nonSolarFlux_single_year
else
# Use the stream template that has all CAM reanalysis years available.

set STREAMFILE_SOLAR = datm.streams.txt.CPLHISTForcing.Solar_complete
set STREAMFILE_STATE1HR = datm.streams.txt.CPLHISTForcing.State1hr_complete
set STREAMFILE_STATE3HR = datm.streams.txt.CPLHISTForcing.State3hr_complete
set STREAMFILE_NONSOLARFLUX = datm.streams.txt.CPLHISTForcing.nonSolarFlux_complete
endif

# ==============================================================================
# Modify namelist templates for each instance.

@ inst = 1
while ( $inst <= $num_instances )

set inst_string = `printf %04d $inst`


if (${num_instances} == 1) then
set inst_string = ''
else
set inst_string = `printf _%04d $inst`
set inst_string2 = `printf %04d $inst`
endif
# ===========================================================================
set fname = "user_nl_datm_${inst_string}"
set fname = "user_nl_datm${inst_string}"
# ===========================================================================
# DATM namelist

set FILE1 = datm.streams.txt.CPLHISTForcing.Solar_${inst_string}
set FILE2 = datm.streams.txt.CPLHISTForcing.State1hr_${inst_string}
set FILE3 = datm.streams.txt.CPLHISTForcing.State3hr_${inst_string}
set FILE4 = datm.streams.txt.CPLHISTForcing.nonSolarFlux_${inst_string}
set FILE1 = datm.streams.txt.CPLHISTForcing.Solar${inst_string}
set FILE2 = datm.streams.txt.CPLHISTForcing.State1hr${inst_string}
set FILE3 = datm.streams.txt.CPLHISTForcing.State3hr${inst_string}
set FILE4 = datm.streams.txt.CPLHISTForcing.nonSolarFlux${inst_string}
set DOMAINFILE = '/glade/p/cesmdata/cseg/inputdata/share/domains/domain.lnd.fv0.9x1.25_gx1v7.151020.nc'

echo "domainfile = '${DOMAINFILE}'" >> ${fname}
echo "streams = '$FILE1 $stream_year_align $stream_year_first $stream_year_last'," >> ${fname}
echo " '$FILE2 $stream_year_align $stream_year_first $stream_year_last'," >> ${fname}
echo " '$FILE3 $stream_year_align $stream_year_first $stream_year_last'," >> ${fname}
echo " '$FILE4 $stream_year_align $stream_year_first $stream_year_last'," >> ${fname}
echo " 'datm.streams.txt.presaero.clim_2000_${inst_string} 2000 2000 2000'" >> ${fname}
echo " 'datm.streams.txt.presaero.clim_2000${inst_string} 2000 2000 2000'" >> ${fname}
echo "vectors = 'u:v' " >> ${fname}
echo "mapmask = 'nomask', " >> ${fname}
echo " 'nomask', " >> ${fname}
Expand All @@ -290,9 +298,6 @@ while ( $inst <= $num_instances )
echo " 'linear', " >> ${fname}
echo " 'linear', " >> ${fname}
echo " 'nearest' " >> ${fname}
if ($startdate == 2011-01-01) then
echo "dtlimit = 1.0e30" >> ${fname}
endif

# Create stream files for each ensemble member
set SOURCEDIR = ${dartroot}/models/clm/shell_scripts/cesm2_2
Expand All @@ -301,15 +306,24 @@ while ( $inst <= $num_instances )
${COPY} ${SOURCEDIR}/${STREAMFILE_STATE3HR} user_${FILE3} || exit 5
${COPY} ${SOURCEDIR}/${STREAMFILE_NONSOLARFLUX} user_${FILE4} || exit 5

foreach FNAME ( user_datm.streams.txt*${inst_string} )
echo "modifying $FNAME"
sed s/NINST/${inst_string}/g $FNAME >! temp
sed s/RUNYEAR/${stream_year_first}/g temp >! $FNAME
end

if (${num_instances} == 1) then
foreach FNAME ( user_datm.streams.txt* )
echo "modifying $FNAME"
sed s/NINST/0001/g $FNAME >! temp
sed s/RUNYEAR/${stream_year_first}/g temp >! $FNAME
end
else
foreach FNAME ( user_datm.streams.txt*${inst_string} )
echo "modifying $FNAME"
sed s/NINST/${inst_string2}/g $FNAME >! temp
sed s/RUNYEAR/${stream_year_first}/g temp >! $FNAME
end
endif
${REMOVE} temp

# ===========================================================================
set fname = "user_nl_clm_${inst_string}"
set fname = "user_nl_clm${inst_string}"
# ===========================================================================

# This is the opportunity to output additional items at your own discretion.
Expand All @@ -333,14 +347,14 @@ while ( $inst <= $num_instances )


# ===========================================================================
set fname = "user_nl_mosart_${inst_string}"
set fname = "user_nl_mosart${inst_string}"
# ===========================================================================

# We are explicitly constructing the 'finidat_rtm' to match what is getting
# staged by the 'stage_cesm_files' script
# If this file is not available or you do not want stage this file set finidat_rtm = ' '.

echo "finidat_rtm = '"${refcase}.mosart_${inst_string}.r.${reftimestamp}.nc"'" >> ${fname}
echo "finidat_rtm = '"${refcase}.mosart${inst_string}.r.${reftimestamp}.nc"'" >> ${fname}

@ inst ++
end
Expand Down Expand Up @@ -438,8 +452,12 @@ if ( \${CONTINUE_RUN} == TRUE ) then
@ inst=1
while (\$inst <= $num_instances)
set inst_string = \`printf _%04d \$inst\`
if ( \${num_instances} == 1) then
set inst_string = ''
else
set inst_string = \`printf _%04d \$inst\`
endif
echo "\${CASE}.cpl\${inst_string}.r.\${restart_time}.nc" >! rpointer.drv\${inst_string}
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}
Expand Down Expand Up @@ -468,21 +486,30 @@ else # CONTINUE_RUN == FALSE
@ inst=1
while (\$inst <= $num_instances)
if ( \${num_instances} == 1) then
set inst_string = \`printf _%04d \$inst\`
set inst_string2 = ''
else
set inst_string = \`printf _%04d \$inst\`
set inst_string2 = \`printf _%04d \$inst\`
endif
set inst_string = \`printf _%04d \$inst\`
echo "Staging initial files for instance \$inst of $num_instances"
if ( -e ${stagedir}/${refcase}.clm2\${inst_string}.r.${init_time}.nc ) then
${LINK} ${stagedir}/${refcase}.clm2\${inst_string}.r.${init_time}.nc .
${LINK} ${stagedir}/${refcase}.clm2\${inst_string}.r.${init_time}.nc \
${refcase}.clm2\${inst_string2}.r.${init_time}.nc
else
echo "ERROR: ${stagedir}/${refcase}.clm2\${inst_string}.r.${init_time}.nc does not exist."
echo " Check your 'reftimestamp' setting, or maybe your 'stagedir' or 'refcase' or ..."
exit 8
endif
if ( -e ${stagedir}/${refcase}.mosart\${inst_string}.r.${init_time}.nc ) then
${LINK} ${stagedir}/${refcase}.mosart\${inst_string}.r.${init_time}.nc .
${LINK} ${stagedir}/${refcase}.mosart\${inst_string}.r.${init_time}.nc \
${refcase}.mosart\${inst_string2}.r.${init_time}.nc
else
echo "WARNING: ${stagedir}/${refcase}.mosart\${inst_string}.r.${init_time}.nc does not exist."
echo " Check your 'reftimestamp' setting, or maybe your 'stagedir' or 'refcase' or ..."
Expand Down
15 changes: 2 additions & 13 deletions models/clm/shell_scripts/cesm2_2/CLM5_setup_assimilation
Original file line number Diff line number Diff line change
Expand Up @@ -230,20 +230,12 @@ endif
./xmlchange INFO_DBUG=0

# ==============================================================================
# If the experiment only spans one year, copy a stream template for a single year
# otherwise, use 'all' the years.

if (${stream_year_first} == ${stream_year_last}) then
set STREAMFILE_SOLAR = datm.streams.txt.CPLHISTForcing.Solar_single_year
set STREAMFILE_STATE1HR = datm.streams.txt.CPLHISTForcing.State1hr_single_year
set STREAMFILE_STATE3HR = datm.streams.txt.CPLHISTForcing.State3hr_single_year
set STREAMFILE_NONSOLARFLUX = datm.streams.txt.CPLHISTForcing.nonSolarFlux_single_year
else
# Use the stream template that has all CAM reanalysis years available.

set STREAMFILE_SOLAR = datm.streams.txt.CPLHISTForcing.Solar_complete
set STREAMFILE_STATE1HR = datm.streams.txt.CPLHISTForcing.State1hr_complete
set STREAMFILE_STATE3HR = datm.streams.txt.CPLHISTForcing.State3hr_complete
set STREAMFILE_NONSOLARFLUX = datm.streams.txt.CPLHISTForcing.nonSolarFlux_complete
endif

# ==============================================================================
# Modify namelist templates for each instance.
Expand Down Expand Up @@ -284,9 +276,6 @@ while ( $inst <= $num_instances )
echo " 'linear', " >> ${fname}
echo " 'linear', " >> ${fname}
echo " 'nearest' " >> ${fname}
if ($startdate == 2011-01-01) then
echo "dtlimit = 1.0e30" >> ${fname}
endif

# Create stream files for each ensemble member
set SOURCEDIR = ${dartroot}/models/clm/shell_scripts/cesm2_2
Expand Down
15 changes: 2 additions & 13 deletions models/clm/shell_scripts/cesm2_2/CLM5_setup_pmo
Original file line number Diff line number Diff line change
Expand Up @@ -224,20 +224,12 @@ endif
./xmlchange INFO_DBUG=0

# ==============================================================================
# If the experiment only spans one year, copy a stream template for a single year
# otherwise, use 'all' the years.

if (${stream_year_first} == ${stream_year_last}) then
set STREAMFILE_SOLAR = datm.streams.txt.CPLHISTForcing.Solar_single_year
set STREAMFILE_STATE1HR = datm.streams.txt.CPLHISTForcing.State1hr_single_year
set STREAMFILE_STATE3HR = datm.streams.txt.CPLHISTForcing.State3hr_single_year
set STREAMFILE_NONSOLARFLUX = datm.streams.txt.CPLHISTForcing.nonSolarFlux_single_year
else
# Use the stream template that has all CAM reanalysis years available.

set STREAMFILE_SOLAR = datm.streams.txt.CPLHISTForcing.Solar_complete
set STREAMFILE_STATE1HR = datm.streams.txt.CPLHISTForcing.State1hr_complete
set STREAMFILE_STATE3HR = datm.streams.txt.CPLHISTForcing.State3hr_complete
set STREAMFILE_NONSOLARFLUX = datm.streams.txt.CPLHISTForcing.nonSolarFlux_complete
endif

# ==============================================================================
# Modify namelist templates for each instance.
Expand Down Expand Up @@ -285,9 +277,6 @@ while ( $inst <= $num_instances )
echo " 'linear', " >> ${fname}
echo " 'linear', " >> ${fname}
echo " 'nearest' " >> ${fname}
if ($startdate == 2011-01-01) then
echo "dtlimit = 1.0e30" >> ${fname}
endif

# Create stream files for each ensemble member
set SOURCEDIR = ${dartroot}/models/clm/shell_scripts/cesm2_2
Expand Down
Loading

0 comments on commit a456bf2

Please sign in to comment.