From 1bde8a6516aba1c8b9b2393fe16aca72a23afb8a Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Thu, 10 Mar 2016 16:40:09 +0000 Subject: [PATCH] Make sure no 0 or negative ID is read in for DM particles --- src/common_io.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/common_io.c b/src/common_io.c index 56008c763a..5f345b2ac5 100644 --- a/src/common_io.c +++ b/src/common_io.c @@ -487,7 +487,11 @@ void prepare_dm_gparts(struct gpart* gparts, int Ndm) { /* Let's give all these gparts a negative id */ for (int i = 0; i < Ndm; ++i) { - gparts[i].id = -abs(gparts[i].id); + + /* 0 ir negative ids are not allowed */ + if(gparts[i].id <= 0) error("0 or negative if for DM particle"); + + gparts[i].id = -gparts[i].id; } } -- GitLab