Line data Source code
1 : ! ***********************************************************************
2 : !
3 : ! Copyright (C) 2010 The MESA Team
4 : !
5 : ! This program is free software: you can redistribute it and/or modify
6 : ! it under the terms of the GNU Lesser General Public License
7 : ! as published by the Free Software Foundation,
8 : ! either version 3 of the License, or (at your option) any later version.
9 : !
10 : ! This program is distributed in the hope that it will be useful,
11 : ! but WITHOUT ANY WARRANTY; without even the implied warranty of
12 : ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 : ! See the GNU Lesser General Public License for more details.
14 : !
15 : ! You should have received a copy of the GNU Lesser General Public License
16 : ! along with this program. If not, see <https://www.gnu.org/licenses/>.
17 : !
18 : ! ***********************************************************************
19 :
20 : module utils_openmp
21 :
22 : implicit none
23 :
24 : private
25 : public :: eval_OMP_GET_THREAD_NUM
26 : public :: eval_OMP_GET_MAX_THREADS
27 : public :: eval_OMP_SET_NUM_THREADS
28 :
29 : integer :: omp_max_threads = -1
30 :
31 : contains
32 :
33 1311 : integer function eval_OMP_GET_THREAD_NUM()
34 : use omp_lib, only: OMP_GET_THREAD_NUM
35 1311 : eval_OMP_GET_THREAD_NUM = OMP_GET_THREAD_NUM()
36 1311 : end function eval_OMP_GET_THREAD_NUM
37 :
38 20 : integer function eval_OMP_GET_MAX_THREADS()
39 : use omp_lib, only: OMP_GET_MAX_THREADS
40 20 : if (omp_max_threads < 0) &
41 3 : omp_max_threads = OMP_GET_MAX_THREADS()
42 20 : eval_OMP_GET_MAX_THREADS = omp_max_threads
43 20 : end function eval_OMP_GET_MAX_THREADS
44 :
45 0 : subroutine eval_OMP_SET_NUM_THREADS(threads)
46 : use omp_lib, only: OMP_SET_NUM_THREADS
47 : integer, intent(in) :: threads
48 0 : call OMP_SET_NUM_THREADS(threads)
49 0 : end subroutine eval_OMP_SET_NUM_THREADS
50 :
51 : end module utils_openmp
|