Returns the thread number of the thread, within the team, making this call. This number will be between 0 and OMP_GET_NUM_THREADS-1. The master thread of the team is thread 0.
INTEGER FUNCTION OMP_GET_THREAD_NUM()
#include <omp.h>
int omp_get_thread_num(void)
If called from a nested parallel region, or a serial region, this function will return 0.
PROGRAM HELLO
INTEGER TID, OMP_GET_THREAD_NUM
!$OMP PARALLEL PRIVATE(TID)
TID = OMP_GET_THREAD_NUM()
PRINT *, 'Hello World from thread = ', TID
...
!$OMP END PARALLEL
END
PROGRAM HELLO
INTEGER TID, OMP_GET_THREAD_NUM
!$OMP PARALLEL
TID = OMP_GET_THREAD_NUM()
PRINT *, 'Hello World from thread = ', TID
...
!$OMP END PARALLEL
END
PROGRAM HELLO
INTEGER TID, OMP_GET_THREAD_NUM
TID = OMP_GET_THREAD_NUM()
PRINT *, 'Hello World from thread = ', TID
!$OMP PARALLEL
...
!$OMP END PARALLEL
END