updated top-level README and version_decl for V4.5 (#1847)
[WRF.git] / configure
blobeaf4a1aa17a9683bf6f94865ce1443c1f6bda130
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 Win, 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 if [ -e $NETCDF/bin/nc-config ] ; then
163 ncversion=`nc-config --version | awk '{print $2}'`
164 else
165 ncversion=OLD
168 PROBS=FALSE
169 if [ -n "$NETCDFPAR" ] ; then
170 NETCDF="$NETCDFPAR"
171 if [ ! -e $NETCDF/bin/nc-config ] ; then
172 PROBS=TRUE
173 else
174 ncversion=`nc-config --version | awk '{print $2}'`
175 ncversiona=`echo $ncversion | cut -c 1`
176 ncversionb=`echo $ncversion | cut -c 3`
177 ncversionc=`echo $ncversion | cut -c 5`
178 ncversiona=`expr $ncversiona \* 100`
179 ncversionb=`expr $ncversionb \* 10`
180 ncversionabc=`expr $ncversiona + $ncversionb`
181 ncversionabc=`expr $ncversionabc + $ncversionc`
182 if [ $ncversionabc -lt 474 ] ; then
183 PROBS=TRUE
186 if [ "$PROBS" = "TRUE" ] ; then
187 echo
188 echo Cannot activate NETCDFPAR with this version of NetCDF: $ncversion
189 echo You need NetCDF version 4.7.4 or newer
190 echo Use a newer version of NetCDF, or unset the env variable NETCDFPAR
191 echo
192 exit
194 NETCDF4="1"
195 USENETCDFPAR="1"
196 export NETCDF
197 export NETCDF4
198 export USENETCDFPAR
201 if test -z "$NETCDF" ; then
202 echo ' '
203 echo '*****************************************************************************'
204 echo 'No environment variable NETCDF set.'
205 echo 'Stopping'
206 echo '*****************************************************************************'
207 echo ' '
208 exit 5
211 if test -z "$NETCDF_classic" ; then
212 export NETCDF4=1
213 else
214 unset NETCDF4
217 USENETCDFF=""
218 USENETCDF=""
219 if [ -n "$NETCDF" ] ; then
220 echo "Will use NETCDF in dir: $NETCDF"
221 # Oh UNIDATA, why make it so hard ...
222 if [ -f "$NETCDF/lib/libnetcdff.a" -o -f "$NETCDF/lib/libnetcdff.so" -o -f "$NETCDF/lib/libnetcdff.dll.a" ] ; then
223 USENETCDFF="-lnetcdff"
224 else
225 USENETCDFF=" "
227 if [ -f "$NETCDF/lib/libnetcdf.a" -o -f "$NETCDF/lib/libnetcdf.so" -o -f "$NETCDF/lib/libnetcdf.dll.a" ] ; then
228 USENETCDF="-lnetcdf"
229 else
230 USENETCDF=" "
232 export USENETCDF=$USENETCDF
233 export USENETCDFF=$USENETCDFF
234 else
235 echo ' '
236 echo '*****************************************************************************'
237 echo 'No environment variable NETCDF set.'
238 echo 'Stopping'
239 echo '*****************************************************************************'
240 echo ' '
241 exit 6
244 # If the user asked for classic netcdf, acquiesce to the request.
246 ans="`which nf-config`"
247 status="$?"
248 if [ "$ans" = "nf-config:" -o "$ans" = "" -o "$status" != "0" ] ; then
249 export NETCDF_classic=1
250 unset NETCDF4
251 else
252 if [ -n "$NETCDF_classic" ] ; then
253 if [ $NETCDF_classic -eq 1 ] ; then
254 unset NETCDF4
255 else
256 unset NETCDF_classic
257 export NETCDF4=1
259 else
260 if [ "`nf-config --has-nc4`" = "yes" ] ; then
261 unset NETCDF_classic
262 export NETCDF4=1
263 else
264 export NETCDF_classic=1
265 unset NETCDF4
270 if [ -z "$HDF5_PATH" ] ; then HDF5_PATH=''; fi
271 if [ -z "$ZLIB_PATH" ] ; then ZLIB_PATH=''; fi
272 if [ -z "$GPFS_PATH" ] ; then GPFS_PATH=''; fi
273 if [ -z "$CURL_PATH" ] ; then CURL_PATH=''; fi
275 if [ -n "$NETCDF4" ] ; then
276 if [ $NETCDF4 -eq 1 ] ; then
277 DEP_LIB_PATH=''
278 if [ -f $NETCDF/bin/nf-config ] ; then
279 nx_config="$NETCDF/bin/nf-config --flibs"
280 DEP_LIB_PATH="`$nx_config | awk '{for(i=1;i<=NF;i++){if(match($i, /-L.*/)) {print $i} } }'`"
281 CURL="`$nx_config | awk '{for(i=1;i<=NF;i++){if($i == "-lcurl") {print $i} } }'`"
282 GPFS="`$nx_config | awk '{for(i=1;i<=NF;i++){if($i == "-lgpfs") {print $i} } }'`"
284 if [ "$DEP_LIB_PATH" = '' ] ; then
285 if [ -f $NETCDF/bin/nc-config ] ; then
286 nx_config="$NETCDF/bin/nc-config --libs"
287 DEP_LIB_PATH="`$nx_config | awk '{for(i=1;i<=NF;i++){if(match($i, /-L.*/)) {print $i} } }'`"
288 CURL="`$nx_config | awk '{for(i=1;i<=NF;i++){if($i == "-lcurl") {print $i} } }'`"
289 GPFS="`$nx_config | awk '{for(i=1;i<=NF;i++){if($i == "-lgpfs") {print $i} } }'`"
290 if [ "$CURL" != '' -a "$CURL_PATH" = '' ] ; then
291 CURL_PATH="DEFAULT"
293 if [ "$GPFS" != '' -a "$GPFS_PATH" = '' ] ; then
294 GPFS_PATH="DEFAULT"
298 for P in "$HDF5_PATH" "$ZLIB_PATH" "$GPFS_PATH" "$CURL_PATH"
300 if [ "$P" != '' -a "$P" != "DEFAULT" ] ; then
301 if [ "${P#${P%?}}" = "/" ] ; then
302 P=`echo $P | sed 's/\/$//'`
304 DEP_LIB_PATH="`echo $DEP_LIB_PATH | awk -v VAR=-L$P/lib '{for(i=1;i<=NF;i++){if ($i != VAR ) {print $i} } }'`"
305 DEP_LIB_PATH="$DEP_LIB_PATH -L$P/lib"
307 done
308 if [ "${NETCDF#${NETCDF%?}}" = "/" ] ; then
309 NETCDF=`echo $NETCDF | sed 's/\/$//'`
311 buff="`ls -l $NETCDF | sed 's/ */ /g'`"
312 while [ "`echo $buff | grep lib`" = "" -a "`echo $buff | grep '\->'`" != "" ]
314 buff="`echo $buff | sed -e 's/->//' -e 's/ */ /g'`"
315 n=`echo $buff | wc -w`
316 lastword=`echo "$buff" | cut -d' ' -f$n | sed 's/\/$//'`
317 c="`echo $lastword | cut -c1`"
318 if [ "$c" = "/" ] ; then
319 NETCDF=$lastword
320 else
321 c="`echo $lastword | cut -c1-2`"
322 if [ "$c" = "./" ] ; then
323 lastword="echo $lastword | cut -c3-"
325 NETCDF=${NETCDF%/*}/$lastword
327 buff="`ls -l $NETCDF | sed 's/ */ /g'`"
328 done
329 if [ "`echo $NETCDF | grep '..'`" != "" ] ; then
330 buff="`echo $NETCDF | sed -e 's/^\///' -e 's/\// /g'`"
331 n=`echo $buff | wc -w`
333 while [ $i -le $n ]
335 if [ "`echo $buff | cut -d' ' -f$i`" = ".." ] ; then
336 m=$i
338 i=$(( $i + 1 ))
339 done
340 m=$(( $m + 1 ))
341 NETCDF=/"`echo $buff | cut -d' ' -f${m}- | sed 's/ */\//g'`"
343 if [ "${DEP_LIB_PATH#${DEP_LIB_PATH%?}}" = "/" ] ; then
344 DEP_LIB_PATH=`echo $DEP_LIB_PATH | sed 's/\/$//'`
346 DEP_LIB_PATH="`echo $DEP_LIB_PATH | awk -v VAR=-L$NETCDF/lib '{for(i=1;i<=NF;i++){if ($i != VAR ) {print $i} } }'`"
350 if [ -n "$PNETCDF" ] ; then
351 echo "Will use PNETCDF in dir: $PNETCDF"
352 # experimental, so don't tease the user if it is not there
353 #else
354 # echo "Will configure for use without NetCDF"
357 if [ -n "$ADIOS2" ] ; then
358 echo "Will use ADIOS2 in dir: $ADIOS2"
359 else
360 echo "ADIOS2 not set in environment. Will configure WRF for use without."
363 if [ -n "$HDF5" ] ; then
364 echo "Will use HDF5 in dir: $HDF5"
365 else
366 echo "HDF5 not set in environment. Will configure WRF for use without."
369 if [ -n "$PHDF5" ] ; then
370 echo "Will use PHDF5 in dir: $PHDF5"
371 else
372 echo "PHDF5 not set in environment. Will configure WRF for use without."
375 if [ "$wrf_core" = "DA_CORE" -o "$wrf_core" = "4D_DA_CORE" ] ; then
376 if [ -n "$RTTOV" ] ; then
377 echo "Will use RTTOV in dir: $RTTOV"
378 else
379 echo "RTTOV not set in environment. Will configure WRFDA for use without."
383 # Set the "traditional" flag and the "cpp" flags
385 TFL="-traditional-cpp"
386 CFL="-P -nostdinc"
388 if [ "$wrf_core" = "4D_DA_CORE" ]; then
389 if [ -n "$WRFPLUS_DIR" ] ; then
390 echo "Will use WRFPLUS in dir: $WRFPLUS_DIR"
391 else
392 echo "WRFPLUS_DIR not set in environment. Please compile WRFPLUS and set WRFPLUS_DIR."
393 exit
395 else
396 if [ -n "$WRFPLUS_DIR" ] ; then
397 echo 'Unsetting "$WRFPLUS_DIR" environment variable. Use "configure 4dvar" to configure for 4dvar compilation.'
398 unset WRFPLUS_DIR
401 # Users who are cross-compiling can set environment variable
402 # $WRF_OS to override the value normally obtained from `uname`.
403 # If $WRF_OS is set, then $WRF_MACH can also be set to override
404 # the value normally obtained from `uname -m`. If $WRF_OS is
405 # set and $WRF_MACH is not set, then $WRF_MACH defaults to "ARCH".
406 # If $WRF_OS is not set then $WRF_MACH is ignored.
407 if [ -n "$WRF_OS" ] ; then
408 echo "${0}: WRF operating system set to \"${WRF_OS}\" via environment variable \$WRF_OS"
409 os=$WRF_OS
410 mach="ARCH"
411 if [ -n "$WRF_MACH" ] ; then
412 echo "${0}: WRF machine set to \"${WRF_MACH}\" via environment variable \$WRF_MACH"
413 mach=$WRF_MACH
415 else
416 # if the uname command exists, give it a shot and see if
417 # we can narrow the choices; otherwise, spam 'em
418 os="ARCH"
419 mach="ARCH"
420 type uname > /dev/null
421 if [ $? -eq 0 ] ; then
422 os=`uname`
423 if [ "$os" = "AIX" -o "$os" = "IRIX" -o "$os" = "IRIX64" -o "$os" = "SunOS" -o "$os" = "HP-UX" -o "$os" = "Darwin" -o "$os" = "Interix" ] ; then
424 mach="ARCH"
425 else
426 xxx=`expr "$os" : '\(.........\).*'`
427 if [ "$xxx" = "CYGWIN_NT" ] ; then
428 os=$xxx
430 if [ "$os" = "OSF1" -o "$os" = "Linux" -o "$os" = "UNICOS/mp" -o "$os" = "UNIX_System_V" -o "$os" = "CYGWIN_NT" ] ; then
431 mach=`uname -m`
432 if [ "$mach" = "ia64" -a -f /etc/sgi-release ] ; then
433 mach="Altix"
435 else
436 os="ARCH"
437 mach="ARCH"
443 # an IBM specific hack to adjust the bmaxstack and bmaxdata options if addressing is 32-bit
444 if [ "$os" = "AIX" ] ; then
445 if [ -z "$OBJECT_MODE" ] ; then
446 OBJECT_MODE=32
447 export OBJECT_MODE
449 if [ "$OBJECT_MODE" = "32" ] ; then
450 # the bang means nothing to sh in this context; use to represent spaces (perl will unbang)
451 ldflags=-bmaxstack:256000000!-bmaxdata:2048000000
455 # compile options that come from the environment, such as chemistry
456 # the "!" is removed by Config.pl
457 if [ -n "$WRF_HYDRO" ] ; then
458 if [ $WRF_HYDRO = 1 ] ; then
459 echo building WRF-HYDRO
460 compileflags="${compileflags}!-DWRF_HYDRO"
461 echo $compileflags
465 # compile options that come from the environment, such as chemistry
466 # the "!" is removed by Config.pl
467 if [ -n "$WRF_MARS" ] ; then
468 if [ $WRF_MARS = 1 ] ; then
469 echo building WRF for Mars
470 compileflags="${compileflags}!-DPLANET!-DMARS"
471 echo $compileflags
475 if [ -n "$WRF_TITAN" ] ; then
476 if [ $WRF_TITAN = 1 ] ; then
477 echo building WRF for Titan
478 compileflags="${compileflags}!-DPLANET!-DTITAN"
482 if [ -n "$WRF_VENUS" ] ; then
483 if [ $WRF_VENUS = 1 ] ; then
484 echo building WRF for Venus
485 compileflags="${compileflags}!-DPLANET!-DVENUS"
488 if [ -n "$WRF_QUIETLY" ]; then
489 echo WRF_QUIETLY is now a synonym for WRF_LOG_BUFFERING
490 echo setting WRF_LOG_BUFFERING to 1...
491 export WRF_LOG_BUFFERING=1
493 if [ -n "$WRF_LOG_BUFFERING" ]; then
494 if [ $WRF_LOG_BUFFERING = 1 ]; then
495 echo building WRF with support for buffering of log messages
496 compileflags="${compileflags}!-DWRF_LOG_BUFFERING=1"
499 if [ -n "$PNETCDF_QUILT" ]; then
500 echo Enabling quilt_pnc I/O server implementation.
501 compileflags="${compileflags}!-DPNETCDF_QUILT=1"
503 if [ -n "$WRF_DFI_RADAR" ] ; then
504 if [ $WRF_DFI_RADAR = 1 ] ; then
505 echo building WRF with radar dfi option
506 compileflags="${compileflags}!-DWRF_DFI_RADAR=1"
510 if [ -n "$WRF_CMAQ" ] ; then
511 echo building WRF with CMAQ option
512 compileflags="${compileflags}!-DWRF_CMAQ"
515 if [ -n "$WRF_CHEM" ] ; then
516 if [ $WRF_CHEM = 1 ] ; then
517 echo building WRF with chemistry option
518 compileflags="${compileflags}!-DWRF_CHEM!-DBUILD_CHEM=1"
519 if [ -n "$WRF_KPP" ] ; then
520 if [ $WRF_KPP = 1 ] ; then
521 echo building WRF with KPP chemistry option
522 compileflags="${compileflags}!-DWRF_KPP"
525 else
526 compileflags="${compileflags} "
528 else
529 compileflags="${compileflags} "
532 if [ -n "$WRFPLUS" ] ; then
533 if [ $WRFPLUS = 1 ] ; then
534 echo building WRF for TL and AD
535 compileflags="!-DWRFPLUS"
536 echo $compileflags
540 type m4 > /dev/null
541 if [ $? -ne 0 ] ; then
542 echo
543 echo "ERROR ERROR ERROR ERROR ERROR ERROR ERROR"
544 echo "'m4' utility not found! Can not configure."
545 echo
546 echo "If on an Ubuntu machine, use the command"
547 echo " sudo apt-get install m4 "
548 echo "To download and install the 'm4' utility"
549 exit 1
552 if command -v timex > /dev/null 2>&1; then
553 FORTRAN_COMPILER_TIMER=timex
554 echo "Will use 'timex' to report timing information"
555 elif command -v time > /dev/null 2>&1; then
556 FORTRAN_COMPILER_TIMER=time
557 echo "Will use 'time' to report timing information"
560 # Is this some type of WRF DA build? If so, it is real*8.
561 # Let's go ahead and set a flag internally.
562 if test -n "$wrf_core" ; then
563 if [ "$wrf_core" = "DA_CORE" -o \
564 "$wrf_core" = "4D_DA_CORE" -o \
565 "$wrf_core" = "WRF_PLUS_CORE" ] ; then
566 rword="-r8"
570 # Found perl, so proceed with configuration
571 if test -n "$PERL" ; then
572 srch=`grep -i "^#ARCH.*$os" arch/configure.defaults | grep -i "$mach"`
573 if [ -n "$srch" ] ; then
574 $PERL arch/Config.pl -dmparallel=$COMMLIB -ompparallel=$OMP -perl=$PERL \
575 -netcdf=$NETCDF -pnetcdf=$PNETCDF -netcdfpar=$NETCDFPAR -adios2=$ADIOS2 -hdf5=$HDF5 -phdf5=$PHDF5 -os=$os -mach=$mach -ldflags=$ldflags \
576 -compileflags=$compileflags -opt_level=$opt_level -USENETCDFF=$USENETCDFF -USENETCDF=$USENETCDF \
577 -time=$FORTRAN_COMPILER_TIMER -tfl="$TFL" -cfl="$CFL" -config_line="$config_line" \
578 -wrf_core=$wrf_core -gpfs=$GPFS_PATH -curl=$CURL_PATH -dep_lib_path="$DEP_LIB_PATH"
579 if test ! -f configure.wrf ; then
580 echo "configure.wrf not created! Exiting configure script..."
581 exit 1
583 if [ "$opt_level" = "-d" ] ; then
584 sed -e 's/FCOPTIM[ ]*=/& # /' -e '/FCDEBUG[ ]*=/s/#//' configure.wrf > configure.wrf.edit
585 /bin/mv configure.wrf.edit configure.wrf
587 if [ "$opt_level" = "-D" ] ; then
588 sed -e 's/FCOPTIM[ ]*=/& # /' -e '/FCDEBUG[ ]*=/s/#//g' configure.wrf > configure.wrf.edit
589 /bin/mv configure.wrf.edit configure.wrf
592 # GNU has a funny way of doing promotion to real*8
593 if [ "$rword" = "-r8" ] ; then
594 srch=`grep -i "^SFC" configure.wrf | grep -i "gfortran"`
595 if [ -n "$srch" ] ; then
596 sed -e '/^PROMOTION/s/#//' \
597 -e '/^RWORDSIZE/s/$(NATIVE_RWORDSIZE)/8/' configure.wrf > configure.wrf.edit
598 else
599 sed -e '/^RWORDSIZE/s/$(NATIVE_RWORDSIZE)/8/' configure.wrf > configure.wrf.edit
601 /bin/mv configure.wrf.edit configure.wrf
602 sed -e 's/-DBUILD_SBM_FAST=1/-DBUILD_SBM_FAST=0/' configure.wrf > configure.wrf.edit
603 /bin/mv configure.wrf.edit configure.wrf
605 else
606 echo '*********************************************************'
607 echo '*** ERROR ERROR ERROR ERROR ***'
608 echo '*** ***'
609 echo '*** Configuration not found in configure.defaults ***'
610 echo '*********************************************************'
611 exit 2
615 if test -f configure.wrf ; then
616 # new dec 2005. test what fseek is supported (needed for share/landread.c to work correctly)
617 echo testing for fseeko and fseeko64
618 /bin/rm -f tools/fseeko_test tools/fseeko64_test
619 ( make fseek_test 2> /dev/null ) 1> /dev/null
620 if [ "$os" = "Darwin" ] ; then
621 # fseeko64 does not exist under Darwin fseeko does. Remove the 0 length executable
622 # file that might get generated anyway, even though the compiler complains about missing reference.
623 /bin/rm -f tools/fseeko64_test
625 if test -x tools/fseeko64_test ; then
626 ( tools/fseeko64_test 2> /dev/null ) 1> /dev/null
627 if [ $? = 0 ] ; then
628 echo fseeko64 is supported
629 sed '/^CC .*=/s/$/ -DFSEEKO64_OK /' configure.wrf > xx$$ ; /bin/mv xx$$ configure.wrf
631 else
632 if test -x tools/fseeko_test ; then
633 ( tools/fseeko_test 2> /dev/null ) 1> /dev/null
634 if [ $? = 0 ] ; then
635 echo fseeko is supported and handles 64 bit offsets
636 sed '/^CC .*=/s/$/ -DFSEEKO_OK /' configure.wrf > xx$$ ; /bin/mv xx$$ configure.wrf
637 else
638 echo neither fseeko64 nor fseeko with 64 bit offsets works, landread will be compiled with fseek
639 echo but may not work correctly for very high resolution terrain datasets
641 else
642 echo neither fseeko64 nor fseeko with 64 bit offsets works, landread will be compiled with fseek
643 echo but may not work correctly for very high resolution terrain datasets
648 echo "------------------------------------------------------------------------"
649 sed -e '1,/#### Architecture specific settings ####/d' -e '/^externals/,$d' configure.wrf
651 echo "------------------------------------------------------------------------"
652 echo "Settings listed above are written to configure.wrf."
653 echo "If you wish to change settings, please edit that file."
654 echo "If you wish to change the default options, edit the file:"
655 echo " arch/configure.defaults"
657 if test -n "$NETCDF" ; then
658 if [ ! -f $NETCDF/include/netcdf.inc ] ; then
659 echo
660 echo "Error : Not found $NETCDF/include/netcdf.inc"
661 echo " Please check this installation of NetCDF and re-run this configure script"
662 exit -1
664 grep nf_format_64bit $NETCDF/include/netcdf.inc > /dev/null
665 configure_aaaa=$? ; export configure_aaaa
666 if [ $configure_aaaa -a -z "$WRFIO_NCD_NO_LARGE_FILE_SUPPORT" ] ; then
667 echo "NetCDF users note:"
668 echo " This installation of NetCDF supports large file support. To DISABLE large file"
669 echo " support in NetCDF, set the environment variable WRFIO_NCD_NO_LARGE_FILE_SUPPORT"
670 echo " to 1 and run configure again. Set to any other value to avoid this message."
673 echo " "
675 if [ "$wrf_core" = "DA_CORE" -o "$wrf_core" = "WRF_PLUS_CORE" -o "$wrf_core" = "4D_DA_CORE" ]; then
676 if [ "`grep '^SFC' configure.wrf | grep -i 'gfortran'`" != "" -o "`grep '^SFC' configure.wrf | grep -i 'frtpx'`" != "" ]; then
677 echo "WRFDA/WRFPLUS using gfortran/frtpx needs realsize=8"
678 sed -e '/^PROMOTION.*=/s/#//' configure.wrf > configure.wrf.edit
679 /bin/mv configure.wrf.edit configure.wrf
683 if [ -n "$WRFPLUS" ] ; then
684 if [ $WRFPLUS = 1 ] ; then
685 if [ `grep '^SFC' configure.wrf | cut -d= -f2` = "gfortran" ]; then
686 echo "WRFPLUS using gfortran needs realsize=8"
687 sed -e '/^PROMOTION.*=/s/#//' configure.wrf > configure.wrf.edit
688 /bin/mv configure.wrf.edit configure.wrf
693 #Checking cross-compiling capability for some particular environment
694 #on Linux and Mac box
696 if [ $os = "Linux" -o $os = "Darwin" ]; then
698 SFC=`grep '^SFC' configure.wrf | awk '{print $3}'`
699 SCC=`grep '^SCC' configure.wrf | awk '{print $3}'`
700 CCOMP=`grep '^CCOMP' configure.wrf | awk '{print $3}'`
702 SFC="`type $SFC 2>/dev/null | awk '{print $NF}' | sed -e 's/(//g;s/)//g'`"
703 SCC="`type $SCC 2>/dev/null | awk '{print $NF}' | sed -e 's/(//g;s/)//g'`"
704 CCOMP="`type $CCOMP 2>/dev/null | awk '{print $NF}' | sed -e 's/(//g;s/)//g'`"
706 foo=foo_$$
708 grep '^SFC' configure.wrf | grep -i 'gfortran' > /dev/null
709 if [ $? ]
710 then
712 cat > ${foo}.F << EOF
713 PROGRAM GFORTRAN_VERSION_CHECK
714 IF (__GNUC__ .GT. 9) CALL EXIT(1)
715 END PROGRAM
718 gfortran -o ${foo} ${foo}.F > /dev/null 2>&1 && ./${foo}
719 if [ $? -eq 1 ]
720 then
721 sed '/^FCCOMPAT/ s/$/ -fallow-argument-mismatch -fallow-invalid-boz/' configure.wrf > configure.wrf.edit
722 mv configure.wrf.edit configure.wrf
724 rm ${foo} ${foo}.F 2> /dev/null
727 cat > ${foo}.c <<EOF
728 int main(int argc, char ** argv)
730 return (0);
734 cat > ${foo}.f <<EOF
735 program test_exit
736 integer :: STATUS = 0
737 call EXIT(STATUS)
738 end program test_exit
741 # do not do this test for MIC, which cross compiles
742 if [ -z "`grep 'SCC.*mmic' configure.wrf`" ] ; then
743 # Detecting whether if mpi compiler wrapper supports -cc/-f90 options
744 if [ -z "`grep -i -E '^DMPARALLEL[ \t]*=.*#' configure.wrf`" ] ; then
745 mpicc -cc=$SCC -o ${foo} ${foo}.c > /dev/null 2>&1
746 if [ $? != 0 ]; then
747 sed 's/-cc=$(SCC)//' configure.wrf > configure.wrf.edit
748 mv configure.wrf.edit configure.wrf
750 rm ${foo} ${foo}.o 2> /dev/null
751 mpif90 -f90=$SFC -o ${foo} ${foo}.f > /dev/null 2>&1
752 if [ $? != 0 ]; then
753 sed 's/-f90=$(SFC)//' configure.wrf > configure.wrf.edit
754 mv configure.wrf.edit configure.wrf
756 rm ${foo} ${foo}.o 2> /dev/null
760 if [ -e $NETCDF/lib/libnetcdf.a -a "$SFC" != "" -a "$SCC" != "" -a "$CCOMP" != "" ]; then
762 SFC_MULTI_ABI=0
763 SCC_MULTI_ABI=0
764 CCOMP_MULTI_ABI=0
765 CROSS_COMPILING=0
767 echo
768 echo Testing for NetCDF, C and Fortran compiler
769 echo
771 ar p $NETCDF/lib/libnetcdf.a `ar t $NETCDF/lib/libnetcdf.a | grep -E '\.o' | head -n 1 | sed 's/://'` > ${foo}.o
772 netcdf_arch="`file ${foo}.o | grep -o -E '[0-9]{2}-bit|i386'`"
773 rm ${foo}.o
775 $SFC -o ${foo} ${foo}.f > /dev/null 2>&1
776 SFC_arch="`file ${foo} | grep -o -E '[0-9]{2}-bit|i386'`"
777 rm ${foo} ${foo}.o 2> /dev/null
779 $SCC -o ${foo} ${foo}.c > /dev/null 2>&1
780 SCC_arch="`file ${foo} | grep -o -E '[0-9]{2}-bit|i386'`"
781 CCOMP_arch=$SCC_arch
782 rm ${foo} ${foo}.o 2> /dev/null
784 if [ "$SCC" != "$CCOMP" ]; then
785 $CCOMP -o ${foo} ${foo}.c > /dev/null 2>&1
786 CCOMP_arch="`file ${foo} | grep -o -E '[0-9]{2}-bit|i386'`"
787 rm ${foo} ${foo}.o 2> /dev/null
790 if [ "$SFC_arch" = "" -o "$SCC_arch" = "" -o "$CCOMP_arch" = "" ]; then
791 echo " One of compilers testing failed!"
792 echo " Please check your compiler"
793 echo
794 rm -f ${foo} ${foo}.[cfo] 2> /dev/null
795 exit
796 else
797 cp configure.wrf configure.wrf.edit
800 case $netcdf_arch in
802 32-bit|i386 )
804 if [ "$SFC_arch" = "64-bit" ] ; then
805 CROSS_COMPILING=1
806 $SFC -m32 -o ${foo} ${foo}.f > /dev/null 2>&1
807 if [ $? = 0 ]; then
808 SFC_MULTI_ABI=1
809 sed '/^SFC.*=/s/$/ -m32/' configure.wrf.edit > configure.wrf.tmp
810 mv configure.wrf.tmp configure.wrf.edit
813 if [ "$SCC_arch" = "64-bit" ] ; then
814 CROSS_COMPILING=1
815 $SCC -m32 -o ${foo} ${foo}.c > /dev/null 2>&1
816 if [ $? = 0 ]; then
817 SCC_MULTI_ABI=1
818 sed '/^SCC.*=/s/$/ -m32/' configure.wrf.edit > configure.wrf.tmp
819 mv configure.wrf.tmp configure.wrf.edit
823 if [ "$CCOMP_arch" = "64-bit" ] ; then
824 CROSS_COMPILING=1
825 if [ "$CCOMP" != "$SCC" ]; then
826 $CCOMP -m32 -o ${foo} ${foo}.c > /dev/null 2>&1
827 if [ $? = 0 ]; then
828 CCOMP_MULTI_ABI=1
829 sed '/^CCOMP/ s/$/ -m32/' configure.wrf.edit > configure.wrf.tmp
830 mv configure.wrf.tmp configure.wrf.edit
832 else
833 CCOMP_MULTI_ABI=1
834 sed '/^CCOMP/ s/$/ -m32/' configure.wrf.edit > configure.wrf.tmp
835 mv configure.wrf.tmp configure.wrf.edit
839 if [ $CROSS_COMPILING -eq 1 ] ; then
840 echo NOTE:
841 echo This installation of NetCDF is 32-bit
842 if [ \( $SFC_MULTI_ABI -ne 1 -a "$SFC_arch" = "64-bit" \) \
843 -o \( $SCC_MULTI_ABI -ne 1 -a "$SCC_arch" = "64-bit" \) \
844 -o \( $CCOMP_MULTI_ABI -ne 1 -a "$CCOMP_arch" = "64-bit" \) ] ; then
845 rm configure.wrf.edit
846 echo One of compilers is 64-bit and doesn\'t support cross-compiling.
847 echo Please check your NETCDF lib and compiler
848 else
849 echo -m32 is appended to configure.wrf
850 echo It will be forced to build in 32-bit.
851 echo If you don\'t want 32-bit binaries, please use 64-bit NetCDF, and re-run the configure script.
856 64-bit )
858 if [ "$SFC_arch" = "32-bit" -o "$SFC_arch" = "i386" ] ; then
859 CROSS_COMPILING=1
860 $SFC -m64 -o ${foo} ${foo}.f > /dev/null 2>&1
861 if [ $? = 0 ]; then
862 SFC_MULTI_ABI=1
863 sed '/^SFC.*=/s/$/ -m64/' configure.wrf.edit > configure.wrf.tmp
864 mv configure.wrf.tmp configure.wrf.edit
867 if [ "$SCC_arch" = "32-bit" -o "$SCC_arch" = "i386" ] ; then
868 CROSS_COMPILING=1
869 $SCC -m64 -o ${foo} ${foo}.c > /dev/null 2>&1
870 if [ $? = 0 ]; then
871 SCC_MULTI_ABI=1
872 sed '/^SCC.*=/s/$/ -m64/' configure.wrf.edit > configure.wrf.tmp
873 mv configure.wrf.tmp configure.wrf.edit
877 if [ "$CCOMP_arch" = "32-bit" -o "$CCOMP_arch" = "i386" ] ; then
878 CROSS_COMPILING=1
879 if [ "$CCOMP" != "$SCC" ]; then
880 $CCOMP -m64 -o ${foo} ${foo}.c > /dev/null 2>&1
881 if [ $? = 0 ]; then
882 CCOMP_MULTI_ABI=1
883 sed '/^CCOMP/ s/$/ -m64/' configure.wrf.edit > configure.wrf.tmp
884 mv configure.wrf.tmp configure.wrf.edit
886 else
887 CCOMP_MULTI_ABI=1
888 sed '/^CCOMP/ s/$/ -m64/' configure.wrf.edit > configure.wrf.tmp
889 mv configure.wrf.tmp configure.wrf.edit
893 if [ $CROSS_COMPILING -eq 1 ] ; then
894 echo NOTE:
895 echo This installation of NetCDF is 64-bit
896 if [ \( $SFC_MULTI_ABI -ne 1 -a "$SFC_arch" != "64-bit" \) \
897 -o \( $SCC_MULTI_ABI -ne 1 -a "$SCC_arch" != "64-bit" \) \
898 -o \( $CCOMP_MULTI_ABI -ne 1 -a "$CCOMP_arch" != "64-bit" \) ]; then
899 rm configure.wrf.edit
900 echo One of Compilers is 32-bit and doesn\'t support cross-compiling.
901 echo Please check your NetCDF lib and compiler
902 else
903 echo -m64 is appended to configure.wrf
904 echo It will be forced to build in 64-bit.
905 echo If you don\'t want 64-bit binaries, please use 32-bit NetCDF, and re-run the configure script.
909 esac
911 if [ -e configure.wrf.edit ]; then
912 mv configure.wrf.edit configure.wrf
915 if [ $CROSS_COMPILING -eq 0 ] ; then
916 echo "This installation of NetCDF is $netcdf_arch"
917 echo " C compiler is $SCC_arch"
918 echo " Fortran compiler is $SFC_arch"
919 echo " It will build in $netcdf_arch"
920 echo " "
921 if [ -e $NETCDF/bin/nc-config ] ; then
922 echo "NetCDF version: ${ncversion}"
923 echo "Enabled NetCDF-4/HDF-5: `nc-config --has-nc4`"
924 echo "NetCDF built with PnetCDF: `nc-config --has-pnetcdf`"
925 if [ "$USENETCDFPAR" = "1" ] ; then
926 echo "Using parallel NetCDF via NETCDFPAR option"
928 echo " "
931 echo
933 rm -f ${foo} ${foo}.[cfo] 2> /dev/null
936 # testing for Fortran 2003 IEEE features
937 make fortran_2003_ieee_test > tools/fortran_2003_ieee_test.log 2>&1
938 rm -f tools/fortran_2003_ieee_test.log
939 retval=-1
940 if [ -f tools/fortran_2003_ieee_test.exe ] ; then
941 retval=0
943 if [ $retval -ne 0 ] ; then
944 sed -e '/^ARCH_LOCAL/s/$/ -DNO_IEEE_MODULE/' configure.wrf > configure.wrf.edit
945 mv configure.wrf.edit configure.wrf
946 echo " "
947 echo " "
948 echo "************************** W A R N I N G ************************************"
949 echo " "
950 echo "There are some IEEE Fortran 2003 features in WRF that your compiler does not"
951 echo "recognize. The IEEE function calls have been removed."
952 echo " "
953 echo "*****************************************************************************"
956 # testing for Fortran 2003 ISO_C features
957 make fortran_2003_iso_c_test > tools/fortran_2003_iso_c_test.log 2>&1
958 rm -f tools/fortran_2003_iso_c_test.log
959 retval=-1
960 if [ -f tools/fortran_2003_iso_c_test.exe ] ; then
961 retval=0
963 if [ $retval -ne 0 ] ; then
964 sed -e '/^ARCH_LOCAL/s/$/ -DNO_ISO_C_SUPPORT/' configure.wrf > configure.wrf.edit
965 mv configure.wrf.edit configure.wrf
966 echo " "
967 echo " "
968 echo "************************** W A R N I N G ************************************"
969 echo " "
970 echo "There are some Fortran 2003 features in WRF that your compiler does not recognize"
971 echo "The routines that utilize ISO_C support have been stubbed out. "
972 echo "That may not be enough."
973 echo " "
974 echo "*****************************************************************************"
977 # testing for Fortran 2003 FLUSH features
978 make fortran_2003_flush_test > tools/fortran_2003_flush_test.log 2>&1
979 rm -f tools/fortran_2003_flush_test.log
980 retval=-1
981 if [ -f tools/fortran_2003_flush_test.exe ] ; then
982 retval=0
984 if [ $retval -ne 0 ] ; then
985 make fortran_2003_fflush_test > tools/fortran_2003_fflush_test.log 2>&1
986 rm -f tools/fortran_2003_fflush_test.log
987 retval=-1
988 if [ -f tools/fortran_2003_fflush_test.exe ] ; then
989 retval=0
991 if [ $retval -eq 0 ] ; then
992 sed -e '/^ARCH_LOCAL/s/$/ -DUSE_FFLUSH/' configure.wrf > configure.wrf.edit
993 mv configure.wrf.edit configure.wrf
994 echo " "
995 echo " "
996 echo "************************** W A R N I N G ************************************"
997 echo " "
998 echo "There are some Fortran 2003 features in WRF that your compiler does not recognize"
999 echo "The standard FLUSH routine has been replaced by FFLUSH."
1000 echo "That may not be enough."
1001 echo " "
1002 echo "*****************************************************************************"
1004 if [ $retval -ne 0 ] ; then
1005 sed -e '/^ARCH_LOCAL/s/$/ -DNO_FLUSH_SUPPORT/' configure.wrf > configure.wrf.edit
1006 mv configure.wrf.edit configure.wrf
1007 echo " "
1008 echo " "
1009 echo "************************** W A R N I N G ************************************"
1010 echo " "
1011 echo "There are some Fortran 2003 features in WRF that your compiler does not recognize"
1012 echo "The standard FLUSH routine has been stubbed out."
1013 echo "That may not be enough."
1014 echo " "
1015 echo "*****************************************************************************"
1019 # testing for Fortran 2008 intrinsic gamma function
1020 make fortran_2008_gamma_test > tools/fortran_2008_gamma.log 2>&1
1021 rm -f tools/fortran_2008_gamma.log
1022 retval=-1
1023 if [ -f tools/fortran_2008_gamma_test.exe ] ; then
1024 retval=0
1026 if [ $retval -ne 0 ] ; then
1027 sed -e '/^ARCH_LOCAL/s/$/ -DNO_GAMMA_SUPPORT/' configure.wrf > configure.wrf.edit
1028 mv configure.wrf.edit configure.wrf
1029 echo " "
1030 echo " "
1031 echo "************************** W A R N I N G ************************************"
1032 echo " "
1033 echo "There are some Fortran 2008 features in WRF that your compiler does not recognize"
1034 echo "The intrinsic gamma function is not available, required by some schemes."
1035 echo "That code is stubbbed out, and those schemes are unavailable at run-time."
1036 echo " "
1037 echo "*****************************************************************************"
1040 # testing for location of rpc/types.h file, used in landuse
1041 make rpc_test > tools/rpc_test.log 2>&1
1042 rm -f tools/rpc_test.log
1044 if [ -f tools/rpc_test.exe ] ; then
1045 rpc_type=`tools/rpc_test.exe`
1046 if [ $rpc_type == "rpc" ]; then
1047 sed -e '/^CFLAGS_LOCAL/s/#/-DRPC_TYPES=1 &/' configure.wrf > configure.wrf.edit
1048 else
1049 sed -e '/^CFLAGS_LOCAL/s/#/-DRPC_TYPES=2 &/' configure.wrf > configure.wrf.edit
1051 mv configure.wrf.edit configure.wrf
1052 else
1053 echo "************************** W A R N I N G ************************************"
1054 echo " "
1055 echo "The moving nest option is not available due to missing rpc/types.h file."
1056 echo "Copy landread.c.dist to landread.c in share directory to bypass compile error."
1057 echo " "
1058 echo "*****************************************************************************"
1061 # testing for netcdf4 IO features
1062 if [ -n "$NETCDF4" ] ; then
1063 if [ $NETCDF4 -eq 1 ] ; then
1064 make nc4_test > tools/nc4_test.log 2>&1
1065 retval=-1
1066 if [ -f tools/nc4_test.exe ] ; then
1067 retval=0
1068 rm -f tools/nc4_test.log
1070 if [ $retval -ne 0 ] ; then
1071 echo "************************** W A R N I N G ************************************"
1072 echo "NETCDF4 IO features are requested, but this installation of NetCDF "
1073 echo " $NETCDF"
1074 echo "DOES NOT support these IO features. "
1075 echo
1076 echo "Please make sure NETCDF version is 4.1.3 or later and was built with "
1077 echo "--enable-netcdf4 "
1078 echo
1079 echo "OR set NETCDF_classic variable "
1080 echo " bash/ksh : export NETCDF_classic=1 "
1081 echo " csh : setenv NETCDF_classic 1 "
1082 echo
1083 echo "Then re-run this configure script "
1084 echo
1085 echo "!!! configure.wrf has been REMOVED !!!"
1086 echo
1087 echo "*****************************************************************************"
1088 rm -f configure.wrf
1089 else
1090 echo "*****************************************************************************"
1091 echo "This build of WRF will use NETCDF4 with HDF5 compression"
1092 echo "*****************************************************************************"
1093 echo " "
1096 else
1097 echo "*****************************************************************************"
1098 echo "This build of WRF will use classic (non-compressed) NETCDF format"
1099 echo "*****************************************************************************"
1100 echo " "