Author Message

As a fortran programmer with a few weeks under forty years of
experience with FORTRAN, I have finally encountered a problem which
requires pointers.

INTEGER, POINTER :: DART1
INTEGER, POINTER :: DART2
INTEGER, TARGET :: BOARD
INTEGER, TARGET :: BULL

DART1 => BOARD
DART2 => BOARD

Assuming that BOARD is inaccessible, except via DART1 and DART2, can I
assign a new value to it?

I have assumed that if I execute

DART1 => BULL

DART2 would then still refer to BOARD

Dave Flower

Fri, 28 Nov 2008 19:50:48 GMT

Quote:

> I have assumed that if I execute

> DART1 => BULL

> DART2 would then still refer to BOARD

That's true. For instance, run the following:

INTEGER, POINTER :: DART1
INTEGER, POINTER :: DART2
INTEGER, TARGET :: BOARD
INTEGER, TARGET :: BULL
board = 2
DART1 => BOARD
DART2 => BOARD
print *, dart1, dart2
bull = 3
dart2 => bull
board = 4
print *, dart1, dart2
end

But what do you mean by board being inaccessible? In a module and private?

Regards,

Mike Metcalf

Fri, 28 Nov 2008 20:17:10 GMT

Quote:

> > I have assumed that if I execute

> > DART1 => BULL

> > DART2 would then still refer to BOARD

> That's true. For instance, run the following:

> INTEGER, POINTER :: DART1
> INTEGER, POINTER :: DART2
> INTEGER, TARGET :: BOARD
> INTEGER, TARGET :: BULL
> board = 2
> DART1 => BOARD
> DART2 => BOARD
> print *, dart1, dart2
> bull = 3
> dart2 => bull
> board = 4
> print *, dart1, dart2
> end

> But what do you mean by board being inaccessible? In a module and private?

> Regards,

> Mike Metcalf

Neither, it is a variable (might be local, module or COMMON) in a
separate routine, that cannot be passed as an argument

Dave Flower

Fri, 28 Nov 2008 20:31:04 GMT

Quote:
> > But what do you mean by board being inaccessible? In a module and private?

> Neither, it is a variable (might be local, module or COMMON) in a
> separate routine, that cannot be passed as an argument

This is just a warning.  Whatever the reasons are that you cannot
pass the original variable as an argument, those same reasons may
apply also to a pointer to that variable.

\$.02 -Ron Shepard

Fri, 28 Nov 2008 22:29:04 GMT

 Page 1 of 1 [ 4 post ]

Relevant Pages