Use omp_get_level to return the number of active and inactive nested parallel regions that the generating task is executing in. This does not include the implicit parallel region.
int omp_get_level(void);