work in progress
This topic is a subsection of Programming
When writing a truly portable API we need to consider programming language interoperability. This "work in progress" looks at
- calling Fortran90 from C/C++
- (others to follow)
calling Fortran90 from C++
There are several use cases for which we are providing worked examples via our github repository (email us for access), including
- C++ passes scalar, whose value can be changed with Fortran
- C++ passes scalar, whose value is used with Fortran to define array statically
- C++ passes scalar, whose value is used with Fortran to define array dynamically
- C++ declares and allocates array and passes to Fortran, where values can be changed. Fortran expects known size
We are currently working on
- C++ declares and allocates array and passes to Fortran, where values can be changed. Fortran expects known size and shape
Key lessons:
- within Fortran use ISO_C_BINDINGS, but be careful of when to use 'value' keyword
- be aware of C/C++ and Fortran using different ordering for storing multidimensional arrays