jameskermode / f90wrap

F90 to Python interface generator with derived type support
GNU Lesser General Public License v3.0
243 stars 80 forks source link

Type check for better fortran interface support #182

Closed danbeibei closed 1 year ago

danbeibei commented 1 year ago

This pull request addresses two current limitations:

This pr adds type and shape checks in the python wrapper function. It raises TypeError if the type/shape provided to the python function does not match the type/shape of the wrapped Fortran subroutine. It allows better support for Fortran interfaces. For instance, it enables one to wrap:

Known limitation: as Fortran logical is mapped to C int there is no differentiation of python bool and int32.

It should solve issue #107

A command line flag is added to activate those checks, so that old behavior is still possible and is the default. The flag could be removed so that the checks are always added, but this could break existing code. It does break some tests in the exemple directory, though they seem easily fixable.

jameskermode commented 1 year ago

OK, I understand the point about polymorphism now. Happy to merge once you fix the minor issue with the type_check default value.

danbeibei commented 1 year ago

I fixed the type_check default value. I also reworked a bit the case where the fortran type is not known to f90wrap.

jameskermode commented 1 year ago

thank you! I'll wait for the upcoming build improvements before doing a new release.