omp_partools.F90 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. !### macro's #####################################################
  2. !
  3. #define TRACEBACK write (gol,'("in ",a," (",a,", line",i5,")")') rname, __FILE__, __LINE__; call goErr
  4. #define IF_NOTOK_RETURN(action) if (status/=0) then; TRACEBACK; action; return; end if
  5. #define IF_ERROR_RETURN(action) if (status> 0) then; TRACEBACK; action; return; end if
  6. !
  7. #include "tm5.inc"
  8. !
  9. !#################################################################
  10. module OMP_ParTools
  11. use GO, only : gol, goPr, goErr
  12. use partools, only : isRoot
  13. public :: TM5_OMP_Init
  14. ! --- const --------------------------------------
  15. character(len=*), parameter :: mname = 'OMP_ParTools'
  16. ! --- var --------------------------------------
  17. integer :: omp_mytask, omp_ntasks
  18. !$OMP THREADPRIVATE (omp_mytask, omp_ntasks)
  19. contains
  20. ! ===================================================
  21. subroutine TM5_OMP_Init ( status )
  22. implicit none
  23. integer, intent(out) :: status
  24. ! Functions
  25. integer :: omp_get_thread_num, omp_get_num_threads
  26. !$OMP PARALLEL &
  27. !$OMP default (none)
  28. #ifdef _OPENMP
  29. omp_mytask = omp_get_thread_num()
  30. omp_ntasks = omp_get_num_threads()
  31. write(gol,*)'OMP. ntasks: ',omp_ntasks,', my_task: ',omp_mytask ; call goPr
  32. #else
  33. omp_mytask = 0
  34. omp_ntasks = 1
  35. if(isRoot) then
  36. write(gol,*)'No OpenMP parallelization used' ; call goPr
  37. endif
  38. #endif
  39. !$OMP END PARALLEL
  40. status = 0
  41. return
  42. end subroutine TM5_OMP_Init
  43. end module OMP_ParTools