forked from NOAA-EMC/global-workflow
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwave_grid_interp_sbs.sh
More file actions
executable file
·168 lines (137 loc) · 4.56 KB
/
wave_grid_interp_sbs.sh
File metadata and controls
executable file
·168 lines (137 loc) · 4.56 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
#! /usr/bin/env bash
################################################################################
#
# UNIX Script Documentation Block
# Script name: wave_grid_interp_sbs.sh
# Script description: Interpolate from native grids to target grid
#
# Author: J-Henrique Alves Org: NCEP/EMC Date: 2019-11-02
# Abstract: Creates grib2 files from WW3 binary output
#
# Script history log:
# 2019-11-02 J-Henrique Alves Ported to global-workflow.
# 2020-06-10 J-Henrique Alves Ported to R&D machine Hera
#
# $Id$
#
# Attributes:
# Language: Bourne-again (BASH) shell
#
# Requirements:
# - wgrib2 with IPOLATES library
#
################################################################################
# --------------------------------------------------------------------------- #
# 0. Preparations
source "${USHgfs}/preamble.sh"
# 0.a Basic modes of operation
cd $GRDIDATA
grdID=$1
ymdh=$2
dt=$3
nst=$4
echo "Making GRID Interpolation Files for $grdID."
rm -rf grint_${grdID}_${ymdh}
mkdir grint_${grdID}_${ymdh}
err=$?
if [ "$err" != '0' ]
then
set +x
echo ' '
echo '************************************************************************************* '
echo '*** FATAL ERROR : ERROR IN ww3_grid_interp (COULD NOT CREATE TEMP DIRECTORY) *** '
echo '************************************************************************************* '
echo ' '
set_trace
exit 1
fi
cd grint_${grdID}_${ymdh}
# 0.b Define directories and the search path.
# The tested variables should be exported by the postprocessor script.
set +x
echo ' '
echo '+--------------------------------+'
echo '! Make GRID files |'
echo '+--------------------------------+'
echo " Model ID : $WAV_MOD_TAG"
set_trace
if [[ -z "${PDY}" ]] || [[ -z "${cyc}" ]] || [[ -z "${cycle}" ]] || [[ -z "${EXECgfs}" ]] || \
[[ -z "${waveGRD}" ]] || [[ -z "${WAV_MOD_TAG}" ]] || [[ -z "${SENDDBN}" ]]
then
set +x
echo ' '
echo '***************************************************'
echo '*** EXPORTED VARIABLES IN postprocessor NOT SET ***'
echo '***************************************************'
echo ' '
echo "${PDY}${cyc} ${cycle} ${EXECgfs} ${WAV_MOD_TAG} ${SENDDBN} ${waveGRD}"
set_trace
exit 1
fi
# 0.c Links to files
rm -f ${DATA}/output_${ymdh}0000/out_grd.$grdID
if [ ! -f ${DATA}/${grdID}_interp.inp.tmpl ]; then
cp "${PARMgfs}/wave/${grdID}_interp.inp.tmpl" "${DATA}/${grdID}_interp.inp.tmpl"
fi
${NLN} "${DATA}/${grdID}_interp.inp.tmpl" "${grdID}_interp.inp.tmpl"
${NLN} "${DATA}/output_${ymdh}0000/out_grd.${waveGRD}" "out_grd.${waveGRD}"
for ID in ${waveGRD} ${grdID}; do
${NLN} "${DATA}/mod_def.${ID}" "mod_def.${ID}"
done
# --------------------------------------------------------------------------- #
# 1. Generate GRID file with all data
# 1.a Generate Input file
time="${ymdh:0:8} ${ymdh:8:2}0000"
sed -e "s/TIME/$time/g" \
-e "s/DT/$dt/g" \
-e "s/NSTEPS/$nst/g" ${grdID}_interp.inp.tmpl > ww3_gint.inp
# Check if there is an interpolation weights file available
wht_OK='no'
if [ ! -f ${DATA}/ww3_gint.WHTGRIDINT.bin.${grdID} ]; then
if [ -f ${FIXgfs}/wave/ww3_gint.WHTGRIDINT.bin.${grdID} ]
then
set +x
echo ' '
echo " Copying ${FIXgfs}/wave/ww3_gint.WHTGRIDINT.bin.${grdID} "
set_trace
cp ${FIXgfs}/wave/ww3_gint.WHTGRIDINT.bin.${grdID} ${DATA}
wht_OK='yes'
else
set +x
echo ' '
echo " Not found: ${FIXgfs}/wave/ww3_gint.WHTGRIDINT.bin.${grdID} "
fi
fi
# Check and link weights file
if [ -f ${DATA}/ww3_gint.WHTGRIDINT.bin.${grdID} ]
then
${NLN} ${DATA}/ww3_gint.WHTGRIDINT.bin.${grdID} ./WHTGRIDINT.bin
fi
# 1.b Run interpolation code
export pgm="${NET,,}_ww3_gint.x"
source prep_step
set +x
echo " Executing ${pgm}"
set_trace
"${EXECgfs}/${pgm}" 1> gint.${grdID}.out 2>&1
export err=$?;err_chk
if [ "$err" != '0' ]
then
set +x
echo ' '
echo '*************************************************** '
echo "*** FATAL ERROR : ERROR IN ${pgm} interpolation * "
echo '*************************************************** '
echo ' '
set_trace
exit 3
fi
# 1.b Clean up
rm -f grid_interp.inp
rm -f mod_def.*
mv out_grd.$grdID ${DATA}/output_${ymdh}0000/out_grd.$grdID
# --------------------------------------------------------------------------- #
# 2. Clean up the directory
cd ../
mv -f grint_${grdID}_${ymdh} done.grint_${grdID}_${ymdh}
# End of ww3_grid_interp.sh -------------------------------------------- #