source: trunk/WRF.COMMON/WRFV3/arch/Config_new.pl @ 2762

Last change on this file since 2762 was 2759, checked in by aslmd, 3 years ago

adding unmodified code from WRFV3.0.1.1, expurged from useless data +1M size

File size: 18.6 KB
Line 
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_crtm_inc = "" ;
24$WRFCHEM = 0 ;
25$sw_os = "ARCH" ;           # ARCH will match any
26$sw_mach = "ARCH" ;         # ARCH will match any
27$sw_wrf_core = "" ;
28$sw_da_core = "-DDA_CORE=\$\(WRF_DA_CORE\)" ;
29$sw_nmm_core = "-DNMM_CORE=\$\(WRF_NMM_CORE\)" ;
30$sw_em_core = "-DEM_CORE=\$\(WRF_EM_CORE\)" ;
31$sw_exp_core = "-DEXP_CORE=\$\(WRF_EXP_CORE\)" ;
32$sw_coamps_core = "-DCOAMPS_CORE=\$\(WRF_COAMPS_CORE\)" ;
33$sw_dmparallel = "" ;
34$sw_ompparallel = "" ;
35$sw_stubmpi = "" ;
36$sw_usenetcdff = "" ;    # for 3.6.2 and greater, the fortran bindings might be in a separate lib file
37$sw_time = "" ;          # name of a timer to time fortran compiles, e.g. timex or time
38$sw_ifort_r8 = 0 ;
39
40while ( substr( $ARGV[0], 0, 1 ) eq "-" )
41 {
42  if ( substr( $ARGV[0], 1, 5 ) eq "perl=" )
43  {
44    $sw_perl_path = substr( $ARGV[0], 6 ) ;
45  }
46  if ( substr( $ARGV[0], 1, 7 ) eq "netcdf=" )
47  {
48    $sw_netcdf_path = substr( $ARGV[0], 8 ) ;
49  }
50  if ( substr( $ARGV[0], 1, 8 ) eq "pnetcdf=" )
51  {
52    $sw_pnetcdf_path = substr( $ARGV[0], 9 ) ;
53  }
54  if ( substr( $ARGV[0], 1, 6 ) eq "phdf5=" )
55  {
56    $sw_phdf5_path = substr( $ARGV[0], 7 ) ;
57  }
58  if ( substr( $ARGV[0], 1, 3 ) eq "os=" )
59  {
60    $sw_os = substr( $ARGV[0], 4 ) ;
61  }
62  if ( substr( $ARGV[0], 1, 5 ) eq "mach=" )
63  {
64    $sw_mach = substr( $ARGV[0], 6 ) ;
65  }
66  if ( substr( $ARGV[0], 1, 10 ) eq "opt_level=" )
67  {
68    $sw_opt_level = substr( $ARGV[0], 11 ) ;
69  }
70  if ( substr( $ARGV[0], 1, 11 ) eq "USENETCDFF=" )
71  {
72    $sw_usenetcdff = substr( $ARGV[0], 12 ) ;
73  }
74  if ( substr( $ARGV[0], 1, 5 ) eq "time=" )
75  {
76    $sw_time = substr( $ARGV[0], 6 ) ;
77  }
78  if ( substr( $ARGV[0], 1, 8 ) eq "ldflags=" )
79  {
80    $sw_ldflags = substr( $ARGV[0], 9 ) ;
81# multiple options separated by spaces are passed in from sh script
82# separated by ! instead. Replace with spaces here.
83    $sw_ldflags =~ s/!/ /g ;
84  }
85  if ( substr( $ARGV[0], 1, 9 ) eq "wrf_core=" )
86  {
87    $sw_wrf_core = substr( $ARGV[0], 10 ) ;
88    if ( index ( $sw_wrf_core , "EM_CORE" ) > -1 ) 
89    {
90      $sw_em_core = "-DEM_CORE=1" ;
91      $sw_da_core = "-DDA_CORE=0" ;
92      $sw_nmm_core = "-DNMM_CORE=0" ;
93      $sw_exp_core = "-DEXP_CORE=0" ;
94      $sw_coamps_core = "-DCOAMPS_CORE=0" ;
95    }
96    if ( index ( $sw_wrf_core , "DA_CORE" ) > -1 ) 
97    {
98      $sw_em_core = "-DEM_CORE=1" ;
99      $sw_da_core = "-DDA_CORE=1" ;
100      $sw_nmm_core = "-DNMM_CORE=0" ;
101      $sw_exp_core = "-DEXP_CORE=0" ;
102      $sw_coamps_core = "-DCOAMPS_CORE=0" ;
103    }
104    if ( index ( $sw_wrf_core , "NMM_CORE" ) > -1 ) 
105    {
106      $sw_em_core = "-DEM_CORE=0" ;
107      $sw_da_core = "-DDA_CORE=0" ;
108      $sw_nmm_core = "-DNMM_CORE=1" ;
109      $sw_exp_core = "-DEXP_CORE=0" ;
110      $sw_coamps_core = "-DCOAMPS_CORE=0" ;
111    }
112    if ( index ( $sw_wrf_core , "EXP_CORE" ) > -1 ) 
113    {
114      $sw_em_core = "-DEM_CORE=0" ;
115      $sw_da_core = "-DDA_CORE=0" ;
116      $sw_nmm_core = "-DNMM_CORE=0" ;
117      $sw_exp_core = "-DEXP_CORE=1" ;
118      $sw_coamps_core = "-DCOAMPS_CORE=0" ;
119    }
120    if ( index ( $sw_wrf_core , "COAMPS_CORE" ) > -1 ) 
121    {
122      $sw_em_core = "-DEM_CORE=0" ;
123      $sw_da_core = "-DDA_CORE=0" ;
124      $sw_nmm_core = "-DNMM_CORE=0" ;
125      $sw_exp_core = "-DEXP_CORE=0" ;
126      $sw_coamps_core = "-DCOAMPS_CORE=1" ;
127    }
128  }
129  if ( substr( $ARGV[0], 1, 13 ) eq "compileflags=" )
130  {
131    $sw_compileflags = substr( $ARGV[0], 14 ) ;
132    $sw_compileflags =~ s/!/ /g ;
133#   look for each known option
134    $where_index = index ( $sw_compileflags , "-DWRF_CHEM" ) ;
135    if ( $where_index eq -1 ) 
136    {
137      $WRFCHEM = 0 ;
138    }
139    else
140    {
141      $WRFCHEM = 1 ;
142    } 
143  }
144  if ( substr( $ARGV[0], 1, 11 ) eq "dmparallel=" )
145  {
146    $sw_dmparallel=substr( $ARGV[0], 12 ) ;
147  }
148  if ( substr( $ARGV[0], 1, 12 ) eq "ompparallel=" )
149  {
150    $sw_ompparallel=substr( $ARGV[0], 13 ) ;
151  }
152  shift @ARGV ;
153 }
154
155 $sw_fc = "\$(SFC)" ;
156 $sw_cc = "\$(SCC)" ;
157 $sw_comms_lib = "" ;
158 $sw_comms_include = "" ;
159 $sw_dmparallelflag = "" ;
160 $sw_nest_opt = "" ; 
161 $sw_comms_external = "gen_comms_serial module_dm_serial" ;
162
163 if ( $sw_dmparallel eq "RSL_LITE" ) 
164 {
165  $sw_fc = "\$(DM_FC)" ;
166  $sw_cc = "\$(DM_CC)" ;
167  $sw_dmparallelflag = "-DDM_PARALLEL" ;
168  $sw_comms_lib = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a" ;
169  $sw_comms_external = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a gen_comms_rsllite module_dm_rsllite" ;
170  $sw_comms_include = "-I\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE" ;
171 }
172
173# The jasper library is required to build Grib2 I/O.  User must set
174# environment variables JASPERLIB and JASPERINC to paths to library and
175# include files to enable this feature prior to running configure. 
176 if ( $ENV{JASPERLIB} && $ENV{JASPERINC} )
177   {
178   printf "Configuring to use jasper library to build Grib2 I/O...\n" ;
179   printf("  \$JASPERLIB = %s\n",$ENV{JASPERLIB});
180   printf("  \$JASPERINC = %s\n",$ENV{JASPERINC});
181   $sw_jasperlib_path = $ENV{JASPERLIB}; 
182   $sw_jasperinc_path = $ENV{JASPERINC}; 
183   }
184 else
185   {
186   printf "\$JASPERLIB or \$JASPERINC not found in environment, configuring to build without grib2 I/O...\n" ;
187   }
188
189# When compiling DA code, we need to always use 8-byte reals.
190 if ( $ENV{WRF_DA_CORE} eq "1" || $sw_da_core eq "-DDA_CORE=1" )
191   {
192     $sw_rwordsize = "8"; 
193     if ( $ENV{CRTM} )
194       {
195       $sw_crtm_flag = "-DCRTM";
196       $sw_crtm_inc = "-I$ENV{CRTM}/src";
197       }
198     if ( $ENV{RTTOV} )
199       {
200       $sw_rttov_flag = "-DRTTOV";
201       $sw_rttov_inc = "-I$ENV{RTTOV}/src";
202       }
203   }
204
205# A separately-installed ESMF library is required to build the ESMF
206# implementation of WRF IOAPI in external/io_esmf.  This is needed
207# to couple WRF with other ESMF components.  User must set environment
208# variables ESMFLIB and ESMFINC to paths ESMF to library and include
209# files to enable this feature prior to running configure.
210 if ( $ENV{ESMFLIB} && $ENV{ESMFINC} )
211   {
212   printf "Configuring to use ESMF library to build WRF...\n" ;
213   printf "WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING\n" ;
214   printf "WARNING:  THIS IS AN EXPERIMENTAL CONFIGURATION\n" ;
215   printf "WARNING:  IT DOES NOT WORK WITH NESTING\n" ;
216   printf "WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING\n" ;
217   printf("  \$ESMFLIB = %s\n",$ENV{ESMFLIB});
218   printf("  \$ESMFINC = %s\n",$ENV{ESMFINC});
219   $sw_esmflib_path = $ENV{ESMFLIB};
220   $sw_esmfinc_path = $ENV{ESMFINC};
221   $sw_esmf_ldflag = "yes" ;
222   }
223
224# parse the configure.wrf file
225
226$validresponse = 0 ;
227
228# Display the choices to the user and get selection
229until ( $validresponse ) {
230  printf "------------------------------------------------------------------------\n" ;
231  printf "Please select from among the following supported platforms.\n\n" ;
232
233  $opt = 1 ;
234  open CONFIGURE_DEFAULTS, "< ./arch/configure_new.defaults" 
235      or die "Cannot open ./arch/configure_new.defaults for reading" ;
236  while ( <CONFIGURE_DEFAULTS> )
237  {
238    for $paropt ( 'serial','smpar','dmpar','dm+sm' )
239    {
240      if ( substr( $_, 0, 5 ) eq "#ARCH"
241          && ( index( $_, $sw_os ) >= 0 ) && ( index( $_, $sw_mach ) >= 0 ) 
242          && ( index($_, $paropt) >= 0 ) )
243      {
244        $optstr[$opt] = substr($_,6) ;
245        $optstr[$opt] =~ s/^[   ]*// ;
246        $optstr[$opt] =~ s/#.*$//g ;
247        chomp($optstr[$opt]) ;
248        $optstr[$opt] = $optstr[$opt]." (".$paropt.")" ;
249        if ( substr( $optstr[$opt], 0,4 ) ne "NULL" )
250        {
251          printf "  %2d.  %s\n",$opt,$optstr[$opt] ;
252          $opt++ ;
253        }
254      }
255    }
256  }
257  close CONFIGURE_DEFAULTS ;
258
259  $opt -- ;
260
261  printf "\nEnter selection [%d-%d] : ",1,$opt ;
262  $response = <STDIN> ;
263
264  if ( $response == -1 ) { exit ; }
265
266  if ( $response >= 1 && $response <= $opt ) 
267  { $validresponse = 1 ; }
268  else
269  { printf("\nInvalid response (%d)\n",$response);}
270}
271printf "------------------------------------------------------------------------\n" ;
272
273$optchoice = $response ;
274
275open CONFIGURE_DEFAULTS, "cat ./arch/configure_new.defaults |"  ;
276$latchon = 0 ;
277while ( <CONFIGURE_DEFAULTS> )
278{
279  if ( substr( $_, 0, 5 ) eq "#ARCH" && $latchon == 1 )
280  {
281    close CONFIGURE_DEFAULTS ;
282    if ( $sw_opt_level eq "-f" ) {
283      open CONFIGURE_DEFAULTS, "cat ./arch/postamble_new ./arch/noopt_exceptions_f |"  or die "horribly" ;
284    } else {
285      open CONFIGURE_DEFAULTS, "cat ./arch/postamble_new ./arch/noopt_exceptions |"  or die "horribly" ;
286    }
287  }
288  if ( $latchon == 1 )
289  {
290    $_ =~ s/CONFIGURE_PERL_PATH/$sw_perl_path/g ;
291    $_ =~ s/CONFIGURE_NETCDF_PATH/$sw_netcdf_path/g ;
292    $_ =~ s/CONFIGURE_PNETCDF_PATH/$sw_pnetcdf_path/g ;
293    $_ =~ s/CONFIGURE_PHDF5_PATH/$sw_phdf5_path/g ;
294    $_ =~ s/CONFIGURE_LDFLAGS/$sw_ldflags/g ;
295    $_ =~ s/CONFIGURE_COMPILEFLAGS/$sw_compileflags/g ;
296    $_ =~ s/CONFIGURE_RWORDSIZE/$sw_rwordsize/g ;
297    $_ =~ s/CONFIGURE_FC/$sw_time $sw_fc/g ;
298    $_ =~ s/CONFIGURE_CC/$sw_cc/g ;
299    $_ =~ s/CONFIGURE_COMMS_LIB/$sw_comms_lib/g ;
300    $_ =~ s/CONFIGURE_COMMS_INCLUDE/$sw_comms_include/g ;
301    $_ =~ s/CONFIGURE_COMMS_EXTERNAL/$sw_comms_external/g ;
302    $_ =~ s/CONFIGURE_DMPARALLEL/$sw_dmparallelflag/g ;
303    $_ =~ s/CONFIGURE_STUBMPI/$sw_stubmpi/g ;
304    $_ =~ s/CONFIGURE_NESTOPT/$sw_nest_opt/g ;
305    $_ =~ s/CONFIGURE_CRTM_FLAG/$sw_crtm_flag/g ;
306    $_ =~ s/CONFIGURE_CRTM_INC/$sw_crtm_inc/g ;
307    $_ =~ s/CONFIGURE_RTTOV_FLAG/$sw_rttov_flag/g ;
308    $_ =~ s/CONFIGURE_RTTOV_INC/$sw_rttov_inc/g ;
309    if ( $sw_ifort_r8 ) {
310      $_ =~ s/^PROMOTION.*=/PROMOTION       =       -r8 /g ;
311    }
312    if ( $sw_dmparallel ne "" && ($_ =~ /^DMPARALLEL[=\t ]/) ) {
313       $_ =~ s/#// ;
314    }
315    if ( $sw_ompparallel ne "" && ( $_ =~ /^OMPCPP[=\t ]/ || $_ =~ /^OMP[=\t ]/ ) ) {
316       $_ =~ s/#// ;
317       $_ =~ s/#// ;
318    }
319    if ( $sw_netcdf_path ) 
320      { $_ =~ s/CONFIGURE_WRFIO_NF/wrfio_nf/g ;
321        $_ =~ s:CONFIGURE_NETCDF_FLAG:-DNETCDF: ;
322        if ( $sw_os == Interix ) {
323          $_ =~ s:CONFIGURE_NETCDF_LIB_PATH:\$\(WRF_SRC_ROOT_DIR\)/external/io_netcdf/libwrfio_nf.a -L$sw_netcdf_path/lib -lnetcdf $sw_usenetcdff : ;
324        } else {
325          $_ =~ s:CONFIGURE_NETCDF_LIB_PATH:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_netcdf -lwrfio_nf -L$sw_netcdf_path/lib -lnetcdf $sw_usenetcdff : ;
326        }
327         }
328    else                   
329      { $_ =~ s/CONFIGURE_WRFIO_NF//g ;
330        $_ =~ s:CONFIGURE_NETCDF_FLAG::g ;
331        $_ =~ s:CONFIGURE_NETCDF_LIB_PATH::g ;
332         }
333
334    if ( $sw_pnetcdf_path ) 
335      { $_ =~ s/CONFIGURE_WRFIO_PNF/wrfio_pnf/g ;
336        $_ =~ s:CONFIGURE_PNETCDF_FLAG:-DPNETCDF: ;
337        if ( $sw_os == Interix ) {
338          $_ =~ s:CONFIGURE_PNETCDF_LIB_PATH:\$\(WRF_SRC_ROOT_DIR\)/external/io_pnetcdf/libwrfio_pnf.a -L$sw_pnetcdf_path/lib -lpnetcdf: ;
339        } else {
340          $_ =~ s:CONFIGURE_PNETCDF_LIB_PATH:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_pnetcdf -lwrfio_pnf -L$sw_pnetcdf_path/lib -lpnetcdf: ;
341        }
342         }
343    else                   
344      { $_ =~ s/CONFIGURE_WRFIO_PNF//g ;
345        $_ =~ s:CONFIGURE_PNETCDF_FLAG::g ;
346        $_ =~ s:CONFIGURE_PNETCDF_LIB_PATH::g ;
347         }
348
349    if ( $sw_phdf5_path ) 
350
351      { $_ =~ s/CONFIGURE_WRFIO_PHDF5/wrfio_phdf5/g ;
352        $_ =~ s:CONFIGURE_PHDF5_FLAG:-DPHDF5: ;
353        $_ =~ 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: ;
354         }
355    else                   
356      { $_ =~ s/CONFIGURE_WRFIO_PHDF5//g ;
357        $_ =~ s:CONFIGURE_PHDF5_FLAG::g ;
358        $_ =~ s:CONFIGURE_PHDF5_LIB_PATH::g ;
359         }
360
361    if ( $sw_jasperlib_path && $sw_jasperinc_path ) 
362      { $_ =~ s/CONFIGURE_WRFIO_GRIB2/wrfio_grib2/g ;
363        $_ =~ s:CONFIGURE_GRIB2_FLAG:-DGRIB2:g ;
364        $_ =~ s:CONFIGURE_GRIB2_INC:-I$sw_jasperinc_path:g ;
365        $_ =~ s:CONFIGURE_GRIB2_LIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_grib2 -lio_grib2 -L$sw_jasperlib_path -ljasper:g ;
366      }
367    else                   
368      { $_ =~ s/CONFIGURE_WRFIO_GRIB2//g ;
369        $_ =~ s:CONFIGURE_GRIB2_FLAG::g ;
370        $_ =~ s:CONFIGURE_GRIB2_INC::g ;
371        $_ =~ s:CONFIGURE_GRIB2_LIB::g ;
372      }
373
374
375    # ESMF substitutions in configure.defaults
376    if ( $sw_esmflib_path && $sw_esmfinc_path )
377      {
378      $_ =~ s:CONFIGURE_ESMF_FLAG:-DESMFIO:g ;
379      $_ =~ s:ESMFIOLIB:-L$sw_esmflib_path -lesmf -L\$\(WRF_SRC_ROOT_DIR\)/external/io_esmf -lwrfio_esmf \$\(ESMF_LIB_FLAGS\):g ;
380      $_ =~ s:ESMFIOEXTLIB:-L$sw_esmflib_path -lesmf -L\$\(WRF_SRC_ROOT_DIR\)/external/io_esmf -lwrfio_esmf \$\(ESMF_LIB_FLAGS\):g ;
381      $_ =~ s:ESMFLIBFLAG:\$\(ESMF_LDFLAG\):g ;
382      }
383    else
384      {
385        $_ =~ s:CONFIGURE_ESMF_FLAG::g ;
386        $_ =~ s:ESMFLIBFLAG::g ;
387        if ( $sw_os == Interix ) {
388           $_ =~ s:ESMFIOLIB:\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90/libesmf_time.a:g ;
389           $_ =~ s:ESMFIOEXTLIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90/libesmf_time.a:g ;
390        } else {
391           $_ =~ s:ESMFIOLIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90 -lesmf_time:g ;
392           $_ =~ s:ESMFIOEXTLIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90 -lesmf_time:g ;
393        }
394      }
395
396    if ( ! (substr( $_, 0, 5 ) eq "#ARCH") ) { @machopts = ( @machopts, $_ ) ; }
397    if ( substr( $_, 0, 10 ) eq "ENVCOMPDEF" )
398    {
399      @machopts = ( @machopts, "WRF_CHEM\t=\t$WRFCHEM \n" ) ;
400    }
401  }
402
403# nesting support
404# 0 = no nesting (only selectable for serial and smpar)
405# 1 = basic nesting (serial and smpar compile with RSL_LITE and STUBMPI; dmpar and dm+sm use RSL_LITE and MPI)
406# 2 = nesting with prescribed moves  (add -DMOVE_NESTS to ARCHFLAGS)
407# 3 = nesting with prescribed moves  (add -DMOVE_NESTS and -DVORTEX_CENTER to ARCHFLAGS)
408
409  for $paropt ( 'serial','smpar','dmpar','dm+sm' )
410  {
411    if ( substr( $_, 0, 5 ) eq "#ARCH" && $latchon == 0 
412          && ( index( $_, $sw_os ) >= 0 ) && ( index( $_, $sw_mach ) >= 0 ) 
413          && ( index($_, $paropt) >= 0 ) )
414    {
415      $x=substr($_,6) ;
416      $x=~s/^[     ]*// ;
417      $x =~ s/#.*$//g ;
418      chomp($x) ;
419      $x = $x." (".$paropt.")" ;
420      if ( $x eq $optstr[$optchoice] )
421      {
422        $latchon = 1 ;
423        $sw_ompparallel = "" ;
424        $sw_dmparallel = "" ;
425        $validresponse = 0 ;
426        #only allow parallel netcdf if the user has chosen parallel option
427        if ( $paropt ne 'dmpar' && $paropt ne 'dm+sm' ) { $sw_pnetcdf_path = "" ; }
428        #
429        until ( $validresponse ) {
430          if ( $paropt eq 'serial' || $paropt eq 'smpar' ) {
431            printf "Compile for nesting? (0=no nesting, 1=basic, 2=preset moves, 3=vortex following) [default 0]: " ;
432          } else {
433            printf "Compile for nesting? (1=basic, 2=preset moves, 3=vortex following) [default 1]: " ;
434          }
435          $response = <STDIN> ;
436          printf "\n" ;
437          lc $response ;
438          chop $response ;
439          if ( $response == "" || ($response >= 0 && $response <= 3) )
440            { $validresponse = 1 ; }
441          else
442            { printf("\nInvalid response (%d)\n",$response);}
443        }
444        if ( $response == "" ) { 
445          if ( ( $paropt eq 'serial' || $paropt eq 'smpar' ) ) { $response = 0 ; }
446          else                                                 { $response = 1 ; }
447        }
448        if ( $response == 0 ) {
449          if ( ! ( $paropt eq 'serial' || $paropt eq 'smpar' ) ) { $response = 1 ; }
450        } 
451        if ( ( $response == 1 ) || ( $response == 2 ) || ( $response == 3 ) ) {
452          if ( ( $paropt eq 'serial' || $paropt eq 'smpar' ) ) {   # nesting without MPI
453            $sw_stubmpi = "-DSTUBMPI" ;
454            $sw_comms_lib = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a" ;
455            $sw_comms_external = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a gen_comms_rsllite module_dm_rsllite" ;
456            $sw_dmparallel = "RSL_LITE" ;
457            $sw_dmparallelflag = "-DDM_PARALLEL" ;
458          }
459        } 
460        if ( $response == 2 ) {
461          $sw_nest_opt = "-DMOVE_NESTS" ; 
462        } elsif ( $response == 3 ) {
463          $sw_nest_opt = "-DMOVE_NESTS -DVORTEX_CENTER" ; 
464        }
465        if ( $paropt eq 'smpar' || $paropt eq 'dm+sm' ) { $sw_ompparallel = "OMP" ; }
466        if ( $paropt eq 'dmpar' || $paropt eq 'dm+sm' ) { 
467          $sw_comms_lib = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a" ;
468          $sw_comms_external = "\$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a gen_comms_rsllite module_dm_rsllite" ;
469          $sw_dmparallel = "RSL_LITE" ;
470          $sw_dmparallelflag = "-DDM_PARALLEL" ;
471          $sw_fc = "\$(DM_FC)" ;
472          $sw_cc = "\$(DM_CC)" ;
473        }  # only one option in v3.0
474
475        $sw_ifort_r8 = 0 ;
476        if ( index ( $x, "ifort" ) > -1 || index ( $x, "intel compiler" ) > -1 ) {
477          if ( $sw_rwordsize == 8 ) {
478            $sw_ifort_r8 = 1 ;
479          }
480        }
481      }
482    }
483  }
484}
485close CONFIGURE_DEFAULTS ;
486close POSTAMBLE ;
487close ARCH_NOOPT_EXCEPTIONS ;
488
489open CONFIGURE_WRF, "> configure.wrf" or die "cannot append configure.wrf" ;
490open ARCH_PREAMBLE, "< arch/preamble_new" or die "cannot open arch/preamble_new" ;
491my @preamble;
492# apply substitutions to the preamble...
493while ( <ARCH_PREAMBLE> )
494  {
495  # ESMF substitutions in preamble
496  if ( $sw_esmflib_path && $sw_esmfinc_path )
497    {
498    $_ =~ s/ESMFCOUPLING/1/g ;
499    $_ =~ s:ESMFMODDEPENDENCE:\$\(WRF_SRC_ROOT_DIR\)/external/io_esmf/module_utility.o:g ;
500    $_ =~ s:ESMFMODINC:-I$sw_esmfinc_path -I\$\(WRF_SRC_ROOT_DIR\)/main:g ;
501    $_ =~ s:ESMFIOINC:-I\$\(WRF_SRC_ROOT_DIR\)/external/io_esmf:g ;
502    $_ =~ s:ESMFIODEFS:-DESMFIO:g ;
503    $_ =~ s:ESMFTARGET:wrfio_esmf:g ;
504    }
505  else
506    {
507    $_ =~ s/ESMFCOUPLING/0/g ;
508    $_ =~ s:ESMFMODDEPENDENCE:\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90/module_utility.o:g ;
509    $_ =~ s:ESMFMODINC::g ;
510    $_ =~ s:ESMFIOINC:-I\$\(WRF_SRC_ROOT_DIR\)/external/esmf_time_f90:g ;
511    $_ =~ s:ESMFIODEFS::g ;
512    $_ =~ s:ESMFTARGET:esmf_time:g ;
513    }
514  $_ =~ s:CONFIGURE_EM_CORE:$sw_em_core:g ;
515  $_ =~ s:CONFIGURE_DA_CORE:$sw_da_core:g ;
516  $_ =~ s:CONFIGURE_NMM_CORE:$sw_nmm_core:g ;
517  $_ =~ s:CONFIGURE_COAMPS_CORE:$sw_coamps_core:g ;
518  $_ =~ s:CONFIGURE_EXP_CORE:$sw_exp_core:g ;
519
520  @preamble = ( @preamble, $_ ) ;
521  }
522close ARCH_PREAMBLE ;
523print CONFIGURE_WRF @preamble  ;
524close ARCH_PREAMBLE ;
525printf CONFIGURE_WRF "# Settings for %s\n", $optstr[$optchoice] ;
526print CONFIGURE_WRF @machopts  ;
527print "$ENV{WRF_MARS}" ;
528if ( $ENV{WRF_MARS} || $ENV{WRF_TITAN} || $ENV{WRF_VENUS} )
529{
530    open ARCH_PLANETAMBLE, "< arch/planetamble" or die "cannot open arch/planetamble" ;
531    while ( <ARCH_PLANETAMBLE> ) { print CONFIGURE_WRF } ;
532    close ARCH_PLANETAMBLE ;
533}
534
535close CONFIGURE_WRF ;
536
537printf "Configuration successful. To build the model type compile . \n" ;
538printf "------------------------------------------------------------------------\n" ;
539
540
Note: See TracBrowser for help on using the repository browser.