Fortran Previous Work¶
Communicating between languages has a long history.
https://computation.llnl.gov/projects/babel-high-performance-language-interoperability Babel parses a SIDL (Scientific Interface Definition Language) file to generate source. It is a hub-and-spokes approach where each language it supports is mapped to a Babel runtime object. The last release was 2012-01-06. http://en.wikipedia.org/wiki/Babel_Middleware
http://chasm-interop.sourceforge.net/ - This page is dated July 13, 2005
Chasm is a tool to improve C++ and Fortran 90 interoperability. Chasm parses Fortran 90 source code and automatically generates C++ bridging code that can be used in C++ programs to make calls to Fortran routines. It also automatically generates C structs that provide a bridge to Fortran derived types. Chasm supplies a C++ array descriptor class which provides an interface between C and F90 arrays. This allows arrays to be created in one language and then passed to and used by the other language. http://www.cs.uoregon.edu/research/pdt/users.php
- CHASM: Static Analysis and Automatic Code Generation for Improved Fortran 90 and C++ Interoperability
- C.E. Rasmussen, K.A. Lindlan, B. Mohr, J. Striegnitz
- Bridging the language gap in scientific computing: the Chasm approach C. E. Rasmussen, M. J. Sottile, S. S. Shende, A. D. Malony (2005)
a PMPI wrapper generator
Trilonos wraps C++ with C, then the Fortran over the C. Described in the book Scientific Software Design. http://www.amazon.com/Scientific-Software-Design-The-Object-Oriented/dp/0521888131
- On the object-oriented design of reference-counted shadow objects Karla Morris, Damian W.I. Rouson, Jim Xia (2011)
- This Isn’t Your Parents’ Fortran: Managing C++ Objects with Modern Fortran Damian Rouson, Karla Morris, Jim Xia (2012)
Directory packages/ForTrilinos/src/skeleton has a basic template which must be edited to create a wrapper for a class.
Exascale Programming: Adapting What We Have Can (and Must) Work
In 2009 and 2010, the C++ based Trilinos project developed Fortran interface capabilities, called ForTrilinos. As an object-oriented (OO) collection of libraries, we assumed that the OO features of Fortran 2003 would provide us with natural mappings of Trilinos classes into Fortran equivalents. Over the two-year span of the ForTrilinos effort, we discovered that compiler support for 2003 features was very immature. ForTrilinos developers quickly came to know the handful of compiler developers who worked on these features and, despite close collaboration with them to complete and stabilize the implementation of Fortran 2003 features (in 2010), ForTrilinos stalled and is no longer developed.
This is the new effort to provide Fortran interfaces to Trilinos through automatic code generation using SWIG. The previous effort (ca. 2008-2012) can be obtained by downloading Trilinos releases prior to 12.12.
The custom version of swig available at https://github.com/swig-fortran/swig
- Documenting automated Fortran-C++ bindings with SWIG
- IDEAS-ECP Webinar: Automated Fortran-C++ Bindings for Large-Scale Scientific Applications
MPICH uses a custom perl scripts which has routine names and types in the source.
gtk-fortran uses a python script which parse the C header files to generate the Fortran.
https://github.com/jerryd/gtk-fortran/blob/master/src/cfwrapper.py https://github.com/vmagnin/gtk-fortran/wiki https://github.com/vmagnin/gtk-fortran/wiki/How-gtk-fortran-is-generated
CDI is a C and Fortran Interface to access Climate and NWP model Data. https://code.zmaw.de/projects/cdi
“One part of CDI is a such generator. It still has some rough edges and we haven’t yet decided what to do about functions returning char * (it seems like that will need some wrapping unless we simply return TYPE(c_ptr) and let the caller deal with that) but if you’d like to have a starting point in Ruby try interfaces/f2003/bindGen.rb from the tarball you can download” https://groups.google.com/d/msg/comp.lang.fortran/oadwd3HHtGA/J8DD8kGeVw8J
This is a Fortran interface over the Python API written using the metaprogramming tool Fypp.
The CNF package comprises two sets of software which ease the task of writing portable programs in a mixture of FORTRAN and C. F77 is a set of C macros for handling the FORTRAN/C subroutine linkage in a portable way, and CNF is a set of functions to handle the difference between FORTRAN and C character strings, logical values and pointers to dynamically allocated memory.
The h2m-AutoFortran tool is designed to allow easy calls to C routines from Fortran programs. Given a header file in standard C, h2m will produce a Fortran module providing function interfaces which maintain interoperability with C. Features for which there are no Fortran equivalents will not be translated and warnings will be written to standard error. The h2m-AutoFortran tool is built into Clang, the LLVM C compiler. During translation, the Clang abstract syntax tree (AST) is used to assemble information about the header file.
- Technical Specification ISO/IEC TS 29113:2012
- Generating C Interfaces
- Shadow-object interface between Fortran95 and C++ Mark G. Gray, Randy M. Roberts, and Tom M. Evans (1999)
- Generate C interface from C++ source code using Clang libtooling
- Memory leaks in derived types revisited G. W. Stewart (2003)
- A General Approach to Creating Fortran Interface for C++ Application Libraries
- C, Fortran, and single-character strings
- Emulating Multiple Inheritance in Fortran 2003/2008