gpt4 book ai didi

windows - LOC 和 %LOC 在 Windows 的子程序中不起作用

转载 作者:可可西里 更新时间:2023-11-01 10:21:25 28 4
gpt4 key购买 nike

我有一个 Fortran 90 项目,它广泛使用 loc 函数来获取数组的地址(与 Matlab 互操作的 API 的一部分)。

这段代码在 Mac 和 Linux 上编译并运行在 Intel 和 gfortran 上,并且已经有一段时间了(跨几个不同的编译器版本)。

我现在正尝试使用来自 Composer XE 2015 的 Intel Fortran 在 Windows 上进行构建。当我逐步使用调试器时,我发现主函数中的 LOC 调用正确返回了地址,但从中调用的子例程中的调用似乎什么也不做 - 它只返回数据的值而不是位置。

有谁知道为什么 LOC 不起作用?我尝试同时使用 loc() 和 %LOC() 并获得相同的行为。有关示例,请参见 this function .第 69 行的 loc 有效,第 116 行的无效(仅返回数据值)。 REPIDX_0(X,1) 是一个预处理器宏,在这种情况下只返回 X。

任何建议或指示将不胜感激 - 我完全被困住了。

这是一个最小的例子:

program testloc
implicit none
real, pointer :: x
integer(8) :: add1, add2

allocate(x)
x = 2
add1 = loc(x)
call get_add(x,add2)
write(*,*) add1
write(*,*) add2
deallocate(x)
contains
subroutine get_add(x,add)
real, pointer, intent(in) :: x
integer(8), intent(out) :: add
add = loc(x)
end subroutine
end program

在带有 ifort 12.1.3 的 Mac/Linux 上,我得到了预期的输出:

MatlabAPI_lite robince$ ./a.out
140661969926608
140661969926608

在装有 ifort 15.0.1 的 Windows 上,我得到了有问题的输出:

c:\code\MatlabAPI_lite>testloc
4636400
2

最佳答案

这是一个编译器错误 - 它已在 15.0.3 中修复。

关于windows - LOC 和 %LOC 在 Windows 的子程序中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28381601/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com