2012-07-05 57 views
1

如何在Fortran 77中打印變量的地址?例如:在Fortran 77中打印變量的地址

 subroutine foo 

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

C語言中的等價物,當然是

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

謝謝!

回答

1

雖然不是技術上的Fortran 77,最Fortran編譯器提供了一個LOC函數來獲得一個變量的地址。

參見:http://gcc.gnu.org/onlinedocs/gfortran/LOC.html

+0

謝謝!我其實知道loc函數,但只在Cray指針的上下文中看到它,並不知道如何使用它來打印地址。您提到的頁面有一個有用的示例。 – 2012-07-06 01:47:59