~airpollution/fluidity/fluidity_airpollution

« back to all changes in this revision

Viewing changes to libvtkfortran/configure.in

  • Committer: ziyouzhj
  • Date: 2013-12-09 16:51:29 UTC
  • Revision ID: ziyouzhj@gmail.com-20131209165129-ucoetc3u0atyy05c
airpolution

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#    Copyright (C) 2006 Imperial College London and others.
 
2
#
 
3
#    Please see the AUTHORS file in the main source directory for a full list
 
4
#    of copyright holders.
 
5
#
 
6
#    Gerard Gorman
 
7
#    Applied Modelling and Computation Group
 
8
#    Department of Earth Science and Engineering
 
9
#    Imperial College London
 
10
#
 
11
#    amcgsoftware@imperial.ac.uk
 
12
#
 
13
#    This library is free software; you can redistribute it and/or
 
14
#    modify it under the terms of the GNU Lesser General Public
 
15
#    License as published by the Free Software Foundation,
 
16
#    version 2.1 of the License.
 
17
#
 
18
#    This library is distributed in the hope that it will be useful,
 
19
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
20
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
21
#    Lesser General Public License for more details.
 
22
#
 
23
#    You should have received a copy of the GNU Lesser General Public
 
24
#    License along with this library; if not, write to the Free Software
 
25
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 
26
#    USA
 
27
 
 
28
dnl Process this file with autoconf to produce a configure script.
 
29
AC_INIT(vtkfortran.cpp)
 
30
AC_CONFIG_HEADERS(config.h)
 
31
 
 
32
echo "Hostname: `hostname`"
 
33
 
 
34
# Store enviroment variables
 
35
AC_ARG_ENABLE(debugging,
 
36
    [AC_HELP_STRING([--enable-debugging],
 
37
            [turns on debugging flags])])
 
38
 
 
39
# Check system type
 
40
AC_CANONICAL_HOST
 
41
 
 
42
# Set fortran compiler
 
43
AC_PROG_FC(ifort ifc efc sunf95 gfortran pgf95 pathf95 g95 f90,,f90,$PATH)
 
44
AC_FC_LIBRARY_LDFLAGS
 
45
fccompiler=`basename $FC`
 
46
 
 
47
AC_PROG_CXX(icpc icc ecc sunCC pgCC g++ CC)
 
48
AC_PROG_CPP
 
49
LINKER=$CXX
 
50
 
 
51
AC_LONG_64_BITS
 
52
 
 
53
AC_FC_LIBRARY_LDFLAGS
 
54
LIBS="$LIBS $FCLIBS"
 
55
 
 
56
AC_F77_WRAPPERS
 
57
 
 
58
# Check for standard libraries
 
59
AC_LANG_PUSH([C])
 
60
AC_CHECK_LIB(stdc++,main,,)
 
61
AC_CHECK_LIB(m,main,,)
 
62
AC_CHECK_LIB(pthread,main,,)
 
63
 
 
64
AC_ARG_ENABLE(shared,
 
65
[AC_HELP_STRING([--enable-shared],
 
66
[Compile objects with -fPIC to enable the 'make shared' target.])])
 
67
if test "$enable_shared" = "yes" ; then
 
68
  PIC_FLAG="-fPIC"
 
69
  CXXFLAGS="$CXXFLAGS $PIC_FLAG"
 
70
  FCFLAGS="$FCFLAGS $PIC_FLAG"
 
71
else
 
72
  PIC_FLAG=""
 
73
fi
 
74
 
 
75
##
 
76
## What fortran compiler options work
 
77
##
 
78
if test "$FC" = "g95"; then
 
79
    FCFLAGS="-ffast-math -fno-second-underscore $FCFLAGS"
 
80
fi
 
81
 
 
82
if test "$FC" == "gfortran" || test "$FC" == "gfortran-4.4"; then
 
83
  USING_GFORTRAN="yes"
 
84
else
 
85
  USING_GFORTRAN="no"
 
