On 9/26/21 9:06 AM, gah4 wrote:
> On Saturday, September 25, 2021 at 3:32:18 AM UTC-7, Dave Tholen wrote:
>> According to gfortran on-line documentation, the MAXLOC intrinsic determines
>> the location of the element in the array with the maximum value, but what is
>> the definition of "location" in this instance? The on-line documentation for
>> IBM's XL Fortran calls it "the subscript of the location", but what if the
>> subscript doesn't start at 1?
>
> I have commented on the numbering system before, but note that array
> expressions always start at 1.
>
> A dummy array that is not POINTER or ALLOCATABLE doesn't get the lower
> bound from the caller. Since the argument of MAXLOC isn't POINTER or
> ALLOCATABLE, then it won't get the lower bound.
Yes, this shows that the way MAXLOC works is consistent with the way any
other user-written subroutine works. In fact, MAXLOC could be a
user-written function, there is nothing special about it in that way.
> But overall, the standard does not make this very easy to follow, finding
> the exact cases where arrays lose the lower bound.
Other intrinsic functions such as LBOUND and UBOUND do not work that
way. These functions could NOT be user-written because they return array
metadata directly, metadata that is lost or replaced during the
association of actual and dummy arguments (with the exceptions noted
above). It is tricky sometimes to keep track of the two types of
functions and their exceptions, and MAXLOC is one of those tricky cases
because it could have been defined to work either way.
$.02 -Ron Shepard