Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
4 Views

declared variable type not exported from Fortran module

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
Highlighted
Black Belt
4 Views

The compiler is complaining

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?

0 Kudos
Highlighted
Beginner
4 Views

Hello IanH,

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

0 Kudos
Highlighted
Black Belt
4 Views

You should be able to

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.

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted
Black Belt
4 Views

Quote:Sebastian K. wrote:

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.

0 Kudos
Highlighted
Beginner
4 Views

Hey guy, thanks very much for

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.

 


 

0 Kudos