HP 3000 Manuals

Using Conditional Compilation Directives [ HP FORTRAN 77/iX Programmer's Guide ] MPE/iX 5.0 Documentation


HP FORTRAN 77/iX Programmer's Guide

Using Conditional Compilation Directives 

Use the conditional compilation directives listed in table 8-1.

          Table 7-1.  Conditional Compilation Directives 

---------------------------------------------------------------------------
|                |                                                        |
|   Directive    |                      Description                       |
|                |                                                        |
---------------------------------------------------------------------------
|                |                                                        |
| $IF            | Conditionally compiles blocks of code.                 |
|                |                                                        |
---------------------------------------------------------------------------
|                |                                                        |
| $ELSE          | Used with the IF directive; marks the beginning of the |
|                | ELSE block of code.                                    |
|                |                                                        |
---------------------------------------------------------------------------
|                |                                                        |
| $ENDIF         | Ends the IF directive.                                 |
|                |                                                        |
---------------------------------------------------------------------------
|                |                                                        |
| $SET           | Assigns values to identifiers used in IF directives.   |
|                |                                                        |
---------------------------------------------------------------------------

For example, the partial program below uses the system intrinsics if the
program is run on an MPE/iX system and uses FORTRAN I/O for portable
code.

            PROGRAM sysmpeix

     $SET (os_mpe_ix = .TRUE.)

            CHARACTER buffer(80)

     $IF (os_mpe_ix)
            SYSTEM INTRINSIC FREAD, FWRITE
     $ENDIF
            .
            .
            .
     $IF (os_mpe_ix)
     C  MPE/iX intrinsic I/O; System-specific:

            length = FREAD(filenum1, buffer, 80)
            CALL FWRITE(filenum2, buffer, length, 0)

     $ELSE
     C FORTRAN I/O; Portable version:

            READ(5,100) buffer
            WRITE(6,200) buffer
     100    FORMAT(80A1)
     200    FORMAT(1X, 80A1)
     $ENDIF
            .
            .
            .
            END



MPE/iX 5.0 Documentation