diff --git a/parm/prep_sfc/snow2mdl.nml.tmpl b/parm/prep_sfc/snow2mdl.nml.tmpl new file mode 100644 index 000000000..cdb4c848b --- /dev/null +++ b/parm/prep_sfc/snow2mdl.nml.tmpl @@ -0,0 +1,34 @@ +&source_data + autosnow_file="" + nesdis_snow_file="./imssnow96.grib2" + nesdis_lsmask_file="" + afwa_snow_global_file="./snow.usaf.grib2" + afwa_snow_nh_file="" + afwa_snow_sh_file="" + afwa_lsmask_nh_file="" + afwa_lsmask_sh_file="" +/ +&qc + climo_qc_file="@[CLIMO_QC]" +/ +&model_specs + model_lat_file="@[MODEL_LATITUDE_FILE]" + model_lon_file="@[MODEL_LONGITUDE_FILE]" + model_lsmask_file="@[MODEL_SLMASK_FILE]" + gfs_lpl_file="@[GFS_LONSPERLAT_FILE]" +/ +&output_data + model_snow_file="./@[MODEL_SNOW_FILE]" + output_grib2=@[OUTPUT_GRIB2] +/ +&output_grib_time + grib_year=@[IMSYEAR] + grib_month=@[IMSMONTH] + grib_day=@[IMSDAY] + grib_hour=@[IMSHOUR] +/ +¶meters + lat_threshold=55.0 + min_snow_depth=0.05 + snow_cvr_threshold=50.0 +/ diff --git a/reg_tests/ice_blend/driver.hercules.sh b/reg_tests/ice_blend/driver.hercules.sh index 5377e77d3..35d818723 100755 --- a/reg_tests/ice_blend/driver.hercules.sh +++ b/reg_tests/ice_blend/driver.hercules.sh @@ -32,11 +32,13 @@ set -x source ../../sorc/machine-setup.sh > /dev/null 2>&1 module use ../../modulefiles module load build.$target.intelllvm +module load grib-util/1.4.0 +module load wgrib2/3.6.0 module list ulimit -s unlimited -export DATA="${WORK_DIR:-/work/noaa/stmp/$LOGNAME}" +DATA="${WORK_DIR:-/work2/noaa/stmp/$LOGNAME}" export DATA="${DATA}/reg-tests/ice-blend" #----------------------------------------------------------------------------- @@ -50,17 +52,9 @@ if [ "$UPDATE_BASELINE" = "TRUE" ]; then source ../get_hash.sh fi -export WGRIB=/work/noaa/epic/role-epic/spack-stack/hercules/spack-stack-1.5.0/envs/unified-env/install/intel/2021.9.0/grib-util-1.3.0-wenl3in/bin/wgrib -export WGRIB2=/work/noaa/epic/role-epic/spack-stack/hercules/spack-stack-1.5.0/envs/unified-env/install/intel/2021.9.0/wgrib2-3.1.1-v7xhwos/bin/wgrib2 -export COPYGB=/work/noaa/epic/role-epic/spack-stack/hercules/spack-stack-1.5.0/envs/unified-env/install/intel/2021.9.0/grib-util-1.3.0-wenl3in/bin/copygb -export COPYGB2=/work/noaa/epic/role-epic/spack-stack/hercules/spack-stack-1.5.0/envs/unified-env/install/intel/2021.9.0/grib-util-1.3.0-wenl3in/bin/copygb2 -export CNVGRIB=/work/noaa/epic/role-epic/spack-stack/hercules/spack-stack-1.5.0/envs/unified-env/install/intel/2021.9.0/grib-util-1.3.0-wenl3in/bin/cnvgrib - export HOMEreg=/work/noaa/nems/role-nems/ufs_utils.hercules/reg_tests/ice_blend export HOMEgfs=$PWD/../.. -rm -fr $DATA - ./ice_blend.sh exit 0 diff --git a/reg_tests/ice_blend/driver.jet.sh b/reg_tests/ice_blend/driver.jet.sh index 89106eca1..bd6088805 100755 --- a/reg_tests/ice_blend/driver.jet.sh +++ b/reg_tests/ice_blend/driver.jet.sh @@ -57,8 +57,6 @@ export HOMEreg=/lfs5/HFIP/hfv3gfs/emc.nemspara/role.ufsutils/ufs_utils/reg_tests export HOMEgfs=$PWD/../.. -rm -fr $DATA - ./ice_blend.sh exit 0 diff --git a/reg_tests/ice_blend/driver.orion.sh b/reg_tests/ice_blend/driver.orion.sh index a21b8893e..4759ed8de 100755 --- a/reg_tests/ice_blend/driver.orion.sh +++ b/reg_tests/ice_blend/driver.orion.sh @@ -55,8 +55,6 @@ fi export HOMEreg=/work/noaa/nems/role-nems/ufs_utils/reg_tests/ice_blend export HOMEgfs=$PWD/../.. -rm -fr $DATA - ./ice_blend.sh exit 0 diff --git a/reg_tests/ice_blend/driver.ursa.sh b/reg_tests/ice_blend/driver.ursa.sh index 0bf72da87..1a5283449 100755 --- a/reg_tests/ice_blend/driver.ursa.sh +++ b/reg_tests/ice_blend/driver.ursa.sh @@ -59,8 +59,6 @@ fi export HOMEreg=/scratch3/NCEPDEV/nems/role.ufsutils/ufs_utils/reg_tests/ice_blend export HOMEgfs=$PWD/../.. -rm -fr $DATA - ./ice_blend.sh exit 0 diff --git a/reg_tests/ice_blend/driver.wcoss2.sh b/reg_tests/ice_blend/driver.wcoss2.sh index 3131dda72..791d02a6e 100755 --- a/reg_tests/ice_blend/driver.wcoss2.sh +++ b/reg_tests/ice_blend/driver.wcoss2.sh @@ -54,8 +54,6 @@ fi export HOMEreg=/lfs/h2/emc/nems/noscrub/emc.nems/UFS_UTILS/reg_tests/ice_blend export HOMEgfs=$PBS_O_WORKDIR/../.. -rm -fr $DATA - ./ice_blend.sh exit 0 diff --git a/reg_tests/ice_blend/ice_blend.sh b/reg_tests/ice_blend/ice_blend.sh index fcd90fa35..c69b87e66 100755 --- a/reg_tests/ice_blend/ice_blend.sh +++ b/reg_tests/ice_blend/ice_blend.sh @@ -5,20 +5,52 @@ # driver script. #----------------------------------------------------------------------------- -export IMS_FILE=$HOMEreg/input_data/imssnow96.grib2.gdas.2018120618 -export FIVE_MIN_ICE_FILE=$HOMEreg/input_data/seaice.5min.grib2.gdas.2018120618 +set -x -${HOMEgfs}/ush/emcsfc_ice_blend.sh +rm -fr $DATA +mkdir -p $DATA +cd $DATA +IMS_FILE=${HOMEreg}/input_data/imssnow96.grib2.gdas.2018120618 +cp ${IMS_FILE} ./ims.grib2 + +# Follow OPS procedure by converting the IMS data to the 5 minute +# global grid. +$WGRIB2 ims.grib2 -match "ICEC" -grib ims.icec.grib2 +grid173="0 0 0 0 0 0 0 0 4320 2160 0 0 89958000 42000 48 -89958000 359958000 83000 83000 0" +$COPYGB2 -x -i3 -g "$grid173" ims.icec.grib2 ims.icec.5min.grib2 + +FIVE_MIN_ICE_FILE=${HOMEreg}/input_data/seaice.5min.grib2.gdas.2018120618 +FIVE_MIN_ICE_MASK_FILE=${HOMEgfs}/fix/am/emcsfc_gland5min.grib2 +BLENDED_ICE_FILE="seaice.5min.blend" + +# These are input files. +export FORT17="$FIVE_MIN_ICE_MASK_FILE" +export FORT11="ims.icec.5min.grib2" +export FORT15="$FIVE_MIN_ICE_FILE" + +# This is the output blended file +export FORT51=${BLENDED_ICE_FILE} + +# Run the emcsfc_ice_blend executable. +${HOMEgfs}/exec/emcsfc_ice_blend >> OUTPUT 2> errfile iret=$? + if [ $iret -ne 0 ]; then set +x echo "<<< ICE_BLEND TEST FAILED. <<<" - echo "<<< ICE_BLEND TEST FAILED. <<<" > ./summary.log + echo "<<< ICE_BLEND TEST FAILED. <<<" > ${HOMEgfs}/reg_tests/ice_blend/summary.log exit $iret +else +# Follow the OPS procedure by converting the output to grib1 and replace the +# bitmap with a flag value of 1.57. That flag is expected by the global_cycle +# program. + $WGRIB2 -set_int 3 51 42000 ${BLENDED_ICE_FILE} -grib ${BLENDED_ICE_FILE}.corner + $CNVGRIB -g21 ${BLENDED_ICE_FILE}.corner ${BLENDED_ICE_FILE}.bitmap + $COPYGB -M "#1.57" -x ${BLENDED_ICE_FILE}.bitmap $BLENDED_ICE_FILE fi -cmp ${DATA}/seaice.5min.blend $HOMEreg/baseline_data/t1534/seaice.5min.blend +cmp ${BLENDED_ICE_FILE} ${HOMEreg}/baseline_data/t1534/seaice.5min.blend iret=$? test_failed=0 if [ $iret -ne 0 ]; then @@ -31,17 +63,16 @@ if [ $test_failed -ne 0 ]; then echo "*********************************" echo "<<< ICE BLEND TEST FAILED. >>>" echo "*********************************" - echo "<<< ICE BLEND TEST FAILED. >>>" > ./summary.log + echo "<<< ICE BLEND TEST FAILED. >>>" > ${HOMEgfs}/reg_tests/ice_blend/summary.log if [ "$UPDATE_BASELINE" = "TRUE" ]; then - cd $DATA - $HOMEgfs/reg_tests/update_baseline.sh $HOMEreg "t1534" $commit_num + ${HOMEgfs}/reg_tests/update_baseline.sh $HOMEreg "t1534" $commit_num fi else echo echo "*********************************" echo "<<< ICE BLEND TEST PASSED. >>>" echo "*********************************" - echo "<<< ICE BLEND TEST PASSED. >>>" > ./summary.log + echo "<<< ICE BLEND TEST PASSED. >>>" > ${HOMEgfs}/reg_tests/ice_blend/summary.log fi exit 0 diff --git a/reg_tests/snow2mdl/driver.hercules.sh b/reg_tests/snow2mdl/driver.hercules.sh index caec19c5a..cd36be1c7 100755 --- a/reg_tests/snow2mdl/driver.hercules.sh +++ b/reg_tests/snow2mdl/driver.hercules.sh @@ -23,13 +23,12 @@ set -x source ../../sorc/machine-setup.sh > /dev/null 2>&1 module use ../../modulefiles module load build.$target.intelllvm -module load prod_util/2.1.1 module list ulimit -s unlimited -export DATA_ROOT="${WORK_DIR:-/work2/noaa/stmp/$LOGNAME}" -export DATA_ROOT="${DATA_ROOT}/reg-tests/snow2mdl" +DATA_ROOT="${WORK_DIR:-/work2/noaa/stmp/$LOGNAME}" +DATA_ROOT="${DATA_ROOT}/reg-tests/snow2mdl" PROJECT_CODE="${PROJECT_CODE:-fv3-cpu}" QUEUE="${QUEUE:-batch}" @@ -51,8 +50,6 @@ export OMP_NUM_THREADS=1 export HOMEreg=/work/noaa/nems/role-nems/ufs_utils.hercules/reg_tests/snow2mdl export HOMEgfs=$PWD/../.. -export WGRIB=/work/noaa/epic/role-epic/spack-stack/hercules/spack-stack-1.5.0/envs/unified-env/install/intel/2021.9.0/grib-util-1.3.0-wenl3in/bin/wgrib -export WGRIB2=/work/noaa/epic/role-epic/spack-stack/hercules/spack-stack-1.5.0/envs/unified-env/install/intel/2021.9.0/wgrib2-3.1.1-v7xhwos/bin/wgrib2 # The first test uses the hemispheric air force/afwa data, which was used in OPS. diff --git a/reg_tests/snow2mdl/driver.jet.sh b/reg_tests/snow2mdl/driver.jet.sh index 75177d8f7..c764bcbcd 100755 --- a/reg_tests/snow2mdl/driver.jet.sh +++ b/reg_tests/snow2mdl/driver.jet.sh @@ -24,8 +24,6 @@ set -x source ../../sorc/machine-setup.sh > /dev/null 2>&1 module use ../../modulefiles module load build.$target.intelllvm -module load wgrib2/2.0.8 -module load prod_util/2.1.1 set +x module list set -x @@ -49,7 +47,6 @@ fi export HOMEreg=/lfs5/HFIP/hfv3gfs/emc.nemspara/role.ufsutils/ufs_utils/reg_tests/snow2mdl export HOMEgfs=$PWD/../.. -export WGRIB=/apps/wgrib/1.8.1.0b/bin/wgrib rm -fr $DATA_ROOT diff --git a/reg_tests/snow2mdl/driver.orion.sh b/reg_tests/snow2mdl/driver.orion.sh index df0b87d5f..b3a4802a6 100755 --- a/reg_tests/snow2mdl/driver.orion.sh +++ b/reg_tests/snow2mdl/driver.orion.sh @@ -23,15 +23,12 @@ set -x source ../../sorc/machine-setup.sh > /dev/null 2>&1 module use ../../modulefiles module load build.$target.intelllvm -module load grib-util/1.4.0 -module load wgrib2/3.6.0 -module load prod_util/2.1.1 module list ulimit -a -export DATA_ROOT="${WORK_DIR:-/work/noaa/stmp/$LOGNAME}" -export DATA_ROOT="${DATA_ROOT}/reg-tests/snow2mdl" +DATA_ROOT="${WORK_DIR:-/work/noaa/stmp/$LOGNAME}" +DATA_ROOT="${DATA_ROOT}/reg-tests/snow2mdl" PROJECT_CODE="${PROJECT_CODE:-fv3-cpu}" QUEUE="${QUEUE:-batch}" diff --git a/reg_tests/snow2mdl/driver.ursa.sh b/reg_tests/snow2mdl/driver.ursa.sh index d91f9380b..2b9cfb594 100755 --- a/reg_tests/snow2mdl/driver.ursa.sh +++ b/reg_tests/snow2mdl/driver.ursa.sh @@ -25,16 +25,8 @@ compiler=${compiler:-"intelllvm"} source ../../sorc/machine-setup.sh > /dev/null 2>&1 module use ../../modulefiles module load build.$target.$compiler -module load grib-util -module load wgrib2 -module load prod_util module list -WGRIB=${GRIB_UTIL_ROOT}/bin/wgrib - -export WGRIB -export WGRIB2 - DATA_ROOT="${WORK_DIR:-/scratch4/NCEPDEV/stmp/$LOGNAME}" DATA_ROOT="${DATA_ROOT}/reg-tests/snow2mdl" diff --git a/reg_tests/snow2mdl/driver.wcoss2.sh b/reg_tests/snow2mdl/driver.wcoss2.sh index 3199f52da..ea89f698b 100755 --- a/reg_tests/snow2mdl/driver.wcoss2.sh +++ b/reg_tests/snow2mdl/driver.wcoss2.sh @@ -21,15 +21,12 @@ source ../../sorc/machine-setup.sh > /dev/null 2>&1 module use ../../modulefiles module load build.$target.intel -module load grib_util/1.2.2 -module load wgrib2/2.0.8 -module load prod_util/2.0.14 module list set -x -export DATA_ROOT="${WORK_DIR:-/lfs/h2/emc/stmp/$LOGNAME}" -export DATA_ROOT="${DATA_ROOT}/reg-tests/snow2mdl" +DATA_ROOT="${WORK_DIR:-/lfs/h2/emc/stmp/$LOGNAME}" +DATA_ROOT="${DATA_ROOT}/reg-tests/snow2mdl" PROJECT_CODE=${PROJECT_CODE:-"GFS-DEV"} QUEUE=${QUEUE:-"dev"} diff --git a/reg_tests/snow2mdl/snow2mdl.global.sh b/reg_tests/snow2mdl/snow2mdl.global.sh index 2ede113c7..2890ca08c 100755 --- a/reg_tests/snow2mdl/snow2mdl.global.sh +++ b/reg_tests/snow2mdl/snow2mdl.global.sh @@ -1,25 +1,55 @@ #!/bin/bash #-------------------------------------------------------------------------- -# Create a snow file from afwa global data and ims data. This script +# Create a snow file from afwa global data and ims data. This script # is run from its machine-specific driver. +# +# This test mimics current GFS OPS which uses the global afwa data. +# +# Note, this test uses the "snow2mdl.nml.tmpl" template to create +# the fort.41 namelist as is done by the global workflow. #-------------------------------------------------------------------------- +echo "BEGIN SNOW2MDL GLOBAL TEST." + set -x -export IMS_FILE=$HOMEreg/input_data/global/gfs.t00z.imssnow96.grib2 -export AFWA_GLOBAL_FILE="$HOMEreg/input_data/global/gfs.t00z.snow.usaf.grib2" +HOMEush="${HOMEgfs}/ush" +HOMEparm="${HOMEgfs}/parm" +HOMEexec="${HOMEgfs}/exec" +HOMEfix="${HOMEgfs}/fix/am" + +source "${HOMEush}/atparse.bash" # include function atparse for parsing @[XYZ] templated files + +SNOW2MDLNMLTMPL="${HOMEparm}/prep_sfc/snow2mdl.nml.tmpl" + +CLIMO_QC="${HOMEfix}/emcsfc_snow_cover_climo.grib2" + +MODEL_LATITUDE_FILE="${HOMEfix}/global_latitudes.t1534.3072.1536.grb" +MODEL_LONGITUDE_FILE="${HOMEfix}/global_longitudes.t1534.3072.1536.grb" +MODEL_SLMASK_FILE="${HOMEfix}/global_slmask.t1534.3072.1536.grb" +GFS_LONSPERLAT_FILE="${HOMEfix}/global_lonsperlat.t1534.3072.1536.txt" + +MODEL_SNOW_FILE="snogrb_model" +OUTPUT_GRIB2=".false." + +IMSYEAR=2025 +IMSMONTH=03 +IMSDAY=25 +IMSHOUR=0 -export MODEL_LATITUDE_FILE=$HOMEgfs/fix/am/global_latitudes.t1534.3072.1536.grb -export MODEL_LONGITUDE_FILE=$HOMEgfs/fix/am/global_longitudes.t1534.3072.1536.grb -export MODEL_SLMASK_FILE=$HOMEgfs/fix/am/global_slmask.t1534.3072.1536.grb -export GFS_LONSPERLAT_FILE=$HOMEgfs/fix/am/global_lonsperlat.t1534.3072.1536.txt +rm -fr $DATA +mkdir -p $DATA +cd $DATA -export OMP_NUM_THREADS=1 -export OUTPUT_GRIB2=.false. +cp "$HOMEreg/input_data/global/gfs.t00z.imssnow96.grib2" "./imssnow96.grib2" +cp "$HOMEreg/input_data/global/gfs.t00z.snow.usaf.grib2" "./snow.usaf.grib2" -${HOMEgfs}/ush/emcsfc_snow.sh +atparse < "${SNOW2MDLNMLTMPL}" >> "./fort.41" +echo "Rendered fort.41" +cat "./fort.41" +eval ${HOMEexec}/emcsfc_snow2mdl >> OUTPUT 2> errfile iret=$? if [ $iret -ne 0 ]; then set +x diff --git a/scripts/exemcsfc_global_sfc_prep.sh b/scripts/exemcsfc_global_sfc_prep.sh deleted file mode 100755 index 2090eb035..000000000 --- a/scripts/exemcsfc_global_sfc_prep.sh +++ /dev/null @@ -1,273 +0,0 @@ -#!/bin/bash - -#### UNIX Script Documentation Block ################################### -# . . -# Script name: exemcsfc_global_sfc_prep.sh -# RFC Contact: George Gayno -# Abstract: This script calls two utility scripts to prepare a global -# blended ice analysis and global snow analyses for use by GFS/GDAS. -# If there is an error in either utility script, the ice/snow -# file from the previous cycle is copied to the current com -# directory. If the ice/snow file from the previous cycle is -# unavailable, the script aborts. -# -# Script History Log: -# 07/2014 Gayno Initial version -# 12/2014 Gayno Set file defaults to grib 2 versions -# when available. -# 08/2015 Gayno Update to current NCO standards -# 08/2020 Gayno Rename without the '.ecf' extention per -# latest NCO standards. -# -# Usage: -# Parameters: < no arguments > -# Modules: -# /nwprod/gfs.vX.Y.Z/ush/emcsfc_ice_blend.sh (create global ice blend) -# /nwprod/gfs.vX.Y.Z/ush/emcsfc_snow.sh (create model snow analysis) -# Input Files: -# $AFWA_GLOBAL_FILE - afwa snow data (grib 2) -# $IMS_FILE - nh ims snow cover and ice data (grib 2) -# $FIVE_MIN_ICE_FILE - global 5-minute ice concentration (grib 2) -# $FIVE_MIN_ICE_MASK_FILE - corresponding land/sea mask for $FIVE_MIN_ICE_FILE -# (grib 2) -# $BLENDED_ICE_FILE_m6hrs - global 5-minute blended ice data (grib 1) -# from previous cycle. Backup data if -# program failure. -# $MODEL_SLMASK_FILE - model land/sea mask (grib 1) -# $MODEL_LATITUDE_FILE - model latitudes (grib 1) -# $MODEL_LONGITUDE_FILE - model longitudes (grib 1) -# $GFS_LONSPERLAT_FILE - gfs reduced grid information (text) -# $MODEL_SNOW_FILE_m6hrs - snow analysis on model grid (grib 1) -# from previous cycle. Backup data if -# program failure -# Output Files: -# $BLENDED_ICE_FILE - global 5-minute blended ice data (grib 1) -# $MODEL_SNOW_FILE - snow analysis on model grid (grib 1) -# -# Condition codes: -# 0 - normal termination -# non-0 - problem in the emcsfc_ice_blend.sh or emcsfc_snow.sh -# script and the backup ice or snow data is missing. -# fatal error. -# -# Attributes: -# Language: RedHat Linux -# Machine: NCEP WCOSS -# -######################################################################### - -VERBOSE=${VERBOSE:-"YES"} -if test "$VERBOSE" = "YES" -then - set -x -fi - -RUN=${RUN:-"gfs"} - -export PACKAGEROOT=${PACKAGEROOT:-/lfs/h1/ops/prod/packages} -export HOMEgfs=${HOMEgfs:-${PACKAGEROOT}/gfs.${gfs_ver:?}} -export USHgfs=${USHgfs:-$HOMEgfs/ush} -export FIXgfs=${FIXgfs:-$HOMEgfs/fix} -export EXECgfs=${EXECgfs:-$HOMEgfs/exec} - -# output com directory. -export COMOUT=${COMOUT:-$PWD} -export COMINgfs_m6hrs=${COMINgfs_m6hrs:-$PWD} - -# working directory -export DATA=${DATA:-$PWD} -if [ ! -d $DATA ]; then - mkdir -p $DATA -fi -cd $DATA - -# copy output data to com directory? -export SENDCOM=${SENDCOM:-"NO"} - -#----------------------------------------------------------------------- -# The "err_exit" utility is only used in ncep ops -# when the "prod_util" module is loaded. -#----------------------------------------------------------------------- - -use_prod_util=`echo $UTILROOT` -if ((${#use_prod_util} != 0)); then - use_prod_util="true" -else - use_prod_util="false" -fi - -#----------------------------------------------------------------------- -# the input data for emcsfc_ice_blend and emcsfc_snow2mdl programs. -#----------------------------------------------------------------------- - -# afwa snow depth data (grib 2) -export AFWA_GLOBAL_FILE=${AFWA_GLOBAL_FILE:-"snow.usaf.grib2"} - -# ims snow cover and ice cover data (grib 1 or grib 2) -export IMS_FILE=${IMS_FILE:-"ims.grib2"} - -# global 5-minute ice concentration file (grib 2) -export FIVE_MIN_ICE_FILE=${FIVE_MIN_ICE_FILE:-"seaice.5min.grib2"} - -# landmask file for global 5-minute data (grib 2) -export FIVE_MIN_ICE_MASK_FILE=${FIVE_MIN_ICE_MASK_FILE:-${FIXgfs}/am/emcsfc_gland5min.grib2} - -# the output ice blend data (grib) -export BLENDED_ICE_FILE=${BLENDED_ICE_FILE:-seaice.5min.blend} - -# the 6-hour old output ice blend data. -export BLENDED_ICE_FILE_m6hrs=${BLENDED_ICE_FILE_m6hrs:-seaice.5min.blend.old} - -# the emcsfc_ice_blend executable -export BLENDICEEXEC=${BLENDICEEXEC:-$EXECgfs/emcsfc_ice_blend} - -# standard output file -export pgmout=${pgmout:-OUTPUT} - -#----------------------------------------------------------------------- -# call utility script to create global ice blend data. -#----------------------------------------------------------------------- - -echo "Create blended ice data." - -${USHgfs}/emcsfc_ice_blend.sh -rc=$? - -#----------------------------------------------------------------------- -# If there is a failure in the ice blend script, copy the 6-hr old file -# to the current file. The gfs/gdas can run with old ice data for -# about a week. Although not fatal, any errors must be -# investigated. -# -# If there is a failure in the ice blend script AND the 6-hour old file -# is not available as a backup, abort the script. The global cycling -# code can't run without an ice analysis. -#----------------------------------------------------------------------- - -if ((rc != 0));then - if test "$SENDCOM" = "YES" - then - if [ -s $BLENDED_ICE_FILE_m6hrs ]; then - echo "Copy old ice blend file to current directory" - cp $BLENDED_ICE_FILE_m6hrs $COMOUT/$BLENDED_ICE_FILE - else - echo "FATAL ERROR: CURRENT AND 6-HR OLD ICE FILE MISSING" - if test "$use_prod_util" = "true" ; then - err_exit - else - exit 7 - fi - fi - else - exit 7 - fi # SENDCOM check -fi # return code check - -#----------------------------------------------------------------------- -# now create global snow depth data for full-res gaussian grid -# and (if a gdas run) enkf gaussian grid. -#----------------------------------------------------------------------- - -export SNOW2MDLEXEC=${EXECgfs}/emcsfc_snow2mdl - -JCAP=${JCAP:-"1534"} -LONB=${LONB:-"3072"} -LATB=${LATB:-"1536"} - -resolution="${JCAP}.${LONB}.${LATB}" - -export MODEL_SLMASK_FILE=${SLMASK:-${FIXgfs}/am/global_slmask.t${resolution}.grb} -export MODEL_LATITUDE_FILE=${MDL_LATS:-${FIXgfs}/am/global_latitudes.t${resolution}.grb} -export MODEL_LONGITUDE_FILE=${MDL_LONS:-${FIXgfs}/am/global_longitudes.t${resolution}.grb} -export GFS_LONSPERLAT_FILE=${LONSPERLAT:-${FIXgfs}/am/global_lonsperlat.t${resolution}.txt} -export MODEL_SNOW_FILE=${FNSNOAJCAP:-${RUN}.${cycle}.snogrb_t${resolution}} -export MODEL_SNOW_FILE_m6hrs=${FNSNOGJCAP:-${COMINgfs_m6hrs}/${RUN}.${cycle_m6hrs}.snogrb_t${resolution}} - -echo "Create ${JCAP} snow data." - -${USHgfs}/emcsfc_snow.sh -rc=$? - -#----------------------------------------------------------------------- -# If there was a failure in the emcsfc_snow script, copy the 6-hr old -# snow file to the current file. The gfs/gdas can run with old snow data -# for a day or two at most. So while not fatal, any errors must be -# investigated. -# -# If there is a failure in the emcsfc_snow script AND the 6-hour old -# snow file is not available as a backup, abort the script. The -# global cycling can't run without an snow analysis. -#----------------------------------------------------------------------- - -if ((rc != 0)); then - if test "$SENDCOM" = "YES" - then - if [ -s $MODEL_SNOW_FILE_m6hrs ]; then - echo "COPY OLD ${JCAP} SNOW FILE TO CURRENT DIRECTORY" - cp $MODEL_SNOW_FILE_m6hrs $COMOUT/$MODEL_SNOW_FILE - else - echo "FATAL ERROR: CURRENT AND 6-HR OLD ${JCAP} SNOW MISSING" - if test "$use_prod_util" = "true" ; then - err_exit - else - exit 8 - fi - fi # check of missing 6-hr snow file - else - exit 8 - fi # SENDCOM check -fi # return code check - -#----------------------------------------------------------------------- -# The GFS step does not run the enkf stuff. So there is no need to -# create an enkf snow file. -#----------------------------------------------------------------------- - -if test "$RUN" = "gfs" -then - exit 0 -fi - -JCAP_ENKF=${JCAP_ENKF:-"574"} -LONB_ENKF=${LONB_ENKF:-"1152"} -LATB_ENKF=${LATB_ENKF:-"576"} - -resolution="${JCAP_ENKF}.${LONB_ENKF}.${LATB_ENKF}" - -export MODEL_SLMASK_FILE=${SLMASK_ENKF:-${FIXgfs}/am/global_slmask.t${resolution}.grb} -export MODEL_LATITUDE_FILE=${MDL_LATS_ENKF:-${FIXgfs}/am/global_latitudes.t${resolution}.grb} -export MODEL_LONGITUDE_FILE=${MDL_LONS_ENKF:-${FIXgfs}/am/global_longitudes.t${resolution}.grb} -export GFS_LONSPERLAT_FILE=${LONSPERLAT_ENKF:-${FIXgfs}/am/global_lonsperlat.t${resolution}.txt} -export MODEL_SNOW_FILE=${FNSNOAJCAP_ENKF:-${RUN}.${cycle}.snogrb_t${resolution}} -export MODEL_SNOW_FILE_m6hrs=${FNSNOGJCAP_ENKF:-${COMINgfs_m6hrs}/${RUN}.${cycle_m6hrs}.snogrb_t${resolution}} - -echo "Create enkf snow data." - -${USHgfs}/emcsfc_snow.sh -rc=$? - -#----------------------------------------------------------------------- -# Check for errors creating enkf snow. Use 6-hour old data -# as backup. If old data not available, abort. -#----------------------------------------------------------------------- - -if ((rc != 0)); then - if test "$SENDCOM" = "YES" - then - if [ -s $MODEL_SNOW_FILE_m6hrs ]; then - echo "COPY OLD ENKF SNOW FILE TO CURRENT DIRECTORY" - cp $MODEL_SNOW_FILE_m6hrs $COMOUT/$MODEL_SNOW_FILE - else - echo "FATAL ERROR: CURRENT AND 6-HR OLD ENKF SNOW MISSING" - if test "$use_prod_util" = "true" ; then - err_exit - else - exit 9 - fi - fi # check of missing 6-hr snow file - else - exit 9 - fi # SENDCOM check -fi # return code check - -exit 0 diff --git a/ush/atparse.bash b/ush/atparse.bash new file mode 100755 index 000000000..5e0e8985d --- /dev/null +++ b/ush/atparse.bash @@ -0,0 +1,126 @@ +#! /usr/bin/env bash +function atparse { + # Usage: + # source atparse.bash # defines the "atparse" function; only do this once + # atparse [ var1=value1 [ var2=value2 [...] ] ] < input_file > output_file + # This function filters text from stdin to stdout. It scans for text sequences like: + # @[varname] + # And replaces them with the value of the corresponding ${varname} variable. + # You can provide variables that are not set in bash by providing them on the command line. + # If set -u is enabled, it will exit the process when a variable is empty or undefined via set -u. + + # Use __ in names to avoid clashing with variables in {var} blocks. + local __text # current line of text being parsed, or the current command-line argument being parsed + local __before # all text before the next @[...] option + local __after # all text after the next @[...] option + local __during # the contents of the @[...] option, including the @[ and ] + local __set_x=":" # will be "set -x" if the calling script had that option enabled + local __set_u=":" # will be "set -u" if the calling script had that option enabled + local __set_e=":" # will be "set -e" if the calling script had that option enabled + local __abort_on_undefined=NO # YES = script should abort if a variable is undefined, NO otherwise + + # Ensure "set -x -e -u" are all inactive, but remember if they + # were active so we can reset them later. + if [[ -o xtrace ]] ; then + __set_x="set -x" + fi + if [[ -o errexit ]] ; then + __set_e="set -e" + fi + if [[ -o nounset ]] ; then + __set_u="set -u" + __abort_on_undefined=YES + fi + set +eux + + # Allow setting variables on the atparse command line rather than the environment. + # They will be local variables in this function. + for __text in "$@" ; do + if [[ $__text =~ ^([a-zA-Z][a-zA-Z0-9_]*)=(.*)$ ]] ; then + eval "local ${BASH_REMATCH[1]}" + eval "${BASH_REMATCH[1]}="'"${BASH_REMATCH[2]}"' + else + echo "ERROR: Ignoring invalid argument $__text" 1>&2 + fi + done + + # Loop over all lines of text. + while [[ 1 == 1 ]] ; do + # Read the next line of text. This will "fail" if no more text + # is left OR if the last line lacks an end-of-line character. + read -d '' -r __text + + # Stop when "read" reports it is done ($? -ne 0) AND the text is + # non-empty (! -n "$__text"). This ensures we read the final line + # even if it lacks an end-of-line character. + if [[ $? -ne 0 ]] ; then + if [[ -n "$__text" ]] ; then + # Text remained, but it had no end-of-line. + : + else + break + fi + fi + # Search for strings like @[varname] or @['string'] or @[@] + while [[ "$__text" =~ ^([^@]*)(@\[[a-zA-Z_][a-zA-Z_0-9]*\]|@\[\'[^\']*\'\]|@\[@\]|@)(.*) ]] ; do + __before="${BASH_REMATCH[1]}" + __during="${BASH_REMATCH[2]}" + __after="${BASH_REMATCH[3]}" + printf %s "$__before" + # @['string'] inserts string + if [[ "$__during" =~ ^@\[\'(.*)\'\]$ ]] ; then + printf %s "${BASH_REMATCH[1]}" + # @[@] inserts @ + elif [[ "$__during" == '@[@]' ]] ; then + printf @ + # @[varname] inserts $varname + elif [[ "$__during" =~ ^@\[([a-zA-Z_][a-zA-Z_0-9]*)\] ]] ; then + # Flag unknown variables at this step only. + if [[ ${__abort_on_undefined} == YES ]] ; then + set -u + fi + eval 'printf %s "$'"${BASH_REMATCH[1]}"'"' + if [[ ${__abort_on_undefined} == YES ]] ; then + set +u + fi + # Unrecognized sequences are inserted verbatim. + else + printf '%s' "$__during" + fi + # Continue until we run out of text in this line. + if [[ "$__after" == "$__text" ]] ; then + break + fi + __text="$__after" + done + # Print the corrected text + printf '%s\n' "$__text" + done + + # Restore the calling script's shell options. + eval "$__set_x" + eval "$__set_u" + eval "$__set_e" +} + +function test_atparse { + # Note that these cannot be local since they will be invisible + # to atparse: + testvar='[testvar]' + var1='[var1]' + var2='[var2]' + var4='[var4]' + ( cat<<\EOF ; echo -n "line with no end-of-line character [var4] = @[var4]" ) | atparse var3='**' +Nothing special here. = @['Nothing special here.'] +[testvar] = @[testvar] +[var1] [var2] = @[var1] @[var2] +** = @[var3] +[var4] == @[var4] +@ = @[@] = @['@'] +@[undefined_variable_that_should_exit_script_if_set_minus_u_is_used] +-n + eval "export PE$c=\${PE$c:-0}" = @[' eval "export PE$c=\${PE$c:-0}"'] +EOF + echo " ... this text should be on the same line as the line with no end-of-line character" + echo "After block, \$var3 = \"$var3\" should be empty" +} diff --git a/ush/emcsfc_ice_blend.sh b/ush/emcsfc_ice_blend.sh deleted file mode 100755 index 45fcbc632..000000000 --- a/ush/emcsfc_ice_blend.sh +++ /dev/null @@ -1,186 +0,0 @@ -#!/bin/bash - -#### UNIX Script Documentation Block ################################### -# . . -# Script name: emcsfc_ice_blend.sh -# RFC Contact: George Gayno -# Abstract: This script calls the emcsfc_ice_blend program to create -# a global ice concentation from a blend of National Ice Center IMS data -# and EMC/MMAB 5-minute data. -# -# Script History Log: -# July 2014 Gayno Initial version -# Oct 2014 Gayno The emcsfc_ice_blend program was modified to -# use all grib 2 for i/o. Modify default -# filenames to use 'grib2' extension. -# Aug 2015 Gayno Convert output blended ice file from -# grib 2 to grib 1. Bring up to NCO standards. -# -# Usage: -# Parameters: [no arguments] -# Input Files: -# $IMS_FILE - ims ice cover data (grib 1 or 2) -# $FIVE_MIN_ICE_FILE - 5-minute global ice concentration (grib 2) -# $FIVE_MIN_ICE_MASK_FILE - land/sea mask of $FIVE_MIN_ICE_FILE -# (grib 2) -# Output Files: -# $BLENDED_ICE_FILE - blended ice concentration file. program -# produces grib 2. script converts to -# grib 1 expected by gfs. -# -# Condition codes: -# 0 - normal termination -# non 0 - input data is missing or emcsfc_ice_blend program -# terminated abnormally. -# -# Attributes: -# Language: RedHat Linux -# Machine: NCEP WCOSS -# -######################################################################### - -VERBOSE=${VERBOSE:-"YES"} -if [[ "$VERBOSE" == YES ]]; then - set -x -fi - -#----------------------------------------------------------------------- -# The "startmsg" and "prep_step" utilities are only -# used in ncep ops when the "prod_util" module is loaded. -#----------------------------------------------------------------------- - -use_prod_util=`echo $UTILROOT` -if ((${#use_prod_util} != 0)); then - use_prod_util="true" -else - use_prod_util="false" -fi - -export pgm=emcsfc_ice_blend -if test "$use_prod_util" = "true" ; then - startmsg -fi - -#------------------------------------------------------------------------ -# working directory -#------------------------------------------------------------------------ - -DATA=${DATA:-$PWD} -if [ ! -d $DATA ]; then - mkdir -p $DATA -fi -cd $DATA - -#------------------------------------------------------------------------ -# set up script variables -#------------------------------------------------------------------------ - -# copy output ice blend data to com? -SENDCOM=${SENDCOM:-"NO"} - -PACKAGEROOT=${PACKAGEROOT:-/lfs/h1/ops/prod/packages} -HOMEgfs=${HOMEgfs:-$PACKAGEROOT/gfs.${gfs_ver:?}} -EXECgfs=${EXECgfs:-$HOMEgfs/exec} -FIXgfs=${FIXgfs:-$HOMEgfs/fix} - -# output com directory. -COMOUT=${COMOUT:-$PWD} - -# the input data. ims may be grib1 or grib2. five_min files are grib 2. -IMS_FILE=${IMS_FILE:-"ims.grib2"} -FIVE_MIN_ICE_FILE=${FIVE_MIN_ICE_FILE:-"seaice.5min.grib2"} -FIVE_MIN_ICE_MASK_FILE=${FIVE_MIN_ICE_MASK_FILE:-${FIXgfs}/am/emcsfc_gland5min.grib2} - -# the output ice blend data (grib) -BLENDED_ICE_FILE=${BLENDED_ICE_FILE:-seaice.5min.blend} - -# the program executable -BLENDICEEXEC=${BLENDICEEXEC:-$EXECgfs/emcsfc_ice_blend} - -# standard output file -pgmout=${pgmout:-OUTPUT} - -#------------------------------------------------------------------------ -# Interpolate ims data to ncep grid 173 (the grid used by mmab 5-minute ice data). -# If ims is grib1 format, convert to grib2. If ims data is missing, then -# don't run ice blend program. Copy old blended data to current directory. -#------------------------------------------------------------------------ - -if [ -f "${IMS_FILE}" ] -then - $WGRIB2 -Sec0 ${IMS_FILE} 2>&1 | grep "grib1 message" - status=$? - if (( status == 0 )); then - $CNVGRIB -g12 -p40 ${IMS_FILE} ./ims.grib2 - else - cp ${IMS_FILE} ./ims.grib2 - fi - $WGRIB2 ims.grib2 -match "ICEC" -grib ims.icec.grib2 - grid173="0 0 0 0 0 0 0 0 4320 2160 0 0 89958000 42000 48 -89958000 359958000 83000 83000 0" - $COPYGB2 -x -i3 -g "$grid173" ims.icec.grib2 ims.icec.5min.grib2 -else - echo "WARNING in ${pgm}: IMS ice data missing. Can not run program." - exit 3 -fi - -#------------------------------------------------------------------------ -# Does EMC/MMAB 5-minute ice data exist? If not, don't run ice blend -# program. Copy old blended data to current directory. -#------------------------------------------------------------------------ - -if [ ! -f ${FIVE_MIN_ICE_FILE} ] -then - echo "WARNING in ${pgm}: MMAB ice data missing. Can not run program." - exit 5 -fi - -#------------------------------------------------------------------------ -# Run program to blend data. -#------------------------------------------------------------------------ - -if test "$use_prod_util" = "true" ; then - . prep_step -fi - -# These are input files. -export FORT17="$FIVE_MIN_ICE_MASK_FILE" -export FORT11="ims.icec.5min.grib2" -export FORT15="$FIVE_MIN_ICE_FILE" - -# This is the output blended file -export FORT51="$BLENDED_ICE_FILE" - -$BLENDICEEXEC >> $pgmout 2> errfile -rc=$? - -#------------------------------------------------------------------------ -# Did program run without error? -# -# If no, copy old blended ice file to current directory. -# -# If yes, convert file from grib 2 to grib 1 expected by gfs as -# follows: -# - use wgrib 2 to set corner point longitude to 0.042 degrees -# to prevent round-off error during the cnvgrib step. -# - use cnvgrib to convert from grib2 to grib 1. -# - use copygb to replace bitmap with '1.57' land flag value -# expected by global cycle program. -#------------------------------------------------------------------------ - -if (( rc != 0 )) -then - echo "WARNING: ${pgm} completed abnormally." - exit $rc -else - $WGRIB2 -set_int 3 51 42000 ${BLENDED_ICE_FILE} -grib ${BLENDED_ICE_FILE}.corner - $CNVGRIB -g21 ${BLENDED_ICE_FILE}.corner ${BLENDED_ICE_FILE}.bitmap - rm $BLENDED_ICE_FILE - $COPYGB -M "#1.57" -x ${BLENDED_ICE_FILE}.bitmap $BLENDED_ICE_FILE - echo "${pgm} completed normally." - if [ "$SENDCOM" = "YES" ] ; then - cp $BLENDED_ICE_FILE $COMOUT - fi - rm -f ${BLENDED_ICE_FILE}.corner ${BLENDED_ICE_FILE}.bitmap -fi - -exit 0 diff --git a/ush/emcsfc_snow.sh b/ush/emcsfc_snow.sh deleted file mode 100755 index d86d03cdf..000000000 --- a/ush/emcsfc_snow.sh +++ /dev/null @@ -1,256 +0,0 @@ -#!/bin/bash - -#### UNIX Script Documentation Block ################################### -# . . -# Script name: emcsfc_snow.sh -# RFC Contact: George Gayno -# Abstract: This script calls the emcsfc_snow2mdl program to create a -# model snow analysis from IMS snow cover and AFWA snow depth data. -# -# Script History Log: -# 07/2014 Gayno Initial version -# 12/2014 Gayno Use grib 2 version of snow cover climo file. -# Add $OUTPUT_GRIB2 environment variable to -# control whether model analysis is grib 1 or -# grib 2. -# 08/2015 Gayno Bring up to current NCO standard. -# -# Usage: -# Parameters: < no arguments > -# Input files: -# $GFS_LONSPERLAT_FILE - definition of gfs reduced grid (text) -# $MODEL_SLMASK_FILE - model landmask (grib 1 or 2) -# $MODEL_LATITUDE_FILE - model latitude (grib 1 or 2) -# $MODEL_LONGITUDE_FILE - model longitude (grib 1 or 2) -# $AFWA_GLOBAL_FILE - global afwa snow data (grib 2) -# $IMS_FILE - nh ims snow cover data (grib 2) -# $CLIMO_QC - nh climatological snow cover (grib 2) -# fort.41 - program configuration namelist -# Output files: -# $MODEL_SNOW_FILE - output snow analysis on model grid (grib 1 or 2) -# -# Condition codes: -# 0 - normal termination -# non 0 - indicates missing or corrupt input data -# or a problem in emcsfc_snow2mdl execution. -# -# If a non-zero status occurs, no model snow analysis will be created. -# This is not fatal to the model executation. But any problems should -# be investigated. -# -# Attributes: -# Language: RedHat Linux -# Machine: NCEP WCOSS -# -######################################################################### - -VERBOSE=${VERBOSE:-"YES"} -if [[ "$VERBOSE" == YES ]]; then - set -x -fi - -#----------------------------------------------------------------------- -# The "startmsg" and "prep_step" utilities are only -# used in ncep ops when the "prod_util" module is loaded. -#----------------------------------------------------------------------- - -use_prod_util=`echo $UTILROOT` -if ((${#use_prod_util} != 0)); then - use_prod_util="true" -else - use_prod_util="false" -fi - -export pgm=emcsfc_snow2mdl -if test "$use_prod_util" = "true" ; then - startmsg -fi - -#------------------------------------------------------------------------ -# Path names -#------------------------------------------------------------------------ - -PACKAGEROOT=${PACKAGEROOT:-/lfs/h1/ops/prod/packages} -HOMEgfs=${HOMEgfs:-$PACKAGEROOT/gfs.${gfs_ver:?}} -EXECgfs=${EXECgfs:-$HOMEgfs/exec} -FIXgfs=${FIXgfs:-$HOMEgfs/fix} - -COMOUT=${COMOUT:-$PWD} - -#------------------------------------------------------------------------ -# The snow2mdl executable -#------------------------------------------------------------------------ - -SNOW2MDLEXEC=${SNOW2MDLEXEC:-${EXECgfs}/emcsfc_snow2mdl} - -#------------------------------------------------------------------------ -# Fixed files that describe the model grid: landmask, latitudes/longitudes. -# And for gfs only, the definition of the reduced grid (lonsperlat). -# The lonsperlat file is optional. If not chosen, will create gfs -# snow analysis on the 'full' grid. -#------------------------------------------------------------------------ - -MODEL_SLMASK_FILE=${MODEL_SLMASK_FILE:-global_slmask.t1534.3072.1536.grb} -MODEL_LATITUDE_FILE=${MODEL_LATITUDE_FILE:-global_latitudes.t1534.3072.1536.grb} -MODEL_LONGITUDE_FILE=${MODEL_LONGITUDE_FILE:-global_longitudes.t1534.3072.1536.grb} -GFS_LONSPERLAT_FILE=${GFS_LONSPERLAT_FILE:-global_lonsperlat.t1534.3072.1536.txt} - -#------------------------------------------------------------------------ -# Input snow data. ims snow cover and afwa snow depth. ims is NH only. -# AFWA is global. -#------------------------------------------------------------------------ - -AFWA_GLOBAL_FILE=${AFWA_GLOBAL_FILE:-"snow.usaf.grib2"} -IMS_FILE=${IMS_FILE:-"imssnow96.grb.grib2"} - -#------------------------------------------------------------------------ -# File of snow cover climo used to qc the input snow data -#------------------------------------------------------------------------ - -CLIMO_QC=${CLIMO_QC:-${FIXgfs}/am/emcsfc_snow_cover_climo.grib2} - -#------------------------------------------------------------------------ -# Output snow analysis on model grid -#------------------------------------------------------------------------ - -MODEL_SNOW_FILE=${MODEL_SNOW_FILE:-"snogrb_model"} -OUTPUT_GRIB2=${OUTPUT_GRIB2:-.false.} # grib 1 when false. - -SENDCOM=${SENDCOM:-NO} - -#------------------------------------------------------------------------ -# working directory -#------------------------------------------------------------------------ - -DATA=${DATA:-$(pwd)} -if [ ! -d $DATA ]; then - mkdir -p $DATA -fi -cd $DATA - -#------------------------------------------------------------------------ -# Do a quick check of the ims data to ensure it exists and is -# not corrupt. -#------------------------------------------------------------------------ - -if [[ ! -f $IMS_FILE ]]; then - set +x - echo "WARNING: ${pgm} detects missing ims data. Will not run." - set -x - exit 7 -fi - -#------------------------------------------------------------------------ -# The model analysis time is set to the ims valid time, because the -# ims data has highest priority of all input data. -#------------------------------------------------------------------------ - -$WGRIB2 -d 1 ${IMS_FILE} -status=$? -if (( status != 0 )); then - set +x - echo "WARNING: ${pgm} detects corrupt ims data. Will not run." - set -x - exit 9 -else - tempdate=$($WGRIB2 -t $IMS_FILE | head -1) - IMSDATE=${tempdate#*d=} -fi -IMSDATE10=$(echo $IMSDATE|cut -c1-10) -IMSYEAR=$(echo $IMSDATE10 | cut -c1-4) -IMSMONTH=$(echo $IMSDATE10 | cut -c5-6) -IMSDAY=$(echo $IMSDATE10 | cut -c7-8) -IMSHOUR=0 # emc convention is to use 00Z. - -#------------------------------------------------------------------------ -# Ensure AFWA data exists and is not too old. -#------------------------------------------------------------------------ - -if [[ ! -f $AFWA_GLOBAL_FILE ]]; then - set +x - echo "WARNING: ${pgm} detects missing afwa data. Will not run." - set -x - exit 3 -else - $WGRIB2 -d 1 $AFWA_GLOBAL_FILE - status=$? - if ((status != 0));then - set +x - echo "WARNING: ${pgm} detects corrupt afwa data. Will not run." - set -x - exit $status - else - tempdate=$($WGRIB2 -d 1 -t $AFWA_GLOBAL_FILE) - AFWADATE=${tempdate#*d=} - two_days_ago=$($NDATE -48 $IMSDATE10) - if ((AFWADATE < two_days_ago)); then - set +x - echo "WARNING: ${pgm} detects old afwa data. Will not run." - set -x - exit 4 - fi - fi -fi - -pgmout=${pgmout:-OUTPUT} - -if test "$use_prod_util" = "true" ; then - . prep_step -fi - -rm -f ./fort.41 -cat > ./fort.41 << ! - &source_data - autosnow_file="" - nesdis_snow_file="${IMS_FILE}" - nesdis_lsmask_file="" - afwa_snow_global_file="${AFWA_GLOBAL_FILE}" - afwa_snow_nh_file="" - afwa_snow_sh_file="" - afwa_lsmask_nh_file="" - afwa_lsmask_sh_file="" - / - &qc - climo_qc_file="${CLIMO_QC}" - / - &model_specs - model_lat_file="${MODEL_LATITUDE_FILE}" - model_lon_file="${MODEL_LONGITUDE_FILE}" - model_lsmask_file="${MODEL_SLMASK_FILE}" - gfs_lpl_file="${GFS_LONSPERLAT_FILE}" - / - &output_data - model_snow_file="./${MODEL_SNOW_FILE}" - output_grib2=${OUTPUT_GRIB2} - / - &output_grib_time - grib_year=${IMSYEAR} - grib_month=${IMSMONTH} - grib_day=${IMSDAY} - grib_hour=${IMSHOUR} - / - ¶meters - lat_threshold=55.0 - min_snow_depth=0.05 - snow_cvr_threshold=50.0 - / -! - -eval $SNOW2MDLEXEC >> $pgmout 2> errfile -rc2=$? - -if ((rc2 != 0));then - echo "WARNING: ${pgm} completed abnormally." - exit $rc2 -else - echo "${pgm} completed normally." - if test "$SENDCOM" = "YES" - then - cp $MODEL_SNOW_FILE $COMOUT - rm -f $MODEL_SNOW_FILE - fi -fi - -rm -f ./fort.41 - -exit 0