-1
在表達一個右括號在編譯使用Windows代碼::塊16.0.1這個代碼,示出了以下錯誤錯誤DO循環:預期在(1)
a(i) = (1/(delx)^2)-(1/x-1)
1
Error: Expected a right parenthesis in expression at (1)
b(i) = ((-2/((delx)^2)) - bi*ce)
1
Error: Expected a right parenthesis in expression at (1)
c(i) = (1/(delx)^2) + (1/(2*(delx)*(x-1)))
1
Error: Expected a right parenthesis in expression at (1)
論加法&
3個語句中的每一個的結尾,後面的2成爲好的,但第一個保持不變
program HW0
implicit none
integer, parameter :: nx=101
integer, parameter :: ce = 100
real*8, parameter :: bi = 10.d0
real*8 :: delx
integer :: i
real*8, dimension(nx) :: t, x
real*8, dimension(nx) :: a, b, c, d
i = 1
delx = 1/(nx-1)
a(1) = 0; b(1) = 1; c(1) = 0; d(1) = 0
a(nx) = -(1/(delx))
b(delx) = (1/(delx)) + bi
c(nx) = 0; d(nx) = 0;
do i = 2, (nx - 1)
a(i) = (1/(delx)^2)-(1/x-1)
b(i) = ((-2/((delx)^2)) - bi*ce)
c(i) = (1/(delx)^2) + (1/(2*(delx)*(x-1)))
d(i) = 0
enddo
do i = 2, nx
b(i) = b(i) - c(i-1)*(a(i)/b(i-1)); d(i) = d(i) - d(i-1)*(a(i)/b(i-1))
enddo
t(nx) = d(nx)/b(nx)
do i = (nx-1), 1, -1
t(i) = (d(i) - c(i)*t(i+1))/b(i)
enddo
stop
end program HW0
請注意「delx = 1 /(nx-1)」,其值爲0(因爲1/100 - > 0爲整數除法)。我們可以得到正確的值,如delx = 1.0d0 /(nx-1)(或1.0_dp/...等等)。 – roygvib
哦,滑了我的腦海。謝謝您的幫助! –