Skip to content

Commit

Permalink
Add missing user-defined stochastic physics options; fix stochastic p…
Browse files Browse the repository at this point in the history
…hysics seed generation script (#704)

## DESCRIPTION OF CHANGES: 
Add missing user-defined options for tendency-based stochastic physics and fix the ensemble-based seed generation script to work regardless of whether stochastic physics is turned on or not.

## TESTS CONDUCTED: 
Tested on Hera using the following WE2E configurations with and without stochastic physics:

config.grid_RRFS_CONUS_3km_ics_HRRR_lbcs_RAP_suite_HRRR.sh
config.community_ensemble_2mems.sh

## ISSUE (optional): 
[Issue #702](ufs-community/regional_workflow#702)

## CONTRIBUTORS (optional): 
Thanks to @mkavulich and @chan-hoo for finding this problem.
  • Loading branch information
JeffBeck-NOAA committed Mar 23, 2022
1 parent 6bbecfb commit add8b2c
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 57 deletions.
7 changes: 4 additions & 3 deletions scripts/exregional_run_fcst.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#
. ${GLOBAL_VAR_DEFNS_FP}
. $USHDIR/source_util_funcs.sh
. $USHDIR/set_FV3nml_stoch_params.sh
. $USHDIR/set_FV3nml_ens_stoch_seeds.sh
#
#-----------------------------------------------------------------------
#
Expand Down Expand Up @@ -444,8 +444,9 @@ if [ ${WRITE_DOPOST} = "TRUE" ]; then
cp_vrfy ${UPP_DIR}/parm/params_grib2_tbl_new .
fi

if [ "${DO_ENSEMBLE}" = TRUE ]; then
set_FV3nml_stoch_params cdate="$cdate" || print_err_msg_exit "\
if [ "${DO_ENSEMBLE}" = TRUE ] && ([ "${DO_SPP}" = TRUE ] || [ "${DO_SPPT}" = TRUE ] || [ "${DO_SHUM}" = TRUE ] \
[ "${DO_SKEB}" = TRUE ] || [ "${DO_LSM_SPP}" = TRUE ]); then
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:
cdate = \"${cdate}\"
Expand Down
9 changes: 9 additions & 0 deletions ush/config_defaults.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1504,6 +1504,7 @@ FIXgsm_FILES_TO_COPY_TO_FIXam=( \
"global_hyblev.l65.txt" \
"global_zorclim.1x1.grb" \
"global_sfc_emissivity_idx.txt" \
"global_tg3clim.2.6x1.5.grb" \
"global_solarconstant_noaa_an.txt" \
"global_albedo4.1x1.grb" \
"geo_em.d01.lat-lon.2.5m.HGT_M.nc" \
Expand Down Expand Up @@ -1558,6 +1559,7 @@ CYCLEDIR_LINKS_TO_FIXam_FILES_MAPPING=( \
"global_h2oprdlos.f77 | global_h2o_pltc.f77" \
"global_albedo4.1x1.grb | global_albedo4.1x1.grb" \
"global_zorclim.1x1.grb | global_zorclim.1x1.grb" \
"global_tg3clim.2.6x1.5.grb | global_tg3clim.2.6x1.5.grb" \
"sfc_emissivity_idx.txt | global_sfc_emissivity_idx.txt" \
"solarconstant_noaa_an.txt | global_solarconstant_noaa_an.txt" \
"global_o3prdlos.f77 | " \
Expand Down Expand Up @@ -1793,18 +1795,25 @@ NUM_ENS_MEMBERS="1"
DO_SHUM="FALSE"
DO_SPPT="FALSE"
DO_SKEB="FALSE"
ISEED_SPPT="1"
ISEED_SHUM="2"
ISEED_SKEB="3"
NEW_LSCALE="TRUE"
SHUM_MAG="0.006" #Variable "shum" in input.nml
SHUM_LSCALE="150000"
SHUM_TSCALE="21600" #Variable "shum_tau" in input.nml
SHUM_INT="3600" #Variable "shumint" in input.nml
SPPT_MAG="0.7" #Variable "sppt" in input.nml
SPPT_LOGIT="TRUE"
SPPT_LSCALE="150000"
SPPT_TSCALE="21600" #Variable "sppt_tau" in input.nml
SPPT_INT="3600" #Variable "spptint" in input.nml
SPPT_SFCLIMIT="TRUE"
SKEB_MAG="0.5" #Variable "skeb" in input.nml
SKEB_LSCALE="150000"
SKEB_TSCALE="21600" #Variable "skeb_tau" in input.nml
SKEB_INT="3600" #Variable "skebint" in input.nml
SKEBNORM="1"
SKEB_VDOF="10"
USE_ZMTNBLCK="FALSE"
#
Expand Down
64 changes: 45 additions & 19 deletions ush/generate_FV3LAM_wflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -790,22 +790,6 @@ settings="\
'lndp_type': ${LNDP_TYPE},
'lndp_each_step': ${LSM_SPP_EACH_STEP},
'fhcyc': ${FHCYC_LSM_SPP_OR_NOT},
}
'nam_stochy': {
'shum': ${SHUM_MAG},
'shum_lscale': ${SHUM_LSCALE},
'shum_tau': ${SHUM_TSCALE},
'shumint': ${SHUM_INT},
'sppt': ${SPPT_MAG},
'sppt_lscale': ${SPPT_LSCALE},
'sppt_tau': ${SPPT_TSCALE},
'spptint': ${SPPT_INT},
'skeb': ${SKEB_MAG},
'skeb_lscale': ${SKEB_LSCALE},
'skeb_tau': ${SKEB_TSCALE},
'skebint': ${SKEB_INT},
'skeb_vdof': ${SKEB_VDOF},
'use_zmtnblck': ${USE_ZMTNBLCK},
}"
#
# Add to "settings" the values of those namelist variables that specify
Expand Down Expand Up @@ -862,6 +846,51 @@ done
settings="$settings
}"
#
# Add the relevant tendency-based stochastic physics namelist variables to
# "settings" when running with SPPT, SHUM, or SKEB turned on. 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},
'use_zmtnblck': ${USE_ZMTNBLCK},"
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},
'use_zmtnblck': ${USE_ZMTNBLCK},"
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.
#
Expand Down Expand Up @@ -1067,9 +1096,6 @@ fi

}




