forked from ufs-community/UFS_UTILS
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexemcsfc_global_sfc_prep.sh
executable file
·279 lines (236 loc) · 9.7 KB
/
exemcsfc_global_sfc_prep.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#!/bin/sh
#### 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_NH_FILE - nh afwa snow data (grib 1)
# $AFWA_SH_FILE - sh afwa snow data (grib 1)
# $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
# path names
export envir=${envir:-"prod"}
export NWROOT=${NWROOT:-"/nw${envir}"}
RUN=${RUN:-"gfs"}
export HOMEgfs=${HOMEgfs:-$NWROOT/gfs.${gfs_ver:?}}
export USHgfs=${USHgfs:-$HOMEgfs/ush}
export FIXgfs=${FIXgfs:-$HOMEgfs/fix}
FIXgfs_am=${FIXgfs_am:-$HOMEgfs/fix/fix_am}
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 1)
export AFWA_NH_FILE=${AFWA_NH_FILE:-"NPR.SNWN.SP.S1200.MESH16"}
export AFWA_SH_FILE=${AFWA_SH_FILE:-"NPR.SNWS.SP.S1200.MESH16"}
# 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