Last active
August 21, 2024 22:58
-
-
Save dcasati/4dca4e190c4187527b2cc8168b9649d6 to your computer and use it in GitHub Desktop.
compile delft3d on rockylinux9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env bash | |
# shfmt -i 2 -ci -w | |
set -eox | |
wget https://registrationcenter-download.intel.com/akdlm/IRC_NAS/d461a695-6481-426f-a22f-b5644cd1fa8b/l_HPCKit_p_2024.2.1.79_offline.sh | |
sh ./l_HPCKit_p_2024.2.1.79_offline.sh -a --silent --cli --eula accept | |
# pre-requisites | |
apt update && apt install -y \ | |
bison \ | |
cmake \ | |
file \ | |
flex \ | |
g++ \ | |
gfortran \ | |
libblosc-dev \ | |
libcurl4-openssl-dev \ | |
libhdf5-serial-dev | |
m4 \ | |
make \ | |
patch \ | |
patchelf \ | |
pkg-config \ | |
python3 \ | |
python3-pip \ | |
ruby \ | |
sqlite \ | |
subversion \ | |
unzip \ | |
util-linux \ | |
uuid-dev | |
######################### | |
# Set environment variables for compilers | |
export LD_LIBRARY_PATH=/opt/intel/oneapi/2024.2/lib:/opt/intel/oneapi/compiler/2024.2/lib:/home/delft3d/lib:$LD_LIBRARY_PATH | |
export PATH="/home/delft3d/bin:$PATH" | |
export MAKEFLAGS="-j $(nproc)" | |
############################## | |
# Create necessary directories | |
mkdir -p /home/delft3d/src && | |
mkdir -p /home/delft3d/ | |
cd /home/delft3d/src | |
export SRCDIR=/home/delft3d/src | |
################## | |
# Download sources | |
[ ! -f "zlib-1.3.1.tar.gz" ] && wget https://github.com/madler/zlib/releases/download/v1.3.1/zlib-1.3.1.tar.gz -O zlib-1.3.1.tar.gz | |
[ ! -f "hdf5-1_10_5.tar.gz" ] && wget https://github.com/HDFGroup/hdf5/archive/refs/tags/hdf5-1_10_5.tar.gz -O hdf5-1_10_5.tar.gz | |
[ ! -f "v4.9.2.tar.gz" ] && wget https://github.com/Unidata/netcdf-c/archive/refs/tags/v4.9.2.tar.gz -O netcdf-c-4.9.2.tar.gz | |
[ ! -f "netcdf-fortran-4.6.1.tar.gz" ] && wget https://downloads.unidata.ucar.edu/netcdf-fortran/4.6.1/netcdf-fortran-4.6.1.tar.gz -O netcdf-fortran-4.6.1.tar.gz | |
[ ! -f "petsc-with-docs-3.21.1.tar.gz" ] && wget https://web.cels.anl.gov/projects/petsc/download/release-snapshots/petsc-with-docs-3.21.1.tar.gz -O petsc-with-docs-3.21.1.tar.gz | |
[ ! -f "v1.14.0.tar.gz" ] && wget https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz -O googletest-1.14.0.tar.gz | |
[ ! -f "v2.0.0.tar.gz" ] && wget https://github.com/OSGeo/gdal/archive/refs/tags/v2.0.0.tar.gz -O gdal-2.0.0.tar.gz | |
[ ! -f "proj-4.9.3.tar.gz" ] && wget https://download.osgeo.org/proj/proj-4.9.3.tar.gz -O proj-4.9.3.tar.gz | |
######################### | |
# Install zlib | |
tar -xzvf zlib-1.3.1.tar.gz && | |
cd zlib-1.3.1 && | |
./configure --prefix=/home/delft3d && | |
make && | |
make check && | |
make install && | |
cd $SRCDIR | |
###### | |
# hdf5 | |
tar -xzvf hdf5-1_10_5.tar.gz && | |
cd hdf5-hdf5-1_10_5 && | |
./configure --with-zlib=/home/delft3d --enable-parallel --enable-fortran --prefix=/home/delft3d | |
make && | |
make install && | |
cd $SRCDIR | |
export FC=mpiifx | |
export CXX=mpiicpx | |
export CC=mpiicx | |
source /opt/intel/oneapi/setvars.sh | |
################## | |
# netcdf-c library | |
tar -xzvf netcdf-c-4.9.2.tar.gz && | |
cd netcdf-c-4.9.2 && | |
export CPPFLAGS='-I/home/delft3d/include' && | |
export LDFLAGS='-L/home/delft3d/lib' && | |
./configure --prefix=/home/delft3d/ --disable-libxml2 && | |
make && | |
make check && | |
make install && | |
cd $SRCDIR | |
######################## | |
# netcdf fortran library | |
tar -xzvf netcdf-fortran-4.6.1.tar.gz && | |
cd netcdf-fortran-4.6.1 && | |
export CPPFLAGS='-I/home/delft3d/include' && | |
export LDFLAGS='-L/home/delft3d/lib' && | |
./configure --prefix=/home/delft3d/ && | |
make && | |
make check && | |
make install && | |
cd $SRCDIR | |
######## | |
# petsc | |
tar xvzf petsc-with-docs-3.21.1.tar.gz && | |
cd petsc-3.21.1 && | |
./configure --prefix=/home/delft3d --download-fblaslapack=1 && | |
make PETSC_DIR=/home/delft3d/src/petsc-3.21.1 PETSC_ARCH=arch-linux-c-debug all && | |
make PETSC_DIR=/home/delft3d/src/petsc-3.21.1 PETSC_ARCH=arch-linux-c-debug install && | |
cd $SRCDIR | |
############ | |
# googletest | |
tar -xvzf googletest-1.14.0.tar.gz && | |
cd googletest-1.14.0/ && mkdir build && | |
cd build/ && cmake -DCMAKE_PREFIX_PATH=/home/delft3d -DCMAKE_INSTALL_PREFIX=/home/delft3d .. && cmake --build . && cmake --build . --target install && | |
cd $SRCDIR | |
################## | |
# pro legacy 4.9.3 | |
tar -xvzf proj-4.9.3.tar.gz && | |
cd proj-4.9.3 && | |
CFLAGS=-O0 ./configure --prefix=/home/delft3d && | |
make && | |
make check && | |
make install && | |
cd $SRCDIR | |
################### | |
# gdal legacy 2.0.0 | |
tar -xvzf gdal-2.0.0.tar.gz && | |
cp patches/gdal/* gdal-2.0.0/gdal/ && | |
cd gdal-2.0.0/gdal | |
# convert from CRLF to LF | |
sed -i 's/\r$//' frmts/jpeg2000/jpeg2000_vsil_io.cpp | |
# Apply the patches | |
for patch in patch-*.cpp; do | |
echo "Applying $patch..." | |
patch -p0 <"$patch" | tee patch_log.txt 2>&1 | |
done | |
./configure --prefix=/home/delft3d --without-jasper CFLAGS='-std=gnu89' && | |
make && | |
make install && | |
cd $SRCDIR | |
################# | |
# Delft3D | |
export CC=mpiicx | |
export CXX=mpiicpx | |
export FC=mpiifx | |
export LD_LIBRARY_PATH="/home/delft3d/lib:$LD_LIBRARY_PATH" | |
export LD_LIBRARY_PATH="/home/delft3d/lib64:$LD_LIBRARY_PATH" | |
export PKG_CONFIG_PATH="/home/delft3d/lib/pkgconfig:$PKG_CONFIG_PATH" | |
export PKG_CONFIG_PATH="/home/delft3d/lib64/pkgconfig:$PKG_CONFIG_PATH" | |
export C_INCLUDE_PATH="/home/delft3d/include" | |
export CPLUS_INCLUDE_PATH="/home/delft3d/include" | |
export PATH=/home/delft3d/bin:$PATH | |
svn checkout -r 142633 https://svn.oss.deltares.nl/repos/delft3d/trunk /home/delft3d/src/delft3d_142633 | |
cp patches/delft3d delft3d_142633 | |
cd delft3D_142633 | |
# dos2unix | |
sed -i 's/\r$//g' src/utils_lgpl/deltares_common/packages/deltares_common_c/src/meminfo.cpp | |
# apply the patches | |
patch -p0 <patch-src-setenv.sh | |
patch -p0 <patch-src-cmake-CMakeLists.txt | |
patch -p0 <patch-src-utils_lgpl-deltares_common-packages-deltares_common_c-src-meminfo.cpp | |
./build.sh delft3d4 --compiler intel21 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment