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

modules are not found during compilation

Thomas_S_2
Beginner
1,868 Views

Hi,

I read through all to posts on this subject and read that I have to compile the modules explictily before I compile the rest.

Well this works for my project, but since I build the same project with CodeBlocks I got the question wy this is necessary. In CodeBlocks the modul file are precompiled automatically.

So I read through "Creating a New Project in the Fortran Developers Guid and found this passage:

Working with Fortran Modules

If your program uses Fortran modules, you do not need to explicitly add them to your project; they appear as dependencies (.MOD files).

A module file is a precompiled, binary version of a module definition, stored as a .mod file. When you change the source definition of a module, you can update the .mod file before you rebuild your project. To do this, compile the corresponding source file separately by selecting the file in the Solution Explorer window and selecting Build > Compile. If the module source file is part of your project, you do not need to compile the file separately. When you build your project, the Intel® Fortran Compiler determines what files need to be compiled.

To control the placement of module files in directories, use Project > Properties > Fortran > Output Files > Module Path in the IDE or the compiler option [no]module on the command line. The location you specify is automatically searched for .mod files.

To control the search for module files in directories, select one of the following:

  • In the IDE
    • Project > Properties > Fortran > Preprocessor > Default Include and Use Path

    • Project > Properties > Fortran > Preprocessor > Ignore Standard Include Path

  • On the Command Line

    • X or I and assume:source_include compiler options.

     

For a newly created project (or any other project), the IDE scans the file list for sources that define modules and compiles them before compiling the program units that use them. The IDE automatically scans the added project files for modules specified in USE statements, as well as any INCLUDE statements. It scans the source files for all tools used in building the project.

 

Now my question: The guide says that the modul files will be autometically compiled by the ide. But actualy this doesn't work for me.

Help appreciated,

Thomas

0 Kudos
4 Replies
andrew_4619
Honored Contributor II
1,868 Views

It is not clear from the information what causes your problem, you do not need to be adding and changing module paths and that could be a source of problems. Within a project folder the VS creates folders such as "release" , "debug" etc for each configuration in the project.

So when you do a release build When you compile .obj .mod and other files are automatically created in the "release" folder but as a user you do not need to know or do anything with these files the system creates and uses than as required.

You may have a problem with circular dependencies  e.g. module A uses module B and module B uses Module A. If you do a clean build you will always get an error because whatever the order there will be a missing module as it has not been compiled yet. A repeat build often then succeeds because there is a module from the first attempt existing.  You should fix such problems.

Why not demonstrate that system works by making a new solution and project with default option using the example source files  below:

! first source file
module fred
   implicit none
   contains
   subroutine bill(ivar)
      integer, intent(out) :: ivar
      ivar = 42
   end subroutine bill
end module fred

! second source file
program bill_user
   use fred
   implicit none

   integer :: i
   call bill(i)
   write(*,*) 'I=',i
end program bill_user

 

0 Kudos
Thomas_S_2
Beginner
1,868 Views

Hi Andrew,

meanwhile I tested the project module dependencies with several other compiles. No problems with circular dependcies. Then I compiled the project in CodeBlocks (CB) with gfortran and ifort. Both tests succeeded. Since I'd like to debug it, I came back to VS and created the project in vs2015 from scratch.Now it workes. But I do not understand why?

Now I have the problem that the release version in VS runs but if I try the same input files with the debug version it crashes. (I develop FEM-Software)  Compiling with ifort in CB both (release and debug) version runs. Well I should post this elsewhere. I'll come back to you as soon as I encounter additional problems with modules.

Thanks so far, Thomas

0 Kudos
andrew_4619
Honored Contributor II
1,868 Views

Thomas S. wrote:
Now it works. But I do not understand why?

I often have this feeling also, either the software messed up, you messed up or both.....hey ho that's life.

As to why debug should fail, release does not. It is normally the other way around as (for example) debug does not optimise code so there are no possible optimisation bugs. That said, bugs in your code that corrupt things will behave differently as the memory arrangement in debug is different, you may corrupt something that is not important in debug...

  At least with the debug going wrong you can debug it! good luck!

0 Kudos
NotThatItMatters
Beginner
1,868 Views

I have had the same problem writing FEM software that runs in Release and crashes in Debug.  In my experience this has been a question of floating-point arithmetic problems due to matrix near-singularity.  Unfortunately, in my case it was a long haul until that problem was found and resolved.  For me it involved stiffness and stress matrix checks (every term) and hand calculations until I found the culprit.

0 Kudos
Reply