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

Qustion on cross reference in Fortran 90

pecan_zq
Beginner
279 Views

Hi Guys,

I am having a trouble using Fortran 90 with the following example:

I created two classes named pipe and connector

Module Class_pipe

use Class_connector

type Pipe

type(Connector),pointer :: conn

end type Pipe

End Module Class_pipe

Module Class_connector

use Class_pipe

type Connector

type(Pipe),pointer :: conn

end type Connector

End Module Class_connector

This piece of coding does not compile. I think it is because in the Module Class_pipe I "use" the Class_connector, while in the Module Class_connector I "use" the Class_pipe. Itis a cross reference situation. If I put the two type definition into one module, the code can compile, but I really hate to do so. Anyone can help me to resolve the problem?

Quan

0 Kudos
1 Reply
Paul_Curtis
Valued Contributor I
279 Views
You've answered your own question -- circularities of this sort are not allowed. Also, if your two UDTs need to reference each other, they are not logically distinct and belong in the same module anyway. Nothing wrong with putting all your types in a single module, and grouping your functions into separate modules which all USE the types module.
0 Kudos
Reply