-
Notifications
You must be signed in to change notification settings - Fork 5
/
configure
executable file
·230 lines (200 loc) · 5.32 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
#!/bin/bash
# ABIN local configuration generator
#
# The local build configuration is stored in make.vars,
# which is NOT under version control.
# Exit script immediately upon error
set -euo pipefail
# Output file name (do not change)
VARS=make.vars
# Default configure options
MPI=FALSE
CP2K=FALSE
PLUMED=FALSE
FFTW=FALSE
TCPB=FALSE
ABINEXE=abin
MPI_PATH=''
PFUNIT_PATH=''
PLUMED_PATH=''
CP2K_PATH=''
TCPB_PATH=''
function show_help() {
echo "
NAME
configure - generate local configuration for ABIN
SYNOPSIS
configure [--debug] [--mpi path/to/mpi] [--tcpb path/to/tcpb/lib] [--plumed path/to/plumed/lib] [--pfunit path/to/pfunit] [--cp2k]
OPTIONS
--debug Compile in debug mode
--mpi Compile with MPI support
(needed for REMD and interface with TeraChem)
--tcpb Compile with TCPB interface to TeraChem
--plumed Compile with Plumed library
--fftw Use FFTW library (needed for normal mode PIMD)
--cp2k Cross-compile with CP2K (experimental)
--pfunit Compile with unit tests using pFUnit library
(use ./install_pfunit.sh to install it first)
"
}
function check_path() {
if [[ ! -d $1 ]]; then
echo "$1 is not a directory!"
exit 1
fi
}
warning_flags="-Wall -Wno-integer-division -Wno-maybe-uninitialized"
# Overwrite default options from command line
PARAMS="$@"
while [[ $# -gt 0 ]]; do
case "$1" in
--debug)
FFLAGS="-g -O0 -fopenmp -fimplicit-none $warning_flags"
shift
;;
--mpi)
MPI=TRUE
if [[ $# -lt 2 ]]; then
echo "Error: missing MPI_PATH argument"
exit 1
fi
MPI_PATH=$2
# We allow passing "" as empty path to allow
# default system-wide MPI installations
if [[ ! -z "$MPI_PATH" ]]; then
check_path "$MPI_PATH"
fi
shift 2
;;
--tcpb)
TCPB=TRUE
if [[ $# -lt 2 ]]; then
echo "Error: missing TCPB_PATH argument"
exit 1
fi
TCPB_PATH=$2
check_path "$TCPB_PATH"
shift 2
;;
--plumed)
PLUMED=TRUE
if [[ $# -lt 2 ]]; then
echo "Error: missing PLUMED_PATH argument"
exit 1
fi
PLUMED_PATH=$2
check_path "$PLUMED_PATH"
shift 2
;;
--pfunit)
if [[ $# -lt 2 ]]; then
echo "Error: missing PFUNIT_PATH argument"
exit 1
fi
PFUNIT_PATH=$2
check_path "$PFUNIT_PATH"
shift 2
;;
--fftw)
echo "Using FFTW library, assuming it's in your LD_LIBRARY_PATH"
FFTW=TRUE
shift
;;
--cp2k)
CP2K=TRUE
shift
;;
*)
show_help
exit 1
;;
esac
done
# Set to default if FFLAGS is not defined yet, see
# https://stackoverflow.com/questions/11362250/in-bash-how-do-i-test-if-a-variable-is-defined-in-u-mode
: ${FFLAGS:="-O2 -fopenmp -fimplicit-none $warning_flags"}
if [[ -z ${FC-} ]];then
if [[ $MPI = "TRUE" ]];then
if [[ $MPI_PATH != "" ]];then
FC=$MPI_PATH/bin/mpifort
else
# By using an empty path, we presume that MPI
# is already available by default system paths
FC=mpifort
fi
else
FC="gfortran"
fi
fi
if [[ ! -f $FC && ! `which $FC` ]];then
echo "ERROR: program \"$FC\" not found"
echo "Consider exporting variable \"FC\" manually"
exit 1
fi
if [[ -z ${CXX-} ]];then
CXX="c++"
fi
CXXFLAGS="-O2 -Wall -std=c++11"
if [[ $PLUMED = "TRUE" ]];then
PLUMED_INC=${PLUMED_PATH}/lib/plumed/src/lib/Plumed.inc
if [[ ! -f ${PLUMED_INC} ]];then
echo "File $PLUMED_INC does not exist!"
exit 1
fi
fi
echo "Generating local build configuration for ABIN"
echo "Compiler info:"
$FC --version
echo "Writing config to $VARS"
# Print all vars to make.vars
rm -rf $VARS
echo "
# Local build configuration, included into Makefile
# This file was built as follows.
# $0 $PARAMS
# Name of the final binary
BIN = $ABINEXE
# Compilers
FC = $FC
CXX = $CXX
# Compiler flags
FFLAGS = $FFLAGS
CXXFLAGS = $CXXFLAGS
LDFLAGS = ${LDFLAGS-}
LDLIBS = ${LDLIBS-}
# MPI library
MPI = $MPI
MPI_PATH = $MPI_PATH
# Compilation with Plumed library
PLUMED = $PLUMED
PLUMED_INC = ${PLUMED_INC:-}
# TCBP interface to TeraChem
TCPB = $TCPB
TCPB_LIB = $TCPB_PATH
# FFTW library is typically shipped with your system
# It is needed for normal mode coordinate transformation in PIMD
FFTW = $FFTW
# Experimental cross-compilation with CP2K
CP2K = $CP2K
# Compile with unit tests
PFUNIT_PATH = $PFUNIT_PATH" > $VARS
# TODO: Make automatic check for FFTW library
if [[ $CP2K = "TRUE" ]];then
echo "Linkink with CP2K"
echo "Setup paths to CP2K libs manually in $VARS"
echo "
CP2K_PATH = /cp2k/lib/Linux-x86-64-gfortran-mkl/sopt/
LIBINT_LIB = /libint/1.1.4-gcc/lib
FFTW_LIB = /fftw/3.3.4-gcc/lib/
LIBXC_LIB = /libxc/2.1.2-gcc/lib
MKL = $(MKLROOT)/lib/intel64
MKL_LIBS = -ldl -L\$(MKL) -lmkl_blas95_lp64 -lmkl_lapack95_lp64\
-Wl,--start-group \${MKL}/libmkl_intel_lp64.a \${MKL}/libmkl_sequential.a\
\${MKL}/libmkl_core.a -Wl,--end-group -lpthread
CP2K_LIBS = \$(MKL_LIBS) \
\$(FFTW_LIB)/libfftw3.a\
\$(LIBXC_LIB)/libxc.a\
\$(LIBINT_LIB)/libderiv.a\
\$(LIBINT_LIB)/libint.a
" >> $VARS
fi