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

Last reviewed: December 11, 1995
Article 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 and 1.0a
  • Microsoft FORTRAN PowerStation 32 for Windows NT, version 1.0 and 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 reference words: 4.00 4.01 4.10 5.00 5.10 1.00 1.00a
KBCategory: kbtool kberrmsg kbprb
KBSubcategory: FLIss


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: December 11, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.