Modernized Minpack release candidate

We are now staging the first release of the modernized Minpack version at

We are interested in feedback for the Fortran package (supported via fpm or meson), as well as the C and Python bindings. Let us know if you find something that is not working as expected.


To use this version of Minpack with fpm it requires nothing but a dependency in the package manifest

[dependencies]
minpack.git = "https://github.com/fortran-lang/minpack"

For meson projects you can get the minpack dependency via

minpack_dep = dependency('minpack', fallback: ['minpack', 'minpack_dep'])

To use mesons subprojects include a wrap file with the following content in subprojects/minpack.wrap

[wrap-git]
directory = minpack
url = https://github.com/fortran-lang/minpack
revision = head

Finally, for Python projects we offer a shortcut via meson-python to directly build the Fortran projects and the Python bindings

pip install https://github.com/fortran-lang/minpack/releases/download/v2.0.0-rc.1/minpack-2.0.0-python-sdist.tar.gz

We didn’t upload Minpack to PyPI yet, because we want to gather some experience on the usability of meson-python as build backend first before we fully commit to it. The disadvantage of this build setup is obviously that you cannot use the Minpack installation in Fortran anymore :wink:

12 Likes

I was looking for inspiration on how to develop a C API for a Fortran routine and came across with this project.
The c-bindings are defined in minpack_capi.f90. I guess I understand most of the code, but I wonder why the interfaces to the problem functions (e.g. minpack_func) are declared public. Is that really necessary? Why so?
Thanks.

It’s useful for the case where the function is selected at runtime:

// For C
minpack_func f = condition ? &funa : &funb;
! In Fortran
procedure(minpack_func), pointer :: f

If (condition) then 
   f => funa
else
   f => funb
endif

Or if you want to write a procedure that takes a MINPACK compatible function as an argument.

I realize I need to restate the question more precisely. I understand the use mentioned by @ivanpribec.

What intrigues me is that the companion header file minpack.h includes a typedef definition for the problem functions. Isn’t this somehow equivalent to the interfaces? Isn’t this “double definition” redundant?

It’s necessary because we define the procedures on the Fortran side, but you need the declaration on the C side.