NCEPLIBS-sp 2.4.0
ncpus.F
Go to the documentation of this file.
1C> @file
2C> Set number of cpus.
3C>
4C> ### Program History Log
5C> Date | Programmer | Comments
6C> -----|------------|---------
7C> 94-08-19 | Iredell | Initial.
8C> 98-11-09 | Vuong | Add doc>block and remove cray references.
9C> 1998-12-18 | Iredell | IBM SMP version.
10C> 2010-11-16 | Slovacek | Linux must have different call.
11C> 2012-11-01 | Mirvis | Multi-threading on LINUX-IBM/TIDE.
12C>
13C> @author Iredell @date 94-08-19
14
15C> Set number of CPUs - the number of processors over which
16C> to parallelize.
17C>
18C> @param[out] ncpus number of CPUs.
19C>
20C> @return Number of CPUs assigned.
21C>
22C> @author Iredell @date 94-08-19
23 FUNCTION ncpus()
24 INTEGER nthreads, tid, omp_get_num_threads,omp_get_thread_num
25C 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