- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a huge program with modules inside. All compiled ok but when i introduced a new ,module all sorts of problems occurred which I could not understand . When I put the new module in i got all sorts of errors and none pointed to the root of the problem. From the internet I found that modules must be compiled first ( i think) . When I did this with the introduced module then ran a build all was ok. I also came across the command ifort in the discussions
ifort module1.f90 module2.f90 main.f90
and this can be used to compile modules first . How is this used and where is the procedure inserted
steve Konarski
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You should understand that modules may depend on each other and that therefore the order of compilation is important - each module leads to a module interface file (if that is the correct word) that contains information about the argument list of each public routine inside the module and all the public variables and other entities. These interface files (with an extension .mod) are used by the compiler to check the code in any program unit that uses a particular module..
If you change a source file, say A_file.f90, and thereby the code for a module in that file, say A_mod, then any program unit that uses that module A_mod must be compiled after that file A_file.f90. Otherwise the module interface file for A_mod is out of date.
Build systems like Visual Studio or CMake and others examine the source code and determine the appropriate order of compilation. If you do it manually, then getting it right is a somewhat tedious but important task.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"ifort" is the command one uses in a command line environment to invoke the compiler. If you are using Visual Studio, you don't use that.
Yes, modules must be compiled before program units that use the module. Normally, the Visual Studio build system handles this automatically, but sometimes things get out of synch. The first thing I'd suggest is to right click on the project and select Rebuild.
If that doesn't work, close Visual Studio and open the project folder in a file window. Look for a subfolder named .vs - if you don't see it, open Folder Options, View and enable "Show hidden files, folders and drives". Once you see the .vs folder, delete it. Then open Visual Studio and try building again.
Do make sure that the source containing the module is part of the project.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Steve
thanks for the reply - tried the Rebuild , that didn't work although i think it had some affect earlier when i was trying something- the "new " module is in the .vfprog file, so it appears to be part of the project. I could not find the .vs folder anywhere - maybe i am looking in the wrong place
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you change the folder options to show hidden files, as I suggested?
If nothing else works, create a new project and add your source files to it, then build that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I did change folder options And got nothing - this project is on VS 2012- I have the VS folder on 2022 - can the program on VS2012 be fixed at all or should i give it up as a bad job, The program is huge and any change can send it spinning
thanks Steve for your help - will try creating new project
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah - you didn't mention that you were using such an old version of VS (and presumably the compiler.) I used to see this sort of thing many years ago, not recently. I suggest recreating the project in VS2022 and the current compiler.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
![](/skins/images/045A6C88D0527A93E76B179D7F5E2AFE/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page