Skip to content

Commit

Permalink
Enable different coupled settings for ensemble
Browse files Browse the repository at this point in the history
Preliminarily adds the ability to turn off some coupled components for
the ensemble.

To enable this, many settings are moved out of `config.fcst` and into
`config.ufs` so they are calculated after any overrides of `DO_*` have
been made. Some settings also had to be moved out of `config.base` for
the same reason.

The name of the nems configure template used is converted from a
partial file name to the full file name. In anticipation of NOAA-EMC#1942, the
filename is assigned to a variable named `ufs_configure_template`,
though otherwise 'nems' is still used for filenames, etc.

Refs NOAA-EMC#1692
  • Loading branch information
WalterKolczynski-NOAA committed Nov 6, 2023
1 parent 75269e4 commit f39438c
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 71 deletions.
11 changes: 0 additions & 11 deletions parm/config/gfs/config.base.emc.dyn
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,8 @@ export DO_WAVE="NO"
export DO_OCN="NO"
export DO_ICE="NO"
export DO_AERO="NO"
export CCPP_SUITE="FV3_GFS_v17_p8"
export WAVE_CDUMP="" # When to include wave suite: gdas, gfs, or both
export DOBNDPNT_WAVE="NO"
export cplwav2atm=".false."
export FRAC_GRID=".true."

# Set operational resolution
Expand Down Expand Up @@ -193,17 +191,14 @@ export ICERES=${OCNRES}

case "${APP}" in
ATM)
export confignamevarfornems="atm"
;;
ATMA)
export DO_AERO="YES"
export confignamevarfornems="atm_aero"
;;
ATMW)
export DO_COUPLED="YES"
export DO_WAVE="YES"
export WAVE_CDUMP="both"
export confignamevarfornems="leapfrog_atm_wav"
;;
NG-GODAS)
export DO_ATM="NO"
Expand All @@ -214,21 +209,15 @@ case "${APP}" in
export DO_COUPLED="YES"
export DO_OCN="YES"
export DO_ICE="YES"
export CCPP_SUITE="FV3_GFS_v17_coupled_p8" # TODO: Does this include FV3_GFS_v17_p8? Can this be used instead of FV3_GFS_v17_p8 on L149
export confignamevarfornems="cpld"

if [[ "${APP}" =~ A$ ]]; then
export DO_AERO="YES"
export confignamevarfornems="${confignamevarfornems}_aero"
fi

if [[ "${APP}" =~ ^S2SW ]]; then
export DO_WAVE="YES"
export WAVE_CDUMP="both"
export cplwav2atm=".true."
export confignamevarfornems="${confignamevarfornems}_outerwave"
fi

;;
*)
echo "Unrecognized APP: '${APP}'"
Expand Down
56 changes: 0 additions & 56 deletions parm/config/gfs/config.fcst
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ string="--fv3 ${CASE}"
# shellcheck disable=SC2086
source "${EXPDIR}/config.ufs" ${string}

# Source component configs if necessary
for component in WAVE OCN ICE AERO; do
control="DO_${component}"
if [[ ${!control} == "YES" ]]; then
source "${EXPDIR}/config.${component,,}"
fi
done

# Get task specific resources
source "${EXPDIR}/config.resources" fcst
Expand All @@ -41,35 +34,6 @@ export esmf_profile=".false."
export esmf_logkind="ESMF_LOGKIND_MULTI_ON_ERROR" #Options: ESMF_LOGKIND_MULTI_ON_ERROR, ESMF_LOGKIND_MULTI, ESMF_LOGKIND_NONE


#######################################################################
# COUPLING COMPONENTS

# cpl defaults
export cpl=".false."
export cplflx=".false."
export cplice=".false."
export cplchm=".false."
export cplwav=".false."

# cpl changes based on APP

if [[ "${DO_COUPLED}" == "YES" ]]; then
export cpl=".true."
fi
if [[ "${DO_AERO}" == "YES" ]]; then
export cplchm=".true."
fi
if [[ "${DO_ICE}" == "YES" ]]; then
export cplice=".true."
export cplflx=".true."
fi
if [[ "${DO_OCN}" == "YES" ]]; then
export cplflx=".true."
fi
if [[ "${DO_WAVE}" == "YES" ]]; then
export cplwav=".true."
fi

#######################################################################

