forked from Amber-MD/cpptraj
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·709 lines (667 loc) · 17.2 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
#!/bin/bash
# CPPTRAJ standalone configure script
# Daniel R. Roe
# 2010-11-18
# Simple script to set compiler vars. Create config.h, which will be used
# by src/Makefile.
# Usage: ./configure [gnu/intel] OPTIONS
# Print help message
Usage() {
echo "Usage: ./configure [gnu | intel | clang | pgi] OPTIONS"
echo " OPTIONS:"
echo " --help : Display this message."
echo " -d, -debug : Turn on compiler debugging info"
echo " -openmp : Use openmp for parallelization of certain routines."
echo " -mpi : Use mpicc/mpicxx to compile."
echo " -cray : Use cray compiler wrappers (cc/CC/ftn)."
echo " -debugon : Add -DDEBUG flag to activate internal debugging"
echo " -noopt : Do not use optimized compiler flags (default when -d specified)"
echo " -nolfs : Do not enable large file support."
echo " -shared : Enable position-independent code for generating shared library."
echo ""
echo " Library linking options:"
echo " --with-netcdf=<DIR>"
echo " --with-zlib=<DIR>"
echo " --with-bzlib=<DIR>"
echo " --with-blas=<DIR>"
echo " --with-lapack=<DIR>"
echo " --with-arpack=<DIR>"
echo " -static : Use static linking."
echo " -amberlib : Use BLAS/ARPACK/LAPACK/NetCDF libraries from \$AMBERHOME"
echo " -nobzlib : Do not use libbz2 (bzip2)"
echo " -nozlib : Do not use zlib (gzip/zip)"
echo " -nonetcdf : Do not use NetCDF"
echo " -nomathlib : Do not include routines which require ARPACK, LAPACK, or BLAS"
echo ""
echo " EXPERIMENTAL OPTIONS:"
echo " -profile : Use Gnu compiler profiling (>= V4.5)"
echo " -gprofile : Use Gnu compiler GLIBC profiling (>= V4.5)"
echo " -vtune : Enable options for use with Intel Vtune"
echo " NOTE: -openmp and -mpi are mutually exclusive, as are -profile and -gprofile."
# echo " --with-hdf5=<DIR>"
}
# If arg is Key=Value, separate into Key and Value
ParseArg() {
KEY=`echo "$1" | awk 'BEGIN{FS = "=";}{print $1;}'`
VALUE=`echo "$1" | awk 'BEGIN{FS = "=";}{print $2;}'`
if [[ $VALUE = $KEY ]] ; then
VALUE=""
else
eval VALUE=$VALUE
fi
}
# CompileError "Compile Line"
# Compile error message
CompileError() {
echo " Error: Unable to compile using:"
echo " $1"
echo " Please check your compiler settings or configure flags. Error follows:"
echo " --------------------"
cat compile.err
echo " --------------------"
echo ""
exit 1
}
# TestCxxProgram "TestName" "Lib"
# Test compile test program testp.cpp
TestCxxProgram() {
echo "$1"
COMPILELINE="$CXX $CXXFLAGS -o testp testp.cpp $2"
$COMPILELINE > /dev/null 2> compile.err
./testp | grep "Testing" > /dev/null
status=$?
if [[ $status -gt 0 ]] ; then
CompileError "$COMPILELINE"
fi
/bin/rm -f testp.cpp testp
echo " OK"
}
TestBzlib() {
if [[ ! -z $BZLIB ]] ; then
cat > testp.cpp <<EOF
#include <cstdio>
#include "bzlib.h"
int main() { BZFILE *bfile; bfile=NULL; printf("Testing\n"); return 0; }
EOF
TestCxxProgram "Checking BZLIB" "$BZLIB"
fi
}
TestZlib() {
if [[ ! -z $ZLIB ]] ; then
cat > testp.cpp <<EOF
#include <cstdio>
#include "zlib.h"
int main() { gzFile gfile; gfile=NULL; printf("Testing\n"); return 0; }
EOF
TestCxxProgram "Checking ZLIB" "$ZLIB"
fi
}
TestNetcdf() {
if [[ ! -z $NETCDFLIB ]] ; then
cat > testp.cpp <<EOF
#include <cstdio>
#include "netcdf.h"
int main() { printf("Testing\n"); printf("%s\n",nc_strerror(0)); return 0; }
EOF
TestCxxProgram "Checking NetCDF" "$NETCDFLIB"
fi
}
TestMathlib() {
if [[ ! -z $ARPACK ]] ; then # Assume BLAS and LAPACK also defined
cat > testp.cpp <<EOF
#include <cstdio>
extern "C" {
void dsaupd_(int&, char&, int&, char*, int&, double&, double*,
int&, double*, int&, int*, int*, double*, double*,
int&, int&);
}
int main() {
int ival = 0;
double dval = 0.0;
char cval = 'I';
dsaupd_(ival, cval, ival, &cval, ival, dval, &dval,
ival, &dval, ival, &ival, &ival, &dval, &dval,
ival, ival);
printf("Testing\n"); return 0;
}
EOF
TestCxxProgram "Checking ARPACK/LAPACK/BLAS" "$ARPACK $LAPACK $BLAS $MKLLIB $FLIBS"
fi
}
# Test C/C++/Fortran compilers
TestCompile() {
# C
echo "Testing C compiler:"
cat > testp.c <<EOF
#include <stdio.h>
int main() { printf("Testing\n"); return 0; }
EOF
$CC $CFLAGS -o testp testp.c > /dev/null 2> compile.err
./testp | grep "Testing" > /dev/null
status=$?
if [[ $status -gt 0 ]] ; then
CompileError "$CC $CFLAGS"
fi
/bin/rm -f testp.c testp
echo " OK"
# C++
echo "Testing C++ compiler:"
cat > testp.cpp <<EOF
#include <cstdio>
int main() { printf("Testing\n"); return 0; }
EOF
$CXX $CXXFLAGS -o testp testp.cpp > /dev/null 2> compile.err
./testp | grep "Testing" > /dev/null
status=$?
if [[ $status -gt 0 ]] ; then
CompileError "$CXX $CXXFLAGS"
fi
/bin/rm -f testp.cpp testp
echo " OK"
# Fortran
echo "Testing Fortran compiler:"
cat > testp.f <<EOF
program testf
write(6,*) 'testing a Fortran program'
end program testf
EOF
$FC $FFLAGS -o testp testp.f > /dev/null 2> compile.err
./testp | grep "testing a Fortran program" > /dev/null
status=$?
if [[ $status -gt 0 ]] ; then
CompileError "$FC $FFLAGS"
fi
/bin/rm -f testp.f testp
echo " OK"
}
#---------------------------------------------------------------------
if [[ -z $1 || $1 = "--help" || $1 = "-h" ]] ; then
Usage
exit 0
fi
CONFIGURECMD="./configure $*"
KEY=""
VALUE=""
echo ""
# Process Options
ARCHITECTURE="x86_64" # TODO: Actually determine
OPT=1
USEMPI=0
USEOPENMP=0
USETIMER=0
PROFILE=0
USECRAY=0
USESHARED=0
CC=""
CXX=""
FC=""
SFX=""
CPPTRAJHOME=""
CPPTRAJBIN=""
CPPTRAJLIB=""
DIRECTIVES=""
DBGFLAGS=""
OPTFLAGS=""
OMPFLAGS=""
FFLAGS=""
FOPTFLAGS=""
PICFLAG=""
LFS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
INCLUDE=""
# Library flags
LDFLAGS=""
STATIC=0
NETCDF_HOME=""
BZLIB_HOME=""
ZLIB_HOME=""
BLAS_HOME=""
LAPACK_HOME=""
ARPACK_HOME=""
READLINE_HOME="readline"
NETCDFLIB="-lnetcdf"
BZLIB="-lbz2"
ZLIB="-lz"
BLAS="-lblas"
LAPACK="-llapack"
ARPACK="-larpack"
READLINE=$READLINE_HOME/libreadline.a
USE_AMBER_LIB=0
USEMKL=0
FLIBS=""
#HDF5LIB="-lhdf5_hl -lhdf5"
HDF5LIB=""
while [[ ! -z $1 ]] ; do
ParseArg $1
case "$KEY" in
"gnu" )
echo "Using gnu compilers"
CC=gcc
CXX=g++
FC=gfortran
OPTFLAGS="-O3 -Wall"
OMPFLAGS="-fopenmp"
FFLAGS="-ffree-form"
FOPTFLAGS="-O3"
FLIBS="$FLIBS -lgfortran -w"
PICFLAG="-fPIC"
;;
"clang" )
echo "Using clang/gfortran compilers"
CC=clang
CXX=clang++
FC=gfortran
OPTFLAGS="-O3 -Weverything"
OMPFLAGS=""
FFLAGS="-ffree-form"
FOPTFLAGS="-O3"
FLIBS="$FLIBS -lgfortran -w"
PICFLAG="-fPIC"
;;
"intel" )
echo "Using intel compilers"
CC=icc
CXX=icpc
FC=ifort
OPTFLAGS="-O3 -Wall"
OMPFLAGS="-openmp"
FFLAGS="-FR"
FOPTFLAGS="-ip -O3"
FLIBS="$FLIBS -lifport -lifcore"
PICFLAG="-fpic"
;;
"pgi" )
echo "Using PGI compilers"
CC=pgcc
CXX=pgc++
FC=pgf90
OPTFLAGS="-O2"
OMPFLAGS="-mp"
FFLAGS="-Mfree"
FOPTFLAGS="-fast -O3"
FLIBS="-pgf90libs"
PICFLAG="-fpic"
;;
"cray" )
echo "Using Cray compilers"
USECRAY=1
CC=cc
CXX=CC
FC=ftn
OPTFLAGS=""
OMPFLAGS=""
FFLAGS="-f free -emf"
FOPTFLAGS=""
FLIBS=""
PICFLAG="-fpic"
;;
"-cray" )
echo "Using cray compiler wrappers (cc/CC/ftn)"
USECRAY=1
;;
"-debug" )
echo "Turning on compiler debug info"
DBGFLAGS="-g"
;;
"-d" )
echo "Turning on compiler debug info and disabling optimization"
DBGFLAGS="-g"
OPT=0
;;
"-debugon" )
echo "Turning on cpptraj internal debug info"
DIRECTIVES="$DIRECTIVES -DDEBUG"
;;
"-noopt" )
echo "Turning off optimization"
OPT=0
;;
"-mpi" )
USEMPI=1
USEOPENMP=0
;;
"-openmp" )
USEOPENMP=1
USEMPI=0
;;
"-profile" ) PROFILE=1 ;;
"-gprofile" ) PROFILE=2 ;;
"-vtune" ) PROFILE=3 ;;
"-timer" ) USETIMER=1 ;;
"-nolfs" )
echo "Disabling large file support"
LFS=""
;;
"-static" )
echo "Using static linking."
STATIC=1
;;
"-shared" )
echo "Enabling position-independent code for generating shared library."
USESHARED=1
;;
"-amberlib" )
if [[ -z $AMBERHOME ]] ; then
echo "Error: '-amberlib' set but AMBERHOME is not defined."
echo " Set AMBERHOME and re-run configure."
exit 1
fi
echo "Using BLAS/LAPACK/ARPACK/NetCDF libraries in $AMBERHOME"
USE_AMBER_LIB=1
;;
"-mkl" )
if [[ -z $MKLROOT ]] ; then
if [[ -z $MKL_HOME ]] ; then
echo "MKLROOT/MKL_HOME not set."
exit 1
fi
MKLROOT=$MKL_HOME
fi
echo "Using MKL for BLAS/LAPACK in $MKLROOT"
USEMKL=1
;;
"-nobzlib" )
echo "Not using bzip2"
BZLIB=""
;;
"-nozlib" )
echo "Not using zlib (gzip/zip)"
ZLIB=""
;;
"-nonetcdf" )
echo "Not using netcdf"
NETCDFLIB=""
;;
"-nomathlib")
echo "Not using BLAS/LAPACK/ARPACK routines."
DIRECTIVES="$DIRECTIVES -DNO_MATHLIB"
ARPACK=""
LAPACK=""
BLAS=""
;;
"--with-bzlib" )
INCLUDE="$INCLUDE -I$VALUE/include"
BZLIB_HOME="$VALUE"
echo "Using BZIP2 in $BZLIB_HOME"
;;
"--with-zlib" )
INCLUDE="$INCLUDE -I$VALUE/include"
ZLIB_HOME="$VALUE"
echo "Using ZLIB in $ZLIB_HOME"
;;
"--with-netcdf" )
INCLUDE="$INCLUDE -I$VALUE/include"
NETCDF_HOME="$VALUE"
echo "Using NETCDF in $NETCDF_HOME"
;;
"--with-blas" )
INCLUDE="$INCLUDE -I$VALUE/include"
BLAS_HOME="$VALUE"
echo "Using BLAS in $BLAS_HOME"
;;
"--with-lapack" )
INCLUDE="$INCLUDE -I$VALUE/include"
LAPACK_HOME="$VALUE"
echo "Using LAPACK in $LAPACK_HOME"
;;
"--with-arpack" )
INCLUDE="$INCLUDE -I$VALUE/include"
ARPACK_HOME="$VALUE"
echo "Using ARPACK in $ARPACK_HOME"
;;
# "--with-hdf5" )
# INCLUDE="$INCLUDE -I$VALUE/include"
# HDF5LIB="-I$VALUE/include $VALUE/lib/libhdf5_hl.a $VALUE/lib/libhdf5.a -lm"
# echo "Using HDF5LIB: $HDF5LIB"
# ;;
"--prefix" )
CPPTRAJHOME=$VALUE
CPPTRAJBIN=$VALUE/bin
CPPTRAJLIB=$VALUE/lib
;;
* )
echo "Unrecognized OPTION: $1"
exit 1
;;
esac
shift
done
# Check install directory
if [[ -z $CPPTRAJHOME ]] ; then
# Default is to use current directory.
CPPTRAJHOME=`pwd`
CPPTRAJBIN=$CPPTRAJHOME/bin
CPPTRAJLIB=$CPPTRAJHOME/lib
elif [[ ! -e $CPPTRAJHOME ]] ; then
echo "Error: Install directory '$CPPTRAJHOME' does not exist."
exit 1
fi
echo "Installing cpptraj binary to $CPPTRAJBIN"
# Check for compilers
if [[ -z $CC || -z $CXX || -z $FC ]] ; then
echo "No compiler specified."
echo "Specify 'gnu', 'intel', or 'pgi' as an argument to ./configure"
Usage
exit 1
fi
# If no netcdf specified and AMBERHOME defined use netcdf from AMBERHOME
#if [[ $NETCDFLIB = "-lnetcdf" && ! -z $AMBERHOME ]] ; then
# echo "Using netcdf from AMBERHOME: $AMBERHOME"
# INCLUDE="$INCLUDE -I$AMBERHOME/AmberTools/src/netcdf/include"
# NETCDFLIB="-I$AMBERHOME/AmberTools/src/netcdf/include $AMBERHOME/AmberTools/src/netcdf/lib/libnetcdf.a"
#fi
# Add HDF5 flags to NETCDF
if [[ ! -z $NETCDFLIB ]] ; then
NETCDFLIB="$NETCDFLIB $HDF5LIB"
fi
# Add directives
if [[ ! -z $BZLIB ]] ; then
DIRECTIVES="$DIRECTIVES -DHASBZ2"
fi
if [[ ! -z $ZLIB ]] ; then
DIRECTIVES="$DIRECTIVES -DHASGZ"
fi
if [[ ! -z $NETCDFLIB ]] ; then
DIRECTIVES="$DIRECTIVES -DBINTRAJ"
fi
# Use libraries in AMBERHOME for stuff thats undefined
if [[ $USE_AMBER_LIB -eq 1 ]] ; then
INCLUDE="$INCLUDE -I$AMBERHOME/include"
if [[ -z $BLAS_HOME && ! -z $BLAS ]] ; then
BLAS_HOME=$AMBERHOME
fi
if [[ -z $ARPACK_HOME && ! -z $ARPACK ]] ; then
ARPACK_HOME=$AMBERHOME
fi
if [[ -z $LAPACK_HOME && ! -z $LAPACK ]] ; then
LAPACK_HOME=$AMBERHOME
fi
if [[ -z $NETCDF_HOME && ! -z $NETCDFLIB ]] ; then
NETCDF_HOME=$AMBERHOME
fi
fi
# Static/Dynamic linking options
if [[ $STATIC -eq 1 ]] ; then
# Static linking
if [[ ! -z $BLAS_HOME && ! -z $BLAS ]] ; then
BLAS="$BLAS_HOME/lib/libblas.a"
fi
if [[ ! -z $ARPACK_HOME && ! -z $ARPACK ]] ; then
ARPACK="$ARPACK_HOME/lib/libarpack.a"
fi
if [[ ! -z $LAPACK_HOME && ! -z $LAPACK ]] ; then
LAPACK="$LAPACK_HOME/lib/liblapack.a"
fi
if [[ ! -z $NETCDF_HOME && ! -z $NETCDFLIB ]] ; then
NETCDFLIB="$NETCDF_HOME/lib/libnetcdf.a"
fi
if [[ ! -z $BZLIB_HOME && ! -z $BZLIB ]] ; then
BZLIB="$BZLIB_HOME/lib/libbz2.a"
fi
if [[ ! -z $ZLIB_HOME && ! -z $ZLIB ]] ; then
ZLIB="$ZLIB_HOME/lib/libz.a"
fi
else
# Dynamic linking
if [[ ! -z $BLAS_HOME && ! -z $BLAS ]] ; then
BLAS="-L$BLAS_HOME/lib $BLAS"
fi
if [[ ! -z $ARPACK_HOME && ! -z $ARPACK ]] ; then
ARPACK="-L$ARPACK_HOME/lib $ARPACK"
fi
if [[ ! -z $LAPACK_HOME && ! -z $LAPACK ]] ; then
LAPACK="-L$LAPACK_HOME/lib $LAPACK"
fi
if [[ ! -z $NETCDF_HOME && ! -z $NETCDFLIB ]] ; then
NETCDFLIB="-L$NETCDF_HOME/lib $NETCDFLIB"
fi
if [[ ! -z $BZLIB_HOME && ! -z $BZLIB ]] ; then
BZLIB="-L$BZLIB_HOME/lib $BZLIB"
fi
if [[ ! -z $ZLIB_HOME && ! -z $ZLIB ]] ; then
ZLIB="-L$ZLIB_HOME/lib $ZLIB"
fi
fi
MKLLIB=""
if [[ $USEMKL -eq 1 ]] ; then
# Use MKL for LAPACK/BLAS
if [[ $ARCHITECTURE = "x86_64" ]] ; then
MKLINTERFACE=libmkl_intel_lp64.a
MKLROOT="$MKLROOT/lib/intel64"
BLAS="-lmkl_blas95_lp64"
LAPACK="-lmkl_lapack95_lp64"
else # Assume 32 bit
MKLINTERFACE=libmkl_intel.a
MKLROOT="$MKLROOT/lib/32"
BLAS="-lmkl_blas95"
LAPACK="-lmkl_lapack95"
fi
# Assume GNU linker.
if [[ $USEOPENMP -eq 1 ]] ; then
MKLLIB="-L$MKLROOT $LAPACK $BLAS -Wl, --start-group $MKLROOT/$MKLINTERFACE $MKLROOT/libmkl_intel_thread.a $MKLROOT/libmkl_core.a -Wl,--end-group -liomp5 -lpthread"
else
MKLLIB="-L$MKLROOT $LAPACK $BLAS -Wl,--start-group $MKLROOT/$MKLINTERFACE $MKLROOT/libmkl_sequential.a $MKLROOT/libmkl_core.a -Wl,--end-group -lpthread"
fi
BLAS=""
LAPACK=""
fi
# Set up linking flags
LDFLAGS="$ARPACK $LAPACK $BLAS $MKLLIB $NETCDFLIB $BZLIB $ZLIB $FLIBS"
# Add options for Timer
if [[ $USETIMER -eq 1 ]] ; then
DIRECTIVES="$DIRECTIVES -DTIMER"
LDFLAGS="$LDFLAGS -lrt"
fi
# For pgi on cray modify some flags
if [[ $USECRAY -eq 1 && $CC = "pgcc" ]] ; then
OPTFLAGS="-fast"
OMPFLAGS="-mp=nonuma"
FOPTFLAGS="-fast"
fi
# Add flags for OPENMP if specified
if [[ $USEOPENMP -eq 1 ]] ; then
if [[ $CC = "clang" ]] ; then
echo "Error: clang compiler does not yet support OpenMP."
exit 1
fi
echo "Using OPENMP"
DIRECTIVES="$OMPFLAGS $DIRECTIVES"
LDFLAGS="$OMPFLAGS $LDFLAGS"
SFX=".OMP"
fi
# Remove opt flags if specified
if [[ $OPT -eq 0 ]] ; then
OPTFLAGS=""
FOPTFLAGS=""
DBGFLAGS="$DBGFLAGS -O0"
fi
# Add cray-specific flags
if [[ $CC = "cc" ]] ; then
OPTFLAGS="-h gnu "$OPTFLAGS
if [[ $USEOPENMP -eq 0 ]] ; then
DIRECTIVES="-h noomp "$DIRECTIVES
fi
fi
# Change to MPI compiler wrappers if specified
if [[ $USEMPI -eq 1 ]] ; then
echo "Using MPI"
DIRECTIVES="$DIRECTIVES -DMPI"
CC=mpicc
CXX=mpicxx
FC=mpif90
SFX=".MPI"
fi
# Set up compiler flags
CFLAGS="$DBGFLAGS $OPTFLAGS $DIRECTIVES $LFS $INCLUDE"
CXXFLAGS="$DBGFLAGS $OPTFLAGS $DIRECTIVES $LFS $INCLUDE"
FFLAGS="$FFLAGS $DBGFLAGS $FOPTFLAGS $DIRECTIVES $LFS $INCLUDE"
# Add position-independent code if necessary
if [[ $USESHARED -eq 1 ]] ; then
CFLAGS="$CFLAGS $PICFLAG"
CXXFLAGS="$CXXFLAGS $PICFLAG"
FFLAGS="$FFLAGS $PICFLAG"
fi
# Add debug flags for non-PGI compilers if debug info on
if [[ ! -z $DBGFLAGS && $CXX != "pgc++" ]] ; then
CFLAGS="-Wall $CFLAGS"
CXXFLAGS="-Wall -fno-inline $CXXFLAGS"
FFLAGS="-Wall $FFLAGS"
fi
# Turn on profiling for GNU if specified
if [[ $PROFILE -eq 1 && $CXX = "g++" ]] ; then
echo "Using $CXX profiling."
CFLAGS="-pg $CFLAGS"
CXXFLAGS="-pg $CXXFLAGS"
LDFLAGS="-pg $LDFLAGS"
elif [[ $PROFILE -eq 2 && $CXX = "g++" ]] ; then
echo "Turning on GLIBC profiling for $CXX."
CXXFLAGS="-D_GLIBCXX_PROFILE $CXXFLAGS"
elif [[ $PROFILE -eq 3 ]] ; then
echo "Turning on flags for Intel Vtune"
VTUNEFLAGS=""
if [[ $CXX = "icpc" ]] ; then
VTUNEFLAGS=$VTUNEFLAGS" -debug inline-debug-info"
fi
CFLAGS="-g $VTUNEFLAGS $CFLAGS"
CXXFLAGS="-g $VTUNEFLAGS $CXXFLAGS"
LDFLAGS="-shared-intel -shared-libgcc $LDFLAGS"
fi
# Use cray wrappers
if [[ $USECRAY -eq 1 ]] ; then
CC=cc
CXX=CC
FC=ftn
fi
# Test compilers
TestCompile
TestBzlib
TestZlib
TestNetcdf
TestMathlib
# Write config.h
cat > config.h <<EOF
# config.h for cpptraj
# configured using: $CONFIGURECMD
CPPTRAJHOME=$CPPTRAJHOME
CPPTRAJBIN=$CPPTRAJBIN
CPPTRAJLIB=$CPPTRAJLIB
DBGFLAGS=
CC=$CC
CXX=$CXX
FC=$FC
CFLAGS=$CFLAGS \$(DBGFLAGS)
CXXFLAGS=$CXXFLAGS \$(DBGFLAGS)
FFLAGS=$FFLAGS \$(DBGFLAGS)
READLINE=$READLINE
READLINE_HOME=$READLINE_HOME
LDFLAGS=$LDFLAGS
SFX=$SFX
EOF
# Create directories if necessary
if [[ ! -e $CPPTRAJBIN ]] ; then
mkdir $CPPTRAJBIN
fi
if [[ ! -e $CPPTRAJLIB ]] ; then
mkdir $CPPTRAJLIB
fi
echo ""
exit 0