Skip to content

Commit 0557212

Browse files
Update exemcsfc_global_sfc_prep.sh and emcsfc_snow.sh based
on NCO comments. Fixes #973.
1 parent 85afb0c commit 0557212

File tree

2 files changed

+56
-35
lines changed

2 files changed

+56
-35
lines changed

scripts/exemcsfc_global_sfc_prep.sh

+6-8
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
# /nwprod/gfs.vX.Y.Z/ush/emcsfc_ice_blend.sh (create global ice blend)
2626
# /nwprod/gfs.vX.Y.Z/ush/emcsfc_snow.sh (create model snow analysis)
2727
# Input Files:
28-
# $AFWA_NH_FILE - nh afwa snow data (grib 1)
29-
# $AFWA_SH_FILE - sh afwa snow data (grib 1)
28+
# $AFWA_GLOBAL_FILE - afwa snow data (grib 2)
3029
# $IMS_FILE - nh ims snow cover and ice data (grib 2)
3130
# $FIVE_MIN_ICE_FILE - global 5-minute ice concentration (grib 2)
3231
# $FIVE_MIN_ICE_MASK_FILE - corresponding land/sea mask for $FIVE_MIN_ICE_FILE
@@ -77,7 +76,7 @@ export EXECgfs=${EXECgfs:-$HOMEgfs/exec}
7776

7877
# output com directory.
7978
export COMOUT=${COMOUT:-$PWD}
80-
export COMINgfs_m6hrs=${COMINgfs_m6hrs:-$PWD}
79+
export COMIN_m6hrs=${COMIN_m6hrs:-$PWD}
8180

8281
# working directory
8382
export DATA=${DATA:-$PWD}
@@ -105,9 +104,8 @@ fi
105104
# the input data for emcsfc_ice_blend and emcsfc_snow2mdl programs.
106105
#-----------------------------------------------------------------------
107106

108-
# afwa snow depth data (grib 1)
109-
export AFWA_NH_FILE=${AFWA_NH_FILE:-"NPR.SNWN.SP.S1200.MESH16"}
110-
export AFWA_SH_FILE=${AFWA_SH_FILE:-"NPR.SNWS.SP.S1200.MESH16"}
107+
# afwa snow depth data (grib 2)
108+
export AFWA_GLOBAL_FILE=${AFWA_GLOBAL_FILE:-"snow.usaf.grib2"}
111109

