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

Fortran Compiler error #6405

Glenn1
Beginner
2,556 Views
I'm receiving an "error #6405: The same named entity from different modules and/or program units cannot be referenced. [VERIFICATION_FLG]" when compiling in DEBUG mode for versions 11.0.075 - 11.1.038 whereas I did not have these in previous versions of the FORTRAN compiler. The compiler indicates the error on the second invoke of an external function and any subsequent invokes made in the code. The code will compile successfully if the function is only invoked one time.

I created a sample project to illustrate which contains three source code files:

1.) Main
2.) External Function
3.) Module

I've attached the three source code files for examination. I would appreciate any helpful advice. Thanks!
0 Kudos
1 Solution
Steven_L_Intel1
Employee
2,556 Views
This is a compiler bug which I have escalated as issue DPD200139304. You encounter this problem if you do the following:

1. Declare a Fortran procedure as EXTERNAL in a module, not using an interface block
2. Use the module
3. Call the procedure more than once

My preference for coding this sort of thing is either:

1. Make the procedure a module procedure and not external
2. As noted in this thread, write an INTERFACE block for the procedure. I don't like this because, as I have written elsewhere, writing an interface for a Fortran procedure means you're writing it twice and have to keep it consistent.

View solution in original post

0 Kudos
9 Replies
onkelhotte
New Contributor II
2,556 Views
Quoting - Glenn
I'm receiving an "error #6405: The same named entity from different modules and/or program units cannot be referenced. [VERIFICATION_FLG]" when compiling in DEBUG mode for versions 11.0.075 - 11.1.038 whereas I did not have these in previous versions of the FORTRAN compiler. The compiler indicates the error on the second invoke of an external function and any subsequent invokes made in the code. The code will compile successfully if the function is only invoked one time.

I created a sample project to illustrate which contains three source code files:

1.) Main
2.) External Function
3.) Module

I've attached the three source code files for examination. I would appreciate any helpful advice. Thanks!

I think that declaring Verification_Flg as external is not right. When you put it in an interface block, it works just fine...

Markus

[cpp]MODULE Module_Externals
  interface
    logical function Verification_Flg(c,r)
        INTEGER,INTENT(IN),OPTIONAL:: c 
        INTEGER,INTENT(IN),OPTIONAL:: r 
    end function Verification_Flg
  end interface
ENDMODULE Module_Externals[/cpp]
0 Kudos
Glenn1
Beginner
2,556 Views
Quoting - onkelhotte

I think that declaring Verification_Flg as external is not right. When you put it in an interface block, it works just fine...

Markus

[cpp]MODULE Module_Externals
  interface
    logical function Verification_Flg(c,r)
        INTEGER,INTENT(IN),OPTIONAL:: c 
        INTEGER,INTENT(IN),OPTIONAL:: r 
    end function Verification_Flg
  end interface
ENDMODULE Module_Externals[/cpp]

Markus,

Thanks for the quick response and quick fix to my problem.

Glenn.
0 Kudos
Steven_L_Intel1
Employee
2,556 Views
The original code should work, though the interface block is preferable. It would be best if the called function were a module procedure so you didn't have to declare it twice.

I'll raise this to the developers.
0 Kudos
Steven_L_Intel1
Employee
2,557 Views
This is a compiler bug which I have escalated as issue DPD200139304. You encounter this problem if you do the following:

1. Declare a Fortran procedure as EXTERNAL in a module, not using an interface block
2. Use the module
3. Call the procedure more than once

My preference for coding this sort of thing is either:

1. Make the procedure a module procedure and not external
2. As noted in this thread, write an INTERFACE block for the procedure. I don't like this because, as I have written elsewhere, writing an interface for a Fortran procedure means you're writing it twice and have to keep it consistent.
0 Kudos
Glenn1
Beginner
2,556 Views
Steve,

Thanks for the response. I'll see about adjusting the code as you suggest, meanwhile, I'll be awaiting a new release that corrects the compiler bug.

Thanks,
Glenn.
0 Kudos
Steven_L_Intel1
Employee
2,556 Views
You will be waiting a while - I don't expect this one, given its easy workaround and limited exposure, to be fixed before the next major release.
0 Kudos
JVanB
Valued Contributor II
2,556 Views
The original code should work, though the interface block is preferable. It would be best if the called function were a module procedure so you didn't have to declare it twice.

I'll raise this to the developers.

OPTIONAL => explicit interface
0 Kudos
Steven_L_Intel1
Employee
2,556 Views
Quoting - Repeat Offender

OPTIONAL => explicit interface

Well, yes. Remember that making the routine a module procedure automatically creates an explicit interface. Ideally, you should need INTERFACE blocks only for non-Fortran routines or when declaring generics.
0 Kudos
Steven_L_Intel1
Employee
2,556 Views
The compiler bug giving the spurious error will be fixed in a future update.
0 Kudos
Reply