2

g95 コンパイラを使用すると、次のようなエラーが表示されます。

ERROR: Procedure attribute conflicts with INTENT attribute in 'quantityarray'

配列の合計を見つけようとしていました。このエラーが表示されるサブルーチンは次のとおりです。

SUBROUTINE findTotals(pricearray,quantityarray,totalprice, totalquantity)

INTEGER, INTENT(IN)::quantityarray
REAL, INTENT(IN):: pricearray
INTEGER, INTENT(OUT)::totalquantity
REAL, INTENT(OUT)::totalprice


totalquantity = SUM(quantityarray)
totalprice = SUM(pricearray)


END SUBROUTINE

お時間をいただきありがとうございます。

4

1 に答える 1

2
program SummingAnArray
implicit none
integer, dimension(10) :: array=(/ (i, i=1,10) /)
integer :: i, Total

call VectorSum(array,Total)
print *,Total
read(*,*)



contains
    !===================================================
    subroutine VectorSum(Vector,Total)
    implicit none
    integer, intent(in), dimension(:) :: Vector
    integer, intent(out) :: Total

    Total = SUM(Vector)
    end subroutine VectorSum
    !===================================================
end program SummingAnArray

これはおそらくあなたが達成したかったことですか?

于 2011-04-18T13:41:49.923 に答える