| Re: Multi-Dimensional Arrays. Is it possible more than seven dimensions? |
|
 |
|
 |
|
 |
|
 |
Group: comp.lang.fortran · Group Profile
Author: nospamnospam Date: Jul 13, 2008 21:03
hotmail.com> wrote:
> Hello. I have a problem on trying to define an array with eight
> dimensions. I tried the following:
> integer :: N=10
> complex,dimension(-N:N,-N:N,0:1,0:1,-N:N,-N:N,0:1,0:1) :: P
>
> , but i get an error when compiling that the array cannot have more
> than seven dimensions.
That's true. That is a limitation of the current Fortran standard.
> Thank you for any recommendation on what to do, or suggestion about an
> alternate solution.
I can think of 3 off the top of my head.
1. As several of your dimensions are hardwired to have only 2 elements,
you might be able to get by with something like 2 7-dimensional arrays.
2. You can have an array of derived-type, where the type consists of a
single component that is in turn an array. There is some awkwardness in
this in that you can't directly reference some slices (because of the
restriction against arrays of arrays), but it does get it all in one
object.
3. You could collapse 2 of the dimensions into 1, using a single index
to map onto all the possible values of the 2 original indices. The last
2 dimensions would be an easy choice here.
and sort of a 4th, but you can't do it until f2003 (I don't know whether
gfortran supports that f2003 feature yet). You could define the whole
thing as a 1-dimensional array and then make pointers to any slice that
you happened to want, as long as the slice had no more than 7
dimensions. The f2003 feature in question is allowing higher-rank
pointers to have rank 1 targets.
--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
|