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

Dumb Question #3 Module dependencies within a file

keefer
Beginner
582 Views
Hi,
If I have two subroutines in the same file, A and B, A appearing first and B calling A, there seems to be no problem resolving B's reference to A. If I have the same situation, but A and B are modules, and B uses A, B cannot find A. This is more than a minor annoyance, because even if A and B are related in the program, I need to find another file in which I can "hide" B, even though it has no logical relationship to anything else in that file. Is this a bug or a "feature"? If it is a feature, what is the rationale behind it?
Regards,
Keith
0 Kudos
4 Replies
Steven_L_Intel1
Employee
582 Views
If you just have two subroutines, the linker is what needs to resolve the reference, and once it has loaded the object, it has all the symbols. Modules are processed by the compiler and the standard says that a module has to be "available" when you USE it. Forward module references in a file are not required to work, and don't in most compilers.
0 Kudos
wkramer
Beginner
582 Views
I guess I misunderstand the question, but I believe I do this all the time. I.e. have function B in modB refer to function A in modA. I sometimes have to build (not a complete rebuild) such applications twice in a row because modA.mod may not exist the first time around, but it seems to work.
But then again, I probably misunderstood the question.
Walter
0 Kudos
keefer
Beginner
582 Views
Walter,
I think that you have found a "workaround" to my issue. I was assuming that a .mod file would be created by the compiler for A and then be accessible to B. This is apparently not the case. Also, I think Steve misunderstood that B was making a backward, not a forward reference to A. What may be happening in the case that you describe is that the .mod for A is created the first time you compile, but the compilation of B crashed. On the second compilation, a rebuild, A was ignored because a current version already existed and this time B found it.
Thanks to both of you for your replies.
Regards,
Keith
0 Kudos
wkramer
Beginner
582 Views
Keith,
Yes, this is probably what is happening.I suppose that for simple situationsthe dependency checker will make sure that the sequence of compilation is correct, but in more complex situationsthere may be no (or hard to determine?) proper sequence. Under these circumstances the repeated build can help out.
Walter

Message Edited by wkramer on 12-05-2004 11:16 AM

0 Kudos
Reply