question about elemental subroutines

Richard E Maine Richard.Maine@nasa.gov
Mon Apr 24 19:32:00 GMT 2006


On Apr 24, 2006, at 12:03 PM, Dominique Dhumieres wrote:

> Am I correct
> if I understand them along with note 12.28, that the lines
>
>    call nonassign (x(2), x(1))
>    call nonassign (x(3), x(2))
>
> are correct, but not
>
>    call nonassign (x(2:3), x(1:2))
>
> because x(2) is common to the two arguments?

Yes, I think so.

> However I am puzzled by the following note:
>
>> NOTE 12.31
>> Because a nonpointer dummy argument declared with INTENT(IN) shall  
>> not be
>> used to change the associated actual argument, the associated actual
>> argument remains constant throughout the execution of the procedure.
>
> the 'y' argument of 'nonassign(x,y)' is INTENT(IN), should not x(1:2)
> "remains constant throughout the execution of the procedure"? or  
> what am I
> missing?

You are still missing the fact that the code is illegal by 12.4.1.6.  
That is really, really important. The standard is about defining what  
constitutes legal code and how legal code is interpreted. If the code  
is illegal, then everything else is irrelevant. You will not see  
every statement in the standard preceded by a caveat like "if the  
code in question is legal", because that is implicitly the whole point.

Notes explain consequences of the rules of the standard. They never  
add new rules. In particular, I might paraphrase this note as saying

1. You can't change the value of an intent(in) argument through that  
argument, per the rules for intent(in)

2. You can't change it except through that argument, per the rules of  
14.1.2.6

3. Therefore, it can't change at all.

This note just points out that (3) is a consequence of (1) and (2).

The note does *NOT* say that an intent(in) argument is constant, and  
therefore you can ignore 14.1.2.6 (or any other part of the standard).

-- 
Richard Maine                |  Good judgment comes from experience;
Richard.Maine@nasa.gov       |  experience comes from bad judgment.
                             |        -- Mark Twain



More information about the Fortran mailing list