(j3.2006) Change from Fortran 2003 to Fortran 2008
Bill Long
longb
Fri May 18 14:01:27 EDT 2012
On 5/18/12 3:14 AM, Robert Corbett wrote:
> The change in the definition of variables in Fortran 2008
> appears to cause a semantic difference. Consider the
> program
>
> FUNCTION F(P)
> POINTER F, P
> F => P
> END
>
> PROGRAM ASSOC
> TARGET X
> POINTER P
> INTERFACE
> FUNCTION F(P)
> POINTER F, P
> END FUNCTION
> END INTERFACE
> X = 1.0
> ASSOCIATE(Y => F(P))
> X = 2.0
> PRINT *, X, Y
> END ASSOCIATE
> END
I'm not seeing the connection between X and either Y or P. It looks
like Y is a pointer with undefined association status at the beginning
of the associate construct, and nothing later changes that fact.
Printing it is dodgy at best. Did you mean to have
P => X
before the ASSOCIATE construct? If I add that in, I see
2.0 2.0
as the output. Since Y is pointer associated with X, is that not what
you expect?
Cheers,
Bill
>
> In Fortran 2003, the selector in the ASSOCIATE statement is
> not a variable, and so the assignment to X does not affect
> the value of Y. In Fortran 2008, the selector is a variable,
> and so the assignment to X should change the value of Y.
>
> Robert Corbett
> _______________________________________________
> J3 mailing list
> J3 at j3-fortran.org
> http://j3-fortran.org/mailman/listinfo/j3
--
Bill Long longb at cray.com
Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9142
Cray Inc./Cray Plaza, Suite 210/380 Jackson St./St. Paul, MN 55101
More information about the J3
mailing list