Conditionally Compiling Metacommands in FORTRAN Code

Last reviewed: December 11, 1995
Article ID: Q49466
The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS and OS/2, versions 5.0 and 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

SUMMARY

You can conditionally compile metacommands in FORTRAN source code. However, you cannot use the /4cc compiler option switch to do so because the metacommand requires its dollar sign ($) in the first column of the source line while the /4cc switch requires a character specifier as the first character of the source line.

To conditionally compile code involving metacommands, use the $DEFINE metacommand or the /D compiler option switch with the $IF, $ELSEIF, $ELSE, and $ENDIF metacomands. For more information, see pages 281-284 and page 335 of the Microsoft FORTRAN "Reference" manual for versions 5.0 and 5.1 or the FORTRAN PowerStation Language Help.

MORE INFORMATION

The following code example demonstrates conditionally compiling code that includes metacommands.

Sample Code

C Compile options needed: See below

$IF DEFINED(L) $INCLUDE 'large.inc' $ELSE $INCLUDE 'medium.inc' $ENDIF

If the line "$DEFINE L" precedes this $IF block, the compiler includes the LARGE.INC file, otherwise the compiler includes the MEDIUM.INC file. This method provides the ability to hard code conditional changes.

To choose the version to compile from the command line, specify the /D compiler option switch to define the variable used in the $IF block. The /D option switch eliminates the need for the $DEFINE metacommand. In the previous example, to include the LARGE.INC file, use a compiler command line such as the following:

   fl /DL name.ext


Additional reference words: kbinf 5.00 5.10 1.00 4.00
KBCategory: kbprg
KBSubcategory: FORTLngIss


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.