Skip to content

Commit

Permalink
Add cycle-specific stochastics namelists (NOAA-EMC#430)
Browse files Browse the repository at this point in the history
* Add cycle-specific stochastics namelists

* Update exregional_run_fcst.sh
  • Loading branch information
chunhuazhou authored Oct 8, 2022
1 parent 9c04aca commit 2aa29cd
Show file tree
Hide file tree
Showing 7 changed files with 194 additions and 108 deletions.
40 changes: 34 additions & 6 deletions scripts/exregional_run_fcst.sh
Original file line number Diff line number Diff line change
Expand Up @@ -493,22 +493,50 @@ ln_vrfy -sf ${relative_or_null} ${FIELD_TABLE_FP} ${run_dir}
ln_vrfy -sf ${relative_or_null} ${NEMS_CONFIG_FP} ${run_dir}
ln_vrfy -sf ${relative_or_null} ${NEMS_YAML_FP} ${run_dir}

#
# Determine if running stochastic physics for the specified cycles in CYCL_HRS_STOCH
#
STOCH="FALSE"
if [ "${DO_ENSEMBLE}" = TRUE ] && ([ "${DO_SPP}" = TRUE ] || [ "${DO_SPPT}" = TRUE ] || [ "${DO_SHUM}" = TRUE ] \
|| [ "${DO_SKEB}" = TRUE ] || [ "${DO_LSM_SPP}" = TRUE ]); then
for cyc_start in "${CYCL_HRS_STOCH[@]}"; do
if [ ${HH} -eq ${cyc_start} ]; then
if [ "${DO_ENSFCST}" = TRUE ]; then
if [ ${cycle_type} == "ensfcst" ]; then
STOCH="TRUE"
else
STOCH="FALSE"
fi
else
STOCH="TRUE"
fi
fi
done
fi

if [ ${BKTYPE} -eq 0 ]; then
# cycling, using namelist for cycling forecast
cp_vrfy ${FV3_NML_RESTART_FP} ${run_dir}/input.nml
if [ "${STOCH}" == "TRUE" ]; then
cp_vrfy ${FV3_NML_RESTART_STOCH_FP} ${run_dir}/${FV3_NML_FN}
else
cp_vrfy ${FV3_NML_RESTART_FP} ${run_dir}/${FV3_NML_FN}
fi
else
if [ -f "INPUT/cycle_surface.done" ]; then
# namelist for cold start with surface cycle
cp_vrfy ${FV3_NML_CYCSFC_FP} ${run_dir}/input.nml
cp_vrfy ${FV3_NML_CYCSFC_FP} ${run_dir}/${FV3_NML_FN}
else
# cold start, using namelist for cold start
cp_vrfy ${FV3_NML_FP} ${run_dir}/input.nml
if [ "${STOCH}" == "TRUE" ]; then
cp_vrfy ${FV3_NML_STOCH_FP} ${run_dir}/${FV3_NML_FN}
else
cp_vrfy ${FV3_NML_FP} ${run_dir}/${FV3_NML_FN}
fi
fi
fi

if [ "${DO_ENSEMBLE}" = TRUE ] && ([ "${DO_SPP}" = TRUE ] || [ "${DO_SPPT}" = TRUE ] || [ "${DO_SHUM}" = TRUE ] \
[ "${DO_SKEB}" = TRUE ] || [ "${DO_LSM_SPP}" = TRUE ]); then
cp ${run_dir}/input.nml ${run_dir}/input.nml_base
if [ "${STOCH}" == "TRUE" ]; then
cp ${run_dir}/${FV3_NML_FN} ${run_dir}/${FV3_NML_FN}_base
set_FV3nml_ens_stoch_seeds cdate="$cdate" || print_err_msg_exit "\
Call to function to create the ensemble-based namelist for the current
cycle's (cdate) run directory (run_dir) failed:
Expand Down
3 changes: 2 additions & 1 deletion ush/config.sh.RRFS_CONUS_3km_ens
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ CYCL_HRS_PRODSTART=("09" "21")
CYCL_HRS_PRODSTART=("18")
CYCL_HRS_ENSINIT=("18")
CYCL_HRS_ENSFCST=("00")
CYCL_HRS_STOCH=("00")
#CYCL_HRS_RECENTER=("19")
#CYCLEMONTH="5"
#CYCLEDAY="11-12"
Expand Down Expand Up @@ -211,7 +212,7 @@ fi
if [[ ${DO_ENSEMBLE} == "TRUE" ]]; then
NUM_ENS_MEMBERS=30
# DO_SPPT=TRUE
# DO_SPP=TRUE
DO_SPP=TRUE
# SPPT_MAG=0.5
# DO_ENSCONTROL="TRUE"
DO_GSIOBSERVER="TRUE"
Expand Down
5 changes: 5 additions & 0 deletions ush/config_defaults.sh
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,10 @@ WFLOW_LAUNCH_LOG_FN="log.launch_FV3LAM_wflow"
# CYCL_HRS_ENSFCST
# An array containing the hours of the day at which the ensemble free forecast is on
#
# CYCL_HRS_STOCH
# An array containing the hours of the day at which the stochastics physcis is on
# this might include: SPPT, SHUM, SKEB, SPP, LSM_SPP
#
# BOUNDARY_LEN_HRS
# The length of boundary condition for normal forecast, in integer hours.
#
Expand Down Expand Up @@ -533,6 +537,7 @@ CYCL_HRS_PRODSTART=( "HH1" "HH2" )
CYCL_HRS_RECENTER=( "HH1" "HH2" )
CYCL_HRS_ENSINIT=( "HH1" "HH2" )
CYCL_HRS_ENSFCST=( "HH1" "HH2" )
CYCL_HRS_STOCH=( "HH1" "HH2" )
BOUNDARY_LEN_HRS="0"
BOUNDARY_LONG_LEN_HRS="0"
POSTPROC_LEN_HRS="1"
Expand Down
243 changes: 144 additions & 99 deletions ush/generate_FV3LAM_wflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ settings="\
'cycl_hrs_recenter': [ $( printf "\'%s\', " "${CYCL_HRS_RECENTER[@]}" ) ]
'cycl_hrs_ensinit': [ $( printf "\'%s\', " "${CYCL_HRS_ENSINIT[@]}" ) ]
'cycl_hrs_ensfcst': [ $( printf "\'%s\', " "${CYCL_HRS_ENSFCST[@]}" ) ]
'cycl_hrs_stoch': [ $( printf "\'%s\', " "${CYCL_HRS_STOCH[@]}" ) ]
'cycl_hrs_hyb_fv3lam_ens': [ $( printf "\'%s\', " "${CYCL_HRS_HYB_FV3LAM_ENS[@]}" ) ]
'restart_hrs_prod': ${RESTART_INTERVAL}
'cycl_freq': !!str 12:00:00
Expand Down Expand Up @@ -835,15 +836,6 @@ settings="\
'gfs_physics_nml': {
'kice': ${kice:-null},
'lsoil': ${lsoil:-null},
'do_shum': ${DO_SHUM},
'do_sppt': ${DO_SPPT},
'do_skeb': ${DO_SKEB},
'do_spp': ${DO_SPP},
'n_var_spp': ${N_VAR_SPP},
'n_var_lndp': ${N_VAR_LNDP},
'lndp_type': ${LNDP_TYPE},
'lndp_each_step': ${LSM_SPP_EACH_STEP},
'fhcyc': ${FHCYC_LSM_SPP_OR_NOT},
'print_diff_pgr': ${PRINT_DIFF_PGR},
}"
#
Expand Down Expand Up @@ -901,96 +893,6 @@ done
settings="$settings
}"
#
# Add the relevant tendency-based stochastic physics namelist variables to
# "settings" when running with SPPT, SHUM, or SKEB turned on. If running
# with SPP or LSM SPP, set the "new_lscale" variable. Otherwise only
# include an empty "nam_stochy" stanza.
#
settings="$settings
'nam_stochy': {"
if [ "${DO_SPPT}" = "TRUE" ]; then
settings="$settings
'iseed_sppt': ${ISEED_SPPT},
'new_lscale': ${NEW_LSCALE},
'sppt': ${SPPT_MAG},
'sppt_logit': ${SPPT_LOGIT},
'sppt_lscale': ${SPPT_LSCALE},
'sppt_sfclimit': ${SPPT_SFCLIMIT},
'sppt_tau': ${SPPT_TSCALE},
'spptint': ${SPPT_INT},
'use_zmtnblck': ${USE_ZMTNBLCK},"
fi

if [ "${DO_SHUM}" = "TRUE" ]; then
settings="$settings
'iseed_shum': ${ISEED_SHUM},
'new_lscale': ${NEW_LSCALE},
'shum': ${SHUM_MAG},
'shum_lscale': ${SHUM_LSCALE},
'shum_tau': ${SHUM_TSCALE},
'shumint': ${SHUM_INT},"
fi

if [ "${DO_SKEB}" = "TRUE" ]; then
settings="$settings
'iseed_skeb': ${ISEED_SKEB},
'new_lscale': ${NEW_LSCALE},
'skeb': ${SKEB_MAG},
'skeb_lscale': ${SKEB_LSCALE},
'skebnorm': ${SKEBNORM},
'skeb_tau': ${SKEB_TSCALE},
'skebint': ${SKEB_INT},
'skeb_vdof': ${SKEB_VDOF},"
fi

if [ "${DO_SPP}" = "TRUE" ] || [ "${DO_LSM_SPP}" = "TRUE" ]; then
settings="$settings
'new_lscale': ${NEW_LSCALE},"
fi
settings="$settings
}"
#
# Add the relevant SPP namelist variables to "settings" when running with
# SPP turned on. Otherwise only include an empty "nam_sppperts" stanza.
#
settings="$settings
'nam_sppperts': {"
if [ "${DO_SPP}" = "TRUE" ]; then
settings="$settings
'iseed_spp': [ $( printf "%s, " "${ISEED_SPP[@]}" ) ],
'spp_lscale': [ $( printf "%s, " "${SPP_LSCALE[@]}" ) ],
'spp_prt_list': [ $( printf "%s, " "${SPP_MAG_LIST[@]}" ) ],
'spp_sigtop1': [ $( printf "%s, " "${SPP_SIGTOP1[@]}" ) ],
'spp_sigtop2': [ $( printf "%s, " "${SPP_SIGTOP2[@]}" ) ],
'spp_stddev_cutoff': [ $( printf "%s, " "${SPP_STDDEV_CUTOFF[@]}" ) ],
'spp_tau': [ $( printf "%s, " "${SPP_TSCALE[@]}" ) ],
'spp_var_list': [ $( printf "%s, " "${SPP_VAR_LIST[@]}" ) ],"
fi
settings="$settings
}"
#
# Add the relevant LSM SPP namelist variables to "settings" when running with
# LSM SPP turned on.
#
settings="$settings
'nam_sfcperts': {"
if [ "${DO_LSM_SPP}" = "TRUE" ]; then
settings="$settings
'lndp_type': ${LNDP_TYPE},
'lndp_tau': [ $( printf "%s, " "${LSM_SPP_TSCALE[@]}" ) ],
'lndp_lscale': [ $( printf "%s, " "${LSM_SPP_LSCALE[@]}" ) ],
'iseed_lndp': [ $( printf "%s, " "${ISEED_LSM_SPP[@]}" ) ],
'lndp_var_list': [ $( printf "%s, " "${LSM_SPP_VAR_LIST[@]}" ) ],
'lndp_prt_list': [ $( printf "%s, " "${LSM_SPP_MAG_LIST[@]}" ) ],"
fi
settings="$settings
}"
print_info_msg $VERBOSE "
The variable \"settings\" specifying values of the namelist variables
has been set as follows:
settings =
$settings"
#
#-----------------------------------------------------------------------
#
Expand Down Expand Up @@ -1115,6 +1017,149 @@ if [[ "${DO_DACYCLE}" = "TRUE" || "${DO_ENKFUPDATE}" = "TRUE" ]]; then
Namelist settings specified on command line:
settings =
$settings"
fi
#
# Add the relevant tendency-based stochastic physics namelist variables to
# "settings" when running with SPPT, SHUM, or SKEB turned on. If running
# with SPP or LSM SPP, set the "new_lscale" variable. Otherwise only
# include an empty "nam_stochy" stanza.
#
settings="\
'gfs_physics_nml': {
'do_shum': ${DO_SHUM},
'do_sppt': ${DO_SPPT},
'do_skeb': ${DO_SKEB},
'do_spp': ${DO_SPP},
'n_var_spp': ${N_VAR_SPP},
'n_var_lndp': ${N_VAR_LNDP},
'lndp_type': ${LNDP_TYPE},
'lndp_each_step': ${LSM_SPP_EACH_STEP},
'fhcyc': ${FHCYC_LSM_SPP_OR_NOT},
}"
settings="$settings
'nam_stochy': {"
if [ "${DO_SPPT}" = "TRUE" ]; then
settings="$settings
'iseed_sppt': ${ISEED_SPPT},
'sppt': ${SPPT_MAG},
'sppt_logit': ${SPPT_LOGIT},
'sppt_lscale': ${SPPT_LSCALE},
'sppt_sfclimit': ${SPPT_SFCLIMIT},
'sppt_tau': ${SPPT_TSCALE},
'spptint': ${SPPT_INT},
'use_zmtnblck': ${USE_ZMTNBLCK},"
fi

if [ "${DO_SHUM}" = "TRUE" ]; then
settings="$settings
'iseed_shum': ${ISEED_SHUM},
'shum': ${SHUM_MAG},
'shum_lscale': ${SHUM_LSCALE},
'shum_tau': ${SHUM_TSCALE},
'shumint': ${SHUM_INT},"
fi

if [ "${DO_SKEB}" = "TRUE" ]; then
settings="$settings
'iseed_skeb': ${ISEED_SKEB},
'skeb': ${SKEB_MAG},
'skeb_lscale': ${SKEB_LSCALE},
'skebnorm': ${SKEBNORM},
'skeb_tau': ${SKEB_TSCALE},
'skebint': ${SKEB_INT},
'skeb_vdof': ${SKEB_VDOF},"
fi

if [ "${DO_SPP}" = "TRUE" ] || [ "${DO_LSM_SPP}" = "TRUE" ] || [ "${DO_SPPT}" = "TRUE" ] || [ "${DO_SHUM}" = "TRUE" ] || [ "${DO_SKEB}" = "TRUE" ]; then
settings="$settings
'new_lscale': ${NEW_LSCALE},"
fi
settings="$settings
}"
#
# Add the relevant SPP namelist variables to "settings" when running with
# SPP turned on. Otherwise only include an empty "nam_sppperts" stanza.
#
settings="$settings
'nam_sppperts': {"
if [ "${DO_SPP}" = "TRUE" ]; then
settings="$settings
'iseed_spp': [ $( printf "%s, " "${ISEED_SPP[@]}" ) ],
'spp_lscale': [ $( printf "%s, " "${SPP_LSCALE[@]}" ) ],
'spp_prt_list': [ $( printf "%s, " "${SPP_MAG_LIST[@]}" ) ],
'spp_sigtop1': [ $( printf "%s, " "${SPP_SIGTOP1[@]}" ) ],
'spp_sigtop2': [ $( printf "%s, " "${SPP_SIGTOP2[@]}" ) ],
'spp_stddev_cutoff': [ $( printf "%s, " "${SPP_STDDEV_CUTOFF[@]}" ) ],
'spp_tau': [ $( printf "%s, " "${SPP_TSCALE[@]}" ) ],
'spp_var_list': [ $( printf "%s, " "${SPP_VAR_LIST[@]}" ) ],"
fi
settings="$settings
}"
#
# Add the relevant LSM SPP namelist variables to "settings" when running with
# LSM SPP turned on.
#
settings="$settings
'nam_sfcperts': {"
if [ "${DO_LSM_SPP}" = "TRUE" ]; then
settings="$settings
'lndp_type': ${LNDP_TYPE},
'lndp_tau': [ $( printf "%s, " "${LSM_SPP_TSCALE[@]}" ) ],
'lndp_lscale': [ $( printf "%s, " "${LSM_SPP_LSCALE[@]}" ) ],
'iseed_lndp': [ $( printf "%s, " "${ISEED_LSM_SPP[@]}" ) ],
'lndp_var_list': [ $( printf "%s, " "${LSM_SPP_VAR_LIST[@]}" ) ],
'lndp_prt_list': [ $( printf "%s, " "${LSM_SPP_MAG_LIST[@]}" ) ],"
fi
settings="$settings
}"
print_info_msg $VERBOSE "
The variable \"settings\" specifying values of the namelist variables
has been set as follows:
settings =
$settings"
#
#-----------------------------------------------------------------------
#
# Generate namelist files with stochastic physics if needed
#
if [ "${DO_ENSEMBLE}" = TRUE ] && ([ "${DO_SPP}" = TRUE ] || [ "${DO_SPPT}" = TRUE ] || [ "${DO_SHUM}" = TRUE ] \
|| [ "${DO_SKEB}" = TRUE ] || [ "${DO_LSM_SPP}" = TRUE ]); then

