对于不属于标准一部分的 FORTRAN 内在函数,我该怎么办?

发布于 2024-11-04 21:17:32 字数 741 浏览 0 评论 0原文

我正在尝试通过使用 gfortran 从源代码构建旧版 FORTRAN 代码来工作。我终于能够成功构建它,但现在运行时出现越界错误。我使用 gdb 并将错误跟踪到使用 loc() 内在函数的函数。当我尝试打印 loc(ae) 的值(ae 是传递的整数值)时,我收到错误“当前上下文中没有符号“loc””。我尝试使用 ifort 11.x 进行编译并使用 DDT 进行调试,但得到了相同的错误。对我来说,这意味着编译器对内在函数一无所知。

稍微阅读一下就会发现 loc 内在函数不是 F77 标准的一部分,所以也许这就是问题的一部分。我在下面发布了内在函数的定义,但我不知道如何将其实现到我的代码中,以便可以使用 loc() 。

有什么建议还是我误解了我的问题?因为 gfortran 和 ifort 由于越界错误而在同一位置崩溃,但使用 loc() 的函数在两个编译器之间返回相同的大数字。如果两个编译器返回相同的 loc 值,那么 loc() 将无法工作,这似乎有点奇怪。

用法:

iaddr = loc(obj)

地点:

对象 是需要其地址的变量、数组、函数或子例程。 地址 是一个地址为“obj”的整数。地址在同一个地方 LARn 存储的格式 说明。

描述:

LOC用于获取地址 某物。返回的值不是 在 Fortran 中确实有用,但可能 GMAP 子例程需要,或者 非常特殊的调试。

I'm trying to get a legacy FORTRAN code working by building it from source using gfortran. I have finally been able to build it successfully, but now I'm getting an out-of-bounds error when it runs. I used gdb and traced the error to a function that uses the loc() intrinsic. When I try to print the value of loc(ae), with ae being my integer value being passed, I get the error "No symbol "loc" in current context." I tried compiling with ifort 11.x and debugged with DDT and got the same error. To me, this means that the compiler knows nothing of the intrinsic.

A little reading revealed that the loc intrinsic wasn't part of the F77 standard, so maybe that's part of the problem. I posted the definition of the intrinsic below, but I don't know how I can implement that into my code so loc() can be used.

Any advice or am I misinterpreting my problem? Because both gfortran and ifort crash in the same place due to an out of bounds error, but the function utilizing loc() returns the same large number between both compilers. It seems a bit strange that loc() wouldn't be working if both compilers shoot back the same value for loc.

Usage:

iaddr = loc(obj)

Where:

obj
is a variable, array, function or subroutine whose address is wanted.
iaddr
is an integer with the address of "obj". The address is in the same
format as stored by an LARn
instruction.

Description:

LOC is used to obtain the address of
something. The value returned is not
really useful within Fortran, but may
be needed for GMAP subroutines, or
very special debugging.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

魂归处 2024-11-11 21:17:32

嗯,不,它编译的事实意味着编译器知道 loc ;事实上,gdb 不知道它只是意味着调试器不知道它(调试器也可能不知道 matmult 内在函数)。

loc 是一种广泛使用的非标准扩展。我讨厌那些。如果您想要一些可以在任何地方使用的标准,c_loc,它是 C<-> 的一部分;Fortran2003 中的 Fortran 互操作性标准是您可以使用的。它返回一个可以传递给 C 例程的指针。

如何使用 loc 调用的值?

Well, no, the fact that it compiles means that loc is known by the compiler; the fact that gdb doesn't know about it just means it's just not known by the debugger (which probably doesn't know the matmult intrinsic, either).

loc is a widely-available non-standard extension. I hate those. If you want something standard that should work everywhere, c_loc, which is part of the C<->Fortran interoperability standard in Fortran2003, is something you could use. It returns a pointer that can be passed to C routines.

How is the value from the loc call being used?

摇划花蜜的午后 2024-11-11 21:17:32

Gfortran loc 处理数组的方式似乎与其他一些编译器有些不同。如果您使用它来检查数组副本等,那么最好对第一个元素进行 loc(obj(1,1)) 或类似操作。这相当于我对 intel 的 loc 的看法,但在 gfortran 中它给出了一些其他地址(因此共享完全相同的内存布局的两个数组具有不同的 loc 结果)。

Gfortran loc seems to work a bit differently with arrays to that of some other compilers. If you are using it to eg check for array copies or such then it can be better to do loc of the first element loc(obj(1,1)) or similar. This is equivalent to what loc does I think with intel, but in gfortran it gives instead some other address (so two arrays which share exactly the same memory layout have different loc results).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文