10.07.2015 Views

PGI Fortran Reference manual - The Portland Group

PGI Fortran Reference manual - The Portland Group

PGI Fortran Reference manual - The Portland Group

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

OpenMP Directives for <strong>Fortran</strong>‣ <strong>The</strong>re is an implicit barrier at the end of the parallel region, which, in the directive, isdenoted by the END PARALLEL directive. When all threads have completed execution ofthe parallel region, a single thread resumes execution of the statements that follow.By default, there is no work distribution in a parallel region. Each active thread executes the entire regionredundantly until it encounters a directive that specifies work distribution. For work distribution, refer to theDO...END DO, PARALLEL DO, or C$DOACROSS directives.ExampleExample of <strong>Fortran</strong> PARALLEL...END PARALLEL directivePROGRAM WHICH_PROCESSOR_AM_IINTEGER A(0:1)INTEGER omp_get_thread_numA(0) = -1A(1) = -1!$OMP PARALLELA(omp_get_thread_num()) = omp_get_thread_num()!$OMP END PARALLELPRINT *, "A(0)=",A(0)," A(1)=",A(1)ENDClause UsageCOPYIN: <strong>The</strong> COPYIN clause applies only to THREADPRIVATE common blocks. In thepresence of the COPYIN clause, data from the master thread’s copy of the common block iscopied to the THREADPRIVATE copies upon entry to the parallel region.IF: In the presence of an IF clause, the parallel region is executed in parallel only if thecorresponding scalar_logical_expression evaluates to .TRUE.. Otherwise, the codewithin the region is executed by a single processor, regardless of the value of the environmentvariable OMP_NUM_THREADS.NUM_THREADS: If the NUM_THREADS clause is present, the correspondingexpression, scalar_integer_expression, must evaluate to a positive integer value.This value sets the maximum number of threads used during execution of the parallelregion. A NUM_THREADS clause overrides either a previous call to the library routineomp_set_num_threads() or the setting of the OMP_NUM_THREADS environment variable.8.7.10. PARALLEL DO<strong>The</strong> OpenMP PARALLEL DO directive is a shortcut for a PARALLEL region that contains asingle DO directive.<strong>The</strong> OpenMP PARALLEL DO or DO directive must be immediately followed by a DO statement (as definedby R818 of the ANSI <strong>Fortran</strong> standard). If you place another statement or an OpenMP directive betweenthe PARALLEL DO or DO directive and the DO statement, the compiler issues a syntax error.<strong>PGI</strong> <strong>Fortran</strong> <strong>Reference</strong> Guide 172

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!