2012-07-05 199 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