-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathconfigure
executable file
·1729 lines (1403 loc) · 55.7 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/sh
# !---------------------------------------------------------------------!
# ! Written by Madu Manathunga on 07/09/2020 !
# ! !
# ! Copyright (C) 2020-2021 Merz lab !
# ! Copyright (C) 2020-2021 Götz lab !
# ! !
# ! This Source Code Form is subject to the terms of the Mozilla Public !
# ! License, v. 2.0. If a copy of the MPL was not distributed with this !
# ! file, You can obtain one at http://mozilla.org/MPL/2.0/. !
# !_____________________________________________________________________!
#
# !---------------------------------------------------------------------!
# ! This source code sets up the environment for QUICK compilation and !
# ! writes input file for make. !
# !---------------------------------------------------------------------!
# !---------------------------------------------------------------------!
# ! Set version !
# !---------------------------------------------------------------------!
QUICK_VERSION='QUICK-24.03'
QUICK_HOME=`pwd`
cdate=`date +'%m/%d/%Y'`
ctime=`date +'%r'`
echo ""
echo "Configuring $QUICK_VERSION installation started on $cdate at $ctime.."
# !---------------------------------------------------------------------!
# ! function definitions !
# !---------------------------------------------------------------------!
# this function prints help page
print_help(){
echo "
Use this script as ./configure [flags] compiler
Available flags are:
--prefix <dir> User specified installation directory
--serial Builds a serial version
--mpi Compiles MPI parallel version
--cuda Builds GPU version that utilizes a single NVIDIA GPU
--cudampi Builds multi-GPU version that utilizes multiple NVIDIA GPUs
--hip Builds GPU version that utilizes a single AMD GPU
--hipmpi Builds multi-GPU version that utilizes multiple AMD GPUs
--debug Compiles debug version
--debug-time Compiles a debug version that reports more information
on timing
--profile Compiles profiling version
--shared Build shared object libraries
--arch <kepler|maxwell|pascal|volta|turing|ampere|adalovelace|hopper>
Specify gpu architecture. Applicable for cuda and
cudampi versions only. If unspecified, QUICK will be
compiled for several architectures based on the CUDA
toolkit version.
--ncores <ncore>
Specify the number of cores to be used in compilation.
If unspecified, QUICK will attempt to automatically
detect the number of cores in your system.
--enablef Enables the compilation of time consuming f functions
in the ERI code of cuda version.
--amber Install QUICK executables and libaries into AMBER.
Requires specifying AMBER home directory as prefix.
--cew Compiles source code necessary for CEW QM/MM with AMBER.
--verbose Enable full compilation output
--lapack Use matrix diagonalizer from LAPACK. BLASROOT environment
variable must be set with the correct blas installation path.
This path must contain lib and include directories.
--mkl Use matrix diagonalizer from MKL. MKLROOT environment
variable must be set with the correct mkl installation path.
This path must contain lib and include directories.
--mirp Use Boys function for ERI calculations from mirp library.
MIRP_HOME and MIRP_DEP_HOME environment variables must be set to
mirp and dependency installation directories. These paths must
contain lib and include directories.
Supported compilers are: gnu, intel, pgi, nvidia
For example, cuda version with intel compiler tool chain can be compiled as
follows:
./configure --cuda --arch volta --prefix /home/install intel
"
exit 0;
}
# this function checks if we should link libmpi_cxx.so in the mpi/cudampi version
set_mpicxx(){
mpi_cxx_flag=''
# clean test files if they already exist
rm -f test_mpicxx.c test_prog.f90 test_mpicxx.o test_prog.o test_prog
# create the dummy source files
cat > test_mpicxx.c << EOF
#include <mpi.h>
void test_func(){MPI_Init(NULL, NULL); MPI_Finalize();}
extern "C" {void test_func_(){test_func();}}
EOF
cat > test_prog.f90 << EOF
program test
call test_func()
end program test
EOF
# compile the test sources
$cxx -c test_mpicxx.c -o test_mpicxx.o 2>/dev/null >/dev/null
if [ "$?" -ne 0 ]; then
echo "Error: MPI/C++ source cannot be compiled using $cxx "
echo ""
exit 1
fi
$fort -c test_prog.f90 -o test_prog.o 2>/dev/null >/dev/null
if [ "$?" -ne 0 ]; then
echo "Error: Fortran90 source cannot be compiled using $fort "
echo ""
exit 1
fi
# try to link the object files without -lmpi_cxx and if it doesnt work set mpi_cxx_flag.
$fort test_mpicxx.o test_prog.o -o testmpi $ldflags 2>/dev/null >/dev/null
if [ "$?" -ne 0 ]; then
mpi_cxx_flag="-lmpi_cxx"
fi
# hipmpi version requires linking objects using hipcc.
if [ "$hipmpi" = 'yes' ]; then
hip_mpi_flags=`$fort -show`
hip_mpi_flags=`echo "$hip_mpi_flags" | cut -d ' ' -f2-`
fi
#try to link with libmpi_cxx
$fort test_mpicxx.o test_prog.o -o testmpi $ldflags $mpi_cxx_flag 2>/dev/null >/dev/null
if [ "$?" -ne 0 ]; then
echo "Error: Fortran90 and C++ code cannot be linked using $fort $ldflags $mpi_cxx_flag "
echo "Try to check the commands using 'mpif90 -show' "
exit 1
fi
ldflags="$ldflags $mpi_cxx_flag"
rm -f test_mpicxx.c test_prog.f90 test_mpicxx.o test_prog.o testmpi
}
# this function checks for the operating system
check_os(){
case "$OSTYPE" in
linux*) osname='linux';;
darwin*) osname='osx';;
bsd)* osname='bsd';;
solaris*) osname='solaris';;
*) osname="unknown";;
esac
if [ -z `echo "$OSTYPE"` ]; then
echo "Operating system: unknown"
else
echo "Operating system: $OSTYPE"
fi
}
# this function print compiler mistmach
print_compiler_mistmatch(){
echo "Error: Compiler version mistmatch."
echo " Fortran compiler version: $fort_version."
echo " C compiler version: $cc_version."
echo " C++ compiler version: $cxx_version."
}
# check compiler
check_compiler(){
# variables to assist detecting compiler versions
fort_search=''
cc_search=''
cxx_search=''
case "$compiler" in
gnu)
echo "Requested compiler: GNU."
if [ "$mpi" = 'no' ] && [ "$cudampi" = 'no' ] && [ "$hipmpi" = 'no' ]; then
if [ -z "$FC" ]; then fort='gfortran'; else fort="$FC";fi
if [ -z "$CC" ]; then cc='gcc'; else cc="$CC";fi
if [ -z "$CXX" ]; then cxx='g++'; else cxx="$CXX";fi
else
if [ -z "$MPIF90" ]; then fort='mpif90'; else fort="$MPIF90";fi
if [ -z "$MPICC" ]; then cc='mpicc'; else cc="$MPICC";fi
if [ -z "$MPICXX" ]; then cxx='mpicxx'; else cxx="$MPICXX";fi
fi
fort_search='gfortran'
cc_search='gcc'
cxx_search='g++'
;;
intel)
echo "Requested compiler: Intel"
if [ "$mpi" = 'no' ] && [ "$cudampi" = 'no' ] && [ "$hipmpi" = 'no' ]; then
if [ -z "$FC" ]; then fort='ifort'; else fort="$FC";fi
if [ -z "$CC" ]; then cc='icc'; else cc="$CC";fi
if [ -z "$CXX" ]; then cxx='icpc'; else cxx="$CXX";fi
else
if [ -z "$MPIF90" ]; then fort='mpiifort'; else fort="$MPIF90";fi
if [ -z "$MPICC" ]; then cc='mpiicc'; else cc="$MPICC";fi
if [ -z "$MPICXX" ]; then cxx='mpiicpc'; else cxx="$MPICXX";fi
fi
fort_search='ifort'
cc_search='icc'
cxx_search='icpc'
;;
pgi)
echo "Requested compiler: PGI."
if [ "$mpi" = 'no' ] && [ "$cudampi" = 'no' ] && [ "$hipmpi" = 'no' ]; then
if [ -z "$FC" ]; then fort='pgfortran'; else fort="$FC";fi
if [ -z "$CC" ]; then cc='pgcc'; else cc="$CC";fi
if [ -z "$CXX" ]; then cxx='pgc++'; else cxx="$CXX";fi
else
if [ -z "$MPIF90" ]; then fort='mpif90'; else fort="$MPIF90";fi
if [ -z "$MPICC" ]; then cc='mpicc'; else cc="$MPICC";fi
if [ -z "$MPICXX" ]; then cxx='mpicxx'; else cxx="$MPICXX";fi
fi
fort_search='pgfortran'
cc_search='pgcc'
cxx_search='pgc++'
;;
nvidia)
echo "Requested compiler: NVIDIA."
if [ "$hip" = 'yes' ] || [ "$hipmpi" = 'yes' ]; then
echo "Error: NVIDIA compiler cannot be used with hip/hipmpi version."
exit 1
fi
if [ "$mpi" = 'no' ] && [ "$cudampi" = 'no' ]; then
if [ -z "$FC" ]; then fort='nvfortran'; else fort="$FC";fi
if [ -z "$CC" ]; then cc='nvc'; else cc="$CC";fi
if [ -z "$CXX" ]; then cxx='nvc++'; else cxx="$CXX";fi
else
if [ -z "$MPIF90" ]; then fort='mpif90'; else fort="$MPIF90";fi
if [ -z "$MPICC" ]; then cc='mpicc'; else cc="$MPICC";fi
if [ -z "$MPICXX" ]; then cxx='mpicxx'; else cxx="$MPICXX";fi
fi
fort_search='nvfortran'
cc_search='nvc'
cxx_search='nvc++'
;;
*)
echo "Error: $compiler compiler tool chain is not supported."
exit 1;;
esac
# check for the existance of each compiler
if [ -z "`which $fort 2> /dev/null`" ]; then
echo "Error: $fort is not found."
exit 1
fi
if [ -z "`which $cc 2> /dev/null`" ]; then
echo "Error: $cc is not found."
exit 1
fi
if [ -z "`which $cxx 2> /dev/null`" ]; then
echo "Error: $cxx is not found."
exit 1
fi
# check for hipcc compiler
if [ "$hip" = 'yes' ] || [ "$hipmpi" = 'yes' ]; then
hipcc='hipcc'
if [ -z "`which $hipcc 2> /dev/null`" ]; then
echo "Error: $hipcc is not found."
exit 1
fi
fi
# general vars for compiler search
info_option='-v'
patch_seperator='.'
version_string="[0-9]{1,4}.[0-9]{1,4}$patch_seperator[0-9]{1,4}"
# pgi compilers use a different versioning output
if [ "$fort_search" = 'pgfortran' ] || [ "$fort_search" = 'nvfortran' ]; then
patch_seperator='-'
version_string='[0-9]{1,4}.[0-9]{1,4}-[0-9]{1,4}'
info_option='--version'
fi
# check the fortran compiler version
has_fort_version='no'
fort_version='not'
fort_version_major=''
fort_version_minor=''
fort_version_patch=''
fort_search_string="$fort_search\s[vV]ersion\s$version_string"
# pgi & nvidia compilers use a different version output
if [ "$fort_search" = 'pgfortran' ] || [ "$fort_search" = 'nvfortran' ]; then
fort_search_string="$fort_search\s$version_string"
fi
fort_version_info=`$fort_search $info_option 2>&1 | grep -oE "$fort_search_string"`
# some gnu installations gives off 'gcc version xx.xx.xx' instead of 'gfortran version xx.xx.xx'
if [ -z "$fort_version_info" ]; then
fort_search_string="$cc_search\s[vV]ersion\s$version_string"
fort_version_info=`$fort_search $info_option 2>&1 | grep -oE "$fort_search_string"`
fi
fort_version=`echo $fort_version_info | grep -oE "$version_string"`
if [ `echo $fort_version | grep -oE "$version_string" | wc -l` -gt 0 ]; then
has_fort_version='yes'
fort_version_major=`echo $fort_version | cut -d '.' -f1`
fort_version_minor=`echo $fort_version | cut -d '.' -f2`
fort_version_patch=`echo $fort_version | cut -d "$patch_seperator" -f3`
fi
if [ "$has_fort_version" = 'yes' ]; then
echo " $fort version $fort_version found.."
else
echo "Warning: Failed to detect $fort version."
fi
if [ "$fort_search" = 'gfortran' ] && [ "$fort_version_major" -ge 10 ]; then
fort_vspec_flags='-fallow-argument-mismatch'
fi
# check the c compiler version
has_cc_version='no'
cc_version='not'
cc_version_major=''
cc_version_minor=''
cc_version_patch=''
cc_search_string="$cc_search\s[vV]ersion\s$version_string"
# pgi & nvidia compilers use a different version output
if [ "$cc_search" = 'pgcc' ] || [ "$cc_search" = 'nvc' ]; then
cc_search_string="$cc_search\s$version_string"
fi
cc_version_info=`$cc_search $info_option 2>&1 | grep -oE "$cc_search_string"`
cc_version=`echo $cc_version_info | grep -oE "$version_string"`
if [ `echo $cc_version | grep -oE "$version_string" | wc -l` -gt 0 ]; then
has_cc_version='yes'
cc_version_major=`echo $cc_version | cut -d '.' -f1`
cc_version_minor=`echo $cc_version | cut -d '.' -f2`
cc_version_patch=`echo $cc_version | cut -d "$patch_seperator" -f3`
fi
if [ "$has_cc_version" = 'yes' ]; then
echo " $cc version $cc_version found.."
else
echo "Warning: Failed to detect $cc version."
fi
if [ "$os_name" = 'osx' ] && [ `echo $cc_version | grep -oE "$version_string" | wc -l` -lt 1 ] ; then
cc_version=`$cc_search -v 2>&1 | grep -oE "$version_string" | tail -1`
if [ `"$cc_search" -v 2>&1 | grep "clang"` -gt 0 ]; then
echo "Error: $cc compiler was requested but clang c compiler is loaded."
echo " Please load the correct compiler."
exit 1
fi
fi
# check the cxx compiler version
has_cxx_version='no'
cxx_version='not'
cxx_version_major=''
cxx_version_minor=''
cxx_version_patch=''
cxx_search_string="$cxx_search\s[vV]ersion\s$version_string"
# pgi & nvidia compilers use a different version output
if [ "$cxx_search" = 'pgc++' ]; then
cxx_search_string="pgc\+\+\s$version_string"
fi
if [ "$cxx_search" = 'nvc++' ]; then
cxx_search_string="nvc\+\+\s$version_string"
fi
cxx_version_info=`$cxx_search $info_option 2>&1 | grep -oE "$cxx_search_string"`
# some gnu installations gives off 'gcc version xx.xx.xx' instead of 'g++ version xx.xx.xx'
if [ -z "$cxx_version_info" ]; then
cxx_version_info=`$cxx_search $info_option 2>&1 | grep -oE "$cc_search\s[vV]ersion\s$version_string"`
fi
cxx_version=`echo $cxx_version_info | grep -oE "$version_string"`
if [ `echo $cxx_version | grep -oE "$version_string" | wc -l` -gt 0 ]; then
has_cxx_version='yes'
cxx_version_major=`echo $cxx_version | cut -d '.' -f1`
cxx_version_minor=`echo $cxx_version | cut -d '.' -f2`
cxx_version_patch=`echo $cxx_version | cut -d "$patch_seperator" -f3`
fi
if [ "$has_cxx_version" = 'yes' ]; then
echo " $cxx version $cxx_version found.."
else
echo "Warning: Failed to detect $cxx version."
fi
if [ "$os_name" = 'osx' ] && [ `echo $cxx_version | grep -oE "$version_string" | wc -l` -lt 1 ] ; then
cxx_version=`$cxx_search -v 2>&1 | grep -E "$cxx_search | [vV]ersion " | grep -oE "$version_string" | tail -1`
if [ `"$cxx_search" -v 2>&1 | grep "clang"` > 0 ]; then
echo "Error: $cxx compiler was requested but clang c++ compiler is loaded."
echo " Please load the correct compiler."
exit 1
fi
fi
# check for version compatibility
if [ "$has_fort_version" = 'yes' ] && [ "$has_cc_version" = 'yes' ] && [ "$has_cxx_version" = 'yes' ]; then
if [ ! "$fort_version_major" = "$cc_version_major" ] && [ ! "$fort_version_major" = "$cxx_version_major" ]; then
print_compiler_mistmatch
exit 1
elif [ ! "$fort_version_minor" = "$cc_version_minor" ] && [ ! "$fort_version_minor" = "$cxx_version_minor" ]; then
print_compiler_mistmatch
exit 1
elif [ ! "$fort_version_patch" = "$cc_version_patch" ] && [ ! "$fort_version_patch" = "$cxx_version_patch" ]; then
print_compiler_mistmatch
exit 1
fi
fi
}
# !---------------------------------------------------------------------!
# ! External library checking !
# !---------------------------------------------------------------------!
# Function to check for mkl library and dependencies.
check_mkl(){
if [ -z $MKLROOT ]; then
echo "MKL is not loaded. Inbuilt diagonalizer will be used."
return 1
fi
MKLLIBPATH=$MKLROOT/lib/intel64
if [ ! -e "$MKLLIBPATH/libmkl_intel_lp64.so" ]; then
echo "libmkl_intel_lp64.so cannot be found. Inbuilt diagonalizer will be used."
return 1
fi
if [ ! -e "$MKLLIBPATH/libmkl_intel_thread.so" ]; then
echo "libmkl_intel_thread.so cannot be found. Inbuilt diagonalizer will be used."
return 1
fi
if [ ! -e "$MKLLIBPATH/libmkl_core.so" ]; then
echo "libmkl_core.so cannot be found. Inbuilt diagonalizer will be used."
return 1
fi
}
# Function to check for lapack library and dependencies.
check_lapack(){
if [ ! -z "$BLASROOT" ]; then
if [ ! -e "$BLASROOT/lib/libopenblas.so" ]; then
echo "libopenblas.so cannot be found. Inbuilt diagonalizer will be used."
return 1
fi
else
echo "OPENBLAS is not loaded. Inbuilt diagonalizer will be used."
return 1
fi
}
# Function to check for MIRP library and dependencies.
check_mirp(){
if [ "$mirp" = 'yes' ] && [ "$shared" = 'no' ]; then
echo "Error: MIRP requires --shared flag. Plese reconfigure."
exit 1
fi
if [ -z "$MIRP_HOME" ]; then
echo "Error: MIRP_HOME is not set!"
exit 1
else
# check for the so library
if [ ! -e "$MIRP_HOME/lib/libmirp.so" ]; then
echo "Error: libmirp.so cannot be found!"
exit 1
fi
fi
# check for dependencies
if [ -z "$MIRP_DEP_HOME" ]; then
echo "Error: MIRP_DEP_HOME is not set!"
exit 1
else
# check for libarb.so
if [ ! -e "$MIRP_DEP_HOME/lib/libarb.so" ]; then
echo "Error: libarb.so cannot be found!"
exit 1
fi
# check for libgmp.so
if [ ! -e "$MIRP_DEP_HOME/lib/libgmp.so" ]; then
echo "Error: libgmp.so cannot be found!"
exit 1
fi
# check for libmpfr.so
if [ ! -e "$MIRP_DEP_HOME/lib/libmpfr.so" ]; then
echo "Error: libmpfr.so cannot be found!"
exit 1
fi
# check for libflint.so
if [ ! -e "$MIRP_DEP_HOME/lib/libflint.so" ]; then
echo "Error: libflint.so cannot be found!"
exit 1
fi
fi
}
# !---------------------------------------------------------------------!
# ! Variable definitions !
# !---------------------------------------------------------------------!
# quick version flags
serial='no'
mpi='no'
cuda='no'
cudampi='no'
hip='no'
hipmpi='no'
debug='no'
debugtime='no'
profile='no'
buildtypes=''
installers=''
# keeps track of what compilers being used
fort='no'
cc='no'
cxx='no'
nvcc='no'
hipcc='no'
# where to install
useprefix='false'
quick_prefix="$QUICK_HOME"
# operating system
osname=''
# flag to indicate if a so library compilation is required
shared='no'
# compiler specific flags
fort_flags=''
cc_flags=''
cxx_flags=''
cuda_flags=''
cpp_flags=''
hip_flags=''
# archiver related variables
arch='ar'
arch_flags='cr'
ranlib='ranlib'
libext='a'
# linker flags
ldflags=''
cflags=''
# optimization levels
opt_flags='-O2'
blas_opt_flags='-O3'
# cuda/hip architecture flags
uspec_arch='false'
cuda_arch=''
cuda_arch_flags=''
hip_arch=''
hip_arch_flags=''
# extra cuda flags
cuda_ext_flags='-m64 -use_fast_math'
cuda_dc_flags=''
hip_ext_flags='-ffast-math'
hip_dc_flags=''
hip_ld_flags=''
# cuda include flags
cuda_incl_flags=''
hip_incl_flags=''
# flags to generate PIC in so library case
lib_flags=''
cuda_lib_flags=''
hip_lib_flags=''
hip_mpi_flags=''
# debug flags
fort_debug_flags=''
cc_debug_flags=''
cxx_debug_flags=''
cuda_debug_flags=''
# profile flags
fort_profile_flags=''
cc_profile_flags=''
cxx_profile_flags=''
cuda_profile_flags=''
# compiler version specific flags
fort_vspec_flags=''
# external library specific flags
fort_ext_lib_flags=''
# set common folders
libxcobjfolder=''
libxcdevobjfolder=''
blasobjfolder=''
lapackoobjfolder=''
dlfindobjfolder=''
dftd3objfolder=''
# keep track of which build types to clean
cleantypes=''
# keep track of which versions to install and uninstall
installtypes=''
uninstalltypes=''
# keep track of type of testing (i.e. build or install)
testtype='buildtest'
# numbers of cores to be used for make
uspec_ncores='no'
ncores=''
# track if f functions should not be compiled in cuda version
enablef='no'
# amber related variables
aminstall='false'
cew='no'
# control compiler output
verbose='@'
# external math libraries
lapack='no'
mkl='no'
# flag for mirp library
mirp='no'
# !---------------------------------------------------------------------!
# ! Check user input !
# !---------------------------------------------------------------------!
if [ $# -lt 1 ]; then print_help; fi
while [ $# -gt 0 ]; do
case "$1" in
--serial) serial='yes'; buildtypes="$buildtypes serial"; cleantypes="$cleantypes serialclean"; installers="$installers quick";;
--mpi) mpi='yes'; buildtypes="$buildtypes mpi"; cleantypes="$cleantypes mpiclean"; installers="$installers quick.MPI";;
--cuda) cuda='yes'; buildtypes="$buildtypes cuda"; cleantypes="$cleantypes cudaclean"; installers="$installers quick.cuda";;
--cudampi) cudampi='yes'; buildtypes="$buildtypes cudampi"; cleantypes="$cleantypes cudampiclean"; installers="$installers quick.cuda.MPI";;
--hip) hip='yes'; buildtypes="$buildtypes hip"; cleantypes="$cleantypes hipclean"; installers="$installers quick.hip";;
--hipmpi) hipmpi='yes'; buildtypes="$buildtypes hipmpi"; cleantypes="$cleantypes hipmpiclean"; installers="$installers quick.hip.MPI";;
--debug-time) debugtime='yes';;
--debug) debug='yes';;
--profile) profile='yes';;
--verbose) verbose='';;
--mirp) mirp='yes';;
--shared) shared='yes';;
--enablef) enablef='yes';;
--amber) aminstall='true';;
--cew) cew='yes';;
--lapack) lapack='yes';;
--mkl) mkl='yes';;
--arch) shift; cuda_arch="$cuda_arch $1"; uspec_arch='true';;
--ncores) shift; ncores=$1; uspec_ncores='yes';;
--prefix) shift; quick_prefix=${1%/}; useprefix='true';;
gnu) compiler='gnu';;
intel) compiler='intel';;
pgi) compiler='pgi';;
nvidia) compiler='nvidia';;
-h| -H| -help| --help) print_help;;
*) echo "Error: $1 is an unknown flag."
echo " Run this script as './configure [flags] compiler'."
echo " Run './configure --help' for more information."
exit 1;;
esac
shift
done
# check the build type
if [ -z "$buildtypes" ]; then
echo "No build type specified."
echo "Proceeding with a serial build."
serial='yes'; buildtypes="$buildtypes serial"; cleantypes="$cleantypes serialclean"; installers="$installers quick"
else
echo "Requested installation type/s: $buildtypes"
fi
# check the os first
check_os
if [ "$cuda" = 'yes' ] || [ "$cudampi" = 'yes' ] || [ "$hip" = 'yes' ] || [ "$hipmpi" = 'yes' ] && [ ! "$osname" = 'linux' ]; then
echo "Warning: QUICK cuda/hip and cuda-mpi/hip-mpi versions have never been tested on $osname os."
fi
# check compiler
check_compiler
# check for dependencies
if [ "$mirp" = "yes" ]; then
check_mirp
fi
# check is amber installtion is required
if [ "$aminstall" = "true" ]; then
if [ "$useprefix" = "false" ]; then
echo "Error: AMBER compatible installation requires specifying the AMBER home directory as prefix."
exit 1
fi
# check for AMBER_HOME
if [ ! -d "$quick_prefix/AmberTools" ]; then
echo "Error: Please provide the correct AMBER home directory."
exit 1
else
# do this trick to get absolute path
cd "$quick_prefix"
quick_prefix=`pwd`
cd "$QUICK_HOME"
echo "QUICK will be installed into AMBER home directory $quick_prefix."
installtypes='aminstall'
uninstalltypes='amuninstall'
fi
fi
# check prefix and perform necessary operations, we shall not create these for an amber installation
if [ "$useprefix" = "true" ] && [ "$aminstall" = "false" ]; then
if [ "$QUICK_HOME" = "$quick_prefix" ]; then
echo "Error: Specified --prefix and current folder is the same. Please choose a different location. "
exit 1
elif [ ! -d "$quick_prefix" ]; then
mkdir -p "$quick_prefix"
fi
# do this trick to get absolute path
cd "$quick_prefix"
quick_prefix=`pwd`
cd "$QUICK_HOME"
echo "QUICK will be installed in $quick_prefix"
# create tests and basis directories if they dont exist
if [ ! -d "$quick_prefix/test" ]; then
mkdir -p "$quick_prefix/test"
# delete the runs directory from QUICK_HOME/test if it exists
if [ -d "$QUICK_HOME/test/runs" ]; then rm -rf $QUICK_HOME/test/runs; fi
# Copy test folder from QUICK_HOME to install folder.
echo "Copying test cases into $quick_prefix/test"
cp -rf "$QUICK_HOME/test/"* "$quick_prefix/test/"
fi
# copy the contents of basis folder since user may delete/relocate
# QUICK_HOME folder after installation
if [ ! -d "$quick_prefix/basis" ]; then
mkdir -p "$quick_prefix/basis"
cp -rf "$QUICK_HOME/basis/"* "$quick_prefix/basis/"
fi
# create bin, lib and include directories
if [ ! -d "$quick_prefix/bin" ]; then
mkdir -p "$quick_prefix/bin"
fi
for buildtype in $buildtypes; do
if [ ! -d "$quick_prefix/lib/$buildtype" ]; then
mkdir -p "$quick_prefix/lib/$buildtype"
fi
if [ ! -d "$quick_prefix/include/$buildtype" ]; then
mkdir -p "$quick_prefix/include/$buildtype"
fi
done
# create common include folder
if [ ! -d "$quick_prefix/include/common" ]; then
mkdir -p "$quick_prefix/include/common"
fi
# set install and uninstall types
install_string='install'
uninstall_string='uninstall'
for buildtype in $buildtypes; do
installtypes="$installtypes $buildtype$install_string"
uninstalltypes="$uninstalltypes $buildtype$uninstall_string"
done
fi
if [ "$useprefix" = "false" ]; then
echo "No prefix specified for the installation."
installtypes='noinstall'
uninstalltypes='nouninstall'
fi
# !---------------------------------------------------------------------!
# ! Create essential build directories !
# !---------------------------------------------------------------------!
if [ ! -d "$QUICK_HOME/bin" ]; then
mkdir -p "$QUICK_HOME/bin"
fi
for buildtype in $buildtypes; do
if [ ! -d "$QUICK_HOME/build/lib/$buildtype" ]; then
mkdir -p "$QUICK_HOME/build/lib/$buildtype"
fi
if [ ! -d "$QUICK_HOME/build/include/$buildtype" ]; then
mkdir -p "$QUICK_HOME/build/include/$buildtype"
fi
if [ ! -d "$QUICK_HOME/build/obj/$buildtype" ]; then
mkdir -p "$QUICK_HOME/build/obj/$buildtype"
fi
if [ ! -d "$QUICK_HOME/build/obj/$buildtype/main" ]; then
mkdir -p "$QUICK_HOME/build/obj/$buildtype/main"
fi
if [ "$buildtype" = 'serial' -o "$buildtype" = 'mpi' -o "$buildtype" = 'hip' -o "$buildtype" = 'hipmpi' ]; then
if [ ! -d "$QUICK_HOME/build/common/cpu/libxcobj" ]; then
mkdir -p "$QUICK_HOME/build/common/cpu/libxcobj"
fi
libxcobjfolder="$QUICK_HOME/build/common/cpu/libxcobj"
fi
if [ "$buildtype" = 'cuda' -o "$buildtype" = 'cudampi' -o "$buildtype" = 'hip' -o "$buildtype" = 'hipmpi' ]; then
if [ ! -d "$QUICK_HOME/build/common/gpu/libxcobj" ]; then
mkdir -p "$QUICK_HOME/build/common/gpu/libxcobj"
fi
libxcobjfolder="$QUICK_HOME/build/common/gpu/libxcobj"
if [ ! -d "$QUICK_HOME/build/common/gpu/libxcdevobj" ]; then
mkdir -p "$QUICK_HOME/build/common/gpu/libxcdevobj"
fi
libxcdevobjfolder="$QUICK_HOME/build/common/gpu/libxcdevobj"
fi
# create blasobj directory
if [ ! -d "$QUICK_HOME/build/common/cpu/blasobj" ]; then
mkdir -p "$QUICK_HOME/build/common/cpu/blasobj"
fi
blasobjfolder="$QUICK_HOME/build/common/cpu/blasobj"
# create lapackobj directory
if [ ! -d "$QUICK_HOME/build/common/cpu/lapackobj" ]; then
mkdir -p "$QUICK_HOME/build/common/cpu/lapackobj"
fi
lapackobjfolder="$QUICK_HOME/build/common/cpu/lapackobj"
# create dlfindobj directory
if [ ! -d "$QUICK_HOME/build/common/cpu/dlfindobj" ]; then
mkdir -p "$QUICK_HOME/build/common/cpu/dlfindobj"
fi
dlfindobjfolder="$QUICK_HOME/build/common/cpu/dlfindobj"
# create dftd3objfolder directory
if [ ! -d "$QUICK_HOME/build/common/cpu/dftd3obj" ]; then
mkdir -p "$QUICK_HOME/build/common/cpu/dftd3obj"
fi
dftd3objfolder="$QUICK_HOME/build/common/cpu/dftd3obj"
done
# create common include folder
if [ ! -d "$QUICK_HOME/build/include/common" ]; then
mkdir -p "$QUICK_HOME/build/include/common"
fi
# !---------------------------------------------------------------------!
# ! Query system information !
# !---------------------------------------------------------------------!
# set number of cores for the compilation
if [ "$uspec_ncores" = 'yes' ]; then
echo "Number of cores requested for the compilation: $ncores"
else
if [ `command -v nproc | wc -l` -gt 0 ]; then
ncores=`nproc --all`
echo "A total of $ncores cores will be used for the compilation."
else
ncores=1
echo "Only a single core will be used for the compilation."
fi
fi
# !---------------------------------------------------------------------!
# ! Check for CUDA tool kit and compiler !
# !---------------------------------------------------------------------!
# this function sets the user defined cuda architecture flags, if specified
set_uspec_arch(){
for carch in $cuda_arch; do
case "$carch" in
kepler)
echo "Configuring for SM3.5"
cuda_arch_flags="$cuda_arch_flags $sm35flags -DUSE_LEGACY_ATOMICS"
cuda_dc_flags='-Xptxas --disable-optimizer-constants';;
maxwell)
echo "Configuring for SM5.0"
cuda_arch_flags="$cuda_arch_flags $sm50flags -DUSE_LEGACY_ATOMICS"
cuda_dc_flags='-Xptxas --disable-optimizer-constants';;
pascal)
echo "Configuring for SM6.0"
cuda_arch_flags="$cuda_arch_flags $sm60flags"
cuda_dc_flags='-Xptxas --disable-optimizer-constants';;
volta)
echo "Configuring for SM7.0"
cuda_arch_flags="$cuda_arch_flags $sm70flags"
if [ `echo "$cudaversion < 10.0 "| bc` -gt 0 ]; then
cuda_dc_flags='-Xptxas --disable-optimizer-constants'
fi
;;
turing)
echo "Configuring for SM7.5"
cuda_arch_flags="$cuda_arch_flags $sm75flags";;
ampere)
echo "Configuring for SM8.0"
cuda_arch_flags="$cuda_arch_flags $sm80flags";;
adalovelace)
echo "Configuring for SM8.9"
cuda_arch_flags="$cuda_arch_flags $sm89flags";;
hopper)
echo "Configuring for SM9.0"
cuda_arch_flags="$cuda_arch_flags $sm90flags";;
esac
done
}
if [ "$cuda" = 'yes' ] || [ "$cudampi" = 'yes' ]; then
if [ -z "$CUDA_HOME" ]; then
echo "Error: CUDA_HOME environment variable is not set."
echo "Please make sure CUDA toolkit is loaded."
exit 1
fi
if [ ! -x "$CUDA_HOME/bin/nvcc" ]; then
echo "Error: nvcc compiler is not available in $CUDA_HOME/bin/"
exit 1