I'm not quite sure what you are asking, but that won't stop me from
answering ;-( .
Two things come to mind. You can use a higher dimensioned array
to "contain" smaller dimensioned arrays. Something like:
real composite (10,7,3)
...
composite(1,:,:) = something that is a 7 by 3 array
composite(2,:,:) = something that is a 7 by 3 array
...
composite(10,:,:) = something that is a 7 by 3 array
...
composite(I,:,:) = composite(J,:,:) + composite(k,:,:)
the last line does some work on various "array" elements of composite.
Once you get the composite array built up, you can treat sections of
it as "pseudo array elements". The drawback is that you need to
use the : notation for the "array element" parts.
An other choice would be derived types. Something like:
type has_arrays
real X(7,3)
end type
type (has_arrays) composite(10)
That creates an array of ten elements. Each element is a 7 by 3
array.
composite(1) = something that is a 7 by 3 array ! similar to above
...
composit(I) = composite(J) + composite(K)
The drawback is that you'll have to define functions to do the
add operation and any other operations you need, since fortran
doesn't intrinsically define operations between two things of
type "has_arrays".
You could avoid defining operators by explicitly using the
components of composite.
composit(I)%X = composite(J)%X + composite(K)%X
This explicitly adds two 7 by 3 arrays and stores them into an
explicit 7 by 3 array.
If you need the sub arrays to be different sizes you can add
the pointer attribute to the X component
type has_arrays
real,pointer :: X(7,3)
end type
But now you'll have to manage the memory of each component,
usually by an ALLOCATE statement, and make sure the I, J, and
K arrays have the right shape if you want to do the add above.
Hope this gives you some ideas.
Dick Hendrickson
Edward Osei wrote:
>
> Hi folks:
>
> I was wondering whether Fortran 90/95 allows assignment of arrays to
> elements of other arrays (i.e. can array elements contain arrays)? If not,
> is there a possibility of including that feature in future fortran
> implementations?
>
> Thanks and best regards.
> Edward.
>
> Edward Osei
> Senior Research Economist
> Mailing Address:
> Texas Institute for Applied Environmental Research
> Box T-0410
> Stephenville, TX 76402
>
> Phone: (254)968-9583
> Fax: (254)968-9790
> Email: [log in to unmask]
|