Merge pull request #22 from wirc-sjsu/develop-w21
[WRF-Fire-merge.git] / arch / Config.pl
blobf31b33827eb954a6c3b5eadadce316a2773b2c52
1 #!/usr/bin/perl
3 # Configuration script for WRF prototype code
4 #
5 # Be sure to run as ./configure (to avoid getting a system configure command by mistake)
8 use Cwd qw(getcwd);
9 $wrf_cmaq_option = $ENV{'WRF_CMAQ'}; # determine building WRF-CMAQ coupled model or not
11 select((select(STDOUT), $|=1)[0]);
12 $sw_perl_path = perl ;
13 $sw_netcdf_path = "" ;
14 $sw_pnetcdf_path = "" ;
15 $sw_netcdfpar_path = "" ;
16 $sw_hdf5_path="";
17 $sw_phdf5_path="";
18 $sw_jasperlib_path="";
19 $sw_jasperinc_path="";
20 $sw_esmflib_path="";
21 $sw_esmfinc_path="";
22 $sw_ctsm_mkfile_path="";
23 $sw_ldflags="";
24 $sw_compileflags="";
25 $sw_opt_level="";
26 $sw_rwordsize="\$\(NATIVE_RWORDSIZE\)";
27 $sw_rttov_flag = "" ;
28 $sw_rttov_inc = "" ;
29 $sw_rttov_path = "" ;
30 $sw_crtm_flag = "" ;
31 $sw_cloudcv_flag = "" ;
32 $sw_4dvar_flag = "" ;
33 $sw_wrfplus_path = "" ;
34 $sw_wavelet_flag = "" ;
35 $WRFCHEM = 0 ;
36 $sw_os = "ARCH" ; # ARCH will match any
37 $sw_mach = "ARCH" ; # ARCH will match any
38 $sw_wrf_core = "" ;
39 $sw_da_core = "-DDA_CORE=\$\(WRF_DA_CORE\)" ;
40 $sw_wrfplus_core = "-DWRFPLUS=\$\(WRF_PLUS_CORE\)" ;
41 $sw_nmm_core = "-DNMM_CORE=\$\(WRF_NMM_CORE\)" ;
42 $sw_em_core = "-DEM_CORE=\$\(WRF_EM_CORE\)" ;
43 $sw_dmparallel = "" ;
44 $sw_ompparallel = "" ;
45 $sw_stubmpi = "" ;
46 $sw_usenetcdff = "" ; # UNIDATA switches around library names a bit
47 $sw_usenetcdf = "" ;
48 $sw_time = "" ; # name of a timer to time fortran compiles, e.g. timex or time
49 $sw_ifort_r8 = 0 ;
50 $sw_hdf5 = "-lhdf5_hl -lhdf5";
51 $sw_zlib = "-lz";
52 $sw_dep_lib_path = "";
53 $sw_gpfs_path = "";
54 $sw_gpfs_lib = "-lgpfs";
55 $sw_curl_path = "";
56 $sw_curl_lib = "-lcurl";
57 $sw_terrain_and_landuse = "";
58 $sw_tfl = "" ;
59 $sw_cfl = "" ;
60 $sw_config_line = "" ;
61 while ( substr( $ARGV[0], 0, 1 ) eq "-" )
63 if ( substr( $ARGV[0], 1, 5 ) eq "perl=" )
65 $sw_perl_path = substr( $ARGV[0], 6 ) ;
67 if ( substr( $ARGV[0], 1, 7 ) eq "netcdf=" )
69 $sw_netcdf_path = substr( $ARGV[0], 8 ) ;
71 if ( substr( $ARGV[0], 1, 13 ) eq "dep_lib_path=" )
73 $sw_dep_lib_path = substr( $ARGV[0], 14 ) ;
74 $sw_dep_lib_path =~ s/\r|\n/ /g ;
76 if ( substr( $ARGV[0], 1, 5 ) eq "gpfs=" )
78 $sw_gpfs_path = substr( $ARGV[0], 6 ) ;
79 if ( $sw_gpfs_path ne "" )
81 if ( substr( $sw_gpfs_path, -1, 1 ) eq "/" )
83 $sw_gpfs_path = substr($sw_gpfs_path, 0, length($sw_gpfs_path)-1 ) ;
87 if ( substr( $ARGV[0], 1, 5 ) eq "curl=" )
89 $sw_curl_path = substr( $ARGV[0], 6 ) ;
90 if ( $sw_curl_path ne "" )
92 if ( substr( $sw_curl_path, -1, 1 ) eq "/" )
94 $sw_curl_path = substr($sw_curl_path, 0, length($sw_curl_path)-1 ) ;
98 if ( substr( $ARGV[0], 1, 8 ) eq "pnetcdf=" )
100 $sw_pnetcdf_path = substr( $ARGV[0], 9 ) ;
102 if ( substr( $ARGV[0], 1, 10 ) eq "netcdfpar=" )
104 $sw_netcdfpar_path = substr( $ARGV[0], 11 ) ;
106 if ( substr( $ARGV[0], 1, 5 ) eq "hdf5=" )
108 $sw_hdf5_path = substr( $ARGV[0], 6 ) ;
110 if ( substr( $ARGV[0], 1, 6 ) eq "phdf5=" )
112 $sw_phdf5_path = substr( $ARGV[0], 7 ) ;
114 if ( substr( $ARGV[0], 1, 3 ) eq "os=" )
116 $sw_os = substr( $ARGV[0], 4 ) ;
118 if ( substr( $ARGV[0], 1, 5 ) eq "mach=" )
120 $sw_mach = substr( $ARGV[0], 6 ) ;
122 if ( substr( $ARGV[0], 1, 10 ) eq "opt_level=" )
124 $sw_opt_level = substr( $ARGV[0], 11 ) ;
126 if ( substr( $ARGV[0], 1, 11 ) eq "USENETCDFF=" )
128 $sw_usenetcdff = substr( $ARGV[0], 12 ) ;
130 if ( substr( $ARGV[0], 1, 10 ) eq "USENETCDF=" )
132 $sw_usenetcdf = substr( $ARGV[0], 11 ) ;
134 if ( substr( $ARGV[0], 1, 5 ) eq "time=" )
136 $sw_time = substr( $ARGV[0], 6 ) ;
138 if ( substr( $ARGV[0], 1, 8 ) eq "ldflags=" )
140 $sw_ldflags = substr( $ARGV[0], 9 ) ;
141 # multiple options separated by spaces are passed in from sh script
142 # separated by ! instead. Replace with spaces here.
143 $sw_ldflags =~ s/!/ /g ;
145 if ( substr( $ARGV[0], 1, 9 ) eq "wrf_core=" )
147 $sw_wrf_core = substr( $ARGV[0], 10 ) ;
148 if ( index ( $sw_wrf_core , "EM_CORE" ) > -1 )
150 $sw_em_core = "-DEM_CORE=1" ;
151 $sw_da_core = "-DDA_CORE=0" ;
152 $sw_wrfplus_core = "-DWRFPLUS=0" ;
153 $sw_nmm_core = "-DNMM_CORE=0" ;
155 if ( index ( $sw_wrf_core , "WRF_PLUS_CORE" ) > -1 )
157 $sw_em_core = "-DEM_CORE=1" ;
158 $sw_da_core = "-DDA_CORE=0" ;
159 $sw_wrfplus_core = "-DWRFPLUS=1" ;
160 $sw_nmm_core = "-DNMM_CORE=0" ;
161 $sw_dfi_radar = "-DDFI_RADAR=0" ;
163 if ( index ( $sw_wrf_core , "DA_CORE" ) > -1 )
165 $sw_em_core = "-DEM_CORE=1" ;
166 $sw_da_core = "-DDA_CORE=1" ;
167 $sw_wrfplus_core = "-DWRFPLUS=0" ;
168 $sw_nmm_core = "-DNMM_CORE=0" ;
170 if ( index ( $sw_wrf_core , "4D_DA_CORE" ) > -1 )
172 $sw_em_core = "-DEM_CORE=1" ;
173 $sw_da_core = "-DDA_CORE=1" ;
174 $sw_nmm_core = "-DNMM_CORE=0" ;
176 if ( index ( $sw_wrf_core , "4D_DA_CORE" ) > -1 )
178 $sw_em_core = "-DEM_CORE=1" ;
179 $sw_da_core = "-DDA_CORE=1" ;
180 $sw_nmm_core = "-DNMM_CORE=0" ;
182 if ( index ( $sw_wrf_core , "NMM_CORE" ) > -1 )
184 $sw_em_core = "-DEM_CORE=0" ;
185 $sw_da_core = "-DDA_CORE=0" ;
186 $sw_wrfplus_core = "-DWRFPLUS=0" ;
187 $sw_nmm_core = "-DNMM_CORE=1" ;
190 if ( substr( $ARGV[0], 1, 13 ) eq "compileflags=" )
192 $sw_compileflags = substr( $ARGV[0], 14 ) ;
193 $sw_compileflags =~ s/!/ /g ;
194 # look for each known option
195 $where_index = index ( $sw_compileflags , "-DWRF_CHEM" ) ;
196 if ( $where_index eq -1 )
198 $WRFCHEM = 0 ;
200 else
202 $WRFCHEM = 1 ;
205 if ( substr( $ARGV[0], 1, 11 ) eq "dmparallel=" )
207 $sw_dmparallel=substr( $ARGV[0], 12 ) ;
209 if ( substr( $ARGV[0], 1, 12 ) eq "ompparallel=" )
211 $sw_ompparallel=substr( $ARGV[0], 13 ) ;
213 if ( substr( $ARGV[0], 1, 4 ) eq "tfl=" )
215 $sw_tfl=substr( $ARGV[0], 5 ) ;
217 if ( substr( $ARGV[0], 1, 4 ) eq "cfl=" )
219 $sw_cfl=substr( $ARGV[0], 5 ) ;
221 if ( substr( $ARGV[0], 1, 12 ) eq "config_line=" )
223 $sw_config_line=substr( $ARGV[0], 13 ) ;
225 shift @ARGV ;
228 $sw_fc = "\$(SFC)" ;
229 $sw_cc = "\$(SCC)" ;
230 $sw_comms_lib = "" ;
231 $sw_comms_include = "" ;
232 $sw_dmparallelflag = "" ;
233 $sw_nest_opt = "" ;
234 $sw_comms_external = "gen_comms_serial module_dm_serial" ;
237 if ( $sw_dmparallel eq "RSL_LITE" )
239 $sw_fc = "\$(DM_FC)" ;
240 $sw_cc = "\$(DM_CC)" ;
241 $sw_dmparallelflag = "-DDM_PARALLEL" ;
242 $sw_comms_lib = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a" ;
243 $sw_comms_external = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a gen_comms_rsllite module_dm_rsllite" ;
244 $sw_comms_include = "-I\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE" ;
247 # The jasper library is required to build Grib2 I/O. User must set
248 # environment variables JASPERLIB and JASPERINC to paths to library and
249 # include files to enable this feature prior to running configure.
251 $I_really_want_to_output_grib2_from_WRF = "FALSE" ;
253 if ( $ENV{JASPERLIB} && $ENV{JASPERINC} && $I_really_want_to_output_grib2_from_WRF eq "TRUE" )
255 printf "Configuring to use jasper library to build Grib2 I/O...\n" ;
256 printf(" \$JASPERLIB = %s\n",$ENV{JASPERLIB});
257 printf(" \$JASPERINC = %s\n",$ENV{JASPERINC});
258 $sw_jasperlib_path = $ENV{JASPERLIB};
259 $sw_jasperinc_path = $ENV{JASPERINC};
261 else
263 if ( $ENV{JASPERLIB} && $ENV{JASPERINC} )
265 printf "\n\nIf you REALLY want Grib2 output from WRF, modify the arch/Config.pl script.\n" ;
266 printf "Right now you are not getting the Jasper lib, from the environment, compiled into WRF.\n\n" ;
268 else
270 printf "\$JASPERLIB or \$JASPERINC not found in environment, configuring to build without grib2 I/O...\n" ;
274 # When compiling DA and WRFPLUS code, we need to always use 8-byte reals.
275 if ( $ENV{WRF_DA_CORE} eq "1" || $sw_da_core eq "-DDA_CORE=1" )
277 $sw_rwordsize = "8";
278 if(defined $ENV{'CRTM'})
280 if ( $ENV{CRTM} ne "0" )
282 $sw_crtm_flag = "-DCRTM";
285 else
288 $sw_crtm_flag = "-DCRTM";
291 if ( $ENV{RTTOV} )
293 $sw_rttov_flag = "-DRTTOV";
294 $sw_rttov_inc = "-I$ENV{RTTOV}/include -I$ENV{RTTOV}/mod";
295 $sw_rttov_path= $ENV{RTTOV};
297 if ( $ENV{CLOUD_CV} )
299 $sw_cloudcv_flag = "-DCLOUD_CV";
301 if ( $sw_wrf_core eq "4D_DA_CORE" )
303 $sw_4dvar_flag = "-DVAR4D";
304 $sw_wrfplus_path= $ENV{WRFPLUS_DIR};
306 if ( $ENV{WAVELET} )
308 $sw_wavelet_flag = "-DWAVELET";
312 $sw_rwordsize = "8" if ( $sw_wrfplus_core eq "-DWRFPLUS=1" );
314 # A separately-installed ESMF library is required to build the ESMF
315 # implementation of WRF IOAPI in external/io_esmf. This is needed
316 # to couple WRF with other ESMF components. User must set environment
317 # variables ESMFLIB and ESMFINC to paths ESMF to library and include
318 # files to enable this feature prior to running configure.
319 if ( $ENV{ESMFLIB} && $ENV{ESMFINC} )
321 printf "Configuring to use ESMF library to build WRF...\n" ;
322 printf "WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING\n" ;
323 printf "WARNING: THIS IS AN EXPERIMENTAL CONFIGURATION\n" ;
324 printf "WARNING: IT DOES NOT WORK WITH NESTING\n" ;
325 printf "WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING\n" ;
326 printf(" \$ESMFLIB = %s\n",$ENV{ESMFLIB});
327 printf(" \$ESMFINC = %s\n",$ENV{ESMFINC});
328 $sw_esmflib_path = $ENV{ESMFLIB};
329 $sw_esmfinc_path = $ENV{ESMFINC};
330 $sw_esmf_ldflag = "yes" ;
333 # A separately-installed CTSM library and its dependencies are required
334 # to build WRF with the CTSM land surface model (the next generation of
335 # the CLM model, coupled via LILAC). The user must set the environment
336 # variable WRF_CTSM_MKFILE, which should be a path to a make-formatted
337 # file containing settings of CTSM_INCLUDES and CTSM_LIBS. When this
338 # environment variable is set, this also triggers adding -DWRF_USE_CTSM;
339 # when this env var is not set, then we instead use -DWRF_USE_CLM, which
340 # builds an old version of CLM that is included in the WRF source code.
341 # (We currently cannot build with both at once because of namespace
342 # collisions at link time.)
343 if ( $ENV{WRF_CTSM_MKFILE} ) {
344 $sw_ctsm_mkfile_path = $ENV{WRF_CTSM_MKFILE};
347 # parse the configure.wrf file
349 $validresponse = 0 ;
351 if ( ($sw_wrf_core eq "WRF_PLUS_CORE") || ($sw_wrf_core eq "4D_DA_CORE") )
352 { @platforms = qw ( serial dmpar ) ; }
353 else
354 { @platforms = qw ( serial smpar dmpar dm+sm ) ; }
356 # Display the choices to the user and get selection
357 until ( $validresponse ) {
358 printf "------------------------------------------------------------------------\n" ;
359 printf "Please select from among the following $sw_os $sw_mach options:\n\n" ;
361 $opt = 1 ;
362 $optstr = "";
363 open CONFIGURE_DEFAULTS, "< ./arch/configure.defaults"
364 or die "Cannot open ./arch/configure.defaults for reading" ;
365 while ( <CONFIGURE_DEFAULTS> ) {
367 $currline = $_;
368 chomp $currline;
369 # Look for our platform in the configuration option header.
370 # If we're going to list it, print parallelism options
371 if ( substr( $currline, 0, 5 ) eq "#ARCH" && ( index( $currline, $sw_os ) >= 0 )
372 && ( index( $currline, $sw_mach ) >= 0 ) ) {
373 $optstr = substr($currline,6) ;
375 foreach ( @platforms ) { # Check which parallelism options are valid for this configuration option
376 $paropt = $_ ;
377 if ( index($optstr, $paropt) >= 0 ) { #If parallelism option is valid, print and assign number
378 printf "%3d. (%s) ",$opt,$paropt ;
379 $pararray[$opt] = $paropt ;
380 $opttemp = $optstr ;
381 $opttemp =~ s/#.*$//g ;
382 chomp($opttemp) ;
383 $optarray[$opt] = $opttemp." (".$paropt.")" ;
384 $opt++ ;
385 } else { #If parallelism option is not valid, print spaces for formatting/readability
386 $paropt =~ s/./ /g ;
387 printf " %s ",$paropt ;
390 next;
393 next unless ( length $optstr ) ; # Don't read option lines unless it's valid for our platform
395 if ( substr( $currline, 0, 11 ) eq "DESCRIPTION" ) {
396 $optstr = $currline ; #Initial value of $optstr is DESCRIPTION line
397 next;
400 if ( substr( $currline, 0, 3 ) eq "SFC" ) {
401 $currline =~ s/^SFC\s*=\s*//g; #remove "SFC ="
402 $currline =~ s/ (\-\S*)*$//g; #remove trailing arguments and/or spaces
403 $optstr =~ s/\$SFC/$currline/g; #Substitute the fortran compiler name into optstr
404 $optstr =~ s/DESCRIPTION\s*=\s*//g; #Remove "DESCRIPTION ="
405 next;
408 if ( substr( $currline, 0, 3 ) eq "SCC" ) {
409 $currline =~ s/^SCC\s*=\s*//g; #remove "SCC ="
410 $currline =~ s/ (\-\S*)*$//g; #remove trailing arguments and/or spaces
411 $optstr =~ s/\$SCC/$currline/g; #Substitute the C compiler name into optstr
412 next;
415 if ( substr( $currline, 0, 4 ) eq "####" ) { #reached the end of this option's entry
416 chomp($optstr) ;
417 printf " %s\n",$optstr ;
418 $optstr = "";
419 next;
423 close CONFIGURE_DEFAULTS ;
425 $opt -- ;
427 printf "\nEnter selection [%d-%d] : ",1,$opt ;
428 $response = <STDIN> ;
430 if ( $response == -1 ) { exit ; }
432 if ( $response >= 1 && $response <= $opt )
433 { $validresponse = 1 ; }
434 else
435 { printf("\nInvalid response (%d)\n",$response);}
436 $response_opt = $response ;
437 chop $response_opt ;
439 printf "------------------------------------------------------------------------\n" ;
441 $optchoice = $response ;
442 if ( $response == 2 || $response == 3 ) {
443 if ( $ENV{'TERRAIN_AND_LANDUSE'} eq "1" && index($sw_wrf_core, "EM_CORE") > -1 ) {
444 $sw_terrain_and_landuse =" -DTERRAIN_AND_LANDUSE" ;
445 } else {
446 $sw_terrain_and_landuse =" -DLANDREAD_STUB=1" ;
448 } else {
449 $sw_terrain_and_landuse =" -DLANDREAD_STUB=1" ;
451 open CONFIGURE_DEFAULTS, "cat ./arch/configure.defaults |" ;
452 $latchon = 0 ;
453 while ( <CONFIGURE_DEFAULTS> )
455 if ( $_ =~ /ifort compiler/ )
456 { $lioapi_temp = 'Linux2_x86_64ifort';
458 elsif ( $_ =~ /PGI compiler/ )
459 { $lioapi_temp = 'Linux2_x86_64pg';
461 elsif ( $_ =~ /gfortran compiler/ )
462 { $lioapi_temp = 'Linux2_x86_64gfort';
465 if ( substr( $_, 0, 5 ) eq "#ARCH" && $latchon == 1 )
467 close CONFIGURE_DEFAULTS ;
468 if ( $sw_opt_level eq "-f" ) {
470 # determine whether variable EM_MODULE_DIR contains -I../cmaq or not
471 my $file = "Makefile";
472 open(FH, $file) or die("File $file not found");
474 $lib_path_wo_cmaq = 1;
475 while ( my $String = <FH> )
476 { if($String =~ /-I..\/dyn_em -I..\/cmaq/)
477 { $lib_path_wo_cmaq = 0;
480 close (FH);
482 # determine whether declarations in Registry/registry.CMAQ is commented out or not
483 my $file = "Registry/registry.CMAQ";
484 open (FH, $file) or die("File $file not found");
486 $registry_wo_cmaq = 0;
487 while ( my $String = <FH> )
488 { if($String =~ /#state/)
489 { $registry_wo_cmaq = 1;
492 close (FH);
494 # determine whether express #NOWIN LIB_BUNDLED contains $(IOAPI_LIB) or not
495 my $file = "arch/preamble";
496 open (FH, $file) or die("File $file not found");
498 $bundle_wo_ioapi = 1;
499 while ( my $String = <FH> )
500 { if ( $String =~ /IOAPI_LIB/ )
501 { $bundle_wo_ioapi = 0;
504 close (FH);
506 if ( $wrf_cmaq_option eq 1 ) # build WRF-CMAQ coupled model
507 { if ( $lib_path_wo_cmaq == 1 )
508 { open (FILE, "<Makefile") || die "File not found";
509 my @lines = <FILE>;
510 close (FILE);
512 foreach ( @lines )
513 { $_ =~ s/ -I..\/dyn_em/ -I..\/dyn_em -I..\/cmaq/g;
516 open (FILE, ">Makefile") || die "File not found";
517 print FILE @lines;
518 close (FILE);
521 if ( $registry_wo_cmaq == 1 )
522 { open (FILE, "<Registry/registry.CMAQ") || die "File not found";
523 my @lines = <FILE>;
524 close (FILE);
526 foreach (@lines)
527 { $_ =~ s/#state/state/g;
530 open (FILE, ">Registry/registry.CMAQ") || die "File not found";
531 print FILE @lines;
532 close (FILE);
535 if ( $bundle_wo_ioapi == 1 )
536 { open (FILE, "<arch/preamble") || die "File not found";
537 my @lines = <FILE>;
538 close (FILE);
540 foreach (@lines)
541 { $_ =~ s/#NOWIN LIB_BUNDLED = \\/#NOWIN LIB_BUNDLED = \$(IOAPI_LIB) \\/g;
544 open (FILE, ">arch/preamble") || die "File not found";
545 print FILE @lines;
546 close (FILE);
549 open (FH, '>', wrf_cmaq_path) or die $! ;
550 $ioapi_path = $ENV{'IOAPI'} ;
551 print FH "CMAQLIB = libcmaqlib.a \n" ;
552 print FH "IOAPI = $ioapi_path\n" ;
553 print FH "LIOAPI = $lioapi\n" ;
554 print FH "IOAPI_LIB = -L$ioapi_path/$lioapi -lioapi \n" ;
555 close (FH) ;
556 open CONFIGURE_DEFAULTS, "cat wrf_cmaq_path ./arch/postamble ./arch/noopt_exceptions_f |" or die "horribly" ;
558 else
559 { if ( $lib_path_wo_cmaq == 0 )
560 { open (FILE, "<Makefile") || die "File not found";
561 my @lines = <FILE>;
562 close (FILE);
564 foreach (@lines)
565 { $_ =~ s/ -I..\/cmaq//g;
568 open (FILE, ">Makefile") || die "File not found";
569 print FILE @lines;
570 close (FILE);
574 if ( $registry_wo_cmaq == 0 )
575 { open (FILE, "<Registry/registry.CMAQ") || die "File not found";
576 my @lines = <FILE>;
577 close (FILE);
579 foreach(@lines)
580 { $_ =~ s/state/#state/g;
583 open (FILE, ">Registry/registry.CMAQ") || die "File not found";
584 print FILE @lines;
585 close (FILE);
588 if ( $bundle_wo_ioapi == 0 )
589 { open (FILE, "<arch/preamble") || die "File not found";
590 my @lines = <FILE>;
591 close (FILE);
593 foreach (@lines)
594 { $_ =~ s/ \$\(IOAPI_LIB\)//g;
597 open (FILE, ">arch/preamble") || die "File not found";
598 print FILE @lines;
599 close (FILE);
602 open CONFIGURE_DEFAULTS, "cat ./arch/postamble ./arch/noopt_exceptions_f |" or die "horribly" ;
604 } else {
605 open CONFIGURE_DEFAULTS, "cat ./arch/postamble ./arch/noopt_exceptions |" or die "horribly" ;
608 $_ =~ s:CONFIGURE_NMM_CORE:$sw_nmm_core:g ;
609 if ( $latchon == 1 )
611 $_ =~ s/CONFIGURE_PERL_PATH/$sw_perl_path/g ;
612 $_ =~ s/CONFIGURE_NETCDF_PATH/$sw_netcdf_path/g ;
613 $_ =~ s/CONFIGURE_PNETCDF_PATH/$sw_pnetcdf_path/g ;
614 $_ =~ s/CONFIGURE_NETCDFPAR_PATH/$sw_netcdfpar_path/g ;
615 $_ =~ s/CONFIGURE_HDF5_PATH/$sw_hdf5_path/g ;
616 $_ =~ s/CONFIGURE_PHDF5_PATH/$sw_phdf5_path/g ;
617 $_ =~ s/CONFIGURE_LDFLAGS/$sw_ldflags/g ;
618 $_ =~ s/CONFIGURE_COMPILEFLAGS/$sw_compileflags/g ;
619 $_ =~ s/CONFIGURE_RWORDSIZE/$sw_rwordsize/g ;
620 $_ =~ s/CONFIGURE_FC/$sw_time $sw_fc/g ;
621 $_ =~ s/CONFIGURE_CC/$sw_cc/g ;
622 $_ =~ s/CONFIGURE_COMMS_LIB/$sw_comms_lib/g ;
623 $_ =~ s/CONFIGURE_COMMS_INCLUDE/$sw_comms_include/g ;
624 $_ =~ s/CONFIGURE_COMMS_EXTERNAL/$sw_comms_external/g ;
625 if ( $sw_os ne "CYGWIN_NT" ) {
626 $_ =~ s/#NOWIN// ;
628 $_ =~ s/CONFIGURE_DMPARALLEL/$sw_dmparallelflag/g ;
629 $_ =~ s/CONFIGURE_STUBMPI/$sw_stubmpi/g ;
630 $_ =~ s/CONFIGURE_NESTOPT/$sw_nest_opt/g ;
631 $_ =~ s/CONFIGURE_TRADFLAG/$sw_tfl/g ;
632 $_ =~ s/CONFIGURE_CPPFLAGS/$sw_cfl/g ;
633 $_ =~ s/CONFIGURE_4DVAR_FLAG/$sw_4dvar_flag/g ;
634 $_ =~ s/CONFIGURE_WRFPLUS_PATH/$sw_wrfplus_path/g ;
635 $_ =~ s/CONFIGURE_CRTM_FLAG/$sw_crtm_flag/g ;
636 $_ =~ s/CONFIGURE_RTTOV_FLAG/$sw_rttov_flag/g ;
637 $_ =~ s/CONFIGURE_RTTOV_INC/$sw_rttov_inc/g ;
638 $_ =~ s/CONFIGURE_RTTOV_PATH/$sw_rttov_path/g ;
639 $_ =~ s/CONFIGURE_CLOUDCV_FLAG/$sw_cloudcv_flag/g ;
640 $_ =~ s/CONFIGURE_WAVELET_FLAG/$sw_wavelet_flag/g ;
641 if ( $sw_ifort_r8 ) {
642 $_ =~ s/^PROMOTION.*=/PROMOTION = -r8 /g ;
644 if ( $sw_dmparallel ne "" && ($_ =~ /^DMPARALLEL[=\t ]/) ) {
645 $_ =~ s/#// ;
647 if ( $sw_ompparallel ne "" && ( $_ =~ /^OMPCPP[=\t ]/ || $_ =~ /^OMPCC[=\t ]/ || $_ =~ /^OMP[=\t ]/ ) ) {
648 $_ =~ s/#// ;
649 $_ =~ s/#// ;
650 $_ =~ s/#// ;
653 # put netcdfpar ahead of netcdf so that part of the name does not get clobbered
654 if ( $sw_netcdfpar_path )
655 { $_ =~ s/CONFIGURE_WRFIO_NFPAR/wrfio_nfpar/g ;
656 $_ =~ s:CONFIGURE_NETCDFPAR_FLAG:-DNETCDFPAR: ;
657 $_ =~ s:CONFIGURE_NETCDFPAR_BUILD:: ;
658 if ( $ENV{NETCDFPAR_LDFLAGS} ) {
659 $_ =~ s:CONFIGURE_NETCDFPAR_LIB_PATH:\$\(WRF_SRC_ROOT_DIR\)/external/io_netcdfpar/libwrfio_nfpar.a $ENV{NETCDFPAR_LDFLAGS} : ;
660 } elsif ( $sw_os eq "Interix" ) {
661 $_ =~ s:CONFIGURE_NETCDFPAR_LIB_PATH:\$\(WRF_SRC_ROOT_DIR\)/external/io_netcdfpar/libwrfio_nfpar.a -L$sw_netcdfpar_path/lib $sw_usenetcdff $sw_usenetcdf : ;
662 } else {
663 $_ =~ s:CONFIGURE_NETCDFPAR_LIB_PATH:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_netcdfpar -lwrfio_nfpar -L$sw_netcdfpar_path/lib $sw_usenetcdff $sw_usenetcdf : ;
666 else
667 { $_ =~ s/CONFIGURE_WRFIO_NFPAR//g ;
668 $_ =~ s:CONFIGURE_NETCDFPAR_FLAG::g ;
669 $_ =~ s:CONFIGURE_NETCDFPAR_BUILD:echo SKIPPING: ;
670 $_ =~ s:CONFIGURE_NETCDFPAR_LIB_PATH::g ;
673 if ( $sw_netcdf_path )
674 { $_ =~ s/CONFIGURE_WRFIO_NF/wrfio_nf/g ;
675 $_ =~ s:CONFIGURE_NETCDF_FLAG:-DNETCDF: ;
676 if ( $ENV{NETCDF_LDFLAGS} ) {
677 $_ =~ s:CONFIGURE_NETCDF_LIB_PATH:\$\(WRF_SRC_ROOT_DIR\)/external/io_netcdf/libwrfio_nf.a $ENV{NETCDF_LDFLAGS} : ;
678 } elsif ( $sw_os eq "Interix" ) {
679 $_ =~ s:CONFIGURE_NETCDF_LIB_PATH:\$\(WRF_SRC_ROOT_DIR\)/external/io_netcdf/libwrfio_nf.a -L$sw_netcdf_path/lib $sw_usenetcdff $sw_usenetcdf : ;
680 } else {
681 $_ =~ s:CONFIGURE_NETCDF_LIB_PATH:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_netcdf -lwrfio_nf -L$sw_netcdf_path/lib $sw_usenetcdff $sw_usenetcdf : ;
684 else
685 { $_ =~ s/CONFIGURE_WRFIO_NF//g ;
686 $_ =~ s:CONFIGURE_NETCDF_FLAG::g ;
687 $_ =~ s:CONFIGURE_NETCDF_LIB_PATH::g ;
690 if ( $sw_pnetcdf_path )
691 { $_ =~ s/CONFIGURE_WRFIO_PNF/wrfio_pnf/g ;
692 $_ =~ s:CONFIGURE_PNETCDF_FLAG:-DPNETCDF: ;
693 if ( $sw_os eq "Interix" ) {
694 $_ =~ s:CONFIGURE_PNETCDF_LIB_PATH:\$\(WRF_SRC_ROOT_DIR\)/external/io_pnetcdf/libwrfio_pnf.a -L$sw_pnetcdf_path/lib -lpnetcdf: ;
695 } else {
696 $_ =~ s:CONFIGURE_PNETCDF_LIB_PATH:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_pnetcdf -lwrfio_pnf -L$sw_pnetcdf_path/lib -lpnetcdf: ;
699 else
700 { $_ =~ s/CONFIGURE_WRFIO_PNF//g ;
701 $_ =~ s:CONFIGURE_PNETCDF_FLAG::g ;
702 $_ =~ s:CONFIGURE_PNETCDF_LIB_PATH::g ;
705 if ( $sw_hdf5_path )
706 { $_ =~ s:CONFIGURE_HDF5_LIB_PATH:-L$sw_hdf5_path/lib -lhdf5hl_fortran -lhdf5_hl -lhdf5_fortran -lhdf5 -lm -lz: ;
707 $_ =~ s:CONFIGURE_HDF5_FLAG:-DHDF5: ;
709 else
710 { $_ =~ s:CONFIGURE_HDF5_LIB_PATH::g ;
711 $_ =~ s:CONFIGURE_HDF5_FLAG::g ;
714 if ( $sw_phdf5_path )
716 { $_ =~ s/CONFIGURE_WRFIO_PHDF5/wrfio_phdf5/g ;
717 $_ =~ s:CONFIGURE_PHDF5_FLAG:-DPHDF5: ;
718 $_ =~ 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: ;
720 else
721 { $_ =~ s/CONFIGURE_WRFIO_PHDF5//g ;
722 $_ =~ s:CONFIGURE_PHDF5_FLAG::g ;
723 $_ =~ s:CONFIGURE_PHDF5_LIB_PATH::g ;
726 if ( $sw_jasperlib_path && $sw_jasperinc_path )
727 { $_ =~ s/CONFIGURE_WRFIO_GRIB2/wrfio_grib2/g ;
728 $_ =~ s:CONFIGURE_GRIB2_FLAG:-DGRIB2:g ;
729 $_ =~ s:CONFIGURE_GRIB2_INC:-I$sw_jasperinc_path:g ;
730 $_ =~ s:CONFIGURE_GRIB2_LIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_grib2 -lio_grib2 -L$sw_jasperlib_path -ljasper:g ;
732 else
733 { $_ =~ s/CONFIGURE_WRFIO_GRIB2//g ;
734 $_ =~ s:CONFIGURE_GRIB2_FLAG::g ;
735 $_ =~ s:CONFIGURE_GRIB2_INC::g ;
736 $_ =~ s:CONFIGURE_GRIB2_LIB::g ;
739 if ( $sw_terrain_and_landuse )
741 $_ =~ s/CONFIGURE_TERRAIN_AND_LANDUSE/$sw_terrain_and_landuse/g;
743 else
745 $_ =~ s:CONFIGURE_TERRAIN_AND_LANDUSE:-DLANDREAD_STUB=1:g;
748 # ESMF substitutions in configure.defaults
749 if ( $sw_esmflib_path && $sw_esmfinc_path )
751 $_ =~ s:CONFIGURE_ESMF_FLAG:-DESMFIO:g ;
752 # pre 5.2.0r
753 # $_ =~ s:ESMFIOLIB:-L$sw_esmflib_path -lesmf -L\$\(WRF_SRC_ROOT_DIR\)/external/io_esmf -lwrfio_esmf \$\(ESMF_LIB_FLAGS\):g ;
754 # $_ =~ s:ESMFIOEXTLIB:-L$sw_esmflib_path -lesmf -L\$\(WRF_SRC_ROOT_DIR\)/external/io_esmf -lwrfio_esmf \$\(ESMF_LIB_FLAGS\):g ;
755 # post 5.2.0r
756 $_ =~ s:ESMFIOLIB:\$\(ESMF_F90LINKPATHS\) \$\(ESMF_F90ESMFLINKLIBS\) -L\$\(WRF_SRC_ROOT_DIR\)/external/io_esmf -lwrfio_esmf: ;
757 $_ =~ s:ESMFIOEXTLIB:\$\(ESMF_IO_LIB\): ;
760 $_ =~ s:ESMFLIBFLAG:\$\(ESMF_LDFLAG\):g ;
761 # $_ =~ s:ESMFINCLUDEGOESHERE:'include $(ESMFLIB)/esmf.mk': ;
764 else
766 $_ =~ s:CONFIGURE_ESMF_FLAG::g ;
767 $_ =~ s:ESMFLIBFLAG::g ;
768 if ( $sw_os eq "Interix" ) {
769 $_ =~ s:ESMFIOLIB:\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90/libesmf_time.a:g ;
770 $_ =~ s:ESMFIOEXTLIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90/libesmf_time.a:g ;
771 } else {
772 $_ =~ s:ESMFIOLIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90 -lesmf_time:g ;
773 $_ =~ s:ESMFIOEXTLIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90 -lesmf_time:g ;
777 # CTSM substitutions in configure.defaults and postamble
778 if ( $sw_ctsm_mkfile_path ) {
779 $_ =~ s:CONFIGURE_D_CTSM:-DWRF_USE_CTSM:g ;
780 $_ =~ s:CONFIGURE_CTSM_INC:\$\(CTSM_INCLUDES\):g ;
781 $_ =~ s:CONFIGURE_CTSM_LIB:\$\(CTSM_LIBS\):g ;
783 else {
784 $_ =~ s:CONFIGURE_D_CTSM:-DWRF_USE_CLM:g ;
785 $_ =~ s:CONFIGURE_CTSM_INC::g ;
786 $_ =~ s:CONFIGURE_CTSM_LIB::g ;
789 if ( $ENV{HWRF} )
791 $_ =~ s:CONFIGURE_ATMOCN_LIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/atm_ocn -latm_ocn:g ;
792 $_ =~ s:CONFIGURE_ATMOCN_INC:-I\$\(WRF_SRC_ROOT_DIR\)/external/atm_ocn:g;
793 $_ =~ s/CONFIGURE_ATMOCN/atm_ocn/g ;
795 else
797 $_ =~ s:CONFIGURE_ATMOCN_LIB::g ;
798 $_ =~ s/CONFIGURE_ATMOCN//g ;
799 $_ =~ s:CONFIGURE_ATMOCN_INC::g;
801 if ( $ENV{NETCDF4} )
802 { if ( $ENV{NETCDF4} eq "1" )
804 if ( /(^ARCH_LOCAL.*=|^TRADFLAG.*=)/ )
805 { $_ =~ s/\r|\n//g;
806 $_ .= " \$\(NETCDF4_IO_OPTS\)\n" ;
808 if (/^LIB.*=/)
809 { $_ =~ s/(\\?)[\r\n]/ \$\(NETCDF4_DEP_LIB\)\1\n/g ;
814 if ( ! (substr( $_, 0, 5 ) eq "#ARCH") ) { @machopts = ( @machopts, $_ ) ; }
815 if ( substr( $_, 0, 10 ) eq "ENVCOMPDEF" )
817 @machopts = ( @machopts, "WRF_CHEM\t=\t$WRFCHEM \n" ) ;
821 # nesting support
822 # 0 = no nesting (only selectable for serial and smpar)
823 # 1 = basic nesting (serial and smpar compile with RSL_LITE and STUBMPI; dmpar and dm+sm use RSL_LITE and MPI)
824 # 2 = nesting with prescribed moves (add -DMOVE_NESTS to ARCHFLAGS)
825 # 3 = nesting with prescribed moves (add -DMOVE_NESTS and -DVORTEX_CENTER to ARCHFLAGS)
827 for $paropt ( @platforms )
829 if ( substr( $_, 0, 5 ) eq "#ARCH" && $latchon == 0
830 && ( index( $_, $sw_os ) >= 0 ) && ( index( $_, $sw_mach ) >= 0 )
831 && ( index($_, $paropt) >= 0 ) )
833 # We are cycling through the configure.defaults file again.
834 # This bit tries to match the line corresponding to the option we previously selected.
835 $x=substr($_,6) ;
836 $x =~ s/#.*$//g ;
837 chomp($x) ;
838 $x = $x." (".$paropt.")" ;
839 if ( $x eq $optarray[$optchoice] )
842 if($ENV{WRF_HYDRO} eq 1) {
843 $tt = `cd hydro; ./wrf_hydro_config "$x" "$paropt"`;
846 $latchon = 1 ;
847 $sw_ompparallel = "" ;
848 $sw_dmparallel = "" ;
849 $validresponse = 0 ;
850 #only allow parallel netcdf if the user has chosen parallel option
851 if ( $paropt ne 'dmpar' && $paropt ne 'dm+sm' ) { $sw_pnetcdf_path = "" ; }
853 until ( $validresponse ) {
854 if ( $ENV{WRF_DA_CORE} eq "1" || $sw_da_core eq "-DDA_CORE=1" ) {
855 $response = 1 ;
856 } elsif ( $sw_wrfplus_core eq "-DWRFPLUS=1" ) {
857 $response = 0 ;
858 } elsif ( $ENV{HWRF} ) {
859 printf "HWRF requires moving nests";
860 $response = "2\n";
861 } else {
862 if ( $paropt eq 'serial' || $paropt eq 'smpar' ) {
863 printf "Compile for nesting? (0=no nesting, 1=basic, 2=preset moves, 3=vortex following) [default 0]: " ;
864 } elsif ( $ENV{WRF_NMM_CORE} eq "1" ) {
865 printf "Compile for nesting? (1=basic, 2=preset moves) [default 1]: " ;
866 } else {
867 printf "Compile for nesting? (1=basic, 2=preset moves, 3=vortex following) [default 1]: " ;
869 $response = <STDIN> ;
870 $lioapi = $lioapi_temp;
872 printf "\n" ;
873 lc $response ;
874 chop $response ;
875 if ( $response == "" || ($response >= 0 && $response <= 3) )
876 { $validresponse = 1 ; }
877 else
878 { printf("\nInvalid response (%d)\n",$response);}
880 if ( $response == "" ) {
881 if ( ( $paropt eq 'serial' || $paropt eq 'smpar' ) ) { $response = 0 ; }
882 else { $response = 1 ; }
884 if ( $response == 0 ) {
885 if ( ! ( $paropt eq 'serial' || $paropt eq 'smpar' ) ) { $response = 1 ; }
887 $response_nesting = $response ;
888 if ( ( $response == 1 ) || ( $response == 2 ) || ( $response == 3 ) ) {
889 if ( ( $paropt eq 'serial' || $paropt eq 'smpar' ) ) { # nesting without MPI
890 $sw_stubmpi = "-DSTUBMPI" ;
891 if ( $sw_os ne "CYGWIN_NT" ) {
892 $sw_comms_lib = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a" ;
893 } else {
894 $sw_comms_lib = "../external/RSL_LITE/librsl_lite.a" ;
896 $sw_comms_external = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a gen_comms_rsllite module_dm_rsllite" ;
897 $sw_dmparallel = "RSL_LITE" ;
898 $sw_dmparallelflag = "-DDM_PARALLEL" ;
901 if ( $response == 2 ) {
902 $sw_nest_opt = "-DMOVE_NESTS" ;
903 if ( $ENV{'TERRAIN_AND_LANDUSE'} eq "1" ) {
904 $sw_terrain_and_landuse =" -DTERRAIN_AND_LANDUSE" ;
905 $sw_nest_opt = $sw_nest_opt . $sw_terrain_and_landuse;
907 } elsif ( $response == 3 ) {
908 $sw_nest_opt = "-DMOVE_NESTS -DVORTEX_CENTER" ;
909 if ( $ENV{'TERRAIN_AND_LANDUSE'} eq "1" ) {
910 $sw_terrain_and_landuse =" -DTERRAIN_AND_LANDUSE" ;
911 $sw_nest_opt = $sw_nest_opt . $sw_terrain_and_landuse;
914 if ( $paropt eq 'smpar' || $paropt eq 'dm+sm' ) { $sw_ompparallel = "OMP" ; }
915 if ( $paropt eq 'dmpar' || $paropt eq 'dm+sm' ) {
916 if ( $sw_os ne "CYGWIN_NT" ) {
917 $sw_comms_lib = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a" ;
918 if ( $sw_wrf_core eq "4D_DA_CORE" )
920 $sw_comms_lib = "\$(WRFPLUS_DIR)/external/RSL_LITE/librsl_lite.a" ;
922 } else {
923 $sw_comms_lib = "../external/RSL_LITE/librsl_lite.a" ;
925 $sw_comms_external = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a gen_comms_rsllite module_dm_rsllite" ;
926 $sw_dmparallel = "RSL_LITE" ;
927 $sw_dmparallelflag = "-DDM_PARALLEL" ;
928 $sw_fc = "\$(DM_FC)" ;
929 $sw_cc = "\$(DM_CC)" ;
930 } # only one option in v3.0
932 $sw_ifort_r8 = 0 ;
933 if ( index ( $x, "ifort" ) > -1 || index ( $x, "intel compiler" ) > -1 ) {
934 if ( $sw_rwordsize == 8 ) {
935 $sw_ifort_r8 = 1 ;
943 if ($latchon == 0) { # Never hurts to check that we actually found the option again.
944 unlink "configure.wrf";
945 print "\nERROR ERROR ERROR ERROR\n\n";
946 print "SOMETHING TERRIBLE HAS HAPPENED: configure.wrf not created correctly.\n";
947 print 'Check "$x" and "$optarray[$optchoice]"';
948 die "\n\nERROR ERROR ERROR ERROR\n\n";
951 close CONFIGURE_DEFAULTS ;
952 close POSTAMBLE ;
953 close ARCH_NOOPT_EXCEPTIONS ;
955 if ( $wrf_cmaq_option eq 1 )
956 { unlink "wrf_cmaq_path";
959 open CONFIGURE_WRF, "> configure.wrf" or die "cannot append configure.wrf" ;
960 open ARCH_PREAMBLE, "< arch/preamble" or die "cannot open arch/preamble" ;
961 my @preamble;
962 # apply substitutions to the preamble...
963 while ( <ARCH_PREAMBLE> )
965 if ( $sw_os ne "CYGWIN_NT" ) {
966 $_ =~ s/#NOWIN// ;
968 # ESMF substitutions in preamble
969 if ( $sw_esmflib_path && $sw_esmfinc_path )
971 $_ =~ s/ESMFCOUPLING/1/g ;
972 $_ =~ s:ESMFMODDEPENDENCE:\$\(WRF_SRC_ROOT_DIR\)/external/io_esmf/module_utility.o:g ;
973 $_ =~ s:ESMFMODINC:-I$sw_esmfinc_path -I\$\(WRF_SRC_ROOT_DIR\)/main:g ;
974 $_ =~ s:ESMFIOINC:-I\$\(WRF_SRC_ROOT_DIR\)/external/io_esmf:g ;
975 $_ =~ s:ESMFIODEFS:-DESMFIO:g ;
976 $_ =~ s:ESMFTARGET:wrfio_esmf:g ;
977 $_ =~ s:\# ESMFINCLUDEGOESHERE:include \$\(ESMFLIB\)/esmf.mk: ;
980 else
982 $_ =~ s/ESMFCOUPLING/0/g ;
983 $_ =~ s:ESMFMODDEPENDENCE:\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90/module_utility.o:g ;
984 $_ =~ s:ESMFMODINC::g ;
985 $_ =~ s:ESMFIOINC:-I\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90:g ;
986 $_ =~ s:ESMFIODEFS::g ;
987 $_ =~ s:ESMFTARGET:esmf_time:g ;
990 # CTSM substitutions in preamble
991 if ( $sw_ctsm_mkfile_path ) {
992 $_ =~ s:\# CTSMINCLUDEGOESHERE:include $sw_ctsm_mkfile_path: ;
995 if ( $ENV{HWRF} )
997 $_ =~ s:CONFIGURE_ATMOCN_LIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/atm_ocn -latm_ocn:g ;
998 $_ =~ s/CONFIGURE_ATMOCN/atm_ocn/g ;
1000 else
1002 $_ =~ s:CONFIGURE_ATMOCN_LIB::g ;
1003 $_ =~ s/CONFIGURE_ATMOCN//g ;
1005 $_ =~ s:CONFIGURE_EM_CORE:$sw_em_core:g ;
1006 $_ =~ s:CONFIGURE_DA_CORE:$sw_da_core:g ;
1007 $_ =~ s:CONFIGURE_WRFPLUS_CORE:$sw_wrfplus_core:g ;
1008 $_ =~ s:CONFIGURE_NMM_CORE:$sw_nmm_core:g ;
1009 $_ =~ s/CONFIGURE_CONFIG_LINE/$sw_config_line/g ;
1010 $_ =~ s/CONFIGURE_CONFIG_NUM/Compiler choice: $response_opt/g ;
1011 $_ =~ s/CONFIGURE_CONFIG_NEST/Nesting option: $response_nesting/g ;
1013 $_ =~ s/CONFIGURE_DEP_LIB_PATH/$sw_dep_lib_path/g ;
1015 $_ =~ s/CONFIGURE_COMMS_LIB/$sw_comms_lib/g ;
1016 if ( $sw_os ne "CYGWIN_NT" ) {
1017 $_ =~ s/#NOWIN// ;
1020 if ( $sw_netcdfpar_path )
1021 { #print("set sw_netcdfpar_path stuff\n");
1022 $_ =~ s/CONFIGURE_WRFIO_NFPAR/wrfio_nfpar/g ;
1023 $_ =~ s:CONFIGURE_NETCDFPAR_FLAG:-DNETCDFPAR: ;
1024 if ( $ENV{NETCDFPAR_LDFLAGS} ) {
1025 $_ =~ s:CONFIGURE_NETCDFPAR_LIB_PATH:\$\(WRF_SRC_ROOT_DIR\)/external/io_netcdfpar/libwrfio_nfpar.a $ENV{NETCDFPAR_LDFLAGS} : ;
1026 } elsif ( $sw_os eq "Interix" ) {
1027 $_ =~ s:CONFIGURE_NETCDFPAR_LIB_PATH:\$\(WRF_SRC_ROOT_DIR\)/external/io_netcdfpar/libwrfio_nfpar.a -L$sw_netcdfpar_path/lib $sw_usenetcdff $sw_usenetcdf : ;
1028 } else {
1029 $_ =~ s:CONFIGURE_NETCDFPAR_LIB_PATH:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_netcdfpar -lwrfio_nfpar -L$sw_netcdfpar_path/lib $sw_usenetcdff $sw_usenetcdf : ;
1032 else
1033 { $_ =~ s/CONFIGURE_WRFIO_NFPAR//g ;
1034 $_ =~ s:CONFIGURE_NETCDFPAR_FLAG::g ;
1035 $_ =~ s:CONFIGURE_NETCDFPAR_LIB_PATH::g ;
1038 if ( $sw_netcdf_path )
1039 { $_ =~ s/CONFIGURE_WRFIO_NF/wrfio_nf/g ;
1040 $_ =~ s:CONFIGURE_NETCDF_FLAG:-DNETCDF: ;
1041 if ( $ENV{NETCDF_LDFLAGS} ) {
1042 $_ =~ s:CONFIGURE_NETCDF_LIB_PATH:\$\(WRF_SRC_ROOT_DIR\)/external/io_netcdf/libwrfio_nf.a $ENV{NETCDF_LDFLAGS} : ;
1043 } elsif ( $sw_os eq "Interix" ) {
1044 $_ =~ s:CONFIGURE_NETCDF_LIB_PATH:\$\(WRF_SRC_ROOT_DIR\)/external/io_netcdf/libwrfio_nf.a -L$sw_netcdf_path/lib $sw_usenetcdff $sw_usenetcdf : ;
1045 } else {
1046 $_ =~ s:CONFIGURE_NETCDF_LIB_PATH:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_netcdf -lwrfio_nf -L$sw_netcdf_path/lib $sw_usenetcdff $sw_usenetcdf : ;
1049 else
1050 { $_ =~ s/CONFIGURE_WRFIO_NF//g ;
1051 $_ =~ s:CONFIGURE_NETCDF_FLAG::g ;
1052 $_ =~ s:CONFIGURE_NETCDF_LIB_PATH::g ;
1055 if ( $sw_pnetcdf_path )
1056 { $_ =~ s/CONFIGURE_WRFIO_PNF/wrfio_pnf/g ;
1057 $_ =~ s:CONFIGURE_PNETCDF_FLAG:-DPNETCDF: ;
1058 if ( $sw_os eq "Interix" ) {
1059 $_ =~ s:CONFIGURE_PNETCDF_LIB_PATH:\$\(WRF_SRC_ROOT_DIR\)/external/io_pnetcdf/libwrfio_pnf.a -L$sw_pnetcdf_path/lib -lpnetcdf: ;
1060 } else {
1061 $_ =~ s:CONFIGURE_PNETCDF_LIB_PATH:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_pnetcdf -lwrfio_pnf -L$sw_pnetcdf_path/lib -lpnetcdf: ;
1064 else
1065 { $_ =~ s/CONFIGURE_WRFIO_PNF//g ;
1066 $_ =~ s:CONFIGURE_PNETCDF_FLAG::g ;
1067 $_ =~ s:CONFIGURE_PNETCDF_LIB_PATH::g ;
1070 if ( $sw_hdf5_path )
1071 { $_ =~ s:CONFIGURE_HDF5_LIB_PATH:-L$sw_hdf5_path/lib -lhdf5hl_fortran -lhdf5_hl -lhdf5_fortran -lhdf5 -lm -lz: ;
1072 $_ =~ s:CONFIGURE_HDF5_FLAG:-DHDF5: ;
1074 else
1075 { $_ =~ s:CONFIGURE_HDF5_LIB_PATH::g ;
1076 $_ =~ s:CONFIGURE_HDF5_FLAG::g ;
1079 if ( $sw_phdf5_path )
1081 { $_ =~ s/CONFIGURE_WRFIO_PHDF5/wrfio_phdf5/g ;
1082 $_ =~ s:CONFIGURE_PHDF5_FLAG:-DPHDF5: ;
1083 $_ =~ 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: ;
1085 else
1086 { $_ =~ s/CONFIGURE_WRFIO_PHDF5//g ;
1087 $_ =~ s:CONFIGURE_PHDF5_FLAG::g ;
1088 $_ =~ s:CONFIGURE_PHDF5_LIB_PATH::g ;
1091 if ( $sw_jasperlib_path && $sw_jasperinc_path )
1092 { $_ =~ s/CONFIGURE_WRFIO_GRIB2/wrfio_grib2/g ;
1093 $_ =~ s:CONFIGURE_GRIB2_FLAG:-DGRIB2:g ;
1094 $_ =~ s:CONFIGURE_GRIB2_INC:-I$sw_jasperinc_path:g ;
1095 $_ =~ s:CONFIGURE_GRIB2_LIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_grib2 -lio_grib2 -L$sw_jasperlib_path -ljasper:g ;
1097 else
1098 { $_ =~ s/CONFIGURE_WRFIO_GRIB2//g ;
1099 $_ =~ s:CONFIGURE_GRIB2_FLAG::g ;
1100 $_ =~ s:CONFIGURE_GRIB2_INC::g ;
1101 $_ =~ s:CONFIGURE_GRIB2_LIB::g ;
1104 if ( $sw_gpfs_path ne "" )
1105 { if (/^GPFS.*=/)
1106 { $_ =~ s/\r|\n//g;
1107 if ( $sw_gpfs_path ne "DEFAULT" )
1108 { $_ .= " -L" . $sw_gpfs_path ; }
1109 $_ .= " " . $sw_gpfs_lib . "\n" ;
1112 if ( $sw_curl_path ne "" )
1113 { if (/^CURL.*=/)
1114 { $_ =~ s/\r|\n//g;
1115 if ( $sw_curl_path ne "DEFAULT" )
1116 { $_ .= " -L" . $sw_curl_path ; }
1117 $_ .= " " . $sw_curl_lib . "\n" ;
1120 if ( $sw_dep_lib_path ne "" )
1121 { if (/^HDF5.*=/)
1122 { $_ =~ s/\r|\n//g;
1123 $_ .= " " . $sw_hdf5 . "\n" ;
1125 if (/^ZLIB.*=/)
1126 { $_ =~ s/\r|\n//g;
1127 $_ .= " " . $sw_zlib . "\n" ;
1131 @preamble = ( @preamble, $_ ) ;
1133 close ARCH_PREAMBLE ;
1134 print CONFIGURE_WRF @preamble ;
1135 close ARCH_PREAMBLE ;
1136 printf CONFIGURE_WRF "# Settings for %s\n", $optarray[$optchoice] ;
1137 print CONFIGURE_WRF @machopts ;
1138 print "$ENV{WRF_MARS}" ;
1139 if ( $ENV{WRF_MARS} || $ENV{WRF_TITAN} || $ENV{WRF_VENUS} )
1141 open ARCH_PLANETAMBLE, "< arch/planetamble" or die "cannot open arch/planetamble" ;
1142 while ( <ARCH_PLANETAMBLE> ) { print CONFIGURE_WRF } ;
1143 close ARCH_PLANETAMBLE ;
1146 close CONFIGURE_WRF ;
1148 printf "Configuration successful! \n" ;
1149 printf "------------------------------------------------------------------------\n" ;