The following program, looks quite legal to me, gives error message : duplicate name.
! Koenig.f95
module M1
INTEGER, public :: p
public :: AA
private :: BB
CONTAINS
subroutine AA ()
p = BB ()
CONTAINS
subroutine AA_1 ()
integer :: i
i = BB ()
end subroutine AA_1
function BB( ) result(r)
integer :: r
R = 1
end function BB
end subroutine AA
function BB() result(Q)
integer :: Q
Q = 2
end function BB
end module M1
program P1
USE M1
implicit none
p = 0
call AA ()
print *, p
end program P1
! D:\Fortran\Test>ftn95 koenig.f95 /lgo ! [FTN95/Win32 Ver. 4.8.0 Copyright (C) Salford Software Ltd 1993-2005] ! PROCESSING MODULE [<M1> FTN95/Win32 v4.8.0] ! 0012) integer :: i ! WARNING - Variable I has been given a value but never used ! NO ERRORS, 1 WARNING [<AA_1> FTN95/Win32 v4.8.0] ! NO ERRORS [<BB> FTN95/Win32 v4.8.0] ! NO ERRORS [<AA> FTN95/Win32 v4.8.0] ! 0022) function BB() result(Q) ! *** Duplicate sub-program name M1!BB ! 1 ERROR [<BB> FTN95/Win32 v4.8.0] ! NO ERRORS [<M1> FTN95/Win32 v4.8.0] ! NO ERRORS [<P1> FTN95/Win32 v4.8.0] ! *** Compilation failed
JvO