Re: Problem with array size
- From: Richard E Maine <nospam@xxxxxxxxxxxxx>
- Date: Sun, 24 Apr 2005 17:36:13 -0700
In article <2cc28924.0504241454.36cecc4@xxxxxxxxxxxxxxxxxx>,
nath.domi@xxxxxxxx (D Marty) wrote:
> I don't understand why this following program fail and particulary why
> the size of the array "A()" in subroutine "titi" is equal to zero.
Ron gave some hints as to how to solve the problem. Let me comment
briefly on what the problem was
> subroutine titi(A)
> integer A(*)
The A(*) declaration here is an f77-style one known as assumed size.
Basically it means that the compiler is not told what the size is. You
aren't telling it in this declaration and it doesn't get it from
elsewhere either. Just because A is declared with a size of 3 in the
main program, that does *NOT* mean that this is known in the subroutine.
Actually, it is illegal to ask about the size of A at all in this case;
if you do ask, it isn't surprising to get a garbage answer such as 0.
The A(:) declaration that Ron suggests (and I concur) is known as
assumed shape. It means that the shape information (which includes size)
is passed from the main program to the subroutine. The explicit
interface that Ron described is necessary so that the main program can
know it is supposed to do it this way.
--
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
.
- Follow-Ups:
- Re: Problem with array size
- From: D Marty
- Re: Problem with array size
- References:
- Problem with array size
- From: D Marty
- Problem with array size
- Prev by Date: Re: Problem with array size
- Next by Date: Re: Detect EOF for direct access, unformatted files?
- Previous by thread: Re: Problem with array size
- Next by thread: Re: Problem with array size
- Index(es):
Relevant Pages
|
|