- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
First of all, sorry for a newbie quiestion on this forum.
1st case, I have two simple fortran modules, A_MOD and B_MOD:
2nd case, similar three modules, A_MOD, B_MOD and C_MOD:
- A uses B
- B uses C
- C uses A
In any of such combinations, how do I compile the program? To compile A, I need B to be compiled, which needs A. Heard about some vague solution, where:
- in A you comment lines 2 and 5
- compile A
- compile B
- uncomment A
- delete all/some .obj and/or .mod files (???)
- recompile (what?)
Tried, no success, as I do not understand it.
Any hint would be very appreciated. :)
Regards,
Mario
First of all, sorry for a newbie quiestion on this forum.
1st case, I have two simple fortran modules, A_MOD and B_MOD:
[bash]MODULE A_MOD
USE B_MOD
INTEGER PAR_1
...
IF (PAR_2 .GT. 0) CYCLE
...[/bash]
[bash]MODULE B_MOD
USE A_MOD
INTEGER PAR_2
...
IF (PAR_1 .GT. 0) CYCLE
...[/bash]
2nd case, similar three modules, A_MOD, B_MOD and C_MOD:
- A uses B
- B uses C
- C uses A
In any of such combinations, how do I compile the program? To compile A, I need B to be compiled, which needs A. Heard about some vague solution, where:
- in A you comment lines 2 and 5
- compile A
- compile B
- uncomment A
- delete all/some .obj and/or .mod files (???)
- recompile (what?)
Tried, no success, as I do not understand it.
Any hint would be very appreciated. :)
Regards,
Mario
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, this is interesting - a post written by no username. Hmm.
The short answer is "don't do that" - a circular module dependency is not legal Fortran and will, as you note, cause problems when you try to build. If A and B are really that related, put them in the same module. Otherwise, perhaps moving some common items to a third module C will break the mutual dependency.
The short answer is "don't do that" - a circular module dependency is not legal Fortran and will, as you note, cause problems when you try to build. If A and B are really that related, put them in the same module. Otherwise, perhaps moving some common items to a third module C will break the mutual dependency.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Mario,
As Steve recommends seperate the data such that you have no circular dependencies.
MODULE A_MOD_DATA
INTEGER PAR_1
...
------------------------
MODULE B_MOD_DATA
INTEGER PAR_2
...
----------------------
MODULE A_MOD_CODE
USE B_MOD_DATA
...
IF(PAR_1 .GT. 0) CYCLE
...
------------------------
MODULE B_MOD_CODE
USE A_MOD_DATA
...
IF(PAR_2 .GT. 0) CYCLE
...
This doesn't fix situations were you are co-dependent on subroutines and/or functions, but this can be fix using INTERFACE blocks.
Jim Dempsey
As Steve recommends seperate the data such that you have no circular dependencies.
MODULE A_MOD_DATA
INTEGER PAR_1
...
------------------------
MODULE B_MOD_DATA
INTEGER PAR_2
...
----------------------
MODULE A_MOD_CODE
USE B_MOD_DATA
...
IF(PAR_1 .GT. 0) CYCLE
...
------------------------
MODULE B_MOD_CODE
USE A_MOD_DATA
...
IF(PAR_2 .GT. 0) CYCLE
...
This doesn't fix situations were you are co-dependent on subroutines and/or functions, but this can be fix using INTERFACE blocks.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve, Jim,
Thanks for very quick replies. I'm recompiling large, someone elses program and to be honest - have no time to refactor too much of it. My predecessor used to compile it by this 'illegal' operation of commenting and deleting. I was curious maybe someone else knows this hack. Anyway, thanks again for your repies.
P.S. Don't know why my username did not appear, I was logged in...
Thanks for very quick replies. I'm recompiling large, someone elses program and to be honest - have no time to refactor too much of it. My predecessor used to compile it by this 'illegal' operation of commenting and deleting. I was curious maybe someone else knows this hack. Anyway, thanks again for your repies.
P.S. Don't know why my username did not appear, I was logged in...

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page