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

ID: Q49730

4.00 4.01 4.10 5.00 5.10 1.00 1.00a | 4.10 5.00 5.10 | 1.00 4.00

MS-DOS                              | OS/2           | WINDOWS NT
  kbprb

The information in this article applies to:

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 reference words: 4.00 4.01 4.10 5.00 5.10 1.00 1.00a
KBCategory:   kbprb
KBSubcategory: FLIss
Keywords          : kberrmsg kbLangFortran 
Version           : 4.00 4.01 4.10 5.00 5.10 1.00 1.
Platform          : MS-DOS NT OS/2 WINDOWS

Last Reviewed: May 23, 1998