-
Notifications
You must be signed in to change notification settings - Fork 208
Expand file tree
/
Copy pathexgfs_atmos_gempak_meta.sh
More file actions
executable file
·87 lines (70 loc) · 2.19 KB
/
exgfs_atmos_gempak_meta.sh
File metadata and controls
executable file
·87 lines (70 loc) · 2.19 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
#! /usr/bin/env bash
GEMGRD1="${RUN}_1p00_${PDY}${cyc}f"
export numproc=23
# Find the last hour available
for ((fhr = fhend; fhr >= fhbeg; fhr = fhr - fhinc)); do
fhr3=$(printf "%03d" "${fhr}")
if [[ -r "${COMIN_ATMOS_GEMPAK_1p00}/${GEMGRD1}${fhr3}" ]]; then
break
fi
done
sleep_interval=20
max_tries=180
first_time=0
do_all=0
#loop through and process needed forecast hours
while [[ ${fhr} -le ${fhend} ]]; do
#
# First check to see if this is a rerun. If so make all Meta files
if [[ ${fhr} -gt 126 && ${first_time} -eq 0 ]]; then
do_all=1
fi
first_time=1
if [[ ${fhr} -eq 120 ]]; then
fhr=126
fi
gempak_file="${COMIN_ATMOS_GEMPAK_1p00}/${GEMGRD1}${fhr3}"
if ! wait_for_file "${gempak_file}" "${sleep_interval}" "${max_tries}"; then
err_exit "FATAL ERROR: gempak grid file ${gempak_file} not available after maximum wait time."
fi
export fhr
########################################################
# Create a script to be poe'd
#
# Note: The number of scripts to be run MUST match the number
# of total_tasks set in the ecf script, or the job will fail.
#
rm -f poescript
fhr3=$(printf "%03d" "${fhr}")
if [[ ${do_all} -eq 1 ]]; then
do_all=0
awk '{print $1}' "${HOMEglobal}/gempak/fix/gfs_meta" | envsubst > "poescript"
else
#
# Do not try to grep out 12, it will grab the 12 from 126.
# This will work as long as we don't need 12 fhr metafiles
#
if [[ ${fhr} -ne 12 ]]; then
grep "${fhr}" "${HOMEglobal}/gempak/fix/gfs_meta" | awk -F" [0-9]" '{print $1}' | envsubst > "poescript"
fi
fi
# If this is the final fcst hour, alert the
# file to all centers.
#
if [[ ${fhr} -ge ${fhend} ]]; then
export DBN_ALERT_TYPE=GFS_METAFILE_LAST
fi
export fend=${fhr}
cat poescript
"${HOMEglobal}/ush/run_mpmd.sh" poescript && true
export err=$?
if [[ ${err} -ne 0 ]]; then
err_exit "Failed to generate one or more gempak meta plots!"
fi
if [[ ${fhr} -eq 126 ]]; then
fhr=$((fhr + 6))
else
fhr=$((fhr + fhinc))
fi
done
exit