If more than one module contains identically named variables, and a program unit USEs more than one such module, and there are no rename clauses or ONLY clauses in the USE statements to suppress duplicates, references to those variables become ambiguous, and the language does not allow it. Section 11.3.2 of the Fortran 95 standard says
Two or more accessible entities, other than generic interfaces, may have the same name only if the name is not used to refer to an entity in the scoping unit. Generic interfaces are handled as described in section 14.1.2.3. Except for these cases, the local name of any entity given accessibility by a USE statement shall differ from the local names of all other entities accessible to the scoping unit through USE statements and otherwise.
FTN95 8.51 fails to detect the duplicate declarations and definitions in the following example, even with /checkmate:
module mod1
implicit none
integer :: w1=0, w2=-1, w3=-2
end module mod1
module mod2
implicit none
integer :: w1=2, w2=3, w3=-1
end module mod2
subroutine sub(x,y,z,n)
use mod1
use mod2
implicit none
integer, intent(in) :: n
real, dimension(n) :: x,y,z
integer i
if(w1 > 1)z(1:n) = x(1:n) + y(1:n)
return
end subroutine
program pgm
implicit none
real x(4),y(4),z(4)
call random_number(x)
call random_number(y)
call sub(x,y,z,4)
print *,z
end program
Gfortran says: modbug.f90:18:5:
18 | if(w1 > 1)z(1:n) = x(1:n) + y(1:n) | 1 Error: Name 'w1' at (1) is an ambiguous reference to 'w1' from module 'mod1'