$USHDIR/set_namelist.py -q \
-n ${FV3_NML_FP} \
-u "$settings" \
-o ${FV3_NML_STOCH_FP} || \
print_err_msg_exit "\
Call to python script set_namelist.py to generate an FV3 namelist file with stochastics
failed. Parameters passed to this script are:
Full path to base namelist file:
FV3_NML_FP = \"${FV3_NML_FP}\"
Full path to output namelist file for stochastics:
FV3_NML_STOCH_FP = \"${FV3_NML_STOCH_FP}\"
Namelist settings specified on command line:
settings =
$settings"
#
#-----------------------------------------------------------------------
#
if [[ "${DO_DACYCLE}" = "TRUE" || "${DO_ENKFUPDATE}" = "TRUE" ]]; then
$USHDIR/set_namelist.py -q \
-n ${FV3_NML_RESTART_FP} \
-u "$settings" \
-o ${FV3_NML_RESTART_STOCH_FP} || \
print_err_msg_exit "\
Call to python script set_namelist.py to generate an restart FV3 namelist file with stochastics
failed. Parameters passed to this script are:
Full path to base namelist file:
FV3_NML_RESTART_FP = \"${FV3_NML_RESTART_FP}\"
Full path to output namelist file for DA with stochastics:
FV3_NML_RESTART_STOCH_FP = \"${FV3_NML_RESTART_STOCH_FP}\"
Namelist settings specified on command line:
settings =
$settings"
fi

