-
Notifications
You must be signed in to change notification settings - Fork 13
/
Config_new.pl
736 lines (693 loc) · 24.7 KB
/
Config_new.pl
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
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
#!/usr/bin/perl
#
# Configuration script for WRF prototype code
#
# Be sure to run as ./configure (to avoid getting a system configure command by mistake)
#
select((select(STDOUT), $|=1)[0]);
$sw_perl_path = perl ;
$sw_netcdf_path = "" ;
$sw_pnetcdf_path = "" ;
$sw_phdf5_path="";
$sw_jasperlib_path="";
$sw_jasperinc_path="";
$sw_esmflib_path="";
$sw_esmfinc_path="";
$sw_ldflags="";
$sw_compileflags="";
$sw_opt_level="";
$sw_rwordsize="\$\(NATIVE_RWORDSIZE\)";
$sw_rttov_flag = "" ;
$sw_rttov_inc = "" ;
$sw_crtm_flag = "" ;
$sw_4dvar_flag = "" ;
$sw_wavelet_flag = "" ;
$WRFCHEM = 0 ;
$sw_os = "ARCH" ; # ARCH will match any
$sw_mach = "ARCH" ; # ARCH will match any
$sw_wrf_core = "" ;
$sw_da_core = "-DDA_CORE=\$\(WRF_DA_CORE\)" ;
$sw_nmm_core = "-DNMM_CORE=\$\(WRF_NMM_CORE\)" ;
$sw_em_core = "-DEM_CORE=\$\(WRF_EM_CORE\)" ;
$sw_exp_core = "-DEXP_CORE=\$\(WRF_EXP_CORE\)" ;
$sw_coamps_core = "-DCOAMPS_CORE=\$\(WRF_COAMPS_CORE\)" ;
$sw_dmparallel = "" ;
$sw_ompparallel = "" ;
$sw_stubmpi = "" ;
$sw_usenetcdff = "" ; # for 3.6.2 and greater, the fortran bindings might be in a separate lib file
$sw_time = "" ; # name of a timer to time fortran compiles, e.g. timex or time
$sw_ifort_r8 = 0 ;
$sw_hdf5 = "-lhdf5 -lhdf5_hl";
$sw_zlib = "-lz";
$sw_dep_lib_path = "";
$sw_gpfs_path = "";
$sw_gpfs_lib = "-lgpfs";
$sw_curl_path = "";
$sw_curl_lib = "-lcurl";
$sw_terrain_and_landuse = "";
while ( substr( $ARGV[0], 0, 1 ) eq "-" )
{
if ( substr( $ARGV[0], 1, 5 ) eq "perl=" )
{
$sw_perl_path = substr( $ARGV[0], 6 ) ;
}
if ( substr( $ARGV[0], 1, 7 ) eq "netcdf=" )
{
$sw_netcdf_path = substr( $ARGV[0], 8 ) ;
}
if ( substr( $ARGV[0], 1, 13 ) eq "dep_lib_path=" )
{
$sw_dep_lib_path = substr( $ARGV[0], 14 ) ;
$sw_dep_lib_path =~ s/\r|\n/ /g ;
}
if ( substr( $ARGV[0], 1, 5 ) eq "gpfs=" )
{
$sw_gpfs_path = substr( $ARGV[0], 6 ) ;
if ( $sw_gpfs_path ne "" )
{
if ( substr( $sw_gpfs_path, -1, 1 ) eq "/" )
{
$sw_gpfs_path = substr($sw_gpfs_path, 0, length($sw_gpfs_path)-1 ) ;
}
}
}
if ( substr( $ARGV[0], 1, 5 ) eq "curl=" )
{
$sw_curl_path = substr( $ARGV[0], 6 ) ;
if ( $sw_curl_path ne "" )
{
if ( substr( $sw_curl_path, -1, 1 ) eq "/" )
{
$sw_curl_path = substr($sw_curl_path, 0, length($sw_curl_path)-1 ) ;
}
}
}
if ( substr( $ARGV[0], 1, 8 ) eq "pnetcdf=" )
{
$sw_pnetcdf_path = substr( $ARGV[0], 9 ) ;
}
if ( substr( $ARGV[0], 1, 6 ) eq "phdf5=" )
{
$sw_phdf5_path = substr( $ARGV[0], 7 ) ;
}
if ( substr( $ARGV[0], 1, 3 ) eq "os=" )
{
$sw_os = substr( $ARGV[0], 4 ) ;
}
if ( substr( $ARGV[0], 1, 5 ) eq "mach=" )
{
$sw_mach = substr( $ARGV[0], 6 ) ;
}
if ( substr( $ARGV[0], 1, 10 ) eq "opt_level=" )
{
$sw_opt_level = substr( $ARGV[0], 11 ) ;
}
if ( substr( $ARGV[0], 1, 11 ) eq "USENETCDFF=" )
{
$sw_usenetcdff = substr( $ARGV[0], 12 ) ;
}
if ( substr( $ARGV[0], 1, 5 ) eq "time=" )
{
$sw_time = substr( $ARGV[0], 6 ) ;
}
if ( substr( $ARGV[0], 1, 8 ) eq "ldflags=" )
{
$sw_ldflags = substr( $ARGV[0], 9 ) ;
# multiple options separated by spaces are passed in from sh script
# separated by ! instead. Replace with spaces here.
$sw_ldflags =~ s/!/ /g ;
}
if ( substr( $ARGV[0], 1, 9 ) eq "wrf_core=" )
{
$sw_wrf_core = substr( $ARGV[0], 10 ) ;
if ( index ( $sw_wrf_core , "EM_CORE" ) > -1 )
{
$sw_em_core = "-DEM_CORE=1" ;
$sw_da_core = "-DDA_CORE=0" ;
$sw_nmm_core = "-DNMM_CORE=0" ;
$sw_exp_core = "-DEXP_CORE=0" ;
$sw_coamps_core = "-DCOAMPS_CORE=0" ;
}
if ( index ( $sw_wrf_core , "DA_CORE" ) > -1 )
{
$sw_em_core = "-DEM_CORE=1" ;
$sw_da_core = "-DDA_CORE=1" ;
$sw_nmm_core = "-DNMM_CORE=0" ;
$sw_exp_core = "-DEXP_CORE=0" ;
$sw_coamps_core = "-DCOAMPS_CORE=0" ;
}
if ( index ( $sw_wrf_core , "4D_DA_CORE" ) > -1 )
{
$sw_em_core = "-DEM_CORE=1" ;
$sw_da_core = "-DDA_CORE=1" ;
$sw_nmm_core = "-DNMM_CORE=0" ;
$sw_exp_core = "-DEXP_CORE=0" ;
$sw_coamps_core = "-DCOAMPS_CORE=0" ;
}
if ( index ( $sw_wrf_core , "NMM_CORE" ) > -1 )
{
$sw_em_core = "-DEM_CORE=0" ;
$sw_da_core = "-DDA_CORE=0" ;
$sw_nmm_core = "-DNMM_CORE=1" ;
$sw_exp_core = "-DEXP_CORE=0" ;
$sw_coamps_core = "-DCOAMPS_CORE=0" ;
}
if ( index ( $sw_wrf_core , "EXP_CORE" ) > -1 )
{
$sw_em_core = "-DEM_CORE=0" ;
$sw_da_core = "-DDA_CORE=0" ;
$sw_nmm_core = "-DNMM_CORE=0" ;
$sw_exp_core = "-DEXP_CORE=1" ;
$sw_coamps_core = "-DCOAMPS_CORE=0" ;
}
if ( index ( $sw_wrf_core , "COAMPS_CORE" ) > -1 )
{
$sw_em_core = "-DEM_CORE=0" ;
$sw_da_core = "-DDA_CORE=0" ;
$sw_nmm_core = "-DNMM_CORE=0" ;
$sw_exp_core = "-DEXP_CORE=0" ;
$sw_coamps_core = "-DCOAMPS_CORE=1" ;
}
}
if ( substr( $ARGV[0], 1, 13 ) eq "compileflags=" )
{
$sw_compileflags = substr( $ARGV[0], 14 ) ;
$sw_compileflags =~ s/!/ /g ;
# look for each known option
$where_index = index ( $sw_compileflags , "-DWRF_CHEM" ) ;
if ( $where_index eq -1 )
{
$WRFCHEM = 0 ;
}
else
{
$WRFCHEM = 1 ;
}
}
if ( substr( $ARGV[0], 1, 11 ) eq "dmparallel=" )
{
$sw_dmparallel=substr( $ARGV[0], 12 ) ;
}
if ( substr( $ARGV[0], 1, 12 ) eq "ompparallel=" )
{
$sw_ompparallel=substr( $ARGV[0], 13 ) ;
}
shift @ARGV ;
}
$sw_fc = "\$(SFC)" ;
$sw_cc = "\$(SCC)" ;
$sw_comms_lib = "" ;
$sw_comms_include = "" ;
$sw_dmparallelflag = "" ;
$sw_nest_opt = "" ;
$sw_comms_external = "gen_comms_serial module_dm_serial" ;
if ( $sw_dmparallel eq "RSL_LITE" )
{
$sw_fc = "\$(DM_FC)" ;
$sw_cc = "\$(DM_CC)" ;
$sw_dmparallelflag = "-DDM_PARALLEL" ;
$sw_comms_lib = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a" ;
$sw_comms_external = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a gen_comms_rsllite module_dm_rsllite" ;
$sw_comms_include = "-I\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE" ;
}
# The jasper library is required to build Grib2 I/O. User must set
# environment variables JASPERLIB and JASPERINC to paths to library and
# include files to enable this feature prior to running configure.
$I_really_want_to_output_grib2_from_WRF = "FALSE" ;
if ( $ENV{JASPERLIB} && $ENV{JASPERINC} && $I_really_want_to_output_grib2_from_WRF eq "TRUE" )
{
printf "Configuring to use jasper library to build Grib2 I/O...\n" ;
printf(" \$JASPERLIB = %s\n",$ENV{JASPERLIB});
printf(" \$JASPERINC = %s\n",$ENV{JASPERINC});
$sw_jasperlib_path = $ENV{JASPERLIB};
$sw_jasperinc_path = $ENV{JASPERINC};
}
else
{
if ( $ENV{JASPERLIB} && $ENV{JASPERINC} )
{
printf "\n\nIf you REALLY want Grib2 output from WRF, modify the arch/Config_new.pl script.\n" ;
printf "Right now you are not getting the Jasper lib, from the environment, compiled into WRF.\n\n" ;
}
else
{
printf "\$JASPERLIB or \$JASPERINC not found in environment, configuring to build without grib2 I/O...\n" ;
}
}
# When compiling DA code, we need to always use 8-byte reals.
if ( $ENV{WRF_DA_CORE} eq "1" || $sw_da_core eq "-DDA_CORE=1" )
{
$sw_rwordsize = "8";
if ( $ENV{CRTM} )
{
$sw_crtm_flag = "-DCRTM";
}
if ( $ENV{RTTOV} )
{
$sw_rttov_flag = "-DRTTOV";
$sw_rttov_inc = "-I$ENV{RTTOV}/include -I$ENV{RTTOV}/mod";
}
if ( $sw_wrf_core eq "4D_DA_CORE" )
{
$sw_4dvar_flag = "-DVAR4D";
}
if ( $ENV{WAVELET} )
{
$sw_wavelet_flag = "-DWAVELET";
}
}
# A separately-installed ESMF library is required to build the ESMF
# implementation of WRF IOAPI in external/io_esmf. This is needed
# to couple WRF with other ESMF components. User must set environment
# variables ESMFLIB and ESMFINC to paths ESMF to library and include
# files to enable this feature prior to running configure.
if ( $ENV{ESMFLIB} && $ENV{ESMFINC} )
{
printf "Configuring to use ESMF library to build WRF...\n" ;
printf "WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING\n" ;
printf "WARNING: THIS IS AN EXPERIMENTAL CONFIGURATION\n" ;
printf "WARNING: IT DOES NOT WORK WITH NESTING\n" ;
printf "WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING\n" ;
printf(" \$ESMFLIB = %s\n",$ENV{ESMFLIB});
printf(" \$ESMFINC = %s\n",$ENV{ESMFINC});
$sw_esmflib_path = $ENV{ESMFLIB};
$sw_esmfinc_path = $ENV{ESMFINC};
$sw_esmf_ldflag = "yes" ;
}
# parse the configure.wrf file
$validresponse = 0 ;
if ( $sw_wrf_core eq "4D_DA_CORE" )
{ @platforms = qw ( serial dmpar ) ; }
else
{ @platforms = qw ( serial smpar dmpar dm+sm ) ; }
# Display the choices to the user and get selection
until ( $validresponse ) {
printf "------------------------------------------------------------------------\n" ;
printf "Please select from among the following supported platforms.\n\n" ;
$opt = 1 ;
open CONFIGURE_DEFAULTS, "< ./arch/configure_new.defaults"
or die "Cannot open ./arch/configure_new.defaults for reading" ;
while ( <CONFIGURE_DEFAULTS> )
{
for $paropt ( @platforms )
{
if ( substr( $_, 0, 5 ) eq "#ARCH"
&& ( index( $_, $sw_os ) >= 0 ) && ( index( $_, $sw_mach ) >= 0 )
&& ( index($_, $paropt) >= 0 ) )
{
$optstr[$opt] = substr($_,6) ;
$optstr[$opt] =~ s/^[ ]*// ;
$optstr[$opt] =~ s/#.*$//g ;
chomp($optstr[$opt]) ;
$optstr[$opt] = $optstr[$opt]." (".$paropt.")" ;
if ( substr( $optstr[$opt], 0,4 ) ne "NULL" )
{
printf " %2d. %s\n",$opt,$optstr[$opt] ;
$opt++ ;
}
}
}
}
close CONFIGURE_DEFAULTS ;
$opt -- ;
printf "\nEnter selection [%d-%d] : ",1,$opt ;
$response = <STDIN> ;
if ( $response == -1 ) { exit ; }
if ( $response >= 1 && $response <= $opt )
{ $validresponse = 1 ; }
else
{ printf("\nInvalid response (%d)\n",$response);}
}
printf "------------------------------------------------------------------------\n" ;
$optchoice = $response ;
if ( $response == 2 || $response == 3 ) {
if ( $ENV{'TERRAIN_AND_LANDUSE'} eq "1" && index($sw_wrf_core, "EM_CORE") > -1 ) {
$sw_terrain_and_landuse =" -DTERRAIN_AND_LANDUSE" ;
}
}
open CONFIGURE_DEFAULTS, "cat ./arch/configure_new.defaults |" ;
$latchon = 0 ;
while ( <CONFIGURE_DEFAULTS> )
{
if ( substr( $_, 0, 5 ) eq "#ARCH" && $latchon == 1 )
{
close CONFIGURE_DEFAULTS ;
if ( $sw_opt_level eq "-f" ) {
open CONFIGURE_DEFAULTS, "cat ./arch/postamble_new ./arch/noopt_exceptions_f |" or die "horribly" ;
} else {
open CONFIGURE_DEFAULTS, "cat ./arch/postamble_new ./arch/noopt_exceptions |" or die "horribly" ;
}
}
$_ =~ s:CONFIGURE_NMM_CORE:$sw_nmm_core:g ;
if ( $latchon == 1 )
{
$_ =~ s/CONFIGURE_PERL_PATH/$sw_perl_path/g ;
$_ =~ s/CONFIGURE_NETCDF_PATH/$sw_netcdf_path/g ;
$_ =~ s/CONFIGURE_PNETCDF_PATH/$sw_pnetcdf_path/g ;
$_ =~ s/CONFIGURE_PHDF5_PATH/$sw_phdf5_path/g ;
$_ =~ s/CONFIGURE_LDFLAGS/$sw_ldflags/g ;
$_ =~ s/CONFIGURE_COMPILEFLAGS/$sw_compileflags/g ;
$_ =~ s/CONFIGURE_RWORDSIZE/$sw_rwordsize/g ;
$_ =~ s/CONFIGURE_FC/$sw_time $sw_fc/g ;
$_ =~ s/CONFIGURE_CC/$sw_cc/g ;
$_ =~ s/CONFIGURE_COMMS_LIB/$sw_comms_lib/g ;
$_ =~ s/CONFIGURE_COMMS_INCLUDE/$sw_comms_include/g ;
$_ =~ s/CONFIGURE_COMMS_EXTERNAL/$sw_comms_external/g ;
if ( $sw_os ne "CYGWIN_NT" ) {
$_ =~ s/#NOWIN// ;
}
$_ =~ s/CONFIGURE_DMPARALLEL/$sw_dmparallelflag/g ;
$_ =~ s/CONFIGURE_STUBMPI/$sw_stubmpi/g ;
$_ =~ s/CONFIGURE_NESTOPT/$sw_nest_opt/g ;
$_ =~ s/CONFIGURE_4DVAR_FLAG/$sw_4dvar_flag/g ;
$_ =~ s/CONFIGURE_CRTM_FLAG/$sw_crtm_flag/g ;
$_ =~ s/CONFIGURE_RTTOV_FLAG/$sw_rttov_flag/g ;
$_ =~ s/CONFIGURE_RTTOV_INC/$sw_rttov_inc/g ;
$_ =~ s/CONFIGURE_WAVELET_FLAG/$sw_wavelet_flag/g ;
if ( $sw_ifort_r8 ) {
$_ =~ s/^PROMOTION.*=/PROMOTION = -r8 /g ;
}
if ( $sw_dmparallel ne "" && ($_ =~ /^DMPARALLEL[=\t ]/) ) {
$_ =~ s/#// ;
}
if ( $sw_ompparallel ne "" && ( $_ =~ /^OMPCPP[=\t ]/ || $_ =~ /^OMPCC[=\t ]/ || $_ =~ /^OMP[=\t ]/ ) ) {
$_ =~ s/#// ;
$_ =~ s/#// ;
$_ =~ s/#// ;
}
if ( $sw_netcdf_path )
{ $_ =~ s/CONFIGURE_WRFIO_NF/wrfio_nf/g ;
$_ =~ s:CONFIGURE_NETCDF_FLAG:-DNETCDF: ;
if ( $ENV{NETCDF_LDFLAGS} ) {
$_ =~ s:CONFIGURE_NETCDF_LIB_PATH:\$\(WRF_SRC_ROOT_DIR\)/external/io_netcdf/libwrfio_nf.a $ENV{NETCDF_LDFLAGS} : ;
} elsif ( $sw_os eq "Interix" ) {
$_ =~ s:CONFIGURE_NETCDF_LIB_PATH:\$\(WRF_SRC_ROOT_DIR\)/external/io_netcdf/libwrfio_nf.a -L$sw_netcdf_path/lib $sw_usenetcdff -lnetcdf : ;
} else {
$_ =~ s:CONFIGURE_NETCDF_LIB_PATH:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_netcdf -lwrfio_nf -L$sw_netcdf_path/lib $sw_usenetcdff -lnetcdf : ;
}
}
else
{ $_ =~ s/CONFIGURE_WRFIO_NF//g ;
$_ =~ s:CONFIGURE_NETCDF_FLAG::g ;
$_ =~ s:CONFIGURE_NETCDF_LIB_PATH::g ;
}
if ( $sw_pnetcdf_path )
{ $_ =~ s/CONFIGURE_WRFIO_PNF/wrfio_pnf/g ;
$_ =~ s:CONFIGURE_PNETCDF_FLAG:-DPNETCDF: ;
if ( $sw_os eq "Interix" ) {
$_ =~ s:CONFIGURE_PNETCDF_LIB_PATH:\$\(WRF_SRC_ROOT_DIR\)/external/io_pnetcdf/libwrfio_pnf.a -L$sw_pnetcdf_path/lib -lpnetcdf: ;
} else {
$_ =~ s:CONFIGURE_PNETCDF_LIB_PATH:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_pnetcdf -lwrfio_pnf -L$sw_pnetcdf_path/lib -lpnetcdf: ;
}
}
else
{ $_ =~ s/CONFIGURE_WRFIO_PNF//g ;
$_ =~ s:CONFIGURE_PNETCDF_FLAG::g ;
$_ =~ s:CONFIGURE_PNETCDF_LIB_PATH::g ;
}
if ( $sw_phdf5_path )
{ $_ =~ s/CONFIGURE_WRFIO_PHDF5/wrfio_phdf5/g ;
$_ =~ s:CONFIGURE_PHDF5_FLAG:-DPHDF5: ;
$_ =~ s:CONFIGURE_PHDF5_LIB_PATH:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_phdf5 -lwrfio_phdf5 -L$sw_phdf5_path/lib -lhdf5_fortran -lhdf5 -lm -lz -L$sw_phdf5_path/lib -lsz: ;
}
else
{ $_ =~ s/CONFIGURE_WRFIO_PHDF5//g ;
$_ =~ s:CONFIGURE_PHDF5_FLAG::g ;
$_ =~ s:CONFIGURE_PHDF5_LIB_PATH::g ;
}
if ( $sw_jasperlib_path && $sw_jasperinc_path )
{ $_ =~ s/CONFIGURE_WRFIO_GRIB2/wrfio_grib2/g ;
$_ =~ s:CONFIGURE_GRIB2_FLAG:-DGRIB2:g ;
$_ =~ s:CONFIGURE_GRIB2_INC:-I$sw_jasperinc_path:g ;
$_ =~ s:CONFIGURE_GRIB2_LIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_grib2 -lio_grib2 -L$sw_jasperlib_path -ljasper:g ;
}
else
{ $_ =~ s/CONFIGURE_WRFIO_GRIB2//g ;
$_ =~ s:CONFIGURE_GRIB2_FLAG::g ;
$_ =~ s:CONFIGURE_GRIB2_INC::g ;
$_ =~ s:CONFIGURE_GRIB2_LIB::g ;
}
if ( $sw_terrain_and_landuse )
{
$_ =~ s/CONFIGURE_TERRAIN_AND_LANDUSE/$sw_terrain_and_landuse/g;
}
else
{
$_ =~ s:CONFIGURE_TERRAIN_AND_LANDUSE::g;
}
# ESMF substitutions in configure.defaults
if ( $sw_esmflib_path && $sw_esmfinc_path )
{
$_ =~ s:CONFIGURE_ESMF_FLAG:-DESMFIO:g ;
# pre 5.2.0r
# $_ =~ s:ESMFIOLIB:-L$sw_esmflib_path -lesmf -L\$\(WRF_SRC_ROOT_DIR\)/external/io_esmf -lwrfio_esmf \$\(ESMF_LIB_FLAGS\):g ;
# $_ =~ s:ESMFIOEXTLIB:-L$sw_esmflib_path -lesmf -L\$\(WRF_SRC_ROOT_DIR\)/external/io_esmf -lwrfio_esmf \$\(ESMF_LIB_FLAGS\):g ;
# post 5.2.0r
$_ =~ s:ESMFIOLIB:\$\(ESMF_F90LINKPATHS\) \$\(ESMF_F90ESMFLINKLIBS\) -L\$\(WRF_SRC_ROOT_DIR\)/external/io_esmf -lwrfio_esmf: ;
$_ =~ s:ESMFIOEXTLIB:\$\(ESMF_IO_LIB\): ;
$_ =~ s:ESMFLIBFLAG:\$\(ESMF_LDFLAG\):g ;
# $_ =~ s:ESMFINCLUDEGOESHERE:'include $(ESMFLIB)/esmf.mk': ;
}
else
{
$_ =~ s:CONFIGURE_ESMF_FLAG::g ;
$_ =~ s:ESMFLIBFLAG::g ;
if ( $sw_os eq "Interix" ) {
$_ =~ s:ESMFIOLIB:\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90/libesmf_time.a:g ;
$_ =~ s:ESMFIOEXTLIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90/libesmf_time.a:g ;
} else {
$_ =~ s:ESMFIOLIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90 -lesmf_time:g ;
$_ =~ s:ESMFIOEXTLIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90 -lesmf_time:g ;
}
}
if ( $ENV{HWRF} )
{
$_ =~ s:CONFIGURE_ATMOCN_LIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/atm_ocn -latm_ocn:g ;
$_ =~ s:CONFIGURE_ATMOCN_INC:-I\$\(WRF_SRC_ROOT_DIR\)/external/atm_ocn:g;
$_ =~ s/CONFIGURE_ATMOCN/atm_ocn/g ;
}
else
{
$_ =~ s:CONFIGURE_ATMOCN_LIB::g ;
$_ =~ s/CONFIGURE_ATMOCN//g ;
$_ =~ s:CONFIGURE_ATMOCN_INC::g;
}
if ( $ENV{NETCDF4} )
{ if ( $ENV{NETCDF4} eq "1" )
{
if ( /(^ARCH_LOCAL.*=|^TRADFLAG.*=)/ )
{ $_ =~ s/\r|\n//g;
$_ .= " \$\(NETCDF4_IO_OPTS\)\n" ;
}
if (/^LIB.*=/)
{ $_ =~ s/\r|\n//g ;
$_ .=" \$\(NETCDF4_DEP_LIB\)\n" ;
}
}
}
if ( ! (substr( $_, 0, 5 ) eq "#ARCH") ) { @machopts = ( @machopts, $_ ) ; }
if ( substr( $_, 0, 10 ) eq "ENVCOMPDEF" )
{
@machopts = ( @machopts, "WRF_CHEM\t=\t$WRFCHEM \n" ) ;
}
}
# nesting support
# 0 = no nesting (only selectable for serial and smpar)
# 1 = basic nesting (serial and smpar compile with RSL_LITE and STUBMPI; dmpar and dm+sm use RSL_LITE and MPI)
# 2 = nesting with prescribed moves (add -DMOVE_NESTS to ARCHFLAGS)
# 3 = nesting with prescribed moves (add -DMOVE_NESTS and -DVORTEX_CENTER to ARCHFLAGS)
for $paropt ( @platforms )
{
if ( substr( $_, 0, 5 ) eq "#ARCH" && $latchon == 0
&& ( index( $_, $sw_os ) >= 0 ) && ( index( $_, $sw_mach ) >= 0 )
&& ( index($_, $paropt) >= 0 ) )
{
$x=substr($_,6) ;
$x=~s/^[ ]*// ;
$x =~ s/#.*$//g ;
chomp($x) ;
$x = $x." (".$paropt.")" ;
if ( $x eq $optstr[$optchoice] )
{
if($ENV{WRF_HYDRO} eq 1) {
$tt = `cd hydro; ./wrf_hydro_config "$x" "$paropt"`;
}
$latchon = 1 ;
$sw_ompparallel = "" ;
$sw_dmparallel = "" ;
$validresponse = 0 ;
#only allow parallel netcdf if the user has chosen parallel option
if ( $paropt ne 'dmpar' && $paropt ne 'dm+sm' ) { $sw_pnetcdf_path = "" ; }
#
until ( $validresponse ) {
if ( $paropt eq 'serial' || $paropt eq 'smpar' ) {
printf "Compile for nesting? (0=no nesting, 1=basic, 2=preset moves, 3=vortex following) [default 0]: " ;
} elsif ( $ENV{WRF_NMM_CORE} eq "1" ) {
printf "Compile for nesting? (1=basic, 2=preset moves) [default 1]: " ;
} else {
printf "Compile for nesting? (1=basic, 2=preset moves, 3=vortex following) [default 1]: " ;
}
if ( $ENV{WRF_DA_CORE} eq "1" || $sw_da_core eq "-DDA_CORE=1" ) {
$response = 1 ;
} elsif ( $ENV{HWRF} ) {
printf "HWRF requires moving nests";
$response = "2\n";
} else {
$response = <STDIN> ;
}
printf "\n" ;
lc $response ;
chop $response ;
if ( $response == "" || ($response >= 0 && $response <= 3) )
{ $validresponse = 1 ; }
else
{ printf("\nInvalid response (%d)\n",$response);}
}
if ( $response == "" ) {
if ( ( $paropt eq 'serial' || $paropt eq 'smpar' ) ) { $response = 0 ; }
else { $response = 1 ; }
}
if ( $response == 0 ) {
if ( ! ( $paropt eq 'serial' || $paropt eq 'smpar' ) ) { $response = 1 ; }
}
if ( ( $response == 1 ) || ( $response == 2 ) || ( $response == 3 ) ) {
if ( ( $paropt eq 'serial' || $paropt eq 'smpar' ) ) { # nesting without MPI
$sw_stubmpi = "-DSTUBMPI" ;
if ( $sw_os ne "CYGWIN_NT" ) {
$sw_comms_lib = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a" ;
} else {
$sw_comms_lib = "../external/RSL_LITE/librsl_lite.a" ;
}
$sw_comms_external = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a gen_comms_rsllite module_dm_rsllite" ;
$sw_dmparallel = "RSL_LITE" ;
$sw_dmparallelflag = "-DDM_PARALLEL" ;
}
}
if ( $response == 2 ) {
$sw_nest_opt = "-DMOVE_NESTS" ;
if ( $ENV{'TERRAIN_AND_LANDUSE'} eq "1" ) {
$sw_terrain_and_landuse =" -DTERRAIN_AND_LANDUSE" ;
$sw_nest_opt = $sw_nest_opt . $sw_terrain_and_landuse;
}
} elsif ( $response == 3 ) {
$sw_nest_opt = "-DMOVE_NESTS -DVORTEX_CENTER" ;
if ( $ENV{'TERRAIN_AND_LANDUSE'} eq "1" ) {
$sw_terrain_and_landuse =" -DTERRAIN_AND_LANDUSE" ;
$sw_nest_opt = $sw_nest_opt . $sw_terrain_and_landuse;
}
}
if ( $paropt eq 'smpar' || $paropt eq 'dm+sm' ) { $sw_ompparallel = "OMP" ; }
if ( $paropt eq 'dmpar' || $paropt eq 'dm+sm' ) {
if ( $sw_os ne "CYGWIN_NT" ) {
$sw_comms_lib = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a" ;
if ( $sw_wrf_core eq "4D_DA_CORE" )
{
$sw_comms_lib = "\$(WRFPLUS_DIR)/external/RSL_LITE/librsl_lite.a" ;
}
} else {
$sw_comms_lib = "../external/RSL_LITE/librsl_lite.a" ;
}
$sw_comms_external = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a gen_comms_rsllite module_dm_rsllite" ;
$sw_dmparallel = "RSL_LITE" ;
$sw_dmparallelflag = "-DDM_PARALLEL" ;
$sw_fc = "\$(DM_FC)" ;
$sw_cc = "\$(DM_CC)" ;
} # only one option in v3.0
$sw_ifort_r8 = 0 ;
if ( index ( $x, "ifort" ) > -1 || index ( $x, "intel compiler" ) > -1 ) {
if ( $sw_rwordsize == 8 ) {
$sw_ifort_r8 = 1 ;
}
}
}
}
}
}
close CONFIGURE_DEFAULTS ;
close POSTAMBLE ;
close ARCH_NOOPT_EXCEPTIONS ;
open CONFIGURE_WRF, "> configure.wrf" or die "cannot append configure.wrf" ;
open ARCH_PREAMBLE, "< arch/preamble_new" or die "cannot open arch/preamble_new" ;
my @preamble;
# apply substitutions to the preamble...
while ( <ARCH_PREAMBLE> )
{
# ESMF substitutions in preamble
if ( $sw_esmflib_path && $sw_esmfinc_path )
{
$_ =~ s/ESMFCOUPLING/1/g ;
$_ =~ s:ESMFMODDEPENDENCE:\$\(WRF_SRC_ROOT_DIR\)/external/io_esmf/module_utility.o:g ;
$_ =~ s:ESMFMODINC:-I$sw_esmfinc_path -I\$\(WRF_SRC_ROOT_DIR\)/main:g ;
$_ =~ s:ESMFIOINC:-I\$\(WRF_SRC_ROOT_DIR\)/external/io_esmf:g ;
$_ =~ s:ESMFIODEFS:-DESMFIO:g ;
$_ =~ s:ESMFTARGET:wrfio_esmf:g ;
$_ =~ s:\# ESMFINCLUDEGOESHERE:include \$\(ESMFLIB\)/esmf.mk: ;
}
else
{
$_ =~ s/ESMFCOUPLING/0/g ;
$_ =~ s:ESMFMODDEPENDENCE:\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90/module_utility.o:g ;
$_ =~ s:ESMFMODINC::g ;
$_ =~ s:ESMFIOINC:-I\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90:g ;
$_ =~ s:ESMFIODEFS::g ;
$_ =~ s:ESMFTARGET:esmf_time:g ;
}
if ( $ENV{HWRF} )
{
$_ =~ s:CONFIGURE_ATMOCN_LIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/atm_ocn -latm_ocn:g ;
$_ =~ s/CONFIGURE_ATMOCN/atm_ocn/g ;
}
else
{
$_ =~ s:CONFIGURE_ATMOCN_LIB::g ;
$_ =~ s/CONFIGURE_ATMOCN//g ;
}
$_ =~ s:CONFIGURE_EM_CORE:$sw_em_core:g ;
$_ =~ s:CONFIGURE_DA_CORE:$sw_da_core:g ;
$_ =~ s:CONFIGURE_NMM_CORE:$sw_nmm_core:g ;
$_ =~ s:CONFIGURE_COAMPS_CORE:$sw_coamps_core:g ;
$_ =~ s:CONFIGURE_EXP_CORE:$sw_exp_core:g ;
$_ =~ s/CONFIGURE_DEP_LIB_PATH/$sw_dep_lib_path/g ;
if ( $sw_gpfs_path ne "" )
{ if (/^GPFS.*=/)
{ $_ =~ s/\r|\n//g;
if ( $sw_gpfs_path ne "DEFAULT" )
{ $_ .= " -L" . $sw_gpfs_path ; }
$_ .= " " . $sw_gpfs_lib . "\n" ;
}
}
if ( $sw_curl_path ne "" )
{ if (/^CURL.*=/)
{ $_ =~ s/\r|\n//g;
if ( $sw_curl_path ne "DEFAULT" )
{ $_ .= " -L" . $sw_curl_path ; }
$_ .= " " . $sw_curl_lib . "\n" ;
}
}
if ( $sw_dep_lib_path ne "" )
{ if (/^HDF5.*=/)
{ $_ =~ s/\r|\n//g;
$_ .= " " . $sw_hdf5 . "\n" ;
}
if (/^ZLIB.*=/)
{ $_ =~ s/\r|\n//g;
$_ .= " " . $sw_zlib . "\n" ;
}
}
@preamble = ( @preamble, $_ ) ;
}
close ARCH_PREAMBLE ;
print CONFIGURE_WRF @preamble ;
close ARCH_PREAMBLE ;
printf CONFIGURE_WRF "# Settings for %s\n", $optstr[$optchoice] ;
print CONFIGURE_WRF @machopts ;
print "$ENV{WRF_MARS}" ;
if ( $ENV{WRF_MARS} || $ENV{WRF_TITAN} || $ENV{WRF_VENUS} )
{
open ARCH_PLANETAMBLE, "< arch/planetamble" or die "cannot open arch/planetamble" ;
while ( <ARCH_PLANETAMBLE> ) { print CONFIGURE_WRF } ;
close ARCH_PLANETAMBLE ;
}
close CONFIGURE_WRF ;
printf "Configuration successful. To build the model type compile . \n" ;
printf "------------------------------------------------------------------------\n" ;