86
fi
 
87
 
 
88
if test "$USING_GFORTRAN" = "yes"; then
 
89
    if test "$enable_debugging" = "yes" ; then
 
90
        FCFLAGS="-frecord-marker=4 $FCFLAGS"
 
91
    else
 
92
        FCFLAGS="-ffast-math -frecord-marker=4 $FCFLAGS"
 
93
    fi
 
94
    cat >> confdefs.h << EOF
 
95
#define USING_GFORTRAN 1
 
96
EOF
 
97
fi
 
98
 
 
99
AC_PROG_INSTALL
 
100
AC_CHECK_PROG(MAKE, gmake, gmake, make, $PATH)
 
101
 
 
102
# Set default for ARFLAGS, since autoconf does not have a macro for
 
103
# it. This allows people to set it when running configure or make.
 
104
AC_CHECK_PROG(AR, ar, ar, ,$PATH)
 
105
test -n "$ARFLAGS" || ARFLAGS="cr"
 
106
AC_PROG_RANLIB
 
107
 
 
108
AC_ARG_ENABLE(verbose,
 
109
[AC_HELP_STRING([--enable-verbose],
 
110
[turns on super verbosity])])
 
111
 
 
112
if test "$enable_verbose" = "yes" ; then
 
113
cat >> confdefs.h << EOF
 
114
#define VERBOSE_MESSAGES 1
 
115
EOF
 
116
fi
 
117
 
 
118
if test "$enable_debugging" = "yes" ; then
 
119
  CXXFLAGS="-g -O0 `echo $CXXFLAGS | sed 's/-O2//g'`"
 
120
  FCFLAGS="-g -O0 `echo $FCFLAGS | sed 's/-O2//g'`"
 
121
cat >> confdefs.h << EOF
 
122
#define DDEBUG 1
 
123
EOF
 
124
fi
 
125
 
 
126
# Double precision.
 
127
AC_MSG_CHECKING(what voodoo is required to get 64 bit reals....)
 
128
 
 
129
AC_LANG_PUSH([Fortran])
 
130
old_fcflags="$FCFLAGS"
 
131
if test -z "$FORTRAN_REAL_8" ; then
 
132
   # gfortran
 
133
    FORTRAN_REAL_8="-fdefault-real-8"
 
134
    FCFLAGS="$FCFLAGS $FORTRAN_REAL_8"
 
135
    AC_RUN_IFELSE([AC_LANG_PROGRAM([], [
 
136
       implicit none
 
137
       real::a
 
138
       real*8::b
 
139
 
 
140
       if(kind(a).ne.kind(b)) then
 
141
          call exit(-1)
 
142
       end if
 
143
])],
 
144
        [AC_MSG_RESULT($FORTRAN_REAL_8)],
 
145
        [FCFLAGS="$old_fc_flags" ; FORTRAN_REAL_8=""])
 
146
    FCFLAGS="$old_fcflags"
 
147
fi
 
148
if test -z "$FORTRAN_REAL_8" ; then
 
149
   # Intel compiler suite
 
150
    FORTRAN_REAL_8="-r8"
 
151
    FCFLAGS="$FCFLAGS $FORTRAN_REAL_8"
 
152
    AC_RUN_IFELSE([AC_LANG_PROGRAM([], [
 
153
       implicit none
 
154
       real::a
 
155
       real*8::b
 
156
 
 
157
       if(kind(a).ne.kind(b)) then
 
158
          call exit(-1)
 
159
       end if
 
160
])],
 
161
        [AC_MSG_RESULT($FORTRAN_REAL_8)],
 
162
        [FCFLAGS="$old_fc_flags" ; FORTRAN_REAL_8=""])
 
163
    FCFLAGS="$old_fcflags"
 
164
fi
 
165
if test -z "$FORTRAN_REAL_8" ; then
 
166
   # SUN compiler suite
 
167
    FORTRAN_REAL_8="-xtypemap=real:64,double:64"
 
