Fortran 77 代码有效但不显示所有值

Fortran 77 codes works but does not show all values

我的程序可以运行,但它没有显示所有 P(I) 值。

当它工作时它只显示 P(1) 值。并停止它。但我想知道所有的价值观。 P(1) 到 P(121).

问题出在哪里?循环有什么问题吗?

       PROGRAM odev
        dimension P(121)
c       div(ro.v.fi)=div(r.gradfi)+a-bfi
c       P(1)=P(2)=P(3)=P(4)=P(5)=P(6)=P(7)=P(8)=P(9)=P(10)=P(11)=100
c       P(12)=P(23)=P(34)=P(45)=P(56)=P(67)=P(78)=P(89)=P(100)=P(111)=100
c       P(22)=P(33)=P(44)=P(55)=P(66)=P(77)=P(88)=P(99)=P(110)=P(121)=0
c       P(112)=P(113)=P(114)=P(115)=P(116)=P(117)=P(118)=P(119)=P(120)=0
   50  PRINT *, "Hangi yontemle cozum yapmak istiyorsunuz?"
        PRINT *, "Merkezi farklar icin 1"
        PRINT *, "Upwind icin 2"
        PRINT *, "Hybrid icin 3"
        PRINT *, "Powerlaw icin 4 giriniz"
        READ *, DE
        PRINT *, "iterasyon saysn giriniz"
        read*, iter
        IF (DE.eq.1)  THEN
        GO TO 10
        ELSE IF (DE.eq.2)  THEN
        GO TO 20
        ELSE IF (DE.eq.3)  THEN
        GO TO 30
        ELSE IF (DE.eq.4)  THEN
        GO TO 40
        ELSE
        PRINT *, "Lutfen 1-4 aral§nda giriŸ yapnz"
        GO TO 50
        END IF
    5  do I=1,11
       P(I)=100
       end do
    6  do I=12,111,11
       P(I)= 100
       end do
    7  do I=22,121,11
       P(I)=0
       end do
    8  do I=112,120
       P(I)=0
       end do
   10 PRINT *, "Merkezi farklar metodu"
c      tanimlanan formule gore 10*10 hucreli grid
c      sistem icin hesap yapar
       do 3 n=1, iter
        DO 4 I=13, 109
       P(I)=(0.5*P(I+1)+1.5*P(I-1)-P(I-11)+3*P(I+11)+10)/6
    4 continue
    3 continue
        GO TO 60
   20  PRINT *, "Upwind metodu "
       do n=1, iter
        DO I=13, 109
        P(I)=(P(I+1)+2*P(I-1)+P(I-11)+5*P(I+11)+10)/11
        END DO
       end do
        GO TO 60
   30  PRINT *, "Hybrid metodu "
        do n=1, iter
        DO I=13, 109
        P(I)=(0.5*P(I+1)+1.5*P(I-1)+4*P(I+11)+10)/8
        END DO
       end do
        GO TO 60
   40  PRINT *, "Powerlaw metodu "
        do n=1, iter
        DO I=13, 109
       P(I)=(0.591*P(I+1)+1.591*P(I-1)+0.078*P(I-11)+4.078*P(I+11)+10)/8.338
        END DO
       end do
        GO TO 60
   60  PRINT *, "Tesekkurler"
       do 11 I=1,121
       print *, I, P(I)
       pause
   11  continue
       END

编辑;

来自@High Performance Mark的建议

  60  PRINT *, "Tesekkurler"
       do 11 I=1,121
       print *, I, P(I)
c       pause
   11  continue

现在上班了。但是显示的 P(13) 到 P(109) 值 >Nan

P(1) 到 P(12) 接近 1e-40 (必须是 100) P(110) 到 P(121) 接近 1e-38

我觉得还有一个问题...

编辑 2;

来自@francescalus的建议

c       P(112)=P(113)=P(114)=P(115)=P(116)=P(117)=P(118)=P(119)=P(120)=0
    5  do I=1,11
       P(I)=100
       end do
    6  do I=12,111,11
       P(I)= 100
       end do
    7  do I=22,121,11
       P(I)=0
       end do
    8  do I=112,120
       P(I)=0
       end do
   50  PRINT *, "Hangi yontemle cozum yapmak istiyorsunuz?"

来自@agentp的建议

SELECT CASE (N)
CASE (1)
PRINT *, "Merkezi farklar metodu"
    do 3 n=1, iter
    DO 4 I=13, 109
    P(I)=(0.5*P(I+1)+1.5*P(I-1)-P(I-11)+3*P(I+11)+10)/6
4 continue
3 continue
    GO TO 60
CASE (2)
PRINT *, "Upwind metodu "
    do n=1, iter
    DO I=13, 109
    P(I)=(P(I+1)+2*P(I-1)+P(I-11)+5*P(I+11)+10)/11
    END DO
    end do
    GO TO 60
CASE (3)
PRINT *, "Hybrid metodu "
    do n=1, iter
    DO I=13, 109
    P(I)=(0.5*P(I+1)+1.5*P(I-1)+4*P(I+11)+10)/8
    END DO
    end do
    GO TO 60
CASE (4)
PRINT *, "Powerlaw metodu "
    do n=1, iter
    DO I=13, 109
    Z=8.338
   P(I)=(0.591*P(I+1)+1.591*P(I-1)+0.078*P(I-11)+4.078*P(I+11)+10)/Z
    END DO
    end do
    GO TO 60
END SELECT

现在终于可以工作了...

这些行

   print *, I, P(I)
   pause

告诉程序打印P的第一个元素然后到pause。在许多计算机上,此时任何用户输入(例如按下某个键)都会导致程序继续运行。在您的代码中,这将导致 P 的下一个元素被写入终端,并且程序再次暂停。

尝试将 pause 行取出,看看会发生什么。或者像猴子一样坐在那里按一个键120次

然后把程序扔掉,用现代Fortran重写;看着 FORTRAN77 让我很痛苦。