.. Watlab documentation file, created by Pierre-Yves Gousenbourger on Wed Aug 2, 2023. .. _programs: 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: - :ref:`A C++ compiler ` - :ref:`The OpenMP library ` - :ref:`Python ` 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: 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 .. code-block:: g++ --version If a version is already installed, go to the :ref:`next section `. Otherwise, follow the guide. Linux (Ubuntu) ^^^^^^^^^^^^^^ If no version is installed, run the following commands : .. code-block:: sudo apt-get update sudo apt-get upgrade sudo apt-get install gcc sudo apt-get install g++ Verify the version : .. code-block:: 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: .. code-block:: pacman -Syu and accept ``(y)`` when asked. The terminal will close. Reopen the **MSYS2 terminal** and type .. code-block:: pacman -Su and accept ``(y)`` when asked. Update the library with .. code-block:: 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 .. code-block:: 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 .. code-block:: g++ in the terminal and press ``install`` if a pop-up opens. Test the version with : .. code-block:: g++ --version Hello World ^^^^^^^^^^^ You can try a Hello World by checking the `tutorial of vscode `_ .. _install-openmp: 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 .. code-block:: 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 .. code-block:: 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**: .. code-block:: 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 : .. code-block::c #include #include int main(void) { #pragma omp parallel printf("tread %d\n", omp_get_thread_num()); } 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 .. code-block:: gcc test.c -fopenmp -o test This will create an executable file test.exe. Now execute this program. In a **Windows terminal** (powershell), hit .. code-block:: ./test and in a **cmd terminal**, hit: .. code-block:: test.exe This should print you something like .. code-block:: thread 2 thread 0 thread 3 thread 1 .. _install-python: Install Python -------------- Python will be needed to control the code and to run tests. The easiest way is to install :ref:`Anaconda `. For the same reasons as for ``g++``, make sure that python is added to :ref:`your path `. .. _install-anaconda: 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: 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 .. code-block:: conda create --name hydroFlow python=3.9 then hit : .. code-block:: conda activate hydroFlow Install the required packages : .. code-block:: 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 : .. code-block:: pip install spyder-kernels==2.2.* Now you should be able to get started !