Compile the code#
There are two ways to compile the code : directly with the C++ compiler or with CMake. We highly recommand CMake as it is system independant. It it recommended to use C++20 (C++17 accepted). There is no backward compatibility for older versions.
Note that the python library for Watlab permits to run the code without hitting the following nauseous lines. Check our Tutorials for more information.
Build the code with CMake#
Make sure you installed CMake properly. Open a shell and hit the two following command.
cmake -S . -B _build/
cmake --build _build
The code will generate by itself and the executables will be created in bin/ (for programs) and in tests/ for test executables.
On windows, you may need to specify the C++ Makefiles. If you installed MinGW as recommended in this documentation, you should hit
cmake -S . -G "MinGW Makefiles" -B _build/
cmake --build _build/
To help you, we created scripts in scripts/. It is called scripts/Build-Binaries.
Compile the code with the C++ compiler#
The command lines to create the cpp code without parallelization is
g++ -o hydroflow src/cpp/*.cpp src/cpp/writer/*.cpp src/cpp/physicalmodels/*.cpp src/cpp/interfaces/*.cpp src/cpp/helpers/*.cpp -std=c++20
This will create an executable hydroflow.exe.
To compile the code with parallelization, make sure that OpenMP is installed with your compiler. Now hit the following lines
g++ -O3 -fopenmp -pthread -o hydroflow src/cpp/*.cpp src/cpp/writer/*.cpp src/cpp/physicalmodels/*.cpp src/cpp/interfaces/*.cpp src/cpp/helpers/*.cpp -std=c++20
This will create an executable hydroflow.exe, but now it is parallelizable. If no error is thrown, you have successfully compiled the code.
Execute the code#
When your data.json is exported, you can directly execute the C++ code as follows
./hydroflow -f path/to/data.json
If you wish no verbose, you can also add the command -nodisplay
to your line:
./hydroflow -f path/to/data.json -nodisplay