[J3] BIND(F)?

Ondřej Čertík ondrej at certik.us
Tue Jun 28 20:06:52 UTC 2022

On Tue, Jun 28, 2022, at 10:33 PM, Steve Lionel via J3 wrote:
> I wish it were otherwise, but that ship sailed decades ago. What was 
> asked for initially was a way of specifying the global name for an 
> entity that was not C-interoperable - that is feasible. Trying to 
> expand the idea into general interoperability across two or more 
> Fortran compilers is not.

One way to interoperate between Fortran compilers is via adapters. To test the idea, I have written an adapter for GFortran's array descriptor, compiled a module using GFortran, then called the function from another module (via this adapter) that was compiled using Intel Fortran, I linked everything together and it worked.

However, there is some overhead when converting the GFortran's array descriptor. But if you are willing to live with that, it seems to me it is technically possible to simply "use" a module compiled by another compiler (such as GFortran). The array descriptor (and other ABI details) of course change from a version to version, but not too often (I think the array descriptor changed only once in the past 10 years, and only slightly).

The array descriptor use case I think is now mostly covered by ISO_Fortran_binding.h (with the downside that you have to mark such subroutines as bind(c)), and it is my understanding that the compilers have to convert their internal descriptor to the ISO one, so there is an overhead as well. 

To move this discussion forward, I recommend to have a working prototype between compilers that are willing to experiment with this, and only then come here and try to standardize it. Jeff, if you are able to implement the needed changes in Flang, I am happy to prototype things in LFortran, to get started.


More information about the J3 mailing list