112110
# ims snow cover and ice cover data (grib 1 or grib 2)
113111
export IMS_FILE=${IMS_FILE:-"ims.grib2"}
@@ -187,7 +185,7 @@ export MODEL_LATITUDE_FILE=${MDL_LATS:-$FIXgfs_am/global_latitudes.t${resolution
187185
export MODEL_LONGITUDE_FILE=${MDL_LONS:-$FIXgfs_am/global_longitudes.t${resolution}.grb}
188186
export GFS_LONSPERLAT_FILE=${LONSPERLAT:-$FIXgfs_am/global_lonsperlat.t${resolution}.txt}
189187
export MODEL_SNOW_FILE=${FNSNOAJCAP:-${RUN}.${cycle}.snogrb_t${resolution}}
190-
export MODEL_SNOW_FILE_m6hrs=${FNSNOGJCAP:-${COMINgfs_m6hrs}/${RUN}.${cycle_m6hrs}.snogrb_t${resolution}}
188+
export MODEL_SNOW_FILE_m6hrs=${FNSNOGJCAP:-${COMIN_m6hrs}/${RUN}.${cycle_m6hrs}.snogrb_t${resolution}}
191189

192190
echo "Create ${JCAP} snow data."
193191

@@ -245,7 +243,7 @@ export MODEL_LATITUDE_FILE=${MDL_LATS_ENKF:-$FIXgfs_am/global_latitudes.t${resol
245243
export MODEL_LONGITUDE_FILE=${MDL_LONS_ENKF:-$FIXgfs_am/global_longitudes.t${resolution}.grb}
246244
export GFS_LONSPERLAT_FILE=${LONSPERLAT_ENKF:-$FIXgfs_am/global_lonsperlat.t${resolution}.txt}
247245
export MODEL_SNOW_FILE=${FNSNOAJCAP_ENKF:-${RUN}.${cycle}.snogrb_t${resolution}}
248-
export MODEL_SNOW_FILE_m6hrs=${FNSNOGJCAP_ENKF:-${COMINgfs_m6hrs}/${RUN}.${cycle_m6hrs}.snogrb_t${resolution}}
246+
export MODEL_SNOW_FILE_m6hrs=${FNSNOGJCAP_ENKF:-${COMIN_m6hrs}/${RUN}.${cycle_m6hrs}.snogrb_t${resolution}}
249247

250248
echo "Create enkf snow data."
251249

ush/emcsfc_snow.sh

+50-27
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
# $MODEL_SLMASK_FILE - model landmask (grib 1 or 2)
2323
# $MODEL_LATITUDE_FILE - model latitude (grib 1 or 2)
2424
# $MODEL_LONGITUDE_FILE - model longitude (grib 1 or 2)
25-
# $AFWA_NH_FILE - nh afwa snow data (grib 1)
26-
# $AFWA_SH_FILE - sh afwa snow data (grib 1)
2725
# $AFWA_GLOBAL_FILE - global afwa snow data (grib 2)
2826
# $IMS_FILE - nh ims snow cover data (grib 2)
2927
# $CLIMO_QC - nh climatological snow cover (grib 2)
@@ -33,9 +31,8 @@
3331
#
3432
# Condition codes:
3533
# 0 - normal termination
36-
# $rc1 - non-zero status indicates corrupt ims data.
37-
# $rc2 - non-zero status indicates a problem in emcsfc_snow2mdl execution.
38-
# see source code for details - /nwprod/gfs.vX.Y.Z/sorc/emcsfc_snow2mdl.fd
34+
# non 0 - indicates missing or corrupt input data
35+
# or a problem in emcsfc_snow2mdl execution.
3936
#
4037
# If a non-zero status occurs, no model snow analysis will be created.
4138
# This is not fatal to the model executation. But any problems should
@@ -101,12 +98,9 @@ GFS_LONSPERLAT_FILE=${GFS_LONSPERLAT_FILE:-global_lonsperlat.t1534.3072.1536.txt
10198

10299
#------------------------------------------------------------------------
103100
# Input snow data. ims snow cover and afwa snow depth. ims is NH only.
104-
# In OPS, we run with ims only, or ims and afwa. afwa data is too
105-
# unreliable to use on its own. ims is grib2. afwa is grib1.
101+
# AFWA is global.
106102
#------------------------------------------------------------------------
107103

108-
AFWA_NH_FILE=${AFWA_NH_FILE:-""}
109-
AFWA_SH_FILE=${AFWA_SH_FILE:-""}
110104
AFWA_GLOBAL_FILE=${AFWA_GLOBAL_FILE:-""}
111105
IMS_FILE=${IMS_FILE:-"imssnow96.grb.grib2"}
112106

@@ -136,31 +130,30 @@ fi
136130
cd $DATA
137131

138132
#------------------------------------------------------------------------
139-
# Do a quick check of the ims data to ensure it is not corrupt.
140-
# WGRIB2 works for a grib 1 or grib 2 file. If IMS is bad,
141-
# don't run emcsfc_snow2mdl program because afwa data alone is
142-
# unreliable.
133+
# Do a quick check of the ims data to ensure it exists and is
134+
# not corrupt.
143135
#------------------------------------------------------------------------
144136

145-
$WGRIB2 ${IMS_FILE}
146-
rc1=$?
147-
148-
if ((rc1 != 0));then
149-
echo "WARNING: ${pgm} detects corrupt IMS data. Can not run."
150-
exit $rc1
137+
if [[ ! -f $IMS_FILE ]]; then
138+
set +x
139+
echo "WARNING: ${pgm} detects missing ims data. Will not run."
140+
set -x
141+
exit 7
151142
fi
152143

153144
#------------------------------------------------------------------------
154145
# The model analysis time is set to the ims valid time, because the
155146
# ims data has highest priority of all input data.
156147
#------------------------------------------------------------------------
157148

158-
$WGRIB2 -Sec0 ${IMS_FILE} 2>&1 | grep "grib1 message"
149+
$WGRIB2 -d 1 ${IMS_FILE}
159150
status=$?
160-
if (( status == 0 )); then # grib 1 file
161-
tempdate=$($WGRIB -v $IMS_FILE | head -1)
162-
IMSDATE=${tempdate#*D=}
163-
else # grib 2 file
151+
if (( status != 0 )); then
152+
set +x
153+
echo "WARNING: ${pgm} detects corrupt ims data. Will not run."
154+
set -x
155+
exit 9
156+
else
164157
tempdate=$($WGRIB2 -t $IMS_FILE | head -1)
165158
IMSDATE=${tempdate#*d=}
166159
fi
@@ -170,6 +163,36 @@ IMSMONTH=$(echo $IMSDATE10 | cut -c5-6)
170163
IMSDAY=$(echo $IMSDATE10 | cut -c7-8)
171164
IMSHOUR=0 # emc convention is to use 00Z.
172165

166+
#------------------------------------------------------------------------
167+
# Ensure AFWA data exists and is not too old.
168+
#------------------------------------------------------------------------
169+
170+
if [[ ! -f $AFWA_GLOBAL_FILE ]]; then
171+
set +x
172+
echo "WARNING: ${pgm} detects missing afwa data. Will not run."
173+
set -x
174+
exit 3
175+
else
176+
$WGRIB2 -d 1 $AFWA_GLOBAL_FILE
177+
status=$?
178+
if ((status != 0));then
179+
set +x
180+
echo "WARNING: ${pgm} detects corrupt afwa data. Will not run."
181+
set -x
182+
exit $status
183+
else
184+
tempdate=$($WGRIB2 -d 1 -t $AFWA_GLOBAL_FILE)
185+
AFWADATE=${tempdate#*d=}
186+
two_days_ago=$($NDATE -48 $IMSDATE10)
187+
if ((AFWADATE < two_days_ago)); then
188+
set +x
189+
echo "WARNING: ${pgm} detects old afwa data. Will not run."
190+
set -x
191+
exit 4
192+
fi
193+
fi
194+
fi
195+
173196
pgmout=${pgmout:-OUTPUT}
174197

175198
if test "$use_prod_util" = "true" ; then
@@ -183,8 +206,8 @@ cat > ./fort.41 << !
183206
nesdis_snow_file="${IMS_FILE}"
184207
nesdis_lsmask_file=""
185208
afwa_snow_global_file="${AFWA_GLOBAL_FILE}"
186-
afwa_snow_nh_file="${AFWA_NH_FILE}"
187-
afwa_snow_sh_file="${AFWA_SH_FILE}"
209+
afwa_snow_nh_file=""
210+
afwa_snow_sh_file=""
188211
afwa_lsmask_nh_file=""
189212
afwa_lsmask_sh_file=""
190213
/
@@ -217,7 +240,7 @@ cat > ./fort.41 << !
217240
eval $SNOW2MDLEXEC >> $pgmout 2> errfile
218241
rc2=$?
219242

220-
if ((rc2!= 0));then
243+
if ((rc2 != 0));then
221244
echo "WARNING: ${pgm} completed abnormally."
222245
exit $rc2
223246
else

0 commit comments

Comments
 (0)