Parallel Programming in Fortran 95 using OpenMP - People
Parallel Programming in Fortran 95 using OpenMP - People
Parallel Programming in Fortran 95 using OpenMP - People
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
66 4. The <strong>OpenMP</strong> run-time library<br />
4.3.2 OMP get wtick<br />
This function returns the number of seconds between successive clock ticks. Its <strong>in</strong>terface<br />
declaration is:<br />
function OMP_get_wtick()<br />
real(8) :: OMP_get_wtick<br />
end function OMP_get_wtick<br />
4.4 The <strong>Fortran</strong> 90 module omp lib<br />
The previously presented subrout<strong>in</strong>es and functions have clearly def<strong>in</strong>ed <strong>in</strong>terfaces which<br />
need to be known by the call<strong>in</strong>g program <strong>in</strong> order to call them correctly. This is achieved<br />
through a <strong>Fortran</strong> 90 module called omp lib which has to be supplied by the <strong>OpenMP</strong>implementation.<br />
Even though, the follow<strong>in</strong>g source code shows the content and aspect<br />
such a module should at least have 1 :<br />
module omp_lib<br />
implicit none<br />
!Def<strong>in</strong>es standard variable precisions of the <strong>OpenMP</strong>-implementation<br />
<strong>in</strong>teger, parameter :: OMP_<strong>in</strong>teger_k<strong>in</strong>d = 4<br />
<strong>in</strong>teger, parameter :: OMP_logical_k<strong>in</strong>d = 4<br />
<strong>in</strong>teger, parameter :: OMP_lock_k<strong>in</strong>d = 8<br />
<strong>in</strong>teger, parameter :: OMP_nest_lock_k<strong>in</strong>d = 8<br />
!Def<strong>in</strong>es the <strong>OpenMP</strong> version: <strong>OpenMP</strong> <strong>Fortran</strong> API v2.0<br />
<strong>in</strong>teger, parameter :: openmp_version = 200011<br />
!Gives the explicit <strong>in</strong>terface for each rout<strong>in</strong>e of the run-time library<br />
<strong>in</strong>terface<br />
subrout<strong>in</strong>e OMP_set_num_threads(number_of_threads)<br />
<strong>in</strong>teger(k<strong>in</strong>d = OMP_<strong>in</strong>teger_k<strong>in</strong>d), <strong>in</strong>tent(<strong>in</strong>) :: number_of_threads<br />
end subrout<strong>in</strong>e OMP_set_num_threads<br />
function OMP_get_num_threads()<br />
<strong>in</strong>teger(k<strong>in</strong>d = OMP_<strong>in</strong>teger_k<strong>in</strong>d) :: OMP_get_num_threads<br />
end function OMP_get_num_threads<br />
function OMP_get_max_threads()<br />
<strong>in</strong>teger(k<strong>in</strong>d = OMP_<strong>in</strong>teger_k<strong>in</strong>d) :: OMP_get_max_threads<br />
end function OMP_get_max_threads<br />
function OMP_get_thread_num()<br />
<strong>in</strong>teger(k<strong>in</strong>d = OMP_<strong>in</strong>teger_k<strong>in</strong>d) :: OMP_get_thread_num<br />
end function OMP_get_thread_num<br />
1 The presented source code will not work with many <strong>Fortran</strong> 90 compilers, because they do not<br />
allow the use of parameter constants <strong>in</strong>side <strong>in</strong>terface declarations. To solve this, it is necessary to<br />
substitute manually the values of these constants <strong>in</strong>to the declarations.