forked from NOAA-EMC/global-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexglobal_atmos_sfcanl.sh
More file actions
executable file
·194 lines (164 loc) · 6.78 KB
/
exglobal_atmos_sfcanl.sh
File metadata and controls
executable file
·194 lines (164 loc) · 6.78 KB
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
#! /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.
# Derived base variables
# Dependent Scripts and Executables
CYCLESH=${CYCLESH:-"${USHgfs}/global_cycle.sh"}
REGRIDSH=${REGRIDSH:-"${USHgfs}/regrid_gsiSfcIncr_to_tile.sh"}
export CYCLEXEC=${CYCLEXEC:-"${EXECgfs}/global_cycle"}
NTHREADS_CYCLE=${NTHREADS_CYCLE:-24}
APRUN_CYCLE=${APRUN_CYCLE:-${APRUN:-""}}
# Surface cycle related parameters
export SNOW_NUDGE_COEFF=${SNOW_NUDGE_COEFF:--2.}
export CYCLVARS=${CYCLVARS:-""}
export FHOUR=${FHOUR:-0}
export DELTSFC=${DELTSFC:-6}
export COUPLED=${COUPLED:-".false."}
# Other info used in this script
# Ignore possible spelling error (nothing is misspelled)
# shellcheck disable=SC2153
GPREFIX="gdas.t${GDATE:8:2}z."
OPREFIX="${RUN/enkf/}.t${cyc}z."
APREFIX="${RUN/enkf/}.t${cyc}z."
ntiles=6
##############################################################
# Get dimension information based on CASE
res=${CASE:1}
JCAP_CASE=$((res * 2 - 2))
LATB_CASE=$((res * 2))
LONB_CASE=$((res * 4))
# 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}"}
# Check if resolution specific FNSNOA exists, if not use t1534 version
if [[ ! -f "${FNSNOA}" ]]; then
export FNSNOA="${COMIN_OBS}/${OPREFIX}snogrb_t1534.3072.1536"
fi
if [[ ! -f "${FNSNOA}" ]]; then
echo "WARNING: Current cycle snow file ${FNSNOA} is missing. Snow coverage will not be updated."
else
echo "INFO: Current cycle snow file is ${FNSNOA}"
fi
export FNSNOG=${FNSNOG:-"${COMIN_OBS_PREV}/${GPREFIX}snogrb_t${JCAP_CASE}.${LONB_CASE}.${LATB_CASE}"}
# Check if resolution specific FNSNOG exists, if not use t1534 version
if [[ ! -f "${FNSNOG}" ]]; then
export FNSNOG="${COMIN_OBS_PREV}/${GPREFIX}snogrb_t1534.3072.1536"
fi
if [[ ! -f "${FNSNOG}" ]]; then
echo "WARNING: Previous cycle snow file ${FNSNOG} is missing. Snow coverage will not be updated."
else
echo "INFO: Previous cycle snow file is ${FNSNOG}"
fi
# If any snow files are missing, don't apply snow in the global_cycle step.
if [[ ! -f "${FNSNOA}" ]] || [[ ! -f "${FNSNOG}" ]]; then
export FNSNOA=" "
export CYCLVARS=FSNOL=99999.,FSNOS=99999.,
# Set CYCLVARS by checking grib date of current snogrb vs that of prev cycle
elif [[ "$(${WGRIB} -4yr "${FNSNOA}" 2> /dev/null | grep -i snowc | awk -F: '{print $3}' | awk -F= '{print $2}')" -le "$(${WGRIB} -4yr "${FNSNOG}" 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 CYCLVARS="FSNOL=${SNOW_NUDGE_COEFF},${CYCLVARS}"
fi
# determine where the input snow restart files come from
snow_prefix=""
if [[ "${DO_JEDISNOWDA:-}" == "YES" ]]; then
sfcdata_dir="${COMIN_SNOW_ANALYSIS}"
snow_prefix="snow_analysis."
else
sfcdata_dir="${COMIN_ATMOS_RESTART_PREV}"
fi
# global_cycle executable specific variables
export APRUNCY="${APRUN_CYCLE}"
export OMP_NUM_THREADS_CY="${NTHREADS_CYCLE}"
export MAX_TASKS_CY="${ntiles}"
# Copy fix files required by global_cycle to DATA just once
for ((nn = 1; nn <= ntiles; nn++)); do
cpreq "${FIXgfs}/orog/${CASE}/${CASE}_grid.tile${nn}.nc" "${DATA}/fngrid.00${nn}"
cpreq "${FIXgfs}/orog/${CASE}/${CASE}.mx${OCNRES}_oro_data.tile${nn}.nc" "${DATA}/fnorog.00${nn}"
done
# Copy the NSST analysis file for global_cycle
# There is only a single NSST analysis at the middle of the window
# For now use/assume it is the same at the beginning of the window if doing IAU
if [[ "${DONST}" == "YES" ]]; then
export NST_FILE=${NST_FILE:-${COMIN_ATMOS_ANALYSIS}/${APREFIX}increment.dtf.i006.nc}
if [[ -s "${NST_FILE}" ]]; then
cpreq "${NST_FILE}" "${DATA}/dtfinc"
export NST_FILE="dtfinc"
else
export NST_FILE="NULL"
fi
else
export NST_FILE="NULL"
fi
# Collect the dates in the window to update surface restarts
gcycle_dates=("${PDY}${cyc}") # Always update surface restarts at middle of window
soilinc_fhrs=("${assim_freq}") # increment file at middle of window
LFHR="${assim_freq}"
if [[ "${DOIAU:-}" == "YES" ]]; then # Update surface restarts at beginning of window
half_window=$((assim_freq / 2))
soilinc_fhrs+=("${half_window}")
LFHR=-1
BDATE=$(date --utc -d "${PDY} ${cyc} - ${half_window} hours" +%Y%m%d%H)
gcycle_dates+=("${BDATE}")
fi
# if doing GSI soil anaysis, copy increment file and re-grid it to native model resolution
if [[ "${DO_GSISOILDA}" == "YES" ]]; then
export COMIN_SOIL_ANALYSIS_MEM="${COMIN_ATMOS_ENKF_ANALYSIS_STAT}"
export COMOUT_ATMOS_ANALYSIS_MEM="${COMIN_ATMOS_ANALYSIS}"
export CASE_IN="${CASE_ENS}"
export CASE_OUT="${CASE}"
export OCNRES_OUT="${OCNRES}"
export LFHR
"${REGRIDSH}"
export err=$?
if [[ ${err} -ne 0 ]]; then
err_exit "Soil increment file was not regridded correctly!"
fi
fi
# Loop over the dates in the window to update the surface restarts
for hr in "${!gcycle_dates[@]}"; do
export gcycle_date="${gcycle_dates[hr]}"
FHR="${soilinc_fhrs[hr]}"
echo "Updating surface restarts for ${gcycle_date} ..."
datestr="${gcycle_date:0:8}.${gcycle_date:8:2}0000"
if [[ "${DO_GSISOILDA}" == "YES" ]] && [[ "${GCYCLE_DO_SOILINCR}" == ".true." ]]; then
for ((nn = 1; nn <= ntiles; nn++)); do
cpreq "${COMIN_ATMOS_ANALYSIS}/increment.sfc.i00${FHR}.tile${nn}.nc" \
"${DATA}/soil_xainc.00${nn}"
done
fi
# Copy inputs from COMIN to DATA
for ((nn = 1; nn <= ntiles; nn++)); do
cpreq "${sfcdata_dir}/${datestr}.${snow_prefix}sfc_data.tile${nn}.nc" "${DATA}/fnbgsi.00${nn}"
cpreq "${DATA}/fnbgsi.00${nn}" "${DATA}/fnbgso.00${nn}"
done
"${CYCLESH}" && true
export err=$?
if [[ ${err} -ne 0 ]]; then
err_exit "Unable to update surface data from guess and analysis!"
fi
# Copy outputs from DATA to COMOUT
for ((nn = 1; nn <= ntiles; nn++)); do
cpfs "${DATA}/fnbgso.00${nn}" "${COMOUT_ATMOS_RESTART}/${datestr}.sfcanl_data.tile${nn}.nc"
done
done
################################################################################
exit "${err}"
################################################################################