Merge branch 'master' into jm2/detect2
[wrffire.git] / wrfv2_fire / configure
blob0fb3ce1fe5307a706b7fb7a2f8bf0d550568d883
1 #!/bin/sh
3 # parse argument list
5 thiscmd=$0
7 FORTRAN_COMPILER_TIMER=""
8 opt_level="-f"
9 print_usage=""
10 chemistry=""
11 wrf_core=""
12 while [ $# -ge 1 ]; do
13 case $1 in
14 -d) opt_level="-d" ;;
15 -s) opt_level="-s" ;;
16 -f) opt_level="-f" ;;
17 -h) print_usage="yes" ;;
18 -help) print_usage="yes" ;;
19 -os) shift ; WRF_OS=$1 ;;
20 -mach) shift ; WRF_MACH=$1 ;;
21 -time) shift ; FORTRAN_COMPILER_TIMER=$1 ;;
22 chem) WRF_CHEM=1 ;;
23 kpp) WRF_KPP=1 ;;
24 radardfi) WRF_DFI_RADAR=1 ;;
25 wrfda) wrf_core=DA_CORE ;;
26 4dvar) wrf_core=4D_DA_CORE ;;
27 arw) wrf_core=EM_CORE ;;
28 nmm) wrf_core=NMM_CORE ;;
29 coamps) wrf_core=COAMPS_CORE ;;
30 exp) wrf_core=EXP_CORE ;;
31 titan) WRF_TITAN=1 ; break ;;
32 mars) WRF_MARS=1 ; break ;;
33 venus) WRF_VENUS=1 ; break ;;
34 esac
35 shift
36 done
37 if [ -n "$print_usage" ] ; then
38 echo usage: $thiscmd '[-d|-s|-f|-os os|-mach mach|-time timecommand] [chem] [kpp]'
39 exit
42 if `pwd | grep ' ' > /dev/null ` ; then
43 echo '************************** W A R N I N G ************************************'
44 echo The current working directory has spaces in some components of its path name
45 echo and this may cause problems for your build. This can occur, for example, on
46 echo Windows systems. It is strongly recommended that you install WRF and other
47 echo related software such as NetCDF in directories whose path names contain no
48 echo white space. On Win, for example, create and install in a directory under C:.
49 echo '*****************************************************************************'
53 # lifted from the configure file for mpich; 00/03/10 jm
55 # Check for perl and perl version
56 for p in perl5 perl
58 # Extract the first word of "$p", so it can be a program name with args.
59 set dummy $p; ac_word=$2
60 if test -z "$ac_echo_n" ; then
61 ac_echo_n=yes
62 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
63 # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
64 if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
65 ac_n= ac_c='
66 ' ac_t=' '
67 else
68 ac_n=-n ac_c= ac_t=
70 else
71 ac_n= ac_c='\c' ac_t=
73 ac_echo_test=`echo foo 1>&1`
74 if test -z "$ac_echo_test" ; then
75 print_error "Your sh shell does not handle the output redirection"
76 print_error "1>&1 correctly. Configure will work around this problem,"
77 print_error "but you should report the problem to your vendor."
80 if test -z "$ac_echo_test" -a 1 = 1 ; then
81 echo $ac_n "checking for $ac_word""... $ac_c"
82 else
83 echo $ac_n "checking for $ac_word""... $ac_c" 1>&1
85 ac_prog_where=""
86 if test -n "$PERL"; then
87 ac_pg_PERL="$PERL" # Let the user override the test.
88 else
89 ac_first_char=`expr "$p" : "\(.\)"`
90 if test "$ac_first_char" = "/" -a -x "$p" ; then
91 ac_pg_PERL="$p"
92 ac_prog_where=$p
93 else
94 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
95 for ac_dir in $PATH; do
96 test -z "$ac_dir" && ac_dir=.
97 if test -f $ac_dir/$ac_word; then
98 ac_pg_PERL="$p"
99 ac_prog_where=$ac_dir/$ac_word
100 break
102 done
103 IFS="$ac_save_ifs"
105 fi;PERL="$ac_pg_PERL"
106 if test -n "$ac_prog_where" ; then
107 if test -z "$ac_echo_test" -a 1 = 1 ; then
108 echo "$ac_t""found $ac_prog_where ($PERL)"
109 else
110 echo "$ac_t""found $ac_prog_where ($PERL)" 1>&1
112 PERLFULLPATH=$ac_prog_where
113 else
114 if test -z "$ac_echo_test" -a 1 = 1 ; then
115 echo "$ac_t""no"
116 else
117 echo "$ac_t""no" 1>&1
120 test -n "$PERL" && break
121 done
123 if test -z "$PERL" ; then
124 # We have to set this outside of the loop lest the first failure in
125 # PROGRAM_CHECK set the value (which then terminates the effect of the
126 # loop, since autoconf macros only set values that are null, they
127 # don't override them
128 PERL=""
131 if test -n "$PERL" ; then
132 PERL="$PERL"
134 perlversion=`$PERL -v | grep 'This is perl' | \
135 sed -e 's/^.*v[a-z ]*\([0-9]\).*$/\1/'`
137 # Should do a test first for ch_p4 etc.
138 if test "$perlversion" -lt 5 ; then
139 echo "WRF build requires perl version 5, which configure did not find."
140 echo "You can set the environment variable PERL to contain the "
141 echo "location of perl version 5."
142 echo "Configure believes that $PERL is version $perlversion ."
143 PERL=""
148 # Look for netcdf
149 if test -z "$NETCDF" ; then
150 for p in /usr/local/netcdf
152 if test -d $p ; then
153 NETCDF=$p
154 break
156 done
158 if test -z "$NETCDF" ; then
160 if [ `hostname | cut -c 1-2` = "bs" -o \
161 `hostname | cut -c 1-2` = "bd" -o \
162 `hostname` = "tempest" -o `hostname` = "ute" ] ; then
163 echo 'Compiling on an NCAR system with weird paths to NetCDF'
164 echo 'Setting up a local NetCDF directory with symlinks'
165 if ( test -d ./netcdf_links ) ; then
166 echo 'A directory ./netcdf_links already exists. Continuing.'
167 else
168 mkdir ./netcdf_links
169 if [ -z "$OBJECT_MODE" ] ; then
170 OBJECT_MODE=32
171 export OBJECT_MODE
173 if [ $OBJECT_MODE -ne 64 -a \( `hostname | cut -c 1-2` = "bd" -o `hostname | cut -c 1-2` = "bs" \) ] ; then
174 ( cd ./netcdf_links ; ln -s /usr/local/lib32/r4i4 ./lib ; \
175 ln -s /usr/local/include ./include )
176 else
177 ( cd ./netcdf_links ; ln -s /usr/local/lib64/r4i4 ./lib ; \
178 ln -s /usr/local/include ./include )
181 NETCDF=`pwd`/netcdf_links
182 export NETCDF
185 else
186 bedone=""
187 if [ -d ./netcdf_links ] ; then
188 echo '** There is an existing ./netcdf_links file. Should I use? [y]'
189 read resp
190 if [ "$resp" = "y" ] ; then
191 NETCDF=`pwd`/netcdf_links
192 bedone="yes"
193 else
194 echo 'Removing existing ./netcdf_links directory'
195 /bin/rm -fr ./netcdf_links
197 else
198 echo '** WARNING: No path to NETCDF and environment variable NETCDF not set.'
199 echo '** would you like me to try to fix? [y]'
201 netcdfipath=""
202 netcdflpath=""
203 while [ -z "$bedone" ] ; do
204 read resp
205 if [ "$resp" = "y" -o -z "$resp" ] ; then
206 if [ -d ./netcdf_links ] ; then
207 echo 'There is already a ./netcdf_links directory. Okay to use links'
208 echo 'in this directory for NetCDF include and lib dirs? [y]'
209 read resp
210 if [ "$resp" = "y" ] ; then
211 NETCDF=`pwd`/netcdf_links
212 export NETCDF
213 bedone="yes"
214 continue
217 if [ -z "$netcdfipath" ] ; then
218 echo 'Enter full path to NetCDF include directory on your system'
219 read resp
220 if [ ! -d "$resp" ] ; then
221 echo "invalid path: $resp. Try again? [y]" ; continue
223 netcdfipath=$resp
225 if [ -z "$netcdflpath" ] ; then
226 echo 'Enter full path to NetCDF library directory on your system'
227 read resp
228 if [ ! -d "$resp" ] ; then
229 echo "invalid path: $resp. Try again? [y]" ; continue
231 netcdflpath=$resp
234 if [ -n "$netcdflpath" -a -n "$netcdfipath" ] ; then
235 if [ -d ./netcdf_links ] ; then
236 echo 'Existing ./netcdf_links directory. Okay to remove. [y]'
237 read resp
238 if [ "$resp" = "y" ] ; then
239 /bin/rm -fr ./netcdf_links
242 mkdir ./netcdf_links
243 cd ./netcdf_links
244 ln -s "$netcdfipath" include
245 ln -s "$netcdflpath" lib
246 cd ..
247 echo created new ./netcdf_links directory
248 /bin/ls -lF ./netcdf_links
249 NETCDF=`pwd`/netcdf_links
250 export NETCDF
251 bedone="yes"
253 else
254 bedone="yes"
256 done
260 if test -z "$PDHF5" ; then
261 if [ `hostname | cut -c 1-2` = "bb" -o `hostname | cut -c 1-2` = "bf" -o `hostname | cut -c 1-2` = "bs" -o \
262 `hostname` = "dataproc" -o `hostname` = "ute" ] ; then
263 if [ -d ~michalak/hdf5pbin ] ; then
264 PHDF5=~michalak/hdf5pbin
265 export PHDF5
267 if [ "$OBJECT_MODE" -eq 64 ] ; then
268 if [ -d ~michalak/hdf5pbin-64 ] ; then
269 PHDF5=~michalak/hdf5pbin-64
270 export PHDF5
276 USENETCDFF="" # see below
277 if [ -n "$NETCDF" ] ; then
278 echo "Will use NETCDF in dir: $NETCDF"
279 # for 3.6.2 and greater there might be a second library, libnetcdff.a . Check for this and use
280 # if available
281 if [ -f "$NETCDF/lib/libnetcdff.a" ] ; then
282 USENETCDFF="-lnetcdff"
284 else
285 echo "Will configure for use without NetCDF"
288 if [ -n "$PNETCDF" ] ; then
289 echo "Will use PNETCDF in dir: $PNETCDF"
290 # experimental, so don't tease the user if it is not there
291 #else
292 # echo "Will configure for use without NetCDF"
295 if [ -n "$PHDF5" ] ; then
296 echo "Will use PHDF5 in dir: $PHDF5"
297 else
298 echo "PHDF5 not set in environment. Will configure WRF for use without."
301 if [ "$wrf_core" = "DA_CORE" ]; then
302 if [ -n "$WRFPLUS_DIR" ] ; then
303 unset WRFPLUS_DIR
307 if [ "$wrf_core" = "4D_DA_CORE" ]; then
308 if [ -n "$WRFPLUS_DIR" ] ; then
309 echo "Will use WRFPLUS in dir: $WRFPLUS_DIR"
310 else
311 echo "WRFPLUS_DIR not set in environment. Please compile WRFPLUS and set WRFPLUS_DIR."
312 exit
315 # Users who are cross-compiling can set environment variable
316 # $WRF_OS to override the value normally obtained from `uname`.
317 # If $WRF_OS is set, then $WRF_MACH can also be set to override
318 # the value normally obtained from `uname -m`. If $WRF_OS is
319 # set and $WRF_MACH is not set, then $WRF_MACH defaults to "ARCH".
320 # If $WRF_OS is not set then $WRF_MACH is ignored.
321 if [ -n "$WRF_OS" ] ; then
322 echo "${0}: WRF operating system set to \"${WRF_OS}\" via environment variable \$WRF_OS"
323 os=$WRF_OS
324 mach="ARCH"
325 if [ -n "$WRF_MACH" ] ; then
326 echo "${0}: WRF machine set to \"${WRF_MACH}\" via environment variable \$WRF_MACH"
327 mach=$WRF_MACH
329 else
330 # if the uname command exists, give it a shot and see if
331 # we can narrow the choices; otherwise, spam 'em
332 os="ARCH"
333 mach="ARCH"
334 type uname > /dev/null
335 if [ $? -eq 0 ] ; then
336 os=`uname`
337 if [ "$os" = "AIX" -o "$os" = "IRIX" -o "$os" = "IRIX64" -o "$os" = "SunOS" -o "$os" = "HP-UX" -o "$os" = "Darwin" -o "$os" = "Interix" ] ; then
338 mach="ARCH"
339 else
340 xxx=`expr "$os" : '\(.........\).*'`
341 if [ "$xxx" = "CYGWIN_NT" ] ; then
342 os=$xxx
344 if [ "$os" = "OSF1" -o "$os" = "Linux" -o "$os" = "UNICOS/mp" -o "$os" = "UNIX_System_V" -o "$os" = "CYGWIN_NT" ] ; then
345 mach=`uname -m`
346 if [ "$mach" = "ia64" -a -f /etc/sgi-release ] ; then
347 mach="Altix"
349 else
350 os="ARCH"
351 mach="ARCH"
357 # an IBM specific hack to adjust the bmaxstack and bmaxdata options if addressing is 32-bit
358 if [ "$os" = "AIX" ] ; then
359 if [ -z "$OBJECT_MODE" ] ; then
360 OBJECT_MODE=32
361 export OBJECT_MODE
363 if [ "$OBJECT_MODE" = "32" ] ; then
364 # the bang means nothing to sh in this context; use to represent spaces (perl will unbang)
365 ldflags=-bmaxstack:256000000!-bmaxdata:2048000000
369 # compile options that come from the environment, such as chemistry
370 # the "!" is removed by Config_new.pl
371 if [ -n "$WRF_MARS" ] ; then
372 if [ $WRF_MARS = 1 ] ; then
373 echo building WRF for Mars
374 compileflags="${compileflags}!-DPLANET!-DMARS"
375 echo $compileflags
379 if [ -n "$WRF_TITAN" ] ; then
380 if [ $WRF_TITAN = 1 ] ; then
381 echo building WRF for Mars
382 compileflags="${compileflags}!-DPLANET!-DTITAN"
386 if [ -n "$WRF_VENUS" ] ; then
387 if [ $WRF_VENUS = 1 ] ; then
388 echo building WRF for Mars
389 compileflags="${compileflags}!-DPLANET!-DVENUS"
392 if [ -n "$WRF_NMM_CORE" ]; then
393 if [ $WRF_NMM_CORE = 1 ]; then
394 if [ -n "$HWRF" ]; then
395 if [ $HWRF = 1 ]; then
396 echo building WRF with HWRF option
397 compileflags="${compileflags}!-DHWRF=1"
398 if [ -n "$IDEAL_NMM_TC" ]; then
399 echo building WRF with NMM Idealized Tropical Cyclone option
400 compileflags="${compileflags}!-DIDEAL_NMM_TC=1"
404 if [ -n "$IBM_REDUCE_BUG_WORKAROUND" ]; then
405 if [ $IBM_REDUCE_BUG_WORKAROUND = 1 ]; then
406 echo adding IBM_REDUCE_BUG_WORKAROUND flag for some IBM systems
407 compileflags="${compileflags}!-DIBM_REDUCE_BUG_WORKAROUND"
412 if [ -n "$WRF_DFI_RADAR" ] ; then
413 if [ $WRF_DFI_RADAR = 1 ] ; then
414 echo building WRF with radar dfi option
415 compileflags="${compileflags}!-DWRF_DFI_RADAR=1"
418 if [ -n "$WRF_CHEM" ] ; then
419 if [ $WRF_CHEM = 1 ] ; then
420 echo building WRF with chemistry option
421 compileflags="${compileflags}!-DWRF_CHEM!-DBUILD_CHEM=1"
422 if [ -n "$WRF_KPP" ] ; then
423 if [ $WRF_KPP = 1 ] ; then
424 echo building WRF with KPP chemistry option
425 compileflags="${compileflags}!-DWRF_KPP"
428 else
429 compileflags="${compileflags} "
431 else
432 compileflags="${compileflags} "
435 if [ `which timex 2> /dev/null` ] ; then
436 FORTRAN_COMPILER_TIMER=timex
439 # Found perl, so proceed with configuration
440 if test -n "$PERL" ; then
441 srch=`grep -i "^#ARCH.*$os" arch/configure_new.defaults | grep -i "$mach"`
442 if [ -n "$srch" ] ; then
443 $PERL arch/Config_new.pl -dmparallel=$COMMLIB -ompparallel=$OMP -perl=$PERL \
444 -netcdf=$NETCDF -pnetcdf=$PNETCDF -phdf5=$PHDF5 -os=$os -mach=$mach -ldflags=$ldflags \
445 -compileflags=$compileflags -opt_level=$opt_level -USENETCDFF=$USENETCDFF -time=$FORTRAN_COMPILER_TIMER \
446 -wrf_core=$wrf_core
447 if test ! -f configure.wrf ; then
448 exit 1
450 if [ "$opt_level" = "-d" ] ; then
451 sed -e 's/FCOPTIM[ ]*=/& # /' -e '/FCDEBUG[ ]*=/s/#//g' configure.wrf > configure.wrf.edit
452 /bin/mv configure.wrf.edit configure.wrf
454 else
455 WRF_OS=$os ; export WRF_OS
456 WRF_MACH=$mach ; export WRF_MACH
457 echo '*** Configuration not found in configure_new.defaults; checking configure_old.defaults ***'
459 # see if we still have an old setting laying around from v2
460 if [ "$opt_level" = "-d" ] ; then
461 arch/config_old $opt_level
462 else
463 arch/config_old
469 # new feb 2005. test whether MPI-2
470 if test -f configure.wrf ; then
471 grep 'DMPARALLEL *= *1' configure.wrf > /dev/null
472 if [ $? = 0 ] ; then
473 echo testing for MPI_Comm_f2c and MPI_Comm_c2f
474 /bin/rm -f tools/mpi2_test
475 ( make mpi2_test 2> /dev/null ) 1> /dev/null
476 if test -e tools/mpi2_test.o ; then
477 echo " " MPI_Comm_f2c and MPI_Comm_c2f are supported
478 sed '/^DM_CC.*=/s/$/ -DMPI2_SUPPORT/' configure.wrf > xx$$ ; /bin/mv xx$$ configure.wrf
479 if [ `hostname | cut -c 1-2` = "be" ] ; then
480 sed '/^ARCH_LOCAL.*=/s/$/ -DUSE_MPI_IN_PLACE/' configure.wrf > xx$$ ; /bin/mv xx$$ configure.wrf
482 else
483 echo " " MPI_Comm_f2c and MPI_Comm_c2f are not supported
485 grep 'OMPCPP *= *-D_OPENMP' configure.wrf > /dev/null
486 if [ $? = 0 ] ; then
487 echo testing for MPI_Init_thread
488 /bin/rm -f tools/mpi2_thread_test
489 ( make mpi2_thread_test 2> /dev/null ) 1> /dev/null
490 if test -e tools/mpi2_thread_test.o ; then
491 echo " " MPI_Init_thread is supported
492 sed '/^DM_CC.*=/s/$/ -DMPI2_THREAD_SUPPORT/' configure.wrf > xx$$ ; /bin/mv xx$$ configure.wrf
493 else
494 echo " " MPI_Init_thread is not supported
498 # new dec 2005. test what fseek is supported (needed for share/landread.c to work correctly)
499 echo testing for fseeko and fseeko64
500 /bin/rm -f tools/fseeko_test tools/fseeko64_test
501 ( make fseek_test 2> /dev/null ) 1> /dev/null
502 if [ "$os" = "Darwin" ] ; then
503 # fseeko64 does not exist under Darwin fseeko does. Remove the 0 length executable
504 # file that might get generated anyway, even though the compiler complains about missing reference.
505 /bin/rm -f tools/fseeko64_test
507 if test -x tools/fseeko64_test ; then
508 ( tools/fseeko64_test 2> /dev/null ) 1> /dev/null
509 if [ $? = 0 ] ; then
510 echo fseeko64 is supported
511 sed '/^CC .*=/s/$/ -DFSEEKO64_OK /' configure.wrf > xx$$ ; /bin/mv xx$$ configure.wrf
513 else
514 if test -x tools/fseeko_test ; then
515 ( tools/fseeko_test 2> /dev/null ) 1> /dev/null
516 if [ $? = 0 ] ; then
517 echo fseeko is supported and handles 64 bit offsets
518 sed '/^CC .*=/s/$/ -DFSEEKO_OK /' configure.wrf > xx$$ ; /bin/mv xx$$ configure.wrf
519 else
520 echo neither fseeko64 nor fseeko with 64 bit offsets works, landread will be compiled with fseek
521 echo but may not work correctly for very high resolution terrain datasets
523 else
524 echo neither fseeko64 nor fseeko with 64 bit offsets works, landread will be compiled with fseek
525 echo but may not work correctly for very high resolution terrain datasets
530 echo "------------------------------------------------------------------------"
531 sed -e '1,/#### Architecture specific settings ####/d' -e '/^externals/,$d' configure.wrf
533 echo "------------------------------------------------------------------------"
534 echo "Settings listed above are written to configure.wrf."
535 echo "If you wish to change settings, please edit that file."
536 echo "If you wish to change the default options, edit the file:"
537 echo " arch/configure_new.defaults"
539 if test -n "$NETCDF" ; then
540 grep nf_format_64bit $NETCDF/include/netcdf.inc > /dev/null
541 configure_aaaa=$? ; export configure_aaaa
542 if [ $configure_aaaa -a -z "$WRFIO_NCD_LARGE_FILE_SUPPORT" ] ; then
543 echo "NetCDF users note:"
544 echo " This installation of NetCDF supports large file support. To enable large file"
545 echo " support in NetCDF, set the environment variable WRFIO_NCD_LARGE_FILE_SUPPORT"
546 echo " to 1 and run configure again. Set to any other value to avoid this message."
548 if test -f $NETCDF/bin/nc-config ; then
549 if test -z "$WRFIO_NETCDF4_LINKOPTS" ; then
550 WRFIO_NETCDF_LINKOPTS=`$NETCDF/bin/nc-config --flibs`
551 echo "WRFIO_NETCDF_LINKOPTS=$WRFIO_NETCDF_LINKOPTS" >> configure.wrf
555 echo " "
557 if [ "$wrf_core" = "DA_CORE" -o "$wrf_core" = "4D_DA_CORE" ]; then
558 if [ "`grep '^SFC' configure.wrf | grep -i 'gfortran'`" != "" ]; then
559 echo "WRFDA using gfortran needs realsize=8"
560 sed -e '/^PROMOTION.*=/s/#//' configure.wrf > configure.wrf.edit
561 /bin/mv configure.wrf.edit configure.wrf
565 #Checking cross-compiling capability for some particular environment
566 #on Linux and Mac box
568 if [ $os = "Linux" -o $os = "Darwin" ]; then
570 SFC=`grep '^SFC' configure.wrf | awk '{print $3}'`
571 SCC=`grep '^SCC' configure.wrf | awk '{print $3}'`
572 CCOMP=`grep '^CCOMP' configure.wrf | awk '{print $3}'`
574 SFC="`type $SFC 2>/dev/null | awk '{print $NF}' | sed -e 's/(//g;s/)//g'`"
575 SCC="`type $SCC 2>/dev/null | awk '{print $NF}' | sed -e 's/(//g;s/)//g'`"
576 CCOMP="`type $CCOMP 2>/dev/null | awk '{print $NF}' | sed -e 's/(//g;s/)//g'`"
578 foo=foo_$$
580 cat > ${foo}.c <<EOF
581 int main(int argc, char ** argv)
583 return (0);
587 cat > ${foo}.f <<EOF
588 program test_exit
589 integer :: STATUS = 0
590 call EXIT(STATUS)
591 end program test_exit
594 # Detecting whether if mpi compiler wrapper supports -cc/-f90 options
595 if [ "`grep -i -E '^DMPARALLEL[ \t]*=.*#' configure.wrf`" = "" ]; then
596 mpicc -cc=$SCC -o ${foo} ${foo}.c > /dev/null 2>&1
597 if [ $? != 0 ]; then
598 sed 's/-cc=$(SCC)//' configure.wrf > configure.wrf.edit
599 mv configure.wrf.edit configure.wrf
601 rm ${foo} ${foo}.o 2> /dev/null
602 mpif90 -f90=$SFC -o ${foo} ${foo}.f > /dev/null 2>&1
603 if [ $? != 0 ]; then
604 sed 's/-f90=$(SFC)//' configure.wrf > configure.wrf.edit
605 mv configure.wrf.edit configure.wrf
607 rm ${foo} ${foo}.o 2> /dev/null
610 if [ -e $NETCDF/lib/libnetcdf.a -a "$SFC" != "" -a "$SCC" != "" -a "$CCOMP" != "" ]; then
612 SFC_MULTI_ABI=0
613 SCC_MULTI_ABI=0
614 CCOMP_MULTI_ABI=0
615 CROSS_COMPILING=0
617 echo
618 echo Testing for NetCDF, C and Fortran compiler
619 echo
621 ar p $NETCDF/lib/libnetcdf.a `ar t $NETCDF/lib/libnetcdf.a | grep -E '*\.o' | head -n 1 | sed 's/://'` > ${foo}.o
622 netcdf_arch="`file ${foo}.o | grep -o -E '[0-9]{2}-bit|i386'`"
623 rm ${foo}.o
625 $SFC -o ${foo} ${foo}.f > /dev/null 2>&1
626 SFC_arch="`file ${foo} | grep -o -E '[0-9]{2}-bit|i386'`"
627 rm ${foo} ${foo}.o 2> /dev/null
629 $SCC -o ${foo} ${foo}.c > /dev/null 2>&1
630 SCC_arch="`file ${foo} | grep -o -E '[0-9]{2}-bit|i386'`"
631 CCOMP_arch=$SCC_arch
632 rm ${foo} ${foo}.o 2> /dev/null
634 if [ "$SCC" != "$CCOMP" ]; then
635 $CCOMP -o ${foo} ${foo}.c > /dev/null 2>&1
636 CCOMP_arch="`file ${foo} | grep -o -E '[0-9]{2}-bit|i386'`"
637 rm ${foo} ${foo}.o 2> /dev/null
640 if [ "$SFC_arch" = "" -o "$SCC_arch" = "" -o "$CCOMP_arch" = "" ]; then
641 echo " One of compilers testing failed!"
642 echo " Please check your compiler"
643 echo
644 rm -f ${foo} ${foo}.[cfo] 2> /dev/null
645 exit
646 else
647 cp configure.wrf configure.wrf.edit
650 case $netcdf_arch in
652 32-bit|i386 )
654 if [ "$SFC_arch" = "64-bit" ] ; then
655 CROSS_COMPILING=1
656 $SFC -m32 -o ${foo} ${foo}.f > /dev/null 2>&1
657 if [ $? = 0 ]; then
658 SFC_MULTI_ABI=1
659 sed '/^SFC.*=/s/$/ -m32/' configure.wrf.edit > configure.wrf.tmp
660 mv configure.wrf.tmp configure.wrf.edit
663 if [ "$SCC_arch" = "64-bit" ] ; then
664 CROSS_COMPILING=1
665 $SCC -m32 -o ${foo} ${foo}.c > /dev/null 2>&1
666 if [ $? = 0 ]; then
667 SCC_MULTI_ABI=1
668 sed '/^SCC.*=/s/$/ -m32/' configure.wrf.edit > configure.wrf.tmp
669 mv configure.wrf.tmp configure.wrf.edit
673 if [ "$CCOMP_arch" = "64-bit" ] ; then
674 CROSS_COMPILING=1
675 if [ "$CCOMP" != "$SCC" ]; then
676 $CCOMP -m32 -o ${foo} ${foo}.c > /dev/null 2>&1
677 if [ $? = 0 ]; then
678 CCOMP_MULTI_ABI=1
679 sed '/^CCOMP/ s/$/ -m32/' configure.wrf.edit > configure.wrf.tmp
680 mv configure.wrf.tmp configure.wrf.edit
682 else
683 CCOMP_MULTI_ABI=1
684 sed '/^CCOMP/ s/$/ -m32/' configure.wrf.edit > configure.wrf.tmp
685 mv configure.wrf.tmp configure.wrf.edit
689 if [ $CROSS_COMPILING -eq 1 ] ; then
690 echo NOTE:
691 echo This installation NetCDF is 32-bit
692 if [ \( $SFC_MULTI_ABI -ne 1 -a "$SFC_arch" = "64-bit" \) \
693 -o \( $SCC_MULTI_ABI -ne 1 -a "$SCC_arch" = "64-bit" \) \
694 -o \( $CCOMP_MULTI_ABI -ne 1 -a "$CCOMP_arch" = "64-bit" \) ] ; then
695 rm configure.wrf.edit
696 echo One of compilers is 64-bit and doesn\'t support cross-compiling.
697 echo Please check your NETCDF lib and compiler
698 else
699 echo -m32 is appended to configure.wrf
700 echo It will be forced to build in 32-bit.
701 echo If you don\'t want 32-bit binaries, please use 64-bit NetCDF, and re-run the configure script.
706 64-bit )
708 if [ "$SFC_arch" = "32-bit" -o "$SFC_arch" = "i386" ] ; then
709 CROSS_COMPILING=1
710 $SFC -m64 -o ${foo} ${foo}.f > /dev/null 2>&1
711 if [ $? = 0 ]; then
712 SFC_MULTI_ABI=1
713 sed '/^SFC.*=/s/$/ -m64/' configure.wrf.edit > configure.wrf.tmp
714 mv configure.wrf.tmp configure.wrf.edit
717 if [ "$SCC_arch" = "32-bit" -o "$SCC_arch" = "i386" ] ; then
718 CROSS_COMPILING=1
719 $SCC -m64 -o ${foo} ${foo}.c > /dev/null 2>&1
720 if [ $? = 0 ]; then
721 SCC_MULTI_ABI=1
722 sed '/^SCC.*=/s/$/ -m64/' configure.wrf.edit > configure.wrf.tmp
723 mv configure.wrf.tmp configure.wrf.edit
727 if [ "$CCOMP_arch" = "32-bit" -o "$CCOMP_arch" = "i386" ] ; then
728 CROSS_COMPILING=1
729 if [ "$CCOMP" != "$SCC" ]; then
730 $CCOMP -m64 -o ${foo} ${foo}.c > /dev/null 2>&1
731 if [ $? = 0 ]; then
732 CCOMP_MULTI_ABI=1
733 sed '/^CCOMP/ s/$/ -m64/' configure.wrf.edit > configure.wrf.tmp
734 mv configure.wrf.tmp configure.wrf.edit
736 else
737 CCOMP_MULTI_ABI=1
738 sed '/^CCOMP/ s/$/ -m64/' configure.wrf.edit > configure.wrf.tmp
739 mv configure.wrf.tmp configure.wrf.edit
743 if [ $CROSS_COMPILING -eq 1 ] ; then
744 echo NOTE:
745 echo This installation NetCDF is 64-bit
746 if [ \( $SFC_MULTI_ABI -ne 1 -a "$SFC_arch" != "64-bit" \) \
747 -o \( $SCC_MULTI_ABI -ne 1 -a "$SCC_arch" != "64-bit" \) \
748 -o \( $CCOMP_MULTI_ABI -ne 1 -a "$CCOMP_arch" != "64-bit" \) ]; then
749 rm configure.wrf.edit
750 echo One of Compilers is 32-bit and doesn\'t support cross-compiling.
751 echo Please check your NetCDF lib and compiler
752 else
753 echo -m64 is appended to configure.wrf
754 echo It will be forced to build in 64-bit.
755 echo If you don\'t want 64-bit binaries, please use 32-bit NetCDF, and re-run the configure script.
759 esac
761 if [ -e configure.wrf.edit ]; then
762 mv configure.wrf.edit configure.wrf
765 if [ $CROSS_COMPILING -eq 0 ] ; then
766 echo This installation NetCDF is $netcdf_arch
767 echo C compiler is $SCC_arch
768 echo Fortran compiler is $SFC_arch
769 echo It will build in $netcdf_arch
771 echo
773 rm -f ${foo} ${foo}.[cfo] 2> /dev/null