Skip to content

Commit

Permalink
Changes for initializing the ensemble with GEFS perturbations + deter…
Browse files Browse the repository at this point in the history
…ministic analysis and adding tasks for additional ensemble free forecast (NOAA-EMC#429)
  • Loading branch information
chunhuazhou authored Oct 5, 2022
1 parent e9db125 commit 9c04aca
Show file tree
Hide file tree
Showing 18 changed files with 950 additions and 525 deletions.
4 changes: 4 additions & 0 deletions jobs/JREGIONAL_RUN_FCST
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ the specified cycle.
CYCLE_TYPE=${CYCLE_TYPE:-prod}
if [ ${CYCLE_TYPE} == "spinup" ]; then
run_dir="${CYCLE_DIR}${SLASH_ENSMEM_SUBDIR}/fcst_fv3lam_spinup"
elif [ ${CYCLE_TYPE} == "ensinit" ]; then
run_dir="${CYCLE_DIR}${SLASH_ENSMEM_SUBDIR}/fcst_fv3lam_ensinit"
elif [ ${CYCLE_TYPE} == "ensfcst" ]; then
run_dir="${CYCLE_DIR}${SLASH_ENSMEM_SUBDIR}/fcst_fv3lam_long"
else
run_dir="${CYCLE_DIR}${SLASH_ENSMEM_SUBDIR}/fcst_fv3lam"
fi
Expand Down
7 changes: 7 additions & 0 deletions jobs/JREGIONAL_RUN_POST
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ on the output files corresponding to a specified forecast hour.
CYCLE_TYPE=${CYCLE_TYPE:-prod}
if [ ${CYCLE_TYPE} == "spinup" ]; then
run_dir="${CYCLE_DIR}${SLASH_ENSMEM_SUBDIR}/fcst_fv3lam_spinup"
elif [ ${DO_ENSFCST} = "TRUE" ]; then
run_dir="${CYCLE_DIR}${SLASH_ENSMEM_SUBDIR}/fcst_fv3lam"
for cyc_start in "${CYCL_HRS_ENSFCST[@]}"; do
if [ ${cyc} -eq ${cyc_start} ]; then
run_dir="${CYCLE_DIR}${SLASH_ENSMEM_SUBDIR}/fcst_fv3lam_long"
fi
done
else
run_dir="${CYCLE_DIR}${SLASH_ENSMEM_SUBDIR}/fcst_fv3lam"
fi
Expand Down
10 changes: 10 additions & 0 deletions jobs/JREGIONAL_RUN_PREPSTART
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,19 @@ the specified cycle.
CYCLE_TYPE=${CYCLE_TYPE:-prod}
if [ ${CYCLE_TYPE} == "spinup" ]; then
modelinputdir=${CYCLE_DIR}${SLASH_ENSMEM_SUBDIR}/fcst_fv3lam_spinup/INPUT
elif [ ${CYCLE_TYPE} == "ensinit" ]; then
modelinputdir=${CYCLE_DIR}${SLASH_ENSMEM_SUBDIR}/fcst_fv3lam/INPUT
else
modelinputdir=${CYCLE_DIR}${SLASH_ENSMEM_SUBDIR}/fcst_fv3lam/INPUT
if [ ${DO_ENSINIT} == "TRUE" ]; then
for cyc_start in "${CYCL_HRS_ENSINIT[@]}"; do
if [ ${HH} -eq ${cyc_start} ]; then
modelinputdir=${CYCLE_DIR}${SLASH_ENSMEM_SUBDIR}/fcst_fv3lam_ensinit/INPUT
fi
done
fi
fi

rm -fr ${modelinputdir}
mkdir_vrfy -p ${modelinputdir}
#
Expand Down
111 changes: 111 additions & 0 deletions jobs/JREGIONAL_RUN_PREPSTART_ENSFCST
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/bin/bash

#
#-----------------------------------------------------------------------
#
# This J-JOB script stages initial and boundary conditions for
# the analysis and model of the cycle it is running. The initial
# could come from external model or previous cycles forecast.
# The boundary could come from previous many cycles.
#
#-----------------------------------------------------------------------

#
#-----------------------------------------------------------------------
#
# Source the variable definitions file and the bash utility functions.
#
#-----------------------------------------------------------------------
#
. ${GLOBAL_VAR_DEFNS_FP}
. $USHDIR/source_util_funcs.sh
#
#-----------------------------------------------------------------------
#
# Save current shell options (in a global array). Then set new options
# for this script/function.
#
#-----------------------------------------------------------------------
#
{ save_shell_opts; set -u +x; } > /dev/null 2>&1
#
#-----------------------------------------------------------------------
#
# Get the full path to the file in which this script/function is located
# (scrfunc_fp), the name of that file (scrfunc_fn), and the directory in
# which the file is located (scrfunc_dir).
#
#-----------------------------------------------------------------------
#
scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" )
scrfunc_fn=$( basename "${scrfunc_fp}" )
scrfunc_dir=$( dirname "${scrfunc_fp}" )
#
#-----------------------------------------------------------------------
#
# Print message indicating entry into script.
#
#-----------------------------------------------------------------------
#
print_info_msg "
========================================================================
Entering script: \"${scrfunc_fn}\"
In directory: \"${scrfunc_dir}\"
This is the J-job script for the task that runs a analysis with FV3 for
the specified cycle.
========================================================================"
#
#-----------------------------------------------------------------------
#
# Create the working directory under the cycle directory.
#
#-----------------------------------------------------------------------
#
# CYCLE_TYPE is to indicate which type of cycle this job for:
# ensfcst: this job is for ensemble free forecast cycles
#
CYCLE_TYPE=${CYCLE_TYPE:-ensfcst}
if [ ${CYCLE_TYPE} == "ensfcst" ]; then
modelinputdir=${CYCLE_DIR}${SLASH_ENSMEM_SUBDIR}/fcst_fv3lam_long/INPUT
fi

rm -fr ${modelinputdir}
mkdir_vrfy -p ${modelinputdir}
#
#-----------------------------------------------------------------------
#
# Call the ex-script for this J-job and pass to it the necessary varia-
# bles.
#
#-----------------------------------------------------------------------
#
$SCRIPTSDIR/exregional_run_prepstart_ensfcst.sh \
cycle_dir="${CYCLE_DIR}" \
cycle_type="${CYCLE_TYPE}" \
modelinputdir="${modelinputdir}" \
lbcs_root="${LBCS_ROOT}" || \
print_err_msg_exit "\
Call to ex-script corresponding to J-job \"${scrfunc_fn}\" failed."
#
#-----------------------------------------------------------------------
#
# Print exit message.
#
#-----------------------------------------------------------------------
#
print_info_msg "
========================================================================
Exiting script: \"${scrfunc_fn}\"
In directory: \"${scrfunc_dir}\"
========================================================================"
#
#-----------------------------------------------------------------------
#
# Restore the shell options saved at the beginning of this script/func-
# tion.
#
#-----------------------------------------------------------------------
#
{ restore_shell_opts; } > /dev/null 2>&1

3 changes: 3 additions & 0 deletions jobs/JREGIONAL_SAVE_RESTART
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ CYCLE_TYPE=${CYCLE_TYPE:-prod}
if [ ${CYCLE_TYPE} == "spinup" ]; then
run_dir="${CYCLE_DIR}${SLASH_ENSMEM_SUBDIR}/fcst_fv3lam_spinup"
nwges_dir="${NWGES_DIR}${SLASH_ENSMEM_SUBDIR}/fcst_fv3lam_spinup"
elif [ ${CYCLE_TYPE} == "ensinit" ]; then
run_dir="${CYCLE_DIR}${SLASH_ENSMEM_SUBDIR}/fcst_fv3lam_ensinit"
nwges_dir="${NWGES_DIR}${SLASH_ENSMEM_SUBDIR}/fcst_fv3lam_ensinit"
else
run_dir="${CYCLE_DIR}${SLASH_ENSMEM_SUBDIR}/fcst_fv3lam"
nwges_dir="${NWGES_DIR}${SLASH_ENSMEM_SUBDIR}/fcst_fv3lam"
Expand Down
Empty file modified scripts/exregional_nonvarcldanl.sh
100644 → 100755
Empty file.
41 changes: 33 additions & 8 deletions scripts/exregional_run_prepstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ if [ ${cycle_type} == "spinup" ]; then
BKTYPE=1
fi
done
elif [ ${cycle_type} == "ensinit" ]; then
echo "ensinit cycle - warm start from 1 timestep restart files"
for cyc_start in "${CYCL_HRS_ENSINIT[@]}"; do
if [ ${HH} -eq ${cyc_start} ]; then
BKTYPE=0
fi
done
else
echo " product cycle"
for cyc_start in "${CYCL_HRS_PRODSTART[@]}"; do
Expand Down Expand Up @@ -244,17 +251,23 @@ else
else
fg_restart_dirname=fcst_fv3lam
fi

YYYYMMDDHHmInterv=$( date +%Y%m%d%H -d "${START_DATE} ${DA_CYCLE_INTERV} hours ago" )
bkpath=${fg_root}/${YYYYMMDDHHmInterv}${SLASH_ENSMEM_SUBDIR}/${fg_restart_dirname}/RESTART # cycling, use background from RESTART

#
# let us figure out which backgound is available
#
# the restart file from FV3 has a name like: ${YYYYMMDD}.${HH}0000.fv_core.res.tile1.nc
# But the restart files for the forecast length has a name like: fv_core.res.tile1.nc
# So the defination of restart_prefix needs a "." at the end.
#
restart_prefix="${YYYYMMDD}.${HH}0000."

if [ ${cycle_type} == "ensinit" ] ; then
# point to the 0-h cycle for the warm start from the 1 timestep restart files
fg_restart_dirname=fcst_fv3lam_ensinit
bkpath=${fg_root}/${YYYYMMDDHH}${SLASH_ENSMEM_SUBDIR}/${fg_restart_dirname}/RESTART # cycling, use background from RESTART
else
YYYYMMDDHHmInterv=$( date +%Y%m%d%H -d "${START_DATE} ${DA_CYCLE_INTERV} hours ago" )
bkpath=${fg_root}/${YYYYMMDDHHmInterv}${SLASH_ENSMEM_SUBDIR}/${fg_restart_dirname}/RESTART # cycling, use background from RESTART

n=${DA_CYCLE_INTERV}
while [[ $n -le 6 ]] ; do
checkfile=${bkpath}/${restart_prefix}coupler.res
Expand Down Expand Up @@ -293,6 +306,8 @@ else
done
fi
#
fi

filelistn="fv_core.res.tile1.nc fv_srf_wnd.res.tile1.nc fv_tracer.res.tile1.nc phy_data.nc sfc_data.nc"
checkfile=${bkpath}/${restart_prefix}coupler.res
n_iolayouty=$(($IO_LAYOUT_Y-1))
Expand All @@ -315,7 +330,11 @@ else
done
done
fi
cp_vrfy ${fg_root}/${YYYYMMDDHHmInterv}${SLASH_ENSMEM_SUBDIR}/${fg_restart_dirname}/INPUT/gfs_ctrl.nc gfs_ctrl.nc
if [ ${cycle_type} == "ensinit" ] ; then
cp_vrfy ${fg_root}/${YYYYMMDDHH}${SLASH_ENSMEM_SUBDIR}/${fg_restart_dirname}/INPUT/gfs_ctrl.nc gfs_ctrl.nc
else
cp_vrfy ${fg_root}/${YYYYMMDDHHmInterv}${SLASH_ENSMEM_SUBDIR}/${fg_restart_dirname}/INPUT/gfs_ctrl.nc gfs_ctrl.nc
fi
if [ ${SAVE_CYCLE_LOG} == "TRUE" ] ; then
echo "${YYYYMMDDHH}(${cycle_type}): warm start at ${current_time} from ${checkfile} " >> ${EXPTDIR}/log.cycles
fi
Expand All @@ -338,9 +357,15 @@ else
ncatted -a checksum,,d,, fv_core.res.nc

# generate coupler.res with right date
head -1 bk_coupler.res > coupler.res
tail -1 bk_coupler.res >> coupler.res
tail -1 bk_coupler.res >> coupler.res
if [ ${cycle_type} == "ensinit" ]; then
# from the 1 timestep restart files
head -2 bk_coupler.res > coupler.res
head -2 bk_coupler.res | tail -1 >> coupler.res
else
head -1 bk_coupler.res > coupler.res
tail -1 bk_coupler.res >> coupler.res
tail -1 bk_coupler.res >> coupler.res
fi
else
print_err_msg_exit "Error: cannot find background: ${checkfile}"
fi
Expand Down
Loading

0 comments on commit 9c04aca

Please sign in to comment.