Re: Fortran memory allocation (stack/heap) issues
From: Richard Maine (nospam_at_see.signature)
Date: 04/27/04
- Next message: James Giles: "Re: Question on complex algebra"
- Previous message: Andy Nelson: "Fortran memory allocation (stack/heap) issues"
- In reply to: Andy Nelson: "Fortran memory allocation (stack/heap) issues"
- Next in thread: glen herrmannsfeldt: "Re: Fortran memory allocation (stack/heap) issues"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 27 Apr 2004 13:35:16 -0700
Andy Nelson <andy@kant.maths.ed.ac.uk> writes:
> -Under what circumstances would one expect that the call
> might trigger a quantity to have a copyin/copyout sort of
> arrangement and what might trigger a call by reference sort
> of arrangement?
Compilers are free to vary, but as a general guide, the only
time you'll see copying is when the actual array might be
discontiguous. Namely, that's when the actual argument is a
pointer or an assumed shape dummy. From your description, you
don't have that (those are very much f90 features). There are
other conditions, but it all seems irrelevant to you if you
have described things correctly.
Basically, you rarely see array copying in f77. (It can happen,
but it is rare). You also don't tend to see it in what I would
call "pure" f90 style. You do get it from some attempts to
mix f77 and f90 styles.
> -There are also occasions when a routine might be called with
> one or the other npart=0 (see code below). As a completely
> separate question, my copy of M&R says zero length arrays are
> allowed, but I've run across compilers (can't remember which)
> where the code crashed on trying to enter a subroutine with such
> a situation, and worked when I changed the array declaration
> to a fixed parameter value. Did I do something weird
> or should I report a bug? (Maybe this description isn't
> specific enough for anyone to say for sure though...)
Zero-sized arrays are allowed in f90, but not in f77. I bet the
compilers in question were f77 ones.
[code elided]
> The claim is that the phrasing above will lead to the
> variables getting defined on a stack,
Seems highly unlikely. I also don't see the suggested change
as likely to change anything.
One thing you might be running into has nothing to do with
argument passing. Non-saved local arrays might plausibly be
allocated on the stack. That includes "local" arrays in the main
program. Many compilers have options to change that behavior.
P.S. When do you get the stack overflow? Imediately on loading
the program or later? You should be able to get a hint from
when it happens.
-- 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
- Next message: James Giles: "Re: Question on complex algebra"
- Previous message: Andy Nelson: "Fortran memory allocation (stack/heap) issues"
- In reply to: Andy Nelson: "Fortran memory allocation (stack/heap) issues"
- Next in thread: glen herrmannsfeldt: "Re: Fortran memory allocation (stack/heap) issues"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|