5.1 Directive Usage and Syntax

Directives placed inside a program unit remain in effect from the point of their appearance in the code until the end of the program unit. At the end of the program unit, the directive value defaults to the value set by the command-line switch. You can temporarily override directives in a program unit by partitioning sections of code into directive blocks. Directive blocks allow you to do the following:

The following example shows how command-line switches, directives used outside directive blocks, and directives used inside directive blocks differ in their effective durations.

  Command-line switch
 |
 |    Program Unit A
 |
 |     C*$* directive
 |    |
 |    |   C*$* beginblock
 |    |       C*$* directive
 |    |      | loop
 |    |      | loop
 |    |      | loop
 |    |      -> C*$*endblock
 |    |
 |    |   C*$* beginblock
 |    |       C*$* directive
 |    |      | loop
 |    |      | loop
 |    |      | loop
 |    |      -> C*$*endblock
 |    |
 |     -> End
 |
 |    Program Unit B
 |
 |    loop A
 |
 |     C*$* directive
 |    |
 |    | loop B
 |    |
 |    |   C*$* beginblock
 |    |       C*$* directive
 |    |      | loop
 |    |      | loop
 |    |      | loop
 |    |      -> C*$*endblock
 |    |
 |     -> End
 |
 ->End of source file

Loop directives used inside directive blocks must immediately follow the C*$* beginblock directive. Loop directives used outside of directive blocks must immediately precede the loop they are to affect. In the following example, KAP issues an error message when the loop optimization directive C*$* OPTIMIZE( 0 ) does not immediately precede the DO loop:

C*$*  OPTIMIZE( 0 )
       nbeg = M-((nn-1)*nstep)
       nend = max(1,nbeg-nstep+1)
       DO I=1,N
         colonne(1,i,nn)=c(1,i,nbeg)
         colonne(5,i,nn)=c(5,i,nbeg)
         colonne(8,i,nn)=c(8,i,nbeg)
       ENDDO

Error message:

     ### C*$*  OPTIMIZE( 0 )
     ### in line 6 procedure MOVE2D_PRE of file directive.f ###
This directive is not adjacent to the loop it applies to.
0 errors in file directive.f
 KAP -- Syntax Warnings Detected

To correct the error, C*$* OPTIMIZE( 0 ) should immediately precede DO I=1,N .


Previous Page|Next Page|Contents|Index|
Command-Line Switches

Copyright © Digital Equipment Corporation. 1997. All Rights Reserved.