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

Module use another module?

Adrian_F_1
Beginner
784 Views

I am consolidating parameter duplication in our code and have defined a parameter SDENW now in one module only, say module A.  However this variable exists in module B too (not just as a parameter definition, which I have removed, but also on the right hand side of other parameter definitions).

To prevent duplication, I tried to let Module B USE module A.  However the link fails as the compiler compiles file B.F90 before A.F90 and therefore cannot find A.MOD.  Of course I could just link twice, but I don't want to do that.  Is there a better way to do this?

0 Kudos
4 Replies
mecej4
Honored Contributor III
784 Views

Adrian F. wrote:

To prevent duplication, I tried to let Module B USE module A.  However the link fails as the compiler compiles file B.F90 before A.F90 and therefore cannot find A.MOD.  Of course I could just link twice, but I don't want to do that.  Is there a better way to do this?

The link step fails because one of the .OBJ files it needs is not present. That situation, in turn, is caused by the compiler's not finding a .MOD file that it needed in compiling B.F90.

Linking twice will not solve the problem, because the problem is a compile-time problem.

The basic rule to remember is that before the compiler encounters the program unit containing the USE statement the corresponding .MOD file should have been created . How to go about enforcing the compilation order depends on whether you are using a makefile or the IDE.

0 Kudos
Adrian_F_1
Beginner
784 Views

mecej4 wrote:

The link step fails because one of the .OBJ files it needs is not present. That situation, in turn, is caused by the compiler's not finding a .MOD file that it needed in compiling B.F90.

Linking twice will not solve the problem, because the problem is a compile-time problem.

The basic rule to remember is that before the compiler encounters the program unit containing the USE statement the corresponding .MOD file should have been created . How to go about enforcing the compilation order depends on whether you are using a makefile or the IDE.

I am using Visual Studio 2010 with Intel Fortran Composer 13. 

0 Kudos
FortranFan
Honored Contributor III
784 Views

Adrian F. wrote:

..

I am using Visual Studio 2010 with Intel Fortran Composer 13.

So if you're using Visual Studio, then most of the module dependency stuff is automatically taken care of assuming you've configured your solution properly.  Have you looked at the Help Viewer in Visual Studio and reviewed Intel's Fortran guide and examples to make sure you're configuration is proper?

Otherwise, you will need to provide your Visual Studio configuration details, preferably a zip of your solution (sln file) and Fortran project(s) (vfproj file(s)) so someone can look and guide you.

 

0 Kudos
Adrian_F_1
Beginner
784 Views

FortranFan wrote:

So if you're using Visual Studio, then most of the module dependency stuff is automatically taken care of assuming you've configured your solution properly.  Have you looked at the Help Viewer in Visual Studio and reviewed Intel's Fortran guide and examples to make sure you're configuration is proper?

Otherwise, you will need to provide your Visual Studio configuration details, preferably a zip of your solution (sln file) and Fortran project(s) (vfproj file(s)) so someone can look and guide you.

No problem, it works fine... I had misspelt the module name in the USE statement!  sorry.  It builds correctly.  Thanks.

0 Kudos
Reply