type, POINTER :: varName |
(POINTER is an attribute)
REAL, POINTER :: ptr |
type, TARGET :: varName |
(TARGET is another type of attribute)
REAL, TARGET :: r |
ptr |
is an alias for the expression:
r |
REAL, POINTER :: ptr REAL, TARGET :: r r = 1111 ptr => r ! Make ptr points to r ptr = 4444 ! Same as "r = 4444" |
The variable r is updated !
|
Example:
FUNCTION f(a, b) REAL, TARGET :: a, b REAL, POINTER :: f IF ( a > b ) THEN f => a ELSE f => b END IF END FUNCTION |
(Assign the return value to a pointer variable, of course....)
Example:
REAL, POINTER :: ptr ptr => f(x, y) ! function "f" returns a pointer |
The pointer variable ptr will point to either x or y