Skip to content

Commit c16e452

Browse files
atmyersguj
authored andcommitted
Add assert that we are not inside threaded region when InitRandom is called. (AMReX-Codes#3204)
1 parent fffde2f commit c16e452

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Src/Base/AMReX_Random.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ InitRandom (ULong cpu_seed, int nprocs, ULong gpu_seed)
6767
nthreads = OpenMP::get_max_threads();
6868
generators.resize(nthreads);
6969

70+
#ifdef AMREX_USE_OMP
71+
if (omp_in_parallel()) {
72+
amrex::Abort("It is not safe to call amrex::InitRandom inside a threaded region.");
73+
}
74+
#endif
75+
7076
#ifdef AMREX_USE_OMP
7177
#pragma omp parallel
7278
#endif

0 commit comments

Comments
 (0)