[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: User selectable lower array bound?

On 3 Aug 2001, Stein Vidar Hagfors Haugan wrote:

> Paul van Delst <paul.vandelst@noaa.gov> writes:
> [..]
> > Well, maybe WHERE could work as it does now, but for cases where the start index is not
> > zero, a function like the Fortran 90 intrinsic LBOUND() could be used.
> >
> > BTW, I never check the WHERE result either, always the COUNT value.
> Funny, I [almost] never use the COUNT value.. If you're writing an IF
> test, the information is there anyway..
>  ix = where(nonzero)
>  IF ix[0] ne -1 THEN ...

   Stein Vidar, the point I was making about WHERE was that with definable
lower bounds, -1 could be a legitimate index into the array, but
consistently using COUNT avoids this problem.  I was also speculating that
WHERE returning lbound-1 would be consistent with its current behavior,
and wouldn't break (as many) existing programs, in which the arrays have
an implicit lbound=0 (and thus lbound-1 = -1).

   (Actually, I've been known to use either form, depending on how I feel
at the time. :-)  I've been trying to use COUNT more, though.)

   There are other problems, though.  <sigh>

                                           Jeff Guerber
                                           Raytheon ITSS
                                           NASA Goddard Space Flight Ctr
                                           Oceans & Ice Branch (code 971)