r4627 | gill | 2010-12-29 16:29:58 -0700 (Wed, 29 Dec 2010) | 5 lines
[wrffire.git] / wrfv2_fire / arch / Config_new.pl
blob7ce365742577f13c894132d61e7ba7c7f17c1104
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 $sw_perl_path = perl ;
9 $sw_netcdf_path = "" ;
10 $sw_pnetcdf_path = "" ;
11 $sw_phdf5_path="";
12 $sw_jasperlib_path="";
13 $sw_jasperinc_path="";
14 $sw_esmflib_path="";
15 $sw_esmfinc_path="";
16 $sw_ldflags="";
17 $sw_compileflags="";
18 $sw_opt_level="";
19 $sw_rwordsize="\$\(NATIVE_RWORDSIZE\)";
20 $sw_rttov_flag = "" ;
21 $sw_rttov_inc = "" ;
22 $sw_crtm_flag = "" ;
23 $sw_4dvar_flag = "" ;
24 $sw_wavelet_flag = "" ;
25 $WRFCHEM = 0 ;
26 $sw_os = "ARCH" ; # ARCH will match any
27 $sw_mach = "ARCH" ; # ARCH will match any
28 $sw_wrf_core = "" ;
29 $sw_da_core = "-DDA_CORE=\$\(WRF_DA_CORE\)" ;
30 $sw_nmm_core = "-DNMM_CORE=\$\(WRF_NMM_CORE\)" ;
31 $sw_em_core = "-DEM_CORE=\$\(WRF_EM_CORE\)" ;
32 $sw_exp_core = "-DEXP_CORE=\$\(WRF_EXP_CORE\)" ;
33 $sw_coamps_core = "-DCOAMPS_CORE=\$\(WRF_COAMPS_CORE\)" ;
34 $sw_dmparallel = "" ;
35 $sw_ompparallel = "" ;
36 $sw_stubmpi = "" ;
37 $sw_usenetcdff = "" ; # for 3.6.2 and greater, the fortran bindings might be in a separate lib file
38 $sw_time = "" ; # name of a timer to time fortran compiles, e.g. timex or time
39 $sw_ifort_r8 = 0 ;
41 while ( substr( $ARGV[0], 0, 1 ) eq "-" )
43 if ( substr( $ARGV[0], 1, 5 ) eq "perl=" )
45 $sw_perl_path = substr( $ARGV[0], 6 ) ;
47 if ( substr( $ARGV[0], 1, 7 ) eq "netcdf=" )
49 $sw_netcdf_path = substr( $ARGV[0], 8 ) ;
51 if ( substr( $ARGV[0], 1, 8 ) eq "pnetcdf=" )
53 $sw_pnetcdf_path = substr( $ARGV[0], 9 ) ;
55 if ( substr( $ARGV[0], 1, 6 ) eq "phdf5=" )
57 $sw_phdf5_path = substr( $ARGV[0], 7 ) ;
59 if ( substr( $ARGV[0], 1, 3 ) eq "os=" )
61 $sw_os = substr( $ARGV[0], 4 ) ;
63 if ( substr( $ARGV[0], 1, 5 ) eq "mach=" )
65 $sw_mach = substr( $ARGV[0], 6 ) ;
67 if ( substr( $ARGV[0], 1, 10 ) eq "opt_level=" )
69 $sw_opt_level = substr( $ARGV[0], 11 ) ;
71 if ( substr( $ARGV[0], 1, 11 ) eq "USENETCDFF=" )
73 $sw_usenetcdff = substr( $ARGV[0], 12 ) ;
75 if ( substr( $ARGV[0], 1, 5 ) eq "time=" )
77 $sw_time = substr( $ARGV[0], 6 ) ;
79 if ( substr( $ARGV[0], 1, 8 ) eq "ldflags=" )
81 $sw_ldflags = substr( $ARGV[0], 9 ) ;
82 # multiple options separated by spaces are passed in from sh script
83 # separated by ! instead. Replace with spaces here.
84 $sw_ldflags =~ s/!/ /g ;
86 if ( substr( $ARGV[0], 1, 9 ) eq "wrf_core=" )
88 $sw_wrf_core = substr( $ARGV[0], 10 ) ;
89 if ( index ( $sw_wrf_core , "EM_CORE" ) > -1 )
91 $sw_em_core = "-DEM_CORE=1" ;
92 $sw_da_core = "-DDA_CORE=0" ;
93 $sw_nmm_core = "-DNMM_CORE=0" ;
94 $sw_exp_core = "-DEXP_CORE=0" ;
95 $sw_coamps_core = "-DCOAMPS_CORE=0" ;
97 if ( index ( $sw_wrf_core , "DA_CORE" ) > -1 )
99 $sw_em_core = "-DEM_CORE=1" ;
100 $sw_da_core = "-DDA_CORE=1" ;
101 $sw_nmm_core = "-DNMM_CORE=0" ;
102 $sw_exp_core = "-DEXP_CORE=0" ;
103 $sw_coamps_core = "-DCOAMPS_CORE=0" ;
105 if ( index ( $sw_wrf_core , "4D_DA_CORE" ) > -1 )
107 $sw_em_core = "-DEM_CORE=1" ;
108 $sw_da_core = "-DDA_CORE=1" ;
109 $sw_nmm_core = "-DNMM_CORE=0" ;
110 $sw_exp_core = "-DEXP_CORE=0" ;
111 $sw_coamps_core = "-DCOAMPS_CORE=0" ;
113 if ( index ( $sw_wrf_core , "NMM_CORE" ) > -1 )
115 $sw_em_core = "-DEM_CORE=0" ;
116 $sw_da_core = "-DDA_CORE=0" ;
117 $sw_nmm_core = "-DNMM_CORE=1" ;
118 $sw_exp_core = "-DEXP_CORE=0" ;
119 $sw_coamps_core = "-DCOAMPS_CORE=0" ;
121 if ( index ( $sw_wrf_core , "EXP_CORE" ) > -1 )
123 $sw_em_core = "-DEM_CORE=0" ;
124 $sw_da_core = "-DDA_CORE=0" ;
125 $sw_nmm_core = "-DNMM_CORE=0" ;
126 $sw_exp_core = "-DEXP_CORE=1" ;
127 $sw_coamps_core = "-DCOAMPS_CORE=0" ;
129 if ( index ( $sw_wrf_core , "COAMPS_CORE" ) > -1 )
131 $sw_em_core = "-DEM_CORE=0" ;
132 $sw_da_core = "-DDA_CORE=0" ;
133 $sw_nmm_core = "-DNMM_CORE=0" ;
134 $sw_exp_core = "-DEXP_CORE=0" ;
135 $sw_coamps_core = "-DCOAMPS_CORE=1" ;
138 if ( substr( $ARGV[0], 1, 13 ) eq "compileflags=" )
140 $sw_compileflags = substr( $ARGV[0], 14 ) ;
141 $sw_compileflags =~ s/!/ /g ;
142 # look for each known option
143 $where_index = index ( $sw_compileflags , "-DWRF_CHEM" ) ;
144 if ( $where_index eq -1 )
146 $WRFCHEM = 0 ;
148 else
150 $WRFCHEM = 1 ;
153 if ( substr( $ARGV[0], 1, 11 ) eq "dmparallel=" )
155 $sw_dmparallel=substr( $ARGV[0], 12 ) ;
157 if ( substr( $ARGV[0], 1, 12 ) eq "ompparallel=" )
159 $sw_ompparallel=substr( $ARGV[0], 13 ) ;
161 shift @ARGV ;
164 $sw_fc = "\$(SFC)" ;
165 $sw_cc = "\$(SCC)" ;
166 $sw_comms_lib = "" ;
167 $sw_comms_include = "" ;
168 $sw_dmparallelflag = "" ;
169 $sw_nest_opt = "" ;
170 $sw_comms_external = "gen_comms_serial module_dm_serial" ;
173 if ( $sw_dmparallel eq "RSL_LITE" )
175 $sw_fc = "\$(DM_FC)" ;
176 $sw_cc = "\$(DM_CC)" ;
177 $sw_dmparallelflag = "-DDM_PARALLEL" ;
178 $sw_comms_lib = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a" ;
179 $sw_comms_external = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a gen_comms_rsllite module_dm_rsllite" ;
180 $sw_comms_include = "-I\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE" ;
183 # The jasper library is required to build Grib2 I/O. User must set
184 # environment variables JASPERLIB and JASPERINC to paths to library and
185 # include files to enable this feature prior to running configure.
186 if ( $ENV{JASPERLIB} && $ENV{JASPERINC} )
188 printf "Configuring to use jasper library to build Grib2 I/O...\n" ;
189 printf(" \$JASPERLIB = %s\n",$ENV{JASPERLIB});
190 printf(" \$JASPERINC = %s\n",$ENV{JASPERINC});
191 $sw_jasperlib_path = $ENV{JASPERLIB};
192 $sw_jasperinc_path = $ENV{JASPERINC};
194 else
196 printf "\$JASPERLIB or \$JASPERINC not found in environment, configuring to build without grib2 I/O...\n" ;
199 # When compiling DA code, we need to always use 8-byte reals.
200 if ( $ENV{WRF_DA_CORE} eq "1" || $sw_da_core eq "-DDA_CORE=1" )
202 $sw_rwordsize = "8";
203 if ( $ENV{CRTM} )
205 $sw_crtm_flag = "-DCRTM";
207 if ( $ENV{RTTOV} )
209 $sw_rttov_flag = "-DRTTOV";
210 $sw_rttov_inc = "-I$ENV{RTTOV}/include -I$ENV{RTTOV}/mod";
212 if ( $sw_wrf_core eq "4D_DA_CORE" )
214 $sw_4dvar_flag = "-DVAR4D";
216 if ( $ENV{WAVELET} )
218 $sw_wavelet_flag = "-DWAVELET";
222 # A separately-installed ESMF library is required to build the ESMF
223 # implementation of WRF IOAPI in external/io_esmf. This is needed
224 # to couple WRF with other ESMF components. User must set environment
225 # variables ESMFLIB and ESMFINC to paths ESMF to library and include
226 # files to enable this feature prior to running configure.
227 if ( $ENV{ESMFLIB} && $ENV{ESMFINC} )
229 printf "Configuring to use ESMF library to build WRF...\n" ;
230 printf "WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING\n" ;
231 printf "WARNING: THIS IS AN EXPERIMENTAL CONFIGURATION\n" ;
232 printf "WARNING: IT DOES NOT WORK WITH NESTING\n" ;
233 printf "WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING\n" ;
234 printf(" \$ESMFLIB = %s\n",$ENV{ESMFLIB});
235 printf(" \$ESMFINC = %s\n",$ENV{ESMFINC});
236 $sw_esmflib_path = $ENV{ESMFLIB};
237 $sw_esmfinc_path = $ENV{ESMFINC};
238 $sw_esmf_ldflag = "yes" ;
241 # parse the configure.wrf file
243 $validresponse = 0 ;
245 @platforms = qw ( serial smpar dmpar dm+sm ) ;
247 # Display the choices to the user and get selection
248 until ( $validresponse ) {
249 printf "------------------------------------------------------------------------\n" ;
250 printf "Please select from among the following supported platforms.\n\n" ;
252 $opt = 1 ;
253 open CONFIGURE_DEFAULTS, "< ./arch/configure_new.defaults"
254 or die "Cannot open ./arch/configure_new.defaults for reading" ;
255 while ( <CONFIGURE_DEFAULTS> )
257 for $paropt ( @platforms )
259 if ( substr( $_, 0, 5 ) eq "#ARCH"
260 && ( index( $_, $sw_os ) >= 0 ) && ( index( $_, $sw_mach ) >= 0 )
261 && ( index($_, $paropt) >= 0 ) )
263 $optstr[$opt] = substr($_,6) ;
264 $optstr[$opt] =~ s/^[ ]*// ;
265 $optstr[$opt] =~ s/#.*$//g ;
266 chomp($optstr[$opt]) ;
267 $optstr[$opt] = $optstr[$opt]." (".$paropt.")" ;
268 if ( substr( $optstr[$opt], 0,4 ) ne "NULL" )
270 printf " %2d. %s\n",$opt,$optstr[$opt] ;
271 $opt++ ;
276 close CONFIGURE_DEFAULTS ;
278 $opt -- ;
280 printf "\nEnter selection [%d-%d] : ",1,$opt ;
281 $response = <STDIN> ;
283 if ( $response == -1 ) { exit ; }
285 if ( $response >= 1 && $response <= $opt )
286 { $validresponse = 1 ; }
287 else
288 { printf("\nInvalid response (%d)\n",$response);}
290 printf "------------------------------------------------------------------------\n" ;
292 $optchoice = $response ;
294 open CONFIGURE_DEFAULTS, "cat ./arch/configure_new.defaults |" ;
295 $latchon = 0 ;
296 while ( <CONFIGURE_DEFAULTS> )
298 if ( substr( $_, 0, 5 ) eq "#ARCH" && $latchon == 1 )
300 close CONFIGURE_DEFAULTS ;
301 if ( $sw_opt_level eq "-f" ) {
302 open CONFIGURE_DEFAULTS, "cat ./arch/postamble_new ./arch/noopt_exceptions_f |" or die "horribly" ;
303 } else {
304 open CONFIGURE_DEFAULTS, "cat ./arch/postamble_new ./arch/noopt_exceptions |" or die "horribly" ;
307 if ( $latchon == 1 )
309 $_ =~ s/CONFIGURE_PERL_PATH/$sw_perl_path/g ;
310 $_ =~ s/CONFIGURE_NETCDF_PATH/$sw_netcdf_path/g ;
311 $_ =~ s/CONFIGURE_PNETCDF_PATH/$sw_pnetcdf_path/g ;
312 $_ =~ s/CONFIGURE_PHDF5_PATH/$sw_phdf5_path/g ;
313 $_ =~ s/CONFIGURE_LDFLAGS/$sw_ldflags/g ;
314 $_ =~ s/CONFIGURE_COMPILEFLAGS/$sw_compileflags/g ;
315 $_ =~ s/CONFIGURE_RWORDSIZE/$sw_rwordsize/g ;
316 $_ =~ s/CONFIGURE_FC/$sw_time $sw_fc/g ;
317 $_ =~ s/CONFIGURE_CC/$sw_cc/g ;
318 $_ =~ s/CONFIGURE_COMMS_LIB/$sw_comms_lib/g ;
319 $_ =~ s/CONFIGURE_COMMS_INCLUDE/$sw_comms_include/g ;
320 $_ =~ s/CONFIGURE_COMMS_EXTERNAL/$sw_comms_external/g ;
321 if ( $sw_os ne "CYGWIN_NT" ) {
322 $_ =~ s/#NOWIN// ;
324 $_ =~ s/CONFIGURE_DMPARALLEL/$sw_dmparallelflag/g ;
325 $_ =~ s/CONFIGURE_STUBMPI/$sw_stubmpi/g ;
326 $_ =~ s/CONFIGURE_NESTOPT/$sw_nest_opt/g ;
327 $_ =~ s/CONFIGURE_4DVAR_FLAG/$sw_4dvar_flag/g ;
328 $_ =~ s/CONFIGURE_CRTM_FLAG/$sw_crtm_flag/g ;
329 $_ =~ s/CONFIGURE_RTTOV_FLAG/$sw_rttov_flag/g ;
330 $_ =~ s/CONFIGURE_RTTOV_INC/$sw_rttov_inc/g ;
331 $_ =~ s/CONFIGURE_WAVELET_FLAG/$sw_wavelet_flag/g ;
332 if ( $sw_ifort_r8 ) {
333 $_ =~ s/^PROMOTION.*=/PROMOTION = -r8 /g ;
335 if ( $sw_dmparallel ne "" && ($_ =~ /^DMPARALLEL[=\t ]/) ) {
336 $_ =~ s/#// ;
338 if ( $sw_ompparallel ne "" && ( $_ =~ /^OMPCPP[=\t ]/ || $_ =~ /^OMPCC[=\t ]/ || $_ =~ /^OMP[=\t ]/ ) ) {
339 $_ =~ s/#// ;
340 $_ =~ s/#// ;
341 $_ =~ s/#// ;
343 if ( $sw_netcdf_path )
344 { $_ =~ s/CONFIGURE_WRFIO_NF/wrfio_nf/g ;
345 $_ =~ s:CONFIGURE_NETCDF_FLAG:-DNETCDF: ;
346 if ( $sw_os == Interix ) {
347 $_ =~ s:CONFIGURE_NETCDF_LIB_PATH:\$\(WRF_SRC_ROOT_DIR\)/external/io_netcdf/libwrfio_nf.a -L$sw_netcdf_path/lib $sw_usenetcdff -lnetcdf : ;
348 } else {
349 $_ =~ s:CONFIGURE_NETCDF_LIB_PATH:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_netcdf -lwrfio_nf -L$sw_netcdf_path/lib $sw_usenetcdff -lnetcdf : ;
352 else
353 { $_ =~ s/CONFIGURE_WRFIO_NF//g ;
354 $_ =~ s:CONFIGURE_NETCDF_FLAG::g ;
355 $_ =~ s:CONFIGURE_NETCDF_LIB_PATH::g ;
358 if ( $sw_pnetcdf_path )
359 { $_ =~ s/CONFIGURE_WRFIO_PNF/wrfio_pnf/g ;
360 $_ =~ s:CONFIGURE_PNETCDF_FLAG:-DPNETCDF: ;
361 if ( $sw_os == Interix ) {
362 $_ =~ s:CONFIGURE_PNETCDF_LIB_PATH:\$\(WRF_SRC_ROOT_DIR\)/external/io_pnetcdf/libwrfio_pnf.a -L$sw_pnetcdf_path/lib -lpnetcdf: ;
363 } else {
364 $_ =~ s:CONFIGURE_PNETCDF_LIB_PATH:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_pnetcdf -lwrfio_pnf -L$sw_pnetcdf_path/lib -lpnetcdf: ;
367 else
368 { $_ =~ s/CONFIGURE_WRFIO_PNF//g ;
369 $_ =~ s:CONFIGURE_PNETCDF_FLAG::g ;
370 $_ =~ s:CONFIGURE_PNETCDF_LIB_PATH::g ;
373 if ( $sw_phdf5_path )
375 { $_ =~ s/CONFIGURE_WRFIO_PHDF5/wrfio_phdf5/g ;
376 $_ =~ s:CONFIGURE_PHDF5_FLAG:-DPHDF5: ;
377 $_ =~ 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: ;
379 else
380 { $_ =~ s/CONFIGURE_WRFIO_PHDF5//g ;
381 $_ =~ s:CONFIGURE_PHDF5_FLAG::g ;
382 $_ =~ s:CONFIGURE_PHDF5_LIB_PATH::g ;
385 if ( $sw_jasperlib_path && $sw_jasperinc_path )
386 { $_ =~ s/CONFIGURE_WRFIO_GRIB2/wrfio_grib2/g ;
387 $_ =~ s:CONFIGURE_GRIB2_FLAG:-DGRIB2:g ;
388 $_ =~ s:CONFIGURE_GRIB2_INC:-I$sw_jasperinc_path:g ;
389 $_ =~ s:CONFIGURE_GRIB2_LIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_grib2 -lio_grib2 -L$sw_jasperlib_path -ljasper:g ;
391 else
392 { $_ =~ s/CONFIGURE_WRFIO_GRIB2//g ;
393 $_ =~ s:CONFIGURE_GRIB2_FLAG::g ;
394 $_ =~ s:CONFIGURE_GRIB2_INC::g ;
395 $_ =~ s:CONFIGURE_GRIB2_LIB::g ;
399 # ESMF substitutions in configure.defaults
400 if ( $sw_esmflib_path && $sw_esmfinc_path )
402 $_ =~ s:CONFIGURE_ESMF_FLAG:-DESMFIO:g ;
403 $_ =~ s:ESMFIOLIB:-L$sw_esmflib_path -lesmf -L\$\(WRF_SRC_ROOT_DIR\)/external/io_esmf -lwrfio_esmf \$\(ESMF_LIB_FLAGS\):g ;
404 $_ =~ s:ESMFIOEXTLIB:-L$sw_esmflib_path -lesmf -L\$\(WRF_SRC_ROOT_DIR\)/external/io_esmf -lwrfio_esmf \$\(ESMF_LIB_FLAGS\):g ;
405 $_ =~ s:ESMFLIBFLAG:\$\(ESMF_LDFLAG\):g ;
407 else
409 $_ =~ s:CONFIGURE_ESMF_FLAG::g ;
410 $_ =~ s:ESMFLIBFLAG::g ;
411 if ( $sw_os == Interix ) {
412 $_ =~ s:ESMFIOLIB:\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90/libesmf_time.a:g ;
413 $_ =~ s:ESMFIOEXTLIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90/libesmf_time.a:g ;
414 } else {
415 $_ =~ s:ESMFIOLIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90 -lesmf_time:g ;
416 $_ =~ s:ESMFIOEXTLIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90 -lesmf_time:g ;
419 if ( $ENV{HWRF} )
421 $_ =~ s:CONFIGURE_ATMPOM_LIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/atm_pom -latm_pom:g ;
422 $_ =~ s:CONFIGURE_ATMPOM_INC:-I\$\(WRF_SRC_ROOT_DIR\)/external/atm_pom:g;
423 $_ =~ s/CONFIGURE_ATMPOM/atm_pom/g ;
425 else
427 $_ =~ s:CONFIGURE_ATMPOM_LIB::g ;
428 $_ =~ s/CONFIGURE_ATMPOM//g ;
429 $_ =~ s:CONFIGURE_ATMPOM_INC::g;
432 if ( ! (substr( $_, 0, 5 ) eq "#ARCH") ) { @machopts = ( @machopts, $_ ) ; }
433 if ( substr( $_, 0, 10 ) eq "ENVCOMPDEF" )
435 @machopts = ( @machopts, "WRF_CHEM\t=\t$WRFCHEM \n" ) ;
439 # nesting support
440 # 0 = no nesting (only selectable for serial and smpar)
441 # 1 = basic nesting (serial and smpar compile with RSL_LITE and STUBMPI; dmpar and dm+sm use RSL_LITE and MPI)
442 # 2 = nesting with prescribed moves (add -DMOVE_NESTS to ARCHFLAGS)
443 # 3 = nesting with prescribed moves (add -DMOVE_NESTS and -DVORTEX_CENTER to ARCHFLAGS)
445 for $paropt ( @platforms )
447 if ( substr( $_, 0, 5 ) eq "#ARCH" && $latchon == 0
448 && ( index( $_, $sw_os ) >= 0 ) && ( index( $_, $sw_mach ) >= 0 )
449 && ( index($_, $paropt) >= 0 ) )
451 $x=substr($_,6) ;
452 $x=~s/^[ ]*// ;
453 $x =~ s/#.*$//g ;
454 chomp($x) ;
455 $x = $x." (".$paropt.")" ;
456 if ( $x eq $optstr[$optchoice] )
458 $latchon = 1 ;
459 $sw_ompparallel = "" ;
460 $sw_dmparallel = "" ;
461 $validresponse = 0 ;
462 #only allow parallel netcdf if the user has chosen parallel option
463 if ( $paropt ne 'dmpar' && $paropt ne 'dm+sm' ) { $sw_pnetcdf_path = "" ; }
465 until ( $validresponse ) {
466 if ( $paropt eq 'serial' || $paropt eq 'smpar' ) {
467 printf "Compile for nesting? (0=no nesting, 1=basic, 2=preset moves, 3=vortex following) [default 0]: " ;
468 } else {
469 printf "Compile for nesting? (1=basic, 2=preset moves, 3=vortex following) [default 1]: " ;
471 if ( $ENV{WRF_DA_CORE} eq "1" || $sw_da_core eq "-DDA_CORE=1" ) {
472 $response = 1 ;
473 } elsif ( $ENV{HWRF} ) {
474 printf "HWRF requires moving nests";
475 $response = "2\n";
476 } else {
477 $response = <STDIN> ;
479 printf "\n" ;
480 lc $response ;
481 chop $response ;
482 if ( $response == "" || ($response >= 0 && $response <= 3) )
483 { $validresponse = 1 ; }
484 else
485 { printf("\nInvalid response (%d)\n",$response);}
487 if ( $response == "" ) {
488 if ( ( $paropt eq 'serial' || $paropt eq 'smpar' ) ) { $response = 0 ; }
489 else { $response = 1 ; }
491 if ( $response == 0 ) {
492 if ( ! ( $paropt eq 'serial' || $paropt eq 'smpar' ) ) { $response = 1 ; }
494 if ( ( $response == 1 ) || ( $response == 2 ) || ( $response == 3 ) ) {
495 if ( ( $paropt eq 'serial' || $paropt eq 'smpar' ) ) { # nesting without MPI
496 $sw_stubmpi = "-DSTUBMPI" ;
497 if ( $sw_os ne "CYGWIN_NT" ) {
498 $sw_comms_lib = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a" ;
499 } else {
500 $sw_comms_lib = "../external/RSL_LITE/librsl_lite.a" ;
502 $sw_comms_external = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a gen_comms_rsllite module_dm_rsllite" ;
503 $sw_dmparallel = "RSL_LITE" ;
504 $sw_dmparallelflag = "-DDM_PARALLEL" ;
507 if ( $response == 2 ) {
508 $sw_nest_opt = "-DMOVE_NESTS" ;
509 } elsif ( $response == 3 ) {
510 $sw_nest_opt = "-DMOVE_NESTS -DVORTEX_CENTER" ;
512 if ( $paropt eq 'smpar' || $paropt eq 'dm+sm' ) { $sw_ompparallel = "OMP" ; }
513 if ( $paropt eq 'dmpar' || $paropt eq 'dm+sm' ) {
514 if ( $sw_os ne "CYGWIN_NT" ) {
515 $sw_comms_lib = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a" ;
516 } else {
517 $sw_comms_lib = "../external/RSL_LITE/librsl_lite.a" ;
519 $sw_comms_external = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a gen_comms_rsllite module_dm_rsllite" ;
520 $sw_dmparallel = "RSL_LITE" ;
521 $sw_dmparallelflag = "-DDM_PARALLEL" ;
522 $sw_fc = "\$(DM_FC)" ;
523 $sw_cc = "\$(DM_CC)" ;
524 } # only one option in v3.0
526 $sw_ifort_r8 = 0 ;
527 if ( index ( $x, "ifort" ) > -1 || index ( $x, "intel compiler" ) > -1 ) {
528 if ( $sw_rwordsize == 8 ) {
529 $sw_ifort_r8 = 1 ;
536 close CONFIGURE_DEFAULTS ;
537 close POSTAMBLE ;
538 close ARCH_NOOPT_EXCEPTIONS ;
540 open CONFIGURE_WRF, "> configure.wrf" or die "cannot append configure.wrf" ;
541 open ARCH_PREAMBLE, "< arch/preamble_new" or die "cannot open arch/preamble_new" ;
542 my @preamble;
543 # apply substitutions to the preamble...
544 while ( <ARCH_PREAMBLE> )
546 # ESMF substitutions in preamble
547 if ( $sw_esmflib_path && $sw_esmfinc_path )
549 $_ =~ s/ESMFCOUPLING/1/g ;
550 $_ =~ s:ESMFMODDEPENDENCE:\$\(WRF_SRC_ROOT_DIR\)/external/io_esmf/module_utility.o:g ;
551 $_ =~ s:ESMFMODINC:-I$sw_esmfinc_path -I\$\(WRF_SRC_ROOT_DIR\)/main:g ;
552 $_ =~ s:ESMFIOINC:-I\$\(WRF_SRC_ROOT_DIR\)/external/io_esmf:g ;
553 $_ =~ s:ESMFIODEFS:-DESMFIO:g ;
554 $_ =~ s:ESMFTARGET:wrfio_esmf:g ;
556 else
558 $_ =~ s/ESMFCOUPLING/0/g ;
559 $_ =~ s:ESMFMODDEPENDENCE:\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90/module_utility.o:g ;
560 $_ =~ s:ESMFMODINC::g ;
561 $_ =~ s:ESMFIOINC:-I\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90:g ;
562 $_ =~ s:ESMFIODEFS::g ;
563 $_ =~ s:ESMFTARGET:esmf_time:g ;
565 if ( $ENV{HWRF} )
567 $_ =~ s:CONFIGURE_ATMPOM_LIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/atm_pom -latm_pom:g ;
568 $_ =~ s/CONFIGURE_ATMPOM/atm_pom/g ;
570 else
572 $_ =~ s:CONFIGURE_ATMPOM_LIB::g ;
573 $_ =~ s/CONFIGURE_ATMPOM//g ;
575 $_ =~ s:CONFIGURE_EM_CORE:$sw_em_core:g ;
576 $_ =~ s:CONFIGURE_DA_CORE:$sw_da_core:g ;
577 $_ =~ s:CONFIGURE_NMM_CORE:$sw_nmm_core:g ;
578 $_ =~ s:CONFIGURE_COAMPS_CORE:$sw_coamps_core:g ;
579 $_ =~ s:CONFIGURE_EXP_CORE:$sw_exp_core:g ;
581 @preamble = ( @preamble, $_ ) ;
583 close ARCH_PREAMBLE ;
584 print CONFIGURE_WRF @preamble ;
585 close ARCH_PREAMBLE ;
586 printf CONFIGURE_WRF "# Settings for %s\n", $optstr[$optchoice] ;
587 print CONFIGURE_WRF @machopts ;
588 print "$ENV{WRF_MARS}" ;
589 if ( $ENV{WRF_MARS} || $ENV{WRF_TITAN} || $ENV{WRF_VENUS} )
591 open ARCH_PLANETAMBLE, "< arch/planetamble" or die "cannot open arch/planetamble" ;
592 while ( <ARCH_PLANETAMBLE> ) { print CONFIGURE_WRF } ;
593 close ARCH_PLANETAMBLE ;
596 close CONFIGURE_WRF ;
598 printf "Configuration successful. To build the model type compile . \n" ;
599 printf "------------------------------------------------------------------------\n" ;