NCEPLIBS-ip  5.1.0
ncpus.F
Go to the documentation of this file.
1 C> @file
2 C> Set number of cpus.
3 C>
4 C> ### Program History Log
5 C> Date | Programmer | Comments
6 C> -----|------------|---------
7 C> 94-08-19 | Iredell | Initial.
8 C> 98-11-09 | Vuong | Add doc>block and remove cray references.
9 C> 1998-12-18 | Iredell | IBM SMP version.
10 C> 2010-11-16 | Slovacek | Linux must have different call.
11 C> 2012-11-01 | Mirvis | Multi-threading on LINUX-IBM/TIDE.
12 C>
13 C> @author Iredell @date 94-08-19
14 
15 C> Set number of CPUs - the number of processors over which
16 C> to parallelize.
17 C>
18 C> @param[out] ncpus number of CPUs.
19 C>
20 C> @return Number of CPUs assigned.
21 C>
22 C> @author Iredell @date 94-08-19
23  FUNCTION ncpus()
24  INTEGER tid
25 C Obtain thread number
26 #ifdef openmp
27  INTEGER omp_get_num_threads,omp_get_thread_num
28 !$OMP PARALLEL PRIVATE(TID)
29  tid = omp_get_thread_num()
30 ! PRINT *, '...............thread # ', TID
31  if (tid. eq. 0) then
32  ncpus=omp_get_num_threads()
33 ! PRINT *, 'totaly #------------------- of threads = ',NCPUS
34  endif
35 !$OMP END PARALLEL
36 #else
37  tid = 0
38  ncpus = 1
39 #endif
40  RETURN
41  END
function ncpus()
Set number of CPUs - the number of processors over which to parallelize.
Definition: ncpus.F:24