NCEPLIBS-sp  2.5.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 nthreads, tid, omp_get_num_threads,omp_get_thread_num
25 C Obtain thread number
26 #ifdef openmp
27 !$OMP PARALLEL PRIVATE(TID)
28  tid = omp_get_thread_num()
29 ! PRINT *, '...............thread # ', TID
30  if (tid. eq. 0) then
31  ncpus=omp_get_num_threads()
32 ! PRINT *, 'totaly #------------------- of threads = ',NCPUS
33  endif
34 !$OMP END PARALLEL
35 #else
36  tid = 0
37  ncpus = 1
38 #endif
39  RETURN
40  END
function ncpus()
Set number of CPUs - the number of processors over which to parallelize.
Definition: ncpus.F:24