-
Notifications
You must be signed in to change notification settings - Fork 156
/
Copy pathnmm_binary.sh
executable file
·320 lines (273 loc) · 10.4 KB
/
nmm_binary.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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
set -x
# Set analysis date
#adate=$adate_regional_nmm_binary
# Set guess/analysis (i/o) file format. Two
# option are available: binary or netcdf
io_format=binary
##io_format=netcdf
if [[ "$io_format" = "binary" ]]; then
NETCDF=.false.
FORMAT=binary
elif [[ "$io_format" = "netcdf" ]]; then
NETCDF=.true.
FORMAT=netcdf
else
echo "***ERRROR*** INVALID io_format = $io_format"
exit
fi
# Set experiment name
exp=$jobname
# Set path/file for gsi executable
#gsiexec=$updat
# Set resoltion and other dependent parameters
#export JCAP=62
export LEVS=60
export JCAP_B=62
if [[ "$io_format" = "binary" ]]; then
export LEVS=60
elif [[ "$io_format" = "netcdf" ]]; then
export LEVS=45
fi
export DELTIM=1200
# Set runtime and save directories
tmpdir=$tmpdir/tmpreg_nmm_binary/${exp}
savdir=$savdir/outreg/nmm_binary/${exp}
# Specify GSI fixed field and data directories.
fixcrtm=${fixcrtm:-$CRTM_FIX}
# Set variables used in script
# CLEAN up $tmpdir when finished (YES=remove, NO=leave alone)
# ncp is cp replacement, currently keep as /bin/cp
CLEAN=NO
ncp=/bin/cp
# Given the analysis date, compute the date from which the
# first guess comes. Extract cycle and set prefix and suffix
# for guess and observation data files
sdate=`echo $nmm_binary_adate |cut -c1-8`
odate=`$ndate +12 $nmm_binary_adate`
hha=`echo $nmm_binary_adate | cut -c9-10`
hho=`echo $odate | cut -c9-10`
prefixo=ndas.t${hho}z
prefixa=ndas.t${hha}z
suffix=tm12.bufr_d
#datobs=$datobs_nmm_binary/$adate
#datges=$datobs
# Set up $tmpdir
rm -rf $tmpdir
mkdir -p $tmpdir
chgrp rstprod $tmpdir
chmod 750 $tmpdir
cd $tmpdir
rm -rf core*
# CO2 namelist and file decisions
ICO2=${ICO2:-0}
if [ $ICO2 -gt 0 ] ; then
# Copy co2 files to $tmpdir
co2dir=${CO2DIR:-$fixgsi}
yyyy=$(echo ${CDATE:-$nmm_binary_adate}|cut -c1-4)
rm ./global_co2_data.txt
co2=$co2dir/global_co2.gcmscl_$yyyy.txt
if [ -s $co2 ] ; then
$ncp $co2 ./global_co2_data.txt
fi
if [ ! -s ./global_co2_data.txt ] ; then
echo "\./global_co2_data.txt" not created
exit 1
fi
fi
# Make gsi namelist
. $scripts/regression_nl_update.sh
SETUP="$SETUP_update"
GRIDOPTS="$GRIDOPTS_update"
BKGVERR="$BKGVERR_update"
ANBKGERR="$ANBKERR_update"
JCOPTS="$JCOPTS_update"
STRONGOPTS="$STRONGOPTS_update"
OBSQC="$OBSQC_update"
OBSINPUT="$OBSINPUT_update"
SUPERRAD="$SUPERRAD_update"
SINGLEOB="$SINGLEOB_update"
if [ "$debug" = ".false." ]; then
. $scripts/regression_namelists.sh nmm_binary
else
. $scripts/regression_namelists_db.sh nmm_binary
fi
cat << EOF > gsiparm.anl
$gsi_namelist
EOF
# Set fixed files
# berror = forecast model background error statistics
# specoef = CRTM spectral coefficients
# trncoef = CRTM transmittance coefficients
# emiscoef = CRTM coefficients for IR sea surface emissivity model
# aerocoef = CRTM coefficients for aerosol effects
# cldcoef = CRTM coefficients for cloud effects
# satinfo = text file with information about assimilation of brightness temperatures
# cloudyinfo = text file with information about assimilation of cloudy radiance
# satangl = angle dependent bias correction file (fixed in time)
# atmsbeamdat = data required for atms spatial averaging
# pcpinfo = text file with information about assimilation of prepcipitation rates
# ozinfo = text file with information about assimilation of ozone data
# errtable = text file with obs error for conventional data (regional only)
# convinfo = text file with information about assimilation of conventional data
# bufrtable= text file ONLY needed for single obs test (oneobstest=.true.)
# bftab_sst= bufr table for sst ONLY needed for sst retrieval (retrieval=.true.)
anavinfo=$fixgsi/anavinfo_ndas_binary
if [[ "$io_format" = "binary" ]]; then
berror=$fixgsi/$endianness/nam_nmmstat_na.gcv
elif [[ "$io_format" = "netcdf" ]]; then
berror=$fixgsi/$endianness/nam_glb_berror.f77.gcv
fi
emiscoef_IRwater=$fixcrtm/Nalli.IRwater.EmisCoeff.bin
emiscoef_IRice=$fixcrtm/NPOESS.IRice.EmisCoeff.bin
emiscoef_IRland=$fixcrtm/NPOESS.IRland.EmisCoeff.bin
emiscoef_IRsnow=$fixcrtm/NPOESS.IRsnow.EmisCoeff.bin
emiscoef_VISice=$fixcrtm/NPOESS.VISice.EmisCoeff.bin
emiscoef_VISland=$fixcrtm/NPOESS.VISland.EmisCoeff.bin
emiscoef_VISsnow=$fixcrtm/NPOESS.VISsnow.EmisCoeff.bin
emiscoef_VISwater=$fixcrtm/NPOESS.VISwater.EmisCoeff.bin
emiscoef_MWwater=$fixcrtm/FASTEM6.MWwater.EmisCoeff.bin
aercoef=$fixcrtm/AerosolCoeff.bin
cldcoef=$fixcrtm/CloudCoeff.bin
satinfo=$fixgsi/nam_regional_satinfo.txt
cloudyinfo=$fixgsi/cloudy_radiance_info.txt
scaninfo=$fixgsi/global_scaninfo.txt
satangl=$fixgsi/nam_global_satangbias.txt
atmsbeamdat=$fixgsi/atms_beamwidth.txt
pcpinfo=$fixgsi/nam_global_pcpinfo.txt
ozinfo=$fixgsi/nam_global_ozinfo.txt
errtable=$fixgsi/nam_errtable.r3dv
convinfo=$fixgsi/nam_regional_convinfo_reg_test.txt
### add 9 tables
errtable_pw=$fixgsi/prepobs_errtable_pw.global
errtable_ps=$fixgsi/prepobs_errtable_ps.global_nqcf
errtable_t=$fixgsi/prepobs_errtable_t.global_nqcf
errtable_q=$fixgsi/prepobs_errtable_q.global_nqcf
errtable_uv=$fixgsi/prepobs_errtable_uv.global_nqcf
btable_ps=$fixgsi/nqc_b_ps.global_nqcf
btable_t=$fixgsi/nqc_b_t.global_nqcf
btable_q=$fixgsi/nqc_b_q.global_nqcf
btable_uv=$fixgsi/nqc_b_uv.global_nqcf
###
mesonetuselist=$fixgsi/nam_mesonet_uselist.txt
# Only need this file for single obs test
bufrtable=$fixgsi/prepobs_prep.bufrtable
# Only need this file for sst retrieval
bftab_sst=$fixgsi/bufrtab.012
# Copy executable and fixed files to $tmpdir
if [[ $exp == *"updat"* ]]; then
$ncp $gsiexec_updat ./gsi.x
elif [[ $exp == *"contrl"* ]]; then
$ncp $gsiexec_contrl ./gsi.x
fi
$ncp $anavinfo ./anavinfo
$ncp $berror ./berror_stats
$ncp $emiscoef_IRwater ./Nalli.IRwater.EmisCoeff.bin
$ncp $emiscoef_IRice ./NPOESS.IRice.EmisCoeff.bin
$ncp $emiscoef_IRsnow ./NPOESS.IRsnow.EmisCoeff.bin
$ncp $emiscoef_IRland ./NPOESS.IRland.EmisCoeff.bin
$ncp $emiscoef_VISice ./NPOESS.VISice.EmisCoeff.bin
$ncp $emiscoef_VISland ./NPOESS.VISland.EmisCoeff.bin
$ncp $emiscoef_VISsnow ./NPOESS.VISsnow.EmisCoeff.bin
$ncp $emiscoef_VISwater ./NPOESS.VISwater.EmisCoeff.bin
$ncp $emiscoef_MWwater ./FASTEM6.MWwater.EmisCoeff.bin
$ncp $aercoef ./AerosolCoeff.bin
$ncp $cldcoef ./CloudCoeff.bin
$ncp $satangl ./satbias_angle
$ncp $atmsbeamdat ./atms_beamwidth.txt
$ncp $satinfo ./satinfo
$ncp $cloudyinfo ./cloudy_radiance_info.txt
$ncp $scaninfo ./scaninfo
$ncp $pcpinfo ./pcpinfo
$ncp $ozinfo ./ozinfo
$ncp $convinfo ./convinfo
$ncp $errtable ./errtable
$ncp $mesonetuselist ./mesonetuselist
####
#add 9 tables for new varqc
$ncp $errtable_pw ./errtable_pw
$ncp $errtable_ps ./errtable_ps
$ncp $errtable_t ./errtable_t
$ncp $errtable_q ./errtable_q
$ncp $errtable_uv ./errtable_uv
$ncp $btable_ps ./btable_ps
$ncp $btable_t ./btable_t
$ncp $btable_q ./btable_q
$ncp $btable_uv ./btable_uv
$ncp $bufrtable ./prepobs_prep.bufrtable
$ncp $bftab_sst ./bftab_sstphr
# Copy CRTM coefficient files based on entries in satinfo file
for file in `awk '{if($1!~"!"){print $1}}' ./satinfo | sort | uniq` ;do
$ncp $fixcrtm/${file}.SpcCoeff.bin ./
$ncp $fixcrtm/${file}.TauCoeff.bin ./
done
# Copy observational data to $tmpdir
$ncp $nmm_binary_obs/${prefixo}.prepbufr.tm12 ./prepbufr
$ncp $nmm_binary_obs/${prefixo}.satwnd.$suffix ./satwndbufr
$ncp $nmm_binary_obs/${prefixo}.gpsro.$suffix ./gpsrobufr
$ncp $nmm_binary_obs/${prefixo}.1bhrs3.$suffix ./hirs3bufr
$ncp $nmm_binary_obs/${prefixo}.1bhrs4.$suffix ./hirs4bufr
$ncp $nmm_binary_obs/${prefixo}.1bamua.$suffix ./amsuabufr
$ncp $nmm_binary_obs/${prefixo}.1bamub.$suffix ./amsubbufr
$ncp $nmm_binary_obs/${prefixo}.1bmhs.$suffix ./mhsbufr
$ncp $nmm_binary_obs/${prefixo}.goesfv.$suffix ./gsnd1bufr
$ncp $nmm_binary_obs/${prefixo}.airsev.$suffix ./airsbufr
$ncp $nmm_binary_obs/${prefixo}.radwnd.$suffix ./radarbufr
$ncp $nmm_binary_obs/${prefixo}.nexrad.$suffix ./l2rwbufr
# Copy bias correction, sigma, and surface files
#
# *** NOTE: The regional gsi analysis is written to (over)
# the input guess field file (wrf_inout)
#
$ncp $nmm_binary_obs/${prefixo}.satbias.tm12 ./satbias_in
$ncp $nmm_binary_obs/${prefixo}.satang.tm12 ./satbias_angle
if [[ "$io_format" = "binary" ]]; then
$ncp $nmm_binary_ges/${prefixo}.wrfinput_d01.init ./wrf_inout
elif [[ "$io_format" = "netcdf" ]]; then
$ncp $nmm_binary_ges/wrfinput_d01_nmm_netcdf ./wrf_inout
fi
cp wrf_inout wrf_ges
# Run GSI
cd $tmpdir
echo "run gsi now"
eval "$APRUN $tmpdir/gsi.x > stdout 2>&1"
rc=$?
exit $rc
# Save output
mkdir -p $savdir
chgrp rstprod $savdir
chmod 750 $savdir
cat stdout fort.2* > $savdir/stdout.anl.${nmm_binary_adate}
$ncp wrf_inout $savdir/wrfanl.${nmm_binary_adate}
$ncp satbias_out $savdir/biascr.${nmm_binary_adate}
# If desired, copy guess file to unique filename in $savdir
$ncp wrf_ges $savdir/wrfges.${nmm_binary_adate}
# Loop over first and last outer loops to generate innovation
# diagnostic files for indicated observation types (groups)
#
# NOTE: Since we set miter=2 in GSI namelist SETUP, outer
# loop 03 will contain innovations with respect to
# the analysis. Creation of o-a innovation files
# is triggered by write_diag(3)=.true. The setting
# write_diag(1)=.true. turns on creation of o-g
# innovation files.
#
cd $tmpdir
loops="01 03"
for loop in $loops; do
case $loop in
01) string=ges;;
03) string=anl;;
*) string=$loop;;
esac
# Collect diagnostic files for obs types (groups) below
listall="hirs2_n14 msu_n14 sndr_g08 sndr_g10 sndr_g12 sndr_g08_prep sndr_g10_prep sndr_g12_prep sndrd1_g08 sndrd2_g08 sndrd3_g08 sndrd4_g08 sndrd1_g10 sndrd2_g10 sndrd3_g10 sndrd4_g10 sndrd1_g12 sndrd2_g12 sndrd3_g12 sndrd4_g12 sndrd1_g11 sndrd2_g11 sndrd3_g11 sndrd4_g11 sndrd1_g13 sndrd2_g13 sndrd3_g13 sndrd4_g13 hirs3_n15 hirs3_n16 hirs3_n17 amsua_n15 amsua_n16 amsua_n17 amsub_n15 amsub_n16 amsub_n17 hsb_aqua airs_aqua amsua_aqua imgr_g08 imgr_g10 imgr_g12 pcp_ssmi_dmsp pcp_tmi_trmm conv sbuv2_n16 sbuv2_n17 sbuv2_n18 omi_aura ssmi_f13 ssmi_f15 hirs4_n18 amsua_n18 mhs_n18 amsre_low_aqua amsre_mid_aqua amsre_hig_aqua ssmis_las_f16 ssmis_uas_f16 ssmis_img_f16 ssmis_env_f16 iasi_metop-a"
for type in $listall; do
count=`ls dir.*/${type}_${loop}* | wc -l`
if [[ $count -gt 0 ]]; then
cat dir.*/${type}_${loop}* > diag_${type}_${string}.${nmm_binary_adate}
compress diag_${type}_${string}.${nmm_binary_adate}
$ncp diag_${type}_${string}.${nmm_binary_adate}.Z $savdir/
fi
done
done
exit