Module A includes module B. Module A has a submodule that executes a function from module B.
If module A has a private statement, linking is not possible. This seems to be incorrect because the private statement should have an effect only on other modules that use module A, but not on the submodule (which is technically part of module A).
A full example is given onhttps://cloud.martin-diehl.net/index.php/s/Jk5NPWMrJRn5fkM. If someone from PGI has downloaded it, please let me know because I want to disable the share.
Thanks Martin. I was able to get the source so feel free to delete the link.
This does indeed look like a compiler issue so I’ve added TPR#27999 and sent it to engineering for further review.
Given the bug looks like the private statement is causing the compiler to make moduleB’s routines inaccessible from submodule A, one work around is to make moduleB’s routines public.
% cat moduleA.f90
module moduleA
use moduleB
implicit none
private
real :: a
interface
module subroutine submoduleA_init
end subroutine submoduleA_init
end interface
public :: &
moduleA_init, moduleB_init
contains
subroutine moduleA_init
print*, 'moduleA_init'
call submoduleA_init
end subroutine moduleA_init
end module moduleA
% pgfortran moduleB.f90 moduleA.f90 submoduleA.f90 main.f90; a.out
moduleB.f90:
moduleA.f90:
submoduleA.f90:
main.f90:
main
moduleA_init
submoduleA_init
moduleB_init