[問題] 求助 The shapes of the array expressio

看板Fortran作者 (台南玄野計!)時間10年前 (2014/12/02 01:03), 編輯推噓1(102)
留言3則, 3人參與, 最新討論串1/1
我的程式是這樣 DISPERSION PROGRAM C 1-D, EXPLICIT SCHEME real C(182),F(182),CN(182),E(182),ZNDA +DX,DT,K integer INDX c DIMENSION C OPEN (5, FILE='A5.DAT', STATUS='NEW') OPEN (6, FILE='A6.OUT', STATUS='OLD') C READ(5,*) DX, DT, K DX=1.0 DT=1.0 K=0.1 WRITE(6,*) INDX, I, DX, DT, K INDX=0 20 DO 40,I=1,9 C(I)=0 40 CONTINUE C(5)=10 DX=1.0 DT=1.0 K=0.1 ZNDA=K*DT/(DX)**2 A=-ZNDA 110 B=1+2*ZNDA C=-ZNDA 130 WRITE(*,*)"t=",INDX INDX=INDX+1 E(2)=0 F(2)=C(1) DO 210, I=3,9 D=C(I) E(I)=-C/(A*E(I-1)+B) F(I)=(D-A*F(I-1))/(A*E(I-1)+B) 210 CONTINUE 220 DO 250,I=1,7 J=9-I CN(J)=E(J+1)*C(J+1)+F(J+1) 250 CONTINUE DO 280,I=1,9 C(I)=CN(I) 280 CONTINUE cc WRITE(*,*)"t=",INDX 290 IF(MOD (INDX+60,60).NE.0)GO TO 220 WRITE(1,*)(C(I),I=2,8) 310 IF(INDX.LT.1440)GO TO 110 STOP END 按ctrl+f7之後~ 它說有錯誤 如下 --------------------Configuration: 1DIS - Win32 Debug-------------------- Compiling Fortran... E:\1DIS3\1DIS.FOR E:\1DIS3\1DIS.FOR(39) : Error: The shapes of the array expressions do not conform. [E] E(I)=-C/(A*E(I-1)+B) ------^ Error executing df.exe. 1DIS.OBJ - 1 error(s), 0 warning(s) 想請問是否我沒定義E(I)才會出現這種錯誤?? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.230.83.253 ※ 文章網址: http://www.ptt.cc/bbs/Fortran/M.1417453388.A.543.html

12/02 12:46, , 1F
ㄜ...是不是很多人寫程式都不喜歡加IMPLICIT NONE??
12/02 12:46, 1F

12/02 15:06, , 2F
C應該是陣列 C(1)
12/02 15:06, 2F

12/02 20:08, , 3F
加了IMPLICIT NONE 我還是錯誤 XD.
12/02 20:08, 3F
文章代碼(AID): #1KV9zCL3 (Fortran)
文章代碼(AID): #1KV9zCL3 (Fortran)