Re: Problem with array size



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
.



Relevant Pages

  • Re: Problem with array size
    ... > Ron gave some hints as to how to solve the problem. ... > The Adeclaration here is an f77-style one known as assumed size. ... that does *NOT* mean that this is known in the subroutine. ... It means that the shape information ...
    (comp.lang.fortran)
  • Re: Scope
    ... Ron S. asked what I meant by "external." ... subroutine nor a module subroutine, but a subroutine that is (or ... * Any use of tradenames does not constitute a NOAA endorsement. ...
    (comp.lang.fortran)
  • Re: fortran95 error
    ... ron wrote: ... At a guess you are using a subroutine like: ... While Dr. Reid made two very good guesses, if one of those two isn't the solution, what would be of more help would to post the code segment that demonstrates the error -- the declarations of the function/subroutine and the call or referencing statement at a minimum, ideally a minimum compilable section that illustrates the problem... ...
    (comp.lang.fortran)
  • Re: Clicking on a button on form from VBA
    ... "Ron" wrote in message ... > If I have a subroutine in a module that does NOT belong to a form, ... > a way to press a button on the form (or invoke a routine that is in the ...
    (microsoft.public.access.forms)