summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/ScheduleInterface.c14
-rw-r--r--src/schedule/ScheduleCreater.c31
2 files changed, 34 insertions, 11 deletions
diff --git a/src/main/ScheduleInterface.c b/src/main/ScheduleInterface.c
index b7607dc2..1f9ced64 100644
--- a/src/main/ScheduleInterface.c
+++ b/src/main/ScheduleInterface.c
@@ -415,6 +415,12 @@ int CCTKi_ScheduleFunction(void *function,
retcode = CCTKi_DoScheduleFunction(where, name, function, modifier, (void *)attribute);
+ if(retcode == -2)
+ {
+ CCTK_VWarn (0, __LINE__, __FILE__, "Cactus",
+ "Tried to schedule duplicate item '%s' from thorn '%s' in '%s'",
+ name, thorn, where);
+ }
#ifdef DEBUG
fprintf(stderr, "Scheduled %s at %s\n", name, where);
#endif
@@ -560,6 +566,14 @@ int CCTKi_ScheduleGroup(const char *realname,
if(attribute && (modifier || (n_before == 0 && n_after == 0 && n_while == 0)))
{
retcode = CCTKi_DoScheduleGroup(where, name, realname, modifier, (void *)attribute);
+
+ if(retcode == -2)
+ {
+ CCTK_VWarn (0, __LINE__, __FILE__, "Cactus",
+ "Tried to schedule duplicate item '%s' from thorn '%s' in '%s'",
+ name, thorn, where);
+ }
+
#ifdef DEBUG
fprintf(stderr, "Scheduled %s at %s\n", name, where);
#endif
diff --git a/src/schedule/ScheduleCreater.c b/src/schedule/ScheduleCreater.c
index 51a186b8..958223f3 100644
--- a/src/schedule/ScheduleCreater.c
+++ b/src/schedule/ScheduleCreater.c
@@ -577,6 +577,7 @@ static t_sched_item *ScheduleCreateItem(const char *name, t_sched_modifier *modi
@returndesc
0 - success
-1 - memory failure
+ -2 - duplicate item
@endreturndesc
@@*/
static int ScheduleAddItem(int ghandle, t_sched_item *item)
@@ -587,27 +588,35 @@ static int ScheduleAddItem(int ghandle, t_sched_item *item)
this_group = (t_sched_group *)Util_GetHandledData(schedule_groups, ghandle);
- this_group->n_scheditems++;
+ if(ScheduleItemNumber(this_group, item->name) == -1)
+ {
+ this_group->n_scheditems++;
- temp = (t_sched_item *)realloc(this_group->scheditems, this_group->n_scheditems*sizeof(t_sched_item));
+ temp = (t_sched_item *)realloc(this_group->scheditems, this_group->n_scheditems*sizeof(t_sched_item));
- if(temp)
- {
- this_group->scheditems = temp;
- this_group->scheditems[this_group->n_scheditems-1] = *item;
+ if(temp)
+ {
+ this_group->scheditems = temp;
+ this_group->scheditems[this_group->n_scheditems-1] = *item;
#ifdef DEBUG_SCHEDULAR
- printf("Added item '%s' to group '%s'\n", item->name, this_group->name);
+ printf("Added item '%s' to group '%s'\n", item->name, this_group->name);
#endif
- free(item);
+ free(item);
- retcode = 0;
+ retcode = 0;
+ }
+ else
+ {
+ this_group->n_scheditems--;
+ retcode = -1;
+ }
}
else
{
- this_group->n_scheditems--;
- retcode = -1;
+ /* Item already existed. */
+ retcode = -2;
}
return retcode;