Diagnostic 6405: The same named entity from different modules and/or program units cannot be referenced.

Submit New Article

August 30, 2009 10:00 PM PDT


This error is reported when an entity (procedure, variable, type, named constant, etc.) is declared in two different modules and is referenced.  For example:

module MODA
integer I_GLOBAL
end module MODA

module MODB
integer I_GLOBAL
end module MODB

program CONFLICT
use MODA
use MODB
I_GLOBAL = 0
end program CONFLICT

In this example, the variable I_GLOBAL is defined in MODA and MODB, both modules are USEd and the variable is referenced.  This last item is important: if the entity is not referenced in the program unit, then it is ok to have multiple entities of the same name visible.  But, once you reference it, it is required that the name have a single definition point.

Note that if you have two modules which both USE the same definition, that is allowed, as there is only one original definition.  For example:

module MODA
integer I_GLOBAL
end module MODA

module MODB
use MODA
end module MODB

module MODC
use MODA
end module MODB

program NO_CONFLICT
use MODB
use MODC
I_GLOBAL = 0
end program NO_CONFLICT

There are two typical approaches to resolving the issue.  First, use an ONLY clause to specify only the desired names from each module.  For example:

use MODA, only: SYMBOL1, SYMBOL2
use MODB, only: SYMBOL3, SYMBOL4

An alternative is to use a renaming clause to change the "local name" of the symbol you don't want to use to something that will not be referenced. For example:

use MODA, DUMMY1 => I_GLOBAL

Note that it is not sufficient to declare a local version of the entity that comes from the modules - this does not hide the module definitions and will result in a different error: Diagnostic 6401: The attributes of this name conflict with those made accessible by a USE statement.

The following known product defects cause this diagnostic to be improperly issued:



Do you need more help?


This article applies to: Intel® Fortran Compiler for Linux* Knowledge Base,   Intel® Fortran Compiler for Mac OS X* Knowledge Base,   Intel® Visual Fortran Compiler for Windows* Knowledge Base