fortran中maxloc的用法



program test
    real, dimension(5) :: x
    integer :: n
    x = (/1., 2., 4., 3., 1./)
    n = maxloc(x) + 1
    print *, n
end
 


a.f90(5): error #6366: The shapes of the array expressions do not conform.   [N]
    n = maxloc(x) + 1
----^
compilation aborted for a.f90 (code 1)
 

因为,maxloc的输出值是数组
即使p是一个一维数组
即使maxloc(p)输出只有一个值
但是你还是不得不定义一个只有一个元素的数组来接收,即
integer i4(1)
i4 = maxloc(p)


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM