-
Notifications
You must be signed in to change notification settings - Fork 177
/
Copy pathexglobal_atmos_sfcanl.sh
executable file
·221 lines (177 loc) · 6.6 KB
/
exglobal_atmos_sfcanl.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
#! /usr/bin/env bash
################################################################################
#### UNIX Script Documentation Block
# . .
# Script name: exglobal_atmos_sfcanl.sh
# Script description: Makes global model surface analysis files
#
# Author: Russ Treadon Org: NCEP/EMC Date: 2021-12-13
#
# Abstract: This script makes global model surface analysis files
#
# $Id$
#
# Attributes:
# Language: POSIX shell
#
################################################################################
# Set environment.
source "$HOMEgfs/ush/preamble.sh"
# Directories.
pwd=$(pwd)
# Base variables
CDATE=${CDATE:-"2001010100"}
CDUMP=${CDUMP:-"gdas"}
GDUMP=${GDUMP:-"gdas"}
# Derived base variables
GDATE=$($NDATE -$assim_freq $CDATE)
BDATE=$($NDATE -3 $CDATE)
PDY=$(echo $CDATE | cut -c1-8)
cyc=$(echo $CDATE | cut -c9-10)
bPDY=$(echo $BDATE | cut -c1-8)
bcyc=$(echo $BDATE | cut -c9-10)
# Utilities
export NCP=${NCP:-"/bin/cp"}
export NMV=${NMV:-"/bin/mv"}
export NLN=${NLN:-"/bin/ln -sf"}
export CHGRP_CMD=${CHGRP_CMD:-"chgrp ${group_name:-rstprod}"}
export NEMSIOGET=${NEMSIOGET:-${NWPROD}/exec/nemsio_get}
export NCLEN=${NCLEN:-$HOMEgfs/ush/getncdimlen}
COMPRESS=${COMPRESS:-gzip}
UNCOMPRESS=${UNCOMPRESS:-gunzip}
APRUNCFP=${APRUNCFP:-""}
# IAU
DOIAU=${DOIAU:-"NO"}
export IAUFHRS=${IAUFHRS:-"6"}
# Surface cycle related parameters
CYCLESH=${CYCLESH:-$HOMEgfs/ush/global_cycle.sh}
export CYCLEXEC=${CYCLEXEC:-$HOMEgfs/exec/global_cycle}
NTHREADS_CYCLE=${NTHREADS_CYCLE:-24}
APRUN_CYCLE=${APRUN_CYCLE:-${APRUN:-""}}
export SNOW_NUDGE_COEFF=${SNOW_NUDGE_COEFF:-'-2.'}
export CYCLVARS=${CYCLVARS:-""}
export FHOUR=${FHOUR:-0}
export DELTSFC=${DELTSFC:-6}
export FIXgsm=${FIXgsm:-$HOMEgfs/fix/am}
export FIXfv3=${FIXfv3:-$HOMEgfs/fix/orog}
# FV3 specific info (required for global_cycle)
export CASE=${CASE:-"C384"}
ntiles=${ntiles:-6}
# IAU
DOIAU=${DOIAU:-"NO"}
export IAUFHRS=${IAUFHRS:-"6"}
# Dependent Scripts and Executables
export NTHREADS_CALCINC=${NTHREADS_CALCINC:-1}
export APRUN_CALCINC=${APRUN_CALCINC:-${APRUN:-""}}
export APRUN_CALCANL=${APRUN_CALCANL:-${APRUN:-""}}
export APRUN_CHGRES=${APRUN_CALCANL:-${APRUN:-""}}
export CALCANLEXEC=${CALCANLEXEC:-$HOMEgfs/exec/calc_analysis.x}
export CHGRESNCEXEC=${CHGRESNCEXEC:-$HOMEgfs/exec/enkf_chgres_recenter_nc.x}
export CHGRESINCEXEC=${CHGRESINCEXEC:-$HOMEgfs/exec/interp_inc.x}
export NTHREADS_CHGRES=${NTHREADS_CHGRES:-1}
CALCINCPY=${CALCINCPY:-$HOMEgfs/ush/calcinc_gfs.py}
CALCANLPY=${CALCANLPY:-$HOMEgfs/ush/calcanl_gfs.py}
export APRUN_CHGRES=${APRUN_CALCANL:-${APRUN:-""}}
CHGRESEXEC=${CHGRESEXEC:-$HOMEgfs/exec/enkf_chgres_recenter.x}
# OPS flags
RUN=${RUN:-""}
SENDECF=${SENDECF:-"NO"}
SENDDBN=${SENDDBN:-"NO"}
RUN_GETGES=${RUN_GETGES:-"NO"}
GETGESSH=${GETGESSH:-"getges.sh"}
export gesenvir=${gesenvir:-$envir}
# Observations
OPREFIX=${OPREFIX:-""}
OSUFFIX=${OSUFFIX:-""}
# Guess files
GPREFIX=${GPREFIX:-""}
# Analysis files
export APREFIX=${APREFIX:-""}
DTFANL=${DTFANL:-${COMOUT}/${APREFIX}dtfanl.nc}
# Get dimension information based on CASE
res=$(echo $CASE | cut -c2-)
JCAP_CASE=$((res*2-2))
LATB_CASE=$((res*2))
LONB_CASE=$((res*4))
################################################################################
# Preprocessing
mkdata=NO
if [ ! -d $DATA ]; then
mkdata=YES
mkdir -p $DATA
fi
cd $DATA || exit 99
if [ $DONST = "YES" ]; then
export NSSTBF="${COMOUT}/${OPREFIX}nsstbufr"
$NLN $NSSTBF nsstbufr
fi
##############################################################
# Required model guess files
##############################################################
# Output files
if [ $DONST = "YES" ]; then
$NLN $DTFANL dtfanl
fi
##############################################################
# Update surface fields in the FV3 restart's using global_cycle
mkdir -p $COMOUT/RESTART
# Global cycle requires these files
export FNTSFA=${FNTSFA:-$COMIN_OBS/${OPREFIX}rtgssthr.grb}
export FNACNA=${FNACNA:-$COMIN_OBS/${OPREFIX}seaice.5min.blend.grb}
export FNSNOA=${FNSNOA:-$COMIN_OBS/${OPREFIX}snogrb_t${JCAP_CASE}.${LONB_CASE}.${LATB_CASE}}
[[ ! -f $FNSNOA ]] && export FNSNOA="$COMIN_OBS/${OPREFIX}snogrb_t1534.3072.1536"
FNSNOG=${FNSNOG:-$COMIN_GES_OBS/${GPREFIX}snogrb_t${JCAP_CASE}.${LONB_CASE}.${LATB_CASE}}
[[ ! -f $FNSNOG ]] && FNSNOG="$COMIN_GES_OBS/${GPREFIX}snogrb_t1534.3072.1536"
# Set CYCLVARS by checking grib date of current snogrb vs that of prev cycle
if [ $RUN_GETGES = "YES" ]; then
snoprv=$($GETGESSH -q -t snogrb_$JCAP_CASE -e $gesenvir -n $GDUMP -v $GDATE)
else
snoprv=${snoprv:-$FNSNOG}
fi
if [ $($WGRIB -4yr $FNSNOA 2>/dev/null | grep -i snowc | awk -F: '{print $3}' | awk -F= '{print $2}') -le \
$($WGRIB -4yr $snoprv 2>/dev/null | grep -i snowc | awk -F: '{print $3}' | awk -F= '{print $2}') ] ; then
export FNSNOA=" "
export CYCLVARS="FSNOL=99999.,FSNOS=99999.,"
else
export SNOW_NUDGE_COEFF=${SNOW_NUDGE_COEFF:-0.}
export CYCLVARS="FSNOL=${SNOW_NUDGE_COEFF},$CYCLVARS"
fi
if [ $DONST = "YES" ]; then
export NST_FILE=${GSI_FILE:-$COMOUT/${APREFIX}dtfanl.nc}
else
export NST_FILE="NULL"
fi
if [ $DOIAU = "YES" ]; then
# update surface restarts at the beginning of the window, if IAU
# For now assume/hold dtfanl.nc valid at beginning of window
for n in $(seq 1 $ntiles); do
$NLN $COMIN_GES/RESTART/$bPDY.${bcyc}0000.sfc_data.tile${n}.nc $DATA/fnbgsi.00$n
$NLN $COMOUT/RESTART/$bPDY.${bcyc}0000.sfcanl_data.tile${n}.nc $DATA/fnbgso.00$n
$NLN $FIXfv3/$CASE/${CASE}_grid.tile${n}.nc $DATA/fngrid.00$n
$NLN $FIXfv3/$CASE/${CASE}_oro_data.tile${n}.nc $DATA/fnorog.00$n
done
export APRUNCY=$APRUN_CYCLE
export OMP_NUM_THREADS_CY=$NTHREADS_CYCLE
export MAX_TASKS_CY=$ntiles
$CYCLESH
export err=$?; err_chk
fi
# Update surface restarts at middle of window
for n in $(seq 1 $ntiles); do
$NLN $COMIN_GES/RESTART/$PDY.${cyc}0000.sfc_data.tile${n}.nc $DATA/fnbgsi.00$n
$NLN $COMOUT/RESTART/$PDY.${cyc}0000.sfcanl_data.tile${n}.nc $DATA/fnbgso.00$n
$NLN $FIXfv3/$CASE/${CASE}_grid.tile${n}.nc $DATA/fngrid.00$n
$NLN $FIXfv3/$CASE/${CASE}_oro_data.tile${n}.nc $DATA/fnorog.00$n
done
export APRUNCY=$APRUN_CYCLE
export OMP_NUM_THREADS_CY=$NTHREADS_CYCLE
export MAX_TASKS_CY=$ntiles
$CYCLESH
export err=$?; err_chk
################################################################################
# Postprocessing
cd $pwd
[[ $mkdata = "YES" ]] && rm -rf $DATA
################################################################################
exit $err
################################################################################