Skip to content

Commit

Permalink
Add inline post option to the SRW App (#538)
Browse files Browse the repository at this point in the history
* Add write_dopost for inline post

* Add inline_post to run_fcst script

* Turn off run_post when true

* Add postprod to run_fcst script

* Update workflow template for inline post

* Add a WE2E test for inline post
  • Loading branch information
chan-hoo authored Jul 7, 2021
1 parent c0b2a22 commit 47d5b4f
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 4 deletions.
65 changes: 61 additions & 4 deletions scripts/exregional_run_fcst.sh
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,6 @@ Cannot create symlink because target does not exist:
target = \"$target\""
fi



relative_or_null=""
if [ "${RUN_TASK_MAKE_OROG}" = "TRUE" ] && [ "${MACHINE}" != "WCOSS_CRAY" ] ; then
relative_or_null="--relative"
Expand Down Expand Up @@ -290,7 +288,6 @@ Cannot create symlink because target does not exist:
target = \"$target\""
fi


#
# If using the FV3_HRRR physics suite, there are two files (that contain
# statistics of the orography) that are needed by the gravity wave drag
Expand All @@ -317,7 +314,6 @@ Cannot create symlink because target does not exist:

fi


#
#-----------------------------------------------------------------------
#
Expand Down Expand Up @@ -444,6 +440,27 @@ ln_vrfy -sf ${relative_or_null} ${DATA_TABLE_FP} ${run_dir}
ln_vrfy -sf ${relative_or_null} ${FIELD_TABLE_FP} ${run_dir}
ln_vrfy -sf ${relative_or_null} ${NEMS_CONFIG_FP} ${run_dir}


if [ ${WRITE_DOPOST} = "TRUE" ]; then
cp_vrfy ${EMC_POST_DIR}/parm/nam_micro_lookup.dat ./eta_micro_lookup.dat
if [ ${USE_CUSTOM_POST_CONFIG_FILE} = "TRUE" ]; then
post_config_fp="${CUSTOM_POST_CONFIG_FP}"
print_info_msg "
====================================================================
CUSTOM_POST_CONFIG_FP = \"${CUSTOM_POST_CONFIG_FP}\"
===================================================================="
else
post_config_fp="${EMC_POST_DIR}/parm/postxconfig-NT-fv3lam.txt"
print_info_msg "
====================================================================
post_config_fp = \"${post_config_fp}\"
===================================================================="
fi
cp_vrfy ${post_config_fp} ./postxconfig-NT_FH00.txt
cp_vrfy ${post_config_fp} ./postxconfig-NT.txt
cp_vrfy ${EMC_POST_DIR}/parm/params_grib2_tbl_new .
fi

if [ "${DO_ENSEMBLE}" = TRUE ]; then
set_FV3nml_stoch_params cdate="$cdate" || print_err_msg_exit "\
Call to function to create the ensemble-based namelist for the current
Expand Down Expand Up @@ -507,6 +524,46 @@ $APRUN ${FV3_EXEC_FP} || print_err_msg_exit "\
Call to executable to run FV3-LAM forecast returned with nonzero exit
code."
#
# Only for inline post, create the directory where post-processing output
# are stored (postprd_dir)
if [ ${WRITE_DOPOST} = "TRUE" ]; then
if [ "${RUN_ENVIR}" = "nco" ]; then
COMOUT="${COMOUT_BASEDIR}/$RUN.$PDY/$cyc${SLASH_ENSMEM_SUBDIR}"
postprd_dir="$COMOUT"
else
postprd_dir="${run_dir}/postprd"
fi
mkdir_vrfy -p "${postprd_dir}"

cd_vrfy ${postprd_dir}

yyyymmdd=${cdate:0:8}
hh=${cdate:8:2}
cyc=$hh
tmmark="tm00"
fmn="00"

for fhr in $(seq -f "%02g" 0 ${FCST_LEN_HRS}); do
echo $fhr
post_time=$( date --utc --date "${yyyymmdd} ${hh} UTC + ${fhr} hours + ${fmn} minutes" "+%Y%m%d%H%M" )
post_mn=${post_time:10:2}
post_mn_or_null=""
post_fn_suffix="GrbF${fhr}"
post_renamed_fn_suffix="f0${fhr}${post_mn_or_null}.${tmmark}.grib2"

basetime=$( date --date "$yyyymmdd $hh" +%y%j%H%M )
symlink_suffix="_${basetime}f0${fhr}${post_mn}"
fids=( "bgdawp" "bgrd3d" )
for fid in "${fids[@]}"; do
FID="${fid^^}"
post_orig_fn="${FID}.${post_fn_suffix}"
post_renamed_fn="${NET}.t${cyc}z.${fid}${post_renamed_fn_suffix}"
mv_vrfy ../${post_orig_fn} ${post_renamed_fn}
ln_vrfy -fs ${post_renamed_fn} ${FID}${symlink_suffix}
done
done
fi
#
#-----------------------------------------------------------------------
#
# Print message indicating successful completion of script.
Expand Down
28 changes: 28 additions & 0 deletions tests/baseline_configs/config.inline_post.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# TEST PURPOSE/DESCRIPTION:
# ------------------------
#
# This test checks the capability of the workflow to use the inline
# post option (WRITE_DOPOST) in model_configure.
#

RUN_ENVIR="community"
PREEXISTING_DIR_METHOD="rename"

PREDEF_GRID_NAME="RRFS_CONUS_25km"
WRITE_DOPOST="TRUE"

CCPP_PHYS_SUITE="FV3_GFS_v15p2"

EXTRN_MDL_NAME_ICS="FV3GFS"
EXTRN_MDL_NAME_LBCS="FV3GFS"
USE_USER_STAGED_EXTRN_FILES="TRUE"

DATE_FIRST_CYCL="20190701"
DATE_LAST_CYCL="20190701"
CYCL_HRS=( "00" )

FCST_LEN_HRS="6"
LBC_SPEC_INTVL_HRS="3"


1 change: 1 addition & 0 deletions tests/baselines_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ grid_RRFS_NA_3km
grid_RRFS_SUBCONUS_3km_ics_FV3GFS_lbcs_FV3GFS_suite_GFS_v16
grid_RRFS_SUBCONUS_3km_ics_HRRR_lbcs_RAP_suite_GFS_v15p2
grid_RRFS_SUBCONUS_3km_ics_HRRR_lbcs_RAP_suite_GSD_SAR
inline_post
nco_ensemble
nco_grid_CONUS_25km_GFDLgrid_ics_FV3GFS_lbcs_FV3GFS_suite_GFS_v16
nco_grid_RRFS_CONUS_25km_ics_HRRR_lbcs_RAP_suite_GSD_SAR
Expand Down
5 changes: 5 additions & 0 deletions ush/config_defaults.sh
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,15 @@ FCST_LEN_HRS="24"
# For example, RESTART_INTERVAL="1": restart files are produced every hour
# with the prefix "YYYYMMDD.HHmmSS." in the RESTART directory
#
# WRITE_DOPOST:
# Flag that determines whether or not to use the INLINE POST option
# When TRUE, force to turn off run_post (RUN_TASK_RUN_POST=FALSE) in setup.sh
#
#-----------------------------------------------------------------------
#
DT_ATMOS=""
RESTART_INTERVAL="0"
WRITE_DOPOST="FALSE"
#
#-----------------------------------------------------------------------
#
Expand Down
2 changes: 2 additions & 0 deletions ush/create_model_configure_file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ run directory (run_dir):
dot_quilting_dot="."${QUILTING,,}"."
dot_print_esmf_dot="."${PRINT_ESMF,,}"."
dot_cpl_dot="."${CPL,,}"."
dot_write_dopost="."${WRITE_DOPOST,,}"."
#
#-----------------------------------------------------------------------
#
Expand All @@ -124,6 +125,7 @@ run directory (run_dir):
'atmos_nthreads': ${nthreads:-1}
'ncores_per_node': ${NCORES_PER_NODE}
'restart_interval': ${RESTART_INTERVAL}
'write_dopost': ${dot_write_dopost}
'quilting': ${dot_quilting_dot}
'print_esmf': ${dot_print_esmf_dot}
'output_grid': ${WRTCMP_output_grid}"
Expand Down
4 changes: 4 additions & 0 deletions ush/generate_FV3LAM_wflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,10 @@ settings="\
#
'fcst_len_hrs': ${FCST_LEN_HRS}
#
# Inline post
#
'write_dopost': ${WRITE_DOPOST}
#
# METPlus-specific information
#
'model': ${MODEL}
Expand Down
24 changes: 24 additions & 0 deletions ush/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2121,6 +2121,30 @@ fi
#
#-----------------------------------------------------------------------
#
# Make sure that WRITE_DOPOST is set to a valid value.
#
#-----------------------------------------------------------------------
#
check_var_valid_value "WRITE_DOPOST" "valid_vals_WRITE_DOPOST"
#
# Set WRITE_DOPOST to either "TRUE" or "FALSE" so we don't have to consider
# other valid values later on.
#
WRITE_DOPOST=${WRITE_DOPOST^^}
if [ "$WRITE_DOPOST" = "TRUE" ] || \
[ "$WRITE_DOPOST" = "YES" ]; then
WRITE_DOPOST="TRUE"

# Turn off run_post
RUN_TASK_RUN_POST="FALSE"

elif [ "$WRITE_DOPOST" = "FALSE" ] || \
[ "$WRITE_DOPOST" = "NO" ]; then
WRITE_DOPOST="FALSE"
fi
#
#-----------------------------------------------------------------------
#
# Make sure that QUILTING is set to a valid value.
#
#-----------------------------------------------------------------------
Expand Down
28 changes: 28 additions & 0 deletions ush/templates/FV3LAM_wflow.xml
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,11 @@ the <task> tag to be identical to the ones above for other output times.
<envar><name>ACCUM</name><value>01</value></envar>

<dependency>
{%- if write_dopost %}
<taskdep task="&RUN_FCST_TN;{{ uscore_ensmem_name }}"/>
{%- else %}
<metataskdep metatask="&RUN_POST_TN;{{ uscore_ensmem_name }}"/>
{%- endif %}
</dependency>

</task>
Expand Down Expand Up @@ -732,7 +736,11 @@ the <task> tag to be identical to the ones above for other output times.
<envar><name>VAR</name><value>REFC RETOP</value></envar>

<dependency>
{%- if write_dopost %}
<taskdep task="&RUN_FCST_TN;{{ uscore_ensmem_name }}"/>
{%- else %}
<metataskdep metatask="&RUN_POST_TN;{{ uscore_ensmem_name }}"/>
{%- endif %}
</dependency>

</task>
Expand Down Expand Up @@ -769,7 +777,11 @@ the <task> tag to be identical to the ones above for other output times.
<envar><name>FHR</name><value><cyclestr> {% for h in range(0, fcst_len_hrs+1) %}{{ " %02d" % h }}{% endfor %} </cyclestr></value></envar>

<dependency>
{%- if write_dopost %}
<taskdep task="&RUN_FCST_TN;{{ uscore_ensmem_name }}"/>
{%- else %}
<metataskdep metatask="&RUN_POST_TN;{{ uscore_ensmem_name }}"/>
{%- endif %}
</dependency>

</task>
Expand Down Expand Up @@ -805,7 +817,11 @@ the <task> tag to be identical to the ones above for other output times.
{%- if run_task_get_obs_ccpa %}
<taskdep task="&GET_OBS_CCPA_TN;"/>
{%- else %}
{%- if write_dopost %}
<taskdep task="&RUN_FCST_TN;{{ uscore_ensmem_name }}"/>
{%- else %}
<metataskdep metatask="&RUN_POST_TN;{{ uscore_ensmem_name }}"/>
{%- endif %}
{%- endif %}
</dependency>

Expand Down Expand Up @@ -840,7 +856,11 @@ the <task> tag to be identical to the ones above for other output times.
{%- if run_task_get_obs_mrms %}
<taskdep task="&GET_OBS_MRMS_TN;"/>
{%- else %}
{%- if write_dopost %}
<taskdep task="&RUN_FCST_TN;{{ uscore_ensmem_name }}"/>
{%- else %}
<metataskdep metatask="&RUN_POST_TN;{{ uscore_ensmem_name }}"/>
{%- endif %}
{%- endif %}
</dependency>

Expand Down Expand Up @@ -875,7 +895,11 @@ the <task> tag to be identical to the ones above for other output times.
{%- if run_task_get_obs_mrms %}
<taskdep task="&GET_OBS_MRMS_TN;"/>
{%- else %}
{%- if write_dopost %}
<taskdep task="&RUN_FCST_TN;{{ uscore_ensmem_name }}"/>
{%- else %}
<metataskdep metatask="&RUN_POST_TN;{{ uscore_ensmem_name }}"/>
{%- endif %}
{%- endif %}
</dependency>

Expand Down Expand Up @@ -1005,7 +1029,11 @@ the <task> tag to be identical to the ones above for other output times.
{%- if run_task_get_obs_ndas %}
<taskdep task="&GET_OBS_NDAS_TN;"/>
{%- else %}
{%- if write_dopost %}
<taskdep task="&RUN_FCST_TN;{{ uscore_ensmem_name }}"/>
{%- else %}
<metataskdep metatask="&RUN_POST_TN;{{ uscore_ensmem_name }}"/>
{%- endif %}
{%- endif %}
</dependency>

Expand Down
1 change: 1 addition & 0 deletions ush/templates/model_configure
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ debug_affinity: .true.
restart_interval: {{ restart_interval }}
output_1st_tstep_rst: .false.
print_esmf: {{ print_esmf }}
write_dopost: {{ write_dopost }}
quilting: {{ quilting }}

{% if quilting %}
Expand Down
1 change: 1 addition & 0 deletions ush/valid_param_vals.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ valid_vals_RUN_TASK_MAKE_SFC_CLIMO=("TRUE" "true" "YES" "yes" "FALSE" "false" "N
valid_vals_RUN_TASK_RUN_POST=("TRUE" "true" "YES" "yes" "FALSE" "false" "NO" "no")
valid_vals_RUN_TASK_VX_GRIDSTAT=("TRUE" "true" "YES" "yes" "FALSE" "false" "NO" "no")
valid_vals_RUN_TASK_VX_POINTSTAT=("TRUE" "true" "YES" "yes" "FALSE" "false" "NO" "no")
valid_vals_WRITE_DOPOST=("TRUE" "true" "YES" "yes" "FALSE" "false" "NO" "no")
valid_vals_QUILTING=("TRUE" "true" "YES" "yes" "FALSE" "false" "NO" "no")
valid_vals_PRINT_ESMF=("TRUE" "true" "YES" "yes" "FALSE" "false" "NO" "no")
valid_vals_USE_CRON_TO_RELAUNCH=("TRUE" "true" "YES" "yes" "FALSE" "false" "NO" "no")
Expand Down

0 comments on commit 47d5b4f

Please sign in to comment.