Nvfortran error with submodules

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.

Hi bfabreges,

It’s a compiler issue and appears similar to other reports we’ve had. I filed TPR#34527 and sent it to engineering to investigate.

Thanks!
Mat

FYI, TPR #34527 should be fixed in our 24.1 release:

% nvfortran -V24.1 -c test_subm.f90
%
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.