Build Delft3D on Ubuntu 16.04 of WSL using GNU compiler
Preparation
First, set the Windows shared folder. Add the following to the end of ~/.bashrc
so that you can access the Windows C drive as ~/winc
.
if [ -d winc ]; then
echo "Windows shared folders ready"
else
ln -s /mnt/c winc
fi
In order to reflect the changed .bashrc
, execute the following in your home directory:
source .bashrc
Proceed as follows. You may not need to install some of the following.
sudo apt update
sudo apt upgrade
sudo apt install build-essential subversion autoconf libtool
sudo apt install bison flex g ++ gfortran libstdc ++ 6 byacc libexpat1 libexpat1-dev
sudo apt install uuid-dev ruby make
sudo apt install libcurl4-openssl-dev
sudo apt install -y pkg-config
Install required tools
Next we will build the necessary tools. Create and move a build directory. Here, we will work in ~/src
which was created below the home directory.
MPICH-3.2
Installation of MPICH-3.2 takes a very long time.
wget http://www.mpich.org/static/downloads/3.2/mpich-3.2.tar.gz
tar -xzf mpich-3.2.tar.gz
cd mpich-3.2
./configure --prefix=/opt/mpich-3.2
make
sudo make install
cd ..
ZLIB-1.2.8
wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4/zlib-1.2.8.tar.gz
tar -xzf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure --prefix=/usr/local/zlib-1.2.8
make
sudo make install
cd ..
HDF5
wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8/hdf5-1.8.16/src/hdf5-1.8.16.tar.gz
tar -zxf hdf5-1.8.16.tar.gz
cd hdf5-1.8.16
./configure --prefix=/usr/local/hdf5-1.8.16 --with-zlib=/usr/local/zlib-1.2.8
make
sudo make install
cd ..
netCDF4-C and netCDF4-Fortran
wget https://github.com/Unidata/netcdf-c/archive/v4.4.1.tar.gz
tar -xzf v4.4.1.tar.gz
cd netcdf-c-4.4.1
./configure --prefix=/usr/local/netcdf4.4 --enable-netcdf-4 --enable-shared --enable-dap CPPFLAGS="-I/usr/local/hdf5-1.8.16/include -I/usr/local/zlib-1.2.8/include -I/usr/local/netcdf4.4/include" LDFLAGS="-L/usr/local/hdf5-1.8.16/lib -L/usr/local/zlib-1.2.8/lib -L/usr/local/netcdf4.4/lib"
make
sudo make install
cd ..
wget https://github.com/Unidata/netcdf-fortran/archive/v4.4.4.tar.gz
tar -xzf v4.4.4.tar.gz
cd netcdf-fortran-4.4.4
./configure --prefix=/usr/local/netcdf4.4 --enable-shared CPPFLAGS="-I/usr/local/hdf5-1.8.16/include -I/usr/local/netcdf4.4/include" LDFLAGS="-L/usr/local/hdf5-1.8.16/lib -L/usr/local/netcdf4.4/lib"
make
sudo make install
cd ..
Building Delft3D
Set a directory where the source code is downloaded like /home/teem/winc/cal/Delft3D
and move it here. Here, /home/teem
is supposed to be the home directory, and /winc
is the Windows C drive that was set up at the beginning. Checkout with subversion. The download took about one hour and twenty minutes.
svn checkout https://svn.oss.deltares.nl/repos/delft3d/tags/delft3d4/59659 delft3d_repository
If an error like svn: E120106: ra_serf: The server sent a truncated HTTP response body.
appeared, change directory to delft3d_repository
and execute the following:
svn cleanup
svn update
Move to delft3d_repository/src
, which is created under the current directory, and edit three locations in build_ubuntu1604.sh as follows:
Edit between if ["$ compiler" = 'gnu']; then
and else
around line 260 as follows.
if [ "$compiler" = 'gnu' ]; then
addpath PATH /opt/mpich-3.2/bin
export MPI_INCLUDE=/opt/mpich-3.2/include
export MPILIBS_ADDITIONAL="-L/opt/mpich-3.2/lib -lfmpich -lmpich -lmpl"
export MPIFC=/opt/mpich-3.2/bin/mpif90
else
Next, edit one line related to netcdf in around line 300 as follows:
./configure --prefix=/home/teem/winc/cal/Delft3D/delft3d_repository $configureArgs &> $log \
Finally, edit the part beginning with ./configure
around line 385 as follows according to the installation location of the source code. The executable will be installed in the directory specified here.
./configure --prefix=/home/teem/winc/cal/Delft3D/delft3d_repository $configureArgs &> $log \
Now that you are ready and build it. This will take long time.
./build_ubuntu1604.sh -gnu -64bit
Test case execution (not yet confirmed here)
Create a script delft3d_env.sh
for setting environment in /home/teem/winc/cal/Delft3D/delft3d_repository
with the following contents.
#!/bin/bash
export PATH=/home/teem/winc/cal/Delft3D/delft3d_repository/bin/lnx64/flow2d3d/bin:$PATH
export PATH=/home/teem/winc/cal/Delft3D/delft3d_repository/bin/lnx64/wave/bin:$PATH
export PATH=/home/teem/winc/cal/Delft3D/delft3d_repository/bin/lnx64/swan/scripts:$PATH
export LD_LIBRARY_PATH=/home/teem/winc/cal/Delft3D/delft3d_repository/bin/lnx64/flow2d3d/bin:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/home/teem/winc/cal/Delft3D/delft3d_repository/bin/lnx64/wave/bin:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/home/teem/winc/cal/Delft3D/delft3d_repository/bin/lnx64/swan/bin:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/home/teem/winc/cal/Delft3D/delft3d_repository/bin/lnx64/swan/scripts:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/opt/mpich-3.2/lib:$LD_LIBRARY_PATH
export PATH=/opt/mpich-3.2/bin:$PATH
Every time before start working on Delft3D, the environmental variables should be set:
source /home/teem/winc/cal/Delft3D/delft3d_repository/delft3d_env.sh