-
Notifications
You must be signed in to change notification settings - Fork 183
/
Copy pathprep.sh
executable file
·141 lines (116 loc) · 5.34 KB
/
prep.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
#! /usr/bin/env bash
source "${HOMEgfs}/ush/preamble.sh"
###############################################################
# Source FV3GFS workflow modules
. ${HOMEgfs}/ush/load_fv3gfs_modules.sh
status=$?
[[ ${status} -ne 0 ]] && exit ${status}
###############################################################
# Source relevant configs
configs="base prep"
for config in ${configs}; do
. ${EXPDIR}/config.${config}
status=$?
[[ ${status} -ne 0 ]] && exit ${status}
done
###############################################################
# Source machine runtime environment
. ${BASE_ENV}/${machine}.env prep
status=$?
[[ ${status} -ne 0 ]] && exit ${status}
###############################################################
# Set script and dependency variables
export OPREFIX="${CDUMP}.t${cyc}z."
export COMOUT="${ROTDIR}/${CDUMP}.${PDY}/${cyc}/atmos"
export MAKE_PREPBUFR=${MAKE_PREPBUFR:-"YES"}
[[ ! -d ${COMOUT} ]] && mkdir -p ${COMOUT}
[[ ! -d ${COMIN_OBS} ]] && mkdir -p ${COMIN_OBS}
###############################################################
# If ROTDIR_DUMP=YES, copy dump files to rotdir
if [[ ${ROTDIR_DUMP} = "YES" ]]; then
${HOMEgfs}/ush/getdump.sh "${CDATE}" "${CDUMP}" "${DMPDIR}/${CDUMP}${DUMP_SUFFIX}.${PDY}/${cyc}/atmos" "${COMIN_OBS}"
status=$?
[[ ${status} -ne 0 ]] && exit ${status}
# Ensure previous cycle gdas dumps are available (used by cycle & downstream)
GDATE=$(${NDATE} -${assim_freq} ${CDATE})
gPDY=$(echo ${GDATE} | cut -c1-8)
gcyc=$(echo ${GDATE} | cut -c9-10)
GDUMP=gdas
gCOMOBS="${ROTDIR}/${GDUMP}.${gPDY}/${gcyc}/obs"
if [[ ! -s ${gCOMOBS}/${GDUMP}.t${gcyc}z.updated.status.tm00.bufr_d ]]; then
${HOMEgfs}/ush/getdump.sh "${GDATE}" "${GDUMP}" "${DMPDIR}/${GDUMP}${DUMP_SUFFIX}.${gPDY}/${gcyc}/atmos" "${gCOMOBS}"
status=$?
[[ ${status} -ne 0 ]] && exit ${status}
fi
# exception handling to ensure no dead link
[[ $(find ${COMIN_OBS} -xtype l | wc -l) -ge 1 ]] && exit 9
[[ $(find ${gCOMOBS} -xtype l | wc -l) -ge 1 ]] && exit 9
fi
###############################################################
###############################################################
# For running real-time parallels, execute tropcy_qc and
# copy files from operational syndata directory to a local directory.
# Otherwise, copy existing tcvital data from globaldump.
if [[ ${PROCESS_TROPCY} = "YES" ]]; then
export COMINsyn=${COMINsyn:-$(compath.py gfs/prod/syndat)}
if [[ ${RUN_ENVIR} != "nco" ]]; then
export ARCHSYND=${ROTDIR}/syndat
if [[ ! -d ${ARCHSYND} ]]; then mkdir -p ${ARCHSYND}; fi
if [[ ! -s ${ARCHSYND}/syndat_akavit ]]; then
for file in syndat_akavit syndat_dateck syndat_stmcat.scr syndat_stmcat syndat_sthisto syndat_sthista ; do
cp ${COMINsyn}/${file} ${ARCHSYND}/.
done
fi
fi
[[ ${ROTDIR_DUMP} = "YES" ]] && rm ${COMOUT}${CDUMP}.t${cyc}z.syndata.tcvitals.tm00
${HOMEgfs}/jobs/JGLOBAL_ATMOS_TROPCY_QC_RELOC
status=$?
[[ ${status} -ne 0 ]] && exit ${status}
else
[[ ${ROTDIR_DUMP} = "NO" ]] && cp ${DMPDIR}/${CDUMP}${DUMP_SUFFIX}.${PDY}/${cyc}/atmos/${CDUMP}.t${cyc}z.syndata.tcvitals.tm00 ${COMOUT}/
fi
# Will modify the new location later in the next PR to address issue 1198
if [[ ${ROTDIR_DUMP} = "YES" ]]; then
mv ${COMIN_OBS}/*syndata.tcvitals.tm00 ${COMOUT}
mv ${COMIN_OBS}/*snogrb_t1534.3072.1536 ${COMOUT}
mv ${COMIN_OBS}/*seaice.5min.blend.grb ${COMOUT}
fi
###############################################################
# Generate prepbufr files from dumps or copy from OPS
if [[ ${MAKE_PREPBUFR} = "YES" ]]; then
if [[ ${ROTDIR_DUMP} = "YES" ]]; then
rm -f ${COMIN_OBS}/${OPREFIX}prepbufr
rm -f ${COMIN_OBS}/${OPREFIX}prepbufr.acft_profiles
rm -f ${COMIN_OBS}/${OPREFIX}nsstbufr
fi
export job="j${CDUMP}_prep_${cyc}"
export DATAROOT="${RUNDIR}/${CDATE}/${CDUMP}/prepbufr"
export COMIN=${COMIN_OBS}
export COMINgdas=${COMINgdas:-${ROTDIR}/gdas.${PDY}/${cyc}/atmos}
export COMINgfs=${COMINgfs:-${ROTDIR}/gfs.${PDY}/${cyc}/atmos}
export COMOUT=${COMIN_OBS}
if [[ ${ROTDIR_DUMP} = "NO" ]]; then
COMIN_OBS=${COMIN_OBS:-${DMPDIR}/${CDUMP}${DUMP_SUFFIX}.${PDY}/${cyc}/atmos}
fi
export COMSP=${COMSP:-${COMIN_OBS}/${CDUMP}.t${cyc}z.}
# Disable creating NSSTBUFR if desired, copy from DMPDIR instead
if [[ ${MAKE_NSSTBUFR:-"NO"} = "NO" ]]; then
export MAKE_NSSTBUFR="NO"
fi
${HOMEobsproc}/jobs/JOBSPROC_GLOBAL_PREP
status=$?
[[ ${status} -ne 0 ]] && exit ${status}
# If creating NSSTBUFR was disabled, copy from DMPDIR if appropriate.
if [[ ${MAKE_NSSTBUFR:-"NO"} = "NO" ]]; then
[[ ${DONST} = "YES" ]] && ${NCP} ${DMPDIR}/${CDUMP}${DUMP_SUFFIX}.${PDY}/${cyc}/atmos/${OPREFIX}nsstbufr ${COMIN_OBS}/${OPREFIX}nsstbufr
fi
else
if [[ ${ROTDIR_DUMP} = "NO" ]]; then
${NCP} ${DMPDIR}/${CDUMP}${DUMP_SUFFIX}.${PDY}/${cyc}/atmos/${OPREFIX}prepbufr ${COMIN_OBS}/${OPREFIX}prepbufr
${NCP} ${DMPDIR}/${CDUMP}${DUMP_SUFFIX}.${PDY}/${cyc}/atmos/${OPREFIX}prepbufr.acft_profiles ${COMIN_OBS}/${OPREFIX}prepbufr.acft_profiles
[[ ${DONST} = "YES" ]] && ${NCP} ${DMPDIR}/${CDUMP}${DUMP_SUFFIX}.${PDY}/${cyc}/atmos/${OPREFIX}nsstbufr ${COMIN_OBS}/${OPREFIX}nsstbufr
fi
fi
################################################################################
# Exit out cleanly
exit 0