02.07.2014 Views

Intel(R) Fortran Language Reference (online version)

Intel(R) Fortran Language Reference (online version)

Intel(R) Fortran Language Reference (online version)

SHOW MORE
SHOW LESS

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

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

Directive Enhanced Compilation 14<br />

c$OMP BARRIER<br />

c<br />

Is one of the following: C (or c), !, or * (see “Syntax Rules for Compiler Directives”).<br />

The BARRIER directive must be encountered by all threads in a team or by none at all. It must<br />

also be encountered in the same order by all threads in a team.<br />

Example<br />

The directive binding rules call for a BARRIER directive to bind to the closest enclosing<br />

PARALLEL directive. In the following example, the BARRIER directive ensures that all threads<br />

have executed the first loop and that it is safe to execute the second loop:<br />

c$OMP PARALLEL<br />

c$OMP DO PRIVATE(i)<br />

DO i = 1, 100<br />

b(i) = i<br />

END DO<br />

c$OMP BARRIER<br />

c$OMP DO PRIVATE(i)<br />

DO i = 1, 100<br />

a(i) = b(101-i)<br />

END DO<br />

c$OMP END PARALLEL<br />

See Also<br />

“Nesting and Binding Rules” for details about directive binding<br />

CRITICAL Directive<br />

The CRITICAL directive restricts access to a block of code to only one thread at a time. It takes<br />

the following form:<br />

c$OMP CRITICAL [(name)]<br />

block<br />

c$OMP END CRITICAL [(name)]<br />

c<br />

Is one of the following: C (or c), !, or * (see “Syntax Rules for Compiler Directives”).<br />

name<br />

Is the name of the critical section.<br />

14-57

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

Saved successfully!

Ooh no, something went wrong!