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

Allocate and subroutines

davidgraham
Beginner
437 Views
I am creating an allocatable array and filling an array with data.

type ObsType
character p*8
integer*4 x,y,z
character desc*32
end type ObsType

common/Obsc/Obs/ObsTot
integer*4 ObsTot
type (ObsType),allocatable :: Obs(:)

allocate (Obs(ObsTot))

I then want to use this data in a subrourine and in the subroutine repeat the type & common definition bove.

Is this the correct way to go about it as I am getting compile errors,
the first is "This COMMON scalar or array is invalid in this context" on the allocatable line,
or cannot you not use allocatable arrays in subroutines?

David



0 Kudos
5 Replies
TimP
Honored Contributor III
437 Views
COMMON can't be ALLOCATABLE. Follow published examples where an allocatable module array is used.
0 Kudos
davidgraham
Beginner
437 Views
Quoting - tim18
COMMON can't be ALLOCATABLE. Follow published examples where an allocatable module array is used.
Where are the published examples?
I have looked in the help - it mentions allocatable but not allocatable module
I am using Visual Fortran 6.0C

0 Kudos
Steven_L_Intel1
Employee
437 Views
I don't think DVF 6.0 had any samples of using allocatable arrays. That version is now 11 years old.
0 Kudos
davidgraham
Beginner
437 Views
Sorry, the version is 6.6C.
Are there any examples elsewhere?

0 Kudos
TimP
Honored Contributor III
437 Views
Quoting - davidgraham
Sorry, the version is 6.6C.
Are there any examples elsewhere?
I was thinking of the example in MR&C textbook, right at the beginning of the discussion of allocatable. What about
http://www.stanford.edu/class/me200c/tutorial_90/09_modules.html
or
http://www.sdsc.edu/~tkaiser/f90.html#Passing arrays to subroutines

0 Kudos
Reply