PRB: F2836 "statement out of order" Error From DATA Statement (49730)



The information in this article applies to:

  • Microsoft FORTRAN Compiler for MS-DOS 4.0
  • Microsoft FORTRAN Compiler for MS-DOS 4.01
  • Microsoft FORTRAN Compiler for MS-DOS 4.1
  • Microsoft FORTRAN Compiler for MS-DOS 5.0
  • Microsoft FORTRAN Compiler for MS-DOS 5.1
  • Microsoft FORTRAN compiler for OS/2 4.1
  • Microsoft FORTRAN compiler for OS/2 5.0
  • Microsoft FORTRAN compiler for OS/2 5.1
  • Microsoft FORTRAN PowerStation for MS-DOS 1.0
  • Microsoft FORTRAN PowerStation for MS-DOS 1.0a
  • Microsoft Fortran Powerstation 32 for Windows NT 1.0
  • Microsoft Fortran Powerstation 32 for Windows NT 4.0

This article was previously published under Q49730

SYMPTOMS

Compiling an application which has a DATA statement that precedes an integer declaration causes the compiler to generate the following error:
F2836: statement out of order

CAUSE

The application contains a DATA statement that is not specified in the correct order. According to page 48 of the Microsoft FORTRAN "Reference" manual for versions 5.0 and 5.1, "All specification statements must precede all DATA statements, statement-function statements, and executable statements."

RESOLUTION

To address this error, modify the source code to place the statements in the proper order. The table on page 47 of the Reference manual provides the required statement order for code to compile correctly. The text below provides four rules for using the DATA statement:

  1. The DATA statement must follow COMMON, DIMENSION, EQUIVALENCE, EXTERNAL, INTRINSIC, and SAVE instructions.
  2. The DATA statement can work in conjunction with the following:
          Executable statements
          Statement function statements
          ENTRY and FORMAT statements
          All metacommands except the following:
    
             $DO66,
             $[NO]FLOATCALLS
             $[NO]FREEFORM
             $STORAGE
    						
  3. The DATA statement must follow every other command.
  4. The DATA statement must precede the END instruction.
NOTE: In the Fortran PowerStation 4.0 manual, page 27, the same comment regarding DATA statement placement after type declaration specifiers exists, however this statement is incorrect for Fortran PowerStation 4.0. The order of statements table on page 26 correctly indicates that type declaration statements can occur after DATA statements. The FORTRAN 90 standard allows the mixed-use of type declaration statements and DATA statements, as long as, type declaration statements are declared before they are used in DATA statements.

MORE INFORMATION

The following code example demonstrates the F2836 "statement out of order error" because a DATA statement precedes an integer declaration statement.

Sample Code

C Code options required: None

      INTEGER N
      DATA N /1/ 
      INTEGER M
      END
				

Modification Type:MajorLast Reviewed:12/1/2003
Keywords:kberrmsg kbLangFortran KB49730