[J3] BIND(F)?
Jeff Hammond
jehammond at nvidia.com
Wed Jun 29 08:57:56 UTC 2022
There was an effort to do something like this about 15 years ago, called the Common Component Architecture (CCA):
The CCA specification is expressed as a set of abstract interfaces written in the Scientific Interface Definition Language (SIDL). SIDL is used by the Babel language interoperability tool (discussed further below), which implicitly defines bindings to the various languages that Babel supports (currently Fortran 77, Fortran 90, C, C++, Python, and Java). https://science.osti.gov/-/media/ascr/pdf/program-documents/docs/Ctwatch_quarterly_13.pdf
It received a bunch of DOE funding but – with all due respect to the involved parties – was a complete failure and the only outcome of that effort is a warning to everyone who knows about it to never attempt anything like it ever again.
Jeff
From: J3 <j3-bounces at mailman.j3-fortran.org> on behalf of Van Snyder via J3 <j3 at mailman.j3-fortran.org>
Date: Wednesday, 29June 2022 at 12:23 AM
To: General J3 interest list <j3 at mailman.j3-fortran.org>
Cc: Van Snyder <van.snyder at sbcglobal.net>
Subject: Re: [J3] BIND(F)?
External email: Use caution opening links or attachments
On Tue, 2022-06-28 at 23:06 +0300, Ondřej Čertík via J3 wrote:
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.
Ada faced this reality decades ago. The community developed DIANA, the Distributed Intermediate Attribute Notation for Ada. DIANA is an outgrowth of IDL, the Interface Description Language created by William Wulf and John Nestor (not to be confused with Interactive Data Language).
With formal descriptions of interfaces used by different compilers, not necessarily for the same language, it is (probably) possible to produce a system that generates Ondřej's adapters automatically.
It's probably easier to stand on the shoulders of giants than to re-invent the wheel.
Ondrej
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20220629/ff60fed3/attachment-0001.htm>
More information about the J3
mailing list