168
    FCFLAGS="$FCFLAGS $FORTRAN_REAL_8"
 
169
    AC_RUN_IFELSE([AC_LANG_PROGRAM([], [
 
170
       implicit none
 
171
       real::a
 
172
       real*8::b
 
173
 
 
174
       if(kind(a).ne.kind(b)) then
 
175
          call exit(-1)
 
176
       end if
 
177
])],
 
178
        [AC_MSG_RESULT($FORTRAN_REAL_8)],
 
179
        [FCFLAGS="$old_fc_flags" ; FORTRAN_REAL_8=""])
 
180
    FCFLAGS="$old_fcflags"
 
181
fi
 
182
if test -z "$FORTRAN_REAL_8" ; then
 
183
   # PGI compiler suite
 
184
    old_fcflags="$FCFLAGS"
 
185
 
 
186
    FORTRAN_REAL_8="-Mr8"
 
187
    FCFLAGS="$FCFLAGS $FORTRAN_REAL_8"
 
188
    AC_RUN_IFELSE([AC_LANG_PROGRAM([], [
 
189
       implicit none
 
190
       real::a
 
191
       real*8::b
 
192
 
 
193
       if(kind(a).ne.kind(b)) then
 
194
          call exit(-1)
 
195
       end if
 
196
])],
 
197
        [AC_MSG_RESULT($FORTRAN_REAL_8)],
 
198
        [FCFLAGS="$old_fc_flags" ; FORTRAN_REAL_8=""])
 
199
fi
 
200
if test -z "$FORTRAN_REAL_8" ; then
 
201
   AC_MSG_ERROR(none found)
 
202
fi
 
203
 
 
204
AC_LANG_POP([Fortran])
 
205
 
 
206
AC_ARG_ENABLE(real-8,
 
207
              [AC_HELP_STRING([--enable-real-8],
 
208
                              [Compile for 8 byte reals.])])
 
209
if test "x$enable_real_8" = "yes" ; then
 
210
  cat >> confdefs.h << EOF
 
211
#define DOUBLEP 1
 
212
EOF
 
213
fi
 
214
if test "x$enable_real_8" = "xno"
 
215
  then
 
216
  FORTRAN_REAL_8=""
 
217
  AC_MSG_NOTICE([Selecting 4 byte floating point numbers])
 
218
else
 
219
  AC_MSG_NOTICE([Turning on double 8 byte floating point numbers])
 
220
  if test -n "$enable_real_8" ; then
 
221
    if test "$enable_real_8" != "yes" ; then
 
222
      FORTRAN_REAL_8="$enable_real_8"
 
223
    fi
 
224
  fi
 
225
  enable_real_8="yes"
 
226
 
 
227
cat >> confdefs.h << EOF
 
228
#define DOUBLEP 1
 
229
EOF
 
230
  FFLAGS="$FFLAGS $FORTRAN_REAL_8"
 
231
  FCFLAGS="$FCFLAGS $FORTRAN_REAL_8"
 
232
fi
 
233
 
 
234
##########################################
 
235
# MPI
 
236
##########################################
 
237
check_for_mpich=""
 
238
check_for_lmpi=""
 
239
 
 
240
AC_LANG(C)
 
241
AC_ARG_ENABLE(mpi,
 
242
[AC_HELP_STRING([--enable-mpi],
 
243
[turns on MPI support])])
 
244
 
 
245
# various synonyms accepted to disable MPI
 
246
if test "$with_mpi" = no ; then enable_mpi=no; fi
 
247
if test "$with_MPI" = no ; then enable_mpi=no; fi
 
248
if test "$enable_MPI" = no ; then enable_mpi=no; fi
 
249
if test "$enable_mpi" != "no" ; then
 
250
  AC_CHECK_PROGS(MPIF90, mpif90 mpf90, $FC, $PATH)
 
251
  AC_CHECK_PROGS(MPICXX, mpicxx mpiCC mpCC, $CXX, $PATH)
 
