I'm learning Fortran submodule, this is my code
module name1
implicit none
interface
module subroutine test2(x)
integer,intent(in) :: x
end subroutine test2
end interface
contains
subroutine test1(x)
integer :: x
call test2(x)
end
end module name1
module name2
use name1
implicit none
integer :: z = 22
end module name2
submodule(name1) new
use name2
contains
subroutine test2(x)
integer,intent(in):: x
integer:: y
y = 2
print *, x+y+z ,'from test2'
end
end submodule
program name
use name2
implicit none
call test1(5)
end program name
But while compiling with ifort (IFORT) 2021.3.0 20210609 it shows the following error
test.f90(26): error #6645: The name of the module procedure conflicts with a name in the encompassing scoping unit. [TEST2]
subroutine test2(x)
-------------------^
compilation aborted for test.f90 (code 1)
I can't understand what I'm doing wrong. Is it not a valid Fortran submodule use?