forked from sandialabs/seacas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmake-exodus
executable file
·254 lines (217 loc) · 6.08 KB
/
cmake-exodus
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
#! /usr/bin/env bash
# CMake config file to build ONLY the exodus libraries (C, Fortran, Fortran-32, and Python interface)
# By default, Will build both static and shared version of the C API.
# If only want shared, then run with "sh STATIC=OFF ../cmake-exodus"
if [ "${TRAVIS}" == "true" ]
then
BUILDDIR=${1:-build}
mkdir $BUILDDIR && cd $BUILDDIR
else
EXTRA_ARGS=$@
fi
### The following assumes you are building in a subdirectory of ACCESS Root
### If not, then define "ACCESS" to point to the root of the SEACAS source code.
if [ "$ACCESS" == "" ]
then
ACCESS=$(cd ..; pwd)
fi
### The SEACAS code will install in ${INSTALL_PATH}/bin, ${INSTALL_PATH}/lib, and ${INSTALL_PATH}/include.
INSTALL_PATH=${INSTALL_PATH:-${ACCESS}}
### Set to ON for parallel compile; otherwise OFF for serial (default)
netcdf_parallel=`$INSTALL_PATH/bin/nc-config --has-parallel`
if [ "${netcdf_parallel}" == "yes" ]
then
MPI=ON
else
MPI=OFF
fi
echo "MPI set to ${MPI}"
if [ "${MPI}" == "OFF" ]
then
### Change this to point to the compilers you want to use
## Travis build (and others) set this to EXTERNAL to set
## CXX, CC, and FC externally.
COMPILER=${COMPILER:-gnu}
if [ "$COMPILER" == "gnu" ]
then
CXX=g++
CC=gcc
FC=gfortran
CFLAGS="-Wall -Wunused -pedantic"
CXXFLAGS="-Wall -Wunused -pedantic"
fi
if [ "$COMPILER" == "clang" ]
then
CXX=clang++
CC=clang
FC=gfortran
CFLAGS="-Wall -Wunused -pedantic"
CXXFLAGS="-Wall -Wunused -pedantic"
fi
if [ "$COMPILER" == "intel" ]
then
CXX=icpc
CC=icc
FC=ifort
CFLAGS="-Wall -Wunused"
CXXFLAGS="-Wall -Wunused"
fi
if [ "$COMPILER" == "ibm" ]
then
CXX=xlC
CC=xlc
FC=xlf
fi
fi
STATIC=${STATIC:-ON}
GENERATOR=${GENERATOR:-"Unix Makefiles"}
### Python Version...
PYTHON_VER=${PYTHON_VER:-"3.0"}
# If using an XLF compiler on an IBM system, may need to add the following:
# -DCMAKE_Fortran_FLAGS="-qfixed=72" \
# -DCMAKE_EXE_LINKER_FLAGS:STRING="-lxl -lxlopt"
SHARED="${SHARED:-ON}"
### Switch for Debug or Release build:
### Check that both `DEBUG` and `BUILD_TYPE` are not set
if [ ! -z ${DEBUG+x} ] && [ ! -z ${BUILD_TYPE+x} ]
then
echo "ERROR: Both DEBUG and BUILD_TYPE are set. Only one is allowed."
exit
fi
BUILD_TYPE="${BUILD_TYPE:-RELEASE}"
if [ ! -z ${DEBUG+x} ]
then
if [ "${DEBUG}" == "ON" ] || [ "${DEBUG}" == "YES" ]
then
BUILD_TYPE="DEBUG"
elif [ "${DEBUG}" == "OFF" ] || [ "${DEBUG}" == "NO" ]
then
BUILD_TYPE="RELEASE"
else
echo "ERROR: Invalid value for DEBUG ('$DEBUG'). Must be 'ON', 'OFF', 'YES', 'NO'."
exit
fi
fi
### Set to ON to enable the building of a thread-safe version of the Exodus and IOSS libraries.
THREADSAFE=${THREADSAFE:-OFF}
if [ "$THREADSAFE" == "ON" ] ; then
THREAD_SAFE_OPT="-DSEACASProj_EXTRA_LINK_FLAGS=-lpthread"
fi
FORTRAN=${FORTRAN:-ON}
### TPLs --
### Make sure these point to the locations to find the libraries and includes in lib and include
### subdirectories of the specified paths.
### For example, netcdf.h should be in ${NETCDF_PATH}/include
NETCDF_PATH=${INSTALL_PATH}
PNETCDF_PATH=${INSTALL_PATH}
HDF5_PATH=${INSTALL_PATH}
function check_enable()
{
local path=$1
if [ -e "${path}" ]
then
echo "ON"
else
echo "OFF"
fi
}
HAVE_NETCDF=`check_enable "${NETCDF_PATH}/include/netcdf.h"`
### Define to NO to *enable* exodus deprecated functions
OMIT_DEPRECATED_CODE="NO"
# BUG needs to work with cray too.
if [ "${MPI}" == "ON" ] && [ "${CRAY}" == "ON" ]
then
MPI_EXEC=`which srun`
MPI_SYMBOLS="-D MPI_EXEC=${MPI_EXEC} -D MPI_EXEC_NUMPROCS_FLAG=-n"
CXX=CC
CC=cc
FC=ftn
MPI_BIN=`dirname \`which ${CC}\``
SHARED=OFF
elif [ "${MPI}" == "ON" ]
then
if [ "${USE_SRUN}" == "ON" ]
then
MPI_EXEC=`which srun`
MPI_SYMBOLS="-D MPI_EXEC=${MPI_EXEC} -D MPI_EXEC_NUMPROCS_FLAG=-N"
MPI_BIN=`dirname "${MPI_EXEC}"`
else
MPI_EXEC=`which mpiexec`
MPI_SYMBOLS="-D MPI_EXEC=${MPI_EXEC}"
MPI_BIN=`dirname "${MPI_EXEC}"`
fi
CXX=mpicxx
CC=mpicc
FC=mpif77
fi
OS=$(uname -s)
if [ "$SHARED" == "ON" ]
then
if [ "$OS" == "Darwin" ] ; then
LD_EXT="dylib"
else
LD_EXT="so"
fi
else
LD_EXT="a"
fi
if [ "$OS" == "Darwin" ] ; then
DARWIN_OPT="-D CMAKE_MACOSX_RPATH:BOOL=ON -D TPL_X11_INCLUDE_DIRS:PATH=/opt/X11/include"
else
DARWIN_OPT=""
fi
FC=${FC:-gfortran}
rm -f CMakeCache.txt
###------------------------------------------------------------------------
cmake -G "${GENERATOR}" \
-D CMAKE_CXX_COMPILER:FILEPATH=${CXX} \
-D CMAKE_C_COMPILER:FILEPATH=${CC} \
-D CMAKE_Fortran_COMPILER:FILEPATH=${FC} \
-D CMAKE_CXX_FLAGS=${CXXFLAGS} ${SANITIZER} \
-D CMAKE_C_FLAGS=${CFLAGS} ${SANITIZER} \
-D CMAKE_INSTALL_RPATH:PATH=${INSTALL_PATH}/lib \
-D BUILD_SHARED_LIBS:BOOL=${SHARED} \
-D CMAKE_BUILD_TYPE=${BUILD_TYPE} \
-D SEACASProj_ENABLE_SEACASExodus=ON \
-D SEACASProj_ENABLE_SEACASExodus_for=${FORTRAN} \
-D SEACASProj_ENABLE_SEACASExoIIv2for32=${FORTRAN} \
-D SEACASProj_ENABLE_TESTS=ON \
-D SEACASExodus_ENABLE_STATIC:BOOL=${STATIC} \
-D CMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH} \
-D SEACASProj_SKIP_FORTRANCINTERFACE_VERIFY_TEST:BOOL=ON \
-D SEACASProj_HIDE_DEPRECATED_CODE:BOOL=${OMIT_DEPRECATED_CODE} \
\
-D PythonInterp_FIND_VERSION:STRING=${PYTHON_VER} \
-D SEACASProj_ENABLE_Fortran=${FORTRAN} \
-D TPL_ENABLE_Netcdf:BOOL=${HAVE_NETCDF} \
-D TPL_ENABLE_MPI:BOOL=${MPI} \
-D TPL_ENABLE_Pthread:BOOL=${THREADSAFE} \
${THREAD_SAFE_OPT} \
-D SEACASExodus_ENABLE_THREADSAFE:BOOL=${THREADSAFE} \
\
${MPI_SYMBOLS} \
${DARWIN_OPT} \
\
-D MPI_BIN_DIR:PATH=${MPI_BIN} \
-D NetCDF_ROOT:PATH=${NETCDF_PATH} \
-D HDF5_ROOT:PATH=${HDF5_PATH} \
-D HDF5_NO_SYSTEM_PATHS=ON \
-D PNetCDF_ROOT:PATH=${PNETCDF_PATH} \
\
$EXTRA_ARGS \
${ACCESS}
echo ""
echo " ACCESS: ${ACCESS}"
echo "INSTALL_PATH: ${INSTALL_PATH}"
echo " "
echo " CC: ${CC}"
echo " CXX: ${CXX}"
echo " FC: ${FC}"
echo " MPI: ${MPI}"
echo " SHARED: ${SHARED}"
echo " BUILD_TYPE: ${BUILD_TYPE}"
echo " THREADSAFE: ${THREADSAFE}"
echo " PYTHON_VER: ${PYTHON_VER}"
echo " "
echo " HAVE_NETCDF: ${HAVE_NETCDF}"
echo ""