FIX: Nested $IF Statements with $ELSE Cause F2830 Error (108366)



The information in this article applies to:

  • Microsoft FORTRAN Compiler for MS-DOS 5.0
  • Microsoft FORTRAN Compiler for MS-DOS 5.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

This article was previously published under Q108366

SYMPTOMS

An attempt to compile a program that contains nested $IF compiler conditions with $ELSE clauses may fail to produce the expected result. The compiler may generate the error:
error F2830: END missing

CAUSE

When there is a $ELSE following a $ENDIF and the outer $IF condition is met making the condition false, the compiler fails to parse for any metacommands following the $ELSE including the $ENDIF that terminates the outer $IF block.

STATUS

Microsoft has confirmed this to be a problem in Microsoft FORTRAN PowerStation 32 for Windows NT, version 1.0 and MS-DOS versions 1.0 and 1.0a. This problem was fixed in FORTRAN PowerStation, version 4.0.

MORE INFORMATION

The sample code below illustrates the problem:

Sample Code

C Compile options needed: none
$define first
      subroutine test
$if defined (first)
$if defined (second)
$endif
$else
$endif
      return
      end
				

Modification Type:MajorLast Reviewed:12/1/2003
Keywords:kbfix KB108366