Multi-Dimensional Arrays. Is it possible more than seven dimensions?
  Home FAQ Contact Sign in
comp.lang.fortran only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.fortran Profile…
 Up
Multi-Dimensional Arrays. Is it possible more than seven dimensions?         


Author: mforets
Date: Jul 13, 2008 19:36

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.
I'm working under gfortran version 4.3.0 .
Thank you for any recommendation on what to do, or suggestion about an
alternate solution.
5 Comments
Re: Multi-Dimensional Arrays. Is it possible more than seven dimensions?         


Author: nospam
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.
Show full article (1.74Kb)
no comments
Re: Multi-Dimensional Arrays. Is it possible more than seven dimensions?         


Author: Damian
Date: Jul 14, 2008 06:11

On Jul 13, 9:03 pm, nos...@see.signature (Richard Maine) wrote:
> 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.
> ...
Show full article (2.93Kb)
no comments
Re: Multi-Dimensional Arrays. Is it possible more than seven dimensions?         


Author: Tobias Burnus
Date: Jul 14, 2008 08:20

On 14 Jul., 04:36, mfor...@hotmail.com wrote:
> I have a problem on trying to define an array with eight
> dimensions. [...]
> , but i get an error when compiling that the array cannot have more
> than seven dimensions.
> I'm working under gfortran version 4.3.0 .

Another possibility than the suggestions by Richard and Damian is to
use gfortran 4.4, which supports 15 dimensions (in line with the
Fortran 2008 candidate draft). However, this limits the compatibility
of your program to very few compilers. Additionally, you need to use a
developers version of gfortran (as 4.4 has not been released yet); the
developer versions are usually quite stable, but still a snapshot of a
given day might be not working correctly, if you are unlucky.

For gfortran 4.4, see:
http://gcc.gnu.org/wiki/GFortranBinaries

Tobias
no comments
Re: Multi-Dimensional Arrays. Is it possible more than seven dimensions?         


Author: glen herrmannsfeldt
Date: Jul 18, 2008 16:05

mforets@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

Easiest is to make the last and 0:3 and then reference
it with 2*(I)+(J) where (I) and (J) are the value of the
next to last and last desired subscript.

That generalizes a little. Also, you can use the C preprocessor
to do some of the conversion for you.

-- glen
no comments
Re: Multi-Dimensional Arrays. Is it possible more than seven dimensions?         


Author: Eugene A. Pallat
Date: Jul 20, 2008 17:27

hotmail.com> wrote in message
news:3296cd16-ebff-4585-93ab-6d3a6f94ed1f@c65g2000hsa.googlegroups.com...
> 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.
> I'm working under gfortran version 4.3.0 .
> Thank you for any recommendation on what to do, or suggestion about an
> alternate solution.

Use equivalence statements to get the added dimensions. It's a little more
work, but it's a workaround.

I ran into a problem where I needed a 4 dimensional matrix in COBOL. The
Univac reps said no one could understand more than 3 dimensions. I told
them, "I could understand 10. Too bad about you guys."

I just redefined the matrices which was the COBOL version of equivalence and
had no problem with a 4 dimensional matrix.
Show full article (1.16Kb)
no comments

RELATED THREADS
SubjectArticles qty Group
Re: Helper to create multi-dimensional arrayscomp.lang.ruby ·
how to join array into arraycomp.lang.perl.misc ·
two dimensional arraysmicrosoft.public.excel.worksheet.functions ·