我学习Fortran和需要我的程序,找出一个数组的特定值。一个简单的程序如下图所示:
program hello
implicit none
integer :: x
x = findloc([4,9,0,2,-9,9,1],9)
end program hello
是给我下面的错误:
Error: Function 'findloc' at (1) has no IMPLICIT type
我使用的MacBook gfortran编译它。会很感激,如果我能得到一些关于帮助findloc
该标准内findloc
介绍,在2008年修订的Fortran。对此功能的支持第一次出现在gfortran release 9.0。
你看到错误消息是内在是不是你正在使用的版本支持的指示。
你可以尝试使用所需的版本,不过目前这还处于发展。
幸运的是,循环在你的数组中的元素很简单,有效地创建自己的findloc
版本。
你有两个错误。修改你的代码稍微使得它的工作:
program hello
implicit none
intrinsic :: findloc
integer :: x(1)
x = findloc([4,9,0,2,-9,9,1], value = 9)
end program hello