[問題] 程式碼沒有讀到
編譯時沒有問題,但沒有出現我要的結果
檢查發現有一段程式碼沒有發揮作用,想請教版上的大大是哪裡出錯了?!!
以下是我的code 問題出在50~57行(bbs的行數)的程式沒有作用
MODULE CB
REAL :: U
END MODULE CB
!
PROGRAM OSCILLATOR
!
! Main Program for a driven the Van der Pol Oscillator solved with
! the fourth-order Runge-Kutta algorithm. Parameters:U
!
USE CB
IMPLICIT NONE
INTEGER, PARAMETER :: N=3000,M=1
INTEGER :: I
REAL :: H,T,X1,X2,W1,W1F,W2,W2F,A,Q,Z
REAL :: DK11,DK21,DK12,DK22,DK13,DK23,DK14,DK24
REAL, DIMENSION (2,N) :: X
!
H = 0.05
U = 00.1
X(1,1) = 0.1
X(2,1) = 0.5
!
! Using the Runge-Kutta algorithm to integrate the equation
!
DO I = 1, N-1
T = H*I
X1 = X(1,I)
X2 = X(2,I)
DK11 = H*W1F(X1,X2,T)
DK21 = H*W2F(X1,X2,T)
DK12 = H*W1F((X1+DK11/2.0),(X2+DK21/2.0),(T+H/2.0))
DK22 = H*W2F((X1+DK11/2.0),(X2+DK21/2.0),(T+H/2.0))
DK13 = H*W1F((X1+DK12/2.0),(X2+DK22/2.0),(T+H/2.0))
DK23 = H*W2F((X1+DK12/2.0),(X2+DK22/2.0),(T+H/2.0))
DK14 = H*W1F((X1+DK13),(X2+DK23),(T+H))
DK24 = H*W2F((X1+DK13),(X2+DK23),(T+H))
X(1,I+1) = X(1,I)+(DK11+2.0*(DK12+DK13)+DK14)/6.0
X(2,I+1) = X(2,I)+(DK21+2.0*(DK22+DK23)+DK24)/6.0
END DO
WRITE (81,"(2F16.8)") (X(1,I),X(2,I),I=1,N,M)
DO I=1,N
A=X(1,I)-X(2,I)
Q=abs(A)
IF(q.le.0.001.and.X(1,I).ge.0.and.X(2,I).ge.0)then
Z=sqrt((X(1,I))**2+(X(2,I))**2)
WRITE (82,"(3F16.8)") z,X(1,I),X(2,I)
END IF
END DO
END PROGRAM OSCILLATOR
!
FUNCTION W1F (X1,X2,T) RESULT (W1)
USE CB
IMPLICIT NONE
REAL :: X1,X2,T,W1
!
W1 =X2
END FUNCTION W1F
!
FUNCTION W2F (X1,X2,T) RESULT (W2)
USE CB
IMPLICIT NONE
REAL :: X1,X2,T,W2
!
W2 = U*(1-X1**2)*X2-X1
END FUNCTION W2F
--
◎ ◢) ○
伴隨著五彩光圈,蝴蝶所到之處,惡鬼全成了碎塊, ◥◣◤
○ ⊙◢◥█))
蝴蝶優雅飛去,碎塊才來得及落下。 ○ ◥) ◥) ◎
◢█
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.119.202.112
推
12/08 09:55, , 1F
12/08 09:55, 1F
推
12/08 11:21, , 2F
12/08 11:21, 2F
→
12/08 12:47, , 3F
12/08 12:47, 3F
Fortran 近期熱門文章
PTT數位生活區 即時熱門文章