22
22
# $MODEL_SLMASK_FILE - model landmask (grib 1 or 2)
23
23
# $MODEL_LATITUDE_FILE - model latitude (grib 1 or 2)
24
24
# $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)
27
25
# $AFWA_GLOBAL_FILE - global afwa snow data (grib 2)
28
26
# $IMS_FILE - nh ims snow cover data (grib 2)
29
27
# $CLIMO_QC - nh climatological snow cover (grib 2)
33
31
#
34
32
# Condition codes:
35
33
# 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.
39
36
#
40
37
# If a non-zero status occurs, no model snow analysis will be created.
41
38
# 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
101
98
102
99
# ------------------------------------------------------------------------
103
100
# 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.
106
102
# ------------------------------------------------------------------------
107
103
108
- AFWA_NH_FILE=${AFWA_NH_FILE:- " " }
109
- AFWA_SH_FILE=${AFWA_SH_FILE:- " " }
110
104
AFWA_GLOBAL_FILE=${AFWA_GLOBAL_FILE:- " " }
111
105
IMS_FILE=${IMS_FILE:- " imssnow96.grb.grib2" }
112
106
136
130
cd $DATA
137
131
138
132
# ------------------------------------------------------------------------
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.
143
135
# ------------------------------------------------------------------------
144
136
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
151
142
fi
152
143
153
144
# ------------------------------------------------------------------------
154
145
# The model analysis time is set to the ims valid time, because the
155
146
# ims data has highest priority of all input data.
156
147
# ------------------------------------------------------------------------
157
148
158
- $WGRIB2 -Sec0 ${IMS_FILE} 2>&1 | grep " grib1 message "
149
+ $WGRIB2 -d 1 ${IMS_FILE}
159
150
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
164
157
tempdate=$( $WGRIB2 -t $IMS_FILE | head -1)
165
158
IMSDATE=${tempdate#* d=}
166
159
fi
@@ -170,6 +163,36 @@ IMSMONTH=$(echo $IMSDATE10 | cut -c5-6)
170
163
IMSDAY=$( echo $IMSDATE10 | cut -c7-8)
171
164
IMSHOUR=0 # emc convention is to use 00Z.
172
165
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
+
173
196
pgmout=${pgmout:- OUTPUT}
174
197
175
198
if test " $use_prod_util " = " true" ; then
@@ -183,8 +206,8 @@ cat > ./fort.41 << !
183
206
nesdis_snow_file="${IMS_FILE} "
184
207
nesdis_lsmask_file=""
185
208
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=""
188
211
afwa_lsmask_nh_file=""
189
212
afwa_lsmask_sh_file=""
190
213
/
@@ -217,7 +240,7 @@ cat > ./fort.41 << !
217
240
eval $SNOW2MDLEXEC >> $pgmout 2> errfile
218
241
rc2=$?
219
242
220
- if (( rc2 != 0 )) ; then
243
+ if (( rc2 != 0 )) ; then
221
244
echo " WARNING: ${pgm} completed abnormally."
222
245
exit $rc2
223
246
else
0 commit comments