Hello, I have encountered an error while using submodules with nvfortran. I wrote the following MWE.
MODULE m1
implicit none
INTERFACE
MODULE PURE FUNCTION getlen( string ) result( out )
character(len=*), intent(in) :: string
integer :: out
END FUNCTION getlen
MODULE SUBROUTINE print_hello
END SUBROUTINE print_hello
END INTERFACE
END MODULE
MODULE m2
USE m1, only : getlen
implicit none
character(len=5), parameter :: hello = "hello"
CONTAINS
SUBROUTINE foo
write(*, *) getlen("test")
END SUBROUTINE
END MODULE
SUBMODULE (m1) sub_m1
USE m2, only : hello
implicit none
CONTAINS
PURE FUNCTION getlen( string ) result( out )
character(len=*), intent(in) :: string
integer :: out
out = len(trim(string))
END FUNCTION getlen
SUBROUTINE print_hello
write(*, *) getlen( hello )
END SUBROUTINE print_hello
END SUBMODULE sub_m1
PROGRAM Test
USE m1, only : print_hello
implicit none
call print_hello()
END PROGRAM Test
Using nvfortran 23.3 or 23.9, I got the error:
NVFORTRAN-S-0038-Symbol, out, has not been explicitly declared (test.f90)
I’m not sure if it’s a compiler bug or not. It compiles fine with gfortran.