FortranCon2020 [JP]: Designing a Modern C++/Fortran Interface by Example
Channel: FortranCon
Date: 2020-09-03

In the world of quantum chemistry programs, Fortran reigns supreme. While there are packages available that are purely written in C++ and Python, it has become increasingly common to combine different languages. Common combinations include C++/Fortran or Python/C++. 

Fortran 2003 introduced a standardized way to generate interoperable procedures and derived types with the C programming language, using the BIND(C) attribute. This was a necessary step, as interfaces from C to legacy Fortran code had compiler-specific problems which made portability a major issue. Following Fortran 2008 and 2018, more technical specifications were accepted that furthered interoperability.

In this presentation, we will discuss the development of a C/C++ interface to a modern Fortran library called DBCSR (Distributed Block Compressed Sparse Row), designed for efficient sparse matrix-matrix multiplication, among other operations. This interface is currently being incorporated in a novel sparse-tensor quantum chemistry program written in C++. Several points about C/Fortran interoperability will be addressed, such as memory management, derived types, handling arrays, and problems encountered therein, as well as how preprocessors may be used to help design a modern C++ interface with Fortran at its roots.


Maximilien Ambroise, Universität Heidelberg

https://tcevents.chem.uzh.ch/e/FortranCon2020