SIParCS 2016- Sisi Liu

Sisi Liu, Columbia University

Automating Fortran - C Interoperability

(Slides)  (Recorded Talk)

Most of the current scientific programs run by large systems at NCAR are written in a combination of Fortran and C. Therefore, the support of the interoperability between C and Fortran is critical to the development and maintenance of these programs. In order to connect C software to a Fortran program, a Fortran module must be written to express the C interfaces and data, which, in most cases, are expressed in C header files. Since translating the C headers to Fortran modules by hand is a tedious and repetitive process, we aim to build a tool that automatically does the translation from C to Fortran. The approach we took was to use Clang Tooling for LLVM, which inspects and analyzes each node in the abstract syntax tree generated by Clang compiler, translates it to the corresponding Fortran content, and outputs the entire Fortran module as a whole to the command line. The conversion tool does as much translation as possible, and meanwhile preserves the untranslatable content as comment to make the output compliable, but in some cases, there might be some type safety loss or unavoidable compilation errors, such as some symbols for identifiers that are valid in C but are not in Fortran. The paper will discuss the approaches have taken, how the tool is implemented, and the instruction to build the tool in detail.

Mentors: Dan Nagle and Davide Del Vento, CISL