source: CPL/oasis3-mct/branches/OASIS3-MCT_2.0_branch/lib/mct/configure.ac @ 4775

Last change on this file since 4775 was 4775, checked in by aclsce, 5 years ago
  • Imported oasis3-mct from Cerfacs svn server (not suppotred anymore).

The version has been extracted from https://oasis3mct.cerfacs.fr/svn/branches/OASIS3-MCT_2.0_branch/oasis3-mct@1818

File size: 14.7 KB
Line 
1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_INIT(MCT, 2.8)
5
6# PROCESS THE FOLLOWING MAKEFILES
7AC_CONFIG_MACRO_DIR([m4])
8AC_CONFIG_FILES(Makefile.conf)
9AC_CONFIG_HEADER(config.h)
10
11# DECLARE PACKAGE OPTIONS
12
13AC_ARG_ENABLE(mpiserial,
14AC_HELP_STRING([--enable-mpiserial],
15[Use the included MPI replacement library for single processor]),
16[DONOTCHECKMPI="DONOTCHECKMPI"]
17)
18
19AC_ARG_ENABLE(debugging,
20AC_HELP_STRING([--enable-debugging],
21[Use the debugging flag and disable the optimization flag]),
22[DEBUGGING="ENABLED"]
23)
24
25AC_ARG_ENABLE(selectedrealkind,
26AC_HELP_STRING([--enable-selectedrealkind],
27[define single precision and double precision numbers using the selected_real_kind function. Default uses the kind inquiry function.]),
28[SRKDEF="SELECTEDREALKIND"]
29)
30
31AC_ARG_ENABLE(sequence,
32AC_HELP_STRING([--enable-sequence],[Modify MCT types to make them contiguous in memory.]),
33[SRKDEF="SEQUENCE"],)
34
35AC_ARG_ENABLE(babel,
36AC_HELP_STRING([--enable-babel],[Supply this option if you plan on building the Babel bindings to MCT]),
37[SRKDEF="SEQUENCE"],)
38
39
40
41# DECLARE THE FOLLOWING PRECIOUS VARIABLES
42
43AC_ARG_VAR(MPILIBS,[MPI library command line invocation])
44AC_ARG_VAR(MPIHEADER,[MPI header include path with INCLUDEFLAG])
45AC_ARG_VAR(FPP,C-preprocessor for Fortran source code)
46AC_ARG_VAR(FPPFLAGS,C-preprocessing flags for Fortran source code)
47AC_ARG_VAR(FC,The Fortran compiler)
48AC_ARG_VAR(FCFLAGS,User-defined Fortran compiler flags)
49AC_ARG_VAR(PROGFCFLAGS,User-defined Fortran compiler flags for example programs)
50AC_ARG_VAR(CFLAGS,Customized C source compilation flags)
51AC_ARG_VAR(DEBUG,Fortran compiler flag for generating symbolic debugging information)
52AC_ARG_VAR(OPT,Fortran compiler flag for optimization level)
53AC_ARG_VAR(REAL8,[Fortran compiler flag for setting the default REAL size to REAL(KIND=8)])
54AC_ARG_VAR(BIT64,Fortran compiler flag for generating 64-bit objects)
55AC_ARG_VAR(ENDIAN,Fortran compiler flag for converting big-endian to little-endian)
56AC_ARG_VAR(INCLUDEFLAG,Fortran compiler flag for specifying module search path)
57AC_ARG_VAR(INCLUDEPATH,Additional library and module paths with INCLUDEFLAG)
58AC_ARG_VAR(AR,Archive command)
59AC_ARG_VAR(BABELROOT,Root directory of your Babel installation. i.e.: $BABELROOT/bin/babel $BABELROOT/lib/libsidl.so)
60AC_ARG_VAR(COMPILER_ROOT,Root directory of your FORTRAN compiler)
61AC_ARG_VAR(FORT_SIZE, Number of bits in Fortran real and double kind)
62
63# INCLUDE BABELROOT and COMPILER_ROOT in Makefile.conf(autoconf output)
64AC_SUBST(BABELROOT)
65AC_SUBST(COMPILER_ROOT)
66AC_SUBST(PYTHON)
67AC_SUBST(PYTHONOPTS)
68
69# SET TEMPORARY VARIABLES
70
71# OS AND PLATFORM NAME
72test "$osname"=NONE && osname=`uname -s`
73test "$machinename"=NONE && machinename=`uname -m`
74fullhostname=`hostname -f`
75
76
77# HARDCODE SPECIFIC MACHINES FOR EXTRAORDINARY CIRCUMSTANCES
78
79# CHECK IF WE ARE ON THE EARTH SIMULATOR
80ES="NO"
81if echo $osname | grep -i esos >/dev/null 2>&1; then
82   ES="YES"
83fi
84if echo $osname | grep -i hp-ux >/dev/null 2>&1; then   
85   if test "$ac_hostname" = "moon"; then
86      ES="YES"
87      # TELLS CONFIGURE NOT TO RUN ANY TESTS THAT REQUIRE EXECUTION
88      cross_compiling="yes"
89   fi
90fi
91if test "$ES" = "YES"; then   
92   echo "Using preset configuration values for the Earth Simulator"
93   if test -z "$CC"; then
94      CC="escc"
95   fi
96   if test -z "$FC"; then
97      FC="esf90"
98   fi
99   if test -z "$MPIFC"; then
100      MPIFC="esmpif90"
101   fi
102   if test -z "$AR"; then
103      AR="esar cqs"
104   fi
105   if test -z "FPP"; then
106      FPPFLAGS=" "
107   fi
108   if test -z "$FCFLAGS"; then
109      FCFLAGS="-EP -Wf'-pvctl fullmsg -L fmtlist transform map'"
110   fi
111   if test -z "$OPT"; then
112      OPT="-C vopt"
113   fi     
114   if test -z "$CPPDEFS"; then
115      CPPDEFS="-DESVEC"
116   fi
117fi
118
119# Check if we are on the ANL BG/P
120
121if echo $fullhostname | egrep -q '.\.(challenger|intrepid)\.alcf\.anl\.gov'
122  then if test -z "$FC"; then
123         FC=bgxlf90_r
124       fi
125       if test -z "$MPIFC"; then
126         MPIFC=mpixlf90_r
127       fi
128       if test -z "$CC"; then
129         CC=mpixlc_r
130       fi
131fi
132
133
134
135# START TESTS
136
137# CHECK FOR THE C COMPILER
138AC_PROG_CC([cc])
139
140# CHECK FOR BYTE ORDERING
141AC_C_BIGENDIAN
142
143# CHECK FOR THE FORTRAN COMPILER
144# RLJ- specify the order, include PathScale and do not search for F77
145AC_PROG_FC([xlf95 pgf95 ifort gfortran pathf95 ftn lf95 f95 fort ifc efc g95 xlf90 pgf90 pathf90 epcf90 pghpf])
146
147# CHECK FOR MPI LIBRARIES
148AC_LANG_PUSH(Fortran)
149
150AC_FC_SRCEXT(F90)
151
152OLDFCFLAGS="$FCFLAGS"
153
154if test -n "$MPIHEADER"; then
155   FCFLAGS="$FCFLAGS $MPIHEADER"
156fi
157
158# CHECK MPI BY DEFAULT
159if test -z "$DONOTCHECKMPI"; then
160   ACX_MPI
161fi
162
163# DONT CHECK MPI IF SERIALMPI OPTION IS ENABLED
164if test -n "$DONOTCHECKMPI"; then
165   echo "MPISERIAL ENABLED: BYPASSING MPI CHECK"
166   if test -z "$MPIFC"; then
167      MPIFC=$FC
168   fi
169   if test -z "$FORT_SIZE"; then
170      FORT_SIZE="real4double8"
171      echo "FORT_SIZE IS PRESET TO $FORT_SIZE"
172   fi   
173   abs_top_builddir=`pwd`
174   MPISERPATH=$abs_top_builddir/mpi-serial
175   AC_SUBST(MPISERPATH)
176   MPIHEADER=-I$MPISERPATH
177   MPILIBS="-L$MPISERPATH -lmpi-serial"
178fi
179
180FCFLAGS="$OLDFCFLAGS"
181
182# A HACK TO FIX ACX_MPI TO GET MPILIBS TO BE AN EMPTY STRING
183if test "$MPILIBS" = " "; then
184   MPILIBS=""
185fi
186
187# SET FC TO MPIFC. IF MPILIBS IS PRESENT, SET FC TO FC.
188if test -z "$FC"; then
189   FC=$MPIFC
190   if test "$FC" != "$MPIFC";  then
191      if test -n "$MPILIBS"; then
192         FC=$FC
193      fi
194   fi
195fi
196
197# FOR SANITY, CHECK THAT FILENAME EXTENSION FOR FC IS CONSISTENT WITH FC
198OLDFC="$FC"
199FC="$FC"
200
201AC_COMPILE_IFELSE(
202  [       subroutine oof()
203             return
204          end], [],
205  [AC_MSG_WARN([$FC FAILED TO COMPILE FILENAME EXTENSION $ac_ext])
206  ])
207
208
209
210FC="$OLDFC"
211
212# CHECK HOW TO GET THE COMPILER VERSION.
213echo "Checking Compiler Version"
214AX_FC_VERSION()
215
216AC_LANG_POP(Fortran)
217
218# Check how to use the cpp with fortran
219
220AC_FC_PP_DEFINE()
221
222
223# CHECK HOW TO NAME MANGLE C FUNCTIONS SO THAT IT CAN BE CALLED FROM FORTRAN
224OLDFC="$FC"
225
226AC_FC_WRAPPERS()
227
228FC="$OLDFC"
229
230# CHECK THAT THE FORTRAN COMPILER CAN CORRECTLY PROCESS THESE DIRECTIVES
231# IF NOT, USE THE EXTERNAL C PREPROCESSOR
232OLDFC="$FC"
233
234defineflag="-Daardvark"
235if test "$OLDFC" = "xlf90"; then
236   defineflag="-WF,-Daardvark"
237fi   
238if test "$OLDFC" = "frt"; then
239   defineflag="-Wp,-Daardvark"
240fi
241
242FC="$OLDFC"
243
244# DEFINE VARIABLES ACCORDING TO OS AND COMPILER
245
246echo "Hostname=$ac_hostname"
247echo "Machine=$machinename"
248echo "OS=$osname"
249
250# CHECK OS NAME
251if echo $osname | grep -i aix >/dev/null 2>&1; then
252   SYSDEF="AIX"
253fi
254if echo $osname | grep -i darwin >/dev/null 2>&1; then
255   SYSDEF="DARWIN"
256fi
257if echo $osname | grep -i unix_system_v >/dev/null 2>&1; then
258   SYSDEF="UNIXSYSTEMV"
259fi
260if echo $osname | grep -i irix >/dev/null 2>&1; then
261   SYSDEF="IRIX"
262fi
263if echo $osname | grep -i irix64 >/dev/null 2>&1; then
264   SYSDEF="IRIX64"
265fi
266if echo $osname | grep -i linux >/dev/null 2>&1; then
267   SYSDEF="LINUX"
268fi
269if echo $osname | grep -i osf1 >/dev/null 2>&1; then
270   SYSDEF="OSF1"
271fi
272if echo $osname | grep -i super >/dev/null 2>&1; then
273   SYSDEF="SUPERUX"
274fi
275if echo $osname | grep -i sun >/dev/null 2>&1; then
276   SYSDEF="SUNOS"
277fi
278if echo $osname | grep -i t3e >/dev/null 2>&1; then
279   SYSDEF="T3E"
280fi
281if echo $osname | grep -i unicos >/dev/null 2>&1; then
282   SYSDEF="UNICOS"
283fi
284if test -z "$SYSDEF"; then
285   AC_MSG_WARN([OPERATING SYSTEM UNKNOWN])
286   SYSDEF="UNKNOWNOS"
287fi
288
289# Set the default FCFLAGS for non-gfortran compilers.
290# NOTE:  This may change with a new version of autoconf.
291DEFFCFLAGS="-g"
292
293#####################################################
294# CHECK COMPILER NAME and add specific flags
295if echo $FC | grep xlf >/dev/null 2>&1; then
296   echo "Fortran Compiler is XLF"
297   CPRDEF="XLF"
298   if test -z "$REAL8"; then
299      REAL8="-qrealsize=8"
300   fi
301   if test -z "$OPT"; then
302      OPT="-O2 -qarch=auto"
303   fi
304   if test -z "$DEBUG"; then
305      DEBUG="-qdbg"
306   fi
307   if test "$FCFLAGS" = "$DEFFCFLAGS"; then
308       FCFLAGS=""
309   fi
310elif echo $FC | grep pgf >/dev/null 2>&1; then
311   echo "Fortran Compiler is Portland Group"
312   CPRDEF="PGI"
313   if test -z "$REAL8"; then
314      REAL8="-r8"
315   fi 
316   if test -z "$BIT64"; then
317      BIT64="-pc 64"
318   fi 
319   if test "$FCFLAGS" = "$DEFFCFLAGS"; then
320      FCFLAGS=""
321   fi 
322   if test -z "$ENDIAN"; then
323      ENDIAN="-byteswapio"
324   fi 
325   if test -z "$OPT"; then
326      OPT="-O2"
327   fi 
328   if test -z "$DEBUG"; then
329      DEBUG="-g"
330   fi
331elif echo $FC | grep ftn >/dev/null 2>&1; then
332 if echo $ac_fc_version_output | grep -i Portland >/dev/null 2>&1; then
333   echo "Fortran Compiler is Portland Group, Cray"
334   CPRDEF="PGI"
335   SYSDEF="CNLINUX"
336   if test -z "$REAL8"; then
337      REAL8="-r8"
338   fi 
339   if test -z "$BIT64"; then
340      BIT64="-pc 64"
341   fi 
342   if test "$FCFLAGS" = "$DEFFCFLAGS"; then
343      FCFLAGS=""
344   fi 
345   if test -z "$ENDIAN"; then
346      ENDIAN="-byteswapio"
347   fi 
348   if test -z "$OPT"; then
349      OPT="-O2"
350   fi
351   if test -z "$DEBUG"; then
352      DEBUG="-g"
353   fi
354 fi
355elif echo $FC | grep ifort >/dev/null 2>&1; then
356   echo "Fortran Compiler is Intel ifort"
357   CPRDEF="INTEL"
358   if test -z "$REAL8"; then
359      REAL8="-r8"
360   fi 
361   if test "$FCFLAGS" = "$DEFFCFLAGS"; then
362      FCFLAGS="-w -ftz"
363   fi 
364   if test -z "$PROGFCFLAGS"; then
365      PROGFCFLAGS="-assume byterecl"
366   fi
367   if test -z "$ENDIAN"; then
368      ENDIAN="-convert big_endian"
369   fi
370   if test -z "$OPT"; then
371      OPT="-O2"
372   fi
373   if test -z "$DEBUG"; then
374      DEBUG="-g"
375   fi
376elif echo $FC | grep g95 >/dev/null 2>&1; then
377   echo "Fortran Compiler is GNU"
378   CPRDEF="GNU"
379elif echo $FC | grep gfortran >/dev/null 2>&1; then
380   echo "Fortran Compiler is GNU"
381   CPRDEF="GNU"
382# For gfortran, default flags are different
383   if test "$FCFLAGS" = "-g -O2"; then
384      FCFLAGS=""
385   fi 
386   if test -z "$DEBUG"; then
387      DEBUG="-g"
388   fi
389   if test -z "$OPT"; then
390      OPT="-O2"
391   fi
392###########################################################
393# the compiler flags below have not been verified recently
394###########################################################
395elif echo $FC | grep frt >/dev/null 2>&1; then
396   echo "Fortran Compiler is UXP/V"
397   echo "Suggested additional vectorization flags: -Wv,-s5,-t3,-noalias,-ilfunc,-md"
398   CPRDEF="FUJITSU"
399   if test -z "$F90FLAGS"; then
400      F90FLAGS="-Am -X9"
401   fi
402   if test -z "$BIT64"; then
403      BIT64="-KA64"
404   fi
405   if test -z "$REAL8"; then
406      REAL8="-Ad"
407   fi
408elif echo $ac_fc_version_output | grep Lahey >/dev/null 2>&1; then
409   echo "Fortran Compiler is Lahey"
410   CPRDEF="LAHEY"
411elif echo $FC | grep ifc >/dev/null 2>&1; then
412   echo "Fortran Compiler is Intel 7.x or earlier"
413   echo "Intel ifc compiler must set the environment variable F_UFMTENDIAN=big to do endian conversion"
414   CPRDEF="INTEL"
415   if test -z "$REAL8"; then
416      REAL8="-r8"
417   fi
418   if test -z "$F90FLAGS"; then
419      F90FLAGS="-w"
420   fi
421   if test -z "$OPT"; then
422      OPT="-O2"
423   fi
424elif echo $FC | grep efc >/dev/null 2>&1; then
425   echo "Fortran Compiler is Intel 7.x or earlier for IA-64"
426   echo "Intel efc compiler must set the environment variable F_UFMTENDIAN=big to do endian conversion"
427   CPRDEF="INTEL"
428   if test -z "$REAL8"; then
429      REAL8="-r8"
430   fi
431   if test -z "$F90FLAGS"; then
432      F90FLAGS="-w -ftz"
433   fi
434   if test -z "$OPT"; then
435      OPT="-O2"
436   fi
437elif echo $FC | grep pathf90 >/dev/null 2>&1; then
438   echo "Fortran Compiler is PathScale"
439   CPRDEF="PATHSC"
440   if test -z "$REAL8"; then
441      REAL8="-r8"
442   fi
443   if test -z "$BIT64"; then
444      BIT64="-m64"
445   fi
446   if test -z "$OPT"; then
447      OPT="-O2"
448   fi
449elif echo $ac_fc_version_output | grep -i nag >/dev/null 2>&1; then
450   echo "Fortran Compiler is NAG"
451   CPRDEF="NAG"
452   if test -z "$F90FLAGS"; then
453      F90FLAGS="-dusty -kind=byte"
454   fi
455   if test -z "$OPT"; then
456      OPT="-O2"
457   fi
458elif echo $ac_fc_version_output | grep -i absoft >/dev/null 2>&1; then
459   echo "Fortran Compiler is Absoft"
460   CPRDEF="ABSOFT"
461   if test -z "$REAL8"; then
462      REAL8="-N113"
463   fi
464   if test -z "$INCLUDEFLAG"; then
465      INCLUDEFLAG="-p"
466   fi
467   if test -z "$OPT"; then
468      OPT="-O2"
469   fi
470elif echo $ac_fc_version_output | grep -i workshop >/dev/null 2>&1; then
471   echo "Fortran Compiler is Workshop"
472   CPRDEF="WORKSHOP"
473   if test -z "$INCLUDEFLAG"; then
474      INCLUDEFLAG="-M"
475   fi
476elif echo $ac_fc_version_output | grep -i mipspro >/dev/null 2>&1; then
477   echo "Fortran Compiler is MIPSPro"
478   CPRDEF="MIPSPRO"
479   EXTRACFLAGS="-64"
480   if test -z "$OPT"; then
481      OPT="-O3"
482   fi
483   if test -z "$REAL8"; then
484      REAL8="-r8"
485   fi
486   if test -z "$BIT64"; then
487      BIT64="-64"
488   fi
489elif echo $ac_fc_version_output | grep -i compaq >/dev/null 2>&1; then
490   echo "Fortran Compiler is Compaq"
491   CPRDEF="COMPAQ"
492   MPILIBS="$MPILIBS -lelan"
493   if test -z "$OPT"; then
494      OPT="-fast"
495   fi
496   if test -z "$REAL8"; then
497      REAL8="-real_size 64"
498   fi
499   if test -z "$ENDIAN"; then
500      ENDIAN="-convert big_endian"
501   fi
502
503# Compaq Fortran changed its name to HP Fortran.
504# Lets support both versions for now.
505elif echo $ac_fc_version_output | grep HP >/dev/null 2>&1; then
506   echo "Fortran Compiler is HP"
507   CPRDEF="COMPAQ"
508   MPILIBS="$MPILIBS -lelan"
509   if test -z "$OPT"; then
510      OPT="-fast"
511   fi
512   if test -z "$REAL8"; then
513      REAL8="-real_size 64"
514   fi
515   if test -z "$ENDIAN"; then
516      ENDIAN="-convert big_endian"
517   fi
518
519elif echo $ac_fc_version_output | grep -i sx >/dev/null 2>&1; then
520   echo "Fortran Compiler is SX"
521   CPRDEF="SX"
522   if test -z "$F90FLAGS"; then
523      F90FLAGS="-EP -Wf'-pvctl noassoc'"
524   fi
525   if test -z "$OPT"; then
526      OPT="-Chopt"
527   fi
528fi
529
530###########################################################
531# END of compiler-specific flag setting
532###########################################################
533
534CPPDEFS="$CPPDEFS -DSYS$SYSDEF -DCPR$CPRDEF"
535if test -n "$SRKDEF"; then
536    CPPDEFS="$CPPDEFS -D$SRKDEF"
537fi
538
539# IF DEBUGGING ENABLED, DISABLE OPTIMIZATION FLAG
540if test "$DEBUGGING" = "ENABLED"; then
541        OPT=""
542else
543        DEBUG=""
544fi
545
546# SET HARDCODED VARIABLES AS A LAST RESORT
547
548# ALWAYS ENABLE CRULE IN MAKEFILE
549AC_SUBST(CRULE,[.c.o])
550
551AC_SUBST(CPPDEFS)
552
553# INCLUDE FLAG IF NOT ALREADY SET IS MOST LIKELY -I
554if test -z "$INCLUDEFLAG"; then
555   INCLUDEFLAG="-I"
556fi
557
558# ARCHIVE COMMAND SIMILAR ACROSS ALL PLATFORMS
559if test -z "$AR"; then
560   AR="ar cq"
561fi
562
563echo
564echo Output Variables: {CC=$CC} {CFLAGS=$CFLAGS} \
565{FC=$FC} {FCFLAGS=$FCFLAGS} {PROGFCFLAGS=$PROGFCFLAGS}\
566{CPPDEFS=$CPPDEFS} {OPT=$OPT} {DEBUG=$DEBUG} {REAL8=$REAL8} \
567{BIT64=$BIT64} {ENDIAN=$ENDIAN} {MPIFC=$MPIFC} \
568{MPILIBS=$MPILIBS} {MPIHEADER=$MPIHEADER}  \
569{INCLUDEFLAG=$INCLUDEFLAG} {INCLUDEPATH=$INCLUDEPATH} \
570{AR=$AR} {BABELROOT=$BABELROOT} {COMPILER_ROOT=$COMPILER_ROOT} \
571{PYTHON=$PYTHON} {PYTHONOPTS=$PYTHONOPTS} {FORT_SIZE=$FORT_SIZE} {prefix=$prefix} \
572{SRCDIR=$SRCDIR} {FC_DEFINE=$FC_DEFINE}
573echo
574
575AC_OUTPUT
576
577echo Please check the Makefile.conf
578echo Have a nice day!
579
580# test -z is true for empty strings
581# test -n is true for non-empty strings
582
583
584
585
Note: See TracBrowser for help on using the repository browser.