Re: Allocating arrays inside a subroutine.



<deltaquattro@xxxxxxxxx> wrote:
[on allocating an array in a subroutine]

I usually cope with this by taking away DATA_ARRAY
from the arguments of READ_DATA and putting it in a module:...
Since no one else suggested this, I wonder if that's the best way to
get the job done (my compiler doesn't support "extended allocatables",
even though I'm trying to have this fixed).

It's a fine way for some cases. Hard to say what is "best"; I'd probably
just avoid using the superlative in this context.

To the extent that the subroutine always deals with the same array,
putting the array in a module seems to me like a fine approach. It does
have the advantage of working on any f90/f95 compiler out there,
avoiding dependence on the allocatable TR.

The biggest disadvantage would be in cases where the subroutine might be
called from multiple places with different arrays. In a case like that,
you really want the flexibiliy of passing the array as an argument. But
it doesn't sound like that is likely at issue for the code in question.

--
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: Double precision arrays and subroutines
    ... to be the start of an nx * nx array. ... What happens is that, in Fortran, these two program units are independent. ... The subroutine and the program that calls it are compiled separately, and normally the compiler doesn't know about one when it's compiling the other. ... Thus, the compiler doesn't know about the mismatch between the fact that the subroutine call is being given an integer and two scalar doubles, and the subroutine declaration is expecting an integer and two double arrays. ...
    (comp.lang.fortran)
  • Re: Array argument bounds checking
    ... This led me to wonder about some details of array arguments. ... I would like the compiler to detect all ... < end subroutine foo ...
    (comp.lang.fortran)
  • Re: Really wierd bug
    ... > it has to be a compiler bug because it works fine for other population ... > My compiler is Compaq Visual Fortran 1997-1999. ... > with allocating the array sizes because I've defined the arrays as ... your program does indeed contain an array bounds error -- this ...
    (comp.lang.fortran)
  • Re: VB .Net and Intel Visual Fortran 9
    ... having is that the VB program cannot load the DLL. ... subroutine) to accept an array from VB - in my case a 2D array. ... Declare Sub mmult Lib "test.dll" (ByRef i As Double, ByRef j As Double, ...
    (comp.lang.fortran)
  • VB .Net and Intel Visual Fortran 9
    ... having is that the VB program cannot load the DLL. ... subroutine) to accept an array from VB - in my case a 2D array. ... Declare Sub mmult Lib "test.dll" (ByRef i As Double, ByRef j As Double, ...
    (comp.lang.basic.visual.misc)