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