Are there any C libraries on the Internet that use iso_c_binding? If there are libraries what are the URLs to that library or libraries?
What about complex iso_c_binding examples/programs on the Internet that use derived types? Are there any complete but complex working examples?
I gave a presentation on using derived types defined in Fortran via
iso_c_binding in C and other languages (Using objects across language boundaries — Fortran OOP Seminar Series). It also links in the summary to two production projects which make of this feature in quite some different way.
Another different example might be the Fortran bindings for nlopt: nlopt-f/nlopt_interface.F90 at main · grimme-lab/nlopt-f · GitHub, which provide
iso_c_binding interfaces for the procedures and types defined in nlopt/nlopt.h at master · stevengj/nlopt · GitHub.
However, for both cases only one of the languages needs full access to the internals, while the other is using a rather opaque representation and performing actions via API calls.
There are probably many more examples, some can be found by searching for source files using
iso_c_binding on GitHub.
An early project where I started learning about C interoperability is Brad Richardson / SQLite for Fortran · GitLab
I’ve always wanted Redis in Fortran, I hope somebody makes it as a learning experiment.
The question in the title is somewhat ambiguous. Are you interested in examples of Fortran apps/libraries calling C, or C apps/libraries which call Fortran? Personally, I’d say the former is more common; in the other direction it’s more common to see Python calling Fortran via C-conforming interfaces. But there’s still a lot of code in the wild which doesn’t use the standard interoperability, LAPACK is one of them.
A few projects I used as stepping stones to learn about Fortran-C interoperability include:
I also have snippets of code showing Fortran bindings to parts of nanoflann (C++), BLIS (C), Eigen++ (C++), and the C standard library, and the C++ standard template library. For one project I connected the widgets in a Python Jupyter notebook to an eigenvalue computation in Fortran via a Cython bridge.
This is the most complicated iso_c_binding project I have ever done: GitHub - Nicholaswogan/fortran-yaml-c
It uses recursion and derived types and a big web of pointers to make a fortran interface to a C yaml parser.
Also, I have a repo showing how to make a python interface to fortran using iso_c_binding and cython: GitHub - Nicholaswogan/fortran-cython-examples