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

modules only on VS2005

jimdempseyatthecove
Honored Contributor III
979 Views

Is there a way to have a solution inVS2005 to contain aproject thatcompiles the IVFmodules only. To date, I have been creating a dummy static library or a dummy console application. and then make other ptojects dependent on that(those) project(s). This works but you also end up with a bogus .lib or .exe file. What is the recommend way to compile a bunch of modules without producing an execuitable or .lib file? It would seem like the integration of IVF into VS should have this type of project. So I must be misunderstanding something.

Jim

0 Kudos
6 Replies
Zhanghong_T_
Novice
979 Views

I think the module need not be compiled separately. You can include a source file only contains the module in the project, after compiling, the .mod file will be generated. You can link the .mode file to any other project.

For example, source.f90 have the following module:

module mymodule

! define your data

contains

! your subroutines contained in the module

end module

After compiled, a file named mymodule.mod will be generated. You can link it to some other project and the write

use mymodule

in your project.

0 Kudos
Steven_L_Intel1
Employee
979 Views

The recommended method is a static library, and the .lib is not "bogus". While it is true that in some circumstances it is not needed, there are some types of definitions in modules that require linking in the object code produced when the module was compiled. Making the static library project a dependent of the main project is exactly what you should be doing, and that will cause the module's library to be linked it automatically.

0 Kudos
jimdempseyatthecove
Honored Contributor III
979 Views

If the module (files) have no "contains" (no code) wouldn't the produced obj files and thus .lib file be void of data/code?

While the compiler is unhappy with empty source files, the linker currently is happy to accept .obj files and lib files with no data/code. So linking in a void static library might be benign until the linker writers deam void files are erronious (just as the compiler nowassumes void files are erronious). Since the linker is outside the control of Intel isn't there a problem waiting to happen?

Additionaly the "Depends on" forces inclusion in link if the target is a static libas opposed to compile to .mod file only. So to defend against future linker problem (void .lib) I would think the bogus .exe file would be the safest route.

In the older IDE and MAKE system you could specify a project depended on an arbitrary file, in this case the .MOD files and then the MAKE file would include a section that produced the missing files, in this case compile to .MOD but not .OBJ unless instructed to do so via options. (or compile to .OBJ & .MOD and then promptly delete the .OBJ file).

Jim

0 Kudos
Steven_L_Intel1
Employee
979 Views

The object file is not empty and the linker has no problems with it.

Some derived type and PARAMETER declarations can create needed object code. If there is none, then it is harmless to link in the module. I suggest not worrying about it.

0 Kudos
jimdempseyatthecove
Honored Contributor III
979 Views

I suppose Ican have the module contain a dummy static variable or one that is useful. e.g.

integer, parameter:: Version = 123456

But I have not checked the ASM code to make sure a PARAMETER creates a static instance of the variable for non-IVF modules to access. e.g. fora C++ module to access FOOmod::Version directly.

And, as you say, if the derived type contains initialization, then code is generated to perform the initialization upon instantiation. So in that case the .LIB is required (or at least the .obj is required).

Jim

0 Kudos
Steven_L_Intel1
Employee
979 Views

Why are you worrying about this? Don't go out of your way to create additional symbols. Just let the library link in and you'll be covered. If you're distributing the modules to others you may want to test to see if you can avoid distributing the .lib, but otherwise I'm sure you have better things to do.

If you must know, the kinds of PARAMETERs that generate data for the object file tend to be character, array and derived type, and sometimes only if you DLLEXPORT them. Derived type initialization is done either statically or with code generated by the compiler when the module is USEd, not when the module is compiled.

Here's what's in the object of an empty module file called EMPTY:

COFF SYMBOL TABLE
000 00000000 DEBUG notype Filename | .file
emptymod.f90
002 00000001 ABS notype Static | @feat.00
003 00000000 SECT1 notype Static | .text
Section length 4, #relocs 0, #linenums 0, checksum 0
005 00000000 SECT1 notype () External | _EMPTY.
006 00000000 SECT2 notype Static | .debug$S
Section length 93, #relocs 0, #linenums 0, checksum 0

String Table Size = 0x0 bytes

Summary

93 .debug$S
4 .text

0 Kudos
Reply