3 # Configuration script for WRF prototype code
5 # Be sure to run as ./configure (to avoid getting a system configure command by mistake)
10 $sw_pnetcdf_path = "" ;
12 $sw_jasperlib_path="";
13 $sw_jasperinc_path="";
18 $sw_rwordsize="\$\(NATIVE_RWORDSIZE\)";
20 $sw_os = "ARCH" ; # ARCH will match any
21 $sw_mach = "ARCH" ; # ARCH will match any
23 while ( substr( $ARGV[0], 0, 1 ) eq "-" )
25 if ( substr( $ARGV[0], 1, 5 ) eq "perl=" )
27 $sw_perl_path = substr( $ARGV[0], 6 ) ;
29 if ( substr( $ARGV[0], 1, 7 ) eq "netcdf=" )
31 $sw_netcdf_path = substr( $ARGV[0], 8 ) ;
33 if ( substr( $ARGV[0], 1, 8 ) eq "pnetcdf=" )
35 $sw_pnetcdf_path = substr( $ARGV[0], 9 ) ;
37 if ( substr( $ARGV[0], 1, 6 ) eq "phdf5=" )
39 $sw_phdf5_path = substr( $ARGV[0], 7 ) ;
41 if ( substr( $ARGV[0], 1, 3 ) eq "os=" )
43 $sw_os = substr( $ARGV[0], 4 ) ;
45 if ( substr( $ARGV[0], 1, 5 ) eq "mach=" )
47 $sw_mach = substr( $ARGV[0], 6 ) ;
49 if ( substr( $ARGV[0], 1, 8 ) eq "ldflags=" )
51 $sw_ldflags = substr( $ARGV[0], 9 ) ;
52 # multiple options separated by spaces are passed in from sh script
53 # separated by ! instead. Replace with spaces here.
54 $sw_ldflags =~ s/!/ /g ;
56 if ( substr( $ARGV[0], 1, 13 ) eq "compileflags=" )
58 $sw_compileflags = substr( $ARGV[0], 14 ) ;
59 $sw_compileflags =~ s/!/ /g ;
60 # look for each known option
61 $where_index = index ( $sw_compileflags , "-DWRF_CHEM" ) ;
62 if ( $where_index eq -1 )
74 # The jasper library is required to build Grib2 I/O. User must set
75 # environment variables JASPERLIB and JASPERINC to paths to library and
76 # include files to enable this feature prior to running configure.
77 if ( $ENV{JASPERLIB
} && $ENV{JASPERINC
} )
79 printf "Configuring to use jasper library to build Grib2 I/O...\n" ;
80 printf(" \$JASPERLIB = %s\n",$ENV{JASPERLIB
});
81 printf(" \$JASPERINC = %s\n",$ENV{JASPERINC
});
82 $sw_jasperlib_path = $ENV{JASPERLIB
};
83 $sw_jasperinc_path = $ENV{JASPERINC
};
87 printf "\$JASPERLIB or \$JASPERINC not found in environment, configuring to build without grib2 I/O...\n" ;
90 # When compiling DA code, we need to always use 8-byte reals.
91 if ( $ENV{WRF_DA_CORE
} == "1" )
96 # A separately-installed ESMF library is required to build the ESMF
97 # implementation of WRF IOAPI in external/io_esmf. This is needed
98 # to couple WRF with other ESMF components. User must set environment
99 # variables ESMFLIB and ESMFINC to paths ESMF to library and include
100 # files to enable this feature prior to running configure.
101 if ( $ENV{ESMFLIB
} && $ENV{ESMFINC
} )
103 printf "Configuring to use ESMF library to build WRF...\n" ;
104 printf "WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING\n" ;
105 printf "WARNING: THIS IS AN EXPERIMENTAL CONFIGURATION\n" ;
106 printf "WARNING: IT DOES NOT WORK WITH NESTING\n" ;
107 printf "WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING\n" ;
108 printf(" \$ESMFLIB = %s\n",$ENV{ESMFLIB
});
109 printf(" \$ESMFINC = %s\n",$ENV{ESMFINC
});
110 $sw_esmflib_path = $ENV{ESMFLIB
};
111 $sw_esmfinc_path = $ENV{ESMFINC
};
114 # parse the configure.wrf file
118 # Display the choices to the user and get selection
119 until ( $validresponse ) {
120 printf "------------------------------------------------------------------------\n" ;
121 printf "Please select from among the following supported platforms.\n\n" ;
124 open CONFIGURE_DEFAULTS
, "< ./arch/configure_old.defaults"
125 or die "Cannot open ./arch/configure_old.defaults for reading" ;
126 while ( <CONFIGURE_DEFAULTS
> )
128 if ( substr( $_, 0, 5 ) eq "#ARCH" && ( index( $_, $sw_os ) >= 0 ) && ( index( $_, $sw_mach ) >= 0 ) )
130 $optstr[$opt] = substr($_,6) ;
131 $optstr[$opt] =~ s/^[ ]*// ;
132 if ( substr( $optstr[$opt], 0,4 ) ne "NULL" )
134 printf " %2d. %s",$opt,$optstr[$opt] ;
139 close CONFIGURE_DEFAULTS
;
143 printf "\nEnter selection [%d-%d] : ",1,$opt ;
144 $response = <STDIN
> ;
146 if ( $response == -1 ) { exit ; }
148 if ( $response >= 1 && $response <= $opt )
149 { $validresponse = 1 ; }
151 { printf("\nInvalid response (%d)\n",$response);}
153 printf "------------------------------------------------------------------------\n" ;
155 $optchoice = $response ;
157 open CONFIGURE_DEFAULTS
, "< ./arch/configure_old.defaults"
158 or die "Cannot open ./arch/configure_old.defaults for reading" ;
160 while ( <CONFIGURE_DEFAULTS
> )
162 if ( substr( $_, 0, 5 ) eq "#ARCH" && $latchon == 1 )
168 $_ =~ s/CONFIGURE_PERL_PATH/$sw_perl_path/g ;
169 $_ =~ s/CONFIGURE_NETCDF_PATH/$sw_netcdf_path/g ;
170 $_ =~ s/CONFIGURE_PNETCDF_PATH/$sw_pnetcdf_path/g ;
171 $_ =~ s/CONFIGURE_PHDF5_PATH/$sw_phdf5_path/g ;
172 $_ =~ s/CONFIGURE_LDFLAGS/$sw_ldflags/g ;
173 $_ =~ s/CONFIGURE_COMPILEFLAGS/$sw_compileflags/g ;
174 $_ =~ s/CONFIGURE_RWORDSIZE/$sw_rwordsize/g ;
175 if ( $sw_netcdf_path )
176 { $_ =~ s/CONFIGURE_WRFIO_NF/wrfio_nf/g ;
177 $_ =~ s
:CONFIGURE_NETCDF_FLAG
:-DNETCDF
: ;
178 if ( $sw_os == Interix
) {
179 $_ =~ s
:CONFIGURE_NETCDF_LIB_PATH
:\
$\
(WRF_SRC_ROOT_DIR\
)/external/io_netcdf
/libwrfio_nf.a -L$sw_netcdf_path/lib
-lnetcdf
: ;
181 $_ =~ s
:CONFIGURE_NETCDF_LIB_PATH
:-L\
$\
(WRF_SRC_ROOT_DIR\
)/external/io_netcdf
-lwrfio_nf
-L
$sw_netcdf_path/lib
-lnetcdf
: ;
185 { $_ =~ s/CONFIGURE_WRFIO_NF//g ;
186 $_ =~ s
:CONFIGURE_NETCDF_FLAG
::g
;
187 $_ =~ s
:CONFIGURE_NETCDF_LIB_PATH
::g
;
190 if ( $sw_pnetcdf_path )
191 { $_ =~ s/CONFIGURE_WRFIO_PNF/wrfio_pnf/g ;
192 $_ =~ s
:CONFIGURE_PNETCDF_FLAG
:-DPNETCDF
: ;
193 if ( $sw_os == Interix
) {
194 $_ =~ s
:CONFIGURE_PNETCDF_LIB_PATH
:\
$\
(WRF_SRC_ROOT_DIR\
)/external/io_pnetcdf
/libwrfio_pnf.a -L$sw_pnetcdf_path/lib
-lpnetcdf
: ;
196 $_ =~ s
:CONFIGURE_PNETCDF_LIB_PATH
:-L\
$\
(WRF_SRC_ROOT_DIR\
)/external/io_pnetcdf
-lwrfio_pnf
-L
$sw_pnetcdf_path/lib
-lpnetcdf
: ;
200 { $_ =~ s/CONFIGURE_WRFIO_PNF//g ;
201 $_ =~ s
:CONFIGURE_PNETCDF_FLAG
::g
;
202 $_ =~ s
:CONFIGURE_PNETCDF_LIB_PATH
::g
;
205 if ( $sw_phdf5_path )
207 { $_ =~ s/CONFIGURE_WRFIO_PHDF5/wrfio_phdf5/g ;
208 $_ =~ s
:CONFIGURE_PHDF5_FLAG
:-DPHDF5
: ;
209 $_ =~ s
:CONFIGURE_PHDF5_LIB_PATH
:-L\
$\
(WRF_SRC_ROOT_DIR\
)/external/io_phdf
5 -lwrfio_phdf5
-L
$sw_phdf5_path/lib -lhdf5_fortran -lhdf5 -lm -lz -L$sw_phdf5_path/lib
-lsz
: ;
212 { $_ =~ s/CONFIGURE_WRFIO_PHDF5//g ;
213 $_ =~ s
:CONFIGURE_PHDF5_FLAG
::g
;
214 $_ =~ s
:CONFIGURE_PHDF5_LIB_PATH
::g
;
217 if ( $sw_jasperlib_path && $sw_jasperinc_path )
218 { $_ =~ s/CONFIGURE_WRFIO_GRIB2/wrfio_grib2/g ;
219 $_ =~ s
:CONFIGURE_GRIB2_FLAG
:-DGRIB2
:g
;
220 $_ =~ s
:CONFIGURE_GRIB2_INC
:-I
$sw_jasperinc_path:g
;
221 $_ =~ s
:CONFIGURE_GRIB2_LIB
:-L\
$\
(WRF_SRC_ROOT_DIR\
)/external/io_grib
2 -lio_grib2
-L
$sw_jasperlib_path -ljasper
:g
;
224 { $_ =~ s/CONFIGURE_WRFIO_GRIB2//g ;
225 $_ =~ s
:CONFIGURE_GRIB2_FLAG
::g
;
226 $_ =~ s
:CONFIGURE_GRIB2_INC
::g
;
227 $_ =~ s
:CONFIGURE_GRIB2_LIB
::g
;
231 # ESMF substitutions in configure_old.defaults
232 if ( $sw_esmflib_path && $sw_esmfinc_path )
234 $_ =~ s
:ESMFIOLIB
:-L
$sw_esmflib_path -lesmf
-L\
$\
(WRF_SRC_ROOT_DIR\
)/external/io_esmf
-lwrfio_esmf \
$\
(ESMF_LIB_FLAGS\
):g
;
235 $_ =~ s
:ESMFIOEXTLIB
:-L
$sw_esmflib_path -lesmf
-L\
$\
(WRF_SRC_ROOT_DIR\
)/external/io_esmf
-lwrfio_esmf \
$\
(ESMF_LIB_FLAGS\
):g
;
239 if ( $sw_os == Interix
) {
240 $_ =~ s
:ESMFIOLIB
:\
$\
(WRF_SRC_ROOT_DIR\
)/external/esmf_time_f90
/libesmf_time
.a
:g
;
241 $_ =~ s
:ESMFIOEXTLIB
:-L\
$\
(WRF_SRC_ROOT_DIR\
)/external/esmf_time_f90
/libesmf_time
.a
:g
;
243 $_ =~ s
:ESMFIOLIB
:-L\
$\
(WRF_SRC_ROOT_DIR\
)/external/esmf_time_f90
-lesmf_time
:g
;
244 $_ =~ s
:ESMFIOEXTLIB
:-L\
$\
(WRF_SRC_ROOT_DIR\
)/external/esmf_time_f90
-lesmf_time
:g
;
248 @machopts = ( @machopts, $_ ) ;
249 if ( substr( $_, 0, 10 ) eq "ENVCOMPDEF" )
251 @machopts = ( @machopts, "WRF_CHEM\t=\t$WRFCHEM \n" ) ;
254 if ( substr( $_, 0, 5 ) eq "#ARCH" && $latchon == 0 )
258 if ( $x eq $optstr[$optchoice] )
264 close CONFIGURE_DEFAULTS
;
266 #printf "------------------------------------------------------------------------\n" ;
267 #foreach $f ( @machopts )
269 # if ( substr( $f , 0 , 8 ) eq "external" ) { last ; }
272 #printf "------------------------------------------------------------------------\n" ;
273 #printf "\nYou have chosen: %s",$optstr[$optchoice] ;
274 #printf "Listed above are the default options for this platform.\n" ;
275 #printf "Settings are written to the file configure.wrf here in the top-level\n" ;
276 #printf "directory. If you wish to change settings, please edit that file.\n" ;
277 #printf "If you wish to change the default options, edit the file:\n\n" ;
278 #printf " arch/configure_old.defaults\n" ;
281 open CONFIGURE_WRF
, "> configure.wrf" or die "cannot append configure.wrf" ;
282 open ARCH_PREAMBLE
, "< arch/preamble_old" or die "cannot open arch/preamble_old" ;
284 # apply substitutions to the preamble...
285 while ( <ARCH_PREAMBLE
> )
287 # ESMF substitutions in preamble
288 if ( $sw_esmflib_path && $sw_esmfinc_path )
290 $_ =~ s/ESMFCOUPLING/1/g ;
291 $_ =~ s
:ESMFMODDEPENDENCE
:\
$\
(WRF_SRC_ROOT_DIR\
)/external/io_esmf
/module_utility
.o
:g
;
292 $_ =~ s
:ESMFMODINC
:-I
$sw_esmfinc_path -I\
$\
(WRF_SRC_ROOT_DIR\
)/main
:g
;
293 $_ =~ s
:ESMFIOINC
:-I\
$\
(WRF_SRC_ROOT_DIR\
)/external/io_esmf
:g
;
294 $_ =~ s
:ESMFIODEFS
:-DESMFIO
:g
;
295 $_ =~ s
:ESMFTARGET
:wrfio_esmf
:g
;
299 $_ =~ s/ESMFCOUPLING/0/g ;
300 $_ =~ s
:ESMFMODDEPENDENCE
:\
$\
(WRF_SRC_ROOT_DIR\
)/external/esmf_time_f90
/module_utility
.o
:g
;
301 $_ =~ s
:ESMFMODINC
::g
;
302 $_ =~ s
:ESMFIOINC
:-I\
$\
(WRF_SRC_ROOT_DIR\
)/external/esmf_time_f90
:g
;
303 $_ =~ s
:ESMFIODEFS
::g
;
304 $_ =~ s
:ESMFTARGET
:esmf_time
:g
;
306 @preamble = ( @preamble, $_ ) ;
308 close ARCH_PREAMBLE
;
309 print CONFIGURE_WRF
@preamble ;
310 close ARCH_PREAMBLE
;
311 printf CONFIGURE_WRF
"# Settings for %s", $optstr[$optchoice] ;
312 print CONFIGURE_WRF
@machopts ;
313 print "$ENV{WRF_MARS}" ;
314 if ( $ENV{WRF_MARS
} || $ENV{WRF_TITAN
} || $ENV{WRF_VENUS
} )
316 open ARCH_PLANETAMBLE
, "< arch/planetamble" or die "cannot open arch/planetamble" ;
317 while ( <ARCH_PLANETAMBLE
> ) { print CONFIGURE_WRF
} ;
318 close ARCH_PLANETAMBLE
;
321 open ARCH_POSTAMBLE
, "< arch/postamble_old" or die "cannot open arch/postamble_old" ;
322 while ( <ARCH_POSTAMBLE
> ) { print CONFIGURE_WRF
} ;
323 close ARCH_POSTAMBLE
;
324 close CONFIGURE_WRF
;
326 printf "Configuration successful. To build the model type compile . \n" ;
327 printf "------------------------------------------------------------------------\n" ;