-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.in
1675 lines (1500 loc) · 51.3 KB
/
configure.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright (C) 2006 Imperial College London and others.
#
# Please see the AUTHORS file in the main source directory for a full list
# of copyright holders.
#
# Prof. C Pain
# Applied Modelling and Computation Group
# Department of Earth Science and Engineering
# Imperial College London
#
# amcgsoftware@imperial.ac.uk
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation,
# version 2.1 of the License.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
dnl Process this file with autoconf to produce a configure script.
AC_INIT(fluidity, None)
AC_CONFIG_HEADERS(include/config.h)
# we ignore PACKAGE_VERSION as it is useless
# instead we pass on FLUIDITY_VERSION from the env. if it is set
AC_SUBST(FLUIDITY_VERSION)
echo "Hostname: `hostname`"
# Store enviroment variables
env_f77="${F77}"
env_fflags="${FFLAGS}"
env_flibs="${FLIBS}"
env_fc="${FC}"
env_fcflags="${FCFLAGS}"
env_fclibs="${FCLIBS}"
env_cflags="${CFLAGS}"
env_cxxflags="${CXXFLAGS}"
env_cppflags="${CPPFLAGS}"
env_libs="${LIBS}"
# Set the default compile flags.
if test "no$FFLAGS" = "no"; then
FFLAGS=""
fi
if test "no$FCFLAGS" = "no"; then
FCFLAGS=""
fi
if test "no$CFLAGS" = "no"; then
CFLAGS=""
fi
if test "no$CXXFLAGS" = "no"; then
CXXFLAGS=""
fi
#
# Name fluidity
#
AC_ARG_ENABLE(debugging,
[AC_HELP_STRING([--enable-debugging],
[turns on debugging flags])])
FLFEMDEM="femdem"
# Check system type
AC_CANONICAL_HOST
# Find compilers
AC_MSG_NOTICE([*** Fishing for legacy fortran compiler.])
AC_PROG_F77(ifort ifc efc sunf95 gfortran pgf95 pathf95 g95 f90,,f90,$PATH)
fcompiler=`basename $F77`
AC_MSG_NOTICE([*** Fishing for modern Fortran compiler])
AC_PROG_FC(ifort ifc efc sunf95 gfortran pgf95 pathf95 g95 f90,,f90,$PATH)
fccompiler=`basename $FC`
if test "x$fcompiler" = "xsunf95" ; then
MODINC_FLAG="-M"
FFLAGS="-M../include $FFLAGS"
FCFLAGS="-M../include $FCFLAGS"
else
MODINC_FLAG="-I"
fi
# We're calling the fortran compiler and testing if gcc is in the output. If so
# we're using gfortran. Fixes cases where we're using gfortran, but the compiler binary
# is not called gfortran
if $FC -v 2>&1 | grep 'gcc version'; then
USING_GFORTRAN="yes"
GFORTRAN_VERSION=$($FC -v 2>&1 | grep 'gcc version' | awk '{print $3}')
# test really is so retarded that it can't lexicographically compare strings
if test "$(python -c "print \"$GFORTRAN_VERSION\" >= \"4.5\"")" = "True"; then
GFORTRAN_4_5_OR_NEWER="yes"
AC_SUBST(GFORTRAN_4_5_OR_NEWER)
fi
if test "$(python -c "print \"$GFORTRAN_VERSION\" >= \"4.8\"")" = "True"; then
GFORTRAN_4_8_OR_NEWER="yes"
fi
else
USING_GFORTRAN="no"
fi
# How to specify where .mod files are placed.
if test "$FC" = "ifort"; then
MOD_FLAG="-module "
elif test "$USING_GFORTRAN" = "yes"; then
MOD_FLAG="-J"
else
AC_MSG_ERROR(Don't know how to specify the module output directory for $FC.)
fi
AC_SUBST(MOD_FLAG)
if test "$F77" = "$FC" ; then
smart_fortran="yes"
AC_MSG_NOTICE([*** Assuming that $FC can process both free and fixed form fortran files.])
else
AC_MSG_NOTICE([*** Assuming that $FC cannot process both free and fixed form fortran files (silly fortran).])
smart_fortran="no"
fi
if test "$fcompiler" = "ifort" ; then
if ifort -v 2>&1 |grep 11.0; then
AC_MSG_ERROR(Intel 11.0 is bugged and cannot be used to compile Fluidity. Try a working version of the compiler such as 10.1.)
fi
if ifort -v 2>&1 |grep 11.1; then
AC_MSG_WARN(Early versions of intel 11.1 are bugged and cannot be used to compile Fluidity. Make sure you have at least version 11.1.073.)
fi
FFLAGS="$FFLAGS -vec-report=0"
FCFLAGS="$FCFLAGS -vec-report=0"
fi
AC_PROG_CC(icc ecc suncc pgcc gcc cc)
AC_PROG_CXX(icpc icc ecc sunCC pgCC g++ CC)
AC_PROG_CPP
LINKER=$CXX
AC_LONG_64_BITS
# Find fortran libraries required when linking with C++ main.
AC_FC_LIBRARY_LDFLAGS
AC_F77_WRAPPERS
# Find python to link against.
AC_ARG_ENABLE(python,
[AC_HELP_STRING([--enable-python],
[embed python in fluidity for generic functions.])])
if test "x$enable_python" != "xno"
then
AC_MSG_NOTICE([Checking for Python automagic.])
AC_LANG_PUSH([C++])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[
#include <Python.h>
]],[[
Py_Initialize();
PyRun_SimpleString("from time import time,ctime\n"
"print 'Today is',ctime(time())\n");
Py_Finalize();
]])],
[
AC_MSG_NOTICE([Python automagic works.])
CPPFLAGS="$CPPFLAGS -DHAVE_PYTHON"],
[
AC_MSG_NOTICE([No Python automagic.])
search_for_python=yes
])
AC_LANG_POP([C++])
if test "x$search_for_python" == "xyes" ; then
mycppflag=$CPPFLAGS
AC_PYTHON_DEVEL
CPPFLAGS=$mycppflag
# Save variables...
if test "x$pythonexists" = "xyes";
then
if test "$fcompiler" = "pgf90"; then
PYTHON_EXTRA_LDFLAGS=${PYTHON_EXTRA_LDFLAGS/-Xlinker/}
PYTHON_EXTRA_LDFLAGS=${PYTHON_EXTRA_LDFLAGS/-export-dynamic/}
fi
if test "x$enable_debugging" = "xyes"; then
export PYTHON_EXTRA_LDFLAGS=$(echo $PYTHON_EXTRA_LDFLAGS | sed -e 's/-O1/-O0/g' -e 's/-O2/-O0/g' -e 's/-O3/-O0/g')
fi
LIBS="$LIBS $PYTHON_LDFLAGS $PYTHON_EXTRA_LDFLAGS $PYTHON_EXTRA_LIBS"
CXXFLAGS="$CXXFLAGS $PYTHON_CPPFLAGS"
CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS"
CFLAGS="$CFLAGS $PYTHON_CPPFLAGS"
fi
fi
# Additionally check for numpy
NUMPY=$(python -c 'import numpy; print numpy.get_include()' 2>/dev/null)
if ! test -z "$NUMPY"; then
echo "Numpy is " $NUMPY
CXXFLAGS="$CXXFLAGS -DHAVE_NUMPY -I$NUMPY"
CPPFLAGS="$CPPFLAGS -DHAVE_NUMPY -I$NUMPY"
CFLAGS="$CFLAGS -DHAVE_NUMPY -I$NUMPY"
FFLAGS="$FFLAGS -DHAVE_NUMPY -I$NUMPY"
FCFLAGS="$FCFLAGS -DHAVE_NUMPY -I$NUMPY"
else
echo "Failed to locate Numpy"
fi
fi
AC_SUBST(HAVE_PYTHON)
AC_ARG_ENABLE(cgal, [AC_HELP_STRING([--enable-cgal], [turns on use of the CGAL library])])
if test "x$enable_cgal" = "xyes" ; then
ACX_lib_automagic(CGAL, _ZNK4CGAL6Random8get_seedEv, [HAVE_CGAL=yes; AC_DEFINE(HAVE_LIBCGAL)], AC_MSG_ERROR("Use of CGAL enabled but cannot identify CGAL. Check that it is installed."))
AC_SUBST(HAVE_CGAL)
LIBS="$LIBS -lgmp -lmpfr"
fi
# Find a library which will give us blas and lapack routines
AC_LANG_PUSH([C])
found_blas="no"
if test -z "$with_lapack" -a -z "$with_blas" && \
test \( "$fcompiler" = "ifc" \) -o \( "$fcompiler" = "ifort" \) -o \( "$fcompiler" = "efc" \)
then
AC_MSG_NOTICE([Appear to be using Intel compiler suite. Check if MKL is also available.])
for i in `echo $LD_LIBRARY_PATH | sed -e 's/:/ /g'`
do
echo "looking in $i"
if test \( -f $i/libmkl.a \) -o \( -f $i/libmkl.so \)
then
AC_MSG_NOTICE([Will look in $i for MKL.])
LIBS="$LIBS -L$i"
LAPACK_LIBS="-L$i $LAPACK_LIBS"
fi
done
ACX_BLAS([found_blas="yes"],[found_blas="no"])
elif test "$fcompiler" = "pgf90"
then
AC_MSG_NOTICE([Appear to be using Portland Group compiler suite. Check if ACML is also available.])
AC_CHECK_LIB(acml, dgesv, [found_blas=yes], [found_blas=no])
elif test "$fcompiler" = "sunf95"
then
LIBS="$LIBS -lfui -lfai -lfsu -lmtsk -lpthread -lm"
AC_MSG_NOTICE([Appear to be using Sun Studio compiler suite. Check if Sun Performance Library is also available.])
AC_CHECK_LIB(sunperf, dgesv, [found_blas=yes ; acx_blas_ok=yes], [found_blas=no])
fi
AC_LANG_POP([C])
AC_LANG_PUSH([Fortran 77])
if test "$found_blas" = "no"
then
AC_MSG_NOTICE([checking the position of the stars to help find a versions of BLAS])
ACX_BLAS([],[AC_MSG_ERROR("Cannot identify BLAS. Check that it is installed.")])
fi
ACX_LAPACK([],[AC_MSG_ERROR("Cannot identify LAPACK. Check that it is installed.")])
AC_LANG_POP([Fortran 77])
# Check for standard libraries
AC_LANG_PUSH([C])
AC_CHECK_LIB(stdc++,main,,)
AC_CHECK_LIB(m,main,,)
AC_CHECK_LIB(pthread,main,,)
AC_SEARCH_LIBS(utInit,[udunits udunits2],[have_udunits="yes"],)
if test "$have_udunits" = "yes"; then
cat >> confdefs.h << EOF
#define HAVE_LIBUDUNITS 1
EOF
fi
AC_ARG_ENABLE(openmp,
[AC_HELP_STRING([--enable-openmp],
[turns on OpenMP support])])
if test "x$enable_openmp" == "xyes" ; then
AC_LANG_PUSH([C++])
AC_OPENMP()
CXXFLAGS="$CXXFLAGS $OPENMP_CXXFLAGS"
LDFLAGS="$LDFLAGS $OPENMP_CXXFLAGS"
AC_LANG_POP([C++])
# Assume same flag for FC
FCFLAGS="$FCFLAGS $OPENMP_CXXFLAGS"
fi
LIBS="$LAPACK_LIBS $LIBS $FCLIBS $FLIBS"
AC_SUBST(LAPACK_LIBS)
AC_SUBST(BLAS_LIBS)
LINKER=$CXX
AC_ARG_ENABLE(shared,
[AC_HELP_STRING([--enable-shared],
[Compile objects with -fPIC to enable the 'make shared' target.])])
if test "$enable_shared" = "yes" ; then
PIC_FLAG="-fPIC"
FFLAGS="$FFLAGS $PIC_FLAG"
FCFLAGS="$FCFLAGS $PIC_FLAG"
CFLAGS="$CFLAGS $PIC_FLAG"
CXXFLAGS="$CXXFLAGS $PIC_FLAG"
else
PIC_FLAG=""
fi
##
## what compiler options work
##
if test "$FC" = "g95"; then
FFLAGS="-ffast-math -fno-second-underscore $FFLAGS"
FCFLAGS="-ffast-math -fno-second-underscore $FCFLAGS"
fi
# How to unroll loops?
AC_MSG_CHECKING(["Checking for -funroll-loops"])
UNROLL_LOOPS=""
OLD_FFLAGS="$FFLAGS"
FFLAGS="-funroll-loops"
AC_LANG_PUSH([Fortran 77])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(,[[
PRINT*, "hello world"
]])],
[
AC_MSG_RESULT(-funroll-loops works)
UNROLL_LOOPS="-funroll-loops"
])
FFLAGS="$OLD_FFLAGS"
AC_SUBST(UNROLL_LOOPS)
AC_LANG_POP()
if test "$USING_GFORTRAN" = "yes"; then
if test "$enable_debugging" = "yes" ; then
FFLAGS="-frecord-marker=4 $FFLAGS"
FCFLAGS="-frecord-marker=4 $FCFLAGS"
else
FFLAGS="-ffast-math -frecord-marker=4 $FFLAGS"
FCFLAGS="-ffast-math -frecord-marker=4 $FCFLAGS"
fi
cat >> confdefs.h << EOF
#define USING_GFORTRAN 1
EOF
# Check for -frealloc-lhs
# This optimisation is avaible from gfortran 4.6.? but it leads
# to memory leaks, see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53389
# so we switch it off
AC_MSG_CHECKING(["Checking for -fno-realloc-lhs"])
OLD_FCFLAGS="$FCFLAGS"
FCFLAGS="-fno-realloc-lhs"
AC_LANG_PUSH([Fortran])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(,[[
PRINT*, "hello world"
]])],
[
AC_MSG_RESULT([-fno-realloc-lhs works, adding to FCFLAGS])
NO_REALLOC_LHS="-fno-realloc-lhs"
])
FCFLAGS="$OLD_FCFLAGS"
AC_LANG_POP()
FCFLAGS="$FCFLAGS $NO_REALLOC_LHS"
FFLAGS="$FFLAGS $NO_REALLOC_LHS"
fi
AC_LANG_POP([C])
AC_LANG_PUSH(Fortran 77)
AC_MSG_CHECKING([how do we get fortran 77 to allow long lines])
old_FLAGS="$FFLAGS"
extended_source_flag=none
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(,[[
PRINT*, "hello world "
]])],
[
AC_MSG_RESULT(no extra flags required)
extended_source_flag=happy
])
if test "$extended_source_flag" != happy ; then
if test "$extended_source_flag" = none ; then
FFLAGS="-extend_source"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(,[[
PRINT*, "hello world "
]])],
[
extended_source_flag=$FFLAGS
AC_MSG_RESULT([$FFLAGS])
FFLAGS="$old_FLAGS $FFLAGS"
])
fi
if test "$extended_source_flag" = none ; then
FFLAGS="-extend-source"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(,[[
PRINT*, "hello world "
]])],
[
extended_source_flag=$FFLAGS
AC_MSG_RESULT([$FFLAGS])
FFLAGS="$old_FLAGS $FFLAGS"
])
fi
if test "$extended_source_flag" = none ; then
FFLAGS="-132"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(,[[
PRINT*, "hello world "
]])],
[
extended_source_flag=$FFLAGS
AC_MSG_RESULT([$FFLAGS])
FFLAGS="$old_FLAGS $FFLAGS"
])
fi
if test "$extended_source_flag" = none ; then
FFLAGS="-ffree-line-length-none -ffixed-line-length-none"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(,[[
PRINT*, "hello world "
]])],
[
extended_source_flag=$FFLAGS
AC_MSG_RESULT([$FFLAGS])
FFLAGS="$old_FLAGS $FFLAGS"
])
fi
if test "$extended_source_flag" = none ; then
FFLAGS="-ffixed-line-length-huge -ffree-line-length-huge"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(,[[
PRINT*, "hello world "
]])],
[
extended_source_flag=$FFLAGS
AC_MSG_RESULT([$FFLAGS])
FFLAGS="$old_FLAGS $FFLAGS"
])
fi
if test "$extended_source_flag" = none ; then
FFLAGS="-ffixed-line-length-132 -ffree-line-length-huge"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(,[[
PRINT*, "hello world "
]])],
[
extended_source_flag=$FFLAGS
AC_MSG_RESULT([$FFLAGS])
FFLAGS="$old_FLAGS $FFLAGS"
])
fi
if test "$extended_source_flag" = none ; then
FFLAGS="-ffixed-line-length-132"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(,[[
PRINT*, "hello world "
]])],
[
extended_source_flag=$FFLAGS
AC_MSG_RESULT([$FFLAGS])
FFLAGS="$old_FLAGS $FFLAGS"
])
fi
if test "$extended_source_flag" = none ; then
FFLAGS="-Mextend"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(,[[
PRINT*, "hello world "
]])],
[
extended_source_flag=$FFLAGS
AC_MSG_RESULT([$FFLAGS])
FFLAGS="$old_FLAGS $FFLAGS"
])
fi
if test "$extended_source_flag" = none ; then
FFLAGS="-qfixed=256"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(,[[
PRINT*, "hello world "
]])],
[
extended_source_flag=$FFLAGS
AC_MSG_RESULT([$FFLAGS])
FFLAGS="$old_FLAGS $FFLAGS"
])
fi
if test "$extended_source_flag" = none ; then
FFLAGS="-e"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(,[[
PRINT*, "hello world "
]])],
[
extended_source_flag=$FFLAGS
AC_MSG_RESULT([$FFLAGS])
FFLAGS="$old_FLAGS $FFLAGS"
])
fi
if test "$extended_source_flag" = none ; then
AC_MSG_RESULT([we cannot])
else
FCFLAGS="$FCFLAGS $extended_source_flag"
fi
fi
AC_LANG_POP([Fortran 77])
AC_PROG_INSTALL
AC_CHECK_PROG(MAKE, gmake, gmake, make, $PATH)
# Set default for ARFLAGS, since autoconf does not have a macro for
# it. This allows people to set it when running configure or make.
AC_CHECK_PROG(AR, ar, ar, ,$PATH)
test -n "$ARFLAGS" || ARFLAGS="cr"
AC_PROG_RANLIB
AC_ARG_ENABLE(verbose,
[AC_HELP_STRING([--enable-verbose],
[turns on super verbosity])])
if test "$enable_verbose" = "yes" ; then
cat >> confdefs.h << EOF
#define VERBOSE_MESSAGES 1
EOF
fi
if test "$enable_debugging" = "yes" ; then
CFLAGS="-g -O0 `echo $CFLAGS | sed 's/-O2//g'`"
CXXFLAGS="-g -O0 `echo $CXXFLAGS | sed 's/-O2//g'`"
FFLAGS="-g -O0 `echo $FFLAGS | sed 's/-O2//g'`"
FCFLAGS="-g -O0 `echo $FCFLAGS | sed 's/-O2//g'`"
cat >> confdefs.h << EOF
#define DDEBUG 1
EOF
if test "$fcompiler" = "ifort" ; then
FFLAGS="-C -traceback -check nooutput_conversion -check noarg_temp_created ${FFLAGS}"
FCFLAGS="-C -traceback -check nooutput_conversion -check noarg_temp_created ${FCFLAGS}"
CFLAGS="-fno-omit-frame-pointer ${CFLAGS}"
CXXFLAGS="-fno-omit-frame-pointer ${CXXFLAGS}"
elif test "$USING_GFORTRAN" = "yes" ; then
old_fflags="$FFLAGS"
old_fcflags="$FCFLAGS"
FFLAGS="$FFLAGS -finit-integer=-66666 -finit-real=nan"
FCFLAGS="$FCFLAGS -finit-integer=-66666 -finit-real=nan"
AC_LANG_PUSH([Fortran])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(,[[
PRINT*, "hello world"
]])],
[
AC_MSG_RESULT(can initialise integers and reals)
old_fflags="$FFLAGS"
old_fcflags="$FCFLAGS"
], [
AC_MSG_RESULT(cannot initialise integers and reals)
])
AC_LANG_POP()
FFLAGS="$old_fflags"
FCFLAGS="$old_fcflags"
FFLAGS="-fbounds-check -Wall ${FFLAGS}"
FCFLAGS="-fbounds-check -Wall -Wimplicit-interface -Wno-surprising ${FCFLAGS}"
CFLAGS="-fbounds-check -Wall ${CFLAGS}"
CXXFLAGS="-fbounds-check -Wall ${CXXFLAGS}"
LDFLAGS="-rdynamic ${LDFLAGS}"
elif test "$fcompiler" = "g95" ; then
FFLAGS="-fbounds-check -ftrace=full ${FFLAGS}"
FCFLAGS="-fbounds-check -ftrace=full ${FCFLAGS}"
elif test "$fcompiler" = "sunf95" ; then
FFLAGS="-C -ftrap=invalid -fpover ${FFLAGS}"
FCFLAGS="-C -ftrap=invalid -fpover ${FCFLAGS}"
CFLAGS="-ftrap=invalid ${CFLAGS}"
CXXFLAGS="-ftrap=invalid ${CXXFLAGS}"
fi
else
AC_MSG_NOTICE([Setting optimisation flags for $F77])
cat >> confdefs.h << EOF
#define NDEBUG 1
EOF
OPTIMISATION_FLAGS="$OPTIMISATION_FLAGS -O3"
if test "$fcompiler" = "ifort" ; then
# add inlining and cpu-specific optimisations for intel
OPTIMISATION_FLAGS="$OPTIMISATION_FLAGS -ip -xHost"
fi
AC_CHECK_LIB(tcmalloc,malloc,,AC_MSG_WARN([No tcmalloc support available.]))
fi
FFLAGS="$FFLAGS $OPTIMISATION_FLAGS"
FCFLAGS="$FCFLAGS $OPTIMISATION_FLAGS"
CFLAGS="$CFLAGS $OPTIMISATION_FLAGS"
CXXFLAGS="$CXXFLAGS $OPTIMISATION_FLAGS"
##########################################
# Are we using FEMDEM
##########################################
AC_ARG_WITH(femdem,
[AC_HELP_STRING([--with-femdem@<:@=femdem_library@:>@],
[specify the femdem path])])
if test -n "$with_femdem" ; then
FLFEMDEM_PATH="${with_femdem}"
LIB_FEMDEM="${with_femdem}""/lib/libd$FLFEMDEM.a"
FEMDEM="yes"
cat >> confdefs.h << EOF
#define USING_FEMDEM 1
EOF
else
FLFEMDEM_PATH=""
LIB_FEMDEM=""
FEMDEM=""
fi
AC_SUBST(FLFEMDEM_PATH)
AC_SUBST(LIB_FEMDEM)
AC_SUBST(FEMDEM)
##########################################
# Are we using OASIS
##########################################
AC_ARG_WITH(psmile,
[AC_HELP_STRING([--with-psmile@<:@=psmile_library@:>@],
[specify the oasis4 path])])
if test -n "$with_psmile" ; then
FLPSMILE_PATH="${with_psmile}"
ENABLE_PSMILE="yes"
cat >> confdefs.h << EOF
#define USING_PSMILE 1
EOF
else
FLPSMILE_PATH=""
ENABLE_PSMILE=""
fi
AC_SUBST(FLPSMILE_PATH)
AC_SUBST(ENABLE_PSMILE)
# save compiler name for libadapt before it's changed by MPI stuff
saved_FC="${FC}"
saved_CC="${CC}"
saved_F77="${F77}"
##########################################
# MPI
##########################################
check_for_mpich=""
check_for_lmpi=""
AC_LANG(C)
AC_ARG_VAR(MPICC, C compiler command for MPI programs)
AC_ARG_VAR(MPIF90, Fortran 90 compiler command for MPI programs)
AC_ARG_VAR(MPIF77, Fortran 77 compiler command for MPI programs)
AC_ARG_VAR(MPICXX, C++ compiler command for MPI programs)
AC_CHECK_PROGS(MPIF90, mpif90 mpf90, $FC, $PATH)
if test "$smart_fortran" = "yes" ; then
MPIF77=$MPIF90
else
AC_CHECK_PROGS(MPIF77, mpif77 mpf77, $F77, $PATH)
fi
AC_CHECK_PROGS(MPICC, mpicc mpcc, $CC, $PATH)
AC_CHECK_PROGS(MPICXX, mpicxx mpiCC mpCC, $CXX, $PATH)
F77=$MPIF77
FC=$MPIF90
CC=$MPICC
CXX=$MPICXX
AC_MSG_CHECKING([if we can compile and link without using -lmpi])
AC_TRY_LINK([
#include <mpi.h>
],[
int flag;
MPI_Initialized(&flag);
],[
AC_MSG_RESULT([yes])
mpi="yes"
],[
AC_MSG_RESULT([no])
check_for_lmpi="yes"
])
if test "$check_for_lmpi" = "yes" ; then
AC_MSG_CHECKING([if we can compile and link using -lmpi])
LIBS_bck="$LIBS"
LIBS="-lmpi"
AC_TRY_LINK([
#include <mpi.h>
],[
int flag;
MPI_Initialized(&flag);
],[
AC_MSG_RESULT([yes])
LIBS="$LIBS $LIBS_bck"
mpi="yes"
],[
AC_MSG_RESULT([no])
LIBS="$LIBS_bck"
check_for_mpich="yes"
])
fi
if test "$check_for_mpich" = "yes" ; then
AC_MSG_CHECKING([if we can compile and link using mpich libs])
LIBS_bck="$LIBS"
LIBS="$MPICH_LIBS"
CPPFLAGS_bck="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $MPICH_INCLUDES"
AC_TRY_LINK([
#include <mpi.h>
],[
int flag;
MPI_Initialized(&flag);
],[
AC_MSG_RESULT([yes])
LIBS="$LIBS $LIBS_bck"
mpi="yes"
],[
AC_MSG_RESULT([no])
LIBS="$LIBS_bck"
CPPFLAGS="$CPPFLAGS_bck"
])
fi
if test "$mpi" = "yes" ; then
cat >> confdefs.h << EOF
#define HAVE_MPI 1
#define HAVE_MPI_CXX 1
#define _MPI_CPP_BINDINGS 1
EOF
enable_mpi="yes"
else
AC_MSG_ERROR([no MPI support found on system])
fi
# netCDF support
AC_LANG_PUSH([C])
AC_ARG_WITH(netcdf,
[AC_HELP_STRING([--with-netcdf@<:@=netcdf_ROOT@:>@],
[specify where to find lib/ and include/ for netCDF])])
# allow various synonyms to disable NetCDF
if test -z "$with_netcdf" ; then
if test "$enable_netcdf" = no; then
with_netcdf=no
elif test "$enable_NetCDF" = no; then
with_netcdf=no
elif test "$with_NetCDF" != "yes" ; then
if test -n "$with_NetCDF" ; then
with_netcdf="$with_NetCDF"
fi
fi
fi
if test "$with_netcdf" != "no" ; then
if test -n "$with_netcdf" ; then
if test "$with_netcdf" != "yes" ; then
LIBS="$LIBS -L$with_netcdf"
fi
fi
ACX_lib_automagic(netcdf, nc_create, [AC_DEFINE(HAVE_LIBNETCDF, [1])])
ACX_lib_automagic(netcdff, nc_create, [AC_DEFINE(HAVE_LIBNETCDFF, [1])])
fi
# Exodus-II support
HAVE_EXODUSII=no
AC_LANG_PUSH([C])
AC_ARG_WITH(exodusii,
[AC_HELP_STRING([--with-exodusii@<:@=exodus_ROOT@:>@],
[specify where to find lib/ and include/ for exodusii])])
if test "$with_exodusii" = "yes" ; then
if test -d "$with_exodusii" ; then
LIBS="$LIBS -L$with_exodusii/lib"
fi
ACX_lib_automagic(exoIIv2c, ex_close, [
AC_DEFINE(HAVE_LIBEXOIIV2C, [1])
HAVE_EXODUSII=yes
])
fi
AC_SUBST(HAVE_EXODUSII)
AC_ARG_ENABLE(petsc-fortran-modules,
[AC_HELP_STRING([--disable-petsc-fortran-modules],
[By default fluidity tries to use fortran modules provided with petsc. Use --disable-petsc-fortran-modules if these are known to be not functional (e.g. compiled with different compiler version)])])
ACX_PETSc([AC_MSG_NOTICE(["PETSc found, enabling scalable solver"])], [AC_MSG_ERROR(["PETSc not found"])])
ACX_hypre([AC_MSG_NOTICE(["hypre found, enabling hypre preconditioners"])], [AC_MSG_WARN(["hypre not found"])])
CPPFLAGS="$CPPFLAGS -DHAVE_PETSC"
if test "$HAVE_PETSC_MODULES" == "1"; then
CPPFLAGS="$CPPFLAGS -DHAVE_PETSC_MODULES"
fi
if test "$HAVE_HYPRE" == "1"; then
CPPFLAGS="$CPPFLAGS -DHAVE_HYPRE"
fi
CPPFLAGS=`echo $CPPFLAGS | sed 's/-petsc-version-/3.4.2.0/' | sed 's/x86_64\/x86_64/x86_64/'`
FCFLAGS=`echo $FCFLAGS | sed 's/-petsc-version-/3.4.2.0/' | sed 's/x86_64\/x86_64/x86_64/'`
# Metis, ParMetis
AC_MSG_CHECKING([if we can compile and link without using -lparmetis])
AC_TRY_LINK([
],[
METIS_PartGraphKway();
ParMETIS_V3_AdaptiveRepart();
],[
AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_LIBMETIS, [1])
AC_DEFINE(HAVE_LIBPARMETIS, [1])
],[
AC_MSG_RESULT([no])
ACX_lib_automagic(metis, METIS_PartGraphKway, [AC_DEFINE(HAVE_LIBMETIS, [1])])
ACX_lib_automagic(parmetis, ParMETIS_V3_AdaptiveRepart, [AC_DEFINE(HAVE_LIBPARMETIS, [1])])
])
AC_CHECK_HEADERS([parmetis.h])
AS_IF([test "x$ac_cv_header_parmetis_h" = "xyes" ],
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_MSG_CHECKING([parmetis major version <=3])
AC_EGREP_CPP([test_true],
[
#include <parmetis.h>
#if defined(PARMETIS_MAJOR_VERSION) && PARMETIS_MAJOR_VERSION <= 3
test_true
#endif
],
[AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_PARMETIS_V3,"yes")
PARMETIS_FLAGS="-DPARMETIS_V3" ],
[AC_MSG_RESULT([no])
PARMETIS_FLAGS=""]
)
AC_LANG_RESTORE
]
)
CPPFLAGS="$CPPFLAGS $PARMETIS_FLAGS"
AC_ARG_ENABLE(sam,
[AC_HELP_STRING([--enable-sam],
[use sam rather than zoltan for adaptive load rebalancing])])
if test "$enable_sam" = "yes"; then
HAVE_ZOLTAN=no
else
ACX_lib_automagic(zoltan, Zoltan_Create, [],
[
AC_MSG_NOTICE([Fluidity can be built without zoltan by configuring with the --enable-sam flag. This gives limited functionality when using parallel adaptivity. See the manual for more details.])
AC_MSG_FAILURE("Could not link with Zoltan library.")
])
# Small test for zoltan .mod files:
AC_LANG(Fortran)
c_ext=F90
# In fluidity's makefile we explicitly add CPPFLAGS, temporarily add it to
# FCFLAGS here for this zoltan test:
tmpFCFLAGS="$FCFLAGS"
FCFLAGS="$FCFLAGS $CPPFLAGS"
AC_LINK_IFELSE(
[AC_LANG_SOURCE([
program test_zoltan
use zoltan
end program test_zoltan
])
],
[
AC_MSG_NOTICE([Great success! Zoltan .mod files exist and are usable])
],
[
cp conftest.F90 test_zoltan.F90
AC_MSG_NOTICE([Fluiidity can be build without zoltan by configuring with the --enable-sam flag. This gives limited functionality when using parallel adaptivity. See the manual for more details.])
AC_MSG_NOTICE([Failed to compile with zoltan.mod fortran module. This means the module can either not be found - please add the necessary -I flag to CPPFLAGS - or, the zoltan fortran module has been compiled with a different (version of the) fortran compiler than you are using to compile fluidity - in which case please rebuild zoltan with the same compiler.])
AC_MSG_FAILURE([Failed to find usable zoltan.mod file])
]
)
# And now revert FCFLAGS
FCFLAGS="$tmpFCFLAGS"
AC_LANG_RESTORE
AC_DEFINE(HAVE_ZOLTAN, [1])
HAVE_ZOLTAN=yes
fi
AC_SUBST(HAVE_ZOLTAN)
# Double precision.
AC_MSG_CHECKING(what voodoo is required to get 64 bit reals....)
AC_LANG_PUSH([Fortran])
old_fcflags="$FCFLAGS"
if test -z "$FORTRAN_REAL_8" ; then
# gfortran
FORTRAN_REAL_8="-fdefault-real-8 -fdefault-double-8"
FCFLAGS="$FCFLAGS $FORTRAN_REAL_8"
AC_RUN_IFELSE([AC_LANG_PROGRAM([], [
implicit none
real::a
real*8::b
if(kind(a).ne.kind(b)) then
call exit(-1)
end if
])],
[AC_MSG_RESULT($FORTRAN_REAL_8)],
[FCFLAGS="$old_fc_flags" ; FORTRAN_REAL_8=""])
FCFLAGS="$old_fcflags"
fi
if test -z "$FORTRAN_REAL_8" ; then
# Intel compiler suite
FORTRAN_REAL_8="-r8"
FCFLAGS="$FCFLAGS $FORTRAN_REAL_8"
AC_RUN_IFELSE([AC_LANG_PROGRAM([], [
implicit none
real::a
real*8::b
if(kind(a).ne.kind(b)) then
call exit(-1)
end if
])],
[AC_MSG_RESULT($FORTRAN_REAL_8)],
[FCFLAGS="$old_fc_flags" ; FORTRAN_REAL_8=""])
FCFLAGS="$old_fcflags"
fi
if test -z "$FORTRAN_REAL_8" ; then
# SUN compiler suite
FORTRAN_REAL_8="-xtypemap=real:64,double:64"
FCFLAGS="$FCFLAGS $FORTRAN_REAL_8"
AC_RUN_IFELSE([AC_LANG_PROGRAM([], [
implicit none
real::a
real*8::b
if(kind(a).ne.kind(b)) then
call exit(-1)
end if
])],
[AC_MSG_RESULT($FORTRAN_REAL_8)],
[FCFLAGS="$old_fc_flags" ; FORTRAN_REAL_8=""])
FCFLAGS="$old_fcflags"
fi
if test -z "$FORTRAN_REAL_8" ; then
# PGI compiler suite
old_fcflags="$FCFLAGS"
FORTRAN_REAL_8="-Mr8"
FCFLAGS="$FCFLAGS $FORTRAN_REAL_8"
AC_RUN_IFELSE([AC_LANG_PROGRAM([], [
implicit none
real::a
real*8::b
if(kind(a).ne.kind(b)) then
call exit(-1)
end if
])],
[AC_MSG_RESULT($FORTRAN_REAL_8)],
[FCFLAGS="$old_fc_flags" ; FORTRAN_REAL_8=""])
fi
if test -z "$FORTRAN_REAL_8" ; then
AC_MSG_ERROR(none found)
fi
AC_LANG_POP([Fortran])
AC_ARG_ENABLE(dp,
[AC_HELP_STRING([--enable-dp[=flag]],
[compile with 64 bit floating point numbers (default)])])
if test "$enable_dp" = "no"
then
FORTRAN_REAL_8=""
AC_MSG_NOTICE([Selecting 4 byte floating point numbers])
else
AC_MSG_NOTICE([Turning on double 8 byte floating point numbers])
if test -n "$enable_dp" ; then
if test "$enable_dp" != "yes" ; then
FORTRAN_REAL_8="$enable_dp"
fi
fi
enable_dp="yes"
cat >> confdefs.h << EOF
#define DOUBLEP 1
EOF
FFLAGS="$FFLAGS $FORTRAN_REAL_8"
FCFLAGS="$FCFLAGS $FORTRAN_REAL_8"
fi