Put #pragma omp critical after if statement as otherwise the code seems to block (blocking has been recognized using the ctobssim unit test).