-
Notifications
You must be signed in to change notification settings - Fork 176
/
Copy pathexgfs_atmos_postsnd.sh
executable file
·170 lines (145 loc) · 4.55 KB
/
exgfs_atmos_postsnd.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
#! /usr/bin/env bash
################################################################
# Script Name: exgfs_atmos_postsnd.sh.sms
# Script Description: Generate GFS BUFR sounding files
# Script History Log:
# 1) 2003-03-25 Hualu Pan First Implementation
# 2) 2010-05-25 V. Krishna Kumar Modified for the GFS
# resolution upgrade
# 3) 2014-08-01 D. Carlis Updated to vertical structure
# and T1534 Resolution
# 4) 2016-11-01 H. Chuang Update to read new model nems output
# 5) 2017-02-21 Guang Ping Lou setup mpmd to speedup the run
# and 1 & 3 hourly output
# 6) 2018-03-22 Guang Ping Lou Take FV3GFS configuration
# parameters as input; make it work for
# both FV3GFS and GFS
# 7) 2018-07-18 Guang Ping Lou Generalize this version to other platforms
# 8) 2019-10-18 Guang Ping Lou Transition to reading in NetCDF model data
# 9) 2019-12-18 Guang Ping Lou generalizing to reading in NetCDF or nemsio
################################################################
source "$HOMEgfs/ush/preamble.sh"
cd $DATA
########################################
###################################################
## Run meteogram generator for T574
###################################################
export LEVS=${LEVS:-127}
export STARTHOUR=${STARTHOUR:-00}
export ENDHOUR=${ENDHOUR:-180}
export INCREMENT=12
export MAKEBUFR=NO
export F00FLAG=YES
export fformat=${OUTPUT_FILE:-netcdf}
if [ $fformat == "netcdf" ]
then
export atmfm="nc"
export logfm="txt"
else
export atmfm="nemsio"
export logfm="nemsio"
fi
export NINT1=${FHOUT_HF_GFS:-1}
export NEND1=${FHMAX_HF_GFS:-120}
export NINT3=${FHOUT_GFS:-3}
rm -f -r ${COMOUT}/bufr.${cycle}
mkdir -p ${COMOUT}/bufr.${cycle}
if [ -f $HOMEgfs/ush/getncdimlen ]
then
GETDIM=$HOMEgfs/ush/getncdimlen
else
GETDIM=$EXECbufrsnd/getncdimlen
fi
if [ $fformat == "netcdf" ]
then
export LEVS=$($GETDIM $COMIN/${RUN}.${cycle}.atmf000.${atmfm} pfull)
else
# Extract number of vertical levels from $STARTHOUR atmospheric file
export NEMSIOGET=${NEMSIOGET:-$EXECbufrsnd/nemsio_get}
fhr3=$(printf %03i $STARTHOUR)
ATMFCS=$COMIN/${RUN}.${cycle}.atmf${fhr3}.nemsio
export LEVS=$($NEMSIOGET $ATMFCS dimz | awk '{print $2}')
fi
### Loop for the hour and wait for the sigma and surface flux file:
export FSTART=$STARTHOUR
#
while [ $FSTART -lt $ENDHOUR ]
do
export FINT=$NINT1
# Define the end hour for the input
export FEND=$(expr $FSTART + $INCREMENT)
if test $FEND -lt 100; then FEND=0$FEND; fi
if [ $FSTART -eq 00 ]
then
export F00FLAG=YES
else
export F00FLAG=NO
fi
if [ $FEND -eq $ENDHOUR ]
then
export MAKEBUFR=YES
fi
ic=0
while [ $ic -lt 1000 ]
do
if [ ! -f $COMIN/${RUN}.${cycle}.logf$FEND.${logfm} ]
then
sleep 10
ic=$(expr $ic + 1)
else
break
fi
if [ $ic -ge 360 ]
then
err_exit "COULD NOT LOCATE logf$FEND file AFTER 1 HOUR"
fi
done
## 1-hourly output before $NEND1, 3-hourly output after
if [ $FEND -gt $NEND1 ]; then
export FINT=$NINT3
fi
## $USHbufrsnd/gfs_bufr.sh
$USHbufrsnd/gfs_bufr.sh
export FSTART=$FEND
done
##############################################################
# Tar and gzip the individual bufr files and send them to /com
##############################################################
cd ${COMOUT}/bufr.${cycle}
tar -cf - . | /usr/bin/gzip > ../${RUN}.${cycle}.bufrsnd.tar.gz
cd $DATA
########################################
# Send the single tar file to OSO
########################################
if test "$SENDDBN" = 'YES'
then
$DBNROOT/bin/dbn_alert MODEL GFS_BUFRSND_TAR $job \
$COMOUT/${RUN}.${cycle}.bufrsnd.tar.gz
fi
########################################
# Create Regional Collectives of BUFR data and
# add appropriate WMO Headers.
########################################
collect=' 1 2 3 4 5 6 7 8 9'
if [ $machine == "HERA" -o $machine == "JET" ]; then
for m in ${collect}
do
sh $USHbufrsnd/gfs_sndp.sh $m
done
################################################
# Convert the bufr soundings into GEMPAK files
################################################
sh $USHbufrsnd/gfs_bfr2gpk.sh
else
rm -rf poe_col
for m in ${collect}
do
echo "sh $USHbufrsnd/gfs_sndp.sh $m " >> poe_col
done
mv poe_col cmdfile
cat cmdfile
chmod +x cmdfile
${APRUN_POSTSNDCFP} cmdfile
sh $USHbufrsnd/gfs_bfr2gpk.sh
fi
############## END OF SCRIPT #######################