252
 
 
253
  CXX=$MPICXX
 
254
  FC=$MPIF90
 
255
 
 
256
  AC_MSG_CHECKING([if we can compile and link without using -lmpi])
 
257
  LIBS_bck="$LIBS"
 
258
  LIBS=""
 
259
  AC_TRY_LINK([
 
260
  #include <mpi.h>
 
261
  ],[
 
262
  int flag;
 
263
  MPI_Initialized(&flag);
 
264
  ],[
 
265
  AC_MSG_RESULT([yes])
 
266
  LIBS="$LIBS_bck"
 
267
  mpi="yes"
 
268
  ],[
 
269
  AC_MSG_RESULT([no])
 
270
  LIBS="$LIBS_bck"
 
271
  check_for_lmpi="yes"
 
272
  ])
 
273
else
 
274
  AC_MSG_WARN([mpi disabled])
 
275
  MPICXX=$CXX
 
276
fi
 
277
 
 
278
if test "$check_for_lmpi" = "yes" ; then
 
279
  AC_MSG_CHECKING([if we can compile and link using -lmpi])
 
280
  LIBS_bck="$LIBS"
 
281
  LIBS="-lmpi"
 
282
  AC_TRY_LINK([
 
283
  #include <mpi.h>
 
284
  ],[
 
285
  int flag;
 
286
  MPI_Initialized(&flag);
 
287
  ],[
 
288
  AC_MSG_RESULT([yes])
 
289
  LIBS="$LIBS $LIBS_bck"
 
290
  mpi="yes"
 
291
  ],[
 
292
  AC_MSG_RESULT([no])
 
293
  LIBS="$LIBS_bck"
 
294
  check_for_mpich="yes"
 
295
  ])
 
296
fi
 
297
 
 
298
if test "$check_for_mpich" = "yes" ; then
 
299
  AC_MSG_CHECKING([if we can compile and link using mpich libs])
 
300
  LIBS_bck="$LIBS"
 
301
  LIBS="$MPICH_LIBS"
 
302
 
 
303
  CPPFLAGS_bck="$CPPFLAGS"
 
304
  CPPFLAGS="$CPPFLAGS $MPICH_INCLUDES"
 
305
 
 
306
  AC_TRY_LINK([
 
307
  #include <mpi.h>
 
308
  ],[
 
309
  int flag;
 
310
  MPI_Initialized(&flag);
 
311
  ],[
 
312
  AC_MSG_RESULT([yes])
 
313
  LIBS="$LIBS $LIBS_bck"
 
314
  mpi="yes"
 
315
  ],[
 
316
  AC_MSG_RESULT([no])
 
317
  LIBS="$LIBS_bck"
 
318
  CPPFLAGS="$CPPFLAGS_bck"
 
319
  ])
 
320
fi
 
321
 
 
322
if test "$mpi" = "yes" ; then
 
323
cat >> confdefs.h << EOF
 
324
#define HAVE_MPI 1
 
325
#define HAVE_MPI_CXX 1
 
326
#define _MPI_CPP_BINDINGS 1
 
327
EOF
 
328
  enable_mpi="yes"
 
329
else
 
330
  AC_MSG_WARN([no mpi support found on system])
 
331
  enable_mpi="no"
 
332
fi
 
333
 
 
334
AC_SUBST(OPTIMIZATION_FFLAGS)
 
335
AC_SUBST(LINKER)
 
336
 
 
337
dnl Specific -D options
 
338
AC_SUBST(DEFINE_MPI)
 
339
 
 
340
CXX=$MPICXX
 
341
LINKER=$CXX
 
342
 
 
343
# VTK
 
344
vtk_header_relative_path=""
 
345
AC_ARG_ENABLE(vtk,[AC_HELP_STRING([--enable-vtk], [Only use to disable vtk])])
 
346
# various synonyms accepted for disabling VTK
 
347
if test "$with_vtk" = no ; then enable_vtk=no; fi
 
