Repository navigation
Expand file tree
/
Copy pathinstall_gridpack.sh
More file actions
executable file
·147 lines (108 loc) · 4.17 KB
/
Copy pathinstall_gridpack.sh
File metadata and controls
executable file
·147 lines (108 loc) · 4.17 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
# This script installs GridPACK and python wrappter.GridPACK is built in src/build directory and installed in src/install directory.
set -x
# This script should be run from the top-level GridPACK directory.
# Flag for install GridPACK and GridPACK python wrapper
install_gridpack=true
install_gridpack_shared=true
install_gridpack_python=true
# These must match install_gridpack_deps.sh
boost_version="1.81.0"
ga_version="5.9"
if "$install_gridpack_python"; then
install_gridpack_shared=true
# Set your python executable here
python_exe=`which python`
if test -z ${python_exe}
then
python_exe=`which python3`
fi
fi
if test -z ${GRIDPACK_ROOT_DIR}
then
export GRIDPACK_ROOT_DIR=${PWD}
echo "GRIDPACK_ROOT_DIR = ${GRIDPACK_ROOT_DIR}"
fi
# Create directory for installing external packages
if test -z ${GP_EXT_DEPS}
then
export GP_EXT_DEPS=${GRIDPACK_ROOT_DIR}/external-dependencies
fi
boost_us_version=`echo $boost_version | sed -e 's/\./_/g'`
boost_dir="${GP_EXT_DEPS}/boost_${boost_us_version}/install_for_gridpack"
petsc_dir="${GP_EXT_DEPS}/petsc/install_for_gridpack"
ga_dir="${GP_EXT_DEPS}/ga-${ga_version}/install_for_gridpack"
cd ${GRIDPACK_ROOT_DIR}
# Set environment variable GRIDPACK_BUILD_DIR and create a build directory
export GRIDPACK_BUILD_DIR=${GRIDPACK_ROOT_DIR}/src/build
GRIDPACK_INSTALL_DIR=${GRIDPACK_ROOT_DIR}/src/install
export GRIDPACK_DIR=${GRIDPACK_INSTALL_DIR}
if ${install_gridpack}
then
rm -rf $GRIDPACK_BUILD_DIR
mkdir $GRIDPACK_BUILD_DIR
rm -rf ${GRIDPACK_INSTALL_DIR}
cd ${GRIDPACK_BUILD_DIR}
## GridPACK installation
echo "Building GridPACK"
# git checkout develop
rm -rf CMake*
cmake_args="-D GA_DIR:STRING=${ga_dir}
-D Boost_ROOT:STRING=$boost_dir
-D Boost_DIR:STRING=$boost_dir/lib/cmake/Boost-$boost_version
-D PETSC_DIR:PATH=${petsc_dir}
-D MPI_CXX_COMPILER:STRING='mpicxx'
-D MPI_C_COMPILER:STRING='mpicc'
-D MPIEXEC:STRING='mpiexec'
-D MPIEXEC_MAX_NUMPROCS:STRING=2
-D GRIDPACK_TEST_TIMEOUT:STRING=120
-D ENABLE_ENVIRONMENT_FROM_COMM:BOOL=YES
-D CMAKE_INSTALL_PREFIX:PATH=${GRIDPACK_INSTALL_DIR}
-D CMAKE_BUILD_TYPE:STRING=Debug
-D BUILD_SHARED_LIBS=$install_gridpack_shared
.. "
cmake -Wdev ${cmake_args}
echo "Installing GridPACK develop branch"
make -j 10 install
fi
if ${install_gridpack_python}
then
echo "Installing GridPACK python wrapper"
cd ${GRIDPACK_ROOT_DIR}
git submodule update --init
echo ${GRIDPACK_DIR}
cd python
# This is necessary on RHEL/CentOS systems
# export RHEL_OPENMPI_HACK=yes
rm -rf build dist gridpack_hadrec.egg-info/
# The extension compiles against mpi4py's headers. The isolated build
# fetches its own mpi4py, so pin it to the one used at run time, built
# from source for this MPI if missing.
if ! ${python_exe} -c 'import mpi4py' 2>/dev/null; then
${python_exe} -m pip install --no-binary=mpi4py mpi4py
fi
mpi4py_pin=`mktemp`
${python_exe} -c 'import mpi4py; print("mpi4py==" + mpi4py.__version__)' > ${mpi4py_pin}
PIP_CONSTRAINT=${mpi4py_pin} ${python_exe} -m pip install --no-deps --upgrade --prefix=$GRIDPACK_INSTALL_DIR .
rm -f ${mpi4py_pin}
# Construct the installed package path and check it. The actual
# path with in the prefix seems to be kind of random, so
# add a couple of options to PYTHONPATH
pyvnum=`${python_exe} -V | sed -e 's/Python *\([23]\)\.\([0-9][0-9]*\)\..*/\1.\2/' `
pydir="${GRIDPACK_DIR}/lib/python${pyvnum}/site-packages:${GRIDPACK_DIR}/local/lib/python${pyvnum}/dist-packages"
if [ -z "$PYTHONPATH" ]; then
PYTHONPATH="${pydir}"
else
PYTHONPATH="${pydir}:${PYTHONPATH}"
fi
export PYTHONPATH
# A quick check to see if the Python module is available. Not from
# python/, where the source tree shadows the installed package.
cd ${GRIDPACK_ROOT_DIR}
if ! ${python_exe} -c 'import gridpack'; then
echo "ERROR: the gridpack Python package does not import"
exit 1
fi
fi
cd ${GRIDPACK_ROOT_DIR}
echo "Completed GridPACK installation"
set +x