#
#-----------------------------------------------------------------------
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#
#-----------------------------------------------------------------------
#
function set_FV3nml_stoch_params() {
function set_FV3nml_ens_stoch_seeds() {
#
#-----------------------------------------------------------------------
#
Expand Down Expand Up @@ -98,48 +98,67 @@ function set_FV3nml_stoch_params() {

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

settings="\
'nam_stochy': {"

if [ ${DO_SPPT} = TRUE ]; then

iseed_sppt=$(( cdate*1000 + ensmem_num*10 + 1 ))
settings="$settings
'iseed_sppt': ${iseed_sppt},"

fi

if [ ${DO_SHUM} = TRUE ]; then

iseed_shum=$(( cdate*1000 + ensmem_num*10 + 2 ))
settings="$settings
'iseed_shum': ${iseed_shum},"

fi

if [ ${DO_SKEB} = TRUE ]; then

iseed_skeb=$(( cdate*1000 + ensmem_num*10 + 3 ))
iseed_sppt=$(( cdate*1000 + ensmem_num*10 + 1 ))
iseed_lsm_spp=$(( cdate*1000 + ensmem_num*10 + 9))
settings="$settings
'iseed_skeb': ${iseed_skeb},"

fi
settings="$settings
}"

settings="$settings
'nam_sppperts': {"

if [ ${DO_SPP} = TRUE ]; then

num_iseed_spp=${#ISEED_SPP[@]}
for (( i=0; i<${num_iseed_spp}; i++ )); do
iseed_spp[$i]=$(( cdate*1000 + ensmem_num*10 + ${ISEED_SPP[$i]} ))
done

settings=""

if [ ${DO_SPPT} = TRUE ] || [ ${DO_SHUM} = TRUE ] || [ ${DO_SKEB} = TRUE ]; then

settings=$settings"\
'nam_stochy': {
'iseed_shum': ${iseed_shum},
'iseed_skeb': ${iseed_skeb},
'iseed_sppt': ${iseed_sppt},
}
"
settings="$settings
'iseed_spp': [ $( printf "%s, " "${iseed_spp[@]}" ) ],"

fi

if [ ${DO_SPP} = TRUE ]; then
settings="$settings
}"

settings=$settings"\
'nam_sppperts': {
'iseed_spp': [ $( printf "%s, " "${iseed_spp[@]}" ) ]
}
"
fi
settings="$settings
'nam_sfcperts': {"

if [ ${DO_LSM_SPP} = TRUE ]; then

iseed_lsm_spp=$(( cdate*1000 + ensmem_num*10 + 9))

settings="$settings
'iseed_lndp': [ $( printf "%s, " "${iseed_lsm_spp[@]}" ) ],"

settings=$settings"\
'nam_sfcperts': {
'iseed_lndp': [ $( printf "%s, " "${iseed_lsm_spp[@]}" ) ]
}
"
fi

if [ -n "$settings" ]; then
settings="$settings
}"

$USHDIR/set_namelist.py -q \
-n ${FV3_NML_FP} \
Expand All @@ -156,14 +175,6 @@ failed. Parameters passed to this script are:
Namelist settings specified on command line (these have highest precedence):
settings =
$settings"

else

print_info_msg "\
The variable \"settings\" is empty, so not setting any namelist values."

fi

#
#-----------------------------------------------------------------------
#
Expand Down

0 comments on commit add8b2c

Please sign in to comment.