简体   繁体   中英

Fortran 77 Unclassifiable statement at (1)

I have this code (In Fortran 77)

        CHARACTER*20 DICT(12) C column 9

        DATA DICT/'aa','bb','for','cry','lug','bye','fly','ugly',
     M'test1','test2', C Column 6
     M'parasympathomimetic','thigmotropism'/ C column 6

I'm getting an error on this line "M'test1','test2'," , saying that it's a syntax error/unclassifiable statement. That line and the next line " M'parasympathomimetic','thigmotropism'/" are both on column 6 on my editor, yet the previous line is giving me problems.

I've tried moving that line 1 column over, removing the 'M', and nothing seems to make the program compile.

I'm compiling it as such:

f77 test.for

I know Fortran is in fixed form, so I'm not sure what I'm doing wrong here, any help would be much appreciated.

If the C Column 9 and C Column 6 are just comments present in your code, then to add a comment at the end of a line use the ! symbol, not C .

C234567
      CHARACTER*20 DICT(12) ! column 9

      DATA DICT/'aa','bb','for','cry','lug','bye','fly','ugly',
     M'test1','test2', ! Column 6
     M'parasympathomimetic','thigmotropism'/ ! column 6

Fortran 90 introduced free source form. A source file with the *.f90 extension denotes free source form code, ie, Fortran 90/95/03/08/15. Fortran 2015 is the most recent standard and many popular compilers, including gfortran, support most of Fortran 2008.

In free source form the maximum line length is 132 characters, compared to the older limit of 72 characters. This reduces the possibility of text exceeding the limit, which could lead the compiler to misinterpret names.

Line continuations in free source form are performed by using a trailing ampersand character, & , rather than entering a character in column 6 of the following line.

For example, the following would be a legally continued line in FORTRAN 77 (assuming that the number 1 is actually in column 6):

   x = 1 + 2 + 3 + 4
 1  + 5 + 6

In free source form, a line can extend to the next line by having an ampersand as its last character.

x = 1 + 2 + 3 + 4 &
+ 5 + 6

In fixed source form, the first six columns are reserved for statement labels, with column 1 also used to indicate comment lines. In modern code, using structured control statements, statement labels are rare.

In free source form, any statement can begin in column 1. Free source form always uses the in-line comment style, indicated by using an exclamation mark. In-line comments can begin in any column.

Here is the same code in fixed format and in free source format:

C FIXED SOURCE FORM COMMENT
    DO 10, I=1, 42
    ....
 10 CONTINUE

! Free source form comment
do i=1, 42 ! Comments begin in any column
....
end do

Most importantly, with free source form, the concept of significant blanks was introduced. Here is a sample of a FORTRAN 77 fixed form statement showing what are now considered significant blanks

DO I T ER = 1 , MAX ITE R

followed by an equivalent statement without the blanks:

DO ITER=1, MAXITER

Free source form offers a number of advantages over the older fixed source form code. We recommend that it always be used in new code.

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