diff --git a/src/space.c b/src/space.c index 7565853e047bf10b590e7a5fe50ea42705f8902a..e59b18795e85f77501d1245a328d8fed23bef270 100644 --- a/src/space.c +++ b/src/space.c @@ -1440,6 +1440,7 @@ void space_split_mapper(void *map_data, int num_cells, void *extra_data) { const int count = c->count; const int gcount = c->gcount; + const int depth = c->depth; int maxdepth = 0; float h_max = 0.0f; int ti_end_min = max_nr_timesteps, ti_end_max = 0; @@ -1449,8 +1450,8 @@ void space_split_mapper(void *map_data, int num_cells, void *extra_data) { struct xpart *xparts = c->xparts; /* Check the depth. */ - while (c->depth > (maxdepth = s->maxdepth)) { - atomic_cas(&s->maxdepth, maxdepth, c->depth); + while (depth > (maxdepth = s->maxdepth)) { + atomic_cas(&s->maxdepth, maxdepth, depth); } /* If the depth is too large, we have a problem and should stop. */