LCOV - code coverage report
Current view: | top level - dynamics/se/dycore - thread_mod.F90 (source / functions) |  |  | Hit | Total | Coverage
Test: | coverage.info |  | Lines: | 19 | 25 | 76.0 %
Date: | 2025-01-13 21:54:50 |  | Functions: | 6 | 8 | 75.0 %

              Line data    Source code
           1             : module thread_mod
           2             :
           3             : #ifdef _OPENMP
           4             :   use omp_lib, only: omp_get_thread_num, &
           5             :        omp_in_parallel, &
           6             :        omp_set_num_threads, &
           7             :        omp_get_max_threads, &
           8             :        omp_get_num_threads, &
           9             :        omp_get_nested,      &
          10             :        omp_set_nested
          11             : #endif
          12             :   use cam_logfile,            only: iulog
          13             :   use spmd_utils,             only: masterproc
          14             :
          15             :   implicit none
          16             :   private
          17             :
          18             :   integer, public :: max_num_threads=1 ! maximum number of OpenMP threads
          19             :   integer, public :: horz_num_threads, vert_num_threads, tracer_num_threads
          20             :
          21             :   public :: omp_get_thread_num
          22             :   public :: omp_in_parallel
          23             :   public :: omp_set_num_threads
          24             :   public :: omp_get_max_threads
          25             :   public :: omp_get_num_threads
          26             :   public :: omp_get_nested
          27             :   public :: omp_set_nested
          28             :   public :: initomp
          29             : contains
          30             :
          31             : #ifndef _OPENMP
          32     6676272 :   function omp_get_thread_num() result(ithr)
          33             :     integer ithr
          34     6676272 :     ithr=0
          35     6676272 :   end function omp_get_thread_num
          36             :
          37       12288 :   function omp_get_num_threads() result(ithr)
          38             :     integer ithr
          39       12288 :     ithr=1
          40       12288 :   end function omp_get_num_threads
          41             :
          42        1536 :   function omp_in_parallel() result(ans)
          43             :     logical ans
          44        1536 :     ans=.FALSE.
          45        1536 :   end function omp_in_parallel
          46             :
          47      742656 :   subroutine omp_set_num_threads(NThreads)
          48             :     integer Nthreads
          49      742656 :     NThreads=1
          50      742656 :   end subroutine omp_set_num_threads
          51             :
          52           0 :   integer function omp_get_max_threads()
          53           0 :     omp_get_max_threads=1
          54           0 :   end function omp_get_max_threads
          55             :
          56           0 :   integer function omp_get_nested()
          57           0 :     omp_get_nested=0
          58           0 :   end function omp_get_nested
          59             :
          60    16300128 :   subroutine omp_set_nested(flag)
          61             :     logical :: flag
          62    16300128 :   end subroutine omp_set_nested
          63             :
          64        1536 :   subroutine initomp
          65        1536 :     max_num_threads = 1
          66        1536 :     if (masterproc) then
          67           2 :       write(iulog,*) "INITOMP: INFO: openmp not activated"
          68             :     end if
          69        1536 :   end subroutine initomp
          70             :
          71             : #else
          72             :   subroutine initomp
          73             :     !$OMP PARALLEL
          74             :     max_num_threads = omp_get_num_threads()
          75             :     !$OMP END PARALLEL
          76             :     if (masterproc) then
          77             :       write(iulog,*) "INITOMP: INFO: number of OpenMP threads = ", max_num_threads
          78             :     end if
          79             :   end subroutine initomp
          80             : #endif
          81             :
          82             : end module thread_mod

Generated by: LCOV version 1.14