For Programmers: Free Programming Magazines  


Home > Archive > Fortran > March 2004 > DIMENSION (N,*)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author DIMENSION (N,*)
Oodini

2004-03-30, 9:48 am

Hello,

What does the * mean in DIMENSION (N,*) ?
That the 2nd dimension is not known yet ?

Thanks.

Jan Vorbrüggen

2004-03-30, 10:48 am

> What does the * mean in DIMENSION (N,*) ?
> That the 2nd dimension is not known yet ?


Sort of - it means that the caller will specifiy it
at run time. This is only possible (in this F77-style
form) for the last dimension.

Jan
Oodini

2004-03-30, 11:44 am

Jan Vorbrüggen a écrit:
>
> Sort of - it means that the caller will specifiy it
> at run time. This is only possible (in this F77-style
> form) for the last dimension.


So it is same than:

ALLOCATABLE A(N,:)

?

Richard Maine

2004-03-30, 11:44 am

Oodini <nospam_svdbg@free.fr> writes:

> Jan Vorbrüggen a écrit:
>
>
> So it is same than:
>
> ALLOCATABLE A(N,:)


No. not even close.

1. The * does *NOT* mean anything about allocating. It means
that the dimension is already established in the caller.
I actually like your phrasing fairlt well - that the *
means unknown, with the elaboration that this means unknown
to the compiler. It doesn't imply any kind of dynamic
allocation, but just means that the compiler doesn't know
what size actual argument will be passed.

In fact, it generally means that even at run-time there won't
be information about what the actual size is. It is up to
you, the programmer, to know what size the actual argument
is and to avoid exceeding its bounds.

2. Allocatable a(N,:) isn't allowed at all, by the way. You can't
have some dimensions be allocatable and others not.

--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain | experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
Oodini

2004-03-30, 12:40 pm

> 1. The * does *NOT* mean anything about allocating. It means
> that the dimension is already established in the caller.
> I actually like your phrasing fairlt well - that the *
> means unknown, with the elaboration that this means unknown
> to the compiler. It doesn't imply any kind of dynamic
> allocation, but just means that the compiler doesn't know
> what size actual argument will be passed.
>
> In fact, it generally means that even at run-time there won't
> be information about what the actual size is. It is up to
> you, the programmer, to know what size the actual argument
> is and to avoid exceeding its bounds.


OK, I see the difference, now.

> 2. Allocatable a(N,:) isn't allowed at all, by the way. You can't
> have some dimensions be allocatable and others not.


Good to know that. :-)

Thanks for your explanations.

glen herrmannsfeldt

2004-03-30, 1:37 pm

Oodini wrote:

> Jan Vorbrüggen a écrit:
>
[color=darkred]
[color=darkred]
> So it is same than:


> ALLOCATABLE A(N,:)


I might have called it "previously allocated".

In the olden days, it was popular to put 1 in that spot.

Though in most cases the dimension must be passed as a
parameter, and might just as well go in there.

-- glen

jan van oosterwijk

2004-03-30, 3:40 pm

Oodini <nospam_svdbg@free.fr> wrote in message news:<406993AE.6070005@free.fr>...
> Jan Vorbrüggen a écrit:
>
> So it is same than:
>
> ALLOCATABLE A(N,:)
>


No, certainly not.
DIMENSION A(N,*)
is the Fortran 77 way of declaring (inplicit REAL) an array
with 'assumed size'. This is possible only for dummy arguments in a procedure.
The statement
ALLOCATABLE :: A(N,:) is not possible

For dummy arguments you may use

real :: A(:,:)
This is called an 'assumed shape' array.
And
real, ALLOCATABLE :: A(:,:)
declares an allocatable array with 'deferred shape'

I will not continue my course on elemental Fortran here.
Suggest you get and read a book about Fortran.

[JvO] at wanadoo dot nl
John Harper

2004-03-30, 4:37 pm

In article <8bb02cd6.0403301213.61bec238@posting.google.com>,
jan van oosterwijk <jvo_36@hotmail.com> wrote:
>
>I will not continue my course on elemental Fortran here.


Elementary Fortran, please, not elemental. There are elemental things
in Fortran but they were not what that useful course was about!

John Harper, School of Mathematical and Computing Sciences,
Victoria University, PO Box 600, Wellington, New Zealand
e-mail john.harper@vuw.ac.nz phone (+64)(4)463 5341 fax (+64)(4)463 5045
Charles Russell

2004-03-31, 10:43 am


"Oodini" wrote

> What does the * mean in DIMENSION (N,*) ?


Avoid this if possible even in f77, since then the compiler can't always
check for out-of-bound indexes.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com