cpp: #include <omp.h>\n#include <stdio.h>\n\nint main()\n{\n  int numThreads=0 ; \n#pragma omp parallel\n  {\n    if ( omp_get_thread_num()==0 ) {\n      numThreads = omp_get_num_threads();\n    }\n  }\n  printf ("numThreads=%d\n", numThreads);\n  return 0;\n}\n
fortran: program DRB051_getthreadnum_orig_no\n    use omp_lib\n    implicit none\n\n    integer :: numThreads\n\n    !$omp parallel\n    if (omp_get_thread_num() == 0) then\n        numThreads = omp_get_num_threads()\n    end if\n    !$omp end parallel\n\n    print 100, numThreads\n    100 format ('numThreads =',i3)\nend program