1 | #!/usr/bin/perl |
---|
2 | # |
---|
3 | # Configuration script for WRF prototype code |
---|
4 | # |
---|
5 | # Be sure to run as ./configure (to avoid getting a system configure command by mistake) |
---|
6 | # |
---|
7 | |
---|
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 ; |
---|
40 | |
---|
41 | while ( substr( $ARGV[0], 0, 1 ) eq "-" ) |
---|
42 | { |
---|
43 | if ( substr( $ARGV[0], 1, 5 ) eq "perl=" ) |
---|
44 | { |
---|
45 | $sw_perl_path = substr( $ARGV[0], 6 ) ; |
---|
46 | } |
---|
47 | if ( substr( $ARGV[0], 1, 7 ) eq "netcdf=" ) |
---|
48 | { |
---|
49 | $sw_netcdf_path = substr( $ARGV[0], 8 ) ; |
---|
50 | } |
---|
51 | if ( substr( $ARGV[0], 1, 8 ) eq "pnetcdf=" ) |
---|
52 | { |
---|
53 | $sw_pnetcdf_path = substr( $ARGV[0], 9 ) ; |
---|
54 | } |
---|
55 | if ( substr( $ARGV[0], 1, 6 ) eq "phdf5=" ) |
---|
56 | { |
---|
57 | $sw_phdf5_path = substr( $ARGV[0], 7 ) ; |
---|
58 | } |
---|
59 | if ( substr( $ARGV[0], 1, 3 ) eq "os=" ) |
---|
60 | { |
---|
61 | $sw_os = substr( $ARGV[0], 4 ) ; |
---|
62 | } |
---|
63 | if ( substr( $ARGV[0], 1, 5 ) eq "mach=" ) |
---|
64 | { |
---|
65 | $sw_mach = substr( $ARGV[0], 6 ) ; |
---|
66 | } |
---|
67 | if ( substr( $ARGV[0], 1, 10 ) eq "opt_level=" ) |
---|
68 | { |
---|
69 | $sw_opt_level = substr( $ARGV[0], 11 ) ; |
---|
70 | } |
---|
71 | if ( substr( $ARGV[0], 1, 11 ) eq "USENETCDFF=" ) |
---|
72 | { |
---|
73 | $sw_usenetcdff = substr( $ARGV[0], 12 ) ; |
---|
74 | } |
---|
75 | if ( substr( $ARGV[0], 1, 5 ) eq "time=" ) |
---|
76 | { |
---|
77 | $sw_time = substr( $ARGV[0], 6 ) ; |
---|
78 | } |
---|
79 | if ( substr( $ARGV[0], 1, 8 ) eq "ldflags=" ) |
---|
80 | { |
---|
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 ; |
---|
85 | } |
---|
86 | if ( substr( $ARGV[0], 1, 9 ) eq "wrf_core=" ) |
---|
87 | { |
---|
88 | $sw_wrf_core = substr( $ARGV[0], 10 ) ; |
---|
89 | if ( index ( $sw_wrf_core , "EM_CORE" ) > -1 ) |
---|
90 | { |
---|
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" ; |
---|
96 | } |
---|
97 | if ( index ( $sw_wrf_core , "DA_CORE" ) > -1 ) |
---|
98 | { |
---|
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" ; |
---|
104 | } |
---|
105 | if ( index ( $sw_wrf_core , "4D_DA_CORE" ) > -1 ) |
---|
106 | { |
---|
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" ; |
---|
112 | } |
---|
113 | if ( index ( $sw_wrf_core , "NMM_CORE" ) > -1 ) |
---|
114 | { |
---|
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" ; |
---|
120 | } |
---|
121 | if ( index ( $sw_wrf_core , "EXP_CORE" ) > -1 ) |
---|
122 | { |
---|
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" ; |
---|
128 | } |
---|
129 | if ( index ( $sw_wrf_core , "COAMPS_CORE" ) > -1 ) |
---|
130 | { |
---|
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" ; |
---|
136 | } |
---|
137 | } |
---|
138 | if ( substr( $ARGV[0], 1, 13 ) eq "compileflags=" ) |
---|
139 | { |
---|
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 ) |
---|
145 | { |
---|
146 | $WRFCHEM = 0 ; |
---|
147 | } |
---|
148 | else |
---|
149 | { |
---|
150 | $WRFCHEM = 1 ; |
---|
151 | } |
---|
152 | } |
---|
153 | if ( substr( $ARGV[0], 1, 11 ) eq "dmparallel=" ) |
---|
154 | { |
---|
155 | $sw_dmparallel=substr( $ARGV[0], 12 ) ; |
---|
156 | } |
---|
157 | if ( substr( $ARGV[0], 1, 12 ) eq "ompparallel=" ) |
---|
158 | { |
---|
159 | $sw_ompparallel=substr( $ARGV[0], 13 ) ; |
---|
160 | } |
---|
161 | shift @ARGV ; |
---|
162 | } |
---|
163 | |
---|
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" ; |
---|
171 | |
---|
172 | |
---|
173 | if ( $sw_dmparallel eq "RSL_LITE" ) |
---|
174 | { |
---|
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" ; |
---|
181 | } |
---|
182 | |
---|
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} ) |
---|
187 | { |
---|
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}; |
---|
193 | } |
---|
194 | else |
---|
195 | { |
---|
196 | printf "\$JASPERLIB or \$JASPERINC not found in environment, configuring to build without grib2 I/O...\n" ; |
---|
197 | } |
---|
198 | |
---|
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" ) |
---|
201 | { |
---|
202 | $sw_rwordsize = "8"; |
---|
203 | if ( $ENV{CRTM} ) |
---|
204 | { |
---|
205 | $sw_crtm_flag = "-DCRTM"; |
---|
206 | } |
---|
207 | if ( $ENV{RTTOV} ) |
---|
208 | { |
---|
209 | $sw_rttov_flag = "-DRTTOV"; |
---|
210 | $sw_rttov_inc = "-I$ENV{RTTOV}/include -I$ENV{RTTOV}/mod"; |
---|
211 | } |
---|
212 | if ( $sw_wrf_core eq "4D_DA_CORE" ) |
---|
213 | { |
---|
214 | $sw_4dvar_flag = "-DVAR4D"; |
---|
215 | } |
---|
216 | if ( $ENV{WAVELET} ) |
---|
217 | { |
---|
218 | $sw_wavelet_flag = "-DWAVELET"; |
---|
219 | } |
---|
220 | } |
---|
221 | |
---|
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} ) |
---|
228 | { |
---|
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" ; |
---|
239 | } |
---|
240 | |
---|
241 | # parse the configure.wrf file |
---|
242 | |
---|
243 | $validresponse = 0 ; |
---|
244 | |
---|
245 | @platforms = qw ( serial smpar dmpar dm+sm ) ; |
---|
246 | |
---|
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" ; |
---|
251 | |
---|
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> ) |
---|
256 | { |
---|
257 | for $paropt ( @platforms ) |
---|
258 | { |
---|
259 | if ( substr( $_, 0, 5 ) eq "#ARCH" |
---|
260 | && ( index( $_, $sw_os ) >= 0 ) && ( index( $_, $sw_mach ) >= 0 ) |
---|
261 | && ( index($_, $paropt) >= 0 ) ) |
---|
262 | { |
---|
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" ) |
---|
269 | { |
---|
270 | printf " %2d. %s\n",$opt,$optstr[$opt] ; |
---|
271 | $opt++ ; |
---|
272 | } |
---|
273 | } |
---|
274 | } |
---|
275 | } |
---|
276 | close CONFIGURE_DEFAULTS ; |
---|
277 | |
---|
278 | $opt -- ; |
---|
279 | |
---|
280 | printf "\nEnter selection [%d-%d] : ",1,$opt ; |
---|
281 | $response = <STDIN> ; |
---|
282 | |
---|
283 | if ( $response == -1 ) { exit ; } |
---|
284 | |
---|
285 | if ( $response >= 1 && $response <= $opt ) |
---|
286 | { $validresponse = 1 ; } |
---|
287 | else |
---|
288 | { printf("\nInvalid response (%d)\n",$response);} |
---|
289 | } |
---|
290 | printf "------------------------------------------------------------------------\n" ; |
---|
291 | |
---|
292 | $optchoice = $response ; |
---|
293 | |
---|
294 | open CONFIGURE_DEFAULTS, "cat ./arch/configure_new.defaults |" ; |
---|
295 | $latchon = 0 ; |
---|
296 | while ( <CONFIGURE_DEFAULTS> ) |
---|
297 | { |
---|
298 | if ( substr( $_, 0, 5 ) eq "#ARCH" && $latchon == 1 ) |
---|
299 | { |
---|
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" ; |
---|
305 | } |
---|
306 | } |
---|
307 | if ( $latchon == 1 ) |
---|
308 | { |
---|
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// ; |
---|
323 | } |
---|
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 ; |
---|
334 | } |
---|
335 | if ( $sw_dmparallel ne "" && ($_ =~ /^DMPARALLEL[=\t ]/) ) { |
---|
336 | $_ =~ s/#// ; |
---|
337 | } |
---|
338 | if ( $sw_ompparallel ne "" && ( $_ =~ /^OMPCPP[=\t ]/ || $_ =~ /^OMPCC[=\t ]/ || $_ =~ /^OMP[=\t ]/ ) ) { |
---|
339 | $_ =~ s/#// ; |
---|
340 | $_ =~ s/#// ; |
---|
341 | $_ =~ s/#// ; |
---|
342 | } |
---|
343 | if ( $sw_netcdf_path ) |
---|
344 | { $_ =~ s/CONFIGURE_WRFIO_NF/wrfio_nf/g ; |
---|
345 | $_ =~ s:CONFIGURE_NETCDF_FLAG:-DNETCDF: ; |
---|
346 | if ( $sw_os eq "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 : ; |
---|
350 | } |
---|
351 | } |
---|
352 | else |
---|
353 | { $_ =~ s/CONFIGURE_WRFIO_NF//g ; |
---|
354 | $_ =~ s:CONFIGURE_NETCDF_FLAG::g ; |
---|
355 | $_ =~ s:CONFIGURE_NETCDF_LIB_PATH::g ; |
---|
356 | } |
---|
357 | |
---|
358 | if ( $sw_pnetcdf_path ) |
---|
359 | { $_ =~ s/CONFIGURE_WRFIO_PNF/wrfio_pnf/g ; |
---|
360 | $_ =~ s:CONFIGURE_PNETCDF_FLAG:-DPNETCDF: ; |
---|
361 | if ( $sw_os eq "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: ; |
---|
365 | } |
---|
366 | } |
---|
367 | else |
---|
368 | { $_ =~ s/CONFIGURE_WRFIO_PNF//g ; |
---|
369 | $_ =~ s:CONFIGURE_PNETCDF_FLAG::g ; |
---|
370 | $_ =~ s:CONFIGURE_PNETCDF_LIB_PATH::g ; |
---|
371 | } |
---|
372 | |
---|
373 | if ( $sw_phdf5_path ) |
---|
374 | |
---|
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: ; |
---|
378 | } |
---|
379 | else |
---|
380 | { $_ =~ s/CONFIGURE_WRFIO_PHDF5//g ; |
---|
381 | $_ =~ s:CONFIGURE_PHDF5_FLAG::g ; |
---|
382 | $_ =~ s:CONFIGURE_PHDF5_LIB_PATH::g ; |
---|
383 | } |
---|
384 | |
---|
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 ; |
---|
390 | } |
---|
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 ; |
---|
396 | } |
---|
397 | |
---|
398 | |
---|
399 | # ESMF substitutions in configure.defaults |
---|
400 | if ( $sw_esmflib_path && $sw_esmfinc_path ) |
---|
401 | { |
---|
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 ; |
---|
406 | } |
---|
407 | else |
---|
408 | { |
---|
409 | $_ =~ s:CONFIGURE_ESMF_FLAG::g ; |
---|
410 | $_ =~ s:ESMFLIBFLAG::g ; |
---|
411 | if ( $sw_os eq "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 ; |
---|
417 | } |
---|
418 | } |
---|
419 | if ( $ENV{HWRF} ) |
---|
420 | { |
---|
421 | $_ =~ s:CONFIGURE_ATMOCN_LIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/atm_ocn -latm_ocn:g ; |
---|
422 | $_ =~ s:CONFIGURE_ATMOCN_INC:-I\$\(WRF_SRC_ROOT_DIR\)/external/atm_ocn:g; |
---|
423 | $_ =~ s/CONFIGURE_ATMOCN/atm_ocn/g ; |
---|
424 | } |
---|
425 | else |
---|
426 | { |
---|
427 | $_ =~ s:CONFIGURE_ATMOCN_LIB::g ; |
---|
428 | $_ =~ s/CONFIGURE_ATMOCN//g ; |
---|
429 | $_ =~ s:CONFIGURE_ATMOCN_INC::g; |
---|
430 | } |
---|
431 | |
---|
432 | if ( ! (substr( $_, 0, 5 ) eq "#ARCH") ) { @machopts = ( @machopts, $_ ) ; } |
---|
433 | if ( substr( $_, 0, 10 ) eq "ENVCOMPDEF" ) |
---|
434 | { |
---|
435 | @machopts = ( @machopts, "WRF_CHEM\t=\t$WRFCHEM \n" ) ; |
---|
436 | } |
---|
437 | } |
---|
438 | |
---|
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) |
---|
444 | |
---|
445 | for $paropt ( @platforms ) |
---|
446 | { |
---|
447 | if ( substr( $_, 0, 5 ) eq "#ARCH" && $latchon == 0 |
---|
448 | && ( index( $_, $sw_os ) >= 0 ) && ( index( $_, $sw_mach ) >= 0 ) |
---|
449 | && ( index($_, $paropt) >= 0 ) ) |
---|
450 | { |
---|
451 | $x=substr($_,6) ; |
---|
452 | $x=~s/^[ ]*// ; |
---|
453 | $x =~ s/#.*$//g ; |
---|
454 | chomp($x) ; |
---|
455 | $x = $x." (".$paropt.")" ; |
---|
456 | if ( $x eq $optstr[$optchoice] ) |
---|
457 | { |
---|
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 = "" ; } |
---|
464 | # |
---|
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]: " ; |
---|
470 | } |
---|
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> ; |
---|
478 | } |
---|
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);} |
---|
486 | } |
---|
487 | if ( $response == "" ) { |
---|
488 | if ( ( $paropt eq 'serial' || $paropt eq 'smpar' ) ) { $response = 0 ; } |
---|
489 | else { $response = 1 ; } |
---|
490 | } |
---|
491 | if ( $response == 0 ) { |
---|
492 | if ( ! ( $paropt eq 'serial' || $paropt eq 'smpar' ) ) { $response = 1 ; } |
---|
493 | } |
---|
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" ; |
---|
501 | } |
---|
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" ; |
---|
505 | } |
---|
506 | } |
---|
507 | if ( $response == 2 ) { |
---|
508 | $sw_nest_opt = "-DMOVE_NESTS" ; |
---|
509 | } elsif ( $response == 3 ) { |
---|
510 | $sw_nest_opt = "-DMOVE_NESTS -DVORTEX_CENTER" ; |
---|
511 | } |
---|
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" ; |
---|
518 | } |
---|
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 |
---|
525 | |
---|
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 ; |
---|
530 | } |
---|
531 | } |
---|
532 | } |
---|
533 | } |
---|
534 | } |
---|
535 | } |
---|
536 | close CONFIGURE_DEFAULTS ; |
---|
537 | close POSTAMBLE ; |
---|
538 | close ARCH_NOOPT_EXCEPTIONS ; |
---|
539 | |
---|
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> ) |
---|
545 | { |
---|
546 | # ESMF substitutions in preamble |
---|
547 | if ( $sw_esmflib_path && $sw_esmfinc_path ) |
---|
548 | { |
---|
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 ; |
---|
555 | } |
---|
556 | else |
---|
557 | { |
---|
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 ; |
---|
564 | } |
---|
565 | if ( $ENV{HWRF} ) |
---|
566 | { |
---|
567 | $_ =~ s:CONFIGURE_ATMOCN_LIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/atm_ocn -latm_ocn:g ; |
---|
568 | $_ =~ s/CONFIGURE_ATMOCN/atm_ocn/g ; |
---|
569 | } |
---|
570 | else |
---|
571 | { |
---|
572 | $_ =~ s:CONFIGURE_ATMOCN_LIB::g ; |
---|
573 | $_ =~ s/CONFIGURE_ATMOCN//g ; |
---|
574 | } |
---|
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 ; |
---|
580 | |
---|
581 | @preamble = ( @preamble, $_ ) ; |
---|
582 | } |
---|
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} ) |
---|
590 | { |
---|
591 | open ARCH_PLANETAMBLE, "< arch/planetamble" or die "cannot open arch/planetamble" ; |
---|
592 | while ( <ARCH_PLANETAMBLE> ) { print CONFIGURE_WRF } ; |
---|
593 | close ARCH_PLANETAMBLE ; |
---|
594 | } |
---|
595 | |
---|
596 | close CONFIGURE_WRF ; |
---|
597 | |
---|
598 | printf "Configuration successful. To build the model type compile . \n" ; |
---|
599 | printf "------------------------------------------------------------------------\n" ; |
---|
600 | |
---|
601 | |
---|