3 # Configuration script for WPS code
5 # Be sure to run as ./configure (to avoid getting a system configure command by mistake)
6 # There are two (2) reads of the configure_new.defaults one to present the user with
7 # the appropriate options for the type of machine, and the OS, and the compiler!
13 $sw_jasperlib_path = "";
14 $sw_jasperinc_path = "";
16 $sw_compileflags = "";
17 $sw_os = "ARCH" ; # ARCH will match any
18 $sw_mach = "ARCH" ; # ARCH will match any
26 while(substr( $ARGV[0], 0, 1 ) eq "-")
28 if(substr( $ARGV[0], 1, 5 ) eq "perl=")
30 $sw_perl_path = substr( $ARGV[0], 6);
32 if(substr( $ARGV[0], 1, 7 ) eq "netcdf=")
34 $sw_netcdf_path = substr( $ARGV[0], 8);
36 if(substr( $ARGV[0], 1, 8 ) eq "netcdff=")
38 $sw_netcdff_lib = substr( $ARGV[0], 9);
40 if(substr( $ARGV[0], 1, 6 ) eq "phdf5=")
42 $sw_phdf5_path = substr( $ARGV[0], 7);
44 if(substr( $ARGV[0], 1, 3 ) eq "os=")
46 $sw_os = substr( $ARGV[0], 4 );
48 if(substr( $ARGV[0], 1, 5 ) eq "mach=")
50 $sw_mach = substr( $ARGV[0], 6 );
52 if(substr( $ARGV[0], 1, 8 ) eq "ldflags=")
54 $sw_ldflags = substr( $ARGV[0], 9 );
55 # multiple options separated by spaces are passed in from sh script
56 # separated by ! instead. Replace with spaces here.
57 $sw_ldflags =~ s/!/ /g ;
62 # The jasper library is required to build Grib2 I/O. User must set
63 # environment variables JASPERLIB and JASPERINC to paths to library and
64 # include files to enable this feature prior to running configure.
65 if($ENV{JASPERLIB
} && $ENV{JASPERINC
})
67 printf "Found Jasper environment variables for GRIB2 support...\n";
68 printf(" \$JASPERLIB = %s\n",$ENV{JASPERLIB
});
69 printf(" \$JASPERINC = %s\n",$ENV{JASPERINC
});
70 $sw_jasperlib_path = $ENV{JASPERLIB
};
71 $sw_jasperinc_path = $ENV{JASPERINC
};
75 printf "\$JASPERLIB or \$JASPERINC not found in environment. Using default values for library paths...\n";
79 # added this from the WRF Config.pl by John M.
80 @platforms = ('serial', 'serial_NO_GRIB2', 'dmpar', 'dmpar_NO_GRIB2');
81 # Display the choices to the user and get selection
82 until ($validresponse)
84 printf "------------------------------------------------------------------------\n";
85 printf "Please select from among the following supported platforms.\n\n";
88 # Read configure_new.defaults
89 open CONFIGURE_DEFAULTS
, "< ./arch/configure_new.defaults"
90 || die "Cannot open ./arch/configure_new.defaults for reading";
91 # first read through the .defaults, user select and a read of all appropriate parms is not done here
92 while(<CONFIGURE_DEFAULTS
>)
94 for $paropt (@platforms)
96 # read all the System/OS/Compiler appropriate selections and present same to user
97 if(substr($_, 0, 5) eq "#ARCH" && (index($_, $sw_os) >= 0) && (index($_, $sw_mach) >= 0) && (index($_, $paropt) >= 0))
99 $optstr[$opt] = substr($_,6);
100 $optstr[$opt] =~ s/^[ ]*//;
101 $optstr[$opt] =~ s/#.*$//g;
102 chomp($optstr[$opt]);
103 $optstr[$opt] = $optstr[$opt]." (".$paropt.")";
104 if(substr($optstr[$opt], 0, 4) ne "NULL")
106 printf " %2d. %s\n", $opt, $optstr[$opt];
112 close CONFIGURE_DEFAULTS
;
116 printf "\nEnter selection [%d-%d] : ", 1, $opt;
118 if($response == -1) {exit;}
119 if($response >= 1 && $response <= $opt)
125 printf("\nInvalid response (%d)\n",$response);
129 printf "------------------------------------------------------------------------\n";
131 $optchoice = $response;
133 # this HAS to be opened in 'cat' mode... why?
134 open CONFIGURE_DEFAULTS
, "< ./arch/configure_new.defaults" || die "cannot Open for writing... configure_new.defaults: \n";
136 while(<CONFIGURE_DEFAULTS
>)
138 if(substr($_, 0, 5) eq "#ARCH" && $latchon == 1)
144 $_ =~ s/CONFIGURE_PERL_PATH/$sw_perl_path/g;
145 $_ =~ s/CONFIGURE_NETCDF_PATH/$sw_netcdf_path/g;
146 $_ =~ s/CONFIGURE_LDFLAGS/$sw_ldflags/g;
147 $_ =~ s/CONFIGURE_COMPILEFLAGS/$sw_compileflags/g;
148 $_ =~ s/CONFIGURE_COMP_L/$sw_compL/g;
149 $_ =~ s/CONFIGURE_COMP_I/$sw_compI/g;
150 $_ =~ s/CONFIGURE_FDEFS/$sw_fdefs/g;
151 $_ =~ s/CONFIGURE_FC/$sw_fc/g;
152 $_ =~ s/CONFIGURE_CC/$sw_cc/g;
153 $_ =~ s/CONFIGURE_MPI/$sw_mpi/g;
155 # Load the read in parameters from the configure_new.defaults file
156 if(!(substr($_, 0, 5) eq "#ARCH"))
158 @machopts = (@machopts, $_);
160 } # end if latchon == 1
162 #-----------------------------------------------------------------------------------------------
163 # added for the unified WPS build
164 # init the following for the configure.wps write
167 # now loop through the .defaults again and read the parameters to be written into the configure.wps
168 for $paropt (@platforms)
170 if(substr($_, 0, 5) eq "#ARCH" && $latchon == 0 && (index( $_, $sw_os) >= 0) && (index( $_, $sw_mach) >= 0) && (index($_, $paropt) >= 0))
172 # after #ARCH the following reads the rest of the line in the configure_new.defaults
177 $x = $x." (".$paropt.")" ;
179 if($x eq $optstr[$optchoice])
185 if($paropt eq 'serial')
187 if($ENV{JASPERLIB
} && $ENV{JASPERINC
})
189 $sw_compL = $sw_jasperlib_path;
190 $sw_compI = $sw_jasperinc_path;
194 $sw_compL = "-L/contrib/jasper/lib -L/opt/freeware/lib -ljasper -lpng -lz";
195 $sw_compI = "-I/contrib/libpng/include -I/contrib/zlib/include -I/contrib/jasper/include";
197 $sw_fdefs = "-DUSE_JPEG2000 -DUSE_PNG";
202 if($paropt eq 'serial_NO_GRIB2')
211 if($paropt eq 'dmpar')
213 if($ENV{JASPERLIB
} && $ENV{JASPERINC
})
215 $sw_compL = $sw_jasperlib_path;
216 $sw_compI = $sw_jasperinc_path;
220 $sw_compL = "-L/contrib/jasper/lib -L/opt/freeware/lib -ljasper -lpng -lz";
221 $sw_compI = "-I/contrib/libpng/include -I/contrib/zlib/include -I/contrib/jasper/include";
223 $sw_fdefs = "-DUSE_JPEG2000 -DUSE_PNG";
224 $sw_fc = "\$(DM_FC)";
225 $sw_cc = "\$(DM_CC)";
228 if($paropt eq 'dmpar_NO_GRIB2')
233 $sw_fc = "\$(DM_FC)";
234 $sw_cc = "\$(DM_CC)";
238 #####################################################################################
239 } # end if latchon == 1
243 close CONFIGURE_DEFAULTS
;
245 #printf "\n------------------------------------------------------------------------\n";
246 #foreach $f (@machopts)
248 # if(substr($f , 0 , 8) eq "external")
254 #printf "--------------------------------------------------------------------------\n";
255 #printf "\nYou have chosen: %s\n",$optstr[$optchoice];
256 #printf "Listed above are the default options for this platform.\n";
257 #printf "Settings are written to the file configure.wps here in the top-level\n";
258 #printf "directory. If you wish to change settings, please edit that file.\n";
259 #printf "If you wish to change the default options, edit the file:\n\n";
260 #printf " arch/configure.defaults\n";
262 #printf "------------------------------------------------------------------------\n";
264 open CONFIGURE_WRF
, "> configure.wps" || die "cannot Open for writing... configure.wps: \n";
265 open ARCH_PREAMBLE
, "< arch/preamble" || die "cannot Open for reading... arch/preamble: \n";
267 # apply substitutions to the preamble...
268 while (<ARCH_PREAMBLE
>)
270 if($sw_os eq "CYGWIN_NT")
272 $_ =~ s/^WRF_DIR.*$/COMPILING_ON_CYGWIN_NT = yes/; # will get from environment
275 $_ =~ s
:CONFIGURE_NETCDFF_LIB
:$sw_netcdff_lib:g
;
276 @preamble = ( @preamble, $_ ) ;
281 print CONFIGURE_WRF
@preamble;
283 printf CONFIGURE_WRF
"#\n";
284 printf CONFIGURE_WRF
"# Settings for %s \n", $optstr[$optchoice];
285 printf CONFIGURE_WRF
"#\n";
286 print CONFIGURE_WRF
@machopts;
288 open ARCH_POSTAMBLE
, "< arch/postamble" || die "cannot open arch/postamble: \n";
289 while(<ARCH_POSTAMBLE
>)
291 $_ =~ s
:CONFIGURE_NETCDFF_LIB
:$sw_netcdff_lib:g
;
295 close ARCH_POSTAMBLE
;
298 printf "Configuration successful. To build the WPS, type: compile\n";
299 printf "------------------------------------------------------------------------\n";