Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 90 additions & 56 deletions ush/create_model_configure_file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,14 @@ nthreads \
#
#-----------------------------------------------------------------------
#
local i \
model_config_fp \
yyyy \
local yyyy \
mm \
dd \
hh \
mm \
dot_quilting_dot \
dot_print_esmf_dot
dot_print_esmf_dot \
settings \
model_config_fp
#
#-----------------------------------------------------------------------
#
Expand All @@ -89,12 +88,6 @@ Creating a model configuration file (\"${MODEL_CONFIG_FN}\") in the specified
run directory (run_dir):
run_dir = \"${run_dir}\""
#
# Copy template model configure files from the templates directory to the
# run directory.
#
model_config_fp="${run_dir}/${MODEL_CONFIG_FN}"
cp_vrfy "${MODEL_CONFIG_TMPL_FP}" "${model_config_fp}"
#
# Extract from cdate the starting year, month, day, and hour of the forecast.
#
yyyy=${cdate:0:4}
Expand All @@ -106,65 +99,106 @@ run directory (run_dir):
#
dot_quilting_dot="."${QUILTING,,}"."
dot_print_esmf_dot="."${PRINT_ESMF,,}"."

set_file_param "${model_config_fp}" "PE_MEMBER01" "${PE_MEMBER01}"
set_file_param "${model_config_fp}" "dt_atmos" "${DT_ATMOS}"
set_file_param "${model_config_fp}" "start_year" "$yyyy"
set_file_param "${model_config_fp}" "start_month" "$mm"
set_file_param "${model_config_fp}" "start_day" "$dd"
set_file_param "${model_config_fp}" "start_hour" "$hh"
set_file_param "${model_config_fp}" "nhours_fcst" "${FCST_LEN_HRS}"
set_file_param "${model_config_fp}" "ncores_per_node" "${NCORES_PER_NODE}"
set_file_param "${model_config_fp}" "quilting" "${dot_quilting_dot}"
set_file_param "${model_config_fp}" "print_esmf" "${dot_print_esmf_dot}"
set_file_param "${model_config_fp}" "atmos_nthreads" "${nthreads:-1}"
#
#-----------------------------------------------------------------------
#
# If the write component is to be used, then a set of parameters, including
# those that define the write component's output grid, need to be specified
# in the model configuration file (model_config_fp). This is done by
# appending a template file (in which some write-component parameters are
# set to actual values while others are set to placeholders) to model_config_fp
# and then replacing the placeholder values in the (new) model_config_fp
# file with actual values. The full path of this template file is specified
# in the workflow variable WRTCMP_PARAMS_TMPL_FP.
# Create a multiline variable that consists of a yaml-compliant string
# specifying the values that the jinja variables in the template
# model_configure file should be set to.
#
#-----------------------------------------------------------------------
#
settings="\
'PE_MEMBER01': ${PE_MEMBER01}
'start_year': $yyyy
'start_month': $mm
'start_day': $dd
'start_hour': $hh
'nhours_fcst': ${FCST_LEN_HRS}
'dt_atmos': ${DT_ATMOS}
'atmos_nthreads': ${nthreads:-1}
'ncores_per_node': ${NCORES_PER_NODE}
'quilting': ${dot_quilting_dot}
'print_esmf': ${dot_print_esmf_dot}
'output_grid': ${WRTCMP_output_grid}"
# 'output_grid': \'${WRTCMP_output_grid}\'"
#
# If the write-component is to be used, then specify a set of computational
# parameters and a set of grid parameters. The latter depends on the type
# (coordinate system) of the grid that the write-component will be using.
#
if [ "$QUILTING" = "TRUE" ]; then

cat ${WRTCMP_PARAMS_TMPL_FP} >> ${model_config_fp}
settings="${settings}
'write_groups': ${WRTCMP_write_groups}
'write_tasks_per_group': ${WRTCMP_write_tasks_per_group}
'cen_lon': ${WRTCMP_cen_lon}
'cen_lat': ${WRTCMP_cen_lat}
'lon1': ${WRTCMP_lon_lwr_left}
'lat1': ${WRTCMP_lat_lwr_left}"

if [ "${WRTCMP_output_grid}" = "lambert_conformal" ]; then

settings="${settings}
'stdlat1': ${WRTCMP_stdlat1}
'stdlat2': ${WRTCMP_stdlat2}
'nx': ${WRTCMP_nx}
'ny': ${WRTCMP_ny}
'dx': ${WRTCMP_dx}
'dy': ${WRTCMP_dy}
'lon2': \"\"
'lat2': \"\"
'dlon': \"\"
'dlat': \"\""

set_file_param "${model_config_fp}" "write_groups" "${WRTCMP_write_groups}"
set_file_param "${model_config_fp}" "write_tasks_per_group" "${WRTCMP_write_tasks_per_group}"
elif [ "${WRTCMP_output_grid}" = "regional_latlon" ] || \
[ "${WRTCMP_output_grid}" = "rotated_latlon" ]; then

set_file_param "${model_config_fp}" "output_grid" "\'${WRTCMP_output_grid}\'"
set_file_param "${model_config_fp}" "cen_lon" "${WRTCMP_cen_lon}"
set_file_param "${model_config_fp}" "cen_lat" "${WRTCMP_cen_lat}"
set_file_param "${model_config_fp}" "lon1" "${WRTCMP_lon_lwr_left}"
set_file_param "${model_config_fp}" "lat1" "${WRTCMP_lat_lwr_left}"
settings="${settings}
'lon2': ${WRTCMP_lon_upr_rght}
'lat2': ${WRTCMP_lat_upr_rght}
'dlon': ${WRTCMP_dlon}
'dlat': ${WRTCMP_dlat}
'stdlat1': \"\"
'stdlat2': \"\"
'nx': \"\"
'ny': \"\"
'dx': \"\"
'dy': \"\""

if [ "${WRTCMP_output_grid}" = "rotated_latlon" ]; then
set_file_param "${model_config_fp}" "lon2" "${WRTCMP_lon_upr_rght}"
set_file_param "${model_config_fp}" "lat2" "${WRTCMP_lat_upr_rght}"
set_file_param "${model_config_fp}" "dlon" "${WRTCMP_dlon}"
set_file_param "${model_config_fp}" "dlat" "${WRTCMP_dlat}"
elif [ "${WRTCMP_output_grid}" = "lambert_conformal" ]; then
set_file_param "${model_config_fp}" "stdlat1" "${WRTCMP_stdlat1}"
set_file_param "${model_config_fp}" "stdlat2" "${WRTCMP_stdlat2}"
set_file_param "${model_config_fp}" "nx" "${WRTCMP_nx}"
set_file_param "${model_config_fp}" "ny" "${WRTCMP_ny}"
set_file_param "${model_config_fp}" "dx" "${WRTCMP_dx}"
set_file_param "${model_config_fp}" "dy" "${WRTCMP_dy}"
elif [ "${WRTCMP_output_grid}" = "regional_latlon" ]; then
set_file_param "${model_config_fp}" "lon2" "${WRTCMP_lon_upr_rght}"
set_file_param "${model_config_fp}" "lat2" "${WRTCMP_lat_upr_rght}"
set_file_param "${model_config_fp}" "dlon" "${WRTCMP_dlon}"
set_file_param "${model_config_fp}" "dlat" "${WRTCMP_dlat}"
fi

fi

print_info_msg $VERBOSE "
The variable \"settings\" specifying values to be used in the \"${MODEL_CONFIG_FN}\"
file has been set as follows:
#-----------------------------------------------------------------------
settings =
$settings"
#
#-----------------------------------------------------------------------
#
# Call a python script to generate the experiment's actual MODEL_CONFIG_FN
# file from the template file.
#
#-----------------------------------------------------------------------
#
model_config_fp="${run_dir}/${MODEL_CONFIG_FN}"
$USHDIR/fill_jinja_template.py -q \
-u "${settings}" \
-t ${MODEL_CONFIG_TMPL_FP} \
-o ${model_config_fp} || \
print_err_msg_exit "\
Call to python script fill_jinja_template.py to create a \"${MODEL_CONFIG_FN}\"
file from a jinja2 template failed. Parameters passed to this script are:
Full path to template rocoto XML file:
MODEL_CONFIG_TMPL_FP = \"${MODEL_CONFIG_TMPL_FP}\"
Full path to output rocoto XML file:
model_config_fp = \"${model_config_fp}\"
Namelist settings specified on command line:
settings =
$settings"
#
#-----------------------------------------------------------------------
#
Expand Down
4 changes: 3 additions & 1 deletion ush/set_predef_grid_params.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ local func_name="${FUNCNAME[0]}"
# domain (PREDEF_GRID_NAME). Note that the code will enter this script
# only if PREDEF_GRID_NAME has a valid (and non-empty) value.
#
# The following needs to be updated:
####################
# The following comments need to be updated:
####################
#
# 1) Reset the experiment title (expt_title).
# 2) Reset the grid parameters.
Expand Down
33 changes: 4 additions & 29 deletions ush/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ dot_ccpp_phys_suite_or_null=".${CCPP_PHYS_SUITE}"
DATA_TABLE_TMPL_FN="${DATA_TABLE_FN}"
DIAG_TABLE_TMPL_FN="${DIAG_TABLE_FN}${dot_ccpp_phys_suite_or_null}"
FIELD_TABLE_TMPL_FN="${FIELD_TABLE_FN}${dot_ccpp_phys_suite_or_null}"
MODEL_CONFIG_TMPL_FN="${MODEL_CONFIG_FN}${dot_ccpp_phys_suite_or_null}"
MODEL_CONFIG_TMPL_FN="${MODEL_CONFIG_FN}"
NEMS_CONFIG_TMPL_FN="${NEMS_CONFIG_FN}"

DATA_TABLE_TMPL_FP="${TEMPLATE_DIR}/${DATA_TABLE_TMPL_FN}"
Expand Down Expand Up @@ -2013,42 +2013,19 @@ fi
#
#-----------------------------------------------------------------------
#
# Initialize the full path to the template file containing placeholder
# values for the write component parameters. Then, if the write component
# is going to be used to write output files to disk (i.e. if QUILTING is
# set to "TRUE"), set the full path to this file. This file will be
# appended to the NEMS configuration file (MODEL_CONFIG_FN), and placeholder
# values will be replaced with actual ones.
# If the write-component is going to be used to write output files to
# disk (i.e. if QUILTING is set to "TRUE"), make sure that the grid type
# used by the write-component (WRTCMP_output_grid) is set to a valid value.
#
#-----------------------------------------------------------------------
#
WRTCMP_PARAMS_TMPL_FP=""

if [ "$QUILTING" = "TRUE" ]; then
#
# First, make sure that WRTCMP_output_grid is set to a valid value.
#
err_msg="\
The coordinate system used by the write-component output grid specified
in WRTCMP_output_grid is not supported:
WRTCMP_output_grid = \"${WRTCMP_output_grid}\""
check_var_valid_value \
"WRTCMP_output_grid" "valid_vals_WRTCMP_output_grid" "${err_msg}"
#
# Now set the name of the write-component template file.
#
wrtcmp_params_tmpl_fn=${wrtcmp_params_tmpl_fn:-"wrtcmp_${WRTCMP_output_grid}"}
#
# Finally, set the full path to the write component template file and
# make sure that the file exists.
#
WRTCMP_PARAMS_TMPL_FP="${TEMPLATE_DIR}/${wrtcmp_params_tmpl_fn}"
if [ ! -f "${WRTCMP_PARAMS_TMPL_FP}" ]; then
print_err_msg_exit "\
The write-component template file does not exist or is not a file:
WRTCMP_PARAMS_TMPL_FP = \"${WRTCMP_PARAMS_TMPL_FP}\""
fi

fi
#
#-----------------------------------------------------------------------
Expand Down Expand Up @@ -2518,8 +2495,6 @@ NEMS_CONFIG_FP="${NEMS_CONFIG_FP}"
FV3_EXEC_FP="${FV3_EXEC_FP}"

LOAD_MODULES_RUN_TASK_FP="${LOAD_MODULES_RUN_TASK_FP}"

WRTCMP_PARAMS_TMPL_FP="${WRTCMP_PARAMS_TMPL_FP}"
#
#-----------------------------------------------------------------------
#
Expand Down
Loading