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

ID: Q49730


The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, versions 4.0, 4.01, 4.1, 5.0, 5.1
  • Microsoft FORTRAN for OS/2, versions 4.1, 5.0, 5.1
  • Microsoft FORTRAN PowerStation for MS-DOS, versions 1.0, 1.0a
  • Microsoft Fortran Powerstation 32 for Windows NT, versions 1.0, 4.0


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 

Additional query words: 4.00 4.01 4.10 5.00 5.10 1.00 1.00a

Keywords : kberrmsg kbLangFortran
Version : :1.0,1.0a,4.0,4.01,4.1,5.0,5.1
Platform : MS-DOS NT OS/2 WINDOWS
Issue type :


Last Reviewed: November 3, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.