FORTRAN中的空格

时间:2018-01-06 18:16:49

标签: fortran

我正在尝试编译以下示例代码,我将其嵌入子例程中:

      module wallforcing
      use shared_module
      contains

      subroutine phicontrol

        EXTERNAL  FEX
        INTEGER  IOPT, IOUT, ISTATE, ITASK, ITOL, IWORK(23), LIW, LRW,
     &              MF, NEQ
        DOUBLE PRECISION  ATOL(3), RTOL, RWORK(58), T, TOUT, Y(3)
        NEQ = 3
        Y(1) = 1.D0
        Y(2) = 0.D0
        Y(3) = 0.D0
        T = 0.D0
        TOUT = .4D0
        ITOL = 2
        RTOL = 1.D-4
        ATOL(1) = 1.D-6
        ATOL(2) = 1.D-10
        ATOL(3) = 1.D-6
        ITASK = 1
        ISTATE = 1
        IOPT = 0
        LRW = 58
        LIW = 23
        MF = 21
        DO 40 IOUT = 1,12
          CALL DLSODE (FEX, NEQ, Y, T, TOUT, ITOL, RTOL, ATOL, ITASK,
     &              ISTATE, IOPT, RWORK, LRW, IWORK, LIW, JEX, MF)
          WRITE(6,20)  T, Y(1), Y(2), Y(3)
    20 FORMAT(' At t =',D12.4,'   y =',3D14.6)
            IF (ISTATE .LT. 0)  GO TO 80
    40 TOUT = TOUT*10.D0
          WRITE(6,60)  IWORK(11), IWORK(12), IWORK(13)
    60 FORMAT(/' No. steps =',i4,',  No. f-s =',i4,',  No. J-s =',i4)
          STOP
    80 WRITE(6,90)  ISTATE
    90 FORMAT(///' Error halt.. ISTATE =',I3)
          STOP
        END
C
C        SUBROUTINE  JEX (NEQ, T, Y, ML, MU, PD, NRPD)
C        INTEGER  NEQ, ML, MU, NRPD
C        DOUBLE PRECISION  T, Y(3), PD(NRPD,3)
C        PD(1,1) = -.04D0
C        PD(1,2) = 1.D4*Y(3)
C        PD(1,3) = 1.D4*Y(2)
C        PD(2,1) = .04D0
C        PD(2,3) = -PD(1,3)
C        PD(3,2) = 6.D7*Y(2)
C        PD(2,2) = -PD(1,2) - PD(3,2)
C        RETURN
C        END
C
c       return
       end subroutine phicontrol
C        SUBROUTINE  FEX (NEQ, T, Y, YDOT)
C        INTEGER  NEQ
C        DOUBLE PRECISION  T, Y(3), YDOT(3)
C        YDOT(1) = -.04D0*Y(1) + 1.D4*Y(2)*Y(3)
C        YDOT(3) = 3.D7*Y(2)*Y(2)
C        YDOT(2) = -YDOT(1) - YDOT(3)
C        RETURN
C        END
       end module wallforcing

我得到了一堆错误,我认为这些错误与空格的错误处理有关:

wallcontrol.f(35): error #5082: Syntax error, found INTEGER_CONSTANT '0' when ex   pecting one of: ( * ) :: , <END-OF-STATEMENT> ; + . - % (/ [ : ] /) . ' ** / ...
        20 FORMAT(' At t =',D12.4,'   y =',3D14.6)
---------^
wallcontrol.f(35): error #5082: Syntax error, found REAL_CONSTANT '.4' when expe   cting one of: ( * ) :: , + . - % : . ** / // .LT. < .LE. <= .EQ. == .NE. ...
        20 FORMAT(' At t =',D12.4,'   y =',3D14.6)
-------------------------------^
wallcontrol.f(35): error #5082: Syntax error, found REAL_CONSTANT '.6' when expe   cting one of: * ) :: , <END-OF-STATEMENT> ; + . - (/ [ : ] /) ' ** / // > .LT. .   ..
        20 FORMAT(' At t =',D12.4,'   y =',3D14.6)
-----------------------------------------------^
wallcontrol.f(60): error #6786: This is an invalid statement; an END [MODULE] st   atement is required.
       end subroutine phicontrol
-------^
wallcontrol.f(60): error #6785: This name does not match the unit name.   [PHICO   NTROL]
       end subroutine phicontrol
----------------------^
wallcontrol.f(44): error #6378: SUBROUTINE must be present on the end-subroutine   -stmt of an internal or module subroutine
        END
^
wallcontrol.f(31): error #6321: An unterminated block exists.
        DO 40 IOUT = 1,12
^
wallcontrol.f(31): error #6323: This label is not defined in this scoping unit.      [40]
        DO 40 IOUT = 1,12
-----------^
wallcontrol.f(69): error #6790: This is an invalid statement; an END [PROGRAM]     statement is required.
       end module wallforcing
-------^
wallcontrol.f(69): error #6785: This name does not match the unit name.   [WALLF   ORCING]
       end module wallforcing
------------------^
compilation aborted for wallcontrol.f (code 1)

代码中有什么问题?来自其他编程语言,我觉得奇怪的是FORTRAN如何搞乱空白。有没有关于这个主题的好教程?

0 个答案:

没有答案