- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I undestand the idea of modules andlibraries. My actual problem is a step-by-step working example. If I use some of IVF libraries and modules everthing seems to work fine. Here is what I did:
Created a new project with Microsoft Visual Studio and add a source file to the project with the following code:
program
use_mod use ifport implicit noneend
programThis example I can compile and build without any problems. When I replace use ifortmy own module it won't compile or build. If I call my module module mymodule saved in mods.f90 what are the exact steps I need to do?
When I look in %ifort_compiler10%ia32lib and %ifort_compiler10%ia32include I find ifport.lib and ifport.mod. Which corresponds with how understand the environment variables. Only when I add my stuff is does not seems to work.
Johannes
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It works for modules such as ifport because the path to the IA32INCLUDE folder is automatically added to the list of include directories, where module files are looked for.
Note that compiling a module also results in an object file, which will automatically get linked in if the source was part of your project.
If you have a separate library project that builds the modules, you have to make the library project a "dependent" of the parent project AND add the library project's "output" folder to the list of "additional include directories" for the parent project - that last is not done automatically.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Steve,
my module is in a source file. Adding the source to my project is what I would like to avoid since I use the same module in multiple programs. I also created a userincludewhichI added to my environment variable.This means that my user include directory should be added to the list of include directories bymeans of the environment variable. Or should I add this to some project property in Visual Studio?
Using Visual Studio should I use Project -> Properties or Tools -> Options to find the variables that I have to change. I am new to IVF and Visual Studio.
With my mods.f90 I would like to create module.mod and module.lib (or module.dll) then copy them inmy include and lib directories. And then use them in the same way as ifort for example.
Johannes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Compilation of a module file creates two output files: file.MOD and file.OBJ (sounds like you are aware of this)
The subsequent mod file must be in the INCLUDE path for the USE to work.
If the file.MOD contains only type and interface information (no data) then the .OBJ file need not be linked in with the application.
If the MOD file contains data, then you must link in the .OBJ file of the module (which you may stick into a .LIB file if you wish).
Visual Studio is a bit peculiar in this respect.
If you make your application dependent on the project of the module (sounds like not what you want) then the resultant .OBJ file will be linked into the application and source directory for the module (where the .MOD file is generally written to) is implicitly in your INCLUDE path. So nothing seems to be required of you to get the application to link. Although sometimes I have had to explicitly add the location of the .MOD file to the include directory.
If you build an application without the .MOD project in your dependency then you would generally place these files into your distributables directory and then to build your application you would have to add that directory to the INCLUDE path .AND. add the file.OBJ or yourLib.LIB to the link (which can be done in VS with add existing item and indicating the .OBJ or .LIB in lieu of a source file).
Jim Dempsey

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