XL Fortran for AIX 8.1

Language Reference

MASTER / END MASTER

Purpose

The MASTER construct enables you to define a block of code that will be run by only the master thread of the team. It includes a MASTER directive that precedes a block of code and ends with an END MASTER directive.

The MASTER and END MASTER directives only take effect if you specify the -qsmp compiler option.

Format



>>-MASTER------------------------------------------------------><
 
 
>>-block-------------------------------------------------------><
 
 
>>-END MASTER--------------------------------------------------><
 
 

block
represents the block of code that will be run by the master thread of the team.

Rules

It is illegal to branch into or out of a MASTER construct.

A MASTER directive binds to the closest dynamically enclosing PARALLEL directive, if one exists.

A MASTER directive cannot appear within the dynamic extent of a work-sharing construct or within the dynamic extent of the PARALLEL DO, PARALLEL SECTIONS, and PARALLEL WORKSHARE directives.

No implied barrier exists on entry to, or exit from, the MASTER construct.

Examples

Example 1: An example of the MASTER directive binding to the PARALLEL directive.

!$OMP PARALLEL DEFAULT(SHARED)
!$OMP MASTER
         Y = 10.0
         X =  0.0
         DO I = 1, 4
             X = X + COS(Y) + I
         END DO
!$OMP END MASTER
!$OMP BARRIER
!$OMP DO PRIVATE(J)
         DO J = 1, 10000
              A(J) = X + SIN(J*2.5)
         END DO
!$OMP END DO
!$OMP END PARALLEL
         END

Related Information


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]