12.07.2015 Views

PGI Fortran - Servidor WWW del Cluster Ladon-Hidra

PGI Fortran - Servidor WWW del Cluster Ladon-Hidra

PGI Fortran - Servidor WWW del Cluster Ladon-Hidra

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.

MX = MAX(MX, LMX)!$OMP END CRITICAL!$OMP END PARALLELPRINT *, “MAX VALUE OF A IS “, MXENDNote that this program could also be implemented without the critical region by declaring MX as areduction variable and performing the MAX calculation in the loop using MX directly rather thanusing LMX. See Section 8.6, DO ... END DO and Section 8.2, PARALLEL ... END PARALLEL, formore information on how to use the REDUCTION clause on a parallel DO loop.8.4 MASTER ... END MASTERThe OpenMP MASTER...END MASTER directive uses the following syntax.!$OMP MASTER< Fortran code in body of MASTER section >!$OMP END MASTERIn a parallel region of code, there may be a sub-region of code that should execute only on themaster thread. Instead of ending the parallel region before the sub-region and then starting it upagain after the sub-region, the MASTER...END MASTER directive pair lets you convenientlydesignate code that executes on the master thread and is skipped by the other threads. There is noimplied barrier on entry to or exit from a MASTER...END MASTER section of code. Nestedmaster sections are ignored. Branching into or out of a master section is not supported.PROGRAM MASTER_USEINTEGER A(0:1)INTEGER omp_get_thread_numA=-1!$OMP PARALLELA(omp_get_thread_num()) = omp_get_thread_num()!$OMP MASTERPRINT *, “YOU SHOULD ONLY SEE THIS ONCE”!$OMP END MASTER!$OMP END PARALLELPRINT *, “A(0)=“, A(0), “ A(1)=“, A(1)END8.5 SINGLE ... END SINGLEThe OpenMP SINGLE...END SINGLE directive uses the following syntax:292 Chapter 8

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

Saved successfully!

Ooh no, something went wrong!