13.1 Cpp

Figure 13.1: The Cpp unit directory tree, along with the implemented APIs.
Image Cpp_pic

The Cpp unit primarily exists to collect the various CppAPI implementations across the various units as depicted in Fig. 13.1, which are enumerated in Cpp/CppMain/Config. The Cpp unit also holds some subroutines that help in the fortran-C interoperability, in particular for binding strings between the two languages. This includes Cpp_fStr and Cpp_cStrPtr, which allows the passing of character(len=*) on the fortran side and char* on the C side.

Each Unit/CppAPI unit implements a Unit_cAPI.F90 interface that uses the bind(C) fortran feature to expose the unit's API to C, and a UNIT_cppAPI.hxx header that declares those bindings as extern "C". Additionally, if the unit contains C++ code that should be called from the fortran side it will implement a Unit_cInterface.hxx & Unit_cInterface.F90 which bind in the opposite direction. This is primarily intended for implementing code in python for reading runtime parameters and user defined Simulation routines. The unit may be included at setup with the argument +cppapi.