-
Notifications
You must be signed in to change notification settings - Fork 0
/
JRRFS_PROCESS_SMOKE
176 lines (165 loc) · 5.69 KB
/
JRRFS_PROCESS_SMOKE
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
#!/bin/bash
#
#-----------------------------------------------------------------------
#
# This J-JOB script runs the radar reflectivity preprocess
#
#-----------------------------------------------------------------------
#
#-----------------------------------------------------------------------
#
# Source the variable definitions file and the bash utility functions.
#
#-----------------------------------------------------------------------
#
. ${GLOBAL_VAR_DEFNS_FP}
. $USHdir/source_util_funcs.sh
date
export PS4='+ $SECONDS + '
#
#-----------------------------------------------------------------------
#
# Save current shell options (in a global array). Then set new options
# for this script/function.
#
#-----------------------------------------------------------------------
#
{ save_shell_opts; set -u -x; } > /dev/null 2>&1
#
#-----------------------------------------------------------------------
#
# Get the full path to the file in which this script/function is located
# (scrfunc_fp), the name of that file (scrfunc_fn), and the directory in
# which the file is located (scrfunc_dir).
#
#-----------------------------------------------------------------------
#
scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" )
scrfunc_fn=$( basename "${scrfunc_fp}" )
scrfunc_dir=$( dirname "${scrfunc_fp}" )
#
#-----------------------------------------------------------------------
#
# Print message indicating entry into script.
#
#-----------------------------------------------------------------------
#
print_info_msg "
========================================================================
Entering script: \"${scrfunc_fn}\"
In directory: \"${scrfunc_dir}\"
This is the J-job script for the task that runs a radar reflectivity
preprocess with FV3 for the specified cycle.
========================================================================"
#
#-----------------------------------------------------------------------
#
# Create the working directory under the cycle directory.
#
#-----------------------------------------------------------------------
#
if [ "${CYCLE_TYPE}" = "spinup" ]; then
export workdir=${CYCLE_DIR}/process_smoke_spinup
else
export workdir=${CYCLE_DIR}/process_smoke
fi
rm -fr ${workdir}
mkdir -p ${workdir}
cd ${workdir}
export gridspec_dir=${NWGES_BASEDIR}/grid_spec
#
#-----------------------------------------------------------------------
#
# Set the name of and create the directory in which the output from this
# script will be saved for long time (if that directory doesn't already exist).
# Usually ics_dir under tmpnwprd should be purged fairly soon after cycle done
#
#-----------------------------------------------------------------------
#
export rave_nwges_dir=${NWGES_DIR}/RAVE_INTP
mkdir -p "${rave_nwges_dir}"
#JR STARTS
export hourly_hwpdir=${NWGES_BASEDIR}/HOURLY_HWP
mkdir -p "${hourly_hwpdir}"
#
#-----------------------------------------------------------------------
#
# Link the the hourly, interpolated RAVE data from $rave_nwges_dir so it
# is reused
#
#-----------------------------------------------------------------------
ECHO=/bin/echo
SED=/bin/sed
DATE=/bin/date
LN=/bin/ln
START_DATE=$(${ECHO} "${CDATE}" | ${SED} 's/\([[:digit:]]\{2\}\)$/ \1/')
YYYYMMDDHH=$(${DATE} +%Y%m%d%H -d "${START_DATE}")
YYYYMMDD=${YYYYMMDDHH:0:8}
HH=${YYYYMMDDHH:8:2}
${ECHO} ${YYYYMMDD}
${ECHO} ${HH}
current_day=`${DATE} -d "${YYYYMMDD}"`
current_hh=`${DATE} -d ${HH} +"%H"`
prev_hh=`${DATE} -d "$current_hh -24 hour" +"%H"`
previous_day=`${DATE} '+%C%y%m%d' -d "$current_day-1 days"`
previous_day="${previous_day} ${prev_hh}"
nfiles=24
smokeFile=SMOKE_RRFS_data_${YYYYMMDDHH}00.nc
for i in $(seq 0 $(($nfiles - 1)) )
do
timestr=`date +%Y%m%d%H -d "$previous_day + $i hours"`
intp_fname=${PREDEF_GRID_NAME}_intp_${timestr}00_${timestr}59.nc
if [ -f ${rave_nwges_dir}/${intp_fname} ]; then
${LN} -sf ${rave_nwges_dir}/${intp_fname} ${workdir}/${intp_fname}
echo "${rave_nwges_dir}/${intp_fname} interoplated file available to reuse"
else
echo "${rave_nwges_dir}/${intp_fname} interoplated file non available to reuse"
fi
done
#
#-----------------------------------------------------------------------
#
# Call the ex-script for this J-job.
#
#-----------------------------------------------------------------------
#
export pgmout="${workdir}/OUTPUT.$$"
env
python -u ${SCRIPTSdir}/generate_fire_emissions.py \
"${FIX_SMOKE_DUST}/${PREDEF_GRID_NAME}" \
"${FIRE_RAVE_DIR}" \
"${workdir}" \
"${PREDEF_GRID_NAME}" \
"${EBB_DCYCLE}"
export err=$?; err_chk
#Copy the the hourly, interpolated RAVE data to $rave_nwges_dir so it
# is maintained there for future cycles.
for file in ${workdir}/*; do
filename=$(basename "$file")
if [ ! -f ${rave_nwges_dir}/${filename} ]; then
cp ${file} ${rave_nwges_dir}
echo "Copied missing file: $filename"
fi
done
echo "Copy RAVE interpolated files completed"
#cp ${workdir}/* ${rave_nwges_dir}
#
#-----------------------------------------------------------------------
#
# Print exit message.
#
#-----------------------------------------------------------------------
#
print_info_msg "
========================================================================
Exiting script: \"${scrfunc_fn}\"
In directory: \"${scrfunc_dir}\"
========================================================================"
#
#-----------------------------------------------------------------------
#
# Restore the shell options saved at the beginning of this script/function.
#
#-----------------------------------------------------------------------
#
{ restore_shell_opts; } > /dev/null 2>&1