-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbaseOS.def
More file actions
250 lines (194 loc) · 6.68 KB
/
baseOS.def
File metadata and controls
250 lines (194 loc) · 6.68 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
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
Bootstrap: library
From: ubuntu:20.04
####
#
# Authors: Chris Wood, EPCC, University of Edinburgh <c.wood@epcc.ed.ac.uk>
# Authors: James Harle, National Oceanography Centre <jdha@noc.ac.uk>
# Date: 2021-11-30
# Last updated: 2021-11-30
#
# Definition file for base OS used to create NEMO/XIOS Singularity Containers
#
####
%files
/home/singularity/input_files/NEMO_in
%post
##
# install base OS
##
apt-get -y update
apt install -y locales
locale-gen en_GB en_GB.UTF-8
apt install -y software-properties-common
add-apt-repository universe
apt update
##
# add required packages
##
apt install -y python \
subversion \
wget \
git \
make \
m4 \
gcc-10 \
gfortran-10 \
g++-10 \
liburi-perl \
libcurl4-openssl-dev \
curl \
zlib1g-dev \
libibverbs-dev \
libpmix-dev \
libslurm-dev \
libnuma-dev \
zip \
cmake
##
# make gcc-10 available
##
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10
update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-10 100
#ln -s /usr/bin/cpp-10 /usr/bin/cpp # using cpp++11 later
##
# clean up base build
##
apt clean
##
# make user `nemo` - mpiexec in hdf5 `make check` complains if run as root (although we're not running it at the moment)
##
adduser --disabled-password --gecos "" nemo
###
# softlink gmake to make
###
ln -s /usr/bin/make /usr/bin/gmake
##
# compiling MPI
##
. /home/singularity/input_files/NEMO_in # set MPI choices
MPI=MPICH
if [ -z "$MPI" ] && [ "$MPI_SWAP" = "MPICH" ]
then
MPI="MPICH"
elif [ -z "$MPI" ] && [ "$MPI_SWAP" = "OMPI" ]
then
MPI="OMPI"
fi
MPI_DIR=/opt/mpi
mkdir -p $MPI_DIR
cd $MPI_DIR
mkdir mpi
if [ "$MPI" = "MPICH" ]
then
apt install -y libfabric-dev
wget http://www.mpich.org/static/downloads/3.2.1/mpich-3.2.1.tar.gz
tar -xvzf mpich-3.2.1.tar.gz -C mpi --strip-components 1
rm mpich-3.2.1.tar.gz
cd mpi
#./configure CC=gcc CXX=g++ FC=gfortran --prefix=/opt/mpi/install FFLAGS=-fallow-argument-mismatch
./configure CC=gcc CXX=g++ FC=gfortran --prefix=/opt/mpi/install FFLAGS=-fallow-argument-mismatch
make
make install
elif [ "$MPI" = "OMPI" ]
then
#cd ../
#mkdir ucx
#cd ucx
#mkdir ucx
#wget https://github.com/openucx/ucx/releases/download/v1.9.0/ucx-1.9.0.tar.gz
#tar xzf ucx-1.9.0.tar.gz -C ucx --strip-components 1
#cd ucx
#./contrib/configure-release --prefix=/opt/ucx/install
#make -j8 install
cd $MPI_DIR
wget https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-4.1.1.tar.bz2
tar -xvjf openmpi-4.1.1.tar.bz2 -C mpi --strip-components 1
rm openmpi-4.1.1.tar.bz2
cd mpi
#./configure CC=gcc CXX=g++ FC=gfortran --enable-mpi1-compatibility --prefix=/opt/mpi/install --with-verbs --with-slurm --with-pmix --with-ucx=/opt/ucx/install
./configure CC=gcc CXX=g++ FC=gfortran --enable-mpi1-compatibility --prefix=/opt/mpi/install --with-verbs --with-slurm --with-pmix
make
make install
else
echo "No MPI implementation specified"
exit 1
fi
cd /opt/mpi
rm -r mpi # removes the 303 mb directory
##
# compile HDF5 libraries
##
HDF_DIR=/opt/hdf5
mkdir -p $HDF_DIR
cd $HDF_DIR
wget -O hdf5.tar.bz2 "https://www.hdfgroup.org/package/hdf5-1-12-0-tar-bz2/?wpdmdl=14584&refresh=60be563cf137e1623086652"
mkdir hdf
tar xjvf hdf5.tar.bz2 -C hdf --strip-components 1
rm hdf5.tar.bz2
H5DIR=/opt/hdf5/install
cd hdf
CC=/opt/mpi/install/bin/mpicc ./configure --prefix=${H5DIR} --enable-hl --enable-parallel --with-default-api-version=v18
make
make install
cd ..
rm -r hdf # removes the 212 mb directory
##
# compile NetCDF libraries
##
NETCDF_DIR=/opt/netcdf
mkdir -p $NETCDF_DIR
cd $NETCDF_DIR
# C libraries...
wget -O netcdf.tar.gz https://github.com/Unidata/netcdf-c/archive/v4.8.0.tar.gz
mkdir netcdf
tar xzvf netcdf.tar.gz -C netcdf --strip-components 1
rm netcdf.tar.gz
cd netcdf
NCDIR=/opt/netcdf/install
CC=/opt/mpi/install/bin/mpicc FC=/opt/mpi/install/bin/mpifort CPPFLAGS="-I${H5DIR}/include" LDFLAGS="-L${H5DIR}/lib" ./configure --disable-shared --prefix=$NCDIR
make
make install
cd ..
rm -r netcdf # removes the 125 mb directory
# ...and the fortran libraries
wget https://github.com/Unidata/netcdf-fortran/archive/v4.5.3.tar.gz
mkdir netcdf
tar xzvf v4.5.3.tar.gz -C netcdf --strip-components 1
rm v4.5.3.tar.gz
cd netcdf
NFDIR=/opt/netcdf/install
CC=/opt/mpi/install/bin/mpicc FC=/opt/mpi/install/bin/mpifort CPPFLAGS="-I${NCDIR}/include -I${H5DIR}/include" LDFLAGS="-L${NCDIR}/lib -L${H5DIR}/lib" LIBS="-lhdf5 -lhdf5_hl -lcurl" ./configure --prefix=$NFDIR --disable-shared
make
make install
cd ..
rm -r netcdf # removes the 18 mb directory
ln -s /opt/mpi/install/bin/mpif90 /usr/bin/mpif90
WORK_DIR=/nemo >> $SINGULARITY_ENVIRONMENT
mkdir $WORK_DIR
cd $WORK_DIR
chown nemo:nemo -R $WORK_DIR
PATH=$PATH:/opt/mpi/install/bin:/opt/hdf5/install/bin
LD_LIBRARY_PATH=/opt/hdf5/install/lib:$LD_LIBRARY_PATH
cd $WORK_DIR
# make everything we've built be owned by `nemo`
chown -Rv nemo:nemo /opt
#chmod -Rv 644 /opt
#find /opt -type d -print0 | xargs -0 chmod -v 511
#find /opt -type f -exec file -i {} + | grep ":[^:]*binary[^:]*$" | sed 's/^\(.*\):[^:]*$/\1/' | xargs chmod -v 555
chmod -Rv 755 /opt
rm -rf /var/lib/apt/lists/* /var/lib/dpkg/info/*
%environment
export LD_LIBRARY_PATH=/opt/hdf5/install/lib:$LD_LIBRARY_PATH
%runscript
%labels
Author c.wood@epcc.ed.ac.uk
Author jdha@noc.ac.uk
Version v0.0.1
%help
The definition file used to create this container builds the base OS for NEMO, XIOS, and the following dependencies from source:
- OpenMPI (4.0.1) / MPICH (3.4.2)
- HDF5 (1.10.5)
- NetCDF C (4.7.1) and Fortran (4.5.2) libraries
This container
To build the container, run
singularity build nemo_base_OS.sif Singularity.nemo_baseOS