Move calculation of number of threads outside of .omp parallel.