Skip to content

Commit

Permalink
Merge pull request #131 from DavidHuber-NOAA/fix/gfs_cyc
Browse files Browse the repository at this point in the history
Run metp jobs on the last cycle of CDATE
  • Loading branch information
malloryprow authored Jul 29, 2024
2 parents 0d9e0b6 + cf6feaa commit 92904d2
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 14 deletions.
49 changes: 38 additions & 11 deletions ush/run_verif_global_in_global_workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,53 @@
##---------------------------------------------------------------------------
##---------------------------------------------------------------------------

# Set information based on gfs_cyc
# Set default run cycle based on gfs_cyc
if [ $gfs_cyc = 1 ]; then
export fcyc_list="$cyc"
export vhr_list="$cyc"
export cyc2run="$cyc"
elif [ $gfs_cyc = 2 ]; then
export fcyc_list="00 12"
export vhr_list="00 12"
export cyc2run=00
export cyc2run=12
elif [ $gfs_cyc = 4 ]; then
export fcyc_list="00 06 12 18"
export vhr_list="00 06 12 18"
export cyc2run=00
export cyc2run=18
else
echo "EXIT ERROR: gfs_cyc must be 1, 2 or 4."
exit 1
fi

export SDATE_GFS=${SDATE_GFS:-$SDATE}
export EDATE_GFS=${EDATE_GFS:-$EDATE}
export VDATE="${VDATE:-$(echo $($NDATE -${VRFYBACK_HRS} $CDATE) | cut -c1-8)}"

start_ymd=${SDATE_GFS:0:8}
# Check if we are on the first YMD
if [[ ${start_ymd} == ${VDATE} ]]; then
start_cyc=${SDATE_GFS: -2}
else
start_cyc=0
fi

end_ymd=${EDATE_GFS:0:8}
# Check if we are on the last YMD
if [[ ${end_ymd} == ${VDATE} ]]; then
cyc2run=${EDATE_GFS: -2}
fi

if [[ ${cyc2run} != ${cyc} ]]; then
echo "Skipping ${METPCASE} for cycle ${cyc}, will be run on cycle ${cyc2run}"
exit 0
fi

end_cyc=${cyc2run}
verf_step=${STEP_GFS:-24}

#Determine which cycles to run
if [[ ${gfs_cyc} == 1 ]]; then
export fcyc_list="$cyc"
export vhr_list="$cyc"
else
export fcyc_list="$(seq -s ' ' -f '%02g' ${start_cyc} ${verf_step} ${end_cyc} )"
export vhr_list="$(seq -s ' ' -f '%02g' ${start_cyc} ${verf_step} ${end_cyc} )"
fi

# Map the global workflow environment variables to EMC_verif-global variables
export RUN_GRID2GRID_STEP1=${RUN_GRID2GRID_STEP1:-NO}
export RUN_GRID2OBS_STEP1=${RUN_GRID2OBS_STEP1:-NO}
Expand All @@ -40,7 +69,6 @@ export model_hpss_dir_list=${model_hpss_dir:-/NCEPDEV/$HPSS_PROJECT/1year/$USER/
export model_data_run_hpss=${get_data_from_hpss:-"NO"}
export hpss_walltime=${hpss_walltime:-10}
## DATE SETTINGS
export VDATE="${VDATE:-$(echo $($NDATE -${VRFYBACK_HRS} $CDATE) | cut -c1-8)}"
export start_date="$VDATE"
export end_date="$VDATE"
export spinup_period_start=${spinup_period_start:-"NA"}
Expand Down Expand Up @@ -141,7 +169,6 @@ export precip1_mv_database_desc=${precip1_mv_database_desc:-"Precip METplus data
echo

# Check forecast max hours, adjust if before experiment SDATE_GFS
export SDATE_GFS=${SDATE_GFS:-$SDATE}
SDATE_GFS_YYYYMMDDHH=$(echo $SDATE_GFS | cut -c1-10)
g2g1_anom_check_vhour="${g2g1_anom_vhr_list: -2}"
g2g1_anom_fhr_max_idate="$($NDATE -${g2g1_anom_fhr_max} ${VDATE}${g2g1_anom_check_vhour})"
Expand Down
20 changes: 17 additions & 3 deletions ush/set_init_valid_fhr_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ def get_hr_list_info(hr_list):
"""
hr_beg = (hr_list[0]).zfill(2)
hr_end = (hr_list[-1]).zfill(2)
hr_inc = str(int((24/len(hr_list))*3600))
if len(hr_list) <= 1:
hr_inc = "86400"
else:
hr_inc = str(3600 * int((int(hr_end) - int(hr_beg)) / (len(hr_list)-1)))

return hr_beg, hr_end, hr_inc

def get_forecast_hours(fcyc_list, vhr_list, fhr_min_str, fhr_max_str):
Expand All @@ -48,12 +52,22 @@ def get_forecast_hours(fcyc_list, vhr_list, fhr_min_str, fhr_max_str):
"""
fhr_min = float(fhr_min_str)
fhr_max = float(fhr_max_str)
fcyc_list = [int(fcyc) for fcyc in fcyc_list]
vhr_list = [int(vhr) for vhr in vhr_list]
nfcyc = len(fcyc_list)
nvhr = len(vhr_list)
# Calculate the interval based on the forecast cycle or verification hour
# Assumes that the hours are evenly spaced (6,12,18 or 0, 12 or 6,9,12,15, but not 0,6,9)
if nfcyc > nvhr:
fhr_intvl = int(24/nfcyc)
if nfcyc <= 1:
fhr_intvl = 24
else:
fhr_intvl = (max(fcyc_list) - min(fcyc_list)) / (len(fcyc_list) - 1)
else:
fhr_intvl = int(24/nvhr)
if nvhr <= 1:
fhr_intvl = 24
else:
fhr_intvl = (max(vhr_list) - min(vhr_list)) / (len(vhr_list) - 1)
nfhr = fhr_max/fhr_intvl
fhr_max = int(nfhr*fhr_intvl)
fhr_list = []
Expand Down

0 comments on commit 92904d2

Please sign in to comment.