#!/usr/bin/env sh #### UNIX Script Documentation Block # # Script Name: JNWM_CONVERSION_WATCH #### date export PS4=' $SECONDS + ' set -xa ########################## # Specify NET and RUN Name ########################## export NET=${NET:-nwm} export RUN=${RUN:-nwm} export cycle=${cycle:-t${cyc}z} ######################################################## # Make working directory and file To Log Msgs ######################################################## export DATA=${DATA:-${DATAROOT:?}/${jobid}} if [ ! -e $DATA ]; then mkdir -p $DATA fi cd ${DATA} ################################### # Set up the PDY ################################### setpdy.sh . ./PDY #################################### # Determine Job Output Name on System #################################### export pgmout="OUTPUT.${job}_${PDY}${cyc}.$$" #################################### # Specify Application Areas #################################### export HOMEnwm=${HOMEnwm:-${PACKAGEROOT:?}/${model}.${nwm_ver}} export LIBnwm=${LIBnwm:-${HOMEnwm}/lib} export USHnwm=${USHnwm:-${HOMEnwm}/ush} export PARMnwm=${PARMnwm:-${HOMEnwm}/parm} export SCRIPTnwm=${SCRIPTnwm:-${HOMEnwm}/scripts} ################################## # Input data directory ################################## case ${INPUT_MODEL} in rap) export GESIN=${GESIN:-$(compath.py ${envir}/$NET/${nwm_ver})/${RUN}.grib2netcdf/${INPUT_MODEL}.${PDY}} export filecheck=rap.t${cyc}z.awp130bgrbf export filenumber=18 export COMIN=$(compath.py ${envir}/rap/$rap_ver)/rap.$PDY export filein=rap.t${cyc}z.awp130bgrbf[01-18].grib2 ;; hrrr) export GESIN=${GESIN:-$(compath.py ${envir}/$NET/${nwm_ver})/${RUN}.grib2netcdf/${INPUT_MODEL}.${PDY}/conus} export filecheck=hrrr.t${cyc}z.wrfsfcf export filenumber=18 export COMIN=$(compath.py ${envir}/hrrr/$hrrr_ver)/hrrr.$PDY/conus export filein=hrrr.t${cyc}z.wrfsfcf[01-18].grib2 ;; gfs) export GESIN=${GESIN:-$(compath.py ${envir}/$NET/${nwm_ver})/${RUN}.grib2netcdf/${INPUT_MODEL}.${PDY}/${cyc}/atmos} export filecheck=gfs.t${cyc}z.sfluxgrbf export filenumber=160 export COMIN=$(compath.py ${envir}/gfs/$gfs_ver)/gfs.$PDY/$cyc/atmos export filein=gfs.t${cyc}z.sfluxgrbf[000-240].grib2 ;; cfs) export GESIN=${GESIN:-$(compath.py ${envir}/$NET/${nwm_ver})/${RUN}.grib2netcdf/${INPUT_MODEL}.${PDY}/${cyc}} export filecheck=6hrly_grib_*/flxf export filenumber=496 export COMIN=$(compath.py ${envir}/cfs/$cfs_ver)/cfs.$PDY/$cyc start_time=${PDY}${cyc} end_time=$(finddate.sh ${PDY} d+30) export filein=6hrly_grib_0[1-4]/flxf${end_time}${cyc}.0[1-4].${start_time}.grb2 ;; nam) export GESIN=${GESIN:-$(compath.py ${envir}/$NET/${nwm_ver})/${RUN}.grib2netcdf/${INPUT_MODEL}.${PDY}} export filecheck=nam.t${cyc}z export filenumber=96 export COMIN=$(compath.py ${envir}/nam/$nam_ver)/nam.$PDY if [ $cyc -eq 00 -o $cyc -eq 12 ]; then export filein=nam.t${cyc}z.hawaiinest.hiresf[00-48].tm00.grib2 else export filein=nam.t${cyc}z.priconest.hiresf[00-48].tm00.grib2 fi ;; hiresw) export GESIN=${GESIN:-$(compath.py ${envir}/$NET/${nwm_ver})/${RUN}.grib2netcdf/${INPUT_MODEL}.${PDY}} export filecheck=hiresw.t${cyc}z export filenumber=48 export COMIN=$(compath.py ${envir}/hiresw/$hiresw_ver)/hiresw.$PDY if [ $cyc -eq 00 -o $cyc -eq 12 ]; then export filein=hiresw.t${cyc}z.arw_2p5km.f[00-48].hi.grib2 else export filein=hiresw.t${cyc}z.arw_2p5km.f[00-48].pr.grib2 fi ;; esac if [ ${INPUT_MODEL} = cfs ]; then Waitmax=180 elif [ ${INPUT_MODEL} = gfs ]; then Waitmax=360 else Waitmax=90 fi icnt=1 fn=0 until [ $fn -ge $filenumber ] do fn=`ls $GESIN/${filecheck}* |wc -l` sleep 10 icnt=$((icnt + 1)) if [ $icnt -ge $Waitmax ] then set +x echo "***FATAL ERROR: $GESIN/$filecheck* still not fully available after `expr $Waitmax / 6` minutes waiting!" echo "***Please check if $COMIN/$filein are available." echo "***If so, rerun job jnwm_${INPUT_MODEL}_grib2netcdf and jnwm_${INPUT_MODEL}_conversion_watch." msg="$GESIN/$filecheck* still not fully available after `expr $Waitmax / 6` minutes waiting!" err_exit $msg fi done set -x msg="JOB $job HAS COMPLETED NORMALLY." postmsg $pgmout "$msg" if [ -e $pgmout ]; then cat $pgmout fi if [ "$KEEPDATA" != YES ]; then rm -rf $DATA fi date