-
Notifications
You must be signed in to change notification settings - Fork 7
/
of-7.def
93 lines (72 loc) · 2.52 KB
/
of-7.def
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
Bootstrap: docker
From: centos:7
%help
This recipe provides an OpenFOAM-7 environment installed
with GCC and OpenMPI-4.
%labels
Author Fatih Ertinaz
%post
### Install prerequisites
yum groupinstall -y 'Development Tools'
yum install -y wget git openssl-devel libuuid-devel
### Install OpenMPI
# Why openmpi-4.x is needed: https://github.com/hpcng/singularity/issues/2590
vrs=4.0.4
wget https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-${vrs}.tar.gz
tar xf openmpi-${vrs}.tar.gz && rm -f openmpi-${vrs}.tar.gz
cd openmpi-${vrs}
./configure --prefix=/opt/openmpi-${vrs}
make all install
make all clean
### Update environment - OpenMPI
export MPI_DIR=/opt/openmpi-${vrs}
export MPI_BIN=$MPI_DIR/bin
export MPI_LIB=$MPI_DIR/lib
export MPI_INC=$MPI_DIR/include
export PATH=$MPI_BIN:$PATH
export LD_LIBRARY_PATH=$MPI_LIB:$LD_LIBRARY_PATH
### OpenFOAM version
pkg=OpenFOAM
vrs=7
### Install under /opt
base=/opt/$pkg
mkdir -p $base && cd $base
### Download OF
wget -O - http://dl.openfoam.org/source/$vrs | tar xz
mv $pkg-$vrs-version-$vrs $pkg-$vrs
### Download ThirdParty
wget -O - http://dl.openfoam.org/third-party/$vrs | tar xz
mv ThirdParty-$vrs-version-$vrs ThirdParty-$vrs
### Change dir to OpenFOAM-version
cd $pkg-$vrs
### Get rid of unalias otherwise singularity fails
sed -i 's,FOAM_INST_DIR=$HOME\/$WM_PROJECT,FOAM_INST_DIR='"$base"',g' etc/bashrc
sed -i 's/alias wmUnset/#alias wmUnset/' etc/config.sh/aliases
sed -i '77s/else/#else/' etc/config.sh/aliases
sed -i 's/unalias wmRefresh/#unalias wmRefresh/' etc/config.sh/aliases
### Compile and install
. etc/bashrc
./Allwmake 2>&1 | tee log.Allwmake
### Clean-up environment
rm -rf platforms/$WM_OPTIONS/applications
rm -rf platforms/$WM_OPTIONS/src
cd $base/ThirdParty-$vrs
rm -rf build
rm -rf gcc-* gmp-* mpfr-* binutils-* boost* ParaView-* qt-*
strip $FOAM_APPBIN/*
### Source bashrc at runtime
echo '. /opt/OpenFOAM/OpenFOAM-7/etc/bashrc' >> $SINGULARITY_ENVIRONMENT
%environment
export MPI_DIR=/opt/openmpi-4.0.4
export MPI_BIN=$MPI_DIR/bin
export MPI_LIB=$MPI_DIR/lib
export MPI_INC=$MPI_DIR/include
export PATH=$MPI_BIN:$PATH
export LD_LIBRARY_PATH=$MPI_LIB:$LD_LIBRARY_PATH
%test
. /opt/OpenFOAM/OpenFOAM-7/etc/bashrc
icoFoam -help
%runscript
echo
echo "OpenFOAM installation is available under $WM_PROJECT_DIR"
echo