export FORECASTSH="${HOMEgfs}/scripts/exglobal_forecast.sh"
Expand Down Expand Up @@ -282,16 +246,12 @@ if [[ "${CDUMP}" =~ "gdas" ]] ; then # GDAS cycle specific parameters
# Variables used in DA cycling
export DIAG_TABLE="${HOMEgfs}/parm/ufs/fv3/diag_table_da"


if [[ "${DOIAU}" == "YES" ]]; then
export restart_interval="3"
else
export restart_interval="6"
fi

# Choose coupling with wave
if [[ "${DO_WAVE}" == "YES" ]]; then export cplwav=".true." ; fi

# Turn on dry mass adjustment in GDAS
export adjust_dry_mass=".true."

Expand All @@ -303,11 +263,6 @@ elif [[ "${CDUMP}" =~ "gfs" ]] ; then # GFS cycle specific parameters
# Write gfs restart files to rerun fcst from any break point
export restart_interval=${restart_interval_gfs:-12}

# Choose coupling with wave
if [[ "${DO_WAVE}" = "YES" && "${WAVE_CDUMP}" != "gdas" ]]; then
export cplwav=".true."
fi

# Turn off dry mass adjustment in GFS
export adjust_dry_mass=".false."

Expand All @@ -320,17 +275,6 @@ elif [[ "${CDUMP}" =~ "gfs" ]] ; then # GFS cycle specific parameters

fi

if [[ "${DO_AERO}" = "YES" ]]; then # temporary settings for aerosol coupling
export AERO_DIAG_TABLE="${AERO_DIAG_TABLE:-${HOMEgfs}/parm/ufs/fv3/diag_table.aero}"
export AERO_FIELD_TABLE="${AERO_FIELD_TABLE:-${HOMEgfs}/parm/ufs/fv3/field_table.aero}"
AERO_EMIS_FIRE="${AERO_EMIS_FIRE:-none}"
export AERO_EMIS_FIRE=${AERO_EMIS_FIRE,,}
export AERO_CONFIG_DIR="${AERO_CONFIG_DIR:-${HOMEgfs}/parm/ufs/chem}"
export AERO_INPUTS_DIR="${AERO_INPUTS_DIR:-}"
export fscav_aero="${aero_conv_scav_factors:-${fscav_aero}}"
export dnats_aero="${aero_diag_tracers:-0}"
fi

# Remember config.efcs will over-ride these values for ensemble forecasts
# if these variables are re-defined there.
# Otherwise, the ensemble forecast will inherit from config.fcst
Expand Down
81 changes: 79 additions & 2 deletions parm/config/gfs/config.ufs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

echo "BEGIN: config.ufs"

