I have used Fortran 77 for many years and am in the process of converting
myself and one of my programs to Fortran 90. I would be grateful for advice
from more experienced users of F90.
I would like to arrange for the scalar variables AXX, AXY, etc. to refer to
the elements of a 3 * 3 array A. In Fortran 77 I can do this using
EQUIVALENCE, and this is efficient (I believe):
EQUIVALENCE (AXX, A(1,1)), (AXY, A(1,2)), ...
I can do this in Fortran 90 too, but it is deprecated. It appears that I am
supposed to do
DOUBLE PRECISION, DIMENSION (3,3), TARGET :: A
DOUBLE PRECISION, POINTER :: AXX, AXY, ...
and then
AXX => A(1,1)
AXY => A(1,2)
...
My questions are:
(a) Is this the right way to do it? If not, what should I do?
(b) Is it efficient? I refer to AXX etc many times.
(c) Is there a way to set this up without having to execute run-time code to
associate the pointers with the appropriate variables? For example, can I do
DOUBLE PRECISION, POINTER :: AXX => A(1,1), AXY => A(1,2), ...
or
PARAMETER (AXX => A(1,1))
I want a fixed association, not one that might in principle change. From this
point of view the EQUIVALENCE statement is simple and straightforward, and the
use of pointers seems an unnecessary complication.
--
Anthony Stone
University Chemical Laboratory, Email: [log in to unmask]
Lensfield Road, Phone: +44 1223 336375
Cambridge CB2 1EW Fax: +44 1223 336362
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|