From a72edf45dab7db23b9c2d99175100a019183e8b9 Mon Sep 17 00:00:00 2001 From: AntonMFernando-NOAA <167725623+AntonMFernando-NOAA@users.noreply.github.com> Date: Tue, 21 Jan 2025 12:40:00 -0500 Subject: [PATCH] Add domain level to wave gridded COM path (#3137) This pull request addresses the organization of wave gridded products within the file structure. Currently, all wave gridded products are placed in products/wave/gridded, without any further categorization. To align with the structure used by other component products (such as grib2), this update introduces a domain/resolution directory level to group output more effectively. For example, instead of having all products in a single directory, the structure will now include specific directories based on domain and resolution (e.g., products/wave/gridded/arctic.9km, products/wave/gridded/global.0p16). This change improves organization and scalability for wave gridded product outputs. Resolves #2677 --- jobs/JGLOBAL_ARCHIVE | 23 ++++- jobs/JGLOBAL_EXTRACTVARS | 5 ++ jobs/JGLOBAL_WAVE_GEMPAK | 10 +++ jobs/JGLOBAL_WAVE_POST_SBS | 14 ++- jobs/JGLOBAL_WAVE_PRDGEN_GRIDDED | 12 ++- parm/archive/gfswave.yaml.j2 | 20 ++++- parm/config/gfs/config.com | 1 + parm/config/gfs/config.waveawipsgridded | 2 + parm/config/gfs/config.wavegempak | 2 + scripts/exgfs_wave_nawips.sh | 10 ++- scripts/exgfs_wave_post_gridded_sbs.sh | 110 ++++++++---------------- scripts/exgfs_wave_prdgen_gridded.sh | 31 ++----- scripts/exglobal_archive.py | 2 +- ush/wave_domain_grid.sh | 43 +++++++++ ush/wave_extractvars.sh | 7 +- ush/wave_grib2_sbs.sh | 39 ++++++--- 16 files changed, 206 insertions(+), 125 deletions(-) create mode 100644 ush/wave_domain_grid.sh diff --git a/jobs/JGLOBAL_ARCHIVE b/jobs/JGLOBAL_ARCHIVE index 401feba35f..f62386cdd9 100755 --- a/jobs/JGLOBAL_ARCHIVE +++ b/jobs/JGLOBAL_ARCHIVE @@ -1,9 +1,8 @@ #! /usr/bin/env bash source "${HOMEgfs}/ush/preamble.sh" -source "${HOMEgfs}/ush/jjob_header.sh" -e "arch" -c "base arch" - - +source "${HOMEgfs}/ush/jjob_header.sh" -e "arch" -c "base arch wave" +source "${USHgfs}/wave_domain_grid.sh" ############################################## # Set variables used in the script ############################################## @@ -50,6 +49,23 @@ for grid in "0p25" "0p50" "1p00"; do "COMIN_ATMOS_GRIB_${grid}:COM_ATMOS_GRIB_GRID_TMPL" done +############################################################### +# Create an array of output wave grids to process +if [[ "${DO_WAVE}" == "YES" ]]; then + # Create a variable for output wave grids to process + if [[ -n "${wavepostGRD}" || -n "${waveinterpGRD}" ]]; then + for grdID in ${wavepostGRD} ${waveinterpGRD}; do + process_grdID "${grdID}" + YMD=${PDY} HH=${cyc} GRDRESNAME=${grdNAME} declare_from_tmpl -rx \ + "COMIN_WAVE_GRID_${GRDREGION}_${GRDRES}:COM_WAVE_GRID_RES_TMPL" + grids_arr+=("${GRDREGION}.${GRDRES}") + done + export WAVE_OUT_GRIDS="${grids_arr[*]}" + else + echo "Both wavepostGRD and waveinterpGRD are empty. No grids to process." + export WAVE_OUT_GRIDS="" + fi +fi ############################################################### # Run archive script ############################################################### @@ -69,7 +85,6 @@ if [[ -e "${pgmout}" ]] ; then cat "${pgmout}" fi - ########################################## # Remove the Temporary working directory ########################################## diff --git a/jobs/JGLOBAL_EXTRACTVARS b/jobs/JGLOBAL_EXTRACTVARS index 3478ca3976..1c1a763a03 100755 --- a/jobs/JGLOBAL_EXTRACTVARS +++ b/jobs/JGLOBAL_EXTRACTVARS @@ -2,6 +2,7 @@ source "${HOMEgfs}/ush/preamble.sh" source "${HOMEgfs}/ush/jjob_header.sh" -e "extractvars" -c "base extractvars" +source "${USHgfs}/wave_domain_grid.sh" # Set COM Paths for grid in '0p25' '0p50' '1p00'; do @@ -19,6 +20,10 @@ YMD="${PDY}" HH="${cyc}" declare_from_tmpl -rx \ "COMIN_ICE_NETCDF:COM_ICE_NETCDF_TMPL" \ "COMIN_WAVE_GRID:COM_WAVE_GRID_TMPL" +process_grdID "${waveGRD}" +YMD=${PDY} HH=${cyc} GRDRESNAME=${grdNAME} declare_from_tmpl -rx \ + "COMIN_WAVE_GRID_${GRDREGION}_${GRDRES}:COM_WAVE_GRID_RES_TMPL" + if [[ "${DO_ATM}" == "YES" ]]; then if [[ ! -d "${ARC_RFCST_PROD_ATMOS_F2D}" ]]; then mkdir -p "${ARC_RFCST_PROD_ATMOS_F2D}"; fi if [[ ! -d "${ARC_RFCST_PROD_ATMOS_F3D}" ]]; then mkdir -p "${ARC_RFCST_PROD_ATMOS_F3D}"; fi diff --git a/jobs/JGLOBAL_WAVE_GEMPAK b/jobs/JGLOBAL_WAVE_GEMPAK index c7b615c560..1c01b0cf64 100755 --- a/jobs/JGLOBAL_WAVE_GEMPAK +++ b/jobs/JGLOBAL_WAVE_GEMPAK @@ -17,6 +17,16 @@ YMD=${PDY} HH=${cyc} declare_from_tmpl -rx \ COMIN_WAVE_GRID:COM_WAVE_GRID_TMPL \ COMOUT_WAVE_GEMPAK:COM_WAVE_GEMPAK_TMPL +if [[ -n "${GEMPAK_GRIDS}" ]]; then + for grdID in ${GEMPAK_GRIDS}; do + process_grdID "${grdID}" + YMD=${PDY} HH=${cyc} GRDRESNAME=${grdNAME} declare_from_tmpl -rx \ + "COMIN_WAVE_GRID_${GRDREGION}_${GRDRES}:COM_WAVE_GRID_RES_TMPL" + done +else + echo "waveinterpGRD is empty. No grids to process." +fi + if [[ ! -d ${COMOUT_WAVE_GEMPAK} ]]; then mkdir -p "${COMOUT_WAVE_GEMPAK}"; fi ######################################################## diff --git a/jobs/JGLOBAL_WAVE_POST_SBS b/jobs/JGLOBAL_WAVE_POST_SBS index 53ac4b2083..171d160515 100755 --- a/jobs/JGLOBAL_WAVE_POST_SBS +++ b/jobs/JGLOBAL_WAVE_POST_SBS @@ -2,6 +2,7 @@ source "${HOMEgfs}/ush/preamble.sh" source "${HOMEgfs}/ush/jjob_header.sh" -e "wavepostsbs" -c "base wave wavepostsbs" +source "${USHgfs}/wave_domain_grid.sh" # Add default errchk = err_chk export errchk=${errchk:-err_chk} @@ -19,7 +20,18 @@ for out_dir in "${COMOUT_WAVE_PREP}" "${COMOUT_WAVE_GRID}"; do if [[ ! -d "${out_dir}" ]]; then mkdir -p "${out_dir}"; fi done - +if [[ -n "${wavepostGRD}" || -n "${waveinterpGRD}" ]]; then + for grdID in ${wavepostGRD} ${waveinterpGRD}; do + process_grdID "${grdID}" + YMD=${PDY} HH=${cyc} GRDRESNAME=${grdNAME} declare_from_tmpl -rx \ + "COMOUT_WAVE_GRID_${GRDREGION}_${GRDRES}:COM_WAVE_GRID_RES_TMPL" + out_dir_varname="COMOUT_WAVE_GRID_${GRDREGION}_${GRDRES}" + out_dir=${!out_dir_varname} + if [[ ! -d "${out_dir}" ]]; then mkdir -p "${out_dir}"; fi + done +else + echo "Both wavepostGRD and waveinterpGRD are empty. No grids to process." +fi # Set wave model ID tag to include member number # if ensemble; waveMEMB var empty in deterministic # Set wave model ID tag to include member number diff --git a/jobs/JGLOBAL_WAVE_PRDGEN_GRIDDED b/jobs/JGLOBAL_WAVE_PRDGEN_GRIDDED index 208b36c535..f84c5abc01 100755 --- a/jobs/JGLOBAL_WAVE_PRDGEN_GRIDDED +++ b/jobs/JGLOBAL_WAVE_PRDGEN_GRIDDED @@ -2,6 +2,7 @@ source "${HOMEgfs}/ush/preamble.sh" source "${HOMEgfs}/ush/jjob_header.sh" -e "waveawipsgridded" -c "base wave waveawipsgridded" +source "${USHgfs}/wave_domain_grid.sh" # Add default errchk = err_chk export errchk=${errchk:-err_chk} @@ -19,6 +20,15 @@ YMD=${PDY} HH=${cyc} declare_from_tmpl -rx \ if [[ ! -d ${COMOUT_WAVE_WMO} ]]; then mkdir -p "${COMOUT_WAVE_WMO}"; fi +if [[ -n "${GEMPAK_GRIDS}" ]]; then + for grdID in ${GEMPAK_GRIDS}; do + process_grdID "${grdID}" + YMD=${PDY} HH=${cyc} GRDRESNAME=${grdNAME} declare_from_tmpl -rx \ + "COMIN_WAVE_GRID_${GRDREGION}_${GRDRES}:COM_WAVE_GRID_RES_TMPL" + done +else + echo "GEMPAK_GRIDS are empty. No grids to process." +fi ################################### # Execute the Script @@ -35,6 +45,4 @@ if [ "${KEEPDATA}" != "YES" ]; then rm -rf ${DATA} fi - exit 0 - diff --git a/parm/archive/gfswave.yaml.j2 b/parm/archive/gfswave.yaml.j2 index 6909421757..550ecdb1be 100644 --- a/parm/archive/gfswave.yaml.j2 +++ b/parm/archive/gfswave.yaml.j2 @@ -1,20 +1,31 @@ gfswave: {% set head = "gfswave.t" + cycle_HH + "z." %} + name: "GFSWAVE" target: "{{ ATARDIR }}/{{ cycle_YMDH }}/gfswave.tar" required: # Wave GRIB2 regional forecast products + {% set WAVE_OUT_GRIDS_list = WAVE_OUT_GRIDS.split(' ') %} + {% for grd in WAVE_OUT_GRIDS_list %} + {% set tmpl_dict = ({ '${ROTDIR}':ROTDIR, + '${RUN}':RUN, + '${YMD}':cycle_YMD, + '${HH}':cycle_HH, + '${MEMDIR}':'', + '${GRDRESNAME}':grd}) %} + {% set file_path = COM_WAVE_GRID_RES_TMPL | replace_tmpl(tmpl_dict) %} + {% for fh in range(0, FHMAX_HF_WAV + FHOUT_HF_WAV, FHOUT_HF_WAV) %} # NOTE This is as explicit as possible without major logic to parse wavepostGRD. # Matches files of the form "gfswave.tCCz...fHHH.grib2". - - "{{ COMIN_WAVE_GRID | relpath(ROTDIR) }}/{{ head }}*.*.f{{ '%03d' % fh }}.grib2" - - "{{ COMIN_WAVE_GRID | relpath(ROTDIR) }}/{{ head }}*.*.f{{ '%03d' % fh }}.grib2.idx" + - "{{ file_path | relpath(ROTDIR) }}/{{ head }}*.*.f{{ '%03d' % fh }}.grib2" + - "{{ file_path | relpath(ROTDIR) }}/{{ head }}*.*.f{{ '%03d' % fh }}.grib2.idx" {% endfor %} # Global wave GRIB2 forecast products {% for fh in range(FHMAX_HF_WAV + FHOUT_WAV, FHMAX_WAV_GFS + FHOUT_WAV, FHOUT_WAV) %} - - "{{ COMIN_WAVE_GRID | relpath(ROTDIR) }}/{{ head }}*.*.f{{ '%03d' % fh }}.grib2" - - "{{ COMIN_WAVE_GRID | relpath(ROTDIR) }}/{{ head }}*.*.f{{ '%03d' % fh }}.grib2.idx" + - "{{ file_path | relpath(ROTDIR) }}/{{ head }}*.*.f{{ '%03d' % fh }}.grib2" + - "{{ file_path | relpath(ROTDIR) }}/{{ head }}*.*.f{{ '%03d' % fh }}.grib2.idx" {% endfor %} # Wave bulletins @@ -28,3 +39,4 @@ gfswave: - "{{ COMIN_WAVE_STATION | relpath(ROTDIR) }}/{{ head }}ibpcbull_tar" - "{{ COMIN_WAVE_STATION | relpath(ROTDIR) }}/{{ head }}ibp_tar" {% endif %} + {% endfor %} diff --git a/parm/config/gfs/config.com b/parm/config/gfs/config.com index d949edb33a..8b6da376f3 100644 --- a/parm/config/gfs/config.com +++ b/parm/config/gfs/config.com @@ -74,6 +74,7 @@ declare -rx COM_WAVE_RESTART_TMPL=${COM_BASE}'/model/wave/restart' declare -rx COM_WAVE_PREP_TMPL=${COM_BASE}'/model/wave/prep' declare -rx COM_WAVE_HISTORY_TMPL=${COM_BASE}'/model/wave/history' declare -rx COM_WAVE_GRID_TMPL=${COM_BASE}'/products/wave/gridded' +declare -rx COM_WAVE_GRID_RES_TMPL=${COM_BASE}'/products/wave/gridded/${GRDRESNAME}' declare -rx COM_WAVE_STATION_TMPL=${COM_BASE}'/products/wave/station' declare -rx COM_WAVE_GEMPAK_TMPL=${COM_BASE}'/products/wave/gempak' declare -rx COM_WAVE_WMO_TMPL=${COM_BASE}'/products/wave/wmo' diff --git a/parm/config/gfs/config.waveawipsgridded b/parm/config/gfs/config.waveawipsgridded index 48cbfda6a7..a752c659af 100644 --- a/parm/config/gfs/config.waveawipsgridded +++ b/parm/config/gfs/config.waveawipsgridded @@ -8,6 +8,8 @@ echo "BEGIN: config.waveawipsgridded" # Get task specific resources . $EXPDIR/config.resources waveawipsgridded +export GEMPAK_GRIDS=${GEMPAK_GRIDS:-ak_10m at_10m ep_10m wc_10m glo_30m} +# export GEMPAK_GRIDS=${GEMPAK_GRIDS:-ao_9km at_10m ep_10m wc_10m glo_30m} # AWIPS output frequency export FHMAX_HF_WAV_WMO=72 export FHMAX_WAV_WMO=180 diff --git a/parm/config/gfs/config.wavegempak b/parm/config/gfs/config.wavegempak index bcbec91f07..c0f53eb1b0 100644 --- a/parm/config/gfs/config.wavegempak +++ b/parm/config/gfs/config.wavegempak @@ -8,5 +8,7 @@ echo "BEGIN: config.wavegempak" # Get task specific resources . $EXPDIR/config.resources wavegempak +#export GEMPAK_GRIDS=${GEMPAK_GRIDS:-'glo_30m at_10m ep_10m wc_10m ao_9km'} #Interpolated grids +export GEMPAK_GRIDS=${GEMPAK_GRIDS:-${waveinterpGRD:-'glo_30m'}} echo "END: config.wavegempak" diff --git a/scripts/exgfs_wave_nawips.sh b/scripts/exgfs_wave_nawips.sh index 68ebfc90c7..f8f65a800a 100755 --- a/scripts/exgfs_wave_nawips.sh +++ b/scripts/exgfs_wave_nawips.sh @@ -12,9 +12,10 @@ ##################################################################### source "${USHgfs}/preamble.sh" +source "${USHgfs}/wave_domain_grid.sh" -#export grids=${grids:-'glo_30m at_10m ep_10m wc_10m ao_9km'} #Interpolated grids -export grids=${grids:-${waveinterpGRD:-'glo_30m'}} #Native grids +#export grids=${GEMPAK_GRIDS:-'glo_30m at_10m ep_10m wc_10m ao_9km'} #Interpolated grids +export grids=${GEMPAK_GRIDS:-${waveinterpGRD:-'glo_30m'}} #Native grids export RUNwave=${RUNwave:-${RUN}wave} export fstart=${fstart:-0} export FHMAX_WAV=${FHMAX_WAV:-180} #180 Total of hours to process @@ -73,7 +74,10 @@ while [ ${fhcnt} -le ${FHMAX_WAV} ]; do *) grdIDin= grdIDout= ;; esac - GRIBIN="${COMIN_WAVE_GRID}/${RUNwave}.${cycle}.${grdIDin}.f${fhr}.grib2" + process_grdID "${grid}" + com_varname="COMIN_WAVE_GRID_${GRDREGION}_${GRDRES}" + com_dir=${!com_varname} + GRIBIN="${com_dir}/${RUNwave}.${cycle}.${grdIDin}.f${fhr}.grib2" GRIBIN_chk=${GRIBIN}.idx if ! wait_for_file "${GRIBIN_chk}" "${sleep_interval}" "${maxtries}"; then echo "FATAL ERROR: ${GRIBIN_chk} not found after waiting $((sleep_interval * ( maxtries - 1))) secs" diff --git a/scripts/exgfs_wave_post_gridded_sbs.sh b/scripts/exgfs_wave_post_gridded_sbs.sh index 423d6af694..83584e7a5d 100755 --- a/scripts/exgfs_wave_post_gridded_sbs.sh +++ b/scripts/exgfs_wave_post_gridded_sbs.sh @@ -33,6 +33,7 @@ # 0. Preparations source "${USHgfs}/preamble.sh" +source "${USHgfs}/wave_domain_grid.sh" # 0.a Basic modes of operation @@ -218,7 +219,6 @@ source "${USHgfs}/preamble.sh" echo ' Making command file for sbs grib2 and GRID Interpolation ' set_trace fhr=$(( 10#${FHR3} )) - fhrg=$fhr ymdh=$($NDATE $fhr ${PDY}${cyc}) YMD=$(echo $ymdh | cut -c1-8) HMS="$(echo $ymdh | cut -c9-10)0000" @@ -238,75 +238,41 @@ source "${USHgfs}/preamble.sh" export GRDIDATA=${DATA}/output_$YMDHMS # Gridded data (main part, need to be run side-by-side with forecast + gfile="${COMIN_WAVE_HISTORY}/${WAV_MOD_TAG}.out_grd.${waveGRD}.${YMD}.${HMS}" + if [[ ! -s "${gfile}" ]]; then + echo " FATAL ERROR : NO RAW FIELD OUTPUT FILE ${gfile}" + err=3; export err; "${errchk}" + exit "${err}" + fi + ${NLN} "${gfile}" "./out_grd.${waveGRD}" - if [ $fhr = $fhrg ] + if [ "$DOGRI_WAV" = 'YES' ] then - gfile="${COMIN_WAVE_HISTORY}/${WAV_MOD_TAG}.out_grd.${waveGRD}.${YMD}.${HMS}" - if [[ ! -s "${gfile}" ]]; then - echo " FATAL ERROR : NO RAW FIELD OUTPUT FILE ${gfile}" - err=3; export err; "${errchk}" - exit "${err}" - fi - ${NLN} "${gfile}" "./out_grd.${waveGRD}" - - if [ "$DOGRI_WAV" = 'YES' ] - then - nigrd=1 - for grdID in $waveinterpGRD - do - ymdh_int=$($NDATE -${WAVHINDH} $ymdh); dt_int=3600.; n_int=9999 ; - echo "${USHgfs}/wave_grid_interp_sbs.sh $grdID $ymdh_int $dt_int $n_int > grint_$grdID.out 2>&1" >> ${fcmdigrd}.${nigrd} - 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 - 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} - chmod 744 ${fcmdigrd}.${nigrd} - nigrd=$((nigrd+1)) - done - fi - - if [ "$DOGRB_WAV" = 'YES' ] - then - for grdID in ${wavepostGRD} # First concatenate grib files for sbs grids - do + nigrd=1 + for grdID in $waveinterpGRD + do + ymdh_int=$($NDATE -${WAVHINDH} $ymdh); dt_int=3600.; n_int=9999 ; + echo "${USHgfs}/wave_grid_interp_sbs.sh $grdID $ymdh_int $dt_int $n_int > grint_$grdID.out 2>&1" >> ${fcmdigrd}.${nigrd} + if [ "$DOGRB_WAV" = 'YES' ] + then 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 - echo "${USHgfs}/wave_grib2_sbs.sh $grdID $GRIDNR $MODNR $ymdh $fhr $GRDNAME $GRDRES $gribFL > grib_$grdID.out 2>&1" >> ${fcmdnow} - done - fi + process_grdID "${grdID}" + echo "${USHgfs}/wave_grib2_sbs.sh $grdID $GRIDNR $MODNR $ymdh $fhr $GRDREGION $GRDRES $gribFL > grib_$grdID.out 2>&1" >> ${fcmdigrd}.${nigrd} + fi + echo "${GRIBDATA}/${fcmdigrd}.${nigrd}" >> ${fcmdnow} + chmod 744 ${fcmdigrd}.${nigrd} + nigrd=$((nigrd+1)) + done + fi + if [ "$DOGRB_WAV" = 'YES' ] + then + for grdID in ${wavepostGRD} # First concatenate grib files for sbs grids + do + gribFL=\'$(echo ${OUTPARS_WAV})\' + process_grdID "${grdID}" + echo "${USHgfs}/wave_grib2_sbs.sh $grdID $GRIDNR $MODNR $ymdh $fhr $GRDREGION $GRDRES $gribFL > grib_$grdID.out 2>&1" >> ${fcmdnow} + done fi if [ ${CFP_MP:-"NO"} = "YES" ]; then @@ -377,15 +343,14 @@ source "${USHgfs}/preamble.sh" rm -f out_grd.* # Remove large binary grid output files cd $DATA - - - if [ "$fhr" = "$fhrg" ] - then + # Check if grib2 file created ENSTAG="" + com_varname="COMOUT_WAVE_GRID_${GRDREGION}_${GRDRES}" + com_dir=${!com_varname} if [ ${waveMEMB} ]; then ENSTAG=".${membTAG}${waveMEMB}" ; fi - gribchk="${RUN}wave.${cycle}${ENSTAG}.${GRDNAME}.${GRDRES}.f${FH3}.grib2" - if [ ! -s ${COMOUT_WAVE_GRID}/${gribchk} ]; then + gribchk="${RUN}wave.${cycle}${ENSTAG}.${GRDREGION}.${GRDRES}.f${FH3}.grib2" + if [ ! -s ${com_dir}/${gribchk} ]; then set +x echo ' ' echo '********************************************' @@ -397,7 +362,6 @@ source "${USHgfs}/preamble.sh" err=5; export err;${errchk} exit "$err" fi - fi # --------------------------------------------------------------------------- # # 7. Ending output diff --git a/scripts/exgfs_wave_prdgen_gridded.sh b/scripts/exgfs_wave_prdgen_gridded.sh index 8fd6b5cc76..4e74d08e79 100755 --- a/scripts/exgfs_wave_prdgen_gridded.sh +++ b/scripts/exgfs_wave_prdgen_gridded.sh @@ -25,6 +25,7 @@ # 0. Preparations source "${USHgfs}/preamble.sh" +source "${USHgfs}/wave_domain_grid.sh" # 0.a Basic modes of operation @@ -48,7 +49,7 @@ source "${USHgfs}/preamble.sh" # Input grid grid_in="${waveinterpGRD:-glo_15mxt}" # Output grids -grids=${grids:-ao_9km at_10m ep_10m wc_10m glo_30m} +grids=${GEMPAK_GRIDS:-ak_10m at_10m ep_10m wc_10m glo_30m} # export grids=${wavepostGRD} maxtries=${maxtries:-720} # 0.b Date and time stuff @@ -88,33 +89,19 @@ grids=${grids:-ao_9km at_10m ep_10m wc_10m glo_30m} # 1.a Grib file (AWIPS and FAX charts) # Get input grid # TODO flesh this out with additional input grids if needed - case ${grid_in} in - glo_200) - grdIDin='global.2p00' ;; - glo_15mxt) - grdIDin='global.0p25' ;; - *) - echo "FATAL ERROR Unrecognized input grid ${grid_in}" - exit 2;; - esac + process_grdID "${grid_in}" + grdIDin=${grdNAME} fhcnt=${fstart} while [[ "${fhcnt}" -le "${FHMAX_WAV}" ]]; do fhr=$(printf "%03d" "${fhcnt}") for grdOut in ${grids}; do - case ${grdOut} in - ao_9km) grdID='arctic.9km' ;; - at_10m) grdID='atlocn.0p16' ;; - ep_10m) grdID='epacif.0p16' ;; - wc_10m) grdID='wcoast.0p16' ;; -# glo_30m) grdID='global.0p25' ;; - glo_30m) grdID='global.0p50' ;; - ak_10m) grdID='alaska.0p16' ;; - *) grdID= ;; - esac - # + process_grdID "${grdout}" + grdIDin=${grdNAME} + com_varname="${COMIN_WAVE_GRID}_${GRDREGION}_${GRDRES}" + com_dir="${!com_varname}" - GRIBIN="${COMIN_WAVE_GRID}/${RUNwave}.${cycle}.${grdIDin}.f${fhr}.grib2" + GRIBIN="${com_dir}/${RUNwave}.${cycle}.${grdIDin}.f${fhr}.grib2" GRIBIN_chk="${GRIBIN}.idx" sleep_interval=5 max_tries=1000 diff --git a/scripts/exglobal_archive.py b/scripts/exglobal_archive.py index df49704e06..f64db172ac 100755 --- a/scripts/exglobal_archive.py +++ b/scripts/exglobal_archive.py @@ -40,7 +40,7 @@ def main(): 'NMEM_ENS', 'DO_JEDIATMVAR', 'DO_VRFY_OCEANDA', 'FHMAX_FITS', 'waveGRD', 'IAUFHRS', 'DO_FIT2OBS', 'NET', 'FHOUT_HF_GFS', 'FHMAX_HF_GFS', 'REPLAY_ICS', 'OFFSET_START_HOUR', 'ARCH_EXPDIR', 'EXPDIR', 'ARCH_EXPDIR_FREQ', 'ARCH_HASHES', - 'ARCH_DIFFS', 'SDATE', 'EDATE', 'HOMEgfs', 'DO_GEMPAK'] + 'ARCH_DIFFS', 'SDATE', 'EDATE', 'HOMEgfs', 'DO_GEMPAK', 'WAVE_OUT_GRIDS'] archive_dict = AttrDict() for key in keys: diff --git a/ush/wave_domain_grid.sh b/ush/wave_domain_grid.sh new file mode 100644 index 0000000000..bf393c5513 --- /dev/null +++ b/ush/wave_domain_grid.sh @@ -0,0 +1,43 @@ +#! /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 +####################### + +process_grdID() { + grdID=$1 + case ${grdID} in + glo_10m) GRDREGION='global' ; GRDRES=0p16 ; GRIDNR=255 ; MODNR=11 ;; + glo_15mxt) GRDREGION='global' ; GRDRES=0p25 ; GRIDNR=255 ; MODNR=11 ;; + glo_30mxt) GRDREGION='global' ; GRDRES=0p50 ; GRIDNR=255 ; MODNR=11 ;; + glo_30m) GRDREGION='global' ; GRDRES=0p50 ; GRIDNR=255 ; MODNR=11 ;; + glo_025) GRDREGION='global' ; GRDRES=0p25 ; GRIDNR=255 ; MODNR=11 ;; + glo_100) GRDREGION='global' ; GRDRES=1p00 ; GRIDNR=255 ; MODNR=11 ;; + glo_200) GRDREGION='global' ; GRDRES=2p00 ; GRIDNR=255 ; MODNR=11 ;; + glo_500) GRDREGION='global' ; GRDRES=5p00 ; GRIDNR=255 ; MODNR=11 ;; + at_10m) GRDREGION='atlocn' ; GRDRES=0p16 ; GRIDNR=255 ; MODNR=11 ;; + ep_10m) GRDREGION='epacif' ; GRDRES=0p16 ; GRIDNR=255 ; MODNR=11 ;; + wc_10m) GRDREGION='wcoast' ; GRDRES=0p16 ; GRIDNR=255 ; MODNR=11 ;; + ak_10m) GRDREGION='alaska' ; GRDRES=0p16 ; GRIDNR=255 ; MODNR=11 ;; + aoc_9km) GRDREGION='arctic' ; GRDRES=9km ; GRIDNR=255 ; MODNR=11 ;; + ant_9km) GRDREGION='antarc' ; GRDRES=9km ; GRIDNR=255 ; MODNR=11 ;; + gnh_10m) GRDREGION='global' ; GRDRES=0p16 ; GRIDNR=255 ; MODNR=11 ;; + gsh_15m) GRDREGION='gsouth' ; GRDRES=0p25 ; GRIDNR=255 ; MODNR=11 ;; + ao_20m) GRDREGION='arctic' ; GRDRES=0p33 ; GRIDNR=255 ; MODNR=11 ;; + so_20m) GRDREGION='antarc' ; GRDRES=0p33 ; GRIDNR=255 ; MODNR=11 ;; + reg025) GRDREGION='global' ; GRDRES=0p25 ; GRIDNR=255 ; MODNR=11 ;; + gwes_30m) GRDREGION='global' ; GRDRES=0p50 ; GRIDNR=255 ; MODNR=10 ;; + *) + echo "FATAL ERROR: No grid specific wave config values exist for ${grdID}. Aborting." + exit 1 ;; + esac + grdNAME="${GRDREGION}.${GRDRES}" + echo "grdNAME=${grdNAME}" + echo "GRIDNR=${GRIDNR}" + echo "MODNR=${MODNR}" +} diff --git a/ush/wave_extractvars.sh b/ush/wave_extractvars.sh index 32ee44986b..cad65f777d 100755 --- a/ush/wave_extractvars.sh +++ b/ush/wave_extractvars.sh @@ -10,6 +10,11 @@ ####################### source "${USHgfs}/preamble.sh" +source "${USHgfs}/wave_domain_grid.sh" + +process_grdID "${waveGRD}" +com_varname="COMIN_WAVE_GRID_${GRDREGION}_${GRDRES}" +com_dir=${!com_varname} subdata=${1} @@ -18,7 +23,7 @@ subdata=${1} for (( nh = FHOUT_WAV_EXTRACT; nh <= FHMAX_WAV; nh = nh + FHOUT_WAV_EXTRACT )); do fnh=$(printf "%3.3d" "${nh}") - infile=${COMIN_WAVE_GRID}/${RUN}wave.t${cyc}z.global.${wavres}.f${fnh}.grib2 + infile=${com_dir}/${RUN}wave.t${cyc}z.global.${wavres}.f${fnh}.grib2 outfile=${subdata}/${RUN}wave.t${cyc}z.global.${wavres}.f${fnh}.grib2 rm -f "${outfile}" # Remove outfile if it already exists before extraction diff --git a/ush/wave_grib2_sbs.sh b/ush/wave_grib2_sbs.sh index 22eb361a0d..60e8d2a337 100755 --- a/ush/wave_grib2_sbs.sh +++ b/ush/wave_grib2_sbs.sh @@ -71,8 +71,19 @@ ENSTAG="" if [[ -n ${waveMEMB} ]]; then ENSTAG=".${membTAG}${waveMEMB}" ; fi outfile="${WAV_MOD_TAG}.${cycle}${ENSTAG}.${grdnam}.${grdres}.f${FH3}.grib2" +#create the COM directory var +com_varname="COMOUT_WAVE_GRID_${grdnam}_${grdres}" +com_dir="${!com_varname}" + +# Check if the COM directory exists, create it if necessary +if [[ ! -d "${com_dir}" ]]; then + mkdir -p -m "${com_dir}" + echo "Directory ${com_dir} created." +else + echo "Directory ${com_dir} already exists." +fi # Only create file if not present in COM -if [[ ! -s "${COMOUT_WAVE_GRID}/${outfile}.idx" ]]; then +if [[ ! -s "${com_dir}/${outfile}.idx" ]]; then set +x echo ' ' @@ -83,7 +94,7 @@ if [[ ! -s "${COMOUT_WAVE_GRID}/${outfile}.idx" ]]; then set_trace if [[ -z "${PDY}" ]] || [[ -z ${cyc} ]] || [[ -z "${cycle}" ]] || [[ -z "${EXECgfs}" ]] || \ - [[ -z "${COMOUT_WAVE_GRID}" ]] || [[ -z "${WAV_MOD_TAG}" ]] || [[ -z "${gribflags}" ]] || \ + [[ -z "${com_dir}" ]] || [[ -z "${WAV_MOD_TAG}" ]] || [[ -z "${gribflags}" ]] || \ [[ -z "${GRIDNR}" ]] || [[ -z "${MODNR}" ]] || \ [[ -z "${SENDDBN}" ]]; then set +x @@ -158,11 +169,11 @@ if [[ ! -s "${COMOUT_WAVE_GRID}/${outfile}.idx" ]]; then fi if (( fhr > 0 )); then - ${WGRIB2} gribfile -set_date "${PDY}${cyc}" -set_ftime "${fhr} hour fcst" -grib "${COMOUT_WAVE_GRID}/${outfile}" + ${WGRIB2} gribfile -set_date "${PDY}${cyc}" -set_ftime "${fhr} hour fcst" -grib "${com_dir}/${outfile}" err=$? else ${WGRIB2} gribfile -set_date "${PDY}${cyc}" -set_ftime "${fhr} hour fcst" \ - -set table_1.4 1 -set table_1.2 1 -grib "${COMOUT_WAVE_GRID}/${outfile}" + -set table_1.4 1 -set table_1.2 1 -grib "${com_dir}/${outfile}" err=$? fi @@ -178,7 +189,7 @@ if [[ ! -s "${COMOUT_WAVE_GRID}/${outfile}.idx" ]]; then fi # Create index - ${WGRIB2} -s "${COMOUT_WAVE_GRID}/${outfile}" > "${COMOUT_WAVE_GRID}/${outfile}.idx" + ${WGRIB2} -s "${com_dir}/${outfile}" > "${com_dir}/${outfile}.idx" # Create grib2 subgrid is this is the source grid if [[ "${grdID}" = "${WAV_SUBGRBSRC}" ]]; then @@ -187,14 +198,14 @@ if [[ ! -s "${COMOUT_WAVE_GRID}/${outfile}.idx" ]]; then subgrbnam=$(echo ${!subgrb} | cut -d " " -f 21) subgrbres=$(echo ${!subgrb} | cut -d " " -f 22) subfnam="${WAV_MOD_TAG}.${cycle}${ENSTAG}.${subgrbnam}.${subgrbres}.f${FH3}.grib2" - ${COPYGB2} -g "${subgrbref}" -i0 -x "${COMOUT_WAVE_GRID}/${outfile}" "${COMOUT_WAVE_GRID}/${subfnam}" - ${WGRIB2} -s "${COMOUT_WAVE_GRID}/${subfnam}" > "${COMOUT_WAVE_GRID}/${subfnam}.idx" + ${COPYGB2} -g "${subgrbref}" -i0 -x "${com_dir}/${outfile}" "${com_dir}/${subfnam}" + ${WGRIB2} -s "${com_dir}/${subfnam}" > "${com_dir}/${subfnam}.idx" done fi # 1.e Save in /com - if [[ ! -s "${COMOUT_WAVE_GRID}/${outfile}" ]]; then + if [[ ! -s "${com_dir}/${outfile}" ]]; then set +x echo ' ' echo '********************************************* ' @@ -206,7 +217,7 @@ if [[ ! -s "${COMOUT_WAVE_GRID}/${outfile}.idx" ]]; then set_trace exit 4 fi - if [[ ! -s "${COMOUT_WAVE_GRID}/${outfile}.idx" ]]; then + if [[ ! -s "${com_dir}/${outfile}.idx" ]]; then set +x echo ' ' echo '*************************************************** ' @@ -221,11 +232,11 @@ if [[ ! -s "${COMOUT_WAVE_GRID}/${outfile}.idx" ]]; then if [[ "${SENDDBN}" = 'YES' ]] && [[ ${outfile} != *global.0p50* ]]; then set +x - echo " Alerting GRIB file as ${COMOUT_WAVE_GRID}/${outfile}" - echo " Alerting GRIB index file as ${COMOUT_WAVE_GRID}/${outfile}.idx" + echo " Alerting GRIB file as ${com_dir}/${outfile}" + echo " Alerting GRIB index file as ${com_dir}/${outfile}.idx" set_trace - "${DBNROOT}/bin/dbn_alert" MODEL "${alertName}_WAVE_GB2" "${job}" "${COMOUT_WAVE_GRID}/${outfile}" - "${DBNROOT}/bin/dbn_alert" MODEL "${alertName}_WAVE_GB2_WIDX" "${job}" "${COMOUT_WAVE_GRID}/${outfile}.idx" + "${DBNROOT}/bin/dbn_alert" MODEL "${alertName}_WAVE_GB2" "${job}" "${com_dir}/${outfile}" + "${DBNROOT}/bin/dbn_alert" MODEL "${alertName}_WAVE_GB2_WIDX" "${job}" "${com_dir}/${outfile}.idx" else echo "${outfile} is global.0p50 or SENDDBN is NO, no alert sent" fi @@ -246,7 +257,7 @@ if [[ ! -s "${COMOUT_WAVE_GRID}/${outfile}.idx" ]]; then else set +x echo ' ' - echo " File ${COMOUT_WAVE_GRID}/${outfile} found, skipping generation process" + echo " File ${com_dir}/${outfile} found, skipping generation process" echo ' ' set_trace fi