[Omp] OpenMP and pure function in fortran

Marek Wojcik Marek.Wojcik at ifj.edu.pl
Wed Nov 17 08:36:07 PST 2004


 Dear Experts,

 Is OpenMP standard aware of Fortran 95 Pure (Elemental) Functions?
 In other words is it enough to declare function pure in order to
 achieve parallelization via OpenMP directives?
 Is it required or implementation dependent?

 Regards,
Marek Wojcik

P.S Below I included small example.

module lib
 implicit none

contains

 pure real function poo(x)
   real, intent (in) :: x

   poo = 2*x
  
 end function poo

end module lib

program test
 use lib
 implicit none
 integer, parameter :: n = 1000000
 integer :: i, j
 real    :: a(n), b(n), c(n), t1, t2

 a = 3.1415

!$OMP PARALLEL 

!$OMP DO
 do i=1, n
    b(i) = poo(a(i))
  end do
!$OMP END DO

!$OMP END PARALLEL
end do

 print *, maxval(b), maxval(c), 'time:> ', t2-t1

end program test 




More information about the Omp mailing list