r5152 | xinzhang | 2011-09-26 21:04:33 -0700 (Mon, 26 Sep 2011) | 3 lines
[wrffire.git] / wrfv2_fire / arch / Config_new.pl
blobb161e70943b799db064b6aa74a012a2052924862
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 if ( $sw_wrf_core eq "4D_DA_CORE" )
246 { @platforms = qw ( serial dmpar ) ; }
247 else
248 { @platforms = qw ( serial smpar dmpar dm+sm ) ; }
250 # Display the choices to the user and get selection
251 until ( $validresponse ) {
252 printf "------------------------------------------------------------------------\n" ;
253 printf "Please select from among the following supported platforms.\n\n" ;
255 $opt = 1 ;
256 open CONFIGURE_DEFAULTS, "< ./arch/configure_new.defaults"
257 or die "Cannot open ./arch/configure_new.defaults for reading" ;
258 while ( <CONFIGURE_DEFAULTS> )
260 for $paropt ( @platforms )
262 if ( substr( $_, 0, 5 ) eq "#ARCH"
263 && ( index( $_, $sw_os ) >= 0 ) && ( index( $_, $sw_mach ) >= 0 )
264 && ( index($_, $paropt) >= 0 ) )
266 $optstr[$opt] = substr($_,6) ;
267 $optstr[$opt] =~ s/^[ ]*// ;
268 $optstr[$opt] =~ s/#.*$//g ;
269 chomp($optstr[$opt]) ;
270 $optstr[$opt] = $optstr[$opt]." (".$paropt.")" ;
271 if ( substr( $optstr[$opt], 0,4 ) ne "NULL" )
273 printf " %2d. %s\n",$opt,$optstr[$opt] ;
274 $opt++ ;
279 close CONFIGURE_DEFAULTS ;
281 $opt -- ;
283 printf "\nEnter selection [%d-%d] : ",1,$opt ;
284 $response = <STDIN> ;
286 if ( $response == -1 ) { exit ; }
288 if ( $response >= 1 && $response <= $opt )
289 { $validresponse = 1 ; }
290 else
291 { printf("\nInvalid response (%d)\n",$response);}
293 printf "------------------------------------------------------------------------\n" ;
295 $optchoice = $response ;
297 open CONFIGURE_DEFAULTS, "cat ./arch/configure_new.defaults |" ;
298 $latchon = 0 ;
299 while ( <CONFIGURE_DEFAULTS> )
301 if ( substr( $_, 0, 5 ) eq "#ARCH" && $latchon == 1 )
303 close CONFIGURE_DEFAULTS ;
304 if ( $sw_opt_level eq "-f" ) {
305 open CONFIGURE_DEFAULTS, "cat ./arch/postamble_new ./arch/noopt_exceptions_f |" or die "horribly" ;
306 } else {
307 open CONFIGURE_DEFAULTS, "cat ./arch/postamble_new ./arch/noopt_exceptions |" or die "horribly" ;
310 if ( $latchon == 1 )
312 $_ =~ s/CONFIGURE_PERL_PATH/$sw_perl_path/g ;
313 $_ =~ s/CONFIGURE_NETCDF_PATH/$sw_netcdf_path/g ;
314 $_ =~ s/CONFIGURE_PNETCDF_PATH/$sw_pnetcdf_path/g ;
315 $_ =~ s/CONFIGURE_PHDF5_PATH/$sw_phdf5_path/g ;
316 $_ =~ s/CONFIGURE_LDFLAGS/$sw_ldflags/g ;
317 $_ =~ s/CONFIGURE_COMPILEFLAGS/$sw_compileflags/g ;
318 $_ =~ s/CONFIGURE_RWORDSIZE/$sw_rwordsize/g ;
319 $_ =~ s/CONFIGURE_FC/$sw_time $sw_fc/g ;
320 $_ =~ s/CONFIGURE_CC/$sw_cc/g ;
321 $_ =~ s/CONFIGURE_COMMS_LIB/$sw_comms_lib/g ;
322 $_ =~ s/CONFIGURE_COMMS_INCLUDE/$sw_comms_include/g ;
323 $_ =~ s/CONFIGURE_COMMS_EXTERNAL/$sw_comms_external/g ;
324 if ( $sw_os ne "CYGWIN_NT" ) {
325 $_ =~ s/#NOWIN// ;
327 $_ =~ s/CONFIGURE_DMPARALLEL/$sw_dmparallelflag/g ;
328 $_ =~ s/CONFIGURE_STUBMPI/$sw_stubmpi/g ;
329 $_ =~ s/CONFIGURE_NESTOPT/$sw_nest_opt/g ;
330 $_ =~ s/CONFIGURE_4DVAR_FLAG/$sw_4dvar_flag/g ;
331 $_ =~ s/CONFIGURE_CRTM_FLAG/$sw_crtm_flag/g ;
332 $_ =~ s/CONFIGURE_RTTOV_FLAG/$sw_rttov_flag/g ;
333 $_ =~ s/CONFIGURE_RTTOV_INC/$sw_rttov_inc/g ;
334 $_ =~ s/CONFIGURE_WAVELET_FLAG/$sw_wavelet_flag/g ;
335 if ( $sw_ifort_r8 ) {
336 $_ =~ s/^PROMOTION.*=/PROMOTION = -r8 /g ;
338 if ( $sw_dmparallel ne "" && ($_ =~ /^DMPARALLEL[=\t ]/) ) {
339 $_ =~ s/#// ;
341 if ( $sw_ompparallel ne "" && ( $_ =~ /^OMPCPP[=\t ]/ || $_ =~ /^OMPCC[=\t ]/ || $_ =~ /^OMP[=\t ]/ ) ) {
342 $_ =~ s/#// ;
343 $_ =~ s/#// ;
344 $_ =~ s/#// ;
346 if ( $sw_netcdf_path )
347 { $_ =~ s/CONFIGURE_WRFIO_NF/wrfio_nf/g ;
348 $_ =~ s:CONFIGURE_NETCDF_FLAG:-DNETCDF: ;
349 if ( $sw_os eq "Interix" ) {
350 $_ =~ s:CONFIGURE_NETCDF_LIB_PATH:\$\(WRF_SRC_ROOT_DIR\)/external/io_netcdf/libwrfio_nf.a -L$sw_netcdf_path/lib $sw_usenetcdff -lnetcdf : ;
351 } else {
352 $_ =~ s:CONFIGURE_NETCDF_LIB_PATH:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_netcdf -lwrfio_nf -L$sw_netcdf_path/lib $sw_usenetcdff -lnetcdf : ;
355 else
356 { $_ =~ s/CONFIGURE_WRFIO_NF//g ;
357 $_ =~ s:CONFIGURE_NETCDF_FLAG::g ;
358 $_ =~ s:CONFIGURE_NETCDF_LIB_PATH::g ;
361 if ( $sw_pnetcdf_path )
362 { $_ =~ s/CONFIGURE_WRFIO_PNF/wrfio_pnf/g ;
363 $_ =~ s:CONFIGURE_PNETCDF_FLAG:-DPNETCDF: ;
364 if ( $sw_os eq "Interix" ) {
365 $_ =~ s:CONFIGURE_PNETCDF_LIB_PATH:\$\(WRF_SRC_ROOT_DIR\)/external/io_pnetcdf/libwrfio_pnf.a -L$sw_pnetcdf_path/lib -lpnetcdf: ;
366 } else {
367 $_ =~ s:CONFIGURE_PNETCDF_LIB_PATH:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_pnetcdf -lwrfio_pnf -L$sw_pnetcdf_path/lib -lpnetcdf: ;
370 else
371 { $_ =~ s/CONFIGURE_WRFIO_PNF//g ;
372 $_ =~ s:CONFIGURE_PNETCDF_FLAG::g ;
373 $_ =~ s:CONFIGURE_PNETCDF_LIB_PATH::g ;
376 if ( $sw_phdf5_path )
378 { $_ =~ s/CONFIGURE_WRFIO_PHDF5/wrfio_phdf5/g ;
379 $_ =~ s:CONFIGURE_PHDF5_FLAG:-DPHDF5: ;
380 $_ =~ 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: ;
382 else
383 { $_ =~ s/CONFIGURE_WRFIO_PHDF5//g ;
384 $_ =~ s:CONFIGURE_PHDF5_FLAG::g ;
385 $_ =~ s:CONFIGURE_PHDF5_LIB_PATH::g ;
388 if ( $sw_jasperlib_path && $sw_jasperinc_path )
389 { $_ =~ s/CONFIGURE_WRFIO_GRIB2/wrfio_grib2/g ;
390 $_ =~ s:CONFIGURE_GRIB2_FLAG:-DGRIB2:g ;
391 $_ =~ s:CONFIGURE_GRIB2_INC:-I$sw_jasperinc_path:g ;
392 $_ =~ s:CONFIGURE_GRIB2_LIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_grib2 -lio_grib2 -L$sw_jasperlib_path -ljasper:g ;
394 else
395 { $_ =~ s/CONFIGURE_WRFIO_GRIB2//g ;
396 $_ =~ s:CONFIGURE_GRIB2_FLAG::g ;
397 $_ =~ s:CONFIGURE_GRIB2_INC::g ;
398 $_ =~ s:CONFIGURE_GRIB2_LIB::g ;
402 # ESMF substitutions in configure.defaults
403 if ( $sw_esmflib_path && $sw_esmfinc_path )
405 $_ =~ s:CONFIGURE_ESMF_FLAG:-DESMFIO:g ;
406 # pre 5.2.0r
407 # $_ =~ s:ESMFIOLIB:-L$sw_esmflib_path -lesmf -L\$\(WRF_SRC_ROOT_DIR\)/external/io_esmf -lwrfio_esmf \$\(ESMF_LIB_FLAGS\):g ;
408 # $_ =~ s:ESMFIOEXTLIB:-L$sw_esmflib_path -lesmf -L\$\(WRF_SRC_ROOT_DIR\)/external/io_esmf -lwrfio_esmf \$\(ESMF_LIB_FLAGS\):g ;
409 # post 5.2.0r
410 $_ =~ s:ESMFIOLIB:\$\(ESMF_F90LINKPATHS\) \$\(ESMF_F90ESMFLINKLIBS\) -L\$\(WRF_SRC_ROOT_DIR\)/external/io_esmf -lwrfio_esmf: ;
411 $_ =~ s:ESMFIOEXTLIB:\$\(ESMF_IO_LIB\): ;
414 $_ =~ s:ESMFLIBFLAG:\$\(ESMF_LDFLAG\):g ;
415 # $_ =~ s:ESMFINCLUDEGOESHERE:'include $(ESMFLIB)/esmf.mk': ;
418 else
420 $_ =~ s:CONFIGURE_ESMF_FLAG::g ;
421 $_ =~ s:ESMFLIBFLAG::g ;
422 if ( $sw_os eq "Interix" ) {
423 $_ =~ s:ESMFIOLIB:\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90/libesmf_time.a:g ;
424 $_ =~ s:ESMFIOEXTLIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90/libesmf_time.a:g ;
425 } else {
426 $_ =~ s:ESMFIOLIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90 -lesmf_time:g ;
427 $_ =~ s:ESMFIOEXTLIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90 -lesmf_time:g ;
430 if ( $ENV{HWRF} )
432 $_ =~ s:CONFIGURE_ATMOCN_LIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/atm_ocn -latm_ocn:g ;
433 $_ =~ s:CONFIGURE_ATMOCN_INC:-I\$\(WRF_SRC_ROOT_DIR\)/external/atm_ocn:g;
434 $_ =~ s/CONFIGURE_ATMOCN/atm_ocn/g ;
436 else
438 $_ =~ s:CONFIGURE_ATMOCN_LIB::g ;
439 $_ =~ s/CONFIGURE_ATMOCN//g ;
440 $_ =~ s:CONFIGURE_ATMOCN_INC::g;
443 if ( ! (substr( $_, 0, 5 ) eq "#ARCH") ) { @machopts = ( @machopts, $_ ) ; }
444 if ( substr( $_, 0, 10 ) eq "ENVCOMPDEF" )
446 @machopts = ( @machopts, "WRF_CHEM\t=\t$WRFCHEM \n" ) ;
450 # nesting support
451 # 0 = no nesting (only selectable for serial and smpar)
452 # 1 = basic nesting (serial and smpar compile with RSL_LITE and STUBMPI; dmpar and dm+sm use RSL_LITE and MPI)
453 # 2 = nesting with prescribed moves (add -DMOVE_NESTS to ARCHFLAGS)
454 # 3 = nesting with prescribed moves (add -DMOVE_NESTS and -DVORTEX_CENTER to ARCHFLAGS)
456 for $paropt ( @platforms )
458 if ( substr( $_, 0, 5 ) eq "#ARCH" && $latchon == 0
459 && ( index( $_, $sw_os ) >= 0 ) && ( index( $_, $sw_mach ) >= 0 )
460 && ( index($_, $paropt) >= 0 ) )
462 $x=substr($_,6) ;
463 $x=~s/^[ ]*// ;
464 $x =~ s/#.*$//g ;
465 chomp($x) ;
466 $x = $x." (".$paropt.")" ;
467 if ( $x eq $optstr[$optchoice] )
469 $latchon = 1 ;
470 $sw_ompparallel = "" ;
471 $sw_dmparallel = "" ;
472 $validresponse = 0 ;
473 #only allow parallel netcdf if the user has chosen parallel option
474 if ( $paropt ne 'dmpar' && $paropt ne 'dm+sm' ) { $sw_pnetcdf_path = "" ; }
476 until ( $validresponse ) {
477 if ( $paropt eq 'serial' || $paropt eq 'smpar' ) {
478 printf "Compile for nesting? (0=no nesting, 1=basic, 2=preset moves, 3=vortex following) [default 0]: " ;
479 } else {
480 printf "Compile for nesting? (1=basic, 2=preset moves, 3=vortex following) [default 1]: " ;
482 if ( $ENV{WRF_DA_CORE} eq "1" || $sw_da_core eq "-DDA_CORE=1" ) {
483 $response = 1 ;
484 } elsif ( $ENV{HWRF} ) {
485 printf "HWRF requires moving nests";
486 $response = "2\n";
487 } else {
488 $response = <STDIN> ;
490 printf "\n" ;
491 lc $response ;
492 chop $response ;
493 if ( $response == "" || ($response >= 0 && $response <= 3) )
494 { $validresponse = 1 ; }
495 else
496 { printf("\nInvalid response (%d)\n",$response);}
498 if ( $response == "" ) {
499 if ( ( $paropt eq 'serial' || $paropt eq 'smpar' ) ) { $response = 0 ; }
500 else { $response = 1 ; }
502 if ( $response == 0 ) {
503 if ( ! ( $paropt eq 'serial' || $paropt eq 'smpar' ) ) { $response = 1 ; }
505 if ( ( $response == 1 ) || ( $response == 2 ) || ( $response == 3 ) ) {
506 if ( ( $paropt eq 'serial' || $paropt eq 'smpar' ) ) { # nesting without MPI
507 $sw_stubmpi = "-DSTUBMPI" ;
508 if ( $sw_os ne "CYGWIN_NT" ) {
509 $sw_comms_lib = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a" ;
510 } else {
511 $sw_comms_lib = "../external/RSL_LITE/librsl_lite.a" ;
513 $sw_comms_external = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a gen_comms_rsllite module_dm_rsllite" ;
514 $sw_dmparallel = "RSL_LITE" ;
515 $sw_dmparallelflag = "-DDM_PARALLEL" ;
518 if ( $response == 2 ) {
519 $sw_nest_opt = "-DMOVE_NESTS" ;
520 } elsif ( $response == 3 ) {
521 $sw_nest_opt = "-DMOVE_NESTS -DVORTEX_CENTER" ;
523 if ( $paropt eq 'smpar' || $paropt eq 'dm+sm' ) { $sw_ompparallel = "OMP" ; }
524 if ( $paropt eq 'dmpar' || $paropt eq 'dm+sm' ) {
525 if ( $sw_os ne "CYGWIN_NT" ) {
526 $sw_comms_lib = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a" ;
527 if ( $sw_wrf_core eq "4D_DA_CORE" )
529 $sw_comms_lib = "\$(WRFPLUS_DIR)/external/RSL_LITE/librsl_lite.a" ;
531 } else {
532 $sw_comms_lib = "../external/RSL_LITE/librsl_lite.a" ;
534 $sw_comms_external = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a gen_comms_rsllite module_dm_rsllite" ;
535 $sw_dmparallel = "RSL_LITE" ;
536 $sw_dmparallelflag = "-DDM_PARALLEL" ;
537 $sw_fc = "\$(DM_FC)" ;
538 $sw_cc = "\$(DM_CC)" ;
539 } # only one option in v3.0
541 $sw_ifort_r8 = 0 ;
542 if ( index ( $x, "ifort" ) > -1 || index ( $x, "intel compiler" ) > -1 ) {
543 if ( $sw_rwordsize == 8 ) {
544 $sw_ifort_r8 = 1 ;
551 close CONFIGURE_DEFAULTS ;
552 close POSTAMBLE ;
553 close ARCH_NOOPT_EXCEPTIONS ;
555 open CONFIGURE_WRF, "> configure.wrf" or die "cannot append configure.wrf" ;
556 open ARCH_PREAMBLE, "< arch/preamble_new" or die "cannot open arch/preamble_new" ;
557 my @preamble;
558 # apply substitutions to the preamble...
559 while ( <ARCH_PREAMBLE> )
561 # ESMF substitutions in preamble
562 if ( $sw_esmflib_path && $sw_esmfinc_path )
564 $_ =~ s/ESMFCOUPLING/1/g ;
565 $_ =~ s:ESMFMODDEPENDENCE:\$\(WRF_SRC_ROOT_DIR\)/external/io_esmf/module_utility.o:g ;
566 $_ =~ s:ESMFMODINC:-I$sw_esmfinc_path -I\$\(WRF_SRC_ROOT_DIR\)/main:g ;
567 $_ =~ s:ESMFIOINC:-I\$\(WRF_SRC_ROOT_DIR\)/external/io_esmf:g ;
568 $_ =~ s:ESMFIODEFS:-DESMFIO:g ;
569 $_ =~ s:ESMFTARGET:wrfio_esmf:g ;
570 $_ =~ s:\# ESMFINCLUDEGOESHERE:include \$\(ESMFLIB\)/esmf.mk: ;
573 else
575 $_ =~ s/ESMFCOUPLING/0/g ;
576 $_ =~ s:ESMFMODDEPENDENCE:\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90/module_utility.o:g ;
577 $_ =~ s:ESMFMODINC::g ;
578 $_ =~ s:ESMFIOINC:-I\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90:g ;
579 $_ =~ s:ESMFIODEFS::g ;
580 $_ =~ s:ESMFTARGET:esmf_time:g ;
582 if ( $ENV{HWRF} )
584 $_ =~ s:CONFIGURE_ATMOCN_LIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/atm_ocn -latm_ocn:g ;
585 $_ =~ s/CONFIGURE_ATMOCN/atm_ocn/g ;
587 else
589 $_ =~ s:CONFIGURE_ATMOCN_LIB::g ;
590 $_ =~ s/CONFIGURE_ATMOCN//g ;
592 $_ =~ s:CONFIGURE_EM_CORE:$sw_em_core:g ;
593 $_ =~ s:CONFIGURE_DA_CORE:$sw_da_core:g ;
594 $_ =~ s:CONFIGURE_NMM_CORE:$sw_nmm_core:g ;
595 $_ =~ s:CONFIGURE_COAMPS_CORE:$sw_coamps_core:g ;
596 $_ =~ s:CONFIGURE_EXP_CORE:$sw_exp_core:g ;
598 @preamble = ( @preamble, $_ ) ;
600 close ARCH_PREAMBLE ;
601 print CONFIGURE_WRF @preamble ;
602 close ARCH_PREAMBLE ;
603 printf CONFIGURE_WRF "# Settings for %s\n", $optstr[$optchoice] ;
604 print CONFIGURE_WRF @machopts ;
605 print "$ENV{WRF_MARS}" ;
606 if ( $ENV{WRF_MARS} || $ENV{WRF_TITAN} || $ENV{WRF_VENUS} )
608 open ARCH_PLANETAMBLE, "< arch/planetamble" or die "cannot open arch/planetamble" ;
609 while ( <ARCH_PLANETAMBLE> ) { print CONFIGURE_WRF } ;
610 close ARCH_PLANETAMBLE ;
613 close CONFIGURE_WRF ;
615 printf "Configuration successful. To build the model type compile . \n" ;
616 printf "------------------------------------------------------------------------\n" ;