Skip to content

Commit

Permalink
adding a function to the scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonMFernando-NOAA committed Dec 19, 2024
1 parent 34f8d72 commit 6ba4f73
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 58 deletions.
33 changes: 2 additions & 31 deletions scripts/exgfs_wave_post_gridded_sbs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
Expand Down
42 changes: 42 additions & 0 deletions ush/wave_domain_grid.sh
Original file line number Diff line number Diff line change
@@ -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 ;;

Check warning

Code scanning / shellcheck

GRIDNR appears unused. Verify use (or export if used externally). Warning

GRIDNR appears unused. Verify use (or export if used externally).

Check warning

Code scanning / shellcheck

MODNR appears unused. Verify use (or export if used externally). Warning

MODNR appears unused. Verify use (or export if used externally).
*)
echo "FATAL ERROR: No grid specific wave config values exist for ${grdID}. Aborting."
exit 1 ;;
esac
export grdNAME="${GRDNAME}.${GRDRES}"
}
28 changes: 1 addition & 27 deletions ush/wave_extractvars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"

Check notice

Code scanning / shellcheck

Consider invoking this command separately to avoid masking its return value (or use '|| true' to ignore). Note

Consider invoking this command separately to avoid masking its return value (or use '|| true' to ignore).

Check notice

Code scanning / shellcheck

Double quote to prevent globbing and word splitting. Note

Double quote to prevent globbing and word splitting.

Check notice

Code scanning / shellcheck

Prefer putting braces around variable references even when not strictly required. Note

Prefer putting braces around variable references even when not strictly required.

[[ -d "${subdata}" ]] || mkdir -p "${subdata}"

Expand Down

0 comments on commit 6ba4f73

Please sign in to comment.