source: lmdz_wrf/trunk/WRFV3/configure @ 2295

Last change on this file since 2295 was 1, checked in by lfita, 10 years ago
  • -- --- Opening of the WRF+LMDZ coupling repository --- -- -

WRF: version v3.3
LMDZ: version v1818

More details in:

  • Property svn:executable set to *
File size: 24.0 KB
Line 
1#!/bin/sh
2
3# parse argument list
4
5thiscmd=$0
6
7FORTRAN_COMPILER_TIMER=""
8opt_level="-f"
9print_usage=""
10chemistry=""
11wrf_core=""
12while [ $# -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
36done
37if [ -n "$print_usage" ] ; then
38  echo usage: $thiscmd '[-d|-s|-f|-os os|-mach mach|-time timecommand] [chem] [kpp]'
39  exit 
40fi
41
42if `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 '*****************************************************************************'
50fi
51
52
53# lifted from the configure file for mpich; 00/03/10 jm
54#
55# Check for perl and perl version
56for p in perl5 perl
57do
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=
69      fi
70    else
71      ac_n= ac_c='\c' ac_t=
72    fi
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."
78    fi
79  fi
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
84  fi
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
101          fi
102        done
103        IFS="$ac_save_ifs"
104    fi
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
111    fi
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
118    fi
119  fi
120  test -n "$PERL" && break
121done
122
123if 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=""
129fi
130
131if test -n "$PERL" ; then
132    PERL="$PERL"
133   
134    perlversion=`$PERL -v | grep 'This is perl' | \
135       sed -e 's/^.*v[a-z ]*\([0-9]\).*$/\1/'`
136
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=""
144    fi
145   
146fi
147
148# Look for netcdf
149if test -z "$NETCDF" ; then
150  for p in /usr/local/netcdf
151  do
152    if test -d $p ; then
153      NETCDF=$p
154      break
155    fi
156  done
157fi
158if  test -z "$NETCDF"  ; then
159 
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
172      fi
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 )
179      fi
180    fi
181    NETCDF=`pwd`/netcdf_links
182    export NETCDF
183
184
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
196      fi
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]'
200    fi
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
215          fi
216        fi
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
222          fi
223          netcdfipath=$resp
224        fi
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
230          fi
231          netcdflpath=$resp
232        fi
233
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
240            fi
241          fi
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"
252        fi
253      else
254        bedone="yes"
255      fi
256    done
257  fi
258fi
259
260if 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
266      fi
267      if [ "$OBJECT_MODE" -eq 64 ] ; then
268            if [ -d ~michalak/hdf5pbin-64 ] ; then
269              PHDF5=~michalak/hdf5pbin-64
270              export PHDF5
271            fi
272      fi
273  fi
274fi
275
276USENETCDFF=""  # see below
277if [ -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"
283  fi
284else
285  echo "Will configure for use without NetCDF"
286fi
287
288if [ -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"
293fi
294
295if [ -n "$PHDF5" ] ; then
296  echo "Will use PHDF5 in dir: $PHDF5"
297else
298  echo "PHDF5 not set in environment. Will configure WRF for use without."
299fi
300
301if [ "$wrf_core" = "DA_CORE" ]; then
302   if [ -n "$WRFPLUS_DIR" ] ; then
303      echo "To compile WRFDA without 4DVAR, please remove \$WRFPLUS_DIR from environment. "
304      exit
305   fi
306fi
307
308if [ "$wrf_core" = "4D_DA_CORE" ]; then
309   if [ -n "$WRFPLUS_DIR" ] ; then
310      echo "Will use WRFPLUS in dir: $WRFPLUS_DIR"
311   else
312      echo "WRFPLUS_DIR not set in environment. Please compile WRFPLUS and set WRFPLUS_DIR."
313      exit
314   fi
315fi
316# Users who are cross-compiling can set environment variable
317# $WRF_OS to override the value normally obtained from `uname`. 
318# If $WRF_OS is set, then $WRF_MACH can also be set to override
319# the value normally obtained from `uname -m`.  If $WRF_OS is
320# set and $WRF_MACH is not set, then $WRF_MACH defaults to "ARCH". 
321# If $WRF_OS is not set then $WRF_MACH is ignored. 
322if [ -n "$WRF_OS" ] ; then
323  echo "${0}:  WRF operating system set to \"${WRF_OS}\" via environment variable \$WRF_OS"
324  os=$WRF_OS
325  mach="ARCH"
326  if [ -n "$WRF_MACH" ] ; then
327    echo "${0}:  WRF machine set to \"${WRF_MACH}\" via environment variable \$WRF_MACH"
328    mach=$WRF_MACH
329  fi
330else
331  # if the uname command exists, give it a shot and see if
332  # we can narrow the choices; otherwise, spam 'em
333  os="ARCH"
334  mach="ARCH"
335  type uname > /dev/null
336  if [ $? -eq 0 ] ; then
337    os=`uname`
338    if [ "$os" = "AIX" -o "$os" = "IRIX" -o "$os" = "IRIX64" -o "$os" = "SunOS" -o "$os" = "HP-UX"  -o "$os" = "Darwin" -o "$os" = "Interix" ] ; then
339      mach="ARCH"
340    else
341      xxx=`expr "$os" : '\(.........\).*'`
342      if [ "$xxx"  = "CYGWIN_NT" ] ; then
343        os=$xxx
344      fi
345      if [ "$os" = "OSF1" -o "$os" = "Linux" -o "$os" = "UNICOS/mp" -o "$os" = "UNIX_System_V" -o  "$os" = "CYGWIN_NT" ] ; then
346        mach=`uname -m`
347        if [ "$mach" = "ia64" -a -f /etc/sgi-release ] ; then
348          mach="Altix"
349        fi
350      else
351        os="ARCH"
352        mach="ARCH"
353      fi
354    fi
355  fi
356fi
357
358# an IBM specific hack to adjust the bmaxstack and bmaxdata options if addressing is 32-bit
359if [ "$os" = "AIX" ] ; then
360      if [ -z "$OBJECT_MODE" ] ; then
361         OBJECT_MODE=32
362         export OBJECT_MODE
363      fi
364      if [ "$OBJECT_MODE" = "32" ] ; then
365# the bang means nothing to sh in this context; use to represent spaces (perl will unbang)
366         ldflags=-bmaxstack:256000000!-bmaxdata:2048000000
367      fi
368fi
369
370# compile options that come from the environment, such as chemistry
371# the "!" is removed by Config_new.pl
372if [ -n "$WRF_MARS" ] ; then
373  if [ $WRF_MARS = 1 ] ; then
374    echo building WRF for Mars
375    compileflags="${compileflags}!-DPLANET!-DMARS"
376    echo $compileflags
377  fi
378fi
379
380if [ -n "$WRF_TITAN" ] ; then
381  if [ $WRF_TITAN = 1 ] ; then
382    echo building WRF for Mars
383    compileflags="${compileflags}!-DPLANET!-DTITAN"
384  fi
385fi
386
387if [ -n "$WRF_VENUS" ] ; then
388  if [ $WRF_VENUS = 1 ] ; then
389    echo building WRF for Mars
390    compileflags="${compileflags}!-DPLANET!-DVENUS"
391  fi
392fi
393if [ -n "$WRF_NMM_CORE" ]; then
394  if [ $WRF_NMM_CORE = 1 ]; then
395    if [ -n "$HWRF" ]; then
396      if [ $HWRF = 1 ]; then
397        echo building WRF with HWRF option
398        compileflags="${compileflags}!-DHWRF=1"
399        if [ -n "$HWRFX" ]; then
400          if [ $HWRFX = 1 ]; then
401            compileflags="${compileflags}!-DHWRFX=1"
402          fi
403        fi
404      fi
405    fi
406  fi
407fi
408if [ -n "$WRF_DFI_RADAR" ] ; then
409  if [ $WRF_DFI_RADAR = 1 ] ; then
410    echo building WRF with radar dfi option
411    compileflags="${compileflags}!-DWRF_DFI_RADAR=1"
412  fi
413fi
414if [ -n "$WRF_CHEM" ] ; then
415  if [ $WRF_CHEM = 1 ] ; then
416    echo building WRF with chemistry option
417    compileflags="${compileflags}!-DWRF_CHEM!-DBUILD_CHEM=1"
418    if [ -n "$WRF_KPP" ] ; then
419      if [ $WRF_KPP = 1 ] ; then   
420        echo building WRF with KPP chemistry option
421        compileflags="${compileflags}!-DWRF_KPP"
422      fi
423    fi 
424  else
425    compileflags="${compileflags} "
426  fi
427else
428  compileflags="${compileflags} "
429fi
430
431if [ `which timex` ] ; then
432  FORTRAN_COMPILER_TIMER=timex
433fi
434
435# Found perl, so proceed with configuration
436if test -n "$PERL" ; then
437   srch=`grep -i "^#ARCH.*$os" arch/configure_new.defaults | grep -i "$mach"`
438   if [ -n "$srch" ] ; then
439     $PERL arch/Config_new.pl -dmparallel=$COMMLIB -ompparallel=$OMP -perl=$PERL \
440          -netcdf=$NETCDF -pnetcdf=$PNETCDF -phdf5=$PHDF5 -os=$os -mach=$mach -ldflags=$ldflags \
441          -compileflags=$compileflags -opt_level=$opt_level -USENETCDFF=$USENETCDFF -time=$FORTRAN_COMPILER_TIMER \
442          -wrf_core=$wrf_core
443     if test ! -f configure.wrf ; then
444       exit 1
445     fi
446     if [ "$opt_level" = "-d" ] ; then
447        sed -e 's/FCOPTIM[       ]*=/& # /' -e '/FCDEBUG[        ]*=/s/#//g' configure.wrf > configure.wrf.edit
448        /bin/mv configure.wrf.edit configure.wrf
449     fi
450   else
451     WRF_OS=$os ; export WRF_OS
452     WRF_MACH=$mach ; export WRF_MACH
453     echo '*** Configuration not found in configure_new.defaults; checking configure_old.defaults ***'
454
455     # see if we still have an old setting laying around from v2
456     if [ "$opt_level" = "-d" ] ; then
457       arch/config_old $opt_level 
458     else
459       arch/config_old
460     fi
461
462   fi
463fi
464
465# new feb 2005.  test whether MPI-2
466if test -f configure.wrf ; then
467  grep 'DMPARALLEL *= *1' configure.wrf > /dev/null
468  if [ $? = 0 ] ; then
469    echo testing for MPI_Comm_f2c and MPI_Comm_c2f
470    /bin/rm -f tools/mpi2_test
471    ( make mpi2_test 2> /dev/null ) 1> /dev/null
472    if test -e tools/mpi2_test.o ; then
473      echo "  " MPI_Comm_f2c and MPI_Comm_c2f are supported
474      sed '/^DM_CC.*=/s/$/ -DMPI2_SUPPORT/' configure.wrf > xx$$ ; /bin/mv xx$$ configure.wrf
475      if [ `hostname | cut -c 1-2` = "be" ] ; then
476         sed '/^ARCH_LOCAL.*=/s/$/ -DUSE_MPI_IN_PLACE/' configure.wrf > xx$$ ; /bin/mv xx$$ configure.wrf
477      fi
478    else
479      echo "  " MPI_Comm_f2c and MPI_Comm_c2f are not supported
480    fi
481    grep 'OMPCPP *= *-D_OPENMP' configure.wrf > /dev/null
482    if [ $? = 0 ] ; then
483      echo testing for MPI_Init_thread
484      /bin/rm -f tools/mpi2_thread_test
485      ( make mpi2_thread_test 2> /dev/null ) 1> /dev/null
486      if test -e tools/mpi2_thread_test.o ; then
487        echo "  " MPI_Init_thread is supported
488        sed '/^DM_CC.*=/s/$/ -DMPI2_THREAD_SUPPORT/' configure.wrf > xx$$ ; /bin/mv xx$$ configure.wrf
489      else 
490        echo "  " MPI_Init_thread is not supported
491      fi
492    fi
493  fi
494# new dec 2005.  test what fseek is supported (needed for share/landread.c to work correctly)
495  echo testing for fseeko and fseeko64
496  /bin/rm -f tools/fseeko_test tools/fseeko64_test
497  ( make fseek_test 2> /dev/null ) 1> /dev/null
498  if [ "$os" = "Darwin" ] ; then
499    # fseeko64 does not exist under Darwin fseeko does. Remove the 0 length executable
500    # file that might get generated anyway, even though the compiler complains about missing reference.
501    /bin/rm -f tools/fseeko64_test
502  fi
503  if test -x tools/fseeko64_test ; then
504    ( tools/fseeko64_test 2> /dev/null ) 1> /dev/null
505    if [ $? = 0 ] ; then
506       echo fseeko64 is supported
507       sed '/^CC .*=/s/$/ -DFSEEKO64_OK /' configure.wrf > xx$$ ; /bin/mv xx$$ configure.wrf
508    fi
509  else
510    if test -x tools/fseeko_test ; then
511      ( tools/fseeko_test 2> /dev/null ) 1> /dev/null
512      if [ $? = 0 ] ; then
513        echo fseeko is supported and handles 64 bit offsets
514        sed '/^CC .*=/s/$/ -DFSEEKO_OK /' configure.wrf > xx$$ ; /bin/mv xx$$ configure.wrf
515      else
516        echo neither fseeko64 nor fseeko with 64 bit offsets works, landread will be compiled with fseek
517        echo but may not work correctly for very high resolution terrain datasets
518      fi
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
522    fi
523  fi
524fi
525
526echo "------------------------------------------------------------------------"
527sed -e '1,/#### Architecture specific settings ####/d' -e '/^externals/,$d' configure.wrf
528
529echo "------------------------------------------------------------------------"
530echo "Settings listed above are written to configure.wrf."
531echo "If you wish to change settings, please edit that file."
532echo "If you wish to change the default options, edit the file:"
533echo "     arch/configure_new.defaults"
534
535if test -n $NETCDF ; then
536  grep nf_format_64bit $NETCDF/include/netcdf.inc > /dev/null
537  configure_aaaa=$? ; export configure_aaaa
538  if [ $configure_aaaa -a -z "$WRFIO_NCD_LARGE_FILE_SUPPORT" ] ; then
539    echo "NetCDF users note:"
540    echo " This installation of NetCDF supports large file support.  To enable large file" 
541    echo " support in NetCDF, set the environment variable WRFIO_NCD_LARGE_FILE_SUPPORT"
542    echo " to 1 and run configure again. Set to any other value to avoid this message."
543  fi
544fi
545echo "  "
546
547if [ "$wrf_core" = "DA_CORE" ]; then
548  if [ "`grep '^SFC' configure.wrf | grep -i 'gfortran'`" != "" ]; then
549    echo "WRFDA using gfortran needs realsize=8"
550    sed -e '/^PROMOTION.*=/s/#//' configure.wrf > configure.wrf.edit
551    /bin/mv configure.wrf.edit configure.wrf
552  fi
553fi
554
555#Checking cross-compiling capability for some particular environment
556#on Linux and Mac box
557
558if [ $os = "Linux" -o $os = "Darwin" ]; then
559
560  SFC=`grep '^SFC' configure.wrf | awk '{print $3}'`
561  SCC=`grep '^SCC' configure.wrf | awk '{print $3}'`
562  CCOMP=`grep '^CCOMP' configure.wrf | awk '{print $3}'`
563
564  SFC="`type $SFC 2>/dev/null | awk '{print $NF}' | sed -e 's/(//g;s/)//g'`"
565  SCC="`type $SCC 2>/dev/null | awk '{print $NF}' | sed -e 's/(//g;s/)//g'`"
566  CCOMP="`type $CCOMP 2>/dev/null | awk '{print $NF}' | sed -e 's/(//g;s/)//g'`"
567
568  if [ -e $NETCDF/lib/libnetcdf.a -a "$SFC" != "" -a "$SCC" != "" -a "$CCOMP" != "" ]; then
569
570    SFC_MULTI_ABI=0
571    SCC_MULTI_ABI=0
572    CCOMP_MULTI_ABI=0
573    CROSS_COMPILING=0
574
575    foo=`mktemp foo_$$`
576
577    echo
578    echo Testing for NetCDF, C and Fortran compiler
579    echo
580
581cat > ${foo}.c <<EOF
582 int main(int argc, char ** argv)
583 {
584     return (0);
585 }
586EOF
587
588cat > ${foo}.f <<EOF
589          program test_exit
590            integer :: STATUS = 0
591            call EXIT(STATUS)
592          end program test_exit
593EOF
594
595    ar p $NETCDF/lib/libnetcdf.a netcdf.o > ${foo}.o
596    netcdf_arch="`file ${foo}.o | grep -o -E '[0-9]{2}-bit|i386'`"
597    rm ${foo}.o
598
599    $SFC -o ${foo} ${foo}.f > /dev/null 2>&1 
600    SFC_arch="`file ${foo} | grep -o -E '[0-9]{2}-bit|i386'`"
601    rm ${foo} 2> /dev/null
602
603    $SCC -o ${foo} ${foo}.c > /dev/null 2>&1
604    SCC_arch="`file ${foo} | grep -o -E '[0-9]{2}-bit|i386'`"
605    CCOMP_arch=$SCC_arch
606    rm ${foo} 2> /dev/null
607
608    if [ "$SCC" != "$CCOMP" ]; then
609      $CCOMP -o ${foo} ${foo}.c > /dev/null 2>&1
610      CCOMP_arch="`file ${foo} | grep -o -E '[0-9]{2}-bit|i386'`"
611      rm ${foo} 2> /dev/null
612    fi
613
614    if [ "$SFC_arch" = "" -o "$SCC_arch" = "" -o "$CCOMP_arch" = "" ]; then
615      echo "  One of compilers testing failed!"
616      echo "  Please check your compiler"
617      echo 
618      rm ${foo}* 2> /dev/null
619      exit
620    else
621      cp configure.wrf configure.wrf.edit
622    fi
623
624    case $netcdf_arch in
625
626      32-bit|i386 )
627
628      if [ "$SFC_arch" = "64-bit" ] ; then
629        CROSS_COMPILING=1
630        $SFC -m32 -o ${foo} ${foo}.f > /dev/null 2>&1
631        if [ $? = 0 ]; then
632          SFC_MULTI_ABI=1
633          sed '/^SFC.*=/s/$/ -m32/' configure.wrf.edit > configure.wrf.tmp
634          mv configure.wrf.tmp configure.wrf.edit
635        fi
636      fi
637      if [ "$SCC_arch" = "64-bit" ] ; then
638        CROSS_COMPILING=1
639        $SCC -m32 -o ${foo} ${foo}.c > /dev/null 2>&1
640        if [ $? = 0 ]; then
641          SCC_MULTI_ABI=1
642          sed '/^SCC.*=/s/$/ -m32/' configure.wrf.edit > configure.wrf.tmp
643          mv configure.wrf.tmp  configure.wrf.edit
644        fi
645      fi
646
647      if [ "$CCOMP_arch" = "64-bit" ] ; then
648        CROSS_COMPILING=1
649        if [ "$CCOMP" != "$SCC" ]; then
650          $CCOMP -m32 -o ${foo} ${foo}.c > /dev/null 2>&1
651          if [ $? = 0 ]; then
652            CCOMP_MULTI_ABI=1
653            sed '/^CCOMP/ s/$/ -m32/' configure.wrf.edit > configure.wrf.tmp
654            mv configure.wrf.tmp  configure.wrf.edit
655          fi
656        else
657          CCOMP_MULTI_ABI=1
658          sed '/^CCOMP/ s/$/ -m32/' configure.wrf.edit > configure.wrf.tmp
659          mv configure.wrf.tmp  configure.wrf.edit
660        fi
661      fi
662
663      if [ $CROSS_COMPILING -eq 1 ] ; then
664        echo NOTE:
665        echo This installation NetCDF is 32-bit
666        if [ \( $SFC_MULTI_ABI -ne 1 -a "$SFC_arch" = "64-bit" \) \
667             -o \( $SCC_MULTI_ABI -ne 1 -a "$SCC_arch" = "64-bit" \) \
668             -o \( $CCOMP_MULTI_ABI -ne 1 -a "$CCOMP_arch" = "64-bit" \) ] ; then
669             rm configure.wrf.edit
670             echo One of compilers is 64-bit and doesn\'t support cross-compiling.
671             echo Please check your NETCDF lib and compiler
672        else
673          echo -m32 is appended to configure.wrf
674          echo It will be forced to build in 32-bit.
675          echo If you don\'t want 32-bit binaries, please use 64-bit NetCDF, and re-run the configure script.
676        fi
677      fi
678      ;;
679
680      64-bit )
681
682      if [ "$SFC_arch" = "32-bit" -o "$SFC_arch" = "i386" ] ; then
683        CROSS_COMPILING=1
684        $SFC -m64 -o ${foo} ${foo}.f > /dev/null 2>&1
685        if [ $? = 0 ]; then
686          SFC_MULTI_ABI=1
687          sed '/^SFC.*=/s/$/ -m64/' configure.wrf.edit > configure.wrf.tmp
688          mv configure.wrf.tmp configure.wrf.edit
689        fi
690      fi
691      if [ "$SCC_arch" = "32-bit" -o "$SCC_arch" = "i386" ] ; then
692        CROSS_COMPILING=1
693        $SCC -m64 -o ${foo} ${foo}.c > /dev/null 2>&1
694        if [ $? = 0 ]; then
695          SCC_MULTI_ABI=1
696          sed '/^SCC.*=/s/$/ -m64/' configure.wrf.edit > configure.wrf.tmp
697          mv configure.wrf.tmp configure.wrf.edit
698        fi
699      fi
700
701      if [ "$CCOMP_arch" = "32-bit" -o "$CCOMP_arch" = "i386" ] ; then
702        CROSS_COMPILING=1
703        if [ "$CCOMP" != "$SCC" ]; then
704          $CCOMP -m64 -o ${foo} ${foo}.c > /dev/null 2>&1
705          if [ $? = 0 ]; then
706            CCOMP_MULTI_ABI=1
707            sed '/^CCOMP/ s/$/ -m64/' configure.wrf.edit > configure.wrf.tmp
708            mv configure.wrf.tmp  configure.wrf.edit
709          fi
710        else
711          CCOMP_MULTI_ABI=1
712          sed '/^CCOMP/ s/$/ -m64/' configure.wrf.edit > configure.wrf.tmp
713          mv configure.wrf.tmp  configure.wrf.edit
714        fi
715      fi
716
717      if [ $CROSS_COMPILING -eq 1 ] ; then
718        echo NOTE:
719        echo This installation NetCDF is 64-bit
720        if [ \( $SFC_MULTI_ABI -ne 1 -a "$SFC_arch" != "64-bit" \) \
721            -o \( $SCC_MULTI_ABI -ne 1 -a "$SCC_arch" != "64-bit" \) \
722            -o \( $CCOMP_MULTI_ABI -ne 1 -a "CCOMP_arch" != "64-bit" \) ]; then
723            rm configure.wrf.edit
724            echo One of Compilers is 32-bit and doesn\'t support cross-compiling.
725            echo Please check your NetCDF lib and compiler
726        else
727          echo -m64 is appended to configure.wrf
728          echo It will be forced to build in 64-bit.
729          echo If you don\'t want 64-bit binaries, please use 32-bit NetCDF, and re-run the configure script.
730        fi
731      fi
732      ;;
733    esac
734
735    if [ -e configure.wrf.edit ]; then 
736      mv configure.wrf.edit configure.wrf
737    fi
738
739    rm ${foo}* 2> /dev/null
740
741    if [ $CROSS_COMPILING -eq 0 ] ; then
742      echo This installation NetCDF is $netcdf_arch
743      echo C compiler is $SCC_arch
744      echo Fortran compiler is $SFC_arch
745      echo It will build in $netcdf_arch
746    fi
747    echo
748  fi
749fi
Note: See TracBrowser for help on using the repository browser.