forked from davegill/wrf_feature_testing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
feature_testing.csh
executable file
·296 lines (242 loc) · 7.69 KB
/
feature_testing.csh
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
#!/bin/csh
if ( ${#argv} == 0 ) then
echo
echo "USAGE within the standard WRF docker container:"
echo "./feature_testing.csh /wrf/wrfoutput /wrf/WRF/test/em_real restartA /wrf/cases/basic /wrf/input/additional /wrf/input/standard mpi-8"
echo where
echo The full path to the shared directory = /wrf/wrfoutput
echo The full path to the WRF test directory = /wrf/WRF/test/em_real
echo The WRF designator for this suite of tests = restartA
echo The full path to the namelist directory = /wrf/cases/basic
echo The full path to the additional binary data files for WRF = /wrf/input/additional
echo The full path to the metgrid data if a real case = /wrf/input/standard, ELSE SKIP
echo "The combination of which parallel option (ser, omp, mpi) and how many procs = mpi-8"
echo
echo Please, no trailing "/" characters at the end of the directory names
echo "Please #2, currently, these restart / feature tests are only for MPI"
echo
exit 0
else if ( ${#argv} == 1 ) then
set SUPER_CLEAN = TRUE
goto clean_it_all
endif
# ==========================================================
# Some options that can be changed
# ==========================================================
set VERBOSE = TRUE
set VERBOSE = FALSE
set CLEAN_UP = FALSE
set CLEAN_UP = TRUE
set SUPER_CLEAN = FALSE
# ==========================================================
# Some needed info, all internal
# ==========================================================
set ORIG_DIR = `pwd`
set THEN = `date`
set OVERALL = 0
# ==========================================================
# Process script args
# ==========================================================
# The shared directory that both inside and outside of docker can see
# EXAMPLE: /wrf/wrfoutput
if ( $VERBOSE == TRUE ) then
echo "The shared directory that both inside and outside of docker can see = $1"
endif
set SHARED_DIR = $1
shift
# Full path to run the WRF test case:
# EXAMPLE: /wrf/WRF/test/em_real
# We use the last part of the directory later, so it needs
# to be em_real, em_quarter_ss, etc
# The "out of source build" will not work for this.
if ( $VERBOSE == TRUE ) then
echo "The full directory where to run the WRF test case = $1"
endif
set WRF_DIR = $1
shift
set TEST_DIR = $WRF_DIR:t
if ( $VERBOSE == TRUE ) then
echo "The WRF init type is type $TEST_DIR"
endif
# The WRF test suite designator from the build.csh script.
# EXAMPLE: restartA
# We use this when naming the SUCCESS* files
if ( $VERBOSE == TRUE ) then
echo "The WRF test suite name designator = $1"
endif
set WRF_NAME = $1
shift
# Full namelist directory
# EXAMPLE: /wrf/cases/em_real/basic
if ( $VERBOSE == TRUE ) then
echo "Case namelist location = $1"
ls -ls $1
endif
set NML_DIR = $1
shift
set TEST_CASE = $NML_DIR:t
if ( $VERBOSE == TRUE ) then
echo "The WRF namelist case = $TEST_CASE"
endif
# Binary data: full directory
# EXAMPLE: /wrf/input/additional
# Purpose? Location of Thompson MP data, etc
if ( $VERBOSE == TRUE ) then
echo "Binary data files location = $1"
ls -ls $1
endif
set BIN_DIR = $1
shift
# Metgrid data case, full directory
# EXAMPLE: /wrf/input/standard
if ( $TEST_DIR == em_real ) then
if ( $VERBOSE == TRUE ) then
echo "Metgrid data location = $1"
ls -ls $1
endif
set MET_DIR = $1
shift
else
set MET_DIR = IDEAL_CASE_NO_METGRID_FILES_REQUIRED
endif
# Parallel option selected AND number of procs to use
# ser-1, omp-16, mpi-108 fit the template
if ( $VERBOSE == TRUE ) then
echo "The parallel option + number of procs combo = $1"
endif
set PAR_PROC = $1
shift
set PAR_TYPE = `echo $PAR_PROC | cut -c1-3`
set NUM_PROC = `echo $PAR_PROC | cut -c5-`
if ( $VERBOSE == TRUE ) then
echo "The parallel option = $PAR_TYPE"
echo "The number of processors to use = $NUM_PROC"
endif
pushd $WRF_DIR >& /dev/null
# Set up the pieces to run
cp $NML_DIR/* .
ln -sf $BIN_DIR/* .
if ( $TEST_DIR == em_real ) then
ln -sf $MET_DIR/* .
set PRE_PROC = real.exe
else
set PRE_PROC = ideal.exe
endif
set PRE_ROOT = `echo $PRE_PROC:r | tr "[a-z]" "[A-Z]"`
# ==========================================================
# Step 1: Run real
# ==========================================================
# Run the pre-processor (either real or ideal)
cp namelist.input.1 namelist.input
if ( $PAR_TYPE == mpi ) then
./$PRE_PROC >& /dev/null
cp rsl.out.0000 $PRE_ROOT.print.out
else
./$PRE_PROC >&! $PRE_ROOT.print.out
endif
${ORIG_DIR}/check_OK.csh $VERBOSE $PRE_PROC $PRE_ROOT.print.out
set OK_STEP = $status
set OVERALL = ( $OVERALL && $OK_STEP )
if ( $OVERALL != 0 ) then
exit (91)
touch ${SHARED_DIR}/FAIL_RUN_REAL_em_real_34_${WRF_NAME}_${TEST_CASE}
else
touch ${SHARED_DIR}/SUCCESS_RUN_REAL_em_real_34_${WRF_NAME}_${TEST_CASE}
endif
# ==========================================================
# Step 2: Run WRF
# ==========================================================
# Run the model
cp namelist.input.2 namelist.input
if ( $PAR_TYPE == mpi ) then
mpirun -np $NUM_PROC --oversubscribe ./wrf.exe >& /dev/null
cp rsl.out.0000 WRF.print.out
else
./wrf.exe >&! WRF.print.out
endif
${ORIG_DIR}/check_OK.csh $VERBOSE wrf.exe WRF.print.out
set OK_STEP = $status
set OVERALL = ( $OVERALL && $OK_STEP )
if ( $OVERALL != 0 ) then
exit (92)
touch ${SHARED_DIR}/FAIL_RUN_WRF1_em_real_34_${WRF_NAME}_${TEST_CASE}
else
touch ${SHARED_DIR}/SUCCESS_RUN_WRF1_em_real_34_${WRF_NAME}_${TEST_CASE}
endif
if ( -d HOLD ) then
rm -rf HOLD
endif
mkdir HOLD
mv wrfo* rsl* HOLD
# ==========================================================
# Step 3: Run WRF restart
# ==========================================================
# Run the model
cp namelist.input.3 namelist.input
if ( $PAR_TYPE == mpi ) then
mpirun -np $NUM_PROC --oversubscribe ./wrf.exe >& /dev/null
cp rsl.out.0000 WRF.print.out
else
./wrf.exe >&! WRF.print.out
endif
${ORIG_DIR}/check_OK.csh $VERBOSE wrf.exe WRF.print.out
set OK_STEP = $status
set OVERALL = ( $OVERALL && $OK_STEP )
if ( $OVERALL != 0 ) then
exit (93)
touch ${SHARED_DIR}/FAIL_RUN_WRF2_em_real_34_${WRF_NAME}_${TEST_CASE}
else
touch ${SHARED_DIR}/SUCCESS_RUN_WRF2_em_real_34_${WRF_NAME}_${TEST_CASE}
endif
# ==========================================================
# Step 4: Compare original run vs restart results
# ==========================================================
# What files do we diff? Get the number of domains, and
# get the most recent wrfout files for those domains.
set TOTAL_WRFOUT_FILES = `ls -1 | grep wrfout_d0 | wc -l`
set TOTAL_WRFOUT_FIRST_TIME_PERIOD = `ls -1 | grep wrfout_d01 | wc -l`
@ TOTAL_DOMAINS = $TOTAL_WRFOUT_FILES / $TOTAL_WRFOUT_FIRST_TIME_PERIOD
set FILES_TO_DIFF = `ls -t1 | grep wrfout | head -${TOTAL_DOMAINS}`
# Where oh where is diffwrf?
set D = $WRF_DIR:h:h
set DIFFWRF = $D/external/io_netcdf/diffwrf
# Do the diffs
foreach f ( $FILES_TO_DIFF )
${ORIG_DIR}/check_OK.csh $VERBOSE diffwrf $DIFFWRF $f HOLD/$f
set OK_STEP = $status
set OVERALL = ( $OVERALL && $OK_STEP )
if ( $OVERALL != 0 ) then
exit (94)
touch ${SHARED_DIR}/FAIL_RUN_COMPARE_em_real_34_${WRF_NAME}_${TEST_CASE}_$f
else
touch ${SHARED_DIR}/SUCCESS_RUN_COMPARE_em_real_34_${WRF_NAME}_${TEST_CASE}_$f
endif
end
# ==========================================================
# Step 5: Clean-up and done
# ==========================================================
if ( $CLEAN_UP == TRUE ) then
rm -rf wrfr*
rm -rf wrfi*
rm -rf wrfb*
rm -rf namelist.input
rm -rf fort.88
rm -rf fort.98
rm -rf met_em*
endif
echo " "
echo "Restart test validation completed for $NML_DIR"
echo Started at $THEN
echo Ended at `date`
echo " "
popd >& /dev/null
clean_it_all:
if ( $SUPER_CLEAN == TRUE ) then
cd $1
rm -rf wrfo*
rm -rf REAL.print.out
rm -rf WRF.print.out
rm -rf rsl*
rm -rf HOLD
endif
exit (0)