Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26747 Discussions

declared variable type not exported from Fortran module

Sebastian_K_
Beginner
196 Views

I am trying to compile a Fortran code including a specific module with the following type declaration and function definition:

integer, parameter, public :: intd = selected_int_kind(17)
...
contains
...
integer (intd) FUNCTION test(name)
implicit none
character (len=*) name
integer(intd),public:: test
...
return
end function test

Then, within file xxx.f the function test is called via:

number=test(input)

While compiling the file xxx.f, the compiler (ifort 16.0.2.XXX) complains, that the type intd didn't get export:

xxx.f(67): error #6404: This name does not have a type, and must have an explicit type. [TEST]
number=test(input)

I'm only able to fix the problem by defining within xxx.f an extra interface block for the function test like the following:

interface
function test(name)
import:: intd
character (len=*), intent(in):: name
integer(int8):: test
end function test
end interface

Is there any limitation within the design of the Fortran module interfaces disallowing the exportation of the declared type intd or is something wrong about the given code?

Greetings

Sebastian

0 Kudos
5 Replies
IanH
Black Belt
196 Views

The compiler is complaining about the name 'test', not 'intd'.

Do you have a USE statement for the module in the scope where the function is referenced?  Is the function 'test' a public entity of the module?

Sebastian_K_
Beginner
196 Views

Hello IanH,

fur sure(!), a USE statement is contained in xxx.f. All other public symbols and (function/subroutine) definitions are correctly exported from the module! !!! Only the type intd is not exported and that's what the compiler is complaining about. I am trying to compile a foreign, closed source code, so I am not allowed to paste the original code.

Greetings Sebastian

Steve_Lionel
Black Belt Retired Employee
196 Views

You should be able to construct a minimal but self-contained example that demonstrates the problem, without revealing any of the private code. My guess is that in the process of doing so you'll figure out what the problem is, but if not post the example and compiling results here.

IanH
Black Belt
196 Views

Sebastian K. wrote:

Hello IanH,

fur sure(!), a USE statement is contained in xxx.f. All other public symbols and (function/subroutine) definitions are correctly exported from the module! !!! Only the type intd is not exported and that's what the compiler is complaining about.

The code you posted shows 'intd' as a public entity of the module.

Sebastian_K_
Beginner
196 Views

Hey guy, thanks very much for your replies.

I was able to detect/resolve the problem:

Unfortunately, a (precompiler) macro definition was missing from the arguments passed to the compiler, so that a relevant part of the code within an #ifdef was not built into the library. An aged version of a template file with missing compiler options/switches was automatically chosen during configuration of the makefile system.

 


 

Reply