I'm facing an odd problem while trying to use Lapack function dlantr
to compute norm of triangular matrix. Basically, I had a working single-file program with dlantr
and some other Lapack procedures in it, and now I want to split it into modules. dlantr
ended in subroutine in one such module. However, trying to compile said module with gfortran-10 (through MPI wrapper compiler, since there's also some MPI in there) like
mpifort -o kde.o -c kde.f90
leads to an error :
‘dlantr’ at (1) is not a function
which is strange, because
dtrtri
and dpotrf
) in the same subroutine work alrightsubroutine foo(a)
real(kind=DP), intent(in) :: a(2,2)
real(kind=DP) :: tmp, dlantr
print*, dlantr('F','L','N',2,2,a,2,tmp)**2
end subroutine
also works fine when called from the main program. In the subroutine where the problem arises, it is declared in the same way as above and in the original program, that is
real(kind=DP) :: ..., dlantr, ...
The code in question can be found here. What could be causing such behaviour, and how to fix it?
My original answer was wrong. This is a compiler bug, probably https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87127. Still, this workaround of explicitly using the external
attribute makes the error go away:
real(kind=DP), external :: dlantr
The MWE for this bug is:
subroutine sub
integer :: d
real :: f
real :: a
associate (c => d)
a = f()
end associate
end subroutine sub