From 2aa29cd7733116ac33178d3a5bc648a9a1080be8 Mon Sep 17 00:00:00 2001 From: chunhua zhou Date: Fri, 7 Oct 2022 21:57:41 -0600 Subject: [PATCH] Add cycle-specific stochastics namelists (#430) * Add cycle-specific stochastics namelists * Update exregional_run_fcst.sh --- scripts/exregional_run_fcst.sh | 40 ++++- ush/config.sh.RRFS_CONUS_3km_ens | 3 +- ush/config_defaults.sh | 5 + ush/generate_FV3LAM_wflow.sh | 243 ++++++++++++++++++------------ ush/set_FV3nml_ens_stoch_seeds.sh | 4 +- ush/setup.sh | 4 + ush/templates/FV3LAM_wflow.xml | 3 + 7 files changed, 194 insertions(+), 108 deletions(-) diff --git a/scripts/exregional_run_fcst.sh b/scripts/exregional_run_fcst.sh index 404c53bf2..6d583bded 100755 --- a/scripts/exregional_run_fcst.sh +++ b/scripts/exregional_run_fcst.sh @@ -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: diff --git a/ush/config.sh.RRFS_CONUS_3km_ens b/ush/config.sh.RRFS_CONUS_3km_ens index 379dd8b98..6883d100e 100644 --- a/ush/config.sh.RRFS_CONUS_3km_ens +++ b/ush/config.sh.RRFS_CONUS_3km_ens @@ -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" @@ -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" diff --git a/ush/config_defaults.sh b/ush/config_defaults.sh index 860985715..134c782ad 100644 --- a/ush/config_defaults.sh +++ b/ush/config_defaults.sh @@ -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. # @@ -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" diff --git a/ush/generate_FV3LAM_wflow.sh b/ush/generate_FV3LAM_wflow.sh index 276a26346..fc5f1c9ab 100755 --- a/ush/generate_FV3LAM_wflow.sh +++ b/ush/generate_FV3LAM_wflow.sh @@ -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 @@ -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}, }" # @@ -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" # #----------------------------------------------------------------------- # @@ -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 # #----------------------------------------------------------------------- diff --git a/ush/set_FV3nml_ens_stoch_seeds.sh b/ush/set_FV3nml_ens_stoch_seeds.sh index 733fa2bca..a4dd099ff 100644 --- a/ush/set_FV3nml_ens_stoch_seeds.sh +++ b/ush/set_FV3nml_ens_stoch_seeds.sh @@ -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})) diff --git a/ush/setup.sh b/ush/setup.sh index cefbafcc8..fbc79bac2 100755 --- a/ush/setup.sh +++ b/ush/setup.sh @@ -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}" # #----------------------------------------------------------------------- @@ -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}" diff --git a/ush/templates/FV3LAM_wflow.xml b/ush/templates/FV3LAM_wflow.xml index d8954e30a..5dfbddbe2 100644 --- a/ush/templates/FV3LAM_wflow.xml +++ b/ush/templates/FV3LAM_wflow.xml @@ -833,6 +833,7 @@ MODULES_RUN_TASK_FP script. GLOBAL_VAR_DEFNS_FP&GLOBAL_VAR_DEFNS_FP; PDY@Y@m@d CDATE@Y@m@d@H + HH@H CYCLE_DIR&CYCLE_BASEDIR;/@Y@m@d@H SLASH_ENSMEM_SUBDIR{{ slash_ensmem_subdir }} ENSMEM_INDX#{{ ensmem_indx_name }}# @@ -1360,6 +1361,7 @@ MODULES_RUN_TASK_FP script. GLOBAL_VAR_DEFNS_FP&GLOBAL_VAR_DEFNS_FP; PDY@Y@m@d CDATE@Y@m@d@H + HH@H CYCLE_DIR&CYCLE_BASEDIR;/@Y@m@d@H SLASH_ENSMEM_SUBDIR{{ slash_ensmem_subdir }} ENSMEM_INDX#{{ ensmem_indx_name }}# @@ -2337,6 +2339,7 @@ MODULES_RUN_TASK_FP script. GLOBAL_VAR_DEFNS_FP&GLOBAL_VAR_DEFNS_FP; PDY@Y@m@d CDATE@Y@m@d@H + HH@H CYCLE_DIR&CYCLE_BASEDIR;/@Y@m@d@H SLASH_ENSMEM_SUBDIR{{ slash_ensmem_subdir }} ENSMEM_INDX#{{ ensmem_indx_name }}#