Search code examples
syntaxfortranfortran77

Odd Fortran Pointer Syntax


In some Fortran 77 code I have to deal with, there are pointers declared in a very odd way,

 pointer  (iuu     , uu      ), (ivv     , vv      ),
 $        (it      , t       ), (iq      , q       ), (ips     , ps      ),
 $        (ittm    , ttm     ), (itqm    , tqm     ), (ipsm    , psm     ),

What do the parenthesis here mean? Anything?


Solution

  • These are Cray pointers, a non-standard type of pointer that uses regular integer variables to store the memory address of the target, which may be another variable or a procedure. They were introduced because programmers wanted this functionality and Fortran 77 had no native pointer facility.

    The parentheses in your code are assignment statements for Cray pointers: pointer (iptr, target) [, ...].

    If at all possible, you should consider changing these to standard Fortran pointers, since their usage is subject to fewer restrictions and assumptions, and they are obviously supported by all compilers that implement Fortran 90.