Skip to content

Commit

Permalink
Update gdas forecast jobs for COM refactor
Browse files Browse the repository at this point in the history
Updates the forecast and enkf jobs to use the new COM templates.

Refs: NOAA-EMC#761
  • Loading branch information
WalterKolczynski-NOAA committed Jan 31, 2023
1 parent a6f4633 commit 0c3ee56
Show file tree
Hide file tree
Showing 7 changed files with 161 additions and 127 deletions.
1 change: 0 additions & 1 deletion jobs/JGDAS_ENKF_FCST
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,4 @@ fi
cd ${DATAROOT}
[[ ${KEEPDATA} = "NO" ]] && rm -rf ${DATA}


exit 0
45 changes: 38 additions & 7 deletions jobs/JGLOBAL_FORECAST
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ source "${HOMEgfs}/ush/jjob_header.sh" -e "fcst" -c "base fcst"
##############################################
# Set variables used in the script
##############################################
# Set wave variables
if [ ${DO_WAVE:-"NO"} = "YES" ]; then
# WAVE component directory
export CDUMPwave=${CDUMPwave:-${CDUMP}wave}
export COMINwave=${COMINwave:-$(compath.py ${envir}/${NET}/${gfs_ver})/${CDUMP}.${PDY}/${cyc}/wave}
export COMOUTwave=${COMOUTwave:-$(compath.py -o ${NET}/${gfs_ver})/${CDUMP}.${PDY}/${cyc}/wave}
fi

##############################################
# Begin JOB SPECIFIC work
Expand All @@ -33,6 +26,44 @@ else
export FHOUT_HF=0
fi

export MEMDIR=${MEMDIR:-''}

# Construct COM variables from templates (see config.com)
generate_com -rx COM_ATMOS_RESTART COM_ATMOS_INPUT COM_ATMOS_ANALYSIS COM_ATMOS_HISTORY COM_ATMOS_MASTER
generate_com -rx COM_WAVE_RESTART COM_WAVE_PREP COM_WAVE_HISTORY
generate_com -rx COM_MED_RESTART COM_OCEAN_INPUT COM_OCEAN_HISTORY
generate_com -rx COM_ICE_HISTORY
generate_com -rx COM_CHEM_HISTORY

# Construct COM variables for previous cycle restarts
DATE_PREV=$(${NDATE} -"${assim_freq}" "${PDY}${cyc}")
PDY_PREV=$(echo "${DATE_PREV}" | cut -c1-8)
declare -x PDY_PREV
cyc_PREV=$(echo "${DATE_PREV}" | cut -c9-10)
declare -x cyc_PREV

# shellcheck disable=SC2030,SC2031
COM_ATMOS_RESTART_PREV=$({
# Override env variables for this subshell to get correct template substitution
RUN=${rCDUMP}
PDY="${PDY_PREV}"
cyc="${cyc_PREV}"
echo "${COM_ATMOS_RESTART_TMPL}" | envsubst
})
declare -rx COM_ATMOS_RESTART_PREV

COM_WAVE_RESTART_PREV=$( {
# Override env variables for this subshell to get correct template substitution
# If we drop a separate cycle frequency, this can be merged with above
DATE_PREV=$(${NDATE} -"${WAVHCYC:-${assim_freq}}" "${PDY}${cyc}")
PDY_PREV=$(echo "${DATE_PREV}" | cut -c1-8)
cyc_PREV=$(echo "${DATE_PREV}" | cut -c9-10)
PDY="${PDY_PREV}"
cyc="${cyc_PREV}"
echo "${COM_WAVE_RESTART_TMPL}" | envsubst
})
declare -rx COM_WAVE_RESTART_PREV
# shellcheck disable=

###############################################################
# Run relevant exglobal script
Expand Down
54 changes: 42 additions & 12 deletions scripts/exgdas_enkf_fcst.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,14 @@ SENDDBN=${SENDDBN:-"NO"}

################################################################################
# Preprocessing
mkdata=NO
if [ ! -d $DATA ]; then
mkdata=YES
mkdir -p $DATA
fi
cd $DATA || exit 99
DATATOP=$DATA

################################################################################
# Set output data
cymd=$(echo $CDATE | cut -c1-8)
chh=$(echo $CDATE | cut -c9-10)
EFCSGRP=$COMOUT/efcs.grp${ENSGRP}
EFCSGRP="${ROTDIR}/enkf${CDUMP}.${PDY}/${cyc}/efcs.grp${ENSGRP}"
if [ -f $EFCSGRP ]; then
if [ $RERUN_EFCSGRP = "YES" ]; then
rm -f $EFCSGRP
Expand Down Expand Up @@ -149,7 +144,7 @@ for imem in $(seq $ENSBEG $ENSEND); do
cd $DATATOP

cmem=$(printf %03i $imem)
memchar="mem$cmem"
MEMDIR="mem${cmem}"

echo "Processing MEMBER: $cmem"

Expand All @@ -161,12 +156,50 @@ for imem in $(seq $ENSBEG $ENSEND); do
[[ $memstat -eq 1 ]] && skip_mem="YES"
fi

# Construct COM variables from templates (see config.com)
# Can't make these read-only because we are looping over members
generate_com -x COM_ATMOS_RESTART COM_ATMOS_INPUT COM_ATMOS_ANALYSIS COM_ATMOS_HISTORY COM_ATMOS_MASTER
generate_com -x COM_WAVE_RESTART COM_WAVE_PREP COM_WAVE_HISTORY
generate_com -x COM_MED_RESTART COM_OCEAN_INPUT COM_OCEAN_HISTORY
generate_com -x COM_ICE_HISTORY
generate_com -x COM_CHEM_HISTORY

