简体   繁体   中英

Can a CHARACTER declaration and its DATA statement come before an IMPLICIT statement?

FORTRAN was my first programming language in the 1970s, but I cannot determine if the following FORTRAN code is valid. I have no way to compile or run the code.

    SUBROUTINE ABC(PARM1, PARM2)
    CHARACTER*40 projName 
    DATA projName /'...values...'/

C Lots of comments...

C VARIABLE DECLARATIONS BEGIN HERE (the exact wording)

    IMPLICIT REAL*8(A-H,O-Z)
    (the rest of the declarations)
    . . .

All of the references say that the IMPLICIT statement must come before any declarations; however, this code apparently runs. My thoughts are that either (1) the IMPLICIT statement is ignored, or (2) this code is valid in some flavor of FORTRAN. If IMPLICIT is ignored, compile flags could have been used for the same purpose.

I need to decide valid/invalid and briefly justify my answer. Any ideas would be greatly appreciated.

Thanks, lac

The CHARACTER type was introduced with Fortran 77. Fortran 77 section 3.5 "Order of Statements and Lines" says "Within the specification statements of a program unit, IMPLICIT statements must precede all other specification statements except PARAMETER statements."

Similar restrictions exist in later standards.

The code as described is not conforming.

(Fortran 77 did not require Fortran processors to diagnose even the most basic of the language rules. A compiler may have accepted a different statement ordering as an extension, or by accident.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM