Open rofirrim opened 1 month ago
Fortran unfortunately allows one name to refer to multiple symbols in the same scope in a few cases. One of these cases is the use of a single name to refer to both a generic interface as well as one of its specific procedures. When this happens, it is not possible for a module to contain one and not the other.
f18's module files are just Fortran, so you can cat
them and see this in action.
I suspect that the name mangling code isn't checking for this case. In the symbol table built by semantics, it is represented as a GenericDetails symbol in the scope's name map, and the GenericDetails has a specific()
member function that points to the SubprogramDetails symbol of the same name that is not in the scope's name map.
Consider the following module, simplified from a real module of OpenMPI
And the following three modules, each one in a different file (stated in the first comment)
If we compile them in the proper order
mesh.f90
fails to compile with the following errorWe try to mangle a
GenericDetails
.It seems the problem stems in the exported symbols my
math
(andmesh
) in which we see repeated references tompi_allreduce
(this suggests we might be exporting both the generic interface name and the external name) from these modules.but somehow is not a problem for
comm
(which is hopefully exporting only the generic name?)The problem seems related to the generic interface in
mini_mpi.f90
because commenting it solves the problem. But modifying the OpenMPI module is a bit of an inconvenient workaround.