(j3.2006) ASSOCIATED

Van Snyder Van.Snyder at jpl.nasa.gov
Fri Mar 12 21:31:37 EST 2010


This shows that we have to say the TARGET **DUMMY** argument is an
optional INTENT(IN) pointer instead of leaving the **DUMMY** argument
attributes unspecified, which was the second choice I suggested.  This
works in F08 because an INTENT(IN) pointer is allowed to correspond to a
nonpointer actual, in which case it gets pointer associated with the
actual argument (or, of course, it can correspond to a pointer).

Van

On Fri, 2010-03-12 at 18:10 -0800, Robert Corbett wrote:
> Bill Long wrote:
> > 
> > 
> > Robert Corbett wrote:
> > 
> >>
> >> I see now that fixing the specifications of the intrinsic functions is
> >> going to be a lot of fun.
> >>
> >> I do not think that the authors of the standard intended it to be
> >> impossible for cases (vi) or (vii) to occur.  Under your interpretation,
> >> the program
> >>
> >>        PROGRAM MAIN
> >>          POINTER P, Q
> >>          REAL X
> >>          TARGET X
> >>          P => X
> >>          NULLIFY(Q)
> >>          PRINT *, ASSOCIATED(P, Q)
> >>        END
> >>
> >> should print " T" because P is associated and Q, which is argument
> >> associated with the dummy argument TARGET of ASSOCIATED, is not
> >> associated and therefore the dummy argument TARGET is "not present."
> >> I just compiled and ran that program using three different compilers.
> >> All three runs printed " F".
> >>
> > 
> > Nice example. I tried 5 compilers and got F:5, T:0.  And I believe this 
> > is what is intended. ASSOCIATED looks like a case where we need to have 
> > 2 forms and not identify the TARGET argument as optional.
> 
> I realized while driving home from work this morning that the two
> signature specification of ASSOCIATED is not equivalent to the
> specification of ASSOCIATED in Fortran 2003.  In Fortran 2003,
> assuming "absent" means "not present", the following program is
> standard conformant:
> 
>        SUBROUTINE SUBR(P, Q)
>          POINTER P, Q
>          OPTIONAL Q
>          PRINT *, ASSOCIATED(P, Q)
>        END
> 
>        PROGRAM MAIN
>          INTERFACE
>            SUBROUTINE SUBR(P, Q)
>              POINTER P, Q
>              OPTIONAL Q
>            END SUBROUTINE
>          END INTERFACE
>          POINTER P
>          TARGET X
>          P => X
>          CALL SUBR(P)
>        END
> 
> Under the two signature specification, the function reference is not
> permitted because Q is not present in SUBR.
> 
> The program gets a segmentation violation when run after being compiled
> with the compilers available to me, but that does not mean it is not a
> standard conformant program.
> 
> Bob Corbett
> _______________________________________________
> J3 mailing list
> J3 at j3-fortran.org
> http://j3-fortran.org/mailman/listinfo/j3



More information about the J3 mailing list