# Construct COM variables for previous cycle restarts
DATE_PREV=$(${NDATE} -"${assim_freq}" "${PDY}${cyc}")
PDY_PREV=$(echo "${DATE_PREV}" | cut -c1-8)
declare -x PDY_PREV
cyc_PREV=$(echo "${DATE_PREV}" | cut -c9-10)
declare -x cyc_PREV

# shellcheck disable=SC2030,SC2031
COM_ATMOS_RESTART_PREV=$({
# Override env variables for this subshell to get correct template substitution
RUN=${rCDUMP}
PDY="${PDY_PREV}"
cyc="${cyc_PREV}"
echo "${COM_ATMOS_RESTART_TMPL}" | envsubst
})
declare -x COM_ATMOS_RESTART_PREV

COM_WAVE_RESTART_PREV=$( {
# Override env variables for this subshell to get correct template substitution
# If we drop a separate cycle frequency, this can be merged with above
DATE_PREV=$(${NDATE} -"${WAVHCYC:-${assim_freq}}" "${PDY}${cyc}")
PDY_PREV=$(echo "${DATE_PREV}" | cut -c1-8)
cyc_PREV=$(echo "${DATE_PREV}" | cut -c9-10)
PDY="${PDY_PREV}"
cyc="${cyc_PREV}"
echo "${COM_WAVE_RESTART_TMPL}" | envsubst
})
declare -x COM_WAVE_RESTART_PREV
# shellcheck disable=

if [ $skip_mem = "NO" ]; then

ra=0

export MEMBER=$imem
export DATA=$DATATOP/$memchar
export DATA="${DATATOP}/${MEMDIR}"
if [ -d $DATA ]; then rm -rf $DATA; fi
mkdir -p $DATA
$FORECASTSH
Expand All @@ -186,7 +219,7 @@ for imem in $(seq $ENSBEG $ENSEND); do
while [ $fhr -le $FHMAX ]; do
FH3=$(printf %03i $fhr)
if [ $(expr $fhr % 3) -eq 0 ]; then
$DBNROOT/bin/dbn_alert MODEL GFS_ENKF $job $COMOUT/$memchar/atmos/${CDUMP}.t${cyc}z.sfcf${FH3}.nc
"${DBNROOT}/bin/dbn_alert" MODEL GFS_ENKF "${job}" "${COM_ATMOS_HISTORY}/${CDUMP}.t${cyc}z.sfcf${FH3}.nc"
fi
fhr=$((fhr+FHOUT))
done
Expand Down Expand Up @@ -226,8 +259,5 @@ export err=$rc; err_chk

################################################################################
# Postprocessing
cd $pwd
[[ $mkdata = "YES" ]] && rm -rf $DATATOP


exit $err
4 changes: 2 additions & 2 deletions scripts/exglobal_forecast.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@
# Main body starts here
#######################

source "$HOMEgfs/ush/preamble.sh"
source "${HOMEgfs}/ush/preamble.sh"

SCRIPTDIR=$(dirname $(readlink -f "$0") )/../ush
SCRIPTDIR="${HOMEgfs}/ush"
echo "MAIN: environment loaded for $machine platform,Current Script locates in $SCRIPTDIR."

# include all subroutines. Executions later.
Expand Down
10 changes: 5 additions & 5 deletions ush/forecast_det.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ FV3_GFS_det(){
res_latlon_dynamics="''"

# Determine if this is a warm start or cold start
if [[ -f "${gmemdir}/RESTART/${sPDY}.${scyc}0000.coupler.res" ]]; then
if [[ -f "${COM_ATMOS_RESTART_PREV}/${sPDY}.${scyc}0000.coupler.res" ]]; then
export warm_start=".true."
fi

Expand All @@ -40,22 +40,22 @@ FV3_GFS_det(){
#-------------------------------------------------------
# determine if restart IC exists to continue from a previous forecast
RERUN=${RERUN:-"NO"}
filecount=$(find "${RSTDIR_ATM:-/dev/null}" -type f | wc -l)
filecount=$(find "${COM_ATMOS_RESTART:-/dev/null}" -type f | wc -l)
if [[ ( ${CDUMP} = "gfs" || ( ${RUN} = "gefs" && ${CDATE_RST} = "" )) && ${rst_invt1} -gt 0 && ${FHMAX} -gt ${rst_invt1} && ${filecount} -gt 10 ]]; then
reverse=$(echo "${restart_interval[@]} " | tac -s ' ')
for xfh in ${reverse} ; do
yfh=$((xfh-(IAU_OFFSET/2)))
SDATE=$(${NDATE} +${yfh} "${CDATE}")
PDYS=$(echo "${SDATE}" | cut -c1-8)
cycs=$(echo "${SDATE}" | cut -c9-10)
flag1=${RSTDIR_ATM}/${PDYS}.${cycs}0000.coupler.res
flag2=${RSTDIR_ATM}/coupler.res
flag1=${COM_ATMOS_RESTART}/${PDYS}.${cycs}0000.coupler.res
flag2=${COM_ATMOS_RESTART}/coupler.res

#make sure that the wave restart files also exist if cplwav=true
waverstok=".true."
if [[ "${cplwav}" = ".true." ]]; then
for wavGRD in ${waveGRD} ; do
if [[ ! -f "${RSTDIR_WAVE}/${PDYS}.${cycs}0000.restart.${wavGRD}" ]]; then
if [[ ! -f "${COM_WAVE_RESTART}/${PDYS}.${cycs}0000.restart.${wavGRD}" ]]; then
waverstok=".false."
fi
done
Expand Down
Loading

0 comments on commit 0c3ee56

Please sign in to comment.