-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·154 lines (128 loc) · 3.61 KB
/
setup.sh
File metadata and controls
executable file
·154 lines (128 loc) · 3.61 KB
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
#!/bin/sh
#for unix-like systems (Linux, macOS, etc.)
#maybe can be adapted for unix-like environment in Windows (MSYS2?)
#choices for these for some common systems are given below,
# otherwise specify these here
FC= # fortran compiler
CC= # C compiler
OPT= # fortran compiler options
NO_FORTRAN_MAIN= # needed by some Fortran compilers if the main program is C
DEBUG= # for compiling a version useful for debugging.
#uncomment for debug versions
#DEBUG="yes"
if [ -z "$DEBUG" ] ; then
LIBNAME=liblanczos
else
LIBNAME=liblanczos_debug
fi
#preset options for some systems
GNU=
MACOS=
INTEL=
INTEL_CLASSIC=
NVIDIA=
#uncomment one of these that matches your compiler and Lapack library
#GNU="yes" #gfortran, gcc, + gfortran-compiled LAPACK/BLAS
#MACOS="yes" #gfortran+ gcc + Apple Accelerate (needs wrapped ZDOTC)
#INTEL="yes" #Intel OneAPI ifx, ifc compilers, + MKL library
#INTEL_CLASSIC="yes" #Intel ifort, icc compilers, + MKL library
#NVIDIA="yes" # NVIDIA HPC compilers + libraries from HPC SDK
if [[ -n "$MACOS" ]] ; then
FC=gfortran
CC=gcc
LAPACK="-framework Accelerate"
ZDOTC='-ff2c -fno-second-underscore'
fi
if [[ -n "$INTEL" ]] ; then
FC=ifx
CC=icx
LAPACK="-qmkl=sequential"
#LAPACK="-qmkl=parallel" #use with OpenMP
NO_FORTRAN_MAIN="-nofor-main"
fi
if [[ -n "$INTEL_CLASSIC" ]] ; then
FC=ifort
CC=icc
LAPACK="-qmkl=sequential"
#LAPACK="-qmkl=parallel" #use with OpenMP
NO_FORTRAN_MAIN="-nofor-main"
fi
if [[ -n "$NVIDIA" ]] ; then
FC=nvfortran
CC=nvc
LAPACK="-llapack -lblas"
#LAPACK="-qmkl=parallel" #use with OpenMP
NO_FORTRAN_MAIN="-Mnomain"
fi
if [[ -n "$GNU" ]] ; then
FC=gfortran
CC=gcc
LAPACK="-llapack -lblas"
NO_FORTRAN_MAIN=
fi
if [ -z "$FC" ] ; then
echo "*** No FORTRAN compiler has yet been specified ***" ;
echo "*** Edit setup.sh to fix this ***"
exit
fi
if [[ -n "$DEBUG" ]] ; then
if [[ "$FC" == "gfortran" ]] ; then
OPT2="-fcheck=all"
elif [[ "$FC" == "ifx" || "$FC" == "ifort" ]] ; then
OPT2="-check all"
else
OPT2=
fi
fi
LIB=$LIBNAME.a
#LIB=$LIBNAME_$FC.a
#remove pre-existing versions in case you are rebuilding
if [ -f $LIB ] ; then
rm $LIB
fi
cd lib
$FC $OPT -c vector_m.f90 $OPT2
$FC $OPT -c matrix_algebra_m.f90 $OPT2
$FC $OPT -c tmatrix_m.f90 $OPT2
$FC $OPT -c lanczos_m.f90 $OPT2
$FC $OPT -c *.f90 -I . $OPT2
ar -q $LIB *.o
rm *.o
rm *.mod
mv $LIB ..
cd ..
cd C_interface
$FC $OPT -c blas_settings_wrapper.f90 $OPT2
$FC $OPT -c rs_lanczos_wrapper.f90 $OPT2
$FC $OPT -c ch_lanczos_wrapper.f90 $OPT2
ar -q ../$LIB *.o
rm *.o
cd ..
ranlib $LIB
if [ -z "$LAPACK" ] ; then
echo "to build test programs, specify path to LAPACK/BLAS"
exit
fi
if [ -f test_zdotc ] ; then
rm test_zdotc
fi
echo " building test program test_zdotc"
$FC test_programs/test_zdotc.f90 $LIB $LAPACK -o test_zdotc
echo " building fortran test program test_lanczos_f"
if [ -f test_lanczos_f ] ; then
rm test_lanczos_f
fi
$FC $OPT test_programs/test_lanczos.f90 $LIB $LAPACK $OPT2 -o test_lanczos_f
if [ -z "$CC" ] ; then
echo "to build the C test program, edit setup.sh to specify your C compiler"
exit
fi
echo " building C test program test_lanczos_c "
$CC -c test_programs/test_lanczos.c -I include
if [ -f test_lanczos_c ] ; then
rm test_lanczos_c
fi
# Linking of combined C and Fortran code is done by the FC compiler
# May need $NO_FORTRAN_MAIN flag when the main program is a C program
$FC test_lanczos.o $LIB $LAPACK $NO_FORTRAN_MAIN -o test_lanczos_c
rm test_lanczos.o