Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29279 Discussions

Ascertain number of processors assigned to a Fortran program?

postaquestion
Novice
586 Views
Is there a means to ascertain the number of processors assigned to a Fortran program from within the source code itself? Apparently other compilers have statements that will allow this to be done, but I havebeen unable to find something similar for the Intel Fortran compiler.
0 Kudos
3 Replies
Steven_L_Intel1
Employee
586 Views
You'll have to clarify what you mean by the question. You can ask how many processors are available easily enough - see the "Platform" sample provided. But processors are not typically "assigned" to a progran. You can specify that a thread is to have an affinity to a particular processor, but that doesn't sound like what you're asking.

What's an example from another compiler of what you want?
0 Kudos
tjdelph
Beginner
586 Views
Steve,
The Compaq Fortran compiler, which I have installed on my Windows PC, has the following inquiry function: NUMBER_OF_PROCESSORS, which, quoting directly from the manual, "returns the total number of processors (peers) available to the program". I'd like to know if the Intel Fortran compiler has something similar.

Terry
0 Kudos
Steven_L_Intel1
Employee
586 Views
Ah, that's a HPF (High Performance Fortran) intrinsic. The Intel compiler DOES support this, though I find it is not documented. The OpenMP routine OMP_GET_NUM_PROCS is documented and supported. For example:

use omp_lib
print *, omp_get_num_procs()
end

You need to build with /Qopenmp to use this.

Note that unless you have threaded your application, the number of processors is not meaningful.
0 Kudos
Reply