2-4 July 2020
University of Zurich
Europe/Zurich timezone

Designing a Modern C++/Fortran Interface by Example

3 Jul 2020, 14:30
ZOOM (University of Zurich)


University of Zurich

Junior Presentations Session D


Mr Maximilien Ambroise (Universität Heidelberg)


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.

Primary author

Mr Maximilien Ambroise (Universität Heidelberg)

Presentation Materials