Here is an online dictionary definition of the word "assume".
as·sume
əˈso͞om/Submit
verb
1.
suppose to be the case, without proof.
"you're afraid of what people are going to assume about me"
synonyms: presume, suppose, take it (as given), take for granted, take
as read, conjecture, surmise, conclude, deduce, infer, reckon, reason,
think, fancy, believe, understand, gather, figure
"I assumed he wanted me to keep the book"
2.
take or begin to have (power or responsibility)
"he assumed full responsibility for all organizational work"
synonyms: accept, shoulder, bear, undertake, take on/up, manage, handle,
deal with
"they are to assume more responsibility"
I am not saying that the standard does not use the word "assume," I am
saying that in some cases that word means the first definition (take
without proof) while in other cases the word means the second definition
(to take on).
On 5/13/17 8:57 AM, Richard Maine wrote:
> Ron Shepard <
nos...@nowhere.org> wrote:
>
>> On 5/12/17 7:57 PM, Richard Maine wrote:
>
>>> That's not the way I interpret it. I interpret "assumed size" to use the
>>> same meaning of "assumed" as does "assumed shape" - that is the size is
>>> taken from the actual argument.
>>
>> I think I understand your point, but I still disagree. The assumed size
>> array declaration
>>
>> integer array(*)
>>
>> tells the compiler it MUST IGNORE any of the actual argument shape and
>> size values and to take a default lower bound of 1 and a default size of
>> unknown.
>
> That's not what the standard says. From f2008 5.3.8.5.
>
> " An assumed-size array is a dummy argument array whose size is assumed
> from that of its effective argument....
>
> The size of an assumed-size array is determined as follows [details
> omitted]"
This use of "assume" means to "take without proof". It does not assume
(take on, take from, inherit) the characteristics of the actual
argument. The dummy argument has the new characteristics from that point
on "without proof" from the actual argument characteristics. Even the
standard in this case uses the term "effective argument" rather than
"actual actual" I would assume :) to emphasize this point. I would say
that a better phrasing for that sentence in the standard might be
"...whose size is implicitly limited by that of its effective argument..."
But the standard used the word "assumed," so we are stuck with the
ambiguity of that word.
The explanation of the actual size of the array is given so that the
programmer can stay within the limits of the actual argument array, not
because the compiler is required to assume (take on) characteristics
from the actual argument and to be able to report them to the
programmer. Those characteristics of the actual argument MUST BE IGNORED
by the compiler with this declaration rather than assumed (taken on). I
previously mentioned how a rank-2 actual argument could become a rank-1
dummy argument to demonstrate this. The programmer must stay within the
size constraints of the actual argument, and the compiler can assume
(without proof) that the programmer has done so.
> That seems pretty explicit (not to be confused wih explicit shape :-))
> to me. Nothing there about having a size of unknown. It has a specific
> size and the standard specifies how that size is computed.
It is unknown to the compiler through the dummy argument, and the
standard is specific that shape(), size(), and ubound() inquiries are
not allowed for these array declarations. In the case of ubound(), it is
specifically the last dimension specified by * that is prohibited. The
size must be known to the programmer who is required to know the actual
argument characteristics and to avoid exceeding that size. The compiler
is allowed to assume (without proof) that the programmer has conformed
to these size requirements. If the programmer does not do his part, then
it is not the compiler's fault, and further, the compiler is not
required to report this error because it is not required to assume (take
on) the actual argument characteristics necessary to report this error.
> Oh, and the
> syntax allows lower bound to be specified by declarations like
>
> integer array(0:*)
>
> or for that matter like
>
> integer array(3:7,0:5,42:*)
>
> While 1-D assumed size arrays are the most common case, they are not the
> only case allowed.
Yes, I actually use these forms, and have done so since f77 compilers
became available. But these declarations also take the dummy array rank
and bounds from the dummy array declaration (without proof) rather than
assuming (taking on, taking from) them from the actual argument. The
rank and bounds information from the actual arguments MUST BE IGNORED
with these definitions. For example, if the declaration
integer array(:,:,*)
were allowed, then this might declare a rank 3 array in which the actual
argument characteristics are assumed (taken from) the first two
dimensions, and the characteristics of the last dimension are assumed
(without proof) from the dummy declaration while ignoring the actual
argument characteristics. The actual argument might be a rank 4 or
higher array, for example. This would clearly mix the two different
definitions of the word "assume" in a single array declaration. Of
course, this declaration is not allowed, so I'm just using it here as an
example that shows the two distinct meanings of "assume."
Here is an example that is legal fortran that does pretty clearly mix
the two definitions of the word "assume."
program chartest
character(len=4) c(5)
call sub1(c)
call sub2(c)
contains
subroutine sub1(c)
character(len=*) c(*)
write(*,*) 'len=', len(c) ! size(c) is not allowed.
return
end subroutine sub1
subroutine sub2(c)
character(len=*) c(:)
write(*,*) 'len=', len(c), ' size=', size(c)
return
end subroutine sub2
end program chartest
In sub1() there is an assumed size array of assumed size character
strings. You can inquire about the length of the character string, but
you cannot inquire about the size of the array. That is because assumed
size character strings use the second definition (take from) of the word
"assume" while the assumed size array uses the first definition (without
proof).
In sub2(), there is an assumed shape array of assumed size character
strings. It is legal to inquire about both the length of the character
string and the size of the array. In this case, both definitions use the
second meaning (take from) of the word "assume". Both characteristics
are taken from the actual argument.
When executed, this program prints
len= 4
len= 4 size= 5
Because sub1() is a contained subroutine, the compiler clearly knows
what is the size of the actual argument, both at compile time and at run
time. However, it is still illegal to inquire about that size, size(c),
because within sub1() the compiler is effectively REQUIRED TO IGNORE
that characteristic of the actual argument.
So let's follow this just a little further. Consider adding the line
call sub2(c(1:2))
to sub1(). This is still legal because the programmer has followed the
rules and stayed within the size of the actual argument in the main
program. Now, the program prints out
len= 4
len= 4 size= 2
len= 4 size= 5
as expected. The size() inquiry is still allowed in sub2() because it
assumes (takes from, inherits) this from the actual argument.
There are several other ways in which to make size() allowed. Within
sub1() one could declare c(5) as explicit shape. Or, one could use
size(c(1:5))
and still be legal. But in these cases, the size() of the array is being
determined locally within sub1(), using the "without proof" definition
of assume, rather than the "take from" definition.
$.02 -Ron Shepard