Skip to content

Commit

Permalink
[develop] Fixes to enable stochastic physics (#870)
Browse files Browse the repository at this point in the history
These changes allow ensemble mode to use seeds generated to be unique to the forecast cycle and ensemble member, and they also allow stochastic physics to be turned on in deterministic mode.
  • Loading branch information
willmayfield authored Jul 28, 2023
1 parent eb90788 commit 26b3ac8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
7 changes: 3 additions & 4 deletions scripts/exregional_run_fcst.sh
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,12 @@ fi
#-----------------------------------------------------------------------
#
STOCH="FALSE"
if [ "${DO_ENSEMBLE}" = "TRUE" ] && ([ "${DO_SPP}" = "TRUE" ] || [ "${DO_SPPT}" = "TRUE" ] || [ "${DO_SHUM}" = "TRUE" ] || \
if ([ "${DO_SPP}" = "TRUE" ] || [ "${DO_SPPT}" = "TRUE" ] || [ "${DO_SHUM}" = "TRUE" ] || \
[ "${DO_SKEB}" = "TRUE" ] || [ "${DO_LSM_SPP}" = "TRUE" ]); then
STOCH="TRUE"
fi
if [ "${STOCH}" == "TRUE" ]; then
ln_vrfy -sf ${FV3_NML_STOCH_FP} ${DATA}/${FV3_NML_FN}
cp_vrfy ${FV3_NML_STOCH_FP} ${DATA}/${FV3_NML_FN}
else
ln_vrfy -sf ${FV3_NML_FP} ${DATA}/${FV3_NML_FN}
fi
Expand All @@ -461,8 +461,7 @@ fi
#
#-----------------------------------------------------------------------
#
if [ "$STOCH" == "TRUE" ]; then
cp_vrfy ${DATA}/${FV3_NML_FN} ${DATA}/${FV3_NML_FN}_base
if ([ "$STOCH" == "TRUE" ] && [ "${DO_ENSEMBLE}" = "TRUE" ]); then
python3 $USHdir/set_FV3nml_ens_stoch_seeds.py \
--path-to-defns ${GLOBAL_VAR_DEFNS_FP} \
--cdate "$CDATE" || print_err_msg_exit "\
Expand Down
4 changes: 2 additions & 2 deletions tests/test_python/test_set_FV3nml_ens_stoch_seeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ def setUp(self):
mkdir_vrfy("-p", self.mem_dir)
cp_vrfy(
os.path.join(PARMdir, "input.nml.FV3"),
os.path.join(EXPTDIR, "input.nml_base"),
os.path.join(self.mem_dir, "input.nml"),
)


set_env_var("USHdir", USHdir)
set_env_var("ENSMEM_INDX", 2)
set_env_var("FV3_NML_FN", "input.nml")
set_env_var("FV3_NML_FP", os.path.join(EXPTDIR, "input.nml_base"))
set_env_var("FV3_NML_FP", os.path.join(self.mem_dir, "input.nml"))
set_env_var("DO_SHUM", True)
set_env_var("DO_SKEB", True)
set_env_var("DO_SPPT", True)
Expand Down
2 changes: 1 addition & 1 deletion ush/generate_FV3LAM_wflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ def generate_FV3LAM_wflow(
#
#-----------------------------------------------------------------------
#
if DO_ENSEMBLE and any((DO_SPP, DO_SPPT, DO_SHUM, DO_SKEB, DO_LSM_SPP)):
if any((DO_SPP, DO_SPPT, DO_SHUM, DO_SKEB, DO_LSM_SPP)):

set_namelist(
[
Expand Down
8 changes: 4 additions & 4 deletions ush/set_FV3nml_ens_stoch_seeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def set_FV3nml_ens_stoch_seeds(cdate):
#
# -----------------------------------------------------------------------
#
fv3_nml_ensmem_fp = f"{os.getcwd()}{os.sep}{FV3_NML_FN}_base"
fv3_nml_ensmem_fp = f"{os.getcwd()}{os.sep}{FV3_NML_FN}"

ensmem_num = int(ENSMEM_INDX)

Expand Down Expand Up @@ -93,14 +93,14 @@ def set_FV3nml_ens_stoch_seeds(cdate):
if DO_LSM_SPP:
iseed_lsm_spp = cdate_i * 1000 + ensmem_num * 10 + 9

settings["nam_sppperts"] = {"iseed_lndp": [iseed_lsm_spp]}
settings["nam_sfcperts"] = {"iseed_lndp": [iseed_lsm_spp]}

settings_str = cfg_to_yaml_str(settings)

print_info_msg(
dedent(
f"""
The variable 'settings' specifying seeds in '{FV3_NML_FP}'
The variable 'settings' specifying seeds in '{fv3_nml_ensmem_fp}'
has been set as follows:
settings =\n\n"""
Expand All @@ -111,7 +111,7 @@ def set_FV3nml_ens_stoch_seeds(cdate):

try:
set_namelist(
["-q", "-n", FV3_NML_FP, "-u", settings_str, "-o", fv3_nml_ensmem_fp]
["-q", "-n", fv3_nml_ensmem_fp, "-u", settings_str, "-o", fv3_nml_ensmem_fp]
)
except:
print_err_msg_exit(
Expand Down

0 comments on commit 26b3ac8

Please sign in to comment.