Search code examples
pointersprintingfortran77

Printing the address of a variable in Fortran 77


How can I print the address of a variable in Fortran 77? Example:

      subroutine foo

      integer d3
c Now I want to print "Address of d3: " followed by its address.

The equivalent in C, of course, is

int d3;
printf("Address of d3: %p\n", &d3);

Thanks!


Solution

  • Although not technically Fortran 77, most fortran compilers provide a LOC function to get the address of an variable.

    See: http://gcc.gnu.org/onlinedocs/gfortran/LOC.html