Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

Q about INCLUDE statements re COMMON blocks

WSinc
New Contributor I
827 Views
Hello -

I have 15-20 routines in several different projects. They generally are in the same
solution space, but not always.

Anyway, these routines all use the same COMMON region. So I have an INCLUDE
statement pointing to that COMMON region in each one. The problem is that
they all want to look for the same folder that they are in when the compiler
sees the INCLUDE statement.

How may I set up the INCLUDE text so that ALL the routines can find it? I obviously want only ONE
version of the common block laying around, if at all possible.
The idea is, that one change to the COMMON block will retrigger all routines to recompile.
And they are all guaranteed to have the same COMMON region.

So - do I have to put the COMMON block in the parent folder, or is there some easier way to tell
the compiler where to look?

Where should the COMMON block be put in the project space?
resources, header, or where else? You have several choices.....

Actually, the INCLUDE could have PARAMETER statements that globally should affect all the routines.

Is there an article about this? There should be one......
0 Kudos
8 Replies
DavidWhite
Valued Contributor II
827 Views
Modules are a far better way of handling this than the older COMMON.

e.g.

Module MyCommonData
...
!include all variable declares including parameters
...
End Module MyCommonData

then in the code for each routine, you need to add

USE MyCommonData

Regards,

David
0 Kudos
mecej4
Honored Contributor III
827 Views
It is better to use modules. However, if you stick with INCLUDE:

To the compiler it does not matter what you have in the INCLUDEd files. The contents could be comments, declarations, executable statements -- anything. After the inclusions are processed in a "processor dependent" way, the resulting text should be valid Fortran source code. Most compilers provide a way to specify where to look for inclusions; for IFort, the -I option does so. You can specify a relative path in the INCLUDE statement, such as

INCLUDE '../incl/mycomn.inc'

You can specify absolute paths, as well. If the source files reside in different directories, it is up to you to put the correct paths in the INCLUDE statements in those files, and to put up with the hassle of updating those statements if you move the files.

Using INCLUDE for COMMON blocks has the limitation that all project source files which INCLUDE the block declarations have to use the same variable names and types. Many old style Fortran programs do not cooperate in this regard.
0 Kudos
GVautier
New Contributor III
827 Views
Hello

Create an include directory, put your files to be included in it and declare that path in the include directories section of compiler options. It may contains several path separated by half colons.

0 Kudos
WSinc
New Contributor I
827 Views
THIS DOES NOT WORK. It won't compile -

The USE statement triggers an error.

The compiler makes some remark about "error 7002" and
some reference to "check include path."

Doesn't the module have to be in a special place so that
other subroutines can find it, like resource, header, etc.

If I put the MODULE in the resource files, then every project that uses it
must also have that MODULE in their resource folder, so I still
can't centralize the MODULE in one place. But at lease they compile.

I am wondering if the is a central place in the SOLUTION space that
would get around this problem.

When I put the MODULE in the same place as the other routines,
they can't find it. In fact it screws up VS 2008 so badly
that it skips over compiling anything, so a REBUILD has no effect.

0 Kudos
DavidWhite
Valued Contributor II
827 Views
Can you show us what you did to include the module?

The module file needs to be either part of an existing source (.f90) file (above any references to USE the module), or in a separate source file which is part of the project. The module will get compiled just like any other source files in the project.

It should create a .mod file in the default Modules folder for the project. If you have changed the defaultpaths for Module Path - normally $(IntDir)\ - you may need to check that all sources can access this.

Regards,

David
0 Kudos
IDZ_A_Intel
Employee
827 Views
I put the MODULE in a separate F90 file, and compiled it.
MODULE solve_mod

arrays, parametes, etc.

END MODULE

The routines that USE it have the USE statement in the second line, like:

USE solve_mod


But I have to put the MODULE in the resource folder, I can't put it with with the other
subroutines, or things get really goobered up.


0 Kudos
WSinc
New Contributor I
827 Views
I looked at the project properties.

Apparently you can add other directories to your RESOURCES.

So I guess it expects MODULES to be in the resources folder.

The problem then becomes, where to put the MODULES such that
all the projects can access them.

Is there a centralized location in the SOLUTION space?
0 Kudos
Les_Neilson
Valued Contributor II
827 Views
Surely on a projectbasis it is better to add the relative (or absolute; if you must)path to thelist in :
Project->Properties->Fortran->General->Additional Include Directories

This specifies the directories to search for "include" files and for modules.

Les
0 Kudos
Reply