-
Notifications
You must be signed in to change notification settings - Fork 693
/
compile
executable file
·488 lines (455 loc) · 16.7 KB
/
compile
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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
#!/bin/csh -f
setenv START_OF_COMPILE "`date`"
cont1:
if ( ! -e configure.wrf ) then
echo ""
echo "You must run the 'configure' script before running the 'compile' script!"
echo "Exiting..."
echo ""
exit 1
endif
#----------------------------------
# identify the commit where the compiled code came from
git log >& /dev/null
if ($status) then
set v='No git found or not a git repository, git commit version not available.'
else
set v=(git `git log | head -1` `git diff --shortstat`) >& /dev/null
endif
echo " CHARACTER (LEN=*), PARAMETER :: commit_version = '$v'" > inc/commit_decl
#----------------------------------
if ( ! $?WRF_KPP ) setenv WRF_KPP 0
if ( $WRF_KPP == 1 ) then
chem/KPP/compile_wkc
endif
#---------------------------------
set ZAP = .foofoo
set arglist=""
set prev_was_j = false
set count = 0
foreach a ( $argv )
@ count ++
if ( "$a" == "-h" ) then
goto hlp
else if ( "$a" == "all_wrfvar" || "$a" == "gen_be" ) then
set arglist = ( $arglist $a )
grep "DA_CORE=1" configure.wrf > /dev/null
if ( ! $status ) then
# If configuration file has DA_CORE=1, set WRF_DA_CORE to 1
setenv WRF_DA_CORE 1
else
# If the user ran the configure script without the "wrfda" option, "./compile all_wrfvar"
# will fail in non-obvious ways, and some executables will be created incorrectly.
# Let's just quit right away to avoid the hassle.
echo ""
echo "To build WRFDA, you must run the 'configure' script with the 'wrfda' option:"
echo " ./configure wrfda"
echo ""
echo "Exiting..."
echo ""
exit 1
endif
else if ( "$a" == "em_real" ) then
set arglist = ( $arglist $a )
set ZAP = ( main/wrf.exe main/real.exe main/ndown.exe main/tc.exe )
else if ( `echo $a | cut -c 1-3` == "em_" ) then
set arglist = ( $arglist $a )
set ZAP = ( main/wrf.exe main/ideal.exe )
else if ( "$a" == "io" ) then
set arglist = ( $arglist $a )
else if ( "$a" == "wrfplus" ) then
set arglist = ( $arglist $a )
set ZAP = ( main/wrfplus.exe )
setenv WRF_EM_CORE 1
setenv WRF_PLUS_CORE 1
else if ( "$a" == "wrf" ) then
set arglist = ( $arglist $a )
set ZAP = ( main/wrf.exe )
else if ( "$a" == "-j" ) then
@ JJ = $count + 1
setenv J "-j $argv[$JJ]"
set prev_was_j = true
else if ( "$prev_was_j" == "true" ) then
set prev_was_j = false
else if ( "$a" == "emi_conv" ) then
set arglist = ( $arglist $a )
set ZAP = ( chem/convert_emiss.exe )
else
echo "This option is not recognized: $a"
exit ( 1 )
endif
end
if ( "$arglist" == "" ) then
goto hlp
else
unsetenv A2DCASE
setenv A2DCASE `echo $arglist | grep 2d`
unsetenv A1DCASE
setenv A1DCASE `echo $arglist | grep scm`
if ( ! ( $?WRF_EM_CORE || $?WRF_PLUS_CORE ) ) then
echo 'Neither WRF_EM_CORE nor WRF_PLUS_CORE'
echo ' are explicitly specified in shell environment.... '
setenv WRF_EM_CORE 1
setenv WRF_COAMPS_CORE 0
setenv WRF_EXP_CORE 0
setenv WRF_PLUS_CORE 0
endif
# these settings get passed down through the environment in the
# calls to Make
if ( ! $?WRF_HYDRO ) then
setenv WRF_HYDRO 0
setenv LIB_WRF_HYDRO ""
else
if($WRF_HYDRO == 1) then
setenv LIB_WRF_HYDRO "-L../hydro/lib -lHYDRO"
else
setenv LIB_WRF_HYDRO ""
endif
endif
if ( ! $?WRF_DA_CORE ) setenv WRF_DA_CORE 0
if ( ! $?WRF_EM_CORE ) setenv WRF_EM_CORE 0
if ( ! $?WRF_COAMPS_CORE ) setenv WRF_COAMPS_CORE 0
if ( ! $?WRF_EXP_CORE ) setenv WRF_EXP_CORE 0
if ( ! $?WRF_PLUS_CORE ) setenv WRF_PLUS_CORE 0
if ( ! $?WRF_CHEM ) setenv WRF_CHEM 0
if ( ! $?WRF_DFI_RADAR ) setenv WRF_DFI_RADAR 0
if ( ! $?WRF_CONVERT ) then
if ( "$arglist" == "convert_em" ) then
setenv WRF_CONVERT 1
setenv WRF_EM_CORE 0
else
setenv WRF_CONVERT 0
endif
endif
# temporary - until all vestiges of NMM ifdefs are gone from WRF source
setenv WRF_NMM_CORE 0
setenv WRF_NMM_NEST 0
setenv HWRF 0
if ( ! $?DA_ARCHFLAGS ) setenv DA_ARCHFLAGS ""
# if ( ( $WRF_CHEM == 1 ) && ( $WRF_DA_CORE == 1 ) ) then
# echo " "
# echo "WRFDA can not be compiled with WRF_CHEM=1"
# echo "unset the WRF_CHEM env variable."
# echo " "
# exit
# endif
if ( ( $WRF_DA_CORE == 1 ) && ( ! -d var ) ) then
echo " "
echo "You need to download and untar the Var code, or"
echo "unset the WRF_DA_CORE env variable."
echo " "
exit
endif
if ( ( $WRF_CHEM == 1 ) && ( ! -d chem ) ) then
echo " "
echo "You need to download and untar the chem code, or"
echo "unset the WRF_CHEM env variable."
echo " "
exit
endif
set overwrite=0
if ($WRF_EM_CORE == 0 && ! $WRF_CONVERT == 1 ) then
echo "Cannot compile because both EM core is set to 0."
exit 2
endif
if (($WRF_EM_CORE == 1)&&($WRF_DA_CORE == 0 ) &&($WRF_CHEM == 0 )&&($WRF_CONVERT == 0)&&($WRF_PLUS_CORE == 0) ) then
if ( ! -f Registry/Registry ) then
set overwrite=1
else
head -2 Registry/Registry | tail -1 | grep EM > /dev/null
if ( $status ) then
set overwrite=1
else
set em_time=`ls -1tr Registry | cat -n | grep -w 'Registry\.EM' | grep -v 'Registry.EM.' | awk '{print $1}'`
set rg_time=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'`
if ( $em_time > $rg_time ) set overwrite=1
endif
endif
if ( $overwrite ) then
echo copying Registry/Registry.EM to Registry/Registry
echo '## WARNING: this file is autogenerated from Registry/Registry.EM. Changes may be lost' > Registry/Registry
/bin/cat Registry/Registry.EM >> Registry/Registry
endif
else if ( ($WRF_EM_CORE == 1)&&($WRF_PLUS_CORE == 1) ) then
if ( ! -f Registry/Registry ) then
set overwrite=1
else
head -2 Registry/Registry | tail -1 | grep WRFPLUS > /dev/null
if ( $status ) then
set overwrite=1
else
set em_time=`ls -1tr Registry | cat -n | grep -w 'Registry\.tladj' | grep -v 'Registry.tladj.' | awk '{print $1}'`
set rg_time=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'`
if ( $em_time > $rg_time ) set overwrite=1
endif
endif
if ( $overwrite ) then
echo copying Registry/Registry.tladj to Registry/Registry
echo '## WARNING: this file is autogenerated from Registry/Registry.tladj. Changes may be lost' > Registry/Registry
/bin/cat Registry/Registry.tladj >> Registry/Registry
endif
else if (($WRF_EM_CORE == 1)&&($WRF_CHEM == 1 )&&($WRF_DA_CORE == 0)) then
if ( ! -f Registry/Registry ) then
set overwrite=1
else
head -2 Registry/Registry | tail -1 | grep EM_CHEM > /dev/null
if ( $status ) then
set overwrite=1
else
set em_time=`ls -1tr Registry | cat -n | grep -w 'Registry\.EM_CHEM' | grep -v 'Registry.EM_CHEM.' | awk '{print $1}'`
set rg_time=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'`
if ( $em_time > $rg_time ) set overwrite=1
endif
endif
if ( $overwrite ) then
echo copying Registry/Registry.EM_CHEM to Registry/Registry
echo '## WARNING: this file is autogenerated from Registry/Registry.EM_CHEM. Changes may be lost' > Registry/Registry
/bin/cat Registry/Registry.EM_CHEM >> Registry/Registry
endif
else if (($WRF_EM_CORE == 1)&&($WRF_DFI_RADAR == 1 )) then
if ( ! -f Registry/Registry ) then
set overwrite=1
endif
if ( $overwrite ) then
echo copying Registry/Registry.EM to Registry/Registry
echo '## WARNING: this file is autogenerated from Registry/Registry.EM. Changes may be lost' > Registry/Registry
/bin/cat Registry/Registry.EM >> Registry/Registry
endif
else if (($WRF_EM_CORE == 0)&&($WRF_CONVERT == 1 )) then
if ( ! -f Registry/Registry ) then
set overwrite=1
else
head -2 Registry/Registry | tail -1 | grep EM_CONVERT > /dev/null
if ( $status ) then
set overwrite=1
else
set em_time=`ls -1tr Registry | cat -n | grep -w 'Registry\.EM_CONVERT' | grep -v 'Registry.EM_CONVERT.' | awk '{print $1}'`
set rg_time=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'`
if ( $em_time > $rg_time ) set overwrite=1
endif
endif
if ( $overwrite ) then
echo copying Registry/Registry.CONVERT to Registry/Registry
echo '## WARNING: this file is autogenerated from Registry/Registry.CONVERT. Changes may be lost' > Registry/Registry
/bin/cat Registry/Registry.CONVERT >> Registry/Registry
endif
else if ( $WRF_DA_CORE == 1 ) then
if ( ! -f Registry/Registry ) then
set overwrite=1
else
if ( $WRF_CHEM == 1 ) then
head -2 Registry/Registry | tail -1 | grep WRFCHEMVAR > /dev/null
else
head -2 Registry/Registry | tail -1 | grep WRFVAR > /dev/null
endif
if ( $status ) then
set overwrite=1
endif
endif
if ( $overwrite ) then
/bin/rm -f Registry/Registry.rconfig
/bin/cat Registry/Registry.EM_COMMON | grep '^rconfig' > Registry/Registry.rconfig
if ($WRF_CHEM == 1 ) then
echo copying Registry/Registry.wrfchemvar to Registry/Registry
echo '## WARNING: this file is autogenerated from Registry/Registry.wrfchemvar Registry/Registry.EM_COMMON.var. Changes may be lost' > Registry/Registry
/bin/cat Registry/Registry.wrfchemvar >> Registry/Registry
else
echo copying Registry/Registry.wrfvar to Registry/Registry
echo '## WARNING: this file is autogenerated from Registry/Registry.wrfvar Registry/Registry.EM_COMMON.var. Changes may be lost' > Registry/Registry
/bin/cat Registry/Registry.wrfvar >> Registry/Registry
endif
endif
set wrfpluspath = ( `grep "^WRFPLUSPATH" configure.wrf | cut -d"=" -f2-` )
if ( $wrfpluspath == "" ) then
setenv WRFPLUS_INC " "
else
setenv WRFPLUS_DIR $wrfpluspath
setenv WRFPLUS_INC "-I${wrfpluspath}/dyn_em -I${wrfpluspath}/main -I${wrfpluspath}/frame -I${wrfpluspath}/share -I${wrfpluspath}/wrftladj"
endif
setenv BUFR 1
set CRTM = ( `grep "\-DCRTM" configure.wrf | sed -e 's/\\//g' | sed 's/-//g' ` )
if ( $CRTM != "" ) then
echo " "
echo "Will compile with CRTM library"
echo " "
if ( ! $?BUFR ) then
echo " "
echo "BUFR library is needed for radiance data ingest."
echo "setting BUFR=1"
echo " "
setenv BUFR 1
endif
setenv CRTM_CPP "-DCRTM"
setenv CRTM_LIB "-L../external/crtm_2.3.0/libsrc -lCRTM"
setenv CRTM_SRC "-I../external/crtm_2.3.0/libsrc"
#setenv SFC_CRTM `grep '^SFC' configure.wrf | awk '{print $3}' | sed -e 's/\// /g' | awk '{print $NF}'`
#setenv ABI_CRTM `grep '^SFC' configure.wrf | sed -n 's/.*\(\-m[0-9]\{2\}\).*/\1/p'`
setenv CRTM 1
else
echo " "
echo "Compiling WRFDA without CRTM library"
echo " "
setenv CRTM_CPP " "
setenv CRTM_LIB " "
setenv CRTM_SRC " "
setenv CRTM 0
endif
set hdf5path = ( `grep "^HDF5PATH" configure.wrf | cut -d"=" -f2-` )
if ( $hdf5path == "" ) then
setenv HDF5_INC ""
unsetenv HDF5
else
echo " "
echo "Compiling with HDF5 libraries in:"
echo $hdf5path
echo " "
setenv HDF5_INC "-I${hdf5path}/include"
setenv HDF5 1
endif
set RTTOV = ( `grep "^RTTOVPATH" configure.wrf | cut -d"=" -f2-` )
if ( $RTTOV == "" ) then
setenv RTTOV_LIB " "
setenv RTTOV_SRC " "
unsetenv RTTOV
else
if ( $hdf5path == "" ) then
echo "As of version 12.1 of RTTOV, WRFDA requires HDF5 in order utilize the RTTOV library."
echo "RTTOV emissivity atlas files are now provided only in HDF5 format."
echo "Please supply an HDF5 path prior to configure or unset RTTOV."
exit 1
else
echo " "
echo "Compiling with RTTOV libraries in:"
echo $RTTOV
echo " "
if ( ! $?BUFR ) then
echo " "
echo "BUFR library is needed for radiance data ingest."
echo "setting BUFR=1"
echo " "
setenv BUFR 1
endif
if ( -e ${RTTOV}/lib/librttov12_main.a ) then
setenv RTTOV_LIB "-L${hdf5path}/lib -lhdf5_hl_fortran -lhdf5_hl -lhdf5_fortran -lhdf5 -lhdf5_hl_f90cstub -lhdf5_f90cstub -lhdf5_hl_cpp -L${RTTOV}/lib -lrttov12_coef_io -lrttov12_emis_atlas -lrttov12_main -lrttov12_hdf"
else
echo "Can not find a compatible RTTOV library! Please ensure that your RTTOV build was successful,"
echo "your 'RTTOV' environment variable is set correctly, and you are using a supported version of RTTOV."
echo "Current supported version(s): 12.1"
exit 1
endif
setenv RTTOV_SRC "-I${RTTOV}/include -I${RTTOV}/mod"
endif
endif
if ( $?CLOUD_CV ) then
setenv CLOUD_CV_CPP "-DCLOUD_CV"
else
setenv CLOUD_CV_CPP " "
endif
if ( $?BUFR ) then
setenv BUFR_CPP "-DBUFR"
setenv BUFR_LIB "-L../external/bufr -lbufr"
else
setenv BUFR_CPP " "
setenv BUFR_LIB " "
endif
if ( $?WAVELET ) then
setenv WAVELET_LIB "../external/wavelet/libWavelet.a ../external/wavelet/lib_wavelet.a"
else
setenv WAVELET_LIB " "
endif
if ( $?MADIS ) then
setenv MADIS_CPP "-DMADIS"
setenv MADIS_STATIC ${MADIS}/static
setenv MADIS_LIB "-L${MADIS} -lmadis"
else
setenv MADIS_CPP " "
setenv MADIS_LIB " "
endif
setenv DA_ARCHFLAGS "${BUFR_CPP} ${MADIS_CPP} -DFFTPACK -DNORESHAPE"
endif
echo " "
echo "============================================================================================== "
echo " "
cat inc/version_decl | cut -d"'" -f2 | head -1
cat inc/commit_decl | cut -d"'" -f2
echo " "
echo -n "Compiling: "
if ( $WRF_DA_CORE ) echo -n "WRF_DA_CORE "
if ( $WRF_EM_CORE ) echo -n "WRF_EM_CORE "
if ( $WRF_COAMPS_CORE ) echo -n "WRF_COAMPS_CORE "
if ( $WRF_EXP_CORE ) echo -n "WRF_EXP_CORE "
echo " "
env | grep LARGE
echo " "
uname -a
echo " "
set comp = ( `grep "^SFC" configure.wrf | cut -d"#" -f1 | cut -d"=" -f2-` )
$comp[1] -V >& /dev/null
if ( $status == 0 ) then
$comp[1] -V
else
$comp[1] --version >& /dev/null
if ( $status == 0 ) then
$comp[1] --version
else
echo "Not sure how to figure out the version of this compiler: $comp[1]"
endif
endif
echo " "
echo "============================================================================================== "
echo " "
if ( ! $?WRF_SRC_ROOT_DIR ) setenv WRF_SRC_ROOT_DIR `pwd`
# new dec 2009. check to see if make supports parallel -j option
make -j 2 >& /dev/null
if ( $status == 0 ) then # Parallel make ok
if ( ! $?J ) then # J not defined
echo setting parallel make -j 2 # Set default to 2
setenv J "-j 2"
else
# J is defined, check that it is a correctly formed variable
set first2chars = `echo $J | cut -c 1-2` # Are 1st two chars are -j?
set second_word = `echo $J | cut -d" " -f2` # Is second word a number?
if ( "$first2chars" == "-j" ) then
if ( ( "$second_word" >= "2" ) && \
( "$second_word" <= "20" ) ) then
echo setting parallel make $J
else if ( "$second_word" == "1" ) then
echo setting serial make $J
else
echo "badly formed -j option for parallel make: $J"
echo "or you set the number of processors above 20 "
echo setting parallel make -j 2 # Set default to 2
setenv J "-j 2"
endif
else
if ( "$J" == "" ) then # J blank is OK
echo setting serial make $J
else
echo "parallel option for make is -j, you entered: $first2chars"
echo setting parallel make -j 2 # Set default to 2
setenv J "-j 2"
endif
endif
endif
else
echo not setting parallel make
endif
/bin/rm -f $ZAP >& /dev/null
make $arglist A2DCASE="$A2DCASE" WRF_SRC_ROOT_DIR="$WRF_SRC_ROOT_DIR"
endif
exit 0
hlp:
echo ' '
echo 'Usage:'
echo ' '
echo ' compile [-j n] wrf compile wrf in run dir (NOTE: no real.exe, ndown.exe, or ideal.exe generated)'
echo ' '
echo ' or choose a test case (see README_test_cases for details) :'
foreach d ( `/bin/ls test` )
if ( "$d" != "CVS" ) then
echo " compile [-j n] $d"
endif
end
echo ' '
echo ' compile -j n parallel make using n tasks if supported (default 2)'
echo ' compile -h help message'