Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Intel_C_Intel
Employee
62 Views

Combination of Modules,Commonarea and equivalence

Hi!

Ive made a dummymodule in which ive included a global commonareadefinition through an include-statement.
like this

module Commonarea
INCLUDE MyCommonArea.for'
contains
subroutine dummy
end subroutine dummy
end module Commonarea

The reason for this is to be able to use the commonarea in both *.for and *.f90-files.

In one of the subroutines in my program Im storing the common in an unformatted file. Ive created a huge integerarray and using an equivalencestatement between the first item in the integerarray and the first item in the common to map the memory into my integerarray.

If im using the Use-statement, this doesnt work, but if Im using INCLUDE MyCommonArea.for' instead then it works

Ex:

subroutine test

! Alt 1, not working
USE Commonarea
! Alt 2, working
INCLUDE MyCommonArea.for'

integer inrArr(10000)

equivalence(FirstItemInCommon, intarr(1) )

!StartOfCode

intNo = 1 ! DummyCode

end subroutine test

Can anyone explain the difference or suggest a solution to my problem.

/Martin
0 Kudos
1 Reply
Steven_L_Intel1
Employee
62 Views

The COMMON you define in the MODULE is not the same as the one that's INCLUDEd directly. Remember that INCLUDE is just source substitution.

Why don't you use the USE statement in your *.for files? It will work fine.

Steve
Reply