Multithreading

Using wflow in Julia

Wflow supports multi-threading execution of the wflow_sbm model that uses the kinematic wave approach for river, overland and lateral subsurface flow. Both the vertical SBM concept and the kinematic wave components of this model can run on multiple threads. The optional local inertial model for river flow and the optional local inertial model for river (1D) and land (2D), both part of wflow_sbm, can also run on multiple threads. The threading functionality for the kinematic wave may also be useful for the wflow_sbm model SBM + Groundwater flow. The multi-threading functionality in wflow is considered experimental, see also the following issue, where an error was not thrown running code multi-threaded. Because of this we advise to start with running a wflow model single-threaded (for example during the testing phase of setting up an new wflow model).

For information on how to start Julia with multiple threads we refer to How to start Julia with multiple threads.

Additionally, when running Julia + wflow via the command line (note that this is different from the wflow_cli), it is possible to define the number of threads via the -t flag. An example where we start Julia with three threads:

julia -t 3 -e 'using Wflow; Wflow.run()' path/to/config.toml

Using the command line interface

As explained above, we need to start julia with multiple threads to make use of this speedup. For wflow_cli, the only way to do this is by setting the JULIA_NUM_THREADS environment variable, as explained in these julia docs.

When a model run starts, among the run information the number of threads that are used is printed, so nthreads() = 4 means 4 threads are used, because JULIA_NUM_THREADS has been set to 4.

Back to top