Quantcast
Channel: Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2583

fortran where statement VS openmp?

$
0
0

Dear All, Help I have a subroutine search value for array below PART1

Can I use openmp derivative increase search speed? like PART2

PART1

 subroutine p_search(array, length, value, location)
   implicit none
   integer length
   integer,dimension(length) :: array
   logical,dimension(length) :: ref
   integer value
   integer location

   ref = .false.
   where( array .eq. value) ref = .true.
   if( count( ref ) .ne. 1 )then
      write(*,*)"p_search: error count(ref)=",count(ref)
      write(*,*)"array=",array
      write(*,*)"value=",value
      stop
   else
      location = maxloc(array,1,ref)
   endif
   return
 end subroutine p_search

PART2

 subroutine p_search(array, length, value, location)
   implicit none
   integer length
   integer,dimension(length) :: array
   logical,dimension(length) :: ref
   integer value
   integer location

   ref = .false.
!$OMP PARALLEL
   where( array .eq. value) ref = .true.
!$OMP PARALLEL
   if( count( ref ) .ne. 1 )then
      write(*,*)"p_search: error count(ref)=",count(ref)
      write(*,*)"array=",array
      write(*,*)"value=",value
      stop
   else
      location = maxloc(array,1,ref)
   endif
   return
 end subroutine p_search

 


Viewing all articles
Browse latest Browse all 2583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>