if [ $# -le 1 ]; then
if (( $# <= 1 )); then

echo "Must specify an input resolution argument to set variables!"
echo "argument can be any one of the following:"
Expand All @@ -28,7 +28,7 @@ skip_ww3=true
skip_mediator=true

# Loop through named arguments
while [[ $# -gt 0 ]]; do
while (( $# > 0 )); do
key="$1"
case "${key}" in
"--fv3")
Expand Down Expand Up @@ -60,6 +60,14 @@ if [[ "${skip_mom6}" == "false" ]] || [[ "${skip_cice6}" == "false" ]] || [[ "${
skip_mediator=false
fi

# Source component configs if necessary
for component in WAVE OCN ICE AERO; do
control="DO_${component}"
if [[ ${!control} == "YES" ]]; then
source "${EXPDIR}/config.${component,,}"
fi
done

case "${machine}" in
"WCOSS2")
npe_node_max=128
Expand Down Expand Up @@ -98,6 +106,10 @@ case "${machine}" in
;;
esac
;;
*)
echo "FATAL ERROR: Unrecognized machine ${machine}"
exit 14
;;
esac
export npe_node_max

Expand Down Expand Up @@ -232,16 +244,34 @@ case ${fv3_res} in
OUTPUT_FILETYPE_ATM="netcdf_parallel"
OUTPUT_FILETYPE_SFC="netcdf_parallel"
;;
*)
echo "FATAL ERROR: Unrecognized FV3 resolution ${fv3_res}"
exit 15
;;
esac
export OUTPUT_FILETYPE_ATM OUTPUT_FILETYPE_SFC

# cpl defaults
export cpl=".false."
export cplflx=".false."
export cplice=".false."
export cplchm=".false."
export cplwav=".false."
export cplwav2atm=".false."
export CCPP_SUITE="FV3_GFS_v17_p8"
model_list="atm"

# Mediator specific settings
if [[ "${skip_mediator}" == "false" ]]; then
export cpl=".true."
export nthreads_mediator=${nthreads_fv3} # Use same threads as FV3
export CCPP_SUITE="FV3_GFS_v17_coupled_p8" # TODO: Does this include FV3_GFS_v17_p8? Can this be used instead of FV3_GFS_v17_p8?
fi

# MOM6 specific settings
if [[ "${skip_mom6}" == "false" ]]; then
export cplflx=".true."
model_list="${model_list}.ocean"
nthreads_mom6=1
case "${mom6_res}" in
"500")
Expand Down Expand Up @@ -350,11 +380,14 @@ fi

# CICE6 specific settings
if [[ "${skip_cice6}" == "false" ]]; then
model_list="${model_list}.ice"
# Ensure we sourced the MOM6 section
if [[ "${skip_mom6}" == "true" ]]; then
echo "FATAL ERROR: CICE6 cannot be configured without MOM6, ABORT!"
exit 1
fi

export cplice=".true."
nthreads_cice6=${nthreads_mom6} # CICE6 needs to run on same threads as MOM6
case "${cice6_res}" in
"500")
Expand Down Expand Up @@ -386,6 +419,9 @@ fi

# WW3 specific settings
if [[ "${skip_ww3}" == "false" ]]; then
export cplwav=".true."
export cplwav2atm=".true."
model_list="${model_list}.wave"
nthreads_ww3=2
case "${ww3_res}" in
"gnh_10m;aoc_9km;gsh_15m")
Expand Down Expand Up @@ -416,4 +452,45 @@ if [[ "${skip_ww3}" == "false" ]]; then
export ntasks_ww3 nthreads_ww3
fi

# GOCART specific settings
if [[ "${DO_AERO}" = "YES" ]]; then # temporary settings for aerosol coupling
export cplchm=".true."

model_list="${model_list}.aero"
export AERO_DIAG_TABLE="${AERO_DIAG_TABLE:-${HOMEgfs}/parm/ufs/fv3/diag_table.aero}"
export AERO_FIELD_TABLE="${AERO_FIELD_TABLE:-${HOMEgfs}/parm/ufs/fv3/field_table.aero}"
AERO_EMIS_FIRE="${AERO_EMIS_FIRE:-none}"
export AERO_EMIS_FIRE=${AERO_EMIS_FIRE,,}
export AERO_CONFIG_DIR="${AERO_CONFIG_DIR:-${HOMEgfs}/parm/ufs/chem}"
export AERO_INPUTS_DIR="${AERO_INPUTS_DIR:-}"
export fscav_aero="${aero_conv_scav_factors:-${fscav_aero}}"
export dnats_aero="${aero_diag_tracers:-0}"
fi

# Set the name of the UFS (previously nems) configure template to use
case "${model_list}" in
atm)
export ufs_configure_template="nems.configure.atm.IN"
;;
atm.aero)
export ufs_configure_template="nems.configure.atm_aero.IN"
;;
atm.wave)
export ufs_configure_template="nems.configure.leapfrog_atm_wav.IN"
;;
atm.ocean.ice)
export ufs_configure_template="nems.configure.cpld.IN"
;;
atm.ocean.ice.aero)
export ufs_configure_template="nems.configure.cpld_aero.IN"
;;
atm.ocean.ice.wave.aero)
export ufs_configure_template="nems.configure.cpld_aero_outerwave.IN"
;;
*)
echo "FATAL ERROR: Unable to determine appropriate UFS configure template for ${model_list}"
exit 16
;;
esac

echo "END: config.ufs"
4 changes: 2 additions & 2 deletions ush/nems_configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ if [[ "${cplchm}" = ".true." ]]; then
fi

# Ensure the template exists
template="${HOMEgfs}/parm/ufs/nems.configure.${confignamevarfornems}.IN"
template="${HOMEgfs}/parm/ufs/${ufs_configure_template}"
if [[ ! -f ${template} ]]; then
echo "FATAL ERROR: template '${template}' does not exist, ABORT!"
exit 1
Expand All @@ -103,6 +103,6 @@ cat nems.configure

${NCP} "${HOMEgfs}/sorc/ufs_model.fd/tests/parm/fd_nems.yaml" fd_nems.yaml

echo "SUB ${FUNCNAME[0]}: nems.configure.sh ends for ${confignamevarfornems}"
echo "SUB ${FUNCNAME[0]}: nems.configure.sh ends for ${ufs_configure_template}"

}

0 comments on commit f39438c

Please sign in to comment.