-
Notifications
You must be signed in to change notification settings - Fork 64
/
configure
executable file
·3022 lines (2895 loc) · 100 KB
/
configure
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
#!/bin/bash
# CPPTRAJ standalone configure script.
# Daniel R. Roe
# 2010-11-18
# Rewritten 2018-01-25 (getting old...)
# Support for getting and building external libraries (get_library.sh) added 2021-03-03
# This script will determine compiler and linker flags based on
# desired user-specified options. Generates config.h, which is
# used by src/Makefile.
#-------------------------------------------------------------------------------
# Print simple help message
UsageSimple() {
echo "Usage: ./configure <OPTIONS> [gnu | intel | pgi | clang | cray | oneapi]"
echo " OPTIONS:"
echo " --help : Display this message."
echo " --prefix <dir> : Install CPPTRAJ to specified directory (default is this directory)."
echo " -openmp : Use OpenMP for parallelization of certain routines."
echo " -mpi : Use mpicc/mpicxx to compile."
echo " -intelmpi : Use mpiicc/mpiicpc to compile."
echo " -cuda : Enable CUDA support. See SHADER_MODEL in --full-help for more info."
echo " -hip : Enable HIP support."
echo " -cray : Use cray compiler wrappers (cc/CC/ftn)."
echo " -amberlib : Use BLAS/ARPACK/LAPACK/NetCDF libraries from \$AMBERHOME"
echo " -cmake : Use cmake; 'configure' must be executed in a separate directory."
echo " --full-help : Display additional options."
echo ""
}
#-------------------------------------------------------------------------------
# Print more detailed options
UsageFull() {
UsageSimple
echo " ADDITIONAL OPTIONS"
echo " -debug : Turn on compiler debugging info."
echo " -noopt : Do not use optimized compiler flags."
echo " -tune : Enable host-specific compiler optimizations."
echo " -noc++11 : Disable C++11 support."
echo " -d : Turn on compiler debug info and disable optimization (i.e. -debug -noopt)."
echo " -timer : Enable additional timing info."
echo " -debugon : Add -DDEBUG flag to activate additional internal debugging."
echo " -nolfs : Do not enable large file support."
echo " -shared : Configure for generating libcpptraj (implies -nosanderlib)."
echo " -pubfft : Use pubfft instead of FFTW for FFT (disables PME functionality)."
echo " -windows : Set up for use with MinGW compilers for a native Windows build."
echo " LIBRARY OPTIONS"
echo " -<lib> : Enable library."
echo " --with-<lib>=<DIR> : Use library in specified directory."
echo " -l<lib>=<FILE> : Use specified library file."
echo " -no<lib> : Disable library."
echo " --buildlibs : Attempt to build enabled libraries if they are not present."
echo " --nobuildlibs : Do not asking about building enabled libraries."
echo " -makenetcdf : Have cpptraj build its own NetCDF."
echo " -makeblas : Have cpptraj build its own LAPACK/BLAS."
echo " Libraries: netcdf pnetcdf zlib bzlib blas lapack arpack fftw3 readline sanderlib xdrfile tng openmm"
echo " Note: pnetcdf is needed for writing NetCDF trajectories with MPI."
echo " LINKING OPTIONS"
echo " -static : Use static linking."
echo " -libstatic : Use static linking only for specified libraries."
echo " -mkl : Use Intel MKL for BLAS/LAPACK (requires MKL_HOME/MKLROOT set)."
echo " -nomklfftw : Prevent use of FFTW from MKL."
echo " -openblas : Use OpenBLAS for BLAS/LAPACK (may require '--with-blas' or '-lblas')."
echo " May also want to specify '-larpack' if included in OpenBLAS."
echo " -macAccelerate : Use Accelerate framework for BLAS/LAPACK."
echo " -libsci : Use Cray LibSci for BLAS/LAPACK."
echo " ENVIRONMENT VARIABLES (can also be passed to configure as <VAR>=<VALUE>):"
echo " CXX : Name of the C++ compiler."
echo " CC : Name of the C compiler."
echo " FC : Name of the Fortran compiler."
echo " MPICXX : Name of MPI C++ compiler."
echo " MPICC : Name of MPI C compiler."
echo " MPIF90 : Name of MPI Fortran compiler."
echo " CXXFLAGS : Flags to pass to the C++ compiler."
echo " CFLAGS : Flags to pass to the C compiler."
echo " FFLAGS : Flags to pass to the Fortran compiler."
echo " LDFLAGS : Flags to pass to the linker."
echo " TUNEFLAGS : Host-specific tuning flags. Will override '-tune'."
echo " NVCC : Name of the nvcc/hipcc compiler."
echo " NVCCFLAGS : Flags to pass to the nvcc/hipcc compiler."
echo " DBGFLAGS : Any additional flags to pass to all compilers."
echo " CUDA_HOME : (-cuda) Path to CUDA installation."
echo " HIP_HOME : (-hip) Path to ROCm installation (default is '/opt/rocm')."
echo " SHADER_MODEL : (-cuda) Should be set to 'sm_XX', where XX is CUDA compute architecture."
echo " sm_86 = GA102, 104, 106, 107"
echo " sm_80 = GA100"
echo " sm_75 = Turing"
echo " sm_72 = GV10B"
echo " sm_70 = GV100"
echo " sm_62 = GP10B"
echo " sm_61 = GP106 = GTX-1070, GP104 = GTX-1080, GP102 = Titan-X[P]"
echo " sm_60 = GP100 / P100 = DGX-1"
echo " sm_53 = GM200 [Grid] = M60, M40?"
echo " sm_52 = GM200 = GTX-Titan-X, M6000 etc."
echo " sm_50 = GM204 = GTX980, 970 etc"
echo " sm_37 = GK210 = K80"
echo " sm_35 = GK110 = K20[x], K40, GTX780, GTX-Titan, GTX-Titan-Black, GTX-Titan-Z"
echo " sm_30 = GK104 = K10, GTX680, 690 etc."
echo " sm_20 = All GF variants = C2050, 2075, M2090, GTX480, GTX580 etc."
echo " EXPERIMENTAL OPTIONS:"
echo " --compile-verbose : Turn on compile details."
echo " -profile : Use Gnu compiler profiling (>= V4.5)*"
echo " -gprofile : Use Gnu compiler GLIBC profiling (>= V4.5)*"
echo " -vtune : Enable options for use with Intel Vtune."
echo " -single-ensemble : Enable support for reading/writing single ensemble trajectories."
echo ""
echo "*NOTE: -profile and -gprofile are mutually exclusive."
echo ""
}
# ----- Script variables -------------------------------------------------------
WORKDIR=`dirname $0` # Working directory of the configure script
CURRENTDIR=`pwd` # Directory configure is being executed in
COMPILERS='' # User-specified compiler suite to use.
FLINK='' # Flag for linking in Fortran code
REQUIRES_FLINK=0 # If 1 FLINK flag required during link phase
REQUIRES_PTHREAD=0 # If 1 -lpthread required during link phase
C11FLAG='' # Flag for compiling C++11 code
C11_SUPPORT='yes' # Support C++11 code
SHARED_SUFFIX='' # Suffix for shared libraries
DBFLAG='' # Flag for turning on compiler debug symbols
DIRECTIVES='' # Common compiler directives
CPPTRAJ_INC='' # Library header include line
SFX='' # Binary suffix
EXE='' # Binary executable suffix
REBUILDOPT='' # Can be set to --rebuild and passed to get_library.sh
BUILDTESTOPT='silent' # Set to blank to avoid asking about building libraries
INSTALL_DAT='install_dat' # Target for installing data directory
#CPPTRAJSRC='' # CPPTRAJ source directory
COMPERR='cpptrajcfg.compile.err'
COMPOUT='cpptrajcfg.compile.out'
# ----- Variables for downloading libraries ------
NETCDF_SRCTAR='v4.9.2.tar.gz'
NETCDF_SRCDIR='netcdf-c-4.9.2'
NETCDF_URL="https://github.com/Unidata/netcdf-c/archive/refs/tags/$NETCDF_SRCTAR"
NETCDF_OPTS=" --disable-byterange --disable-libxml2 --disable-netcdf-4 --disable-dap --disable-nczarr $windows_hostflag --disable-shared --disable-doxygen"
NETCDF4_OPTS=" --disable-byterange --disable-libxml2 --disable-dap --disable-nczarr $windows_hostflag --disable-shared --disable-doxygen"
HDF5_SRCTAR='hdf5-1_10_9.tar.gz'
HDF5_SRCDIR='hdf5-hdf5-1_10_9'
HDF5_URL="https://github.com/HDFGroup/hdf5/archive/refs/tags/$HDF5_SRCTAR"
HDF5_OPTS=''
BZIP2_SRCTAR='bzip2-latest.tar.gz'
BZIP2_SRCDIR=''
BZIP2_URL="https://www.sourceware.org/pub/bzip2/$BZIP2_SRCTAR"
BZIP2_OPTS=''
ZLIB_SRCTAR='zlib-1.2.11.tar.gz'
ZLIB_SRCDIR='zlib-1.2.11'
ZLIB_URL="https://zlib.net/$ZLIB_SRCTAR"
ZLIB_OPTS=''
OPENBLAS_SRCTAR='OpenBLAS-0.3.13.tar.gz'
OPENBLAS_SRCDIR='OpenBLAS-0.3.13'
OPENBLAS_URL="https://github.com/xianyi/OpenBLAS/releases/download/v0.3.13/$OPENBLAS_SRCTAR"
OPENBLAS_OPTS=''
LAPACK_SRCTAR='v3.9.0.tar.gz'
LAPACK_SRCDIR='lapack-3.9.0'
LAPACK_URL="https://github.com/Reference-LAPACK/lapack/archive/$LAPACK_SRCTAR"
LAPACK_OPTS=''
PNETCDF_SRCTAR='pnetcdf-1.12.2.tar.gz'
PNETCDF_SRCDIR=''
PNETCDF_URL="https://parallel-netcdf.github.io/Release/$PNETCDF_SRCTAR"
PNETCDF_OPTS='--disable-fortran --disable-cxx'
FFTW_SRCTAR='fftw-3.3.9.tar.gz'
FFTW_SRCDIR='fftw-3.3.9'
FFTW_URL="https://fftw.org/pub/fftw/$FFTW_SRCTAR"
FFTW_OPTS='--enable-threads --with-combined-threads --with-pic --disable-fortran'
# ----- Variables for downloading MPI ------------
MPI_MPICH_SRCTAR='mpich-3.4.2.tar.gz'
MPI_MPICH_SRCDIR='mpich-3.4.2'
MPI_MPICH_URL="http://www.mpich.org/static/downloads/3.4.2/$MPI_MPICH_SRCTAR"
MPI_MPICH_OPTS='--with-device=ch3'
# ----- Configure options ------------------------
USE_CMAKE=0 # 1 = use cmake for build
COMPILE_VERBOSE=0 # 1 = show details during compile
USE_MPI=0 # 0 = no MPI, 1 = mpicc etc, 2 = mpiicc etc
USE_OPENMP=0 # 0 = no OpenMP, 1 = OpenMP
USE_CUDA=0 # 0 = no CUDA, 1 = CUDA
USE_HIP=0 # 0 = no HIP, 1 = HIP
USE_OPT=1 # 0 = no optimization, 1 = use compiler optimizations, 2 = optimize/tune.
BLAS_TYPE='other' # none|mkl|libsci(cray)|openblas|macAccelerate|other=normal BLAS
MKL_TYPE='mkl' # mkl = -mkl for Intel compilers, line = link-line advisor style
MKL_FFTW='' # If yes, use FFTW from MKL if not otherwise specified. If 'no' prevent this.
USE_DEBUG=0 # 0 = no debug info, 1 = enable compiler debug info
USE_STATIC=0 # 0 = dynamic linking, 1 = static linking, 2 = static link for specified libraries
USE_SHARED=0 # 1 = Use flag for position-independent code (required for libcpptraj)
USE_PROFILE=0 # 0 = no profiling, 1 = C++ profiling, 2 = GLIBC profiling, 3 = Intel Vtune
USE_AMBERLIB=0 # 1 = Use AMBERHOME to fill in NetCDF/BLAS/LAPACK/ARPACK as needed
BUILD_LIBS=0 # 1 = Means automatically say yes to building enabled libs when not present.
BUILD_MPI='' # If not empty, attempt to download and build specified mpi dist.
USE_SINGLEENSEMBLE=0 # Enable support for single ensemble trajectories
USE_CPPTRAJDEBUG=0 # Enable internal cpptraj debug flags
CLEAN='yes' # yes = clean after configure, no = do not
PERFORM_CHECKS='yes' # yes = Check compilers/libraries, no = do not
# Flags for large file support
LFS='-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
# Install locations
CPPTRAJHOME=''
CPPTRAJBIN=''
CPPTRAJLIB=''
CPPTRAJINC=''
CPPTRAJDAT=''
# ----- External Libraries -----------------------
# Library indices
# Original: FFT ARPACK LAPACK BLAS NETCDF PARANC BZIP ZIP READLINE XDRFILE
# Libraries containing definition of a function should appear *after*
# any source files or object files which use it.
LNETCDF=0
LPARANC=1 # Parallel NetCDF
LBZIP=2
LTNGFILE=3 # This has to come before ZLIB since it depends on ZLIB
LZIP=4
LARPACK=5
LLAPACK=6
LBLAS=7
LFFTW3=8
LREADLINE=9
LXDRFILE=10
LTIMER=11
LCUDA=12
LHIP=13
LOPENMM=14
LHDF5=15
LSANDER=16 # Make sure this comes last to avoid pulling in unnecessary symbols
# Total number of external libraries
NLIB=17
# LIB_STAT = Library status:
# off : Do not use library.
# enabled : Try to use library.
# specified : Library directory has been specified.
# amberopt : Use library from AMBERHOME - optional.
# optional : Enabled if found, disabled if not.
# bundled : Use bundled version of library.
# direct : Library location directly specified.
LIB_STAT[$LNETCDF]='enabled' # off, enabled, specified, amberopt, optional, bundled, direct
LIB_CKEY[$LNETCDF]='netcdf' # Command-line key for '-', '--with-' and '-no'
LIB_HOME[$LNETCDF]='' # Library home directory (-L<home>)
LIB_FLAG[$LNETCDF]='-lnetcdf' # Library linker flag
LIB_STTC[$LNETCDF]='libnetcdf.a' # Expected static location relative to home
LIB_D_ON[$LNETCDF]='-DBINTRAJ' # Directive if library on
LIB_DOFF[$LNETCDF]='' # Directive if library off
LIB_LINK[$LNETCDF]='dynamic' # How to link the library
LIB_TYPE[$LNETCDF]='ld' # ld = LDFLAGS, cpp = cpptraj, blank = special
LIB_STAT[$LPARANC]='off'
LIB_CKEY[$LPARANC]='pnetcdf'
LIB_HOME[$LPARANC]=''
LIB_FLAG[$LPARANC]='-lpnetcdf'
LIB_STTC[$LPARANC]='libpnetcdf.a'
LIB_D_ON[$LPARANC]='-DHAS_PNETCDF'
LIB_DOFF[$LPARANC]=''
LIB_TYPE[$LPARANC]='ld'
LIB_STAT[$LBZIP]='enabled'
LIB_CKEY[$LBZIP]='bzlib'
LIB_HOME[$LBZIP]=''
LIB_FLAG[$LBZIP]='-lbz2'
LIB_STTC[$LBZIP]='libbz2.a'
LIB_D_ON[$LBZIP]='-DHASBZ2'
LIB_DOFF[$LBZIP]=''
LIB_TYPE[$LBZIP]='ld'
LIB_STAT[$LZIP]='enabled'
LIB_CKEY[$LZIP]='zlib'
LIB_HOME[$LZIP]=''
LIB_FLAG[$LZIP]='-lz'
LIB_STTC[$LZIP]='libz.a'
LIB_D_ON[$LZIP]='-DHASGZ'
LIB_DOFF[$LZIP]=''
LIB_TYPE[$LZIP]='ld'
LIB_STAT[$LBLAS]='enabled'
LIB_CKEY[$LBLAS]='blas'
LIB_HOME[$LBLAS]=''
LIB_FLAG[$LBLAS]='-lblas'
LIB_STTC[$LBLAS]='libblas.a'
LIB_D_ON[$LBLAS]=''
LIB_DOFF[$LBLAS]='-DNO_MATHLIB'
LIB_TYPE[$LBLAS]='cpp'
LIB_STAT[$LLAPACK]='enabled'
LIB_CKEY[$LLAPACK]='lapack'
LIB_HOME[$LLAPACK]=''
LIB_FLAG[$LLAPACK]='-llapack'
LIB_STTC[$LLAPACK]='liblapack.a'
LIB_D_ON[$LLAPACK]=''
LIB_DOFF[$LLAPACK]=''
LIB_TYPE[$LLAPACK]='cpp'
LIB_STAT[$LARPACK]='bundled'
LIB_CKEY[$LARPACK]='arpack'
LIB_HOME[$LARPACK]='arpack'
LIB_FLAG[$LARPACK]='-larpack'
LIB_STTC[$LARPACK]='libarpack.a'
LIB_D_ON[$LARPACK]=''
LIB_DOFF[$LARPACK]='-DNO_ARPACK'
LIB_TYPE[$LARPACK]='cpp'
LIB_STAT[$LFFTW3]='enabled'
LIB_CKEY[$LFFTW3]='fftw3'
LIB_HOME[$LFFTW3]=''
LIB_FLAG[$LFFTW3]='-lfftw3'
LIB_STTC[$LFFTW3]='libfftw3.a'
LIB_D_ON[$LFFTW3]='-DFFTW_FFT'
LIB_DOFF[$LFFTW3]=''
LIB_TYPE[$LFFTW3]='cpp'
LIB_STAT[$LREADLINE]='bundled'
LIB_CKEY[$LREADLINE]='readline'
LIB_HOME[$LREADLINE]='readline'
LIB_FLAG[$LREADLINE]='-lreadline'
LIB_STTC[$LREADLINE]='libreadline.a'
LIB_D_ON[$LREADLINE]=''
LIB_DOFF[$LREADLINE]='-DNO_READLINE'
LIB_TYPE[$LREADLINE]=''
LIB_STAT[$LXDRFILE]='bundled'
LIB_CKEY[$LXDRFILE]='xdrfile'
LIB_HOME[$LXDRFILE]='xdrfile'
LIB_FLAG[$LXDRFILE]='-lxdrfile'
LIB_STTC[$LXDRFILE]='libxdrfile.a'
LIB_D_ON[$LXDRFILE]=''
LIB_DOFF[$LXDRFILE]='-DNO_XDRFILE'
LIB_TYPE[$LXDRFILE]='cpp'
LIB_STAT[$LSANDER]='amberopt'
LIB_CKEY[$LSANDER]='sanderlib'
LIB_HOME[$LSANDER]=''
LIB_FLAG[$LSANDER]='-lsander'
LIB_STTC[$LSANDER]=''
LIB_D_ON[$LSANDER]='-DUSE_SANDERLIB'
LIB_DOFF[$LSANDER]=''
LIB_TYPE[$LSANDER]='ld'
LIB_STAT[$LTIMER]='off'
LIB_CKEY[$LTIMER]='timer'
LIB_FLAG[$LTIMER]='-lrt'
LIB_D_ON[$LTIMER]='-DTIMER'
LIB_TYPE[$LTIMER]='ld'
LIB_STAT[$LCUDA]='off'
LIB_CKEY[$LCUDA]='cuda'
LIB_HOME[$LCUDA]=''
LIB_FLAG[$LCUDA]='-lcudart'
LIB_STTC[$LCUDA]=''
LIB_D_ON[$LCUDA]='-DCUDA'
LIB_DOFF[$LCUDA]=''
LIB_TYPE[$LCUDA]='cpp'
LIB_STAT[$LHIP]='off'
LIB_CKEY[$LHIP]='hip'
LIB_HOME[$LHIP]=''
LIB_FLAG[$LHIP]='-lamdhip64'
LIB_STTC[$LHIP]=''
# TODO: Replace __HIP_PLATFORM_HCC__ after 4.1 rocm release
LIB_D_ON[$LHIP]='-DCUDA -D__HIP_PLATFORM_HCC__'
LIB_DOFF[$LHIP]=''
LIB_TYPE[$LHIP]='cpp'
LIB_STAT[$LTNGFILE]='bundled'
LIB_CKEY[$LTNGFILE]='tng'
LIB_HOME[$LTNGFILE]='tng'
LIB_FLAG[$LTNGFILE]='-ltng_io'
LIB_STTC[$LTNGFILE]='libtng_io.a'
LIB_D_ON[$LTNGFILE]='-DHAS_TNGFILE'
LIB_DOFF[$LTNGFILE]=''
LIB_TYPE[$LTNGFILE]='cpp'
LIB_STAT[$LHDF5]='enabled'
LIB_CKEY[$LHDF5]='hdf5'
LIB_HOME[$LHDF5]=''
LIB_FLAG[$LHDF5]=''
LIB_STTC[$LHDF5]='libhdf5.a'
LIB_D_ON[$LHDF5]='-DHAS_HDF5'
LIB_DOFF[$LHDF5]=''
LIB_LINK[$LHDF5]='dynamic'
LIB_TYPE[$LHDF5]='ld'
LIB_STAT[$LOPENMM]='off'
LIB_CKEY[$LOPENMM]='openmm'
LIB_HOME[$LOPENMM]=''
LIB_FLAG[$LOPENMM]='-lOpenMM'
LIB_STTC[$LOPENMM]=''
LIB_D_ON[$LOPENMM]='-DHAS_OPENMM'
LIB_DOFF[$LOPENMM]=''
LIB_TYPE[$LOPENMM]='cpp'
for ((i=0; i < $NLIB; i++)) ; do
LIB_LINK[$i]='dynamic'
LIB_DISABLED[$i]='false'
done
#-------------------------------------------------------------------------------
# Print error message to stderr
ErrMsg() {
>&2 echo "Error: $*"
}
#-------------------------------------------------------------------------------
# Print error message to stderr and exit.
Err() {
ErrMsg $*
exit 1
}
#-------------------------------------------------------------------------------
# Print warning message to stderr
WrnMsg() {
>&2 echo "Warning: $*"
}
#-------------------------------------------------------------------------------
# Check for '--with' and '-no' library keys.
CheckLibraryKeys() {
for ((i=0; i < $NLIB; i++)) ; do
LKEY="-"${LIB_CKEY[$i]}
if [ "$1" = "$LKEY" ] ; then
# If previously bundled, clear home
if [ "${LIB_STAT[$i]}" = 'bundled' ] ; then
LIB_HOME[$i]=''
fi
LIB_STAT[$i]='enabled'
echo " ${LIB_CKEY[$i]} enabled."
return 0
fi
LKEY="--with-"${LIB_CKEY[$i]}
if [ "$1" = "$LKEY" ] ; then
LIB_HOME[$i]=$2
LIB_STAT[$i]='specified'
echo " ${LIB_CKEY[$i]} specified: $2"
return 0
fi
LKEY="-no"${LIB_CKEY[$i]}
if [ "$1" = "$LKEY" ] ; then
LIB_STAT[$i]='off'
LIB_DISABLED[$i]='true'
echo " ${LIB_CKEY[$i]} disabled."
return 0
fi
LKEY="-l"${LIB_CKEY[$i]}
if [ "$1" = "$LKEY" ] ; then
LIB_STAT[$i]='direct'
LIB_FLAG[$i]=$2
echo " ${LIB_CKEY[$i]} location directly specified: $2"
return 0
fi
LKEY="-make"${LIB_CKEY[$i]}
if [ "$1" = "$LKEY" ] ; then
# For now this only works for certain libraries.
if [ "$1" != '-makeblas' -a "$1" != '-makenetcdf' ] ; then
return 1
fi
echo " Will attempt to download and build ${LIB_CKEY[$i]}"
LIB_STAT[$i]='enabled'
LIB_MAKE[$i]='yes'
return 0
fi
done
return 1
}
#-------------------------------------------------------------------------------
# Download and build an MPI implementation
# ARGS: <implementation>
BuildMPI() {
echo "Attempting to download and build MPI $1 (may be time-consuming)..."
case "$1" in
'mpich' )
mpi_libname='mpich'
mpi_srcdir=$MPI_MPICH_SRCDIR
mpi_srctar=$MPI_MPICH_SRCTAR
mpi_url=$MPI_MPICH_URL
mpi_opts=$MPI_MPICH_OPTS
if [ "$COMPILERS" = 'gnu' ] ; then
fc_version=`$FC --version | awk '{print $4; exit 0;}' | cut -d'.' -f1`
echo "DEBUG: major version $fc_version"
if [ "$fc_version" -ge 10 ] ; then
mpi_fflags='-fallow-argument-mismatch'
fi
fi
;;
* )
Err "Unrecognized MPI: $1"
;;
esac
# Build specified MPI
PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS FC=$FC FFLAGS="$FFLAGS $mpi_fflags" LIBNAME=$mpi_libname \
SRCDIR=$mpi_srcdir SRCTAR=$mpi_srctar URL=$mpi_url ./get_library.sh --rebuild $mpi_opts
if [ $? -ne 0 ] ; then
Err "No MPI $1 available. To build without MPI do not specify the '-mpi' flag."
fi
}
#-------------------------------------------------------------------------------
# Test compile and run a program.
# ARGS: [noexe|silent|quiet] <description> <compiler> <args> <file> [<link>]
TestProgram() {
if [ $BUILD_LIBS -eq 0 ] ; then
REBUILDOPT=''
else
REBUILDOPT='--rebuild'
fi
if [ "$1" = 'noexe' ] ; then
# Output messages, do not execute compiled binary; exit on error
silent=3
shift
elif [ "$1" = 'quiet' ] ; then
# Output nothing.
silent=2
shift
elif [ "$1" = 'silent' ] ; then
# Output messages but return 1 instead of exit 1
silent=1
shift
else
# Output message; exit on error
silent=0
fi
desc="$1"
comp="$2"
args="$3"
file="$4"
link="$5 $LDFLAGS"
if [ $silent -ne 2 ] ; then echo -n "$desc: " ; fi
COMPILELINE="$comp $args -o testp $file $link"
#echo "COMPILE: $COMPILELINE" #DEBUG
$COMPILELINE > $COMPOUT 2> $COMPERR
if [ $? -ne 0 -o ! -f 'testp' ] ; then
if [ $silent -eq 0 -o $silent -eq 3 ] ; then
echo ""
ErrMsg "Test compile failed: $COMPILELINE"
ErrMsg "Check the output below for error messages:"
cat $COMPERR >&2
exit 1
else
COMPILE_ERROR_LINE=$COMPILELINE
COMPILE_ERROR_MESSAGE=`cat $COMPERR`
#echo "DEBUG: Error: $COMPILE_ERROR_LINE"
#echo "DEBUG: Error: $COMPILE_ERROR_MESSAGE"
rm $COMPERR $COMPOUT
return 1
fi
fi
if [ $silent -ne 3 ] ; then
./testp > prog.out
if [ $? -ne 0 ] ; then
echo ""
if [ $silent -eq 1 ] ; then
#echo "DEBUG silent fail: $COMPILELINE"
return 1
fi
Err "Run of test program failed, compiled with: $COMPILELINE"
fi
rm prog.out
fi
if [ $silent -ne 2 ] ; then echo "OK" ; fi
rm -f $file testp $COMPERR
return 0
}
# Error message for TestProgram silent
TestProgErr() {
desc=$1
echo "Failed."
ErrMsg "$1 build/link failed: $COMPILE_ERROR_LINE"
ErrMsg "Error message follows:"
ErrMsg "$COMPILE_ERROR_MESSAGE"
exit 1
}
# This is invoked if linking a bundled library fails.
CheckRebuild() {
desc=$1
libfile=$2
if [ -z "$REBUILDOPT" -a -f "$libfile" ] ; then
echo "Bundled $desc present but needs to be rebuilt."
REBUILDOPT='--rebuild'
fi
}
# ===== LIBRARY TESTS ==========================================================
TestBzlib() {
cat > testp.cpp <<EOF
#include <cstdio>
#include "bzlib.h"
int main() { BZFILE *bfile; bfile=NULL; printf("Testing\n"); return 0; }
EOF
TestProgram silent " Checking BZLIB" "$CXX" "$CXXFLAGS ${LIB_INCL[$LBZIP]}" testp.cpp "${LIB_FLAG[$LBZIP]}"
if [ $? -ne 0 ] ; then
if [ "${LIB_STAT[$LBZIP]}" = 'enabled' ] ; then
# See if there is already a version of BZIP2 in CPPTRAJHOME
LIB_STAT[$LBZIP]='specified'
LIB_HOME[$LBZIP]=$CPPTRAJHOME
LIB_FLAG[$LBZIP]=$CPPTRAJHOME/lib/${LIB_STTC[$LBZIP]}
LIB_INCL[$LBZIP]="-I$CPPTRAJHOME/include"
TestProgram $BUILDTESTOPT " Checking for bundled Bzip2" "$CXX" "$CXXFLAGS ${LIB_INCL[$LBZIP]}" testp.cpp "${LIB_FLAG[$LBZIP]}"
if [ $? -ne 0 ] ; then
CheckRebuild "Bzip2" "${LIB_FLAG[$LBZIP]}"
# See if user would like to get Bzip2
PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS LIBNAME='bzip2' \
SRCDIR=$BZIP2_SRCDIR SRCTAR=$BZIP2_SRCTAR URL=$BZIP2_URL ./get_library.sh $REBUILDOPT $BZIP2_OPTS
if [ $? -ne 0 ] ; then
ErrMsg "No Bzip2 available. To build without Bzip2 specify '-nobzlib'."
exit 1
fi
# Test the built Bzip2
TestProgram " Checking built Bzip2" "$CXX" "$CXXFLAGS ${LIB_INCL[$LBZIP]}" testp.cpp "${LIB_FLAG[$LBZIP]}"
fi
else
# Bzip2 specified but failed.
TestProgErr "Bzip2"
fi
fi
}
TestZlib() {
cat > testp.cpp <<EOF
#include <cstdio>
#include "zlib.h"
int main() { gzFile gfile; gfile=NULL; printf("Testing\n"); return 0; }
EOF
TestProgram silent " Checking ZLIB" "$CXX" "$CXXFLAGS ${LIB_INCL[$LZIP]}" testp.cpp "${LIB_FLAG[$LZIP]}"
if [ $? -ne 0 ] ; then
if [ "${LIB_STAT[$LZIP]}" = 'enabled' ] ; then
# See if there is already a version of ZLIB in CPPTRAJHOME
LIB_STAT[$LZIP]='specified'
LIB_HOME[$LZIP]=$CPPTRAJHOME
LIB_FLAG[$LZIP]=$CPPTRAJHOME/lib/${LIB_STTC[$LZIP]}
LIB_INCL[$LZIP]="-I$CPPTRAJHOME/include"
TestProgram $BUILDTESTOPT " Checking for bundled ZLIB" "$CXX" "$CXXFLAGS ${LIB_INCL[$LZIP]}" testp.cpp "${LIB_FLAG[$LZIP]}"
if [ $? -ne 0 ] ; then
CheckRebuild "ZLIB" "${LIB_FLAG[$LZIP]}"
# See if user would like to get ZLIB
PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS LIBNAME='zlib' \
SRCDIR=$ZLIB_SRCDIR SRCTAR=$ZLIB_SRCTAR URL=$ZLIB_URL ./get_library.sh $REBUILDOPT $ZLIB_OPTS
if [ $? -ne 0 ] ; then
ErrMsg "No ZLIB available. To build without ZLIB specify '-nozlib'."
exit 1
fi
# Test the built ZLIB
TestProgram " Checking built ZLIB" "$CXX" "$CXXFLAGS ${LIB_INCL[$LZIP]}" testp.cpp "${LIB_FLAG[$LZIP]}"
fi
else
# ZLIB specified but failed.
TestProgErr "ZLIB"
fi
fi
}
TestHdf5() {
# First, check if NetCDF has HDF5 support baked in.
cat > testp.cpp <<EOF
#include <cstdio>
#include "netcdf.h"
void unused() {
int ncid, varid;
int dims[1];
// Create a netcdf4 file
nc_create("foo.nc", NC_NETCDF4, &ncid);
// Create a dimension
dims[1] = 10;
nc_def_var(ncid, "MyVar", NC_DOUBLE, 1, dims, &varid);
// Set deflate
int err = nc_def_var_deflate(ncid, varid, NC_SHUFFLE, 1, 1);
}
int main() { printf("Testing\n"); printf("%s\n",nc_strerror(0)); return 0; }
EOF
TestProgram silent " Checking NetCDF4/HDF5" "$CXX" "$CXXFLAGS ${LIB_INCL[$LNETCDF]}" testp.cpp "${LIB_FLAG[$LNETCDF]}"
if [ $? -eq 0 ] ; then
# HDF5 support is present.
# If we are going to build our own netcdf, it needs to know how to link
# HDF5.
if [ "${LIB_MAKE[$LNETCDF]}" = 'yes' ] ; then
LIB_FLAG[$LHDF5]="-lhdf5_hl -lhdf5 -ldl ${LIB_FLAG[$LZIP]}"
fi
return 0
fi
# If netcdf was specified, this means netcdf was built without hdf5 support
if [ "${LIB_STAT[$LNETCDF]}" = 'specified' ] ; then
ErrMsg "NetCDF in '${LIB_HOME[$LNETCDF]}' does not have HDF5 support."
ErrMsg "To use this NetCDF, disable HDF5 support with '-nohdf5'."
exit 1
fi
# Check for separate HDF5
cat > testp.cpp <<EOF
#include <cstdio>
#include "hdf5.h"
void unused() {
hid_t file;
file = H5Fcreate("tmp", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
herr_t status = H5Fclose(file);
}
int main() {
printf("Testing\n");
return 0;
}
EOF
TestProgram silent " Checking HDF5" "$CXX" "$CXXFLAGS ${LIB_INCL[$LHDF5]}" testp.cpp "${LIB_FLAG[$LHDF5]}"
if [ $? -ne 0 ] ; then
if [ "${LIB_STAT[$LHDF5]}" = 'enabled' ] ; then
# See if there is already a version of HDF5 in CPPTRAJHOME
LIB_STAT[$LHDF5]='specified'
LIB_HOME[$LHDF5]=$CPPTRAJHOME
LIB_FLAG[$LHDF5]="$CPPTRAJHOME/lib/libhdf5_hl.a $CPPTRAJHOME/lib/${LIB_STTC[$LHDF5]} -ldl ${LIB_FLAG[$LZIP]}"
LIB_INCL[$LHDF5]="-I$CPPTRAJHOME/include"
TestProgram $BUILDTESTOPT " Checking for bundled HDF5" "$CXX" "$CXXFLAGS ${LIB_INCL[$LHDF5]}" testp.cpp "${LIB_FLAG[$LHDF5]}"
if [ $? -ne 0 ] ; then
CheckRebuild "HDF5" "${LIB_FLAG[$LHDF5]}"
# See if user would like to get HDF5
PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS LIBNAME='hdf5' \
SRCDIR=$HDF5_SRCDIR SRCTAR=$HDF5_SRCTAR URL=$HDF5_URL ./get_library.sh $REBUILDOPT $HDF5_OPTS
if [ $? -ne 0 ] ; then
ErrMsg "No HDF5 available. To build without HDF5 specify '-nohdf5'."
exit 1
fi
# Test the built HDF5
TestProgram " Checking built HDF5" "$CXX" "$CXXFLAGS ${LIB_INCL[$LHDF5]}" testp.cpp "${LIB_FLAG[$LHDF5]}"
fi
else
# HDF5 specified but failed.
TestProgErr "HDF5"
fi
fi
}
TestNetcdf() {
cat > testp.cpp <<EOF
#include <cstdio>
#include "netcdf.h"
void unused() {int ncid; nc_open("foo.nc", 0, &ncid);}
int main() { printf("Testing\n"); printf("%s\n",nc_strerror(0)); return 0; }
EOF
check_netcdf=0
if [ "${LIB_MAKE[$LNETCDF]}" != 'yes' ] ; then
TestProgram silent " Checking NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LNETCDF]}" testp.cpp "${LIB_FLAG[$LNETCDF]}"
check_netcdf=$?
rebuild_netcdf=$REBUILDOPT
else
rebuild_netcdf='--rebuild'
fi
if [ $check_netcdf -ne 0 -o "${LIB_MAKE[$LNETCDF]}" == 'yes' ] ; then
if [ "${LIB_STAT[$LNETCDF]}" = 'enabled' ] ; then
# See if there is already a version of NetCDF in CPPTRAJHOME
LIB_STAT[$LNETCDF]='specified'
LIB_HOME[$LNETCDF]=$CPPTRAJHOME
LIB_FLAG[$LNETCDF]=$CPPTRAJHOME/lib/${LIB_STTC[$LNETCDF]}
LIB_INCL[$LNETCDF]="-I$CPPTRAJHOME/include"
if [ "${LIB_STAT[$LHDF5]}" != 'off' ] ; then
# Netcdf needs to know where hdf5 is
LIB_FLAG[$LNETCDF]="${LIB_FLAG[$LNETCDF]} ${LIB_FLAG[$LHDF5]}"
LIB_INCL[$LNETCDF]="${LIB_INCL[$LNETCDF]} ${LIB_INCL[$LHDF5]}"
fi
TestProgram $BUILDTESTOPT " Checking for bundled NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LNETCDF]}" testp.cpp "${LIB_FLAG[$LNETCDF]}"
if [ $? -ne 0 ] ; then
# Check if lib present but needs to be rebuilt
CheckRebuild "NetCDF" "${LIB_FLAG[$LNETCDF]}"
if [ "${LIB_STAT[$LHDF5]}" != 'off' ] ; then
# Get/compile netcdf4 with HDF5
# Some of the HDF5-related portions of NetCDF4 have race conditions,
# so override MAKE_COMMAND
if [ -z "$MAKE_COMMAND" ] ; then
echo "Setting MAKE_COMMAND to 'make -j1' to avoid NetCDF4/HDF5 race conditions."
else
echo "Overriding MAKE_COMMAND with 'make -j1' to avoid NetCDF4/HDF5 race conditions."
fi
PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS LIBNAME='netcdf' MAKE_COMMAND='make -j1' \
CPPFLAGS=${LIB_INCL[$LHDF5]} LDFLAGS="-L$CPPTRAJHOME/lib" \
SRCDIR=$NETCDF_SRCDIR SRCTAR=$NETCDF_SRCTAR URL=$NETCDF_URL ./get_library.sh $rebuild_netcdf $NETCDF4_OPTS
netcdferr=$?
else
# Get/compile netcdf3
PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS LIBNAME='netcdf' \
SRCDIR=$NETCDF_SRCDIR SRCTAR=$NETCDF_SRCTAR URL=$NETCDF_URL ./get_library.sh $rebuild_netcdf $NETCDF_OPTS
netcdferr=$?
fi
if [ $netcdferr -ne 0 ] ; then
ErrMsg "No NetCDF available. To build without NetCDF specify '-nonetcdf'"
exit 1
fi
# Test the built netcdf
TestProgram " Checking built NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LNETCDF]}" testp.cpp "${LIB_FLAG[$LNETCDF]}"
fi
else
# NetCDF specified but failed.
TestProgErr "NetCDF"
fi
fi
}
TestPnetcdf() {
cat > testp.cpp <<EOF
#include <cstdio>
#include <pnetcdf.h>
void unused() {int ncid; ncmpi_open(MPI_COMM_WORLD, "foo.nc", NC_NOWRITE, MPI_INFO_NULL, &ncid);}
int main() { printf("Testing\n"); printf("%s\n",ncmpi_strerror(0)); return 0; }
EOF
TestProgram silent " Checking Parallel NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LPARANC]}" testp.cpp "${LIB_FLAG[$LPARANC]}"
pnetcdfstat=$?
# Check if pnetcdf just needs netcdf support
if [ $pnetcdfstat -ne 0 -a "${LIB_STAT[$LPARANC]}" = 'specified' ] ; then
TestProgram silent " Checking Parallel NetCDF (link to NetCDF)" "$CXX" "$CXXFLAGS ${LIB_INCL[$LPARANC]} ${LIB_INCL[$LNETCDF]}" testp.cpp "${LIB_FLAG[$LPARANC]} ${LIB_FLAG[$LNETCDF]}"
pnetcdfstat=$?
# If above check worked, pnetcdf should be linked OK with netcdf flags
return 0
#echo "DEBUG: Returned $?"
fi
if [ $pnetcdfstat -ne 0 ] ; then
if [ "${LIB_STAT[$LPARANC]}" = 'optional' ] ; then
WrnMsg "Parallel NetCDF test failed. CPPTRAJ will be built without parallel NetCDF."
LIB_STAT[$LPARANC]='off'
elif [ "${LIB_STAT[$LPARANC]}" = 'enabled' ] ; then
# See if there is already a version of parallel netcdf in CPPTRAJHOME
LIB_STAT[$LPARANC]='specified'
LIB_HOME[$LPARANC]=$CPPTRAJHOME
LIB_FLAG[$LPARANC]=$CPPTRAJHOME/lib/${LIB_STTC[$LPARANC]}
LIB_INCL[$LPARANC]="-I$CPPTRAJHOME/include"
TestProgram $BUILDTESTOPT " Checking for bundled parallel NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LPARANC]}" testp.cpp "${LIB_FLAG[$LPARANC]}"
if [ $? -ne 0 ] ; then
CheckRebuild "Pnetcdf" "${LIB_FLAG[$LPARANC]}"
# See if user would like to get parallel netcdf
PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS LIBNAME='pnetcdf' \
SRCDIR=$PNETCDF_SRCDIR SRCTAR=$PNETCDF_SRCTAR URL=$PNETCDF_URL ./get_library.sh $REBUILDOPT $PNETCDF_OPTS
if [ $? -ne 0 ] ; then
echo "Disabling parallel NetCDF support."
LIB_STAT[$LPARANC]='off'
else
# Test the built parallel netcdf
TestProgram " Checking built parallel NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LPARANC]}" testp.cpp "${LIB_FLAG[$LPARANC]}"
fi
fi
else
# Parallel NetCDF specified but failed.
TestProgErr "Pnetcdf"
fi
fi
}
DetermineFlink() {
if [ "$1" = 'silent' ] ; then
final_opt='silent'
shift
else
final_opt=''
fi
desc="$1"
flibs="$2"
# Do we already need FLINK?
if [ $REQUIRES_FLINK -eq 0 ] ; then
flink_opts="no yes"
else
flink_opts="yes"
fi
# Go through combinations of FLINK/pthread
flink_success=0
for use_flink in $flink_opts ; do
for use_pthread in no yes ; do
libs_to_use="$flibs"
if [ "$use_flink" = 'yes' ] ; then
libs_to_use="$libs_to_use $FLINK"
fi
if [ "$use_pthread" = 'yes' ] ; then
libs_to_use="$libs_to_use -lpthread"
fi
if [ "$use_flink" = 'yes' -a "$use_pthread" = 'yes' ] ; then
# Final try. Report errors here
report=$final_opt
else
report='quiet'
fi
#echo "DEBUG: Testing $desc flink $use_flink pthread $use_pthread $report"
TestProgram $report "$desc" "$CXX" "$CXXFLAGS" testp.cpp "$libs_to_use"
if [ $? -eq 0 ] ; then
# Compile/run worked.
if [ "$use_flink" = 'yes' ] ; then
REQUIRES_FLINK=1
fi
if [ "$use_pthread" = 'yes' ] ; then
REQUIRES_PTHREAD=1
fi
flink_success=1
if [ "$report" = 'quiet' ] ; then
echo "$desc: OK"
fi
return 0
elif [ "$report" = 'silent' ] ; then
# Final iteration failed
return 1
fi
done
done
if [ $flink_success -eq 0 ] ; then
# Sanity check. Should not make it here.
echo "Error: Unexpected error in DetermineFlink()."
exit 1
fi
return 0
}
TestMathlib() {
cat > testp.cpp <<EOF
#include <cstdio>
extern "C" {
void dsyev_(char*, char*, int&, double*, int&, double*,double*,int&,int&);
void dgemm_(char*, char*, int&, int&, int&, double&,
double*, int&, double*, int&, double&, double*, int&);
}
int main() {
int n_cols = 3, lwork = 102, info;
double work[102], mat[9], vec[3], alpha = 1.0;
mat[0] = 1.0; mat[1] = 1.0; mat[2] = 1.0;
mat[3] = 1.0; mat[4] = 1.0; mat[5] = 1.0;
mat[6] = 1.0; mat[7] = 1.0; mat[8] = 1.0;
dsyev_((char*)"V", (char*)"U", n_cols, mat, n_cols, vec, work, lwork, info);
dgemm_((char*)"N",(char*)"N", n_cols, n_cols, n_cols, alpha,
mat, n_cols, mat, n_cols, alpha, mat, n_cols);
printf("Testing\n"); return 0;
}
EOF
check_lblas=0
if [ "${LIB_MAKE[$LBLAS]}" != 'yes' ] ; then
DetermineFlink silent " Checking LAPACK/BLAS" "${LIB_FLAG[$LLAPACK]} ${LIB_FLAG[$LBLAS]}"
check_lblas=$?
rebuild_math=$REBUILDOPT
else
rebuild_math='--rebuild'
fi
if [ $check_lblas -ne 0 -o "${LIB_MAKE[$LBLAS]}" = 'yes' ] ; then
if [ "${LIB_STAT[$LBLAS]}" = 'enabled' ] ; then
if [ "$BLAS_TYPE" = 'openblas' ] ; then
MATH_SRCDIR=$OPENBLAS_SRCDIR
MATH_SRCTAR=$OPENBLAS_SRCTAR
MATH_URL=$OPENBLAS_URL
MATH_OPTS=$OPENBLAS_OPTS
MATH_LIBNAME='openblas'
elif [ "$BLAS_TYPE" = 'other' ] ; then
MATH_SRCDIR=$LAPACK_SRCDIR
MATH_SRCTAR=$LAPACK_SRCTAR
MATH_URL=$LAPACK_URL
MATH_OPTS=$LAPACK_OPTS
MATH_LIBNAME='lapack'
LIB_STAT[$LLAPACK]='specified'
LIB_HOME[$LLAPACK]=$CPPTRAJHOME
LIB_FLAG[$LLAPACK]=$CPPTRAJHOME/lib/${LIB_STTC[$LLAPACK]}
LIB_INCL[$LLAPACK]="-I$CPPTRAJHOME/include"
else
# Bundle not supported for this BLAS type
TestProgErr "LAPACK/BLAS"
fi
# See if there is already a version of BLAS in CPPTRAJHOME
LIB_STAT[$LBLAS]='specified'
LIB_HOME[$LBLAS]=$CPPTRAJHOME
LIB_FLAG[$LBLAS]=$CPPTRAJHOME/lib/${LIB_STTC[$LBLAS]}
LIB_INCL[$LBLAS]="-I$CPPTRAJHOME/include"
DetermineFlink $BUILDTESTOPT " Checking for bundled LAPACK/BLAS" "${LIB_FLAG[$LLAPACK]} ${LIB_FLAG[$LBLAS]}"
#TestProgram silent " Checking for bundled OpenBLAS" "$CXX" "$CXXFLAGS ${LIB_INCL[$LBLAS]}" testp.cpp "${LIB_FLAG[$LBLAS]}"
if [ $? -ne 0 ] ; then
# Check if lib present but needs to be rebuilt
CheckRebuild "LAPACK/BLAS" "${LIB_FLAG[$LBLAS]}"
# See if user would like to get blas
PREFIX=$CPPTRAJHOME CC="$CC" CFLAGS="$CFLAGS" FC="$FC" FFLAGS="$F77FLAGS" FFLAGS_NOOPT="$F77FLAGS_NOOPT" LIBNAME="$MATH_LIBNAME" \
SRCDIR=$MATH_SRCDIR SRCTAR=$MATH_SRCTAR URL=$MATH_URL ./get_library.sh $rebuild_math $MATH_OPTS
if [ $? -ne 0 ] ; then
ErrMsg "No LAPACK/BLAS available. To build without LAPACK/BLAS specify '-nomathlib'."
exit 1
fi
# Test the built openblas
DetermineFlink " Checking built LAPACK/BLAS" "${LIB_FLAG[$LLAPACK]} ${LIB_FLAG[$LBLAS]}"
#TestProgram " Checking built OpenBLAS" "$CXX" "$CXXFLAGS ${LIB_INCL[$LBLAS]}" testp.cpp "${LIB_FLAG[$LBLAS]}"
fi
else
# BLAS specified but failed.
TestProgErr "LAPACK/BLAS"
fi
fi
}
TestArpack() {
cat > testp.cpp <<EOF
#include <cstdio>
extern "C" {
void dsaupd_(int&, char&, int&, char*, int&, double&, double*,
int&, double*, int&, int*, int*, double*, double*,
int&, int&);
}
int main() {
int ival = 0;
double dval = 0.0;