-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure
executable file
·295 lines (258 loc) · 10.4 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
#!/bin/bash
#******************************************************************************
# This code is part of LOWDIN Quantum chemistry package
#
# this program has been developed under direction of:
#
# Prof. A REYES' Lab. Universidad Nacional de Colombia
# http://www.qcc.unal.edu.co
# Prof. R. FLORES' Lab. Universidad de Guadalajara
# http://www.cucei.udg.mx/~robertof
#
# Todos los derechos reservados, 2013
#
#******************************************************************************
usage(){
echo "Usage:"
echo " $ ./configure [-p path/to/install] [-s path/to/scratch] [-l lapack libs] [-d] [-h] "
echo ""
echo " -p"
echo " Path to install LOWDIN"
echo " -s"
echo " Path for scratch"
echo " -l"
echo " Lapack libraries to be used"
echo " -d"
echo " Use defaults (Avoid asking for options)"
echo " -h"
echo " Print this message"
echo ""
echo "Example: ./configure -p /usr/local -s /tmp -l \"-llapack -lblas -latlas\""
echo ""
}
###########################################
# SET DEFAULTS
###########################################
FC="gfortran"
FLAGS="1"
PREFIX="/usr/local"
SCRATCH='/scratch'
CUDAFLAGS="no"
CXX="g++"
CC="gcc"
CFLAGS="-g -O2 -fopenmp -D gfortran"
CPPFLAGS="-g -O2 -fopenmp -D gfortran -std=c++11 "
FCFLAGS="-O2 -ftree-vectorize -ffast-math -fstack-arrays -fpic -fopenmp -cpp -ffree-line-length-none -fno-range-check -fallow-invalid-boz -fbacktrace -g -D gfortran"
GSL_LIBS="-lgsl -lgslcblas"
LAPACK_LIBS="-lblas -llapack"
STDCPP_LIBS="-lstdc++"
LIBINT_LIBS="-lr12 -lderiv -lint -lint2"
LIBXC_LIBS="-lxcf03 -lxc"
ALL_LIBS="$LAPACK_LIBS $LIBINT_LIBS $LIBXC_LIBS $STDCPP_LIBS $GSL_LIBS"
DEFAULTS='F'
SED=sed
if [[ $(uname -s) == Darwin ]]; then
SED=gsed
fi
############################################
# Script options
############################################
while getopts "p:s:l:dh" OPTNAME
do
case $OPTNAME in
p)
PREFIX=$OPTARG
DEFAULTS='T'
;;
s)
SCRATCH=$OPTARG
DEFAULTS='T'
;;
d)
DEFAULTS='T'
;;
l)
LAPACK_LIBS=$OPTARG
ALL_LIBS="$LAPACK_LIBS $LIBINT_LIBS $LIBXC_LIBS $STDCPP_LIBS $GSL_LIBS"
DEFAULTS='T'
;;
h)
usage
exit 0
;;
esac
done
if [[ $DEFAULTS == 'T' ]]; then
echo 'INFO: Using default configuration!'
else
###############################################################################
# LOAD OLD CONFIG
###############################################################################
if [ -e CONFIG ] ; then
FC=`awk '{if($1 == "FC" ) {for(i=3;i<=NF;i++) print $i}}' CONFIG`
FLAGS=`awk '{if($1 == "FLAGS" ) {for(i=3;i<=NF;i++) print $i}}' CONFIG`
PREFIX=`awk '{if($1 == "PREFIX" ) {for(i=3;i<=NF;i++) print $i}}' CONFIG`
SCRATCH=`awk '{if($1 == "SCRATCH" ) {for(i=3;i<=NF;i++) print $i}}' CONFIG`
CUBAFLAGS=`awk '{if($1 == "CUBAFLAGS" ) {for(i=3;i<=NF;i++) printf "%s ", $i}}' CONFIG`
CUDAFLAGS=`awk '{if($1 == "CUDAFLAGS" ) {for(i=3;i<=NF;i++) printf "%s ", $i}}' CONFIG`
CXX=`awk '{if($1 == "CXX" ) {for(i=3;i<=NF;i++) print $i}}' CONFIG`
CC=`awk '{if($1 == "CC" ) {for(i=3;i<=NF;i++) print $i}}' CONFIG`
CU=`awk '{if($1 == "CU" ) {for(i=3;i<=NF;i++) print "%s ", $i}}' CONFIG`
CFLAGS=`awk '{if($1 == "CFLAGS" ) {for(i=3;i<=NF;i++) printf "%s ", $i}}' CONFIG`
CPPFLAGS=`awk '{if($1 == "CPPFLAGS" ) {for(i=3;i<=NF;i++) printf "%s ", $i}}' CONFIG`
FCFLAGS=`awk '{if($1 == "FCFLAGS" ) {for(i=3;i<=NF;i++) printf "%s ", $i}}' CONFIG`
LAPACK_LIBS=`awk '{if($1 == "LAPACK_LIBS" ) {for(i=3;i<=NF;i++) printf "%s ", $i}}' CONFIG`
STDCPP_LIBS=`awk '{if($1 == "STDCPP_LIBS" ) {for(i=3;i<=NF;i++) printf "%s ", $i}}' CONFIG`
GSL_LIBS=`awk '{if($1 == "GSL_LIBS" ) {for(i=3;i<=NF;i++) printf "%s ", $i}}' CONFIG`
LIBINT_LIBS=`awk '{if($1 == "LIBINT_LIBS" ) {for(i=3;i<=NF;i++) printf "%s ", $i}}' CONFIG`
LIBXC_LIBS=`awk '{if($1 == "LIBXC_LIBS" ) {for(i=3;i<=NF;i++) printf "%s ", $i}}' CONFIG`
CUDA_LIBS=`awk '{if($1 == "CUDA_LIBS" ) {for(i=3;i<=NF;i++) printf "%s ", $i}}' CONFIG`
# ALL_LIBS=`awk '{if($1 == "ALL_LIBS" ) {for(i=3;i<=NF;i++) printf "%s ", $i}}' CONFIG`
fi
###############################################################################
# OPTIONS FOR FORTRAN COMPILER
###############################################################################
echo "Fortran Compiler command? [$FC]"
read FCOMP
if [ "$FCOMP" = "" ] ; then
FCOMP=$FC
fi
FC=$FCOMP
if [ "$FC" = "ifort" ] ; then
CXX="icpc"
CC="icc"
CU="nvcc -arch=sm_20"
CFLAGS="-g -O2 -D intel "
CPPFLAGS="-g -O2 -D intel -qopenmp -std=c++11 "
else
CXX=g++
CC=gcc
CU="nvcc -arch=sm_20"
CFLAGS="-g -O2 -fopenmp -D gfortran"
CPPFLAGS="-g -O2 -fopenmp -D gfortran -std=c++11"
fi
echo "Compiler Options: (1) regular, (2) backtrace and debug, (3) static (for intel fortran compiler only), (4) Full debug, (5) Highest optimization level [$FLAGS]"
read FFLAGS
if [ "$FFLAGS" = "" ] ; then
FFLAGS=$FLAGS
fi
FLAGS=$FFLAGS
echo "Speed up on GPUs? (you need to have already installed CUDA and Magma libraries): yes/no [$CUDAFLAGS]"
read FCUDAFLAGS
if [ "$FCUDAFLAGS" = "" ] ; then
FCUDAFLAGS=$CUDAFLAGS
fi
CUDAFLAGS=$FCUDAFLAGS
addflagsCuda=""
if [ "$CUDAFLAGS" = "yes" ] ; then
addflagsCuda="-D CUDA"
fi
if [ "$FLAGS" = "1" ] ; then
if [ "$FC" = "ifort" ] ; then
FCFLAGS="-O2 -D intel -fpic -qopenmp -fpp $addflagsCuda"
else
FCFLAGS="-ftree-vectorize -ffast-math -fstack-arrays -fpic -fopenmp -cpp -ffree-line-length-none -fallow-invalid-boz -fno-range-check -g -D gfortran $addflagsCuda"
fi
fi
if [ "$FLAGS" = "2" ] ; then
if [ "$FC" = "ifort" ] ; then
FCFLAGS="-O2 -D intel -fpic -qopenmp -fpp -traceback -g -debug extended $addflagsCuda "
else
FCFLAGS="-O2 -ftree-vectorize -ffast-math -fstack-arrays -fpic -fopenmp -cpp -ffree-line-length-none -fno-range-check -fbacktrace -Wunused -g -D gfortran $addflagsCuda"
fi
fi
if [ "$FLAGS" = "3" ] ; then
if [ "$FC" = "ifort" ] ; then
FCFLAGS="-static -static-intel -static-libgcc -O2 -D intel -fpic -fpp -qopenmp -traceback -g -debug extended $addflagsCuda"
else
echo "WARNING no static option for gfortran compiler, using debug and backtrace option"
FCFLAGS="-O2 -ftree-vectorize -ffast-math -fstack-arrays -fpic -fopenmp -cpp -ffree-line-length-none -fallow-invalid-boz -fno-range-check -fbacktrace -g -D gfortran $addflagsCuda"
fi
fi
if [ "$FLAGS" = "4" ] ; then
if [ "$FC" = "ifort" ] ; then
FCFLAGS="-O2 -D intel -fpic -qopenmp -fpp -traceback -g -debug extended $addflagsCuda "
else
FCFLAGS="-O2 -Wall -Wextra -Warray-temporaries -Wconversion -fimplicit-none -ffree-line-length-0 -ffpe-trap=zero,overflow,underflow -finit-real=nan -ftree-vectorize -ffast-math -fstack-arrays -fpic -fopenmp -cpp -ffree-line-length-none -fno-range-check -fallow-invalid-boz -fbacktrace -fcheck=all -g -D gfortran $addflagsCuda"
fi
fi
if [ "$FLAGS" = "5" ] ; then
if [ "$FC" = "ifort" ] ; then
FCFLAGS="-Ofast -D intel -fpic -qopenmp -fpp -traceback -g -debug extended $addflagsCuda "
else
FCFLAGS="-Ofast -ftree-vectorize -ffast-math -fstack-arrays -fpic -fopenmp -cpp -ffree-line-length-none -fallow-invalid-boz -fno-range-check -fbacktrace -g -D gfortran $addflagsCuda"
fi
fi
###############################################################################
# LIBRARIES CONFIGURATION
###############################################################################
if [ "$FC" = "ifort" ] ; then
LAPACK_LIBS="-mkl"
else
LAPACK_LIBS="-lblas -llapack"
fi
if [ "$CUDAFLAGS" = "yes" ] ; then
CUDA_LIBS="-L/usr/local/cuda/lib64 -lcuda -lcublas -lcudart"
else
CUDA_LIBS=""
fi
if [ "$FC" = "ifort" ] ; then
STDCPP_LIBS="-lstdc++ "
else
STDCPP_LIBS="-lstdc++"
fi
GSL_LIBS="-lgsl -lgslcblas"
LIBINT_LIBS="-lr12 -lderiv -lint -lint2"
ALL_LIBS="$LAPACK_LIBS $LIBINT_LIBS $LIBXC_LIBS $STDCPP_LIBS $GSL_LIBS $CUDA_LIBS"
###############################################################################
# SPECIFIC INSTALLATION DIRECTORIES
###############################################################################
echo "Installation directory? [$PREFIX]"
read BINDIR
if [ "$BINDIR" = "" ] ; then
BINDIR=$PREFIX
fi
PREFIX=$BINDIR
fi
###############################################################################
# SAVING OPTIONS
###############################################################################
echo "FC = $FC" > CONFIG
echo "FLAGS = $FLAGS" >> CONFIG
echo "PREFIX = $PREFIX" >> CONFIG
echo "SCRATCH = $SCRATCH" >> CONFIG
echo "CUBAFLAGS = $CUBAFFLAGS" >> CONFIG
echo "CUDAFLAGS = $CUDAFLAGS" >> CONFIG
echo "CXX = $CXX" >> CONFIG
echo "CC = $CC" >> CONFIG
echo "CU = $CU" >> CONFIG
echo "CFLAGS = $CFLAGS" >> CONFIG
echo "CPPFLAGS = $CPPFLAGS" >> CONFIG
echo "FCFLAGS = $FCFLAGS" >> CONFIG
echo "LAPACK_LIBS = $LAPACK_LIBS" >> CONFIG
echo "STDCPP_LIBS = $STDCPP_LIBS" >> CONFIG
echo "GSL_LIBS = $GSL_LIBS" >> CONFIG
echo "LIBINT_LIBS = $LIBINT_LIBS" >> CONFIG
echo "LIBXC_LIBS = $LIBXC_LIBS" >> CONFIG
echo "CUDA_LIBS = $CUDA_LIBS" >> CONFIG
echo "ALL_LIBS = $ALL_LIBS" >> CONFIG
echo "SED = $SED" >> CONFIG
###############################################################################
# Generate makefiles
###############################################################################
TOPDIR=`pwd`
SRCDIR="src utilities"
SUBDIRS="core ints DFT scf integralsTransformation MBPT PT CalcProp aduw gepol cosmo output CI NOCI MM molden2aim jadamilu"
for DIR in $SRCDIR ; do
cd $DIR
for SUBDIR in $SUBDIRS ; do
if [[ -e $SUBDIR ]] ; then
cd $SUBDIR
echo $SUBDIR
./configure
cd ..
fi
done
cd ..
done
echo "DONE. Now you can proceed with \"make\" command"