source: trunk/WRF.COMMON/WRFV2/configure @ 3094

Last change on this file since 3094 was 11, checked in by aslmd, 14 years ago

spiga@svn-planeto:ajoute le modele meso-echelle martien

  • Property svn:executable set to *
File size: 11.8 KB
Line 
1#!/bin/sh
2
3arg1=$1
4
5# lifted from the configure file for mpich; 00/03/10 jm
6#
7# Check for perl and perl version
8for p in perl5 perl
9do
10  # Extract the first word of "$p", so it can be a program name with args.
11  set dummy $p; ac_word=$2
12  if test -z "$ac_echo_n" ; then
13    ac_echo_n=yes
14    if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
15      # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
16      if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
17    ac_n= ac_c='
18' ac_t='        '
19      else
20        ac_n=-n ac_c= ac_t=
21      fi
22    else
23      ac_n= ac_c='\c' ac_t=
24    fi
25    ac_echo_test=`echo foo 1>&1`
26    if test -z "$ac_echo_test" ; then
27       print_error "Your sh shell does not handle the output redirection"
28       print_error "1>&1 correctly.  Configure will work around this problem,"
29       print_error "but you should report the problem to your vendor."
30    fi
31  fi
32  if test -z "$ac_echo_test" -a 1 = 1 ; then
33    echo $ac_n "checking for $ac_word""... $ac_c"
34  else
35    echo $ac_n "checking for $ac_word""... $ac_c" 1>&1
36  fi
37  ac_prog_where=""
38  if test -n "$PERL"; then
39    ac_pg_PERL="$PERL" # Let the user override the test.
40  else
41    ac_first_char=`expr "$p" : "\(.\)"`
42    if test "$ac_first_char" = "/" -a -x "$p" ; then
43         ac_pg_PERL="$p"
44         ac_prog_where=$p
45    else
46        IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
47        for ac_dir in $PATH; do
48          test -z "$ac_dir" && ac_dir=.
49          if test -f $ac_dir/$ac_word; then
50            ac_pg_PERL="$p"
51            ac_prog_where=$ac_dir/$ac_word
52            break
53          fi
54        done
55        IFS="$ac_save_ifs"
56    fi
57  fi;PERL="$ac_pg_PERL"
58  if test -n "$ac_prog_where" ; then
59    if test -z "$ac_echo_test" -a 1 = 1 ; then
60      echo "$ac_t""found $ac_prog_where ($PERL)"
61    else
62      echo "$ac_t""found $ac_prog_where ($PERL)" 1>&1
63    fi
64    PERLFULLPATH=$ac_prog_where 
65  else
66    if test -z "$ac_echo_test" -a 1 = 1 ; then
67      echo "$ac_t""no"
68    else
69      echo "$ac_t""no" 1>&1
70    fi
71  fi
72  test -n "$PERL" && break
73done
74
75if test -z "$PERL" ; then
76    # We have to set this outside of the loop lest the first failure in
77    # PROGRAM_CHECK set the value (which then terminates the effect of the
78    # loop, since autoconf macros only set values that are null, they
79    # don't override them
80    PERL=""
81fi
82
83if test -n "$PERL" ; then
84    PERL="$PERL"
85   
86    perlversion=`$PERL -v | grep 'This is perl' | \
87       sed -e 's/^.*v[a-z ]*\([0-9]\).*$/\1/'`
88
89    # Should do a test first for ch_p4 etc.
90    if test "$perlversion" -lt 5 ; then
91        echo "WRF build requires perl version 5, which configure did not find."
92        echo "You can set the environment variable PERL to contain the "
93        echo "location of perl version 5."
94        echo "Configure believes that $PERL is version $perlversion ."
95        PERL=""
96    fi
97   
98fi
99
100# Look for netcdf
101if test -z "$NETCDF" ; then
102  for p in /usr/local/netcdf
103  do
104    if test -d $p ; then
105      NETCDF=$p
106      break
107    fi
108  done
109fi
110if  test -z "$NETCDF"  ; then
111 
112  if [ `hostname | cut -c 1-2` = "bs" -o \
113       `hostname | cut -c 1-2` = "bd" -o \
114       `hostname` = "tempest" -o `hostname` = "ute" ] ; then
115    echo 'Compiling on an NCAR system with weird paths to NetCDF'
116    echo 'Setting up a local NetCDF directory with symlinks'
117    if ( test -d ./netcdf_links ) ; then
118      echo 'A directory ./netcdf_links already exists. Continuing.'
119    else
120      mkdir ./netcdf_links
121      if [ -z "$OBJECT_MODE" ] ; then
122         OBJECT_MODE=32 
123         export OBJECT_MODE
124      fi
125      if [ $OBJECT_MODE -ne 64 -a \( `hostname | cut -c 1-2` = "bd" -o `hostname | cut -c 1-2` = "bs" \) ] ; then
126        ( cd ./netcdf_links ; ln -s /usr/local/lib32/r4i4 ./lib ; \
127                              ln -s /usr/local/include ./include )
128      else
129        ( cd ./netcdf_links ; ln -s /usr/local/lib64/r4i4 ./lib ; \
130                              ln -s /usr/local/include ./include )
131      fi
132    fi
133    NETCDF=`pwd`/netcdf_links
134    export NETCDF
135
136
137  else
138    bedone=""
139    if [ -d ./netcdf_links ] ; then
140      echo '** There is an existing ./netcdf_links file. Should I use? [y]'
141      read resp
142      if [ "$resp" = "y" ] ; then
143        NETCDF=`pwd`/netcdf_links
144        bedone="yes"
145      else
146        echo 'Removing existing ./netcdf_links directory'
147        /bin/rm -fr ./netcdf_links
148      fi
149    else
150      echo '** WARNING: No path to NETCDF and environment variable NETCDF not set.'
151      echo '** would you like me to try to fix? [y]'
152    fi
153    netcdfipath=""
154    netcdflpath=""
155    while [ -z "$bedone" ] ; do 
156      read resp
157      if [ "$resp" = "y" -o -z "$resp" ]  ; then
158        if [ -d ./netcdf_links ] ; then
159          echo 'There is already a ./netcdf_links directory. Okay to use links'
160          echo 'in this directory for NetCDF include and lib dirs? [y]'
161          read resp
162          if [ "$resp" = "y" ] ; then
163            NETCDF=`pwd`/netcdf_links
164            export NETCDF
165            bedone="yes"
166            continue
167          fi
168        fi
169        if [ -z "$netcdfipath" ] ; then
170          echo 'Enter full path to NetCDF include directory on your system'
171          read resp
172          if [ ! -d "$resp" ] ; then
173            echo "invalid path: $resp. Try again? [y]" ; continue
174          fi
175          netcdfipath=$resp
176        fi
177        if  [ -z "$netcdflpath" ] ; then
178          echo 'Enter full path to NetCDF library directory on your system'
179          read resp
180          if [ ! -d "$resp" ] ; then
181            echo "invalid path: $resp. Try again? [y]" ; continue
182          fi
183          netcdflpath=$resp
184        fi
185
186        if [ -n "$netcdflpath" -a -n "$netcdfipath" ] ; then
187          if [ -d ./netcdf_links ] ; then
188            echo 'Existing ./netcdf_links directory. Okay to remove. [y]'
189            read resp
190            if [ "$resp" = "y" ]  ; then
191              /bin/rm -fr ./netcdf_links
192            fi
193          fi
194          mkdir ./netcdf_links
195          cd ./netcdf_links
196            ln -s "$netcdfipath" include
197            ln -s "$netcdflpath" lib
198          cd ..
199          echo created new ./netcdf_links directory
200          /bin/ls -lF ./netcdf_links
201          NETCDF=`pwd`/netcdf_links
202          export NETCDF
203          bedone="yes"
204        fi
205      else
206        bedone="yes"
207      fi
208    done
209  fi
210fi
211
212if test -z "$PDHF5" ; then 
213  if [ `hostname | cut -c 1-2` = "bb" -o `hostname | cut -c 1-2` = "bf" -o `hostname | cut -c 1-2` = "bs" -o \
214       `hostname` = "dataproc" -o `hostname` = "ute" ] ; then
215      if [ -d ~michalak/hdf5pbin ] ; then
216        PHDF5=~michalak/hdf5pbin
217        export PHDF5
218      fi
219      if [ "$OBJECT_MODE" -eq 64 ] ; then
220            if [ -d ~michalak/hdf5pbin-64 ] ; then
221              PHDF5=~michalak/hdf5pbin-64
222              export PHDF5
223            fi
224      fi
225  fi
226fi
227
228if [ -n "$NETCDF" ] ; then
229  echo "Will use NETCDF in dir: $NETCDF"
230else
231  echo "Will configure for use without NetCDF"
232fi
233
234if [ -n "$PNETCDF" ] ; then
235  echo "Will use PNETCDF in dir: $PNETCDF"
236# experimental, so don't tease the user if it is not there
237#else
238#  echo "Will configure for use without NetCDF"
239fi
240
241if [ -n "$PHDF5" ] ; then
242  echo "Will use PHDF5 in dir: $PHDF5"
243else
244  echo "PHDF5 not set in environment. Will configure WRF for use without."
245fi
246
247# Users who are cross-compiling can set environment variable
248# $WRF_OS to override the value normally obtained from `uname`. 
249# If $WRF_OS is set, then $WRF_MACH can also be set to override
250# the value normally obtained from `uname -m`.  If $WRF_OS is
251# set and $WRF_MACH is not set, then $WRF_MACH defaults to "ARCH". 
252# If $WRF_OS is not set then $WRF_MACH is ignored. 
253if [ -n "$WRF_OS" ] ; then
254  echo "${0}:  WRF operating system set to \"${WRF_OS}\" via environment variable \$WRF_OS"
255  os=$WRF_OS
256  mach="ARCH"
257  if [ -n "$WRF_MACH" ] ; then
258    echo "${0}:  WRF machine set to \"${WRF_MACH}\" via environment variable \$WRF_MACH"
259    mach=$WRF_MACH
260  fi
261else
262  # if the uname command exists, give it a shot and see if
263  # we can narrow the choices; otherwise, spam 'em
264  os="ARCH"
265  mach="ARCH"
266  type uname > /dev/null
267  if [ $? -eq 0 ] ; then
268    os=`uname`
269    if [ "$os" = "AIX" -o "$os" = "IRIX" -o "$os" = "IRIX64" -o "$os" = "SunOS" -o "$os" = "HP-UX"  -o "$os" = "Darwin" ] ; then
270      mach="ARCH"
271    else
272      if [ "$os" = "OSF1" -o "$os" = "Linux" -o "$os" = "UNICOS/mp" -o "$os" = "UNIX_System_V" -o "$os" = "CYGWIN_NT-5.1" ] ; then
273        mach=`uname -m`
274      else
275        os="ARCH"
276        mach="ARCH"
277      fi
278    fi
279  fi
280fi
281
282# an IBM specific hack to adjust the bmaxstack and bmaxdata options if addressing is 32-bit
283if [ "$os" = "AIX" ] ; then
284      if [ -z "$OBJECT_MODE" ] ; then
285         OBJECT_MODE=32
286         export OBJECT_MODE
287      fi
288      if [ "$OBJECT_MODE" = "32" ] ; then
289# the bang means nothing to sh in this context; use to represent spaces (perl will unbang)
290         ldflags=-bmaxstack:256000000!-bmaxdata:2048000000
291      fi
292fi
293
294# compile options that come from the environment, such as chemistry
295# the "!" is removed by Config.pl
296if [ -n "$WRF_CHEM" ] ; then
297  if [ $WRF_CHEM = 1 ] ; then
298    echo building WRF with chemistry option
299    compileflags="${compileflags}!-DWRF_CHEM"
300  else
301    compileflags=" "
302  fi
303else
304  compileflags=" "
305fi
306
307# Found perl, so proceed with configuration
308if test -n "$PERL" ; then
309   $PERL arch/Config.pl -perl=$PERL -netcdf=$NETCDF -pnetcdf=$PNETCDF -phdf5=$PHDF5 -os=$os -mach=$mach -ldflags=$ldflags \
310   -compileflags=$compileflags
311  if test ! -f configure.wrf ; then
312    exit 1
313  fi
314fi
315
316if [ "$arg1" = "-d" ] ; then
317ls -l configure.wrf
318   if [ -e configure.wrf ] ; then
319     sed -e 's/FCOPTIM[   ]*=/& # /' -e '/FCDEBUG[      ]*=/s/#//g' configure.wrf > configure.wrf.edit
320     /bin/mv configure.wrf.edit configure.wrf
321   fi
322fi
323
324# new feb 2005.  test whether MPI-2
325if test -f configure.wrf ; then
326  grep 'DMPARALLEL .*=.*1' configure.wrf > /dev/null
327  if [ $? = 0 ] ; then
328    echo testing for MPI_Comm_f2c and MPI_Comm_c2f
329    /bin/rm -f tools/mpi2_test
330    ( make mpi2_test 2> /dev/null ) 1> /dev/null
331    if test -e tools/mpi2_test.o ; then
332      echo "  " MPI_Comm_f2c and MPI_Comm_c2f are supported
333      sed '/^CC .*=/s/$/ -DMPI2_SUPPORT/' configure.wrf > xx$$ ; /bin/mv xx$$ configure.wrf
334    else
335      echo "  " MPI_Comm_f2c and MPI_Comm_c2f are not supported
336    fi
337  fi
338# new dec 2005.  test what fseek is supported (needed for share/landread.c to work correctly)
339  echo testing for fseeko and fseeko64
340  /bin/rm -f tools/fseeko_test tools/fseeko64_test
341  ( make fseek_test 2> /dev/null ) 1> /dev/null
342  if test -x tools/fseeko64_test ; then
343    ( tools/fseeko64_test 2> /dev/null ) 1> /dev/null
344    if [ $? = 0 ] ; then
345       echo fseeko64 is supported
346       sed '/^CC .*=/s/$/ -DFSEEKO64_OK /' configure.wrf > xx$$ ; /bin/mv xx$$ configure.wrf
347    fi
348  else
349    if test -x tools/fseeko_test ; then
350      ( tools/fseeko_test 2> /dev/null ) 1> /dev/null
351      if [ $? = 0 ] ; then
352        echo fseeko is supported and handles 64 bit offsets
353        sed '/^CC .*=/s/$/ -DFSEEKO_OK /' configure.wrf > xx$$ ; /bin/mv xx$$ configure.wrf
354      else
355        echo neither fseeko64 nor fseeko with 64 bit offsets works, landread will be compiled with fseek
356        echo but may not work correctly for very high resolution terrain datasets
357      fi
358    else
359      echo neither fseeko64 nor fseeko with 64 bit offsets works, landread will be compiled with fseek
360      echo but may not work correctly for very high resolution terrain datasets
361    fi
362  fi
363fi
364
365echo "------------------------------------------------------------------------"
366sed -e '1,/#### Architecture specific settings ####/d' -e '/^externals/,$d' configure.wrf
367
368echo "------------------------------------------------------------------------"
369echo "Settings listed above are written to configure.wrf."
370echo "If you wish to change settings, please edit that file."
371echo "If you wish to change the default options, edit the file:"
372echo "     arch/configure.defaults"
373echo " "
374
Note: See TracBrowser for help on using the repository browser.