From 6ba4f73cf54fb46f751d77b1daa2c5257d6e37eb Mon Sep 17 00:00:00 2001 From: AntonMFernando Date: Thu, 19 Dec 2024 13:13:01 -0500 Subject: [PATCH] adding a function to the scripts --- scripts/exgfs_wave_post_gridded_sbs.sh | 33 ++------------------ ush/wave_domain_grid.sh | 42 ++++++++++++++++++++++++++ ush/wave_extractvars.sh | 28 +---------------- 3 files changed, 45 insertions(+), 58 deletions(-) create mode 100644 ush/wave_domain_grid.sh diff --git a/scripts/exgfs_wave_post_gridded_sbs.sh b/scripts/exgfs_wave_post_gridded_sbs.sh index 56d6ca55fe..70de933d41 100755 --- a/scripts/exgfs_wave_post_gridded_sbs.sh +++ b/scripts/exgfs_wave_post_gridded_sbs.sh @@ -261,20 +261,7 @@ source "${USHgfs}/preamble.sh" if [ "$DOGRB_WAV" = 'YES' ] then gribFL=\'$(echo ${OUTPARS_WAV})\' - case $grdID in - glo_15mxt) GRDNAME='global' ; GRDRES=0p25 ; GRIDNR=255 ; MODNR=11 ;; - reg025) GRDNAME='global' ; GRDRES=0p25 ; GRIDNR=255 ; MODNR=11 ;; - glo_025) GRDNAME='global' ; GRDRES=0p25 ; GRIDNR=255 ; MODNR=11 ;; - glo_100) GRDNAME='global' ; GRDRES=1p00 ; GRIDNR=255 ; MODNR=11 ;; - glo_200) GRDNAME='global' ; GRDRES=2p00 ; GRIDNR=255 ; MODNR=11 ;; - glo_500) GRDNAME='global' ; GRDRES=5p00 ; GRIDNR=255 ; MODNR=11 ;; - glo_30mxt) GRDNAME='global' ; GRDRES=0p50 ; GRIDNR=255 ; MODNR=11 ;; - glo_30m) GRDNAME='global' ; GRDRES=0p50 ; GRIDNR=255 ; MODNR=11 ;; - at_10m) GRDNAME='atlocn' ; GRDRES=0p16 ; GRIDNR=255 ; MODNR=11 ;; - ep_10m) GRDNAME='epacif' ; GRDRES=0p16 ; GRIDNR=255 ; MODNR=11 ;; - wc_10m) GRDNAME='wcoast' ; GRDRES=0p16 ; GRIDNR=255 ; MODNR=11 ;; - ak_10m) GRDNAME='alaska' ; GRDRES=0p16 ; GRIDNR=255 ; MODNR=11 ;; - esac + eval "$(source "${USHgfs}/wave_domain_grid.sh" $grdID)" echo "${USHgfs}/wave_grib2_sbs.sh $grdID $GRIDNR $MODNR $ymdh $fhr $GRDNAME $GRDRES $gribFL > grib_$grdID.out 2>&1" >> ${fcmdigrd}.${nigrd} fi echo "${GRIBDATA}/${fcmdigrd}.${nigrd}" >> ${fcmdnow} @@ -288,23 +275,7 @@ source "${USHgfs}/preamble.sh" for grdID in ${wavepostGRD} # First concatenate grib files for sbs grids do gribFL=\'$(echo ${OUTPARS_WAV})\' - case $grdID in - aoc_9km) GRDNAME='arctic' ; GRDRES=9km ; GRIDNR=255 ; MODNR=11 ;; - ant_9km) GRDNAME='antarc' ; GRDRES=9km ; GRIDNR=255 ; MODNR=11 ;; - glo_10m) GRDNAME='global' ; GRDRES=0p16 ; GRIDNR=255 ; MODNR=11 ;; - gnh_10m) GRDNAME='global' ; GRDRES=0p16 ; GRIDNR=255 ; MODNR=11 ;; - gsh_15m) GRDNAME='gsouth' ; GRDRES=0p25 ; GRIDNR=255 ; MODNR=11 ;; - glo_15m) GRDNAME='global' ; GRDRES=0p25 ; GRIDNR=255 ; MODNR=11 ;; - ao_20m) GRDNAME='arctic' ; GRDRES=0p33 ; GRIDNR=255 ; MODNR=11 ;; - so_20m) GRDNAME='antarc' ; GRDRES=0p33 ; GRIDNR=255 ; MODNR=11 ;; - glo_15mxt) GRDNAME='global' ; GRDRES=0p25 ; GRIDNR=255 ; MODNR=11 ;; - reg025) GRDNAME='global' ; GRDRES=0p25 ; GRIDNR=255 ; MODNR=11 ;; - glo_025) GRDNAME='global' ; GRDRES=0p25 ; GRIDNR=255 ; MODNR=11 ;; - glo_100) GRDNAME='global' ; GRDRES=1p00 ; GRIDNR=255 ; MODNR=11 ;; - glo_200) GRDNAME='global' ; GRDRES=2p00 ; GRIDNR=255 ; MODNR=11 ;; - glo_500) GRDNAME='global' ; GRDRES=5p00 ; GRIDNR=255 ; MODNR=11 ;; - gwes_30m) GRDNAME='global' ; GRDRES=0p50 ; GRIDNR=255 ; MODNR=10 ;; - esac + eval "$(source "${USHgfs}/wave_domain_grid.sh" $grdID)" echo "${USHgfs}/wave_grib2_sbs.sh $grdID $GRIDNR $MODNR $ymdh $fhr $GRDNAME $GRDRES $gribFL > grib_$grdID.out 2>&1" >> ${fcmdnow} done fi diff --git a/ush/wave_domain_grid.sh b/ush/wave_domain_grid.sh new file mode 100644 index 0000000000..643c2f320c --- /dev/null +++ b/ush/wave_domain_grid.sh @@ -0,0 +1,42 @@ +#! /usr/bin/env bash + +################################################################################ +## UNIX Script Documentation Block +## Script name: wave_domain_grid.sh +## Script description: provides the wave grid specific values that +## are needed for the wave related jobs +####################### +# Main body starts here +####################### + +source "${USHgfs}/preamble.sh" + +process_grdID() { + local grdID=$1 + case ${grdID} in + glo_10m) GRDNAME='global' ; GRDRES=0p16 ; GRIDNR=255 ; MODNR=11 ;; + glo_15mxt) GRDNAME='global' ; GRDRES=0p25 ; GRIDNR=255 ; MODNR=11 ;; + glo_30mxt) GRDNAME='global' ; GRDRES=0p50 ; GRIDNR=255 ; MODNR=11 ;; + glo_30m) GRDNAME='global' ; GRDRES=0p50 ; GRIDNR=255 ; MODNR=11 ;; + glo_025) GRDNAME='global' ; GRDRES=0p25 ; GRIDNR=255 ; MODNR=11 ;; + glo_100) GRDNAME='global' ; GRDRES=1p00 ; GRIDNR=255 ; MODNR=11 ;; + glo_200) GRDNAME='global' ; GRDRES=2p00 ; GRIDNR=255 ; MODNR=11 ;; + glo_500) GRDNAME='global' ; GRDRES=5p00 ; GRIDNR=255 ; MODNR=11 ;; + at_10m) GRDNAME='atlocn' ; GRDRES=0p16 ; GRIDNR=255 ; MODNR=11 ;; + ep_10m) GRDNAME='epacif' ; GRDRES=0p16 ; GRIDNR=255 ; MODNR=11 ;; + wc_10m) GRDNAME='wcoast' ; GRDRES=0p16 ; GRIDNR=255 ; MODNR=11 ;; + ak_10m) GRDNAME='alaska' ; GRDRES=0p16 ; GRIDNR=255 ; MODNR=11 ;; + aoc_9km) GRDNAME='arctic' ; GRDRES=9km ; GRIDNR=255 ; MODNR=11 ;; + ant_9km) GRDNAME='antarc' ; GRDRES=9km ; GRIDNR=255 ; MODNR=11 ;; + gnh_10m) GRDNAME='global' ; GRDRES=0p16 ; GRIDNR=255 ; MODNR=11 ;; + gsh_15m) GRDNAME='gsouth' ; GRDRES=0p25 ; GRIDNR=255 ; MODNR=11 ;; + ao_20m) GRDNAME='arctic' ; GRDRES=0p33 ; GRIDNR=255 ; MODNR=11 ;; + so_20m) GRDNAME='antarc' ; GRDRES=0p33 ; GRIDNR=255 ; MODNR=11 ;; + reg025) GRDNAME='global' ; GRDRES=0p25 ; GRIDNR=255 ; MODNR=11 ;; + gwes_30m) GRDNAME='global' ; GRDRES=0p50 ; GRIDNR=255 ; MODNR=11 ;; + *) + echo "FATAL ERROR: No grid specific wave config values exist for ${grdID}. Aborting." + exit 1 ;; + esac + export grdNAME="${GRDNAME}.${GRDRES}" +} diff --git a/ush/wave_extractvars.sh b/ush/wave_extractvars.sh index c7d097f947..4499d773f9 100755 --- a/ush/wave_extractvars.sh +++ b/ush/wave_extractvars.sh @@ -13,33 +13,7 @@ source "${USHgfs}/preamble.sh" subdata=${1} -for grdID in ${waveGRD}; do - case ${grdID} in - glo_10m) GRDNAME='global' ; GRDRES=0p16;; - glo_15mxt) GRDNAME='global' ; GRDRES=0p25;; - glo_30mxt) GRDNAME='global' ; GRDRES=0p50 ;; - glo_30m) GRDNAME='global' ; GRDRES=0p50 ;; - glo_025) GRDNAME='global' ; GRDRES=0p25 ;; - glo_100) GRDNAME='global' ; GRDRES=1p00;; - glo_200) GRDNAME='global' ; GRDRES=2p00;; - glo_500) GRDNAME='global' ; GRDRES=5p00;; - at_10m) GRDNAME='atlocn' ; GRDRES=0p16 ;; - ep_10m) GRDNAME='epacif' ; GRDRES=0p16;; - wc_10m) GRDNAME='wcoast' ; GRDRES=0p16 ;; - ak_10m) GRDNAME='alaska' ; GRDRES=0p16;; - aoc_9km) GRDNAME='arctic' ; GRDRES=9km;; - ant_9km) GRDNAME='antarc' ; GRDRES=9km ;; - gnh_10m) GRDNAME='global' ; GRDRES=0p16;; - gsh_15m) GRDNAME='gsouth' ; GRDRES=0p25;; - ao_20m) GRDNAME='arctic' ; GRDRES=0p33;; - so_20m) GRDNAME='antarc' ; GRDRES=0p33;; - reg025) GRDNAME='global' ; GRDRES=0p25;; - gwes_30m) GRDNAME='global' ; GRDRES=0p50;; - *) - echo "FATAL ERROR: No grid specific wave config values exist for ${grdID}. Aborting." - exit 1;; - esac -done +eval "$(source "${USHgfs}/wave_domain_grid.sh" $waveGRD)" [[ -d "${subdata}" ]] || mkdir -p "${subdata}"