Update version info for release v4.6.1 (#2122)
[WRF.git] / configure
blob5e2bedb10fd709903c890f698f826819a7e12775
1 #!/bin/sh
3 # parse argument list
5 thiscmd=$0
7 FORTRAN_COMPILER_TIMER=""
8 opt_level="-f"
9 rword="-r4"
10 print_usage=""
11 chemistry=""
12 wrf_core=""
13 config_line="$0 "
14 while [ $# -ge 1 ]; do
15 config_line="$config_line $1"
16 case $1 in
17 -d) opt_level="-d" ;;
18 -D) opt_level="-D" ;;
19 -s) opt_level="-s" ;;
20 -f) opt_level="-f" ;;
21 -h) print_usage="yes" ;;
22 -help) print_usage="yes" ;;
23 -os) shift ; WRF_OS=$1 ;;
24 -mach) shift ; WRF_MACH=$1 ;;
25 -r8) rword="-r8" ;;
26 -time) shift ; FORTRAN_COMPILER_TIMER=$1 ;;
27 chem) WRF_CHEM=1 ;;
28 cmaq) WRF_CMAQ=1 ;;
29 kpp) WRF_KPP=1 ;;
30 radardfi) WRF_DFI_RADAR=1 ;;
31 wrfda) wrf_core=DA_CORE ;;
32 4dvar) wrf_core=4D_DA_CORE ;;
33 arw) wrf_core=EM_CORE ;;
34 coamps) wrf_core=COAMPS_CORE ;;
35 titan) WRF_TITAN=1 ; break ;;
36 mars) WRF_MARS=1 ; break ;;
37 venus) WRF_VENUS=1 ; break ;;
38 wrfplus) wrf_core=WRF_PLUS_CORE ; break ;;
39 *) echo "This option is not recognized: $1" ; exit 2 ;;
40 esac
41 shift
42 done
43 if [ -n "$print_usage" ] ; then
44 echo ' '
45 echo '*****************************************************************************'
46 echo usage: $thiscmd '[-d|-D|-s|-f|-os os|-mach mach|-time timecommand] [chem] [kpp]'
47 echo '-d build with debugging information and no optimization'
48 echo '-D build with -d AND floating traps, traceback, uninitialized variables'
49 echo '-r8 build with 8 byte reals'
50 echo '-help print this message'
51 echo '*****************************************************************************'
52 echo ' '
53 exit
56 if `pwd | grep ' ' > /dev/null ` ; then
57 echo '************************** W A R N I N G ************************************'
58 echo The current working directory has spaces in some components of its path name
59 echo and this may cause problems for your build. This can occur, for example, on
60 echo Windows systems. It is strongly recommended that you install WRF and other
61 echo related software such as NetCDF in directories whose path names contain no
62 echo white space. On Windows, for example, create and install in a directory under C:.
63 echo '*****************************************************************************'
67 # lifted from the configure file for mpich; 00/03/10 jm
69 # Check for perl and perl version
70 for p in perl5 perl
72 # Extract the first word of "$p", so it can be a program name with args.
73 set dummy $p; ac_word=$2
74 if test -z "$ac_echo_n" ; then
75 ac_echo_n=yes
76 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
77 # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
78 if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
79 ac_n= ac_c='
80 ' ac_t=' '
81 else
82 ac_n=-n ac_c= ac_t=
84 else
85 ac_n= ac_c='\c' ac_t=
87 ac_echo_test=`echo foo 1>&1`
88 if test -z "$ac_echo_test" ; then
89 print_error "Your sh shell does not handle the output redirection"
90 print_error "1>&1 correctly. Configure will work around this problem,"
91 print_error "but you should report the problem to your vendor."
94 if test -z "$ac_echo_test" -a 1 = 1 ; then
95 echo $ac_n "checking for $ac_word""... $ac_c"
96 else
97 echo $ac_n "checking for $ac_word""... $ac_c" 1>&1
99 ac_prog_where=""
100 if test -n "$PERL"; then
101 ac_pg_PERL="$PERL" # Let the user override the test.
102 else
103 ac_first_char=`expr "$p" : "\(.\)"`
104 if test "$ac_first_char" = "/" -a -x "$p" ; then
105 ac_pg_PERL="$p"
106 ac_prog_where=$p
107 else
108 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
109 for ac_dir in $PATH; do
110 test -z "$ac_dir" && ac_dir=.
111 if test -f $ac_dir/$ac_word; then
112 ac_pg_PERL="$p"
113 ac_prog_where=$ac_dir/$ac_word
114 break
116 done
117 IFS="$ac_save_ifs"
119 fi;PERL="$ac_pg_PERL"
120 if test -n "$ac_prog_where" ; then
121 if test -z "$ac_echo_test" -a 1 = 1 ; then
122 echo "$ac_t""found $ac_prog_where ($PERL)"
123 else
124 echo "$ac_t""found $ac_prog_where ($PERL)" 1>&1
126 PERLFULLPATH=$ac_prog_where
127 else
128 if test -z "$ac_echo_test" -a 1 = 1 ; then
129 echo "$ac_t""no"
130 else
131 echo "$ac_t""no" 1>&1
134 test -n "$PERL" && break
135 done
137 if test -z "$PERL" ; then
138 # We have to set this outside of the loop lest the first failure in
139 # PROGRAM_CHECK set the value (which then terminates the effect of the
140 # loop, since autoconf macros only set values that are null, they
141 # don't override them
142 PERL=""
145 if test -n "$PERL" ; then
146 PERL="$PERL"
148 perlversion=`$PERL -v | grep 'This is perl' | \
149 sed -e 's/^.*v[a-z ]*\([0-9]\).*$/\1/'`
151 # Should do a test first for ch_p4 etc.
152 if test "$perlversion" -lt 5 ; then
153 echo "WRF build requires perl version 5, which configure did not find."
154 echo "You can set the environment variable PERL to contain the "
155 echo "location of perl version 5."
156 echo "Configure believes that $PERL is version $perlversion ."
157 PERL=""
162 # We just need to find nc-config. First, check if NETCDF_C is set; if not, check
163 # $NETCDF/bin; otherwise, try `which nc-config`. If all that fails, warn user that WRF
164 # may fail to build beacuse of an incomplete NetCDF configuration. It could still be
165 # successfull if NetCDF was built statically because the results of `nf-config --flibs`
166 # should contain the necessary information for linking as long as NetCDF-Fortran is not
167 # version 4.5.3 (see https://github.com/Unidata/netcdf-fortran/issues/270)
169 if [ -n "$NETCDF_C" ] ; then
170 if [ -f "$NETCDF_C/bin/nc-config" ] ; then
171 export NETCDF_C=$NETCDF_C
173 elif [ -f "${NETCDF}/bin/nc-config" ] ; then
174 export NETCDF_C=$NETCDF
175 else
176 ans="`which nc-config`"
177 status="$?"
178 if [ "$ans" != "nc-config:" -a "$ans" != "" -a "$status" = "0" ] ; then
179 export NETCDF_C=`echo $ans | awk -F/ '{NF=NF-2;$NF=$NF}1' OFS=/`
180 else
181 export NETCDF_C="NOT_FOUND"
185 if [ -e $NETCDF_C/bin/nc-config ] ; then
186 ncversion=`$NETCDF_C/bin/nc-config --version | awk '{print $2}'`
187 else
188 ncversion=OLD
191 PROBS=FALSE
192 if [ -n "$NETCDFPAR" ] ; then
193 NETCDF="$NETCDFPAR"
194 if [ ! -e $NETCDF_C/bin/nc-config ] ; then
195 PROBS=TRUE
196 else
197 ncversion=`$NETCDF_C/bin/nc-config --version | awk '{print $2}'`
198 ncversiona=`echo $ncversion | cut -c 1`
199 ncversionb=`echo $ncversion | cut -c 3`
200 ncversionc=`echo $ncversion | cut -c 5`
201 ncversiona=`expr $ncversiona \* 100`
202 ncversionb=`expr $ncversionb \* 10`
203 ncversionabc=`expr $ncversiona + $ncversionb`
204 ncversionabc=`expr $ncversionabc + $ncversionc`
205 if [ $ncversionabc -lt 474 ] ; then
206 PROBS=TRUE
209 if [ "$PROBS" = "TRUE" ] ; then
210 echo
211 echo Cannot activate NETCDFPAR with this version of NetCDF: $ncversion
212 echo You need NetCDF version 4.7.4 or newer
213 echo Use a newer version of NetCDF, or unset the env variable NETCDFPAR
214 echo
215 exit
217 NETCDF4="1"
218 USENETCDFPAR="1"
219 export NETCDF
220 export NETCDF4
221 export USENETCDFPAR
222 else
223 export USENETCDFPAR=0
226 if test -z "$NETCDF" ; then
227 echo ' '
228 echo '*****************************************************************************'
229 echo 'No environment variable NETCDF set.'
230 echo 'Stopping'
231 echo '*****************************************************************************'
232 echo ' '
233 exit 5
236 if test -z "$NETCDF_classic" ; then
237 export NETCDF4=1
238 else
239 unset NETCDF4
242 USENETCDFF=""
243 USENETCDF=""
244 if [ -n "$NETCDF" ] ; then
245 echo "Will use NETCDF in dir: $NETCDF"
246 # Oh UNIDATA, why make it so hard ...
247 if [ -f "$NETCDF/lib/libnetcdff.a" -o -f "$NETCDF/lib/libnetcdff.so" -o -f "$NETCDF/lib/libnetcdff.dll.a" ] ; then
248 USENETCDFF="-lnetcdff"
249 else
250 USENETCDFF=" "
252 if [ -f "$NETCDF_C/lib/libnetcdf.a" -o -f "$NETCDF_C/lib/libnetcdf.so" -o -f "$NETCDF_C/lib/libnetcdf.dll.a" ] ; then
253 USENETCDF="-lnetcdf"
254 else
255 USENETCDF=" "
257 export USENETCDF=$USENETCDF
258 export USENETCDFF=$USENETCDFF
259 else
260 echo ' '
261 echo '*****************************************************************************'
262 echo 'No environment variable NETCDF set.'
263 echo 'Stopping'
264 echo '*****************************************************************************'
265 echo ' '
266 exit 6
269 # If the user asked for classic netcdf, acquiesce to the request.
271 if [ ! -f "$NETCDF/bin/nf-config" ] ; then
272 export NETCDF_classic=1
273 unset NETCDF4
274 else
275 if [ -n "$NETCDF_classic" ] ; then
276 if [ $NETCDF_classic -eq 1 ] ; then
277 unset NETCDF4
278 else
279 unset NETCDF_classic
280 export NETCDF4=1
282 else
283 if [ "`$NETCDF/bin/nf-config --has-nc4`" = "yes" ] ; then
284 unset NETCDF_classic
285 export NETCDF4=1
286 else
287 export NETCDF_classic=1
288 unset NETCDF4
293 if [ -z "$HDF5_PATH" ] ; then HDF5_PATH=''; fi
294 if [ -z "$ZLIB_PATH" ] ; then ZLIB_PATH=''; fi
295 if [ -z "$GPFS_PATH" ] ; then GPFS_PATH=''; fi
296 if [ -z "$CURL_PATH" ] ; then CURL_PATH=''; fi
298 if [ -n "$NETCDF4" ] ; then
299 if [ $NETCDF4 -eq 1 ] ; then
300 NETCDF4_DEP_LIB=''
301 if [ "$NETCDF_C" != "NOT_FOUND" -a -f $NETCDF_C/bin/nc-config ] ; then
302 nx_config="`$NETCDF_C/bin/nc-config --libs`"
303 NETCDF4_DEP_LIB="$NETCDF4_DEP_LIB $nx_config"
304 else
305 echo ' '
306 echo '*****************************************************************************'
307 echo 'WARNING! Unable to find nc-config. Linking with NetCDF may fail.'
308 echo '*****************************************************************************'
309 echo ' '
311 nx_config="`$NETCDF/bin/nf-config --flibs`"
312 NETCDF4_DEP_LIB="$NETCDF4_DEP_LIB $nx_config"
316 if [ -n "$PNETCDF" ] ; then
317 echo "Will use PNETCDF in dir: $PNETCDF"
318 # experimental, so don't tease the user if it is not there
319 #else
320 # echo "Will configure for use without NetCDF"
323 if [ -n "$ADIOS2" ] ; then
324 echo "Will use ADIOS2 in dir: $ADIOS2"
325 else
326 echo "ADIOS2 not set in environment. Will configure WRF for use without."
329 if [ -n "$HDF5" ] ; then
330 echo "Will use HDF5 in dir: $HDF5"
331 else
332 echo "HDF5 not set in environment. Will configure WRF for use without."
335 if [ -n "$PHDF5" ] ; then
336 echo "Will use PHDF5 in dir: $PHDF5"
337 else
338 echo "PHDF5 not set in environment. Will configure WRF for use without."
341 if [ "$wrf_core" = "DA_CORE" -o "$wrf_core" = "4D_DA_CORE" ] ; then
342 if [ -n "$RTTOV" ] ; then
343 echo "Will use RTTOV in dir: $RTTOV"
344 else
345 echo "RTTOV not set in environment. Will configure WRFDA for use without."
349 # Set the "traditional" flag and the "cpp" flags
351 TFL="-traditional-cpp"
352 CFL="-P -nostdinc"
354 if [ "$wrf_core" = "4D_DA_CORE" ]; then
355 if [ -n "$WRFPLUS_DIR" ] ; then
356 echo "Will use WRFPLUS in dir: $WRFPLUS_DIR"
357 else
358 echo "WRFPLUS_DIR not set in environment. Please compile WRFPLUS and set WRFPLUS_DIR."
359 exit
361 else
362 if [ -n "$WRFPLUS_DIR" ] ; then
363 echo 'Unsetting "$WRFPLUS_DIR" environment variable. Use "configure 4dvar" to configure for 4dvar compilation.'
364 unset WRFPLUS_DIR
367 # Users who are cross-compiling can set environment variable
368 # $WRF_OS to override the value normally obtained from `uname`.
369 # If $WRF_OS is set, then $WRF_MACH can also be set to override
370 # the value normally obtained from `uname -m`. If $WRF_OS is
371 # set and $WRF_MACH is not set, then $WRF_MACH defaults to "ARCH".
372 # If $WRF_OS is not set then $WRF_MACH is ignored.
373 if [ -n "$WRF_OS" ] ; then
374 echo "${0}: WRF operating system set to \"${WRF_OS}\" via environment variable \$WRF_OS"
375 os=$WRF_OS
376 mach="ARCH"
377 if [ -n "$WRF_MACH" ] ; then
378 echo "${0}: WRF machine set to \"${WRF_MACH}\" via environment variable \$WRF_MACH"
379 mach=$WRF_MACH
381 else
382 # if the uname command exists, give it a shot and see if
383 # we can narrow the choices; otherwise, spam 'em
384 os="ARCH"
385 mach="ARCH"
386 type uname > /dev/null
387 if [ $? -eq 0 ] ; then
388 os=`uname`
389 if [ "$os" = "AIX" -o "$os" = "IRIX" -o "$os" = "IRIX64" -o "$os" = "SunOS" -o "$os" = "HP-UX" -o "$os" = "Darwin" -o "$os" = "Interix" ] ; then
390 mach="ARCH"
391 else
392 xxx=`expr "$os" : '\(.........\).*'`
393 if [ "$xxx" = "CYGWIN_NT" ] ; then
394 os=$xxx
396 if [ "$os" = "OSF1" -o "$os" = "Linux" -o "$os" = "UNICOS/mp" -o "$os" = "UNIX_System_V" -o "$os" = "CYGWIN_NT" ] ; then
397 mach=`uname -m`
398 if [ "$mach" = "ia64" -a -f /etc/sgi-release ] ; then
399 mach="Altix"
401 else
402 os="ARCH"
403 mach="ARCH"
409 # an IBM specific hack to adjust the bmaxstack and bmaxdata options if addressing is 32-bit
410 if [ "$os" = "AIX" ] ; then
411 if [ -z "$OBJECT_MODE" ] ; then
412 OBJECT_MODE=32
413 export OBJECT_MODE
415 if [ "$OBJECT_MODE" = "32" ] ; then
416 # the bang means nothing to sh in this context; use to represent spaces (perl will unbang)
417 ldflags=-bmaxstack:256000000!-bmaxdata:2048000000
421 # compile options that come from the environment, such as chemistry
422 # the "!" is removed by Config.pl
423 if [ -n "$WRF_HYDRO" ] ; then
424 if [ $WRF_HYDRO = 1 ] ; then
425 echo building WRF-HYDRO
426 compileflags="${compileflags}!-DWRF_HYDRO"
427 echo $compileflags
431 # compile options that come from the environment, such as chemistry
432 # the "!" is removed by Config.pl
433 if [ -n "$WRF_MARS" ] ; then
434 if [ $WRF_MARS = 1 ] ; then
435 echo building WRF for Mars
436 compileflags="${compileflags}!-DPLANET!-DMARS"
437 echo $compileflags
441 if [ -n "$WRF_TITAN" ] ; then
442 if [ $WRF_TITAN = 1 ] ; then
443 echo building WRF for Titan
444 compileflags="${compileflags}!-DPLANET!-DTITAN"
448 if [ -n "$WRF_VENUS" ] ; then
449 if [ $WRF_VENUS = 1 ] ; then
450 echo building WRF for Venus
451 compileflags="${compileflags}!-DPLANET!-DVENUS"
454 if [ -n "$WRF_QUIETLY" ]; then
455 echo WRF_QUIETLY is now a synonym for WRF_LOG_BUFFERING
456 echo setting WRF_LOG_BUFFERING to 1...
457 export WRF_LOG_BUFFERING=1
459 if [ -n "$WRF_LOG_BUFFERING" ]; then
460 if [ $WRF_LOG_BUFFERING = 1 ]; then
461 echo building WRF with support for buffering of log messages
462 compileflags="${compileflags}!-DWRF_LOG_BUFFERING=1"
465 if [ -n "$PNETCDF_QUILT" ]; then
466 echo Enabling quilt_pnc I/O server implementation.
467 compileflags="${compileflags}!-DPNETCDF_QUILT=1"
469 if [ -n "$WRF_DFI_RADAR" ] ; then
470 if [ $WRF_DFI_RADAR = 1 ] ; then
471 echo building WRF with radar dfi option
472 compileflags="${compileflags}!-DWRF_DFI_RADAR=1"
476 if [ -n "$WRF_CMAQ" ] ; then
477 echo building WRF with CMAQ option
478 compileflags="${compileflags}!-DWRF_CMAQ"
481 if [ -n "$WRF_CHEM" ] ; then
482 if [ $WRF_CHEM = 1 ] ; then
483 echo building WRF with chemistry option
484 compileflags="${compileflags}!-DWRF_CHEM!-DBUILD_CHEM=1"
485 if [ -n "$WRF_KPP" ] ; then
486 if [ $WRF_KPP = 1 ] ; then
487 echo building WRF with KPP chemistry option
488 compileflags="${compileflags}!-DWRF_KPP"
491 else
492 compileflags="${compileflags} "
494 else
495 compileflags="${compileflags} "
498 if [ -n "$WRFPLUS" ] ; then
499 if [ $WRFPLUS = 1 ] ; then
500 echo building WRF for TL and AD
501 compileflags="!-DWRFPLUS"
502 echo $compileflags
506 type m4 > /dev/null
507 if [ $? -ne 0 ] ; then
508 echo
509 echo "ERROR ERROR ERROR ERROR ERROR ERROR ERROR"
510 echo "'m4' utility not found! Can not configure."
511 echo
512 echo "If on an Ubuntu machine, use the command"
513 echo " sudo apt-get install m4 "
514 echo "To download and install the 'm4' utility"
515 exit 1
518 if command -v timex > /dev/null 2>&1; then
519 FORTRAN_COMPILER_TIMER=timex
520 echo "Will use 'timex' to report timing information"
521 elif command -v time > /dev/null 2>&1; then
522 FORTRAN_COMPILER_TIMER=time
523 echo "Will use 'time' to report timing information"
526 # Is this some type of WRF DA build? If so, it is real*8.
527 # Let's go ahead and set a flag internally.
528 if test -n "$wrf_core" ; then
529 if [ "$wrf_core" = "DA_CORE" -o \
530 "$wrf_core" = "4D_DA_CORE" -o \
531 "$wrf_core" = "WRF_PLUS_CORE" ] ; then
532 rword="-r8"
536 # Found perl, so proceed with configuration
537 if test -n "$PERL" ; then
538 srch=`grep -i "^#ARCH.*$os" arch/configure.defaults | grep -i "$mach"`
539 if [ -n "$srch" ] ; then
540 $PERL arch/Config.pl -dmparallel=$COMMLIB -ompparallel=$OMP -perl=$PERL \
541 -netcdf=$NETCDF -pnetcdf=$PNETCDF -netcdfpar=$NETCDFPAR -adios2=$ADIOS2 -hdf5=$HDF5 -phdf5=$PHDF5 -os=$os -mach=$mach -ldflags=$ldflags \
542 -compileflags=$compileflags -opt_level=$opt_level -USENETCDFF=$USENETCDFF -USENETCDF=$USENETCDF \
543 -time=$FORTRAN_COMPILER_TIMER -tfl="$TFL" -cfl="$CFL" -config_line="$config_line" \
544 -wrf_core=$wrf_core -gpfs=$GPFS_PATH -curl=$CURL_PATH -netcdf4_dep_lib="$NETCDF4_DEP_LIB"
545 if test ! -f configure.wrf ; then
546 echo "configure.wrf not created! Exiting configure script..."
547 exit 1
549 if [ "$opt_level" = "-d" ] ; then
550 sed -e 's/FCOPTIM[ ]*=/& # /' -e '/FCDEBUG[ ]*=/s/#//' configure.wrf > configure.wrf.edit
551 /bin/mv configure.wrf.edit configure.wrf
553 if [ "$opt_level" = "-D" ] ; then
554 sed -e 's/FCOPTIM[ ]*=/& # /' -e '/FCDEBUG[ ]*=/s/#//g' configure.wrf > configure.wrf.edit
555 /bin/mv configure.wrf.edit configure.wrf
558 # GNU has a funny way of doing promotion to real*8
559 if [ "$rword" = "-r8" ] ; then
560 srch=`grep -i "^SFC" configure.wrf | grep -i "gfortran"`
561 if [ -n "$srch" ] ; then
562 sed -e '/^PROMOTION/s/#//' \
563 -e '/^RWORDSIZE/s/$(NATIVE_RWORDSIZE)/8/' configure.wrf > configure.wrf.edit
564 else
565 sed -e '/^RWORDSIZE/s/$(NATIVE_RWORDSIZE)/8/' configure.wrf > configure.wrf.edit
567 /bin/mv configure.wrf.edit configure.wrf
568 sed -e 's/-DBUILD_SBM_FAST=1/-DBUILD_SBM_FAST=0/' configure.wrf > configure.wrf.edit
569 /bin/mv configure.wrf.edit configure.wrf
571 else
572 echo '*********************************************************'
573 echo '*** ERROR ERROR ERROR ERROR ***'
574 echo '*** ***'
575 echo '*** Configuration not found in configure.defaults ***'
576 echo '*********************************************************'
577 exit 2
581 if test -f configure.wrf ; then
582 # new dec 2005. test what fseek is supported (needed for share/landread.c to work correctly)
583 echo testing for fseeko and fseeko64
584 /bin/rm -f tools/fseeko_test tools/fseeko64_test
585 ( make fseek_test 2> /dev/null ) 1> /dev/null
586 if [ "$os" = "Darwin" ] ; then
587 # fseeko64 does not exist under Darwin fseeko does. Remove the 0 length executable
588 # file that might get generated anyway, even though the compiler complains about missing reference.
589 /bin/rm -f tools/fseeko64_test
591 if test -x tools/fseeko64_test ; then
592 ( tools/fseeko64_test 2> /dev/null ) 1> /dev/null
593 if [ $? = 0 ] ; then
594 echo fseeko64 is supported
595 sed '/^CC .*=/s/$/ -DFSEEKO64_OK /' configure.wrf > xx$$ ; /bin/mv xx$$ configure.wrf
597 else
598 if test -x tools/fseeko_test ; then
599 ( tools/fseeko_test 2> /dev/null ) 1> /dev/null
600 if [ $? = 0 ] ; then
601 echo fseeko is supported and handles 64 bit offsets
602 sed '/^CC .*=/s/$/ -DFSEEKO_OK /' configure.wrf > xx$$ ; /bin/mv xx$$ configure.wrf
603 else
604 echo neither fseeko64 nor fseeko with 64 bit offsets works, landread will be compiled with fseek
605 echo but may not work correctly for very high resolution terrain datasets
607 else
608 echo neither fseeko64 nor fseeko with 64 bit offsets works, landread will be compiled with fseek
609 echo but may not work correctly for very high resolution terrain datasets
614 echo "------------------------------------------------------------------------"
615 sed -e '1,/#### Architecture specific settings ####/d' -e '/^externals/,$d' configure.wrf
617 echo "------------------------------------------------------------------------"
618 echo "Settings listed above are written to configure.wrf."
619 echo "If you wish to change settings, please edit that file."
620 echo "If you wish to change the default options, edit the file:"
621 echo " arch/configure.defaults"
623 if test -n "$NETCDF" ; then
624 if [ ! -f $NETCDF/include/netcdf.inc ] ; then
625 echo
626 echo "Error : Not found $NETCDF/include/netcdf.inc"
627 echo " Please check this installation of NetCDF and re-run this configure script"
628 exit -1
630 grep nf_format_64bit $NETCDF/include/netcdf.inc > /dev/null
631 configure_aaaa=$? ; export configure_aaaa
632 if [ $configure_aaaa -a -z "$WRFIO_NCD_NO_LARGE_FILE_SUPPORT" ] ; then
633 echo "NetCDF users note:"
634 echo " This installation of NetCDF supports large file support. To DISABLE large file"
635 echo " support in NetCDF, set the environment variable WRFIO_NCD_NO_LARGE_FILE_SUPPORT"
636 echo " to 1 and run configure again. Set to any other value to avoid this message."
639 echo " "
641 if [ "$wrf_core" = "DA_CORE" -o "$wrf_core" = "WRF_PLUS_CORE" -o "$wrf_core" = "4D_DA_CORE" ]; then
642 if [ "`grep '^SFC' configure.wrf | grep -i 'gfortran'`" != "" -o "`grep '^SFC' configure.wrf | grep -i 'frtpx'`" != "" ]; then
643 echo "WRFDA/WRFPLUS using gfortran/frtpx needs realsize=8"
644 sed -e '/^PROMOTION.*=/s/#//' configure.wrf > configure.wrf.edit
645 /bin/mv configure.wrf.edit configure.wrf
649 if [ -n "$WRFPLUS" ] ; then
650 if [ $WRFPLUS = 1 ] ; then
651 if [ `grep '^SFC' configure.wrf | cut -d= -f2` = "gfortran" ]; then
652 echo "WRFPLUS using gfortran needs realsize=8"
653 sed -e '/^PROMOTION.*=/s/#//' configure.wrf > configure.wrf.edit
654 /bin/mv configure.wrf.edit configure.wrf
659 #Checking cross-compiling capability for some particular environment
660 #on Linux and Mac box
662 if [ $os = "Linux" -o $os = "Darwin" -o $os = "CYGWIN_NT" ]; then
664 SFC=`grep '^SFC' configure.wrf | awk '{print $3}'`
665 SCC=`grep '^SCC' configure.wrf | awk '{print $3}'`
666 CCOMP=`grep '^CCOMP' configure.wrf | awk '{print $3}'`
668 SFC="`type $SFC 2>/dev/null | awk '{print $NF}' | sed -e 's/(//g;s/)//g'`"
669 SCC="`type $SCC 2>/dev/null | awk '{print $NF}' | sed -e 's/(//g;s/)//g'`"
670 CCOMP="`type $CCOMP 2>/dev/null | awk '{print $NF}' | sed -e 's/(//g;s/)//g'`"
672 foo=foo_$$
674 grep '^SFC' configure.wrf | grep -i 'gfortran' > /dev/null
675 if [ $? ]
676 then
678 cat > ${foo}.F << EOF
679 PROGRAM GFORTRAN_VERSION_CHECK
680 IF (__GNUC__ .GT. 9) CALL EXIT(1)
681 END PROGRAM
684 gfortran -o ${foo} ${foo}.F > /dev/null 2>&1 && ./${foo}
685 if [ $? -eq 1 ]
686 then
687 sed '/^FCCOMPAT/ s/$/ -fallow-argument-mismatch -fallow-invalid-boz/' configure.wrf > configure.wrf.edit
688 mv configure.wrf.edit configure.wrf
690 rm ${foo} ${foo}.F 2> /dev/null
693 cat > ${foo}.c <<EOF
694 int main(int argc, char ** argv)
696 return (0);
700 cat > ${foo}.f <<EOF
701 program test_exit
702 integer :: STATUS = 0
703 call EXIT(STATUS)
704 end program test_exit
707 # do not do this test for MIC, which cross compiles
708 if [ -z "`grep 'SCC.*mmic' configure.wrf`" ] ; then
709 # Detecting whether if mpi compiler wrapper supports -cc/-f90 options
710 if [ -z "`grep -i -E '^DMPARALLEL[ \t]*=.*#' configure.wrf`" ] ; then
711 mpicc -cc=$SCC -o ${foo} ${foo}.c > /dev/null 2>&1
712 if [ $? != 0 ]; then
713 sed 's/-cc=$(SCC)//' configure.wrf > configure.wrf.edit
714 mv configure.wrf.edit configure.wrf
716 rm ${foo} ${foo}.o 2> /dev/null
717 mpif90 -f90=$SFC -o ${foo} ${foo}.f > /dev/null 2>&1
718 if [ $? != 0 ]; then
719 sed 's/-f90=$(SFC)//' configure.wrf > configure.wrf.edit
720 mv configure.wrf.edit configure.wrf
722 rm ${foo} ${foo}.o 2> /dev/null
726 if [ -e $NETCDF_C/lib/libnetcdf.a -a "$SFC" != "" -a "$SCC" != "" -a "$CCOMP" != "" ]; then
728 SFC_MULTI_ABI=0
729 SCC_MULTI_ABI=0
730 CCOMP_MULTI_ABI=0
731 CROSS_COMPILING=0
733 echo
734 echo Testing for NetCDF, C and Fortran compiler
735 echo
737 ar p $NETCDF_C/lib/libnetcdf.a `ar t $NETCDF_C/lib/libnetcdf.a | grep -E '\.o' | head -n 1 | sed 's/://'` > ${foo}.o
738 netcdf_arch="`file ${foo}.o | grep -o -E '[0-9]{2}-bit|i386'`"
739 rm ${foo}.o
741 $SFC -o ${foo} ${foo}.f > /dev/null 2>&1
742 SFC_arch="`file ${foo} | grep -o -E '[0-9]{2}-bit|i386'`"
743 rm ${foo} ${foo}.o 2> /dev/null
745 $SCC -o ${foo} ${foo}.c > /dev/null 2>&1
746 SCC_arch="`file ${foo} | grep -o -E '[0-9]{2}-bit|i386'`"
747 CCOMP_arch=$SCC_arch
748 rm ${foo} ${foo}.o 2> /dev/null
750 if [ "$SCC" != "$CCOMP" ]; then
751 $CCOMP -o ${foo} ${foo}.c > /dev/null 2>&1
752 CCOMP_arch="`file ${foo} | grep -o -E '[0-9]{2}-bit|i386'`"
753 rm ${foo} ${foo}.o 2> /dev/null
756 if [ "$SFC_arch" = "" -o "$SCC_arch" = "" -o "$CCOMP_arch" = "" ]; then
757 echo " One of compilers testing failed!"
758 echo " Please check your compiler"
759 echo
760 rm -f ${foo} ${foo}.[cfo] 2> /dev/null
761 exit
762 else
763 cp configure.wrf configure.wrf.edit
766 case $netcdf_arch in
768 32-bit|i386 )
770 if [ "$SFC_arch" = "64-bit" ] ; then
771 CROSS_COMPILING=1
772 $SFC -m32 -o ${foo} ${foo}.f > /dev/null 2>&1
773 if [ $? = 0 ]; then
774 SFC_MULTI_ABI=1
775 sed '/^SFC.*=/s/$/ -m32/' configure.wrf.edit > configure.wrf.tmp
776 mv configure.wrf.tmp configure.wrf.edit
779 if [ "$SCC_arch" = "64-bit" ] ; then
780 CROSS_COMPILING=1
781 $SCC -m32 -o ${foo} ${foo}.c > /dev/null 2>&1
782 if [ $? = 0 ]; then
783 SCC_MULTI_ABI=1
784 sed '/^SCC.*=/s/$/ -m32/' configure.wrf.edit > configure.wrf.tmp
785 mv configure.wrf.tmp configure.wrf.edit
789 if [ "$CCOMP_arch" = "64-bit" ] ; then
790 CROSS_COMPILING=1
791 if [ "$CCOMP" != "$SCC" ]; then
792 $CCOMP -m32 -o ${foo} ${foo}.c > /dev/null 2>&1
793 if [ $? = 0 ]; then
794 CCOMP_MULTI_ABI=1
795 sed '/^CCOMP/ s/$/ -m32/' configure.wrf.edit > configure.wrf.tmp
796 mv configure.wrf.tmp configure.wrf.edit
798 else
799 CCOMP_MULTI_ABI=1
800 sed '/^CCOMP/ s/$/ -m32/' configure.wrf.edit > configure.wrf.tmp
801 mv configure.wrf.tmp configure.wrf.edit
805 if [ $CROSS_COMPILING -eq 1 ] ; then
806 echo NOTE:
807 echo This installation of NetCDF is 32-bit
808 if [ \( $SFC_MULTI_ABI -ne 1 -a "$SFC_arch" = "64-bit" \) \
809 -o \( $SCC_MULTI_ABI -ne 1 -a "$SCC_arch" = "64-bit" \) \
810 -o \( $CCOMP_MULTI_ABI -ne 1 -a "$CCOMP_arch" = "64-bit" \) ] ; then
811 rm configure.wrf.edit
812 echo One of compilers is 64-bit and doesn\'t support cross-compiling.
813 echo Please check your NETCDF lib and compiler
814 else
815 echo -m32 is appended to configure.wrf
816 echo It will be forced to build in 32-bit.
817 echo If you don\'t want 32-bit binaries, please use 64-bit NetCDF, and re-run the configure script.
822 64-bit )
824 if [ "$SFC_arch" = "32-bit" -o "$SFC_arch" = "i386" ] ; then
825 CROSS_COMPILING=1
826 $SFC -m64 -o ${foo} ${foo}.f > /dev/null 2>&1
827 if [ $? = 0 ]; then
828 SFC_MULTI_ABI=1
829 sed '/^SFC.*=/s/$/ -m64/' configure.wrf.edit > configure.wrf.tmp
830 mv configure.wrf.tmp configure.wrf.edit
833 if [ "$SCC_arch" = "32-bit" -o "$SCC_arch" = "i386" ] ; then
834 CROSS_COMPILING=1
835 $SCC -m64 -o ${foo} ${foo}.c > /dev/null 2>&1
836 if [ $? = 0 ]; then
837 SCC_MULTI_ABI=1
838 sed '/^SCC.*=/s/$/ -m64/' configure.wrf.edit > configure.wrf.tmp
839 mv configure.wrf.tmp configure.wrf.edit
843 if [ "$CCOMP_arch" = "32-bit" -o "$CCOMP_arch" = "i386" ] ; then
844 CROSS_COMPILING=1
845 if [ "$CCOMP" != "$SCC" ]; then
846 $CCOMP -m64 -o ${foo} ${foo}.c > /dev/null 2>&1
847 if [ $? = 0 ]; then
848 CCOMP_MULTI_ABI=1
849 sed '/^CCOMP/ s/$/ -m64/' configure.wrf.edit > configure.wrf.tmp
850 mv configure.wrf.tmp configure.wrf.edit
852 else
853 CCOMP_MULTI_ABI=1
854 sed '/^CCOMP/ s/$/ -m64/' configure.wrf.edit > configure.wrf.tmp
855 mv configure.wrf.tmp configure.wrf.edit
859 if [ $CROSS_COMPILING -eq 1 ] ; then
860 echo NOTE:
861 echo This installation of NetCDF is 64-bit
862 if [ \( $SFC_MULTI_ABI -ne 1 -a "$SFC_arch" != "64-bit" \) \
863 -o \( $SCC_MULTI_ABI -ne 1 -a "$SCC_arch" != "64-bit" \) \
864 -o \( $CCOMP_MULTI_ABI -ne 1 -a "$CCOMP_arch" != "64-bit" \) ]; then
865 rm configure.wrf.edit
866 echo One of Compilers is 32-bit and doesn\'t support cross-compiling.
867 echo Please check your NetCDF lib and compiler
868 else
869 echo -m64 is appended to configure.wrf
870 echo It will be forced to build in 64-bit.
871 echo If you don\'t want 64-bit binaries, please use 32-bit NetCDF, and re-run the configure script.
875 esac
877 if [ -e configure.wrf.edit ]; then
878 mv configure.wrf.edit configure.wrf
881 if [ $CROSS_COMPILING -eq 0 ] ; then
882 echo "This installation of NetCDF is $netcdf_arch"
883 echo " C compiler is $SCC_arch"
884 echo " Fortran compiler is $SFC_arch"
885 echo " It will build in $netcdf_arch"
886 echo " "
887 if [ -e $NETCDF_C/bin/nc-config ] ; then
888 echo "NetCDF version: ${ncversion}"
889 echo "Enabled NetCDF-4/HDF-5: `$NETCDF_C/bin/nc-config --has-nc4`"
890 echo "NetCDF built with PnetCDF: `$NETCDF_C/bin/nc-config --has-pnetcdf`"
891 if [ "$USENETCDFPAR" = "1" ] ; then
892 echo "Using parallel NetCDF via NETCDFPAR option"
894 echo " "
897 echo
899 rm -f ${foo} ${foo}.[cfo] 2> /dev/null
902 # testing for Fortran 2003 IEEE features
903 make fortran_2003_ieee_test > tools/fortran_2003_ieee_test.log 2>&1
904 rm -f tools/fortran_2003_ieee_test.log
905 retval=-1
906 if [ -f tools/fortran_2003_ieee_test.exe ] ; then
907 retval=0
909 if [ $retval -ne 0 ] ; then
910 sed -e '/^ARCH_LOCAL/s/$/ -DNO_IEEE_MODULE/' configure.wrf > configure.wrf.edit
911 mv configure.wrf.edit configure.wrf
912 echo " "
913 echo " "
914 echo "************************** W A R N I N G ************************************"
915 echo " "
916 echo "There are some IEEE Fortran 2003 features in WRF that your compiler does not"
917 echo "recognize. The IEEE function calls have been removed."
918 echo " "
919 echo "*****************************************************************************"
922 # testing for Fortran 2003 ISO_C features
923 make fortran_2003_iso_c_test > tools/fortran_2003_iso_c_test.log 2>&1
924 rm -f tools/fortran_2003_iso_c_test.log
925 retval=-1
926 if [ -f tools/fortran_2003_iso_c_test.exe ] ; then
927 retval=0
929 if [ $retval -ne 0 ] ; then
930 sed -e '/^ARCH_LOCAL/s/$/ -DNO_ISO_C_SUPPORT/' configure.wrf > configure.wrf.edit
931 mv configure.wrf.edit configure.wrf
932 echo " "
933 echo " "
934 echo "************************** W A R N I N G ************************************"
935 echo " "
936 echo "There are some Fortran 2003 features in WRF that your compiler does not recognize"
937 echo "The routines that utilize ISO_C support have been stubbed out. "
938 echo "That may not be enough."
939 echo " "
940 echo "*****************************************************************************"
943 # testing for Fortran 2003 FLUSH features
944 make fortran_2003_flush_test > tools/fortran_2003_flush_test.log 2>&1
945 rm -f tools/fortran_2003_flush_test.log
946 retval=-1
947 if [ -f tools/fortran_2003_flush_test.exe ] ; then
948 retval=0
950 if [ $retval -ne 0 ] ; then
951 make fortran_2003_fflush_test > tools/fortran_2003_fflush_test.log 2>&1
952 rm -f tools/fortran_2003_fflush_test.log
953 retval=-1
954 if [ -f tools/fortran_2003_fflush_test.exe ] ; then
955 retval=0
957 if [ $retval -eq 0 ] ; then
958 sed -e '/^ARCH_LOCAL/s/$/ -DUSE_FFLUSH/' configure.wrf > configure.wrf.edit
959 mv configure.wrf.edit configure.wrf
960 echo " "
961 echo " "
962 echo "************************** W A R N I N G ************************************"
963 echo " "
964 echo "There are some Fortran 2003 features in WRF that your compiler does not recognize"
965 echo "The standard FLUSH routine has been replaced by FFLUSH."
966 echo "That may not be enough."
967 echo " "
968 echo "*****************************************************************************"
970 if [ $retval -ne 0 ] ; then
971 sed -e '/^ARCH_LOCAL/s/$/ -DNO_FLUSH_SUPPORT/' configure.wrf > configure.wrf.edit
972 mv configure.wrf.edit configure.wrf
973 echo " "
974 echo " "
975 echo "************************** W A R N I N G ************************************"
976 echo " "
977 echo "There are some Fortran 2003 features in WRF that your compiler does not recognize"
978 echo "The standard FLUSH routine has been stubbed out."
979 echo "That may not be enough."
980 echo " "
981 echo "*****************************************************************************"
985 # testing for Fortran 2008 intrinsic gamma function
986 make fortran_2008_gamma_test > tools/fortran_2008_gamma.log 2>&1
987 rm -f tools/fortran_2008_gamma.log
988 retval=-1
989 if [ -f tools/fortran_2008_gamma_test.exe ] ; then
990 retval=0
992 if [ $retval -ne 0 ] ; then
993 sed -e '/^ARCH_LOCAL/s/$/ -DNO_GAMMA_SUPPORT/' configure.wrf > configure.wrf.edit
994 mv configure.wrf.edit configure.wrf
995 echo " "
996 echo " "
997 echo "************************** W A R N I N G ************************************"
998 echo " "
999 echo "There are some Fortran 2008 features in WRF that your compiler does not recognize"
1000 echo "The intrinsic gamma function is not available, required by some schemes."
1001 echo "That code is stubbbed out, and those schemes are unavailable at run-time."
1002 echo " "
1003 echo "*****************************************************************************"
1006 # testing for location of rpc/types.h file, used in landuse
1007 make rpc_test > tools/rpc_test.log 2>&1
1008 rm -f tools/rpc_test.log
1010 if [ -f tools/rpc_test.exe ] ; then
1011 rpc_type=`tools/rpc_test.exe`
1012 if [ $rpc_type = "rpc" ]; then
1013 sed -e '/^CFLAGS_LOCAL/s/#/-DRPC_TYPES=1 &/' configure.wrf > configure.wrf.edit
1014 else
1015 sed -e '/^CFLAGS_LOCAL/s/#/-DRPC_TYPES=2 &/' configure.wrf > configure.wrf.edit
1017 mv configure.wrf.edit configure.wrf
1018 else
1019 echo "************************** W A R N I N G ************************************"
1020 echo " "
1021 echo "The moving nest option is not available due to missing rpc/types.h file."
1022 echo "Copy landread.c.dist to landread.c in share directory to bypass compile error."
1023 echo " "
1024 echo "*****************************************************************************"
1027 # testing for netcdf4 IO features
1028 if [ -n "$NETCDF4" ] ; then
1029 if [ $NETCDF4 -eq 1 ] ; then
1030 make nc4_test > tools/nc4_test.log 2>&1
1031 retval=-1
1032 if [ -f tools/nc4_test.exe ] ; then
1033 retval=0
1034 rm -f tools/nc4_test.log
1036 if [ $retval -ne 0 ] ; then
1037 echo "************************** W A R N I N G ************************************"
1038 echo "NETCDF4 IO features are requested, but this installation of NetCDF "
1039 echo " $NETCDF"
1040 echo "DOES NOT support these IO features. "
1041 echo
1042 echo "Please make sure NETCDF version is 4.1.3 or later and was built with "
1043 echo "--enable-netcdf4 "
1044 echo
1045 echo "OR set NETCDF_classic variable "
1046 echo " bash/ksh : export NETCDF_classic=1 "
1047 echo " csh : setenv NETCDF_classic 1 "
1048 echo
1049 echo "Then re-run this configure script "
1050 echo
1051 echo "!!! configure.wrf has been REMOVED !!!"
1052 echo
1053 echo "*****************************************************************************"
1054 rm -f configure.wrf
1055 else
1056 echo "*****************************************************************************"
1057 echo "This build of WRF will use NETCDF4 with HDF5 compression"
1058 echo "*****************************************************************************"
1059 echo " "
1062 else
1063 echo "*****************************************************************************"
1064 echo "This build of WRF will use classic (non-compressed) NETCDF format"
1065 echo "*****************************************************************************"
1066 echo " "