Fortran-to-C interoperability – Segfault upon reading PNG file
Octopus-9.1 fails to read PNG files when compiled by the Intel Fortran/C compilers, version 2019 Update 5 (current).
Impact: Cannot run Octopus 2D box simulations.
The test finite_systems_2d/08-gdlib
of the testsuite fails with a segmentation fault;
all other testsuite components succeed.
I narrowed down the fault due to difficulties in portably passing a string from Fortran to C. In the testsuite, the string contains the name of a PNG file to load. The string arrives on the C side as a pointer with an inconsistent address, including possibly as a null pointer.
See my separate git project at https://gitlab.com/mgsternberg/oct-fortran-c-interop for the full writeup, showing the failure on code isolated from Octopus, as well as Intel-published sample code to show alternative means of Fortran-C string passing in either direction. (Alas, one of the code paths fails to compile with gfortran, sigh!)