Use omp_get_active_level to return the number of active parallel regions that are nested.
int omp_get_active_level(void);