Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29271 Discussions

The same named entity from different modules and/or program units cannot be referenced

milenko1976
Beginner
3,492 Views
ircg.for(234): error #6405: The same named entity from different modules and/or program units cannot be referenced. [MISFIT1]
call misfit1(fa,fb)
module mf
contains
subroutine misfit(fa,fb)
implicit none
integer:: fa,fb
real,dimension(20,4):: model,data,dmf
do fa=1,20
read(20,175)(model(fa,fb),fb=1,4)
175 format(f11.6,2x,f11.8,2x,f11.6,2x,f11.8)
end do
do fa=1,20
read(15,175)(data(fa,fb),fb=1,4)
end do
do fa=1,20
do fb=1,4
dmf(fa,fb)=model(fa,fb)-data(fa,fb)
write(16,*)dmf(fa,fb)
end do
end do
end subroutine
end module
module mf1
contains
subroutine misfit1(fa,fb)
implicit none
integer:: fa,fb
real,dimension(20,4):: model,data,dmf
do fa=1,20
read(120,175)(model(fa,fb),fb=1,4)
175 format(f11.6,2x,f11.8,2x,f11.6,2x,f11.8)
end do
do fa=1,20
read(15,175)(data(fa,fb),fb=1,4)
end do
do fa=1,20
do fb=1,4
dmf(fa,fb)=model(fa,fb)-data(fa,fb)
write(116,*)dmf(fa,fb)
end do
end do
end subroutine
end module
Which entities are making problems?fa,fb?I have to change variable names?
0 Kudos
2 Replies
mecej4
Honored Contributor III
3,492 Views
> Which entities are making problems?fa,fb?I have to change variable names?

Neither. There is no syntax error in the module code that you showed.

The error message that you used as the title of this thread could have come from other code where these modules were USEd. If that code tried to use modules mf and mf1, and both modules contained a subroutine called misfit1, there would be a name clash, since there would be ambiguity as to which of the two subroutines to use, since both are named, perhaps aptly, misfit1.

You have to decide for yourself what you are trying to accomplish and resolve the name clash accordingly.

Fortran provides two means for resolving clashes:

A. If the two versions of misfit1 differ as to argument types, you can use module procedures and overloaded interface names.

B. The rename subclause of the USE statement. For example:

USE mf, misfitA => misfit1
USE mf1, misfitB => misfit1
0 Kudos
milenko1976
Beginner
3,492 Views
Thanks a lot,I see the point now.
0 Kudos
Reply