Skip to content

Conversation

benbovy
Copy link
Member

@benbovy benbovy commented Nov 25, 2019

Compute boundary conditions variables and arrays just once when calling Set_BC (before this task was quite duplicated / scattered in various routines).

This approach use Fortran derived types, which IMO should be used more for grouping arrays or variables into consistent structures (e.g., stack, receivers, etc. -> flow graph), which is much more readable and less error prone.

One important caveat: derived types are not supported by f2py. f90wrap is a tool built on top of f2py and adds support for derived types. Another benefit of using f90wrap is that it may issue RuntimeError to Python (see #13).

However, to use f90wrap we would need to update the CMake script, and either add support for it in scikit-build (contributing upstream) or rewrite the Python setup by hand. Both would need work/time. Additionally, f90wrap would be another build and runtime dependency (conda-forge package are not up-to-date and only for linux/macos).

To install/use f90wrap:

  • pip install f90wrap
  • mkdir -p build/f90wrap; cd build/f90wrap
  • f90wrap -m fastscapelib_fortran ../../src/*.f90
  • gfortran -c ../../src/*.f90 -fPIC
  • f2py-f90wrap -c -m _fastscapelib_fortran f90wrap_*.f90 *.o

@benbovy benbovy marked this pull request as draft May 18, 2020 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant