12.07.2015 Views

PGI User's Guide

PGI User's Guide

PGI User's Guide

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 8. Using Directives and PragmasendWhen compiled with –Mvect, both interior loops are interchanged with the outer loop.$ pgfortran -Mvect dirvect1.fDirectives alter this behavior either globally or on a routine or loop by loop basis. To assure that vectorizationis not applied, use the novector directive with global scope.cpgi$g novectorinteger maxtime, timeparameter (n = 1000, maxtime = 10)double precision a(n,n), b(n,n), c(n,n)do time = 1, maxtimedo i = 1, ndo j = 1, nc(i,j) = a(i,j) + b(i,j)enddoenddoenddoendIn this version, the compiler disables vectorization for the entire source file. Another use of the directivescoping mechanism turns an option on or off locally, either for a specific procedure or for a specific loop:integer maxtime, timeparameter (n = 1000, maxtime = 10)double precision a(n,n), b(n,n), c(n,n)cpgi$l novectordo time = 1, maxtimedo i = 1, ndo j = 1, nc(i,j) = a(i,j) + b(i,j)enddoenddoenddoendLoop level scoping does not apply to nested loops. That is, the directive only applies to the following loop.In this example, the directive turns off vector transformations for the top-level loop. If the outer loop were atiming loop, this would be a practical use for a loop-scoped directive.Scope of C/C++ Pragmas and Command-Line OptionsDuring compilation a pragma either turns an option on or turns an option off. Pragmas apply to the sectionof code corresponding to the specified scope - either the entire file, the following loop, or the following orcurrent routine. This section presents several examples showing the effect of pragmas and the use of thepragma scope indicators.NoteIn all cases, pragmas override a corresponding command-line option.For pragmas that have only routine and global scope, there are two rules for determining the scope of thepragma. We cover these special scope rules at the end of this section.Consider the following program:111

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

Saved successfully!

Ooh no, something went wrong!