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 qualifier. 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 qualifiers, directives used outside directive blocks, and directives used inside directive blocks differ in their effective durations:

  Command-line qualifier
 |
 |    Program Unit A
 |
 |     C*$* directive
 |    |
 |    |   C*$* beginblock
 |    |       C*$* directive
 |    |      | loop
 |    |      | array
 |    |      | loop
 |    |      -> C*$*endblock
 |    |
 |    |   C*$* beginblock
 |    |       C*$* directive
 |    |      | loop
 |    |      | array
 |    |      | loop
 |    |      -> C*$*endblock
 |    |
 |     -> End
 |
 |    Program Unit B
 |
 |    loop A
 |
 |     C*$* directive
 |    |
 |    | loop B
 |    |
 |    |   C*$* beginblock
 |    |       C*$* directive
 |    |      | loop
 |    |      | array
 |    |      | 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 .

To use a loop directive with an array, you must enclose the array in a directive block. In the following example, KAP issues an error message when it sees the parallel loop directive C*$* MINCONCURRENT (999999) and the array ddx outside a directive block:

C*$* MINCONCURRENT ( 999999 )
      ddx(2:I-1,1:J) = array(3:I,1:J)-array(1:I-2,1:J)
      ddx(1,1:J) = 2*(array(2,1:J)-array(  1,1:J))
      ddx(I,1:J) = 2*(array(I,1:J)-array(I-1,1:J))

Error message:

     ### C*$* minconcurrent (999999)
     ### in line 246 procedure DDX of file channel90.f ###
This directive does not apply to any loop and has been ignored.
0 errors in file channel90.f
 KAP -- Syntax Warnings Detected

To correct the error, enclose the directive and the array with C*$* beginblock and C*$* endblock .

You begin KAP directives with C*$* .


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