Re: g95 wish list

From: glen herrmannsfeldt (gah_at_ugcs.caltech.edu)
Date: 11/30/04


Date: Tue, 30 Nov 2004 10:46:07 GMT

Catherine Rees Lay wrote:

(big snip on dimension of (1) in various places)

> I don't follow this. If you treat DIMENSION X(1) as DIMENSION X(*) and
> an array with one element in it is passed, it's perfectly possible to
> have a bounds check which fails if the subroutine references X(2).

I hadn't noticed that, either. I am not sure what any version
of the standard says about non-matching dimensions in subroutines
and subroutine callers.

> There are, and have been for years, compilers which do bounds-checking
> on arrays with bounds of * (this is one of the tests in the Polyhedron
> benchmarks).

Well, it does get complicated in some of the cases being
discussed. Some other languages commonly use call by descriptor
for arrays, allowing the full dimension information to be
passed, but not allowing some of the other Fortran tricks that
have been described here. It should be possible, and not all
that hard with the computer power available to do this.

One could even use the trick of a link time fixup I described
earlier. Ugly, but it works.

> The only problem I can see is that if you always treat 1 as *, you lose
> the possibility of a check as to whether you passed an array of size 2
> to a subroutine where it is declared explicitly as size 1 and was
> actually supposed to be size 1. Both you and the compiler would have to
> be psychic to pick this one up in any case.

-- glen



Relevant Pages

  • Re: Loading matrix from file? [fortran 77]
    ... > Is there any way to load matrix (array) from file, ... You need to allocate enough space for the largest possible matrix at ... You had to know at least the first dimension of the matrix before you ... subroutine sub ...
    (comp.lang.fortran)
  • Re: dimension question
    ... dimension a ... If the subroutine DIMENSION statement is athe array ...
    (comp.lang.fortran)
  • Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
    ... subroutine and then call DCpZeros passing VxGrid, nRdim, and nTHdim. ... Then DCpZeros can dimension VxGrid (nRdim, ... (PS. I'm not concerned or worried about the array bounds exceeded! ...
    (comp.lang.fortran)
  • Re: Neq Max Limit
    ... you are passing incorrect arguments to a subroutine. ... One may be the array size and another an array. ... dimension y,dy ... PRINT *,i at the top of the outer loop may tell you if the program is ...
    (comp.lang.fortran)
  • Re: index value after FORALL
    ... It is a scalar variable that has the type and type parameters that it would have if it were the name of a variable in the scoping unit ... the main program) is an array, and an unallocated one at that! ... I believe KIND is a parameter, and DIMENSION is an attribute. ...
    (comp.lang.fortran)