iand 使用新的 gfortran 版本使用不同种类的参数
iand with different kind parameters using new gfortran version
我目前正在使用旧代码,该代码使用不同种类的整数作为参数调用 iand
函数。下面是代码包含的一个小示例:
program test
integer*1 i
integer j, k
i = 1
j = 8
k = iand(i, j)
print *, k
end program test
gfortran 版本 8 和更早的版本具有使用不同类型的整数调用 iand 的扩展功能(例如,参见 here), whereas this option was removed in gfortran 9 (see this site)。
例如,使用 gfortran 7.5.0:
gfortran-7 -o test test.f90 && ./test
0
但是当用 gfortran 9.2.0 编译时,我得到:
gfortran -o test test.f90
...
Error: Arguments of ‘iand’ have different kind type parameters at (1)
gfortran
的新版本是否有让我按原样使用此代码的选项?
不,没有。由于未明确指定语义,此扩展已被删除,并且将代码修复为符合标准很简单。
见https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81509
在你的情况下,类似于
k = iand(int(i, kind(j)), j)
希望这就是您所追求的。
我目前正在使用旧代码,该代码使用不同种类的整数作为参数调用 iand
函数。下面是代码包含的一个小示例:
program test
integer*1 i
integer j, k
i = 1
j = 8
k = iand(i, j)
print *, k
end program test
gfortran 版本 8 和更早的版本具有使用不同类型的整数调用 iand 的扩展功能(例如,参见 here), whereas this option was removed in gfortran 9 (see this site)。 例如,使用 gfortran 7.5.0:
gfortran-7 -o test test.f90 && ./test
0
但是当用 gfortran 9.2.0 编译时,我得到:
gfortran -o test test.f90
...
Error: Arguments of ‘iand’ have different kind type parameters at (1)
gfortran
的新版本是否有让我按原样使用此代码的选项?
不,没有。由于未明确指定语义,此扩展已被删除,并且将代码修复为符合标准很简单。
见https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81509
在你的情况下,类似于
k = iand(int(i, kind(j)), j)
希望这就是您所追求的。