-
Notifications
You must be signed in to change notification settings - Fork 48
/
configure
executable file
·1072 lines (934 loc) · 32.1 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
###############################################################################################
# Rayleigh Configuration Script.
# This script is built around functions as much as possible.
# The "actual" script is contained with the function "main,"
# defined at the bottom of this file.
###############################################################################################
function compiler_version {
#$1 --version
VSTR=$($1 --version)
VTMP="unknown"
# List Cray first because other compilers might have Cray company name in their version string.
if [[ $VSTR == *"Cray"* ]]
then
VTMP="CRAY"
fi
if [[ $VSTR == *"Intel"* ]]
then
VTMP="INTEL"
fi
if [[ $VSTR == *"GCC"* ]]
then
VTMP="GNU"
fi
if [[ $VSTR == *"gcc"* ]]
then
VTMP="GNU"
fi
if [[ $VSTR == *"GNU"* ]]
then
VTMP="GNU"
fi
if [[ $VSTR == *"AOCC"* ]]
then
VTMP="AOCC"
fi
echo $VTMP
}
function opt_flags {
#$1 --version
if [[ $1 == "INTEL" ]]
then
# the value for heap arrays below was chosen to mimic gnu behavior
echo '-FR -fpp -r8 -O3 -shared-intel -heap-arrays 65'
fi
if [[ $1 == "GNU" ]]
then
echo '-O3 -ffixed-line-length-132'
fi
if [[ $1 == "AOCC" ]]
then
echo '-O3 -ffixed-line-length-132'
fi
if [[ $1 == "CRAY" ]]
then
echo '-O3'
fi
}
function dbg_flags {
#$1 --version
if [[ $1 == "INTEL" ]]
then
# the value for heap arrays below was chosen to mimic gnu behavior
echo '-FR -fpp -r8 -O0 -g -CB -traceback -shared-intel -heap-arrays 65'
fi
if [[ $1 == "GNU" ]]
then
echo '-O0 -g -fbounds-check -ffpe-trap=invalid,zero,overflow -fbacktrace -ffixed-line-length-132'
fi
if [[ $1 == "AOCC" ]]
then
echo '-O0 -g -ffixed-line-length-132'
fi
if [[ $1 == "CRAY" ]]
then
echo '-O0 -g'
fi
}
function displayhelp {
echo ""
echo " Rayleigh Configuration Help"
echo " ================================"
echo " "
echo " usage: ./configure [options]"
echo ""
echo ""
echo " Options passed to this script can be used to control the Fortran and C"
echo " compiler commands, including the optimization, include, and linking "
echo " flags passed to the Makefile."
echo ""
echo " This script generates the file /src/build/Machine_Definitions,"
echo " which is included by the Makefile and used to control the compilation"
echo " process. If configure fails to automatically produce a viable 'definitions'"
echo " file, you may need to specify one or more of the options below."
echo ""
echo " The configure/make/make-install process will generate two rayleigh executables "
echo " by default, compiled as follows."
echo ""
echo " rayleigh.opt: "
echo " \$FC \$FFLAGS_OPT \$INCLUDE -o rayleigh.opt {rayleigh object files} \$LIBFLAGS"
echo ""
echo " rayleigh.dbg: "
echo " \$FC \$FFLAGS_DBG \$INCLUDE -o rayleigh.dbg {rayleigh object files} \$LIBFLAGS"
echo ""
echo " All variables used in the compilation syntax above may be manipulated"
echo " by specifying options of the same name, described below. Several other"
echo " options may also be specified, which are primarily designed to fine-tune"
echo " the automatic values of these variables generated by the configure script."
echo ""
echo ""
echo " OPTIONS: "
echo ""
echo " --blank: "
echo " Causes configure to produce a blank definitions file in"
echo " <rayleigh root>/src/build/Machine_Definitions"
echo ""
echo " --CC=<C compiler name> "
echo " Specifies the C-compiler command to be invoked by Make."
echo " CC must be in your PATH, or else configure will fail. If CC"
echo " is not specified, configure will check your environment"
echo " and use the value of the \$CC environment variable, if defined."
echo " The C-compiler command DOES NOT need to be MPI-capable."
echo ""
echo " --devel / -devel "
echo " Forces Rayleigh to build with debugging flags and no."
echo " vectorization (useful for quick development builds)."
echo ""
echo " --FC=<fortran compiler name> "
echo " Specifies the Fortran compiler command to be invoked by Make."
echo " FC must be in your PATH, or else configure will fail. FC must"
echo " refer to an MPI-capable, Fortran 2003-compliant compiler. If FC"
echo " is not specified, configure will check your environment"
echo " and use the value of the \$FC environment variable, if defined."
echo ""
echo " --FFLAGS=<compilation flags>:"
echo " Used to specify both optimization and debugging flags. This is"
echo " necessary on machines that do not use the GNU or Intel compilers."
echo " If FFLAGS is set, it will override any optimization or debugging"
echo " flags automatically generated by configure. FFLAGS will also "
echo " override the values of FFLAGS_OPT and FFLAGS_DBG, if set."
echo ""
echo " --FFLAGS_DBG=<debugging flags>:"
echo " Specifies debugging flags used to compile rayleigh.dbg. This"
echo " is necessary on machines that do not use the GNU or Intel compilers."
echo " If FFLAGS_DBG is set, it will override any debugging flags that are"
echo " automatically generated by configure."
echo ""
echo " --FFLAGS_OPT=<optimization flags>:"
echo " Specifies optimization flags used to compile rayleigh.opt. This"
echo " is necessary on machines that do not use the GNU or Intel compilers."
echo " If FFLAGS_OPT is set, it will override any optimization flags that are"
echo " automatically generated by configure."
echo ""
echo " -h ; -help ; --help:"
echo " Display this message."
echo ""
echo " --INCLUDE=<include flags>"
echo " Set this flag to manually override the include flags generated by"
echo " invoking configure with --with-fftw, -mkl, or --with-mkl."
echo ""
echo " --LIBFLAGS=<library linking flags>:"
echo " Set this flag to manually specify the linking flags invoked by the"
echo " compiler. Setting this value will override any values set using the"
echo " --with-blas, --with-lapack, --with-fftw, --with-mkl, and -mkl flags."
echo ""
echo " -mkl: "
echo " Link to MKL's FFTW, LAPack, and BLAS routines."
echo " This is done automatically when using the Intel Compiler."
echo " The MKLROOT environment variable must be defined. If this"
echo " variable is undefined, call configure with the --with-mkl flag."
echo ""
echo " -conda-mkl: "
echo " Use this flag in place of -mkl and, if desired, alonside -with-mkl to account"
echo " for the conda-provided MKL directory structure."
echo " Usage Example 1: ./configure -conda-mkl "
echo " Usage Example 2: ./configure --with-mkl='/my/mkl/root' -conda-mkl "
echo ""
echo " -debian-mkl: "
echo " Use this flag in place of -mkl if you plan to use MKL as provided by"
echo " the intel-mkl package in Debian/Ubuntu."
echo ""
echo " --nodirs ; -nodirs: "
echo " Causes Make to compile Rayleigh without directory creation support."
echo " This is intended ONLY for machines where the make process fails when "
echo " linking compiled C-code to Fortran."
echo ""
echo " If Rayleigh is compiled without directory creation support, users "
echo " will need to run the make_dirs script (found in rayleigh/etc) within "
echo " each run directory they create for Rayleigh."
echo ""
echo " --openblas ; -openblas:"
echo " Set this flag to link against the OpenBLAS library"
echo " Depending on the value of --static-blas, Rayleigh will be"
echo " linked against either <BLAS ROOT>/lib/libopenblas.so or"
echo " <BLAS ROOT>/lib/libopenblas.a"
echo ""
echo " --mpi-f77 ; -mpi-f77:"
echo " Set this flag to use mpif.h instead of the MPI F90 module."
echo " This can be useful on systems where the current compiler does not"
echo " match the one used to compile MPI."
echo ""
echo " --mpi-f08 ; -mpi-f08:"
echo " Set this flag to use the newer Fortran 2008 MPI module."
echo " This needs to be supported by the MPI install."
echo " It may help with compiler errors due to type mismatches."
echo ""
echo " --prefix=<RAYLEIGH PREFIX>: "
echo " Specifies the directory in which to place Rayleigh's executables"
echo " when "make install" is run. By default, executables are placed in"
echo " rayleigh/bin. If prefix is specified, executables will be placed"
echo " in <RAYLEIGH PREFIX>\bin."
echo ""
echo " --static-blas ; -static-blas:"
echo " By default, Rayleigh will be dynamically linked to a shared BLAS "
echo " or OpenBLAS library. Set this flag to link statically instead."
echo ""
echo " --static-fftw ; -static-fftw:"
echo " By default, Rayleigh will be dynamically linked to a shared FFTW "
echo " library. Set this flag to link statically instead."
echo ""
echo " --static-lapack ; -static-lapack:"
echo " By default, Rayleigh will be dynamically linked to a shared LAPack "
echo " library. Set this flag to link statically instead."
echo ""
echo " --ifort-march ; -ifort-march:"
echo " ifort only: Use the generic -march options for architecture selection "
echo " instead of the -x options. This is needed for optimizing the code for "
echo " non-Intel CPUs."
echo ""
echo " --with-mkl=<path to the MKL root directory>"
echo " Set this value if the MKLROOT environment variable is not set on your"
echo " system, or if you wish to link against an alternative MKL installation."
echo ""
echo " On most Intel-based systems, the \$MKLROOT environment defines the "
echo " MKL root directory. If specifying this flag, be sure that you have"
echo " specified the root directory properly (see below)."
echo ""
echo " For Intel-compiler builds, verify that the following file exists:"
echo " <MKL ROOT>/include/fftw/fftw3.f "
echo ""
echo " For GNU-compiler builds, verify that the following files exist: "
echo " <MKL ROOT>/include/fftw/fftw3.f"
echo " <MKL ROOT>/lib/intel64/libmkl_gf_lp64.so"
echo " <MKL ROOT>/lib/intel64/libmkl_sequential.so"
echo " <MKL ROOT>/lib/intel64/libmkl_core.so"
echo ""
echo " --with-blas=<BLAS ROOT>"
echo " Set this flag to specify the BLAS root directory. To ensure that"
echo " the root directory is specified properly, verify that AT LEAST ONE"
echo " of the following files exist: "
echo " <BLAS ROOT>/lib/libblas.so"
echo " <BLAS ROOT>/lib/libblas.a"
echo " <BLAS ROOT>/lib/libopenblas.so"
echo " <BLAS ROOT>/lib/libopenblas.a"
echo ""
echo " --with-fftw=<FFTW ROOT>"
echo " Set this flag to specify the fftw root directory. To ensure that"
echo " the root directory is specified properly, verify that the following "
echo " files exist: "
echo " <FFTW ROOT>/include/fftw3.f"
echo " <FFTW ROOT>/lib/{ libfftw3.so OR libfftw3.a }"
echo ""
echo " --with-lapack=<LAPACK ROOT>"
echo " Set this flag to specify the LAPack root directory. To ensure that"
echo " the root directory is specified properly, verify that AT LEAST ONE"
echo " of the following files exist: "
echo " <LAPACK ROOT>/lib/liblapack.so"
echo " <LAPACK ROOT>/lib/liblapack.a"
echo ""
echo " --with-custom=<CUSTOM ROOT>"
echo " Set this flag to specify the location of custom Rayleigh source files."
echo " These files will be copied to the build directory and override any of"
echo " the standard Rayleigh source files."
echo ""
}
###############################################################################################
# MAIN
#
RAYLEIGHROOT=$PWD
PREFIX=$RAYLEIGHROOT
NEED_HELP=no
USE_MKL="FALSE"
CONDAMKL="FALSE"
DEBIANMKL="FALSE"
CUSTOMROOT="none"
###############################################################################################
#Check options and manage environment variables accordingly
for option
do
case $option in
-help | --help | -h)
displayhelp;
exit 0;
;;
--with-custom=*)
export CUSTOMROOT=`expr "x$option" : "x-*with-custom=\(.*\)"`;
;;
-prefix=* | --prefix=*)
PREFIX=`expr "x$option" : "x-*prefix=\(.*\)"`
;;
--FFLAGS=*)
RAFFLAGS=`expr "x$option" : "x-*FFLAGS=\(.*\)"`;
CUSTOMFLAGS="TRUE";
;;
--FFLAGS_OPT=*)
RAFFLAGS_OPT=`expr "x$option" : "x-*FFLAGS_OPT=\(.*\)"`;
CUSTOMOPT="TRUE";
;;
--FFLAGS_DBG=*)
RAFFLAGS_DBG=`expr "x$option" : "x-*FFLAGS_DBG=\(.*\)"`;
CUSTOMDBG="TRUE";
;;
--LIBFLAGS=*)
RALIB=`expr "x$option" : "x-*LIBFLAGS=\(.*\)"`;
CUSTOMLIB="TRUE";
;;
--INCLUDE=*)
RAINC=`expr "x$option" : "x-*INCLUDE=\(.*\)"`;
CUSTOMINC="TRUE";
;;
--FC=*)
export FC=`expr "x$option" : "x-*FC=\(.*\)"`;
;;
--nodirs | -nodirs )
NODIRS="TRUE";
;;
--devel | -devel)
DEVELMODE="TRUE";
;;
-conda-mkl)
if [ ! -z "$MKLROOT" ]
then
CONDAMKL="TRUE"
USE_MKL="TRUE"
RAMKLROOT=$MKLROOT
else
echo "Error Code 5: "
echo "MKLROOT is not defined"
echo "MKLROOT must be defined in your environment to use the -mkl flag."
echo "exiting..."
exit 5
fi
;;
-debian-mkl)
DEBIANMKL="TRUE"
USE_MKL="TRUE"
;;
-mkl)
if [ ! -z "$MKLROOT" ]
then
USE_MKL="TRUE";
RAMKLROOT=$MKLROOT
else
echo "Error Code 5: "
echo "MKLROOT is not defined"
echo "MKLROOT must be defined in your environment to use the -mkl flag."
echo "exiting..."
exit 5
fi
;;
--with-mkl=*)
RAMKLROOT=`expr "x$option" : "x-*with-mkl=\(.*\)"`;
USE_MKL="TRUE";
;;
--with-fftw=*)
FFTWROOT=`expr "x$option" : "x-*with-fftw=\(.*\)"`;
;;
--with-blas=*)
BLASROOT=`expr "x$option" : "x-*with-blas=\(.*\)"`;
;;
--openblas | -openblas )
USEOPENBLAS="TRUE";
;;
--mpi-f77 | -mpi-f77 )
USEMPIF77="TRUE";
;;
--mpi-f08 | -mpi-f08 )
USEMPIF08="TRUE";
;;
--with-lapack=*)
LPROOT=`expr "x$option" : "x-*with-lapack=\(.*\)"`;
;;
--static-blas | -static-blas )
STATICBLAS="TRUE";
;;
--static-lapack | -static-lapack )
STATICLAPACK="TRUE";
;;
--static-fftw | -static-fftw )
STATICFFTW="TRUE";
;;
--ifort-march | -ifort-march )
IFORTMARCH="TRUE";
;;
--CC=*)
export CC=`expr "x$option" : "x-*CC=\(.*\)"`;
;;
--blank)
BLANKMACHINE="TRUE";
;;
*)
echo "unknown option: $option"
exit 1
;;
esac
done
if [ "$USE_MKL" == "TRUE" ]
then
echo ""
elif [[ ! -z $FFTWROOT && ! -z $BLASROOT && ! -z $LPROOT ]];
then
echo ""
elif [[ ! -z $FFTWROOT && ! -z $BLASROOT && "$USEOPENBLAS" == "TRUE" ]]
then
echo ""
else
echo "Configuration Error: One of the three combinations must be satisfied"
echo " 1)The location of MKL is specified."
echo " 2)The location of fftw, blas, and lapack is specified."
echo " 3)The location of fftw, blas, and openblas is specified."
exit 1
fi
echo ""
echo " -----------------------------------------------------------------------------"
VERSION_FILE="VERSION"
VERSION=`cat $VERSION_FILE`
echo " Rayleigh v$VERSION Configuration"
echo " -----------------------------------------------------------------------------"
echo ""
FVERSION="unknown"
CVERSION="unknown"
if [[ $BLANKMACHINE == "TRUE" ]]
then
echo "Creating blank definitions file in $RAYLEIGHROOT/src/build/Machine_Definitions""."
cp $RAYLEIGHROOT/src/Machinefiles/machine.blank $RAYLEIGHROOT/src/build/Machine_Definitions
echo "Edit this file as appropriate, and then run 'make' from within $RAYLEIGHROOT""."
echo "PREFIX = "$PREFIX > make.inc
if [[ $NODIRS == "TRUE" ]]
then
echo "NODIRS = 1" >> make.inc
fi
if [[ $CUSTOMROOT == "none" ]]
then
echo "CUSTOMROOT = " >> make.inc
else
echo "CUSTOMROOT = "$CUSTOMROOT >> make.inc
fi
exit 0
fi
if [[ $FC == "" ]]
then
echo ""
echo "--- Error Code 1 ---"
echo "No Fortran compiler specified."
echo "Please specify a valid Fortran compiler by either: "
echo " 1) setting the FC environment variable "
echo " 2) calling this script with the --FC={compiler command} option "
echo ""
exit 1
else
#Check to see that the file exists (this seems to catch broken softlinks)
if [[ ! -e "$(which $FC)" ]]
then
echo " "
echo " --- Error Code 2 --- "
echo " Specified Fortran compiler does not exist."
echo " FC is set to: "$FC
echo " ...exiting..."
echo " "
exit 2
fi
FCOMP=$FC
FVERSION=$(compiler_version $FC)
OPT_FLAGS=$(opt_flags $FVERSION)
DBG_FLAGS=$(dbg_flags $FVERSION)
if [ "$CUSTOMOPT" == "TRUE" ]
then
echo " Overriding optimization flags."
OPT_FLAGS=$RAFFLAGS_OPT
fi
if [ "$CUSTOMDBG" == "TRUE" ]
then
echo " Overriding debug flags."
DBG_FLAGS=$RAFFLAGS_DBG
fi
if [ "$CUSTOMFLAGS" == "TRUE" ]
then
echo " Overriding all flags..,"
OPT_FLAGS=$RAFFLAGS
DBG_FLAGS=$RAFFLAGS
fi
# internally used preprocessor flags should appear after custom flags are set
if [ "$USEMPIF77" == "TRUE" ]
then
OPT_FLAGS="$OPT_FLAGS -DUSE_MPI_F77_BINDINGS"
DBG_FLAGS="$DBG_FLAGS -DUSE_MPI_F77_BINDINGS"
fi
if [ "$USEMPIF08" == "TRUE" ]
then
OPT_FLAGS="$OPT_FLAGS -DUSE_MPI_F08_BINDINGS"
DBG_FLAGS="$DBG_FLAGS -DUSE_MPI_F08_BINDINGS"
fi
if [ $FVERSION == "INTEL" ]
then
OPT_FLAGS="$OPT_FLAGS -DINTEL_COMPILER"
DBG_FLAGS="$DBG_FLAGS -DINTEL_COMPILER"
fi
if [ $FVERSION == "GNU" ]
then
OPT_FLAGS="$OPT_FLAGS -DGNU_COMPILER"
DBG_FLAGS="$DBG_FLAGS -DGNU_COMPILER"
fi
if [ $FVERSION == "AOCC" ]
then
OPT_FLAGS="$OPT_FLAGS -DAOCC_COMPILER"
DBG_FLAGS="$DBG_FLAGS -DAOCC_COMPILER"
fi
if [ $FVERSION == "CRAY" ]
then
OPT_FLAGS="$OPT_FLAGS -DCRAY_COMPILER"
DBG_FLAGS="$DBG_FLAGS -DCRAY_COMPILER"
fi
echo ' '
echo " Compiler manufacturer : " $FVERSION
echo ' Fortran compiler command : ' $FCOMP
echo ' Fortran optimization flags : ' $OPT_FLAGS
echo ' Fortran debugging flags : ' $DBG_FLAGS
if [ $FVERSION == "INTEL" ]
then
if [ ! -z "$MKLROOT" ]
then
USE_MKL="TRUE";
RAMKLROOT=$MKLROOT
echo " Intel compiler set: MKLROOT is defined"
else
echo " --- Error Code 5 --- "
echo " The MKLROOT environment variable is undefined."
echo " Please define this environment variable or "
echo " rerun configure using the --with-mkl flag."
echo " e.g., ./configure --with-mkl='/your/path/to/mkl'"
echo " exiting..."
echo ""
exit 5
fi
fi
fi
if [[ $CC == "" ]]
then
echo ""
echo "--- Error Code 3 ---"
echo "No C-compiler specified."
echo "Please specify a valid C-compiler by either: "
echo " 1) setting the CC environment variable "
echo " 2) calling this script with the --CC={compiler command} option "
echo ""
exit 1
else
#Check to see that the file exists (this seems to catch broken softlinks)
if [[ ! -e "$(which $CC)" ]]
then
echo " "
echo " --- Error Code 4 --- "
echo " Specified C-compiler does not exist."
echo " CC is set to: "$CC
#echo " Ensure that this executable is in your path."
#echo " If this is a symlink, ensure that it is not broken."
echo " ...exiting..."
echo " "
exit 2
fi
CCOMP=$CC
CVERSION=$(compiler_version $CC)
echo " C compiler command : "$CC
#echo " C compiler manufacturer : "$CVERSION
echo ' '
#Suppress the warning related to mkdir
if [[ $CVERSION == "GNU" ]]
then
CC="$CC -w"
fi
if [[ $CVERSION == "INTEL" ]]
then
CC="$CC -w"
fi
fi
DEFAULT=opt
DEBUG=dbg
RVTAGS[0]="DEFAULT"
RVTAGS[1]="DEBUG"
RVALUES[0]=$DEFAULT
RVALUES[1]=$DEBUG
FFLAGS[0]=$OPT_FLAGS
FFLAGS[1]=$DBG_FLAGS
VECLEVEL[1]=""
nvers=2
MULTIVEC=FALSE
if [[ $DEVELMODE == "TRUE" ]]
then
echo "************************************************************************"
echo " Development mode has been activated. Only rayleigh.dbg"
echo " will be compiled with debugging flags and no vectorization."
RVTAGS[0]="DEBUG"
RVALUES[0]=$DEBUG
FFLAGS[0]=$DBG_FLAGS
nvers=1
fi
if [[ $FVERSION == "INTEL" ]] && [[ $DEVELMODE != "TRUE" ]]
then
echo "***********************************************************************"
echo " Intel compiler detected. Please indicate desired SIMD instruction set."
echo ""
echo " Suggested instruction sets are: "
echo " -- Westmere cores : SSE4.2"
echo " -- Sandy Bridge / Ivy Bridge cores : AVX"
echo " -- Haswell /Broadwell : AVX2 "
echo " -- SkyLake / Knights Landing : AVX512 "
echo " -- Support for all of the above : FAT"
echo ""
OPTIONS="SSE4.2 AVX AVX2 AVX512 ALL FAT NONE"
if [[ $IFORTMARCH == TRUE ]]
then
OSSE42="-march=corei7"
OAVX="-march=corei7-avx"
OAVX2="-march=core-avx2"
# There seems to be no direct equivalent for COMMON-AVX512 using the march option.
OAVX512="-xCOMMON-AVX512 -axCORE-AVX512,MIC-AVX512"
else
OSSE42="-xSSE4.2"
OAVX="-xAVX"
OAVX2="-xCORE-AVX2"
OAVX512="-xCOMMON-AVX512 -axCORE-AVX512,MIC-AVX512"
fi
select opt in $OPTIONS; do
if [ "$opt" = "SSE4.2" ]; then
FFLAGS[0]=$OPT_FLAGS" $OSSE42"
break
elif [ "$opt" = "AVX" ]; then
FFLAGS[0]=$OPT_FLAGS" $OAVX"
break
elif [ "$opt" = "AVX2" ]; then
FFLAGS[0]=$OPT_FLAGS" $OAVX2"
break
elif [ "$opt" = "AVX512" ]; then
FFLAGS[0]=$OPT_FLAGS" $OAVX512"
break
elif [ "$opt" = "ALL" ]; then
DEFAULT='avx2'
nvers=5
MULTIVEC=TRUE
FFLAGS[0]=$OPT_FLAGS" $OAVX2"
FFLAGS[2]=$OPT_FLAGS" $OAVX"
FFLAGS[3]=$OPT_FLAGS" $OSSE42"
FFLAGS[4]=$OPT_FLAGS" $OAVX512"
RVALUES[0]=$DEFAULT
RVALUES[2]=avx
RVALUES[3]=sse
RVALUES[4]=avx512
RVTAGS[2]="AVX"
RVTAGS[3]="SSE"
RVTAGS[4]="AVX512"
break
elif [ "$opt" = "FAT" ]; then
FFLAGS[0]=$OPT_FLAGS" $OSSE42 -axAVX,CORE-AVX2,CORE-AVX512,MIC-AVX512"
break
elif [ "$opt" == "NONE" ]; then
FFLAGS[0]=$OPT_FLAGS
break
else
echo "Invalid option. Choosing no vectorization"
break
fi
done
echo "***********************************************************************"
fi
if [[ $FVERSION == "GNU" || $FVERSION == "AOCC" ]] && [[ $DEVELMODE != "TRUE" ]]
then
echo "***********************************************************************"
echo " GNU compiler detected. Please indicate desired SIMD instruction set."
echo ""
echo " Suggested instruction sets are: "
echo " -- auto-detect (make sure compiling CPU is same as compute) : native"
echo " -- Westmere cores (SSE4.2) : westmere"
echo " -- Sandy Bridge / Ivy Bridge cores (AVX) : sandybridge/ivybridge"
echo " -- Haswell / Broadwell (AVX2) : haswell/broadwell"
echo " -- SkyLake (AVX2 only) : skylake"
echo " -- SkyLake / Knights Landing (AVX512) : skylake-avx512/knl"
echo " -- separate executables for each architecture : ALL"
echo " -- no vectorization : NONE"
echo ""
CPUTYPES="native westmere sandybridge ivybridge haswell broadwell skylake skylake-avx512 knl"
OPTIONS="${CPUTYPES} ALL NONE"
select opt in $OPTIONS; do
if [ -z "$opt" ]; then
echo "Invalid option. Choosing no vectorization"
break
elif [ "$opt" = "NONE" ]; then
FFLAGS[0]=$OPT_FLAGS
break
elif [ "$opt" = "ALL" ]; then
DEFAULT='avx2'
nvers=5
MULTIVEC=TRUE
FFLAGS[0]=$OPT_FLAGS" -march=haswell"
FFLAGS[2]=$OPT_FLAGS" -march=sandybridge"
FFLAGS[3]=$OPT_FLAGS" -march=westmere"
FFLAGS[4]=$OPT_FLAGS" -march=knl"
RVALUES[0]=$DEFAULT
RVALUES[2]=avx
RVALUES[3]=sse
RVALUES[4]=avx512
RVTAGS[2]="AVX"
RVTAGS[3]="SSE"
RVTAGS[4]="AVX512"
break
fi
FFLAGS[0]="${OPT_FLAGS} -march=${opt}"
if [[ "$opt" == "native" && $FVERSION == "GNU" ]]; then
echo "CPU autodetect result: $($FC -march=native -Q --help=target|grep '^\s\+-march'|awk '{print $2}')"
fi
break
done
echo "***********************************************************************"
fi
###############################################################################################
# Set the include flags
# For now, if MKL is used, so is MKL's FFTW interface
MKLFFTW=$USE_MKL
if [[ $MKLFFTW == "TRUE" ]]
then
if [[ $CONDAMKL == "TRUE" ]]
then
RAYLEIGH_INC="-I$RAMKLROOT/include"
elif [[ $DEBIANMKL == "TRUE" ]]
then
RAYLEIGH_INC="-I/usr/include/mkl/fftw"
else
RAYLEIGH_INC="-I$RAMKLROOT/include -I$RAMKLROOT/include/fftw"
fi
else
RAYLEIGH_INC=-I$FFTWROOT/include
fi
if [ "$CUSTOMINC" == "TRUE" ]
then
RAYLEIGH_INC=$RAINC
fi
echo " Include flags : "$RAYLEIGH_INC
echo ""
###############################################################################################
# Standard LIBRARIES
if [[ $OSTYPE == *"darwin"* ]]
then
STD_FLAGS=""
else
STD_FLAGS=""
fi
###############################################################################################
# BLAS, LAPACK, and FFTW LIBRARIES
if [[ $USE_MKL == "TRUE" ]]
then
if [[ $FVERSION == "INTEL" ]]
then
LIB_FLAGS="-mkl"
elif [[ $FVERSION == "GNU" || $FVERSION == "AOCC" ]]
then
# Start by specifying the directory, unless installed by apt on debian
# in which case it is in default path
if [[ $DEBIANMKL == "FALSE" ]]
then
LIB_FLAGS="-L${RAMKLROOT}/lib"
fi
if [[ $CONDAMKL == "TRUE" ]]
then
if [[ $OSTYPE == *"darwin"* ]]
then
OS_SPECIFIC_LIB="-Wl,-rpath,${RAMKLROOT}/lib -lmkl_intel_lp64"
else
OS_SPECIFIC_LIB="-Wl,--no-as-needed -lmkl_gf_lp64"
fi
else
OS_SPECIFIC_LIB="-Wl,--no-as-needed -lmkl_gf_lp64"
fi
# Add OS independent options
LIB_FLAGS="${LIB_FLAGS} ${OS_SPECIFIC_LIB} -lmkl_sequential -lmkl_core -lpthread -lm -ldl"
fi
else
#WE NEED TO RUN CHECKS HERE
#BLAS
if [[ $USEOPENBLAS == "TRUE" ]]
then
# OPENBLAS already comes with LAPACK
if [[ $STATICBLAS == "TRUE" ]]
then
BLASLINK="-L$BLASROOT/lib/libopenblas.a"
else
BLASLINK="-L$BLASROOT/lib -lopenblas"
fi
else
if [[ $STATICBLAS == "TRUE" ]]
then
BLASLINK="-L$BLASROOT/lib/libblas.a"
else
BLASLINK="-L$BLASROOT/lib -lblas"
fi
#LAPACK
if [[ $STATICLAPACK == "TRUE" ]]
then
LAPACKLINK="-L$LPROOT/lib/liblapack.a"
else
LAPACKLINK="-L$LPROOT/lib -llapack"
fi
fi
#FFTW
if [[ $STATICFFTW == "TRUE" ]]
then
FFTWLINK="-L$FFTWROOT/lib/libfftw3.a"
else
FFTWLINK="-L$FFTWROOT/lib -lfftw3"
fi
# Combine the flags
LIB_FLAGS="${LAPACKLINK} ${FFTWLINK} ${BLASLINK}"
fi
if [ "$CUSTOMLIB" == "TRUE" ]
then
LIB_FLAGS=$RALIB
fi
echo " Library flags : "$LIB_FLAGS
echo ""
###############################################################################################
# Create a machine file
# (I) Compiler commands
OFILE=machine.temp
BORDER="################################################################################"
echo $BORDER > $OFILE
echo "# I. Compiler Commands" >> $OFILE
echo " " >> $OFILE
echo "FC = "$FC >> $OFILE
echo "CC = "$CC >> $OFILE
echo " " >> $OFILE
echo $BORDER >> $OFILE
###############################################################################################
# Output the executable version info
# (II) Rayleigh Versions
echo "# II. Version Names" >> $OFILE
echo "" >> $OFILE
COUNTER=0
while [ $COUNTER -lt $nvers ]; do
echo "${RVTAGS[$COUNTER]} = ${RVALUES[$COUNTER]}" >> $OFILE
let COUNTER=COUNTER+1
done
echo "" >> $OFILE
echo $BORDER >> $OFILE
###############################################################################################
# Create the version list
echo "# III. Whitespace-Separated List of Version Names" >> $OFILE
echo "" >> $OFILE
VLIST="VERSIONS = "
COUNTER=0
while [ $COUNTER -lt $nvers ]; do
VLIST="$VLIST \$("${RVTAGS[$COUNTER]}")"
let COUNTER=COUNTER+1
done
echo $VLIST >> $OFILE
echo $BORDER >> $OFILE
################################################################################
# IV. Include flags
echo "# IV. Include Flags" >> $OFILE
echo "" >> $OFILE
echo "RAYLEIGH_INC = "$RAYLEIGH_INC >> $OFILE
echo "" >> $OFILE
echo $BORDER >> $OFILE
################################################################################
# V. Optimization and Library flags
echo "# V. Optimization and Library Flags" >> $OFILE
echo "" >> $OFILE
COUNTER=0
while [ $COUNTER -lt $nvers ]; do
VSTR="FFLAGS_\$("${RVTAGS[$COUNTER]}")"
FSTR=${FFLAGS[$COUNTER]}" \$(RAYLEIGH_INC)" >> $OFILE
echo "$VSTR = $FSTR" >> $OFILE
VSTR="LIB_\$("${RVTAGS[$COUNTER]}")"
echo "$VSTR = $LIB_FLAGS" >> $OFILE