-
Notifications
You must be signed in to change notification settings - Fork 168
/
JGLOBAL_FORECAST
executable file
·132 lines (112 loc) · 4.4 KB
/
JGLOBAL_FORECAST
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
#! /usr/bin/env bash
source "${HOMEgfs}/ush/preamble.sh"
if (( 10#${ENSMEM:-0} > 0 )); then
export DATAjob="${DATAROOT}/${RUN}efcs${ENSMEM}.${PDY:-}${cyc}"
export DATA="${DATAjob}/${jobid}"
source "${HOMEgfs}/ush/jjob_header.sh" -e "efcs" -c "base fcst efcs"
else
export DATAjob="${DATAROOT}/${RUN}fcst.${PDY:-}${cyc}"
export DATA="${DATAjob}/${jobid}"
source "${HOMEgfs}/ush/jjob_header.sh" -e "fcst" -c "base fcst"
fi
# Create the directory to hold restarts and output from the model in stmp
export DATArestart="${DATAjob}/restart"
if [[ ! -d "${DATArestart}" ]]; then mkdir -p "${DATArestart}"; fi
export DATAoutput="${DATAjob}/output"
if [[ ! -d "${DATAoutput}" ]]; then mkdir -p "${DATAoutput}"; fi
##############################################
# Begin JOB SPECIFIC work
##############################################
# Restart conditions for GFS cycle come from GDAS
rCDUMP="${RUN}"
export rCDUMP="${RUN/gfs/gdas}"
# Ignore possible spelling error (nothing is misspelled)
# shellcheck disable=SC2153
GDATE=$(date --utc -d "${PDY} ${cyc} - ${assim_freq} hours" +%Y%m%d%H)
declare -rx GDATE
# shellcheck disable=
declare -rx gPDY="${GDATE:0:8}"
declare -rx gcyc="${GDATE:8:2}"
# Construct COM variables from templates (see config.com)
YMD="${PDY}" HH="${cyc}" declare_from_tmpl -rx \
COMIN_ATMOS_INPUT:COM_ATMOS_INPUT_TMPL \
COMIN_ATMOS_ANALYSIS:COM_ATMOS_ANALYSIS_TMPL \
COMOUT_CONF:COM_CONF_TMPL \
COMOUT_ATMOS_RESTART:COM_ATMOS_RESTART_TMPL \
COMOUT_ATMOS_HISTORY:COM_ATMOS_HISTORY_TMPL \
COMOUT_ATMOS_MASTER:COM_ATMOS_MASTER_TMPL
RUN="${rCDUMP}" YMD="${gPDY}" HH="${gcyc}" declare_from_tmpl -rx \
COMIN_ATMOS_RESTART_PREV:COM_ATMOS_RESTART_TMPL
if [[ "${DO_WAVE}" == "YES" ]]; then
YMD="${PDY}" HH="${cyc}" declare_from_tmpl -rx \
COMIN_WAVE_PREP:COM_WAVE_PREP_TMPL \
COMOUT_WAVE_RESTART:COM_WAVE_RESTART_TMPL \
COMOUT_WAVE_HISTORY:COM_WAVE_HISTORY_TMPL
RUN="${rCDUMP}" YMD="${gPDY}" HH="${gcyc}" declare_from_tmpl -rx \
COMIN_WAVE_RESTART_PREV:COM_WAVE_RESTART_TMPL
fi
if [[ "${DO_OCN}" == "YES" ]]; then
YMD="${PDY}" HH="${cyc}" declare_from_tmpl -rx \
COMIN_OCEAN_ANALYSIS:COM_OCEAN_ANALYSIS_TMPL \
COMIN_OCEAN_INPUT:COM_OCEAN_INPUT_TMPL \
COMOUT_MED_RESTART:COM_MED_RESTART_TMPL \
COMOUT_OCEAN_RESTART:COM_OCEAN_RESTART_TMPL \
COMOUT_OCEAN_HISTORY:COM_OCEAN_HISTORY_TMPL
RUN="${rCDUMP}" YMD="${gPDY}" HH="${gcyc}" declare_from_tmpl -rx \
COMIN_OCEAN_RESTART_PREV:COM_OCEAN_RESTART_TMPL \
COMIN_MED_RESTART_PREV:COM_MED_RESTART_TMPL
fi
if [[ "${DO_ICE}" == "YES" ]]; then
YMD="${PDY}" HH="${cyc}" declare_from_tmpl -rx \
COMIN_ICE_INPUT:COM_ICE_INPUT_TMPL \
COMIN_ICE_ANALYSIS:COM_ICE_ANALYSIS_TMPL \
COMOUT_ICE_RESTART:COM_ICE_RESTART_TMPL \
COMOUT_ICE_HISTORY:COM_ICE_HISTORY_TMPL
RUN="${rCDUMP}" YMD="${gPDY}" HH="${gcyc}" declare_from_tmpl -rx \
COMIN_ICE_RESTART_PREV:COM_ICE_RESTART_TMPL
fi
if [[ "${DO_AERO}" == "YES" ]]; then
YMD="${PDY}" HH="${cyc}" declare_from_tmpl -rx \
COMOUT_CHEM_HISTORY:COM_CHEM_HISTORY_TMPL
fi
###############################################################
# Run relevant exglobal script
###############################################################
"${FORECASTSH:-${SCRgfs}/exglobal_forecast.sh}"
status=$?
(( status != 0 )) && exit "${status}"
# Send DBN alerts for EnKF
# TODO: Should these be in post manager instead?
if [[ "${RUN}" =~ "enkf" ]] && [[ "${SENDDBN:-}" == YES ]]; then
for (( fhr = FHOUT; fhr <= FHMAX; fhr + FHOUT )); do
if (( fhr % 3 == 0 )); then
fhr3=$(printf %03i "${fhr}")
"${DBNROOT}/bin/dbn_alert" MODEL GFS_ENKF "${job}" "${COMOUT_ATMOS_HISTORY}/${RUN}.t${cyc}z.sfcf${fhr3}.nc"
fi
done
fi
##############################################
# End JOB SPECIFIC work
##############################################
##############################################
# Final processing
##############################################
if [[ -e "${pgmout}" ]] ; then
cat "${pgmout}"
fi
##########################################
# Remove the Temporary working directory
##########################################
cd "${DATAROOT}" || true
# do not remove DATAjob. It contains DATAoutput
if [[ "${KEEPDATA}" == "NO" ]]; then
rm -rf "${DATA}"
# Determine if this is the last segment
commas="${FCST_SEGMENTS//[^,]}"
n_segs=${#commas}
if (( n_segs - 1 == ${FCST_SEGMENT:-0} )); then
# Only delete temporary restarts if it is the last segment
rm -rf "${DATArestart}"
fi
fi
exit 0