fi
#
#-----------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions ush/set_FV3nml_ens_stoch_seeds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ function set_FV3nml_ens_stoch_seeds() {
#
ensmem_name="mem${ENSMEM_INDX}"

fv3_nml_ensmem_fp_base="${CYCLE_BASEDIR}/${cdate}/${ensmem_name}/fcst_fv3lam/input.nml_base"
fv3_nml_ensmem_fp="${CYCLE_BASEDIR}/${cdate}/${ensmem_name}/fcst_fv3lam/input.nml"
fv3_nml_ensmem_fp_base="${run_dir}/input.nml_base"
fv3_nml_ensmem_fp="${run_dir}/input.nml"

ensmem_num=$((10#${ENSMEM_INDX}))

Expand Down
4 changes: 4 additions & 0 deletions ush/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1559,6 +1559,8 @@ FV3_NML_FN="${FV3_NML_BASE_SUITE_FN%.*}"
FV3_NML_FP="${EXPTDIR}/${FV3_NML_FN}"
FV3_NML_CYCSFC_FP="${EXPTDIR}/${FV3_NML_FN}_cycsfc"
FV3_NML_RESTART_FP="${EXPTDIR}/${FV3_NML_FN}_restart"
FV3_NML_STOCH_FP="${EXPTDIR}/${FV3_NML_FN}_stoch"
FV3_NML_RESTART_STOCH_FP="${EXPTDIR}/${FV3_NML_FN}_restart_stoch"
NEMS_CONFIG_FP="${EXPTDIR}/${NEMS_CONFIG_FN}"
#
#-----------------------------------------------------------------------
Expand Down Expand Up @@ -2787,6 +2789,8 @@ FV3_NML_FN="${FV3_NML_FN}" # This may not be necessary...
FV3_NML_FP="${FV3_NML_FP}"
FV3_NML_CYCSFC_FP="${FV3_NML_CYCSFC_FP}"
FV3_NML_RESTART_FP="${FV3_NML_RESTART_FP}"
FV3_NML_STOCH_FP="${FV3_NML_STOCH_FP}"
FV3_NML_RESTART_STOCH_FP="${FV3_NML_RESTART_STOCH_FP}"
NEMS_CONFIG_FP="${NEMS_CONFIG_FP}"
NEMS_YAML_FP="${NEMS_YAML_FP}"
Expand Down
Loading

0 comments on commit 2aa29cd

Please sign in to comment.