The Basic Model Interface (BMI; Hutton et al. 2020) for the spectral wave model Simulating WAves Nearshore (SWAN; Booij et al. 1999) is provided here.
The original SWAN code, as well as its official documentation can be found at: https://swanmodel.sourceforge.io/
The Basic Model Interface and its documentation is available here: https://bmi.readthedocs.io/en/stable/
Here we provide the necessary components to be able to configure BMI-SWAN in a Linux machine:
- BMI-The Fortran Specification: It is available through https://github.com/csdms/bmi-fortran
- CMake minimum version 3.0 (https://cmake.org/)
In case you want to couple BMI with the hydrodynamics coastal ocean model Thetis, we recommend performing the configuration inside the "firedrake" environment.
The instructions provided here are for an installation directory that is not the /usr/local, but a directory called 'myenv" i.e. /myenv/local
A. Install BMI-Fortran
a. Download the bmi-fortran code (https://github.com/csdms/bmi-fortran) and copy it inside this repository. Its name should be bmi-fortran
b. cd ./bmi-fortran && mkdir _build && cd _build
c. cmake .. -DCMAKE_INSTALL_PREFIX=/myenv/local
d. make && make install
e. cd ../../
B. Create SWAN's shared library
a. cd ./swan
b. make files
c. make compile
d. cd ../
C. Create BMI-SWAN library and its Python package
a. cd ./bmi-swan && mkdir _build && cd _build
b. Change the paths in the CMakeLists (3 paths should be changed, the one in find_library /myenv/local/lib, the other in find_path /myenv/local/include, and the SWAN find library)
c. Change the paths in ./src/Makefile and ./src/setup.py
d. cmake .. -DCMAKE_INSTALL_PREFIX=/myenv/local
e. make
f. make install
g. cd ../src
h. make
i. python3 setup.py build_ext --inplace
D. Include the necessary Path
a. Include the /myenv/local/lib and the /BMI-SWAN/swan to the LD_LIBRARY_PATH
b. Add the /BMI-SWAN/bmi-swan/src to the PYTHONPATH
In case of the installation of BMI-SWAN within the firedrake environment, see activate file and implement necessary changes into your own activate file located in the firedrake/source/bin directory, so as to add those paths only when firedrake environemnt is activated