348
if test "$with_VTK" = no ; then enable_vtk=no; fi
 
349
if test "$enable_VTK" = no ; then enable_vtk=no; fi
 
350
if test "$enable_vtk" != "no" ; then
 
351
    AC_MSG_NOTICE([Checking for VTK automagic.])
 
352
    AC_LANG_PUSH([C++])
 
353
    AC_LINK_IFELSE(
 
354
        [AC_LANG_PROGRAM([[
 
355
#include <vtkVersion.h>
 
356
#include <vtkUnstructuredGrid.h>
 
357
                        ]],
 
358
                [[
 
359
                        vtkVersion::GetVTKMajorVersion();
 
360
                        vtkUnstructuredGrid *ug=vtkUnstructuredGrid::New();
 
361
                        ]])
 
362
            ],
 
363
        [
 
364
            AC_MSG_NOTICE([VTK automagic works.])
 
365
            CPPFLAGS="$CPPFLAGS -DHAVE_VTK"
 
366
            VTK=yes
 
367
            search_for_vtk=no
 
368
            ],
 
369
        [
 
370
            AC_MSG_NOTICE([No VTK automagic])
 
371
            search_for_vtk=yes      
 
372
        ])
 
373
    
 
374
    if test "x$search_for_vtk" == "xyes" ; then
 
375
        # Usually the location of the libraries is not a mystery. The
 
376
        # header files are another matter.
 
377
        AC_CHECK_LIB(dl, main)
 
378
        AC_CHECK_LIB(vtksys, main)
 
379
        AC_CHECK_LIB(vtkCommon, main, [], 
 
380
            [if test "x$VTK_LIBS" != "x" ; then
 
381
                LIBS="$LIBS -L$VTK_LIBS"
 
382
                unset ac_cv_lib_vtkCommon_main
 
383
                AC_CHECK_LIB(vtkCommon, main, [], 
 
384
                   [
 
385
                      AC_MSG_ERROR([Cannot find vtk installation.])
 
386
                      exit -1
 
387
                   ])
 
388
             else
 
389
                AC_MSG_ERROR([Cannot find vtk installation.])
 
390
                exit -1
 
391
             fi
 
392
            ])
 
393
        AC_CHECK_LIB(vtkzlib, main)
 
394
        AC_CHECK_LIB(vtkexpat, main)
 
395
        AC_CHECK_LIB(vtkFiltering, main)
 
396
        AC_CHECK_LIB(vtkGraphics, main)
 
397
        AC_CHECK_LIB(vtkIO, main)
 
398
        
 
399
        # check at the usual places:
 
400
        for i in $(ls -d /usr/include/vtk*) $VTK_INCLUDE; do
 
401
            if test -r $i/vtkCellData.h; then
 
402
                CPPFLAGS="-I$i $CPPFLAGS"
 
403
            fi
 
404
        done
 
405
        AC_CHECK_HEADER(vtkCellData.h,
 
406
            [CPPFLAGS="$CPPFLAGS -DHAVE_VTK=1"
 
407
                VTK=yes
 
408
                ],
 
409
            [AC_CHECK_HEADER(vtk-5.0/vtkCellData.h,
 
410
                    [CPPFLAGS="$CPPFLAGS -DHAVE_VTK=1"
 
411
                        VTK=yes
 
412
                        vtk_header_relative_path="vtk-5.0/"
 
413
                        ],
 
414
                    [       
 
415
                        AC_MSG_ERROR([Cannot find vtk installation.])
 
416
                        exit -1
 
417
                    ])
 
418
          ])
 
419
    fi
 
420
fi
 
421
cat > include/vtk.h <<EOF
 
422
#ifndef VTK_H
 
423
#define VTK_H
 
424
 
 
425
#ifdef HAVE_VTK
 
426
#include <${vtk_header_relative_path}vtkBMPWriter.h>
 
427
#include <${vtk_header_relative_path}vtkCellData.h>
 
