forked from boutproject/BOUT-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
1831 lines (1555 loc) · 52.1 KB
/
configure.ac
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 2010 B D Dudson, S Farley
#
# Contact Ben Dudson, [email protected]
#
# This file is part of BOUT++.
#
# BOUT++ 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, either version 3 of the License, or
# (at your option) any later version.
#
# BOUT++ 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 BOUT++. If not, see <http://www.gnu.org/licenses/>.
#
#####################################################################
#
# Process this file with autoconf to produce a configure script.
#
# Changelog:
#
# 2010-03-09 Ben Dudson <[email protected]>
# * Changing to always require FFTW (removing NR routines)
# 2015-08-08 David Schwörer <[email protected]>
# * Searching for libs in lib and lib64
#
BOUT_VERSION="2.0"
AC_PREREQ(2.59)
AC_INIT(BOUT++, BOUT_VERSION, [email protected])
AC_ARG_WITH(checks, [ --with-checks=no/1/2/3 Set run-time checking level])
AC_ARG_WITH(signal, [ --with-signal=no Disable SEGFAULT handling])
AC_ARG_WITH(track, [ --with-track Enable variable tracking])
AC_ARG_WITH(pdb, [ --with-pdb Enable support for PDB files])
AC_ARG_WITH(netcdf, [ --with-netcdf Enable support for netCDF files])
AC_ARG_WITH(hdf5, [ --with-hdf5 Enable support for HDF5 files])
AC_ARG_WITH(parallelhdf5,[ --with-parallelhdf5 Enable support for parallel HDF5 files])
AC_ARG_WITH(pnetcdf,[ --with-pnetcdf Set path to Parallel NetCDF library])
AC_ARG_WITH(debug, [ --with-debug Enable all debugging flags])
AC_ARG_WITH(optimize,[ --with-optimize=default/1/2/3 Enable optimization])
AC_ARG_WITH(ida, [ --with-ida=/path/to/ida Use the SUNDIALS IDA solver])
AC_ARG_WITH(cvode, [ --with-cvode Use the SUNDIALS CVODE solver])
AC_ARG_WITH(sundials, [ --with-sundials Use CVODE and IDA])
AC_ARG_WITH(facets, [ --with-facets Build the interface to FACETS])
AC_ARG_WITH(fftw, [ --with-fftw Set directory of FFTW3 library])
AC_ARG_WITH(lapack, [ --with-lapack Use the LAPACK library])
AC_ARG_WITH(petsc, [ --with-petsc Enable PETSc interface])
AC_ARG_WITH(slepc, [ --with-slepc Enable SLEPc interface])
AC_ARG_WITH(pvode, [ --with-pvode Build and enable PVODE 98 (DEFAULT)])
AC_ARG_WITH(hypre, [ --with-hypre Link to the Hypre library])
AC_ARG_WITH(mumps, [ --with-mumps Link with MUMPS library for direct matrix inversions])
AC_ARG_WITH(arkode, [ --with-arkode Use the SUNDIALS ARKODE solver])
AC_ARG_VAR(EXTRA_INCS,[Extra compile flags])
AC_ARG_VAR(EXTRA_LIBS,[Extra linking flags])
file_formats="" # Record which file formats are being supported
# Delete the build log from last time
rm config-build.log
AC_ARG_VAR(CXXFLAGS,[Extra compile flags])
AC_ARG_VAR(LDFLAGS,[Extra linking flags])
AC_ARG_VAR(LDLIBS,[Extra linking libraries])
AC_SUBST(MKDIR)
AC_SUBST(EXTRA_INCS)
AC_SUBST(EXTRA_LIBS)
# Adding variables for additional sources
AC_SUBST(PRECON_SOURCE)
AC_SUBST(FACETS_SOURCE)
AC_DEFUN([CREATE_DIR],
[
if ! [[ -d $1 ]]
then
mkdir $1
fi
])
dnl#############################################################
dnl# Define functions
dnl#############################################################
# Functions inspired by ESPResSo (espressomd.org)
dnl
dnl Try whether the linker / compiler can find the header / libraries
AC_LANG(C++)
AC_DEFUN([BOUT_MSG_DEBUG],[
dnl Uncomment line below to enable debugging
dnl AC_MSG_NOTICE([debug: $1])
])
dnl define the macro to check for libraries
dnl first argument is the name of the library
dnl second arg is a function of that library
dnl third arg is to be executed if found
dnl forth arg is to be executed if not found
dnl fifth arg is an additional path to check
AC_DEFUN([BOUT_ADDPATH_CHECK_LIB],[
AC_MSG_CHECKING([for lib$1])
LDFLAGS_save=$LDFLAGS
LIBS="$EXTRA_LIBS -l$1"
BACL_found=no
AS_IF([test ."$5" = .yes], [extra_prefix=""],[extra_prefix="$5"])
AC_TRY_LINK([extern "C"
char $2();] ,[return $2();], [BACL_found=yes ; break;
BOUT_MSG_DEBUG([found $1 without path])
],)
if test $BACL_found != yes ; then
for prefix in $extra_prefix /usr /opt $HOME $HOME/local /usr/local ; do
for path in $prefix $prefix/lib $prefix/lib64 $prefix/x86_64-linux-gnu ; do
if test -d $path
then
LDFLAGS="-L$path $LDFLAGS_save"
BOUT_MSG_DEBUG([try link $1 with $path])
AC_TRY_LINK([extern "C"
char $2();] ,[return $2();], [BACL_found=yes ; break;
BOUT_MSG_DEBUG([found $1 with $path])
],)
fi
done
AS_IF([test .$BACL_found = .yes],break;)
done
fi
if test $BACL_found = yes ; then
EXTRA_LIBS=$LIBS
AC_MSG_RESULT(yes)
else
LDFLAGS=$LDFLAGS_save
AC_MSG_RESULT(no)
fi
AS_IF([test .$BACL_found = .yes], [$3],[$4])
])
AC_DEFUN([BOUT_ADDPATH_CHECK_HEADER],[
AC_MSG_CHECKING([for $1])
CPPFLAGS_save=$CPPFLAGS
BACH_found=no
AS_IF([test ."$4" != .yes], [extra_prefix="$4"],[extra_prefix=""])
AC_TRY_COMPILE([#include <$1>] ,, [BACH_found=yes ; break;
BOUT_MSG_DEBUG([found $1 without path])
],)
if test $BACH_found != yes ; then
for prefix in $extra_prefix /usr /opt $HOME $HOME/local /usr/local ; do
for path in $prefix $prefix/include ; do
if test -d $path
then
CPPFLAGS="$CPPFLAGS_save -I$path"
BOUT_MSG_DEBUG([try compile $1 with $path])
AC_TRY_COMPILE([#include <$1>] ,, [BACH_found=yes ; break;
BOUT_MSG_DEBUG([found $1 with $path])
],)
fi
done
AS_IF([test .$BACH_found = .yes],break;)
done
fi
if test $BACH_found = yes ; then
AC_MSG_RESULT(yes)
else
CPPFLAGS=$CPPFLAGS_save
AC_MSG_RESULT(no)
fi
AS_IF([test .$BACH_found = .yes], [$2],[$3])
])
#############################################################
# Checks for programs
#############################################################
MKDIR="mkdir -p"
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB
#############################################################
# MPI
#############################################################
AC_DEFUN([ACX_MPI], [
AC_PREREQ(2.50) dnl for AC_LANG_CASE
AC_LANG_CASE([C++], [
AC_REQUIRE([AC_PROG_CXX])
AC_ARG_VAR(MPICXX,[MPI C++ compiler command])
AC_CHECK_PROGS(MPICXX, mpicxx mpiCC mpic++ hcp mpxlC_r mpxlC mpCC cmpic++ CC, $CXX)
acx_mpi_save_CXX="$CXX"
CXX="$MPICXX"
AC_SUBST(MPICXX)
])
if test x = x"$MPILIBS"; then
AC_LANG_CASE([C++], [AC_CHECK_FUNC(MPI_Init, [MPILIBS=" "])])
fi
if test x = x"$MPILIBS"; then
AC_CHECK_LIB(mpi, MPI_Init, [MPILIBS="-lmpi"])
fi
if test x = x"$MPILIBS"; then
AC_CHECK_LIB(mpich, MPI_Init, [MPILIBS="-lmpich"])
fi
dnl We have to use AC_TRY_COMPILE and not AC_CHECK_HEADER because the
dnl latter uses $CPP, not $CC (which may be mpicc).
AC_LANG_CASE([C++], [
if test x != x"$MPILIBS";
then
AC_MSG_CHECKING([for mpi.h])
AC_TRY_COMPILE([#include <mpi.h>],[],[AC_MSG_RESULT(yes)], [MPILIBS=""
AC_MSG_RESULT(no)])
fi
])
# AC_LANG_CASE[C++], [CXX="$acx_mpi_save_CXX"])
AC_SUBST(MPILIBS)
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test x = x"$MPILIBS"; then
$2
:
else
ifelse([$1],,[AC_DEFINE(HAVE_MPI,1,[Define if you have the MPI library.])],[$1])
:
fi
])dnl ACX_MPI
AC_LANG([C++])
ACX_MPI()
# Checks for libraries.
AC_CHECK_LIB([m], [sqrt])
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([malloc.h stdlib.h string.h strings.h])
# Checks for typedefs, structures, and compiler characteristics.
#AC_HEADER_STDBOOL
#AC_C_CONST
#AC_TYPE_SIZE_T
#AC_C_VOLATILE
# Checks for library functions.
#AC_FUNC_ERROR_AT_LINE
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_VPRINTF
#AC_CHECK_FUNCS([pow sqrt strcasecmp])
# Check for OpenMP support
: ${enable_openmp=no} # Disable by default
#AC_OPENMP
# Add the flag to both compile and link stages
#CXXFLAGS="$CXXFLAGS $OPENMP_CXXFLAGS"
#EXTRA_LIBS="$EXTRA_LIBS $OPENMP_CXXFLAGS"
#############################################################
# General Options
#############################################################
OPT_FLAGS=""
if test "$with_debug" != ""
then
echo "Enabling all debug options"
with_checks="3"
# use -Og with available, otherwise fall back to -O0
OPT_FLAGS="-g -O0 -Og"
elif test $with_optimize ; then
optimize=$with_optimize
test $optimize -eq 0 2>/dev/null
if test $? -eq 2 ; then
if test $optimize == "default"
then
OPT_FLAGS="-O"
elif test $optimize == "fast"
then
OPT_FLAGS="-Ofast -march=native -funroll-loops"
DISABLE_CHECK=probably
else
AC_MSG_ERROR([unrecognized option: --with=optimize=$optimize])
fi
else
if test $optimize -gt 3
then
OPT_FLAGS="-Ofast -march=native -funroll-loops"
DISABLE_CHECK=probably
elif test $optimize -gt 2
then
OPT_FLAGS="-O3 -march=native -funroll-loops"
DISABLE_CHECK=probably
elif test $optimize -gt 1
then
OPT_FLAGS="-O2 -march=native"
elif test $optimze -ge 0
then
OPT_FLAGS="-O$optimize"
else
AC_MSG_ERROR([unrecognized option: --with=optimize=$optimize])
fi
fi
else
OPT_FLAGS="-O"
fi
for flag in $OPT_FLAGS
do
CXXFLAGS_save=$CXXFLAGS
CXXFLAGS="$CXXFLAGS $flag"
AC_MSG_CHECKING([for flag $flag])
AC_TRY_COMPILE([],[],[AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no);CXXFLAGS=$CXXFLAGS_save])
done
# disable checks if optimization > 2 is used
if test -z $with_checks && test .$DISABLE_CHECK = ."probably"
then
with_checks=no
fi
CHECK_LEVEL="0"
if test "$with_checks" != "no"
then
echo "Run-time checking enabled"
if test "$with_checks" = "1"
then
echo " -> Level 1 (Basic checking)"
CXXFLAGS="$CXXFLAGS -DCHECK=1"
CHECK_LEVEL="1"
elif test "$with_checks" = "3"
then
CXXFLAGS="$CXXFLAGS -DCHECK=3"
echo " -> Level 3 (Full checking + stack tracing)"
CHECK_LEVEL="3"
else
echo " -> Level 2 (Basic checking + stack tracing)"
CXXFLAGS="$CXXFLAGS -DCHECK=2"
CHECK_LEVEL="2"
fi
else
echo "Run-time checking disabled"
fi
if test "$with_signal" != "no"
then
echo "Segmentation fault handling enabled"
CXXFLAGS="$CXXFLAGS -DSIGHANDLE"
else
echo "Segmentation fault handling disabled"
fi
if test "$with_track" != ""
then
CXXFLAGS="$CXXFLAGS -DTRACK"
fi
echo
#############################################################
# Git revision number
#############################################################
rev=`git rev-parse HEAD`
if test "$?" = "0"
then
# Attach revision info to flags
CXXFLAGS="$CXXFLAGS -DREVISION=$rev"
echo "Revision ID: $rev"
fi
GIT_REVISION=$rev
#############################################################
# FFT routines
#############################################################
echo "Searching for FFTW library"
if type fftw-wisdom > /dev/null 2>&1; then
echo " -> Found fftw-wisdom executable"
# Path to fftw-wisdom, then remove fft-wisdom and bin/
fftw_wisdom=`which fftw-wisdom | xargs -0 dirname | xargs -0 dirname`
with_fftw="$with_fftw $fftw_wisdom"
fi
BOUT_ADDPATH_CHECK_HEADER(fftw3.h, ,AC_MSG_ERROR('FFTW3 is needed by BOUT++'), $with_fftw)
BOUT_ADDPATH_CHECK_LIB(fftw3, fftw_plan_dft_r2c_1d, ,AC_MSG_ERROR("FFTW3 is needed by BOUT++"), $with_fftw)
echo ""
#############################################################
# netCDF support
#############################################################
NCCONF="" # Configuration script
if test "$with_netcdf" != "no"
then
##########################################
# Try to find a valid NetCDF configuration
#
# at first, try to find ncconf script
#echo "Searching for NetCDF configuration"
OLDNCDF="0" # Indicates whether nc-config or ncxx4-config
if (test "$with_netcdf" = "yes") || (test "$with_netcdf" = "")
then
NCCONF=""
# No path specified. Try using nc-config
if type ncxx4-config &> /dev/null ; then
NCCONF=`which ncxx4-config` # New interface
elif type nc-config &> /dev/null ; then
# Older interface. May or may not have C++ support
echo " -> nc-config script found:" `which nc-config`
if test `nc-config --has-c++` = "yes"
then
echo " -> C++ support included"
NCCONF=`which nc-config`
OLDNCDF="1"
else
echo " -> NO C++ SUPPORT"
fi
else
echo " -> No configure script found. Specify using --with-netcdf option"
fi
else
# see if configure scripts are in path
if type $with_netcdf/ncxx4-config > /dev/null 2>&1; then
NCCONF="$with_netcdf/ncxx4-config"
elif type $with_netcdf/bin/ncxx4-config > /dev/null 2>&1; then
NCCONF="$with_netcdf/bin/ncxx4-config"
elif type $with_netcdf/nc-config > /dev/null 2>&1; then
NCCONF="$with_netcdf/nc-config"
OLDNCDF="1"
elif type $with_netcdf/bin/nc-config > /dev/null 2>&1; then
NCCONF="$with_netcdf/bin/nc-config"
OLDNCDF="1"
fi
fi
##########################################
# Get configuration
if test "$NCCONF" != ""; then
echo " -> NetCDF config script found: $NCCONF"
NCINC=`$NCCONF --cflags`
EXTRA_INCS="$EXTRA_INCS $NCINC"
if test "$OLDNCDF" == "1"; then
NCLIB=`$NCCONF --libs | sed s/-lnetcdf/-lnetcdf_c++\ -lnetcdf/` # Note netcdf_c++ needed
LDFLAGS="$LDFLAGS -Wl,-rpath,`nc-config --prefix`/lib"
CXXFLAGS="$CXXFLAGS -DNCDF"
echo " -> NetCDF support enabled"
else
NCLIB=`$NCCONF --libs`
CXXFLAGS="$CXXFLAGS -DNCDF4"
echo " -> NetCDF-4 support enabled"
fi
EXTRA_LIBS="$EXTRA_LIBS $NCLIB"
file_formats="$file_formats netCDF"
NCPATH="found"
NCFOUND=yes
fi
dnl if nc-config / ncxx4-config is not found, try to find library directly
if test .$NCFOUND != ".yes" ; then
BOUT_MSG_DEBUG([calling bout addpath])
BOUT_ADDPATH_CHECK_HEADER(netcdfcpp.h,
BOUT_ADDPATH_CHECK_LIB(netcdf,nc_get_att,
BOUT_ADDPATH_CHECK_LIB(netcdf_c++,nc_close, NCFOUND=yes ,NCFOUND=no, \
$with_netcdf )
,NCFOUND=no, $with_netcdf )
,NCFOUND=no, $with_netcdf)
AS_IF( test $NCFOUND = yes, [file_formats="$file_formats netCDF";
echo " -> NetCDF support enabled";NCPATH="found";
CXXFLAGS="$CXXFLAGS -DNCDF"]
,)
fi
AS_IF( [test $with_netcdf && test $NCFOUND != yes ] , AC_MSG_ERROR("netcdf requested but not found"),)
AS_IF( test $NCFOUND != yes, echo " -> NetCDF support disabeld",)
fi
echo ""
#############################################################
# Parallel NetCDF support
#############################################################
PNCPATH=""
if test "$with_pnetcdf" != "no"
then
echo "Searching for Parallel-NetCDF library"
if test "$with_pnetcdf" != ""
then
# Given a path to the library
AC_CHECK_FILES($with_pnetcdf/include/pnetcdf.h, PNCPATH=$with_pnetcdf,)
if test "$PNCPATH" == ""
then
echo "parallel-netcdf not found in given directory"
fi
fi
# Find the utilities included with pnetcdf
if test "$PNCPATH" == ""
then
path=`which ncmpidump`
if test "$path" != ""
then
path=`dirname $path`
path=$path/..
AC_CHECK_FILES($path/include/pnetcdf.h , PNCPATH=$path,)
fi
fi
# Try locate
if test "$PNCPATH" == ""
then
path=`locate pnetcdf.h | head -n 1`
if test "$path" != ""
then
path=$path/..
AC_CHECK_FILES($path/include/pnetcdf.h , PNCPATH=$path,)
fi
fi
fi
if test "$PNCPATH" != ""
then
AC_CHECK_FILES($path/lib/libpnetcdf.a, PNCPATHLIB='lib',
AC_CHECK_FILES($path/lib64/libpnetcdf.a, PNCPATHLIB='lib64', PNCPATH=''))
fi
if test "$PNCPATH" == ""
then
echo "Parallel-NetCDF support disabled"
else
# Set a compile-time flag
CXXFLAGS="$CXXFLAGS -DPNCDF"
EXTRA_INCS="$EXTRA_INCS -I$PNCPATH/include"
EXTRA_LIBS="$EXTRA_LIBS -L$PNCPATH/$PNCPATHLIB -lpnetcdf"
file_formats="$file_formats Parallel-NetCDF"
echo "Parallel-NetCDF support enabled"
fi
echo ""
#############################################################
# LAPACK routines (Used for tri- and band-diagonal solvers)
#############################################################
HAS_LAPACK="no"
if ( ( test "$with_lapack" != "no" ) )
then
AS_IF( [ test .$with_lapack = .guess || test .$with_lapack = . ],
[ lapack_path="" ],
[ AS_IF(test .$lapack_path != .yes, [lapack_path=$with_lapack
with_lapack=yes], lapack_path="" )])
dnl echo "\$with_lapack=$with_lapack"
dnl echo "\$lapack_pat=$lapack_path"
BOUT_ADDPATH_CHECK_LIB(blas, zgemm_ , HAS_BLAS=yes
BOUT_ADDPATH_CHECK_LIB(lapack, zgbsv_ , HAS_LAPACK=yes
echo "Using LAPACK"
CXXFLAGS="$CXXFLAGS -DLAPACK"
,
[ AS_IF( [test .$with_lapack = ".yes"], AC_MSG_ERROR("LAPACK requested but not found.")) ], $lapack_path )
, [ AS_IF( [test .$with_lapack = ".yes"], AC_MSG_ERROR("LAPACK requested but not found.")) ] , $lapack_path)
fi
echo ""
#############################################################
# FACETS
#############################################################
if test "$with_facets" != ""
then
FACETS="$with_facets"
AC_CHECK_FILE($FACETS/include/FacetsIfc.h, FIFCPATH=$FACETS,
AC_CHECK_FILE(/usr/include/FacetsIfc.h, FIFCPATH=/usr,
AC_CHECK_FILE(/usr/local/include/FacetsIfc.h, FIFCPATH=/usr/local,
AC_CHECK_FILE(/opt/local/include/FacetsIfc.h, FIFCPATH=/opt/local,
AC_CHECK_FILE($HOME/local/include/FacetsIfc.h, FIFCPATH=$HOME/local,
AC_CHECK_FILE($HOME/software/facetsifc/include/FacetsIfc.h, FIFCPATH=$HOME/software/facetsifc,
))))))
if test "$FIFCPATH" != ""
then
echo "Enabling FACETS interface"
EXTRA_INCS="$EXTRA_INCS -I$FIFCPATH/include"
FACETS_SOURCE="$FACETS_SOURCE bout_facets.cxx"
else
echo "--with-facets was specified but could not find the FACETS interface"
exit
fi
fi
#############################################################
# PETSc library
#############################################################
if test "$with_petsc" != "" && test "$with_petsc" != "no"
then
### This still needs to check for PETSC_ARCH
if test "$with_petsc" != "yes"
then
PETSC_DIR="$with_petsc"
else
AC_CHECK_FILE($PETSC_DIR/$PETSC_ARCH/conf, PETSC_CONFDIR=${PETSC_DIR}/conf,
AC_CHECK_FILE($PETSC_DIR/$PETSC_ARCH/lib/petsc/conf, PETSC_CONFDIR=${PETSC_DIR}/lib/petsc/conf,
echo "Error - can't find PETSc distribution"
exit))
fi
PETSC_VERSION_MAJOR="0"
PETSC_VERSION_MAJOR=`grep 'define PETSC_VERSION_MAJOR' $PETSC_DIR/include/petscversion.h | awk '{print \$3;}'`
PETSC_VERSION_MINOR="0"
PETSC_VERSION_MINOR=`grep 'define PETSC_VERSION_MINOR' $PETSC_DIR/include/petscversion.h | awk '{print \$3;}'`
PETSC_VERSION_RELEASE="0"
PETSC_VERSION_RELEASE=`grep 'define PETSC_VERSION_RELEASE' $PETSC_DIR/include/petscversion.h | awk '{print \$3;}'`
if test $PETSC_VERSION_MAJOR != "3"
then
echo "PETSc must be at least version 3"
exit
fi
if test "$PETSC_VERSION_MINOR" = "1"
then
CXXFLAGS="$CXXFLAGS -DBOUT_HAS_PETSC -DBOUT_HAS_PETSC_3_1"
echo "Using PETSc 3.1 interface"
elif test "$PETSC_VERSION_MINOR" = "2"
then
CXXFLAGS="$CXXFLAGS -DBOUT_HAS_PETSC -DBOUT_HAS_PETSC_3_2"
echo "Using PETSc 3.2 interface"
elif test "$PETSC_VERSION_MINOR" = "3" && test "$PETSC_VERSION_RELEASE" = "1"
then
CXXFLAGS="$CXXFLAGS -DBOUT_HAS_PETSC -DBOUT_HAS_PETSC_3_3"
echo "Using PETSc 3.3 interface"
elif test "$PETSC_VERSION_MINOR" = "4" && test "$PETSC_VERSION_RELEASE" = "1"
then
CXXFLAGS="$CXXFLAGS -DBOUT_HAS_PETSC -DBOUT_HAS_PETSC_3_4"
echo "Using PETSc 3.4 interface"
elif test "$PETSC_VERSION_MINOR" = "5" && test "$PETSC_VERSION_RELEASE" = "1"
then
CXXFLAGS="$CXXFLAGS -DBOUT_HAS_PETSC -DBOUT_HAS_PETSC_3_5"
echo "Using PETSc 3.5 interface"
elif test "$PETSC_VERSION_MINOR" = "5" && test "$PETSC_VERSION_RELEASE" = "0"
then
CXXFLAGS="$CXXFLAGS -DBOUT_HAS_PETSC -DBOUT_HAS_PETSC_DEV"
echo "Using PETSc-dev interface"
else
echo "***********************************"
echo "WARNING: Unrecognised PETSc version"
echo "MAJOR VERSION: $PETSC_VERSION_MAJOR"
echo "MINOR VERSION: $PETSC_VERSION_MINOR"
echo "RELEASE : $PETSC_VERSION_RELEASE"
echo ""
echo "Trying PETSc-dev interface"
echo "***********************************"
CXXFLAGS="$CXXFLAGS -DBOUT_HAS_PETSC -DBOUT_HAS_PETSC_DEV"
fi
cat <<MFILE > petscmake$$
PETSC_ARCH = ${PETSC_ARCH}
PETSC_DIR = ${PETSC_DIR}
include ${PETSC_CONFDIR}/rules
include ${PETSC_CONFDIR}/variables
echo_cxx:
-@echo \${CXX}
echo_sundials:
-@echo \${SUNDIALS_LIB}
MFILE
CXX="`make -f petscmake$$ echo_cxx`"
HAS_SUNDIALS=`make -f petscmake$$ echo_sundials | grep -c sundials`
HAS_CXX=`echo $CXX | grep -ic mp`
if test "$HAS_SUNDIALS" == "0"
then
echo "Warning - PETSc has no SUNDIALS support"
PETSC_HAS_SUNDIALS="no"
else
PETSC_HAS_SUNDIALS="yes"
fi
if test "$HAS_CXX" == "0"
then
echo "Warning - PETSc must have C++ support"
#rm petscmake$$
#exit
fi
echo "PETSc used C++ compiler $CXX"
#MPICXX=$CXX
rm petscmake$$
# Set the line to be included in the make.conf file
PETSC="include ${PETSC_CONFDIR}/variables"
else
PETSC=
fi
AC_SUBST(PETSC, $PETSC)
if test "$PETSC" != ""
then
echo "Using PETSC_DIR = $PETSC_DIR"
echo "Using PETSC_ARCH = $PETSC_ARCH"
PRECON_SOURCE="$PRECON_SOURCE jstruc.cxx"
EXTRA_INCS="$EXTRA_INCS \$(PETSC_CC_INCLUDES)"
EXTRA_LIBS="$EXTRA_LIBS \$(PETSC_LIB)"
if test "$PETSC_HAS_SUNDIALS" == "yes"
then
CXXFLAGS="$CXXFLAGS -DPETSC_HAS_SUNDIALS "
fi
fi
echo
#############################################################
# SLEPc library
#############################################################
HAS_SLEPC="no"
SLEPC_VARS=""
if test "$with_slepc" != "" && test "$with_slepc" != "no"
then
#PETSC_ARCH = ${PETSC_ARCH}
#SLEPC_DIR = ${SLEPC_DIR}
echo "Searching for SLEPc"
if test "$SLEPC_DIR" == ""
then
echo "Error - SLEPC_DIR not set"
exit
fi
# Check that the config directory exists
AC_CHECK_FILE($SLEPC_DIR/$PETSC_ARCH/conf, ,
echo "Error - can't find SLEPc distribution"
exit)
echo " -> using SLEPC_DIR=$SLEPC_DIR"
# Find version number
AC_CHECK_FILE(${SLEPC_DIR}/include/slepcversion.h, ,
echo "Error - can't read include/slepcversion.h"
exit)
SLEPC_VERSION_MAJOR="0"
SLEPC_VERSION_MAJOR=`grep 'define SLEPC_VERSION_MAJOR' $SLEPC_DIR/include/slepcversion.h | awk '{print \$3;}'`
SLEPC_VERSION_MINOR="0"
SLEPC_VERSION_MINOR=`grep 'define SLEPC_VERSION_MINOR' $SLEPC_DIR/include/slepcversion.h | awk '{print \$3;}'`
if test "$SLEPC_VERSION_MAJOR" = "3" && test "$SLEPC_VERSION_MINOR" = "4"
then
# Version 3.4
echo " -> Using interface for SLEPc 3.4"
CXXFLAGS="$CXXFLAGS -DBOUT_HAS_SLEPC -DBOUT_HAS_SLEPC_3_4"
HAS_SLEPC="yes"
EXTRA_INCS="$EXTRA_INCS \$(SLEPC_INCLUDE)"
EXTRA_LIBS="$EXTRA_LIBS \$(SLEPC_LIB)"
SLEPC_VARS="include $SLEPC_DIR/conf/slepc_variables"
else
echo "Error - Unknown SLEPc version"
echo " -> No SLEPc support"
HAS_SLEPC="no"
fi
fi
AC_SUBST(SLEPC_VARS, $SLEPC_VARS)
echo
#############################################################
# MUMPS library
#############################################################
if test "$with_mumps" != "" && test "$with_mumps" != "no"
then
MUMPS=""
echo "Searching for MUMPS"
if test "$with_mumps" != "yes"
then
# User specified a directory
MUMPS="$with_mumps"
# Check for libraries
MUMPS_INC=$MUMPS/include
MUMPS_LIB=$MUMPS/lib
fi
if test "$MUMPS" == ""
then
# Look in some standard locations
AC_CHECK_FILE(/usr/include/dmumps_c.h, MUMPS="/usr/".
AC_CHECK_FILE($HOME/local/include/dmumps_c.h, MUMPS="$HOME/local/",))
# Check for libraries
MUMPS_INC=$MUMPS/include
MUMPS_LIB=$MUMPS/lib
fi
if test "$MUMPS" == "" && test "$PETSC_DIR" != ""
then
# Try PETSc installation
mumps_dir=`ls $PETSC_DIR/externalpackages/ | grep MUMPS`
if test "$mumps_dir" != ""
then
# PETSc has a MUMPS installation
MUMPS_INC=$PETSC_DIR/externalpackages/$mumps_dir/include
MUMPS_LIB=$PETSC_DIR/$PETSC_ARCH/lib
MUMPS=$PETSC_DIR/externalpackages/$mumps_dir
fi
fi
if test "$MUMPS" != ""
then
# Check all files needed
AC_CHECK_FILES( $MUMPS_INC/dmumps_c.h $MUMPS_LIB/libdmumps.a $MUMPS_LIB/libmumps_common.a $MUMPS_LIB/libpord.a $MUMPS_LIB/libscalapack.a $MUMPS_LIB/libblacs.a $MUMPS_LIB/libparmetis.a $MUMPS_LIB/libmetis.a $MUMPS_LIB/libptscotch.a $MUMPS_LIB/libptesmumps.a, ,[ MUMPS="" ])
fi
if test "$MUMPS" == ""
then
echo " -> MUMPS not found"
else
echo " -> MUMPS support enabled"
echo " Includes : $MUMPS_INC"
echo " Libraries: $MUMPS_LIB"
EXTRA_INCS="$EXTRA_INCS -I$MUMPS_INC"
EXTRA_LIBS="$EXTRA_LIBS -L$MUMPS_LIB -ldmumps -lmumps_common -lpord -lscalapack -lblacs -lparmetis -lmetis -lptscotch -lptesmumps"
CXXFLAGS="$CXXFLAGS -DBOUT_HAS_MUMPS"
fi
echo
fi
#############################################################
# Solver choice: SUNDIALS' IDA, SUNDIALS' CVODE, PVODE
#############################################################
if ( ( test "$with_sundials" != "" ) && ( test "$with_sundials" != "no" ) )
then
# Set both IDA and CVODE if not set already
if test "$with_ida" = ""
then
with_ida=$with_sundials
fi
if test "$with_cvode" = ""
then
with_cvode=$with_sundials
fi
fi
if ( ( test "$with_ida" != "" ) && ( test "$with_ida" != "no" ) )
then
echo "Searching for SUNDIALS IDA library"
if test "$with_ida" = "yes"
then
# No path specified. Try using sundials-config
if type sundials-config > /dev/null 2>&1; then
IDAINCS=`sundials-config -m ida -t p -l c -s cppflags`
IDALIBS=`sundials-config -m ida -t p -l c -s libs`
scr=`which sundials-config`
echo "=> Using SUNDIALS IDA solver, configured with $scr"
else
IDAINCS=""
IDALIBS=""
fi
else
# Specified with path
echo "Checking given path to SUNDIALS' IDA solver"
IDALIBS=$with_ida
AC_CHECK_FILES( $with_ida/include/ida/ida.h $with_ida/include/ida/ida_spgmr.h $with_ida/include/ida/ida_bbdpre.h $with_ida/include/nvector/nvector_parallel.h $with_ida/include/sundials/sundials_types.h , , [
IDALIBS=""
] )
AC_CHECK_FILES( $with_ida/lib/libsundials_nvecparallel.a $with_ida/lib/libsundials_ida.a, IDALIBSLIB='lib',
AC_CHECK_FILES( $with_ida/lib64/libsundials_nvecparallel.a $with_ida/lib64/libsundials_ida.a, IDALIBSLIB='lib64',
IDALIBS=""
) )
if test "$IDALIBS" != ""
then
IDAINCS="-I$IDALIBS/include"
IDALIBS="-L$IDALIBS/$IDALIBSLIB -lsundials_ida -lsundials_nvecparallel"
echo "=> Using SUNDIALS IDA solver, path $with_ida"
else
echo " -> Given path not correct. Finding..."
fi
fi
if test "$IDALIBS" = ""
then
# Try some known paths
AC_CHECK_FILE($HOME/local/include/ida/ida.h, IDALIBS=$HOME/local,
AC_CHECK_FILE($HOME/include/ida/ida.h, IDALIBS=$HOME,
AC_CHECK_FILE(/usr/include/ida/ida.h, IDALIBS=/usr,
AC_CHECK_FILE(/usr/local/include/ida/ida.h, IDALIBS=/usr/local,
AC_CHECK_FILE(/opt/local/include/ida/ida.h, IDALIBS=/opt/local,
)))))
if test "$IDALIBS" != ""
then
# Check the rest of the files
AC_CHECK_FILES( $IDALIBS/include/ida/ida.h $IDALIBS/include/ida/ida_spgmr.h $IDALIBS/include/ida/ida_bbdpre.h $IDALIBS/include/nvector/nvector_parallel.h $IDALIBS/include/sundials/sundials_types.h , , [
IDALIBS=""
] )
AC_CHECK_FILES( $IDALIBS/lib/libsundials_nvecparallel.a $IDALIBS/lib/libsundials_ida.a, IDALIBSLIB='lib',
AC_CHECK_FILES( $IDALIBS/lib64/libsundials_nvecparallel.a $IDALIBS/lib64/libsundials_ida.a, IDALIBSLIB='lib64',
IDALIBS=""
) )
fi
if test "$IDALIBS" != ""
then
IDAINCS="-I$IDALIBS/include"
IDALIBS="-L$IDALIBS/$IDALIBSLIB -lsundials_ida -lsundials_nvecparallel"
fi
fi
if test "$IDALIBS" = ""
then
echo "=> IDA solver not available"
echo
else
# Compile in the IDA solver
echo "=> IDA solver enabled"
echo
EXTRA_LIBS="$EXTRA_LIBS $IDALIBS"
EXTRA_INCS="$EXTRA_INCS $IDAINCS"
CXXFLAGS="$CXXFLAGS -DBOUT_HAS_IDA"
fi
fi
if ( ( test "$with_cvode" != "" ) && ( test "$with_cvode" != "no" ) )
then
echo "Searching for SUNDIALS' CVODE library"
if test "$with_cvode" = "yes"
then
# No path specified. Try using sundials-config
if type sundials-config > /dev/null 2>&1; then
CVODEINCS=`sundials-config -m cvode -t p -l c -s cppflags`
CVODELIBS=`sundials-config -m cvode -t p -l c -s libs`
scr=`which sundials-config`
echo "=> Using SUNDIALS CVODE solver, configured with $scr"
else
CVODEINCS=""
CVODELIBS=""
fi
else
# Specified with path
echo "Checking given path to SUNDIALS' CVODE solver"
CVODELIBS=$with_cvode
AC_CHECK_FILES( $with_cvode/include/cvode/cvode.h $with_cvode/include/cvode/cvode_spgmr.h $with_cvode/include/cvode/cvode_bbdpre.h $with_cvode/include/nvector/nvector_parallel.h, , [
CVODELIBS=""
] )
AC_CHECK_FILES( $with_cvode/lib/libsundials_cvode.a $with_cvode/lib/libsundials_nvecparallel.a, CVODELIBSLIB='lib',
AC_CHECK_FILES( $with_cvode/lib64/libsundials_cvode.a $with_cvode/lib64/libsundials_nvecparallel.a, CVODELIBSLIB='lib64', [
CVODELIBS=""
]) )
if test "$CVODELIBS" != ""
then
CVODEINCS="-I$with_cvode/include"
CVODELIBS="-L$with_cvode/$CVODELIBSLIB -lsundials_cvode -lsundials_nvecparallel"
echo "=> Using SUNDIALS CVODE solver, path $with_cvode"
else
echo " -> Given path not correct. Finding..."
fi
fi