Install the required programs#

Here is a quick setup of your working environment before you use Watlab. Tu use this library, you first need to compile it, and so you need to install the following checked programs:

It is supposed that you know:

  • What is a compiler;

  • How to install a program;

  • What and how to use a terminal;

  • How to use python and python environments.

Install a C++ compiler#

You’ll need a C++ compiler to recompile the code or changes made in it. Before you start to install the compiler, check if you already have one. Open a terminal a type

g++ --version

If a version is already installed, go to the next section. Otherwise, follow the guide.

Linux (Ubuntu)#

If no version is installed, run the following commands :

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install gcc
sudo apt-get install g++

Verify the version :

g++ --version

Windows#

You can follow the instructions given in MSys2.org, for instance. If you use so, download the installer and install it. Then open a MSYS2 terminal (also called MSYS2 command prompt). You can search it in the launch bar. Hit the following commands:

pacman -Syu

and accept (y) when asked. The terminal will close. Reopen the MSYS2 terminal and type

pacman -Su

and accept (y) when asked.

Update the library with

pacman -S --needed base-devel mingw-w64-x86_64-toolchain

To be able to use the compiler from you cmd terminal or with your Windows terminal, you’ll need to add the g++ command to your PATH. To do so,

  • go to the settings and search for edit environment variables for your account.

  • Choose Path and then click on edit

  • Select New and add the bins of mingw64. If you installed the default, then it should be C:\msys64\mingw64\bin

  • Select OK.

Verify the version by opening a Windows terminal (or a cmd terminal) and hit

g++ --version

This should show you no error and a version for g++.

Mac#

Normally, g++ should be set up on mac. To be sure, open a terminal with cmd+space, write terminal in the pop-up and hit enter.

Type

g++

in the terminal and press install if a pop-up opens.

Test the version with :

g++ --version

Hello World#

You can try a Hello World by checking the tutorial of vscode

Install OpenMP#

OpenMP is a parallelization library for C++ that will increase the velocity of the code by exploiting multiple threadings.

Linux (Ubuntu)#

Open Bash and execute the following commands

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install libomp-dev

Windows#

If you installed C++ with MSYS2, open the MSYS2 terminal and hit

pacman -S mingw-w64-x86_64-openmp

If you installed C++ with MingGW, then run the following command line in the Windows (or cmd) terminal:

mingw-get upgrade --recursive "gcc<4.7.*" "gcc-g++<4.7.*"

Mac#

There is no simple way to install OpenMP on mac, but several solutions are well explained on the clang GitHub page

Test OpenMP installation#

Create a file test.c and copy-paste the following lines in it :

Open now a Windows (or cmd) terminal.

Navigate to the folder where you saved test.c.

Execute the following command to compile the test file

gcc test.c -fopenmp -o test

This will create an executable file test.exe. Now execute this program. In a Windows terminal (powershell), hit

./test

and in a cmd terminal, hit:

test.exe

This should print you something like

thread 2
thread 0
thread 3
thread 1

Install Python#

Python will be needed to control the code and to run tests. The easiest way is to install Anaconda. For the same reasons as for g++, make sure that python is added to your path.

Install anaconda#

Anaconda is a package manager dedicated to Python. You can download it and find installations procedures here: Anaconda Official Website.

Add python to your path#

This will be needed to launch python tests through the terminal (especially for Windows users). You can follow the instructions written on this website to add python (and Anaconda) to your path. Make sure to put the paths of python and anaconda on the top of the list.

Create the environment for the project#

Open a terminal (windows or conda) and navigate to the root of the project. Hit the following command

conda create --name hydroFlow python=3.9

then hit :

conda activate hydroFlow

Install the required packages :

pip install -r requirements.txt

if you want to use spyder (an integrated development environment (IDE) that is included with Anaconda) to deal with HydroFlow, please hit :

pip install spyder-kernels==2.2.*

Now you should be able to get started !