428
#include <${vtk_header_relative_path}vtkCellDataToPointData.h>
 
429
#include <${vtk_header_relative_path}vtkCellDerivatives.h>
 
430
#include <${vtk_header_relative_path}vtkCell.h>
 
431
#include <${vtk_header_relative_path}vtkCellType.h>
 
432
#include <${vtk_header_relative_path}vtkClipDataSet.h>
 
433
#include <${vtk_header_relative_path}vtkContourGrid.h>
 
434
#include <${vtk_header_relative_path}vtkDataArray.h>
 
435
#include <${vtk_header_relative_path}vtkDataObject.h>
 
436
#include <${vtk_header_relative_path}vtkDataSet.h>
 
437
#include <${vtk_header_relative_path}vtkDataSetReader.h>
 
438
#include <${vtk_header_relative_path}vtkDoubleArray.h>
 
439
#include <${vtk_header_relative_path}vtkFloatArray.h>
 
440
#include <${vtk_header_relative_path}vtkGenericCell.h>
 
441
#include <${vtk_header_relative_path}vtkHexahedron.h>
 
442
#include <${vtk_header_relative_path}vtkIdList.h>
 
443
#include <${vtk_header_relative_path}vtkImageData.h>
 
444
#include <${vtk_header_relative_path}vtkIntArray.h>
 
445
#include <${vtk_header_relative_path}vtkPointData.h>
 
446
#include <${vtk_header_relative_path}vtkPointLocator.h>
 
447
#include <${vtk_header_relative_path}vtkPolyData.h>
 
448
#include <${vtk_header_relative_path}vtkShortArray.h>
 
449
#include <${vtk_header_relative_path}vtkStructuredGrid.h>
 
450
#include <${vtk_header_relative_path}vtkTetra.h>
 
451
#include <${vtk_header_relative_path}vtkUnsignedCharArray.h>
 
452
#include <${vtk_header_relative_path}vtkUnsignedIntArray.h>
 
453
#include <${vtk_header_relative_path}vtkUnstructuredGrid.h>
 
454
#include <${vtk_header_relative_path}vtkUnstructuredGridReader.h>
 
455
#include <${vtk_header_relative_path}vtkXMLImageDataWriter.h>
 
456
#include <${vtk_header_relative_path}vtkXMLPolyDataWriter.h>
 
457
#include <${vtk_header_relative_path}vtkXMLPUnstructuredGridReader.h>
 
458
#include <${vtk_header_relative_path}vtkXMLPUnstructuredGridWriter.h>
 
459
#include <${vtk_header_relative_path}vtkXMLStructuredGridWriter.h>
 
460
#include <${vtk_header_relative_path}vtkXMLUnstructuredGridReader.h>
 
461
#include <${vtk_header_relative_path}vtkXMLUnstructuredGridWriter.h>
 
462
#include <${vtk_header_relative_path}vtkZLibDataCompressor.h>
 
463
 
 
464
#ifndef vtkFloatingPointType
 
465
#define vtkFloatingPointType vtkFloatingPointType
 
466
typedef float vtkFloatingPointType;
 
467
#endif
 
468
 
 
469
#endif
 
470
#endif
 
471
EOF
 
472
AC_SUBST(ARFLAGS)
 
473
 
 
474
AC_SUBST(MODINC_FLAG)
 
475
 
 
476
# It appears this is not good practice but...go sue me
 
477
#cat confdefs.h | grep -v std > include/confdefs.h    <-- see below...
 
478
cat confdefs.h | grep DOUBLEP > include/confdefs.h
 
479
cat confdefs.h | grep F77_FUNC >> include/confdefs.h
 
480
cat confdefs.h | grep VTK >> include/confdefs.h
 
481
cat confdefs.h | grep MPI >> include/confdefs.h
 
482
cat confdefs.h | grep "^#[dua][enl][fdl][ieo][nfw]" >> include/confdefs.h
 
483
 
 
484
AC_OUTPUT(Makefile)
 
485