summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/sbin/CreateScheduleBindings.pl8
-rw-r--r--lib/sbin/ScheduleParser.pl30
-rw-r--r--src/include/cctk_Schedule.h2
-rw-r--r--src/include/cctki_Schedule.h9
-rw-r--r--src/include/cctki_ScheduleBindings.h2
-rw-r--r--src/main/ScheduleInterface.c203
-rw-r--r--src/schedule/Schedule.h2
-rw-r--r--src/schedule/ScheduleCreater.c74
-rw-r--r--src/schedule/ScheduleTraverse.c137
9 files changed, 427 insertions, 40 deletions
diff --git a/lib/sbin/CreateScheduleBindings.pl b/lib/sbin/CreateScheduleBindings.pl
index e638cb52..3158fc7d 100644
--- a/lib/sbin/CreateScheduleBindings.pl
+++ b/lib/sbin/CreateScheduleBindings.pl
@@ -344,6 +344,7 @@ sub ScheduleBlock
my(@before_list);
my(@after_list);
my(@while_list);
+ my(@if_list);
# Extract group and routine information from the databases
($mem_groups, $tlist) = &ScheduleSelectGroups($thorn, $implementation,
@@ -386,6 +387,10 @@ sub ScheduleBlock
$rhschedule_db->{"\U$thorn\E BLOCK_$block WHILE"},
$rhinterface_db);
+ @if_list = &ScheduleSelectVars($thorn, $implementation,
+ $rhschedule_db->{"\U$thorn\E BLOCK_$block IF"},
+ $rhinterface_db);
+
# Create a block so that we can have local variables.
$buffer = " {\n";
@@ -479,10 +484,11 @@ sub ScheduleBlock
$buffer .= $indent . scalar(@before_list) . ", /* Number of BEFORE routines */\n";
$buffer .= $indent . scalar(@after_list) . ", /* Number of AFTER routines */\n";
$buffer .= $indent . scalar(@while_list) . ", /* Number of WHILE variables */\n";
+ $buffer .= $indent . scalar(@if_list) . ", /* Number of IF variables */\n";
$buffer .= $indent . "cctkschedulei_tlevelarray /* Array of timelevel data for storage groups */";
foreach $item (@$mem_groups, @$comm_groups, @$trigger_groups, @$sync_groups,
- @options, @before_list, @after_list, @while_list)
+ @options, @before_list, @after_list, @while_list, @if_list)
{
$buffer .= ",\n$indent\"$item\"";
}
diff --git a/lib/sbin/ScheduleParser.pl b/lib/sbin/ScheduleParser.pl
index aae105f8..dff3b0d9 100644
--- a/lib/sbin/ScheduleParser.pl
+++ b/lib/sbin/ScheduleParser.pl
@@ -112,7 +112,7 @@ sub parse_schedule_ccl
my($n_statements);
my($name, $as, $type, $description, $where, $language,
$mem_groups, $comm_groups, $trigger_groups, $sync_groups,
- $options, $before_list, $after_list, $while_list);
+ $options, $before_list, $after_list, $while_list, $if_list);
my($groups);
$buffer = "";
@@ -126,7 +126,8 @@ sub parse_schedule_ccl
($line_number,
$name, $as, $type, $description, $where, $language,
$mem_groups, $comm_groups, $trigger_groups, $sync_groups,
- $options,$before_list, $after_list, $while_list) = &ParseScheduleBlock($thorn,$line_number, @data);
+ $options,$before_list, $after_list, $while_list, $if_list)
+ = &ParseScheduleBlock($thorn,$line_number, @data);
$schedule_db{"\U$thorn\E BLOCK_$n_blocks NAME"} = $name;
$schedule_db{"\U$thorn\E BLOCK_$n_blocks AS"} = $as;
@@ -142,6 +143,7 @@ sub parse_schedule_ccl
$schedule_db{"\U$thorn\E BLOCK_$n_blocks BEFORE"} = $before_list;
$schedule_db{"\U$thorn\E BLOCK_$n_blocks AFTER"} = $after_list;
$schedule_db{"\U$thorn\E BLOCK_$n_blocks WHILE"} = $while_list;
+ $schedule_db{"\U$thorn\E BLOCK_$n_blocks IF"} = $if_list;
$buffer .= "\@BLOCK\@$n_blocks\n";
$n_blocks++;
@@ -193,12 +195,13 @@ sub ParseScheduleBlock
my($thorn,$line_number, @data) = @_;
my($name, $as, $type, $description, $where, $language,
$mem_groups, $comm_groups, $trigger_groups, $sync_groups,
- $options, $before_list, $after_list, $while_list);
+ $options, $before_list, $after_list, $while_list, $if_list);
my(@fields);
my($field);
my(@before_list) = ();
my(@after_list) = ();
my(@while_list) = ();
+ my(@if_list) = ();
my(@mem_groups) = ();
my(@comm_groups) = ();
my(@trigger_groups) = ();
@@ -330,6 +333,16 @@ sub ParseScheduleBlock
$keyword = "WHILE";
$field++;
}
+ elsif($fields[$field] =~ m:^IF$:i)
+ {
+ if($keyword ne "")
+ {
+ &CST_error(0,"Error parsing schedule block line '$data[$line_number]'",
+ "",__LINE__,__FILE__);
+ }
+ $keyword = "IF";
+ $field++;
+ }
elsif($keyword ne "" && $fields[$field] =~ m:\s*\(\s*:)
{
# Parse a clause of the form BEFORE(a,b,c)
@@ -363,6 +376,10 @@ sub ParseScheduleBlock
{
push(@while_list, @current_sched_list);
}
+ elsif($keyword eq "IF")
+ {
+ push(@if_list, @current_sched_list);
+ }
# Reset keyword to empty for next time.
$keyword = "";
@@ -381,6 +398,10 @@ sub ParseScheduleBlock
{
push(@while_list, $fields[$field]);
}
+ elsif($keyword eq "IF")
+ {
+ push(@if_list, $fields[$field]);
+ }
$field++;
$keyword = "";
}
@@ -499,12 +520,13 @@ sub ParseScheduleBlock
$before_list = join(",", @before_list);
$after_list = join(",", @after_list);
$while_list = join(",", @while_list);
+ $if_list = join(",", @if_list);
return ($line_number,
$name, $as, $type, $description, $where, $language,
$mem_groups, $comm_groups, $trigger_groups, $sync_groups,
- $options,$before_list, $after_list, $while_list);
+ $options,$before_list, $after_list, $while_list, $if_list);
}
diff --git a/src/include/cctk_Schedule.h b/src/include/cctk_Schedule.h
index e8f70dc1..ed6bcb2a 100644
--- a/src/include/cctk_Schedule.h
+++ b/src/include/cctk_Schedule.h
@@ -86,6 +86,7 @@ int CCTK_ScheduleFunction(void *function,
int n_before,
int n_after,
int n_while,
+ int n_if,
...);
int CCTK_ScheduleGroup(const char *name,
@@ -99,6 +100,7 @@ int CCTK_ScheduleGroup(const char *name,
int n_before,
int n_after,
int n_while,
+ int n_if,
...);
int CCTK_ScheduleGroupStorage(const char *group);
diff --git a/src/include/cctki_Schedule.h b/src/include/cctki_Schedule.h
index 2b77b826..9361053d 100644
--- a/src/include/cctki_Schedule.h
+++ b/src/include/cctki_Schedule.h
@@ -14,7 +14,11 @@
/* Types needed by other routines. */
-typedef enum {sched_mod_none, sched_before, sched_after, sched_while} t_sched_modifier_type;
+typedef enum {
+ sched_mod_none,
+ sched_before, sched_after,
+ sched_while, sched_if
+} t_sched_modifier_type;
typedef struct T_SCHED_MODIFIER
{
@@ -58,7 +62,8 @@ int CCTKi_DoScheduleSortAllGroups(void);
int CCTKi_DoScheduleTraverse(const char *group_name,
int (*item_entry)(void *, void *),
int (*item_exit)(void *, void *),
- int (*while_check)(int, char **, void *, void *, int),
+ int (*while_check)(int, char **, void *, void *, int),
+ int (*if_check)(int, char **, void *, void *),
int (*function_process)(void *, void *, void *),
void *data);
diff --git a/src/include/cctki_ScheduleBindings.h b/src/include/cctki_ScheduleBindings.h
index c318effd..a87fb301 100644
--- a/src/include/cctki_ScheduleBindings.h
+++ b/src/include/cctki_ScheduleBindings.h
@@ -33,6 +33,7 @@ int CCTKi_ScheduleFunction(void *function,
int n_before,
int n_after,
int n_while,
+ int n_if,
const int *timelevels,
...);
@@ -50,6 +51,7 @@ int CCTKi_ScheduleGroup(const char *realname,
int n_before,
int n_after,
int n_while,
+ int n_if,
const int *timelevels,
...
);
diff --git a/src/main/ScheduleInterface.c b/src/main/ScheduleInterface.c
index 46650121..b9ea8402 100644
--- a/src/main/ScheduleInterface.c
+++ b/src/main/ScheduleInterface.c
@@ -129,6 +129,7 @@ static int ParseOption(t_attribute *attribute,
static t_sched_modifier *CreateModifiers(int n_before,
int n_after,
int n_while,
+ int n_if,
va_list *ap);
int ValidateModifiers(t_sched_modifier *modifier);
@@ -149,6 +150,11 @@ static int CCTKi_SchedulePrintWhile(int n_whiles,
t_attribute *attribute,
t_sched_data *data,
int first);
+static int CCTKi_SchedulePrintIf(int n_if,
+ char **ifs,
+ t_attribute *attribute,
+ t_sched_data *data,
+ int first);
static int CCTKi_SchedulePrintFunction(void *function, t_attribute *attribute, t_sched_data *data);
static int CCTKi_ScheduleCallEntry(t_attribute *attribute, t_sched_data *data);
@@ -158,6 +164,10 @@ static int CCTKi_ScheduleCallWhile(int n_whiles,
t_attribute *attribute,
t_sched_data *data,
int first);
+static int CCTKi_ScheduleCallIf(int n_ifs,
+ char **ifs,
+ t_attribute *attribute,
+ t_sched_data *data);
static int CCTKi_ScheduleCallFunction(void *function,
t_attribute *attribute,
t_sched_data *data);
@@ -369,6 +379,11 @@ int CCTK_CallFunction(void *function,
@vtype int
@vio in
@endvar
+ @var n_if
+ @vdesc Number of vars to schedule if
+ @vtype int
+ @vio in
+ @endvar
@var timelevels
@vdesc The number of timelevels of the storage groups to enable.
@vtype const int *
@@ -400,6 +415,7 @@ int CCTKi_ScheduleFunction(void *function,
int n_before,
int n_after,
int n_while,
+ int n_if,
const int *timelevels,
...
)
@@ -414,13 +430,14 @@ int CCTKi_ScheduleFunction(void *function,
attribute = CreateAttribute(where,name,description, language, thorn, implementation,
n_mem_groups, n_comm_groups, n_trigger_groups,
n_sync_groups, n_options, timelevels, &ap);
- modifier = CreateModifiers(n_before, n_after, n_while, &ap);
+ modifier = CreateModifiers(n_before, n_after, n_while, n_if, &ap);
va_end(ap);
ValidateModifiers(modifier);
- if(attribute && (modifier || (n_before == 0 && n_after == 0 && n_while == 0)))
+ if(attribute && (modifier || (n_before == 0 && n_after == 0 &&
+ n_while == 0 && n_if == 0)))
{
attribute->FunctionData.type = TranslateFunctionType(where);
@@ -525,6 +542,11 @@ int CCTKi_ScheduleFunction(void *function,
@vtype int
@vio in
@endvar
+ @var n_if
+ @vdesc Number of vars to schedule if
+ @vtype int
+ @vio in
+ @endvar
@var timelevels
@vdesc The number of timelevels of the storage groups to enable.
@vtype const int *
@@ -554,6 +576,7 @@ int CCTKi_ScheduleGroup(const char *realname,
int n_before,
int n_after,
int n_while,
+ int n_if,
const int *timelevels,
...
)
@@ -568,13 +591,14 @@ int CCTKi_ScheduleGroup(const char *realname,
attribute = CreateAttribute(where,name,description, NULL, thorn, implementation,
n_mem_groups, n_comm_groups, n_trigger_groups,
n_sync_groups, n_options, timelevels, &ap);
- modifier = CreateModifiers(n_before, n_after, n_while, &ap);
+ modifier = CreateModifiers(n_before, n_after, n_while, n_if, &ap);
va_end(ap);
ValidateModifiers(modifier);
- if(attribute && (modifier || (n_before == 0 && n_after == 0 && n_while == 0)))
+ if(attribute && (modifier || (n_before == 0 && n_after == 0 &&
+ n_while == 0 && n_if == 0)))
{
retcode = CCTKi_DoScheduleGroup(where, name, realname, modifier, (void *)attribute);
@@ -1237,6 +1261,7 @@ static int ScheduleTraverse(const char *where,
(int (*)(void *, void *)) CCTKi_ScheduleCallEntry,
(int (*)(void *, void *)) CCTKi_ScheduleCallExit,
(int (*)(int, char **, void *, void *, int)) CCTKi_ScheduleCallWhile,
+ (int (*)(int, char **, void *, void *)) CCTKi_ScheduleCallIf,
(int (*)(void *, void *, void *)) calling_function,
(void *)&data);
@@ -1473,6 +1498,11 @@ static t_attribute *CreateAttribute(const char *where,
@vtype int
@vio in
@endvar
+ @var n_if
+ @vdesc Number of vars to schedule if
+ @vtype int
+ @vio in
+ @endvar
@var ap
@vdesc options
@vtype va_list of multiple const char *
@@ -1489,6 +1519,7 @@ static t_attribute *CreateAttribute(const char *where,
static t_sched_modifier *CreateModifiers(int n_before,
int n_after,
int n_while,
+ int n_if,
va_list *ap)
{
t_sched_modifier *modifier;
@@ -1496,6 +1527,7 @@ static t_sched_modifier *CreateModifiers(int n_before,
modifier = CreateTypedModifier(NULL, "before", n_before, ap);
modifier = CreateTypedModifier(modifier, "after", n_after, ap);
modifier = CreateTypedModifier(modifier, "while", n_while, ap);
+ modifier = CreateTypedModifier(modifier, "if", n_if, ap);
return modifier;
}
@@ -1506,7 +1538,7 @@ static t_sched_modifier *CreateModifiers(int n_before,
@author Gabrielle Allen
@desc
Validates a schedule modifier list. At the moment just check that
- the while modifier uses a CCTK_INT grid variable.
+ the while and if modifiers use a CCTK_INT grid variable.
@enddesc
@calls
@@ -1541,6 +1573,18 @@ int ValidateModifiers(t_sched_modifier *modifier)
retval = -1;
}
}
+ else if (modifier->type == sched_if)
+ {
+ vindex = CCTK_VarIndex(modifier->argument);
+ type = CCTK_VarTypeI(vindex);
+ if (type != CCTK_VARIABLE_INT)
+ {
+ CCTK_VWarn(0,__LINE__,__FILE__,"Cactus",
+ "If qualifier %s is not a CCTK_INT grid variable",
+ modifier->argument);
+ retval = -1;
+ }
+ }
}
return retval;
}
@@ -1779,7 +1823,7 @@ static int ParseOption(t_attribute *attribute,
@vtype const char *
@vio in
@vcomment
- before, after, while
+ before, after, while, if
@endvar
@var n_items
@vdesc Number of items on list
@@ -1910,10 +1954,11 @@ static int SchedulePrint(const char *where)
if(where)
{
retcode = CCTKi_DoScheduleTraverse(where,
- (int (*)(void *, void *)) CCTKi_SchedulePrintEntry,
- (int (*)(void *, void *)) CCTKi_SchedulePrintExit,
- (int (*)(int, char **, void *, void *, int))CCTKi_SchedulePrintWhile,
- (int (*)(void *, void *, void *)) CCTKi_SchedulePrintFunction,
+ (int (*)(void *, void *)) CCTKi_SchedulePrintEntry,
+ (int (*)(void *, void *)) CCTKi_SchedulePrintExit,
+ (int (*)(int, char **, void *, void *, int))CCTKi_SchedulePrintWhile,
+ (int (*)(int, char **, void *, void *, int))CCTKi_SchedulePrintIf,
+ (int (*)(void *, void *, void *)) CCTKi_SchedulePrintFunction,
(void *)&data);
}
else
@@ -1966,7 +2011,7 @@ static int SchedulePrintTimes(const char *where, t_sched_data *data)
memset (data->total_time->vals, 0,
data->total_time->n_vals * sizeof (data->total_time->vals[0]));
- retcode = CCTKi_DoScheduleTraverse(where, NULL, NULL, NULL,
+ retcode = CCTKi_DoScheduleTraverse(where, NULL, NULL, NULL, NULL,
(int (*)(void *, void *, void *)) CCTKi_SchedulePrintTimesFunction,
(void *)data);
@@ -2157,6 +2202,84 @@ static int CCTKi_SchedulePrintWhile(int n_whiles,
}
/*@@
+ @routine CCTKi_SchedulePrintIf
+ @date Dec 27, 2005
+ @author Erik Schnetter
+ @desc
+ Routine called for if of a group when traversing for printing.
+ @enddesc
+ @calls
+
+ @var n_ifs
+ @vdesc number of if statements
+ @vtype int
+ @vio in
+ @endvar
+ @var ifs
+ @vdesc if statements
+ @vtype char **
+ @vio in
+ @endvar
+ @var attribute
+ @vdesc schedule item attributes
+ @vtype t_attribute *
+ @vio in
+ @endvar
+ @var data
+ @vdesc data associated with schedule item
+ @vtype t_sched_data
+ @vio in
+ @endvar
+ @var first
+ @vdesc flag - is this the first time we are checking if on this schedule item
+ @vtype int
+ @vio in
+ @endvar
+
+ @returntype int
+ @returndesc
+ 0 - schedule item is inactive
+ 1 - schedule item is active
+ @endreturndesc
+@@*/
+static int CCTKi_SchedulePrintIf(int n_ifs,
+ char **ifs,
+ t_attribute *attribute,
+ t_sched_data *data,
+ int first)
+{
+ int i;
+
+ /* prevent compiler warnings about unused parameters */
+ attribute = attribute;
+ data = data;
+
+ if(first)
+ {
+ printf("%*s", indent_level + 2 + 7, "if (");
+
+ for(i = 0; i < n_ifs; i++)
+ {
+ if(i > 0)
+ {
+ printf(" && ");
+ }
+
+ printf(ifs[i]);
+ }
+ printf(")\n");
+ indent_level += 2;
+ }
+ else
+ {
+ indent_level -= 2;
+ printf("%*s\n", indent_level + 9, "end if");
+ }
+
+ return first;
+}
+
+/*@@
@routine CCTKi_SchedulePrintFunction
@date Sun Sep 19 13:36:25 1999
@author Tom Goodale
@@ -2466,6 +2589,64 @@ static int CCTKi_ScheduleCallWhile(int n_whiles,
}
/*@@
+ @routine CCTKi_ScheduleCallIf
+ @date Dec 2007, 2005
+ @author Erik Schnetter
+ @desc
+ Routine called to check variables to see if a group or function should be executed.
+ @enddesc
+ @calls
+
+ @var n_ifs
+ @vdesc number of if statements
+ @vtype int
+ @vio in
+ @endvar
+ @var ifs
+ @vdesc if statements
+ @vtype char **
+ @vio in
+ @endvar
+ @var attribute
+ @vdesc schedule item attributes
+ @vtype t_attribute *
+ @vio in
+ @endvar
+ @var data
+ @vdesc data associated with schedule item
+ @vtype t_sched_data
+ @vio in
+ @endvar
+
+ @returntype int
+ @returndesc
+ 0 - schedule item is inactive
+ 1 - schedule item is active
+ @endreturndesc
+@@*/
+static int CCTKi_ScheduleCallIf(int n_ifs,
+ char **ifs,
+ t_attribute *attribute,
+ t_sched_data *data)
+{
+ int i;
+ int retcode;
+
+ /* prevent compiler warnings about unused parameters */
+ attribute = attribute;
+
+ retcode = 1;
+
+ /* FIXME - should do a lot of validation either here or on registration */
+ for(i = 0; i < n_ifs; i++)
+ {
+ retcode = retcode && *((CCTK_INT *)CCTK_VarDataPtr(data->GH, 0, ifs[i]));
+ }
+
+ return retcode;
+}
+
+/*@@
@routine CCTKi_ScheduleCallFunction
@date Sun Sep 19 13:29:14 1999
@author Tom Goodale
diff --git a/src/schedule/Schedule.h b/src/schedule/Schedule.h
index 5074e87a..bea93775 100644
--- a/src/schedule/Schedule.h
+++ b/src/schedule/Schedule.h
@@ -55,6 +55,8 @@ typedef struct
int n_whiles;
char **whiles;
+ int n_ifs;
+ char **ifs;
void *attributes;
diff --git a/src/schedule/ScheduleCreater.c b/src/schedule/ScheduleCreater.c
index 7aef2a5a..ace2c9a7 100644
--- a/src/schedule/ScheduleCreater.c
+++ b/src/schedule/ScheduleCreater.c
@@ -48,6 +48,7 @@ static int ScheduleItemNumber(t_sched_group *group,
static int ScheduleSetupWhiles(t_sched_item *item);
+static int ScheduleSetupIfs(t_sched_item *item);
/********************************************************************
********************* Other Routine Prototypes *********************
@@ -533,8 +534,11 @@ static t_sched_item *ScheduleCreateItem(const char *name, t_sched_modifier *modi
this->n_whiles = 0;
this->whiles = NULL;
+ this->n_ifs = 0;
+ this->ifs = NULL;
ScheduleSetupWhiles(this);
+ ScheduleSetupIfs(this);
this->attributes = attributes;
@@ -676,6 +680,10 @@ static t_sched_modifier_type ScheduleTranslateModifierType(const char *modifier)
{
retval = sched_while;
}
+ else if(!strcmp(modifier, "if"))
+ {
+ retval = sched_if;
+ }
#ifdef DEBUG_SCHEDULAR
printf("Translated modifier type %s to %d\n", modifier, retval);
@@ -747,7 +755,7 @@ static int ScheduleSortGroup(t_sched_group *group)
#endif
for(modifier = group->scheditems[item].modifiers; modifier; modifier = modifier->next)
{
- if(modifier->type == sched_while)
+ if(modifier->type == sched_while || modifier->type == sched_if)
{
continue;
}
@@ -969,6 +977,70 @@ static int ScheduleSetupWhiles(t_sched_item *item)
return retval;
}
+ /*@@
+ @routine ScheduleSetupIfs
+ @date Dec 27, 2005
+ @author Erik Schnetter
+ @desc
+ Make an array of all the ifs in the modifier list for a schedule item.
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+ @var item
+ @vdesc The schedule item to work on
+ @vtype t_sched_item *
+ @vio inout
+ @vcomment
+
+ @endvar
+ @returntype int
+ @returndesc
+ Number of whiles
+ @endreturndesc
+@@*/
+static int ScheduleSetupIfs(t_sched_item *item)
+{
+ int retval;
+ t_sched_modifier *modifier;
+ char **temp;
+
+ retval = 0;
+
+ for(modifier = item->modifiers; modifier; modifier = modifier->next)
+ {
+ if(modifier->type == sched_if)
+ {
+ item->n_ifs++;
+ temp = (char **)realloc(item->ifs, item->n_ifs*sizeof(char *));
+
+ if(temp)
+ {
+ item->ifs = temp;
+
+ temp[item->n_ifs-1] = (char *)malloc((strlen(modifier->argument)+1)*sizeof(char));
+ if(temp[item->n_ifs-1])
+ {
+ strcpy(temp[item->n_ifs-1], modifier->argument);
+ }
+ else
+ {
+ item->n_ifs--;
+ retval--;
+ }
+ }
+ else
+ {
+ retval--;
+ }
+ }
+ }
+
+ return retval;
+}
+
/********************************************************************
********************************************************************
********************************************************************/
diff --git a/src/schedule/ScheduleTraverse.c b/src/schedule/ScheduleTraverse.c
index 30908371..1baa0ad3 100644
--- a/src/schedule/ScheduleTraverse.c
+++ b/src/schedule/ScheduleTraverse.c
@@ -34,9 +34,12 @@ static int ScheduleTraverseGroup(cHandledData *schedule_groups,
void *attributes,
int n_whiles,
char **whiles,
+ int n_ifs,
+ char **ifs,
int (*item_entry)(void *, void *),
int (*item_exit)(void *, void *),
- int (*while_check)(int, char **, void *, void *, int),
+ int (*while_check)(int, char **, void *, void *, int),
+ int (*if_check)(int, char **, void *, void *),
int (*function_process)(void *, void *, void *),
void *data);
@@ -44,9 +47,12 @@ static int ScheduleTraverseFunction(void *function,
void *attributes,
int n_whiles,
char **whiles,
+ int n_ifs,
+ char **ifs,
int (*item_entry)(void *, void *),
int (*item_exit)(void *, void *),
- int (*while_check)(int, char **, void *, void *, int),
+ int (*while_check)(int, char **, void *, void *, int),
+ int (*if_check)(int, char **, void *, void *),
int (*function_process)(void *, void *, void *),
void *data);
@@ -102,6 +108,13 @@ static int ScheduleTraverseFunction(void *function,
@vcomment
@endvar
+ @var if_check
+ @vdesc function to be called to check an if statement
+ @vtype int (*)(int, char **, void *, void *, int)
+ @vio in
+ @vcomment
+
+ @endvar
@var function_process
@vdesc function to be called on any function
@vtype int (*)(void *, void *, void *)
@@ -126,7 +139,8 @@ static int ScheduleTraverseFunction(void *function,
int CCTKi_DoScheduleTraverse(const char *group_name,
int (*item_entry)(void *, void *),
int (*item_exit)(void *, void *),
- int (*while_check)(int, char **, void *, void *, int),
+ int (*while_check)(int, char **, void *, void *, int),
+ int (*if_check)(int, char **, void *, void *),
int (*function_process)(void *, void *, void *),
void *data)
{
@@ -146,9 +160,12 @@ int CCTKi_DoScheduleTraverse(const char *group_name,
NULL,
0,
NULL,
+ 0,
+ NULL,
item_entry,
item_exit,
while_check,
+ if_check,
function_process,
data);
}
@@ -211,6 +228,20 @@ int CCTKi_DoScheduleTraverse(const char *group_name,
@vcomment
@endvar
+ @var n_ifs
+ @vdesc number of ifs
+ @vtype int
+ @vio in
+ @vcomment
+
+ @endvar
+ @var ifs
+ @vdesc array of if strings
+ @vtype char **
+ @vio in
+ @vcomment
+
+ @endvar
@var item_entry
@vdesc function to be called on entry to an item
@vtype int (*)(void *, void *)
@@ -232,6 +263,13 @@ int CCTKi_DoScheduleTraverse(const char *group_name,
@vcomment
@endvar
+ @var if_check
+ @vdesc function to be called to check a if statement
+ @vtype int (*)(int, char **, void *, void *, int)
+ @vio in
+ @vcomment
+
+ @endvar
@var function_process
@vdesc function to be called on any function
@vtype int (*)(void *, void *, void *)
@@ -257,9 +295,12 @@ static int ScheduleTraverseGroup(cHandledData *schedule_groups,
void *attributes,
int n_whiles,
char **whiles,
+ int n_ifs,
+ char **ifs,
int (*item_entry)(void *, void *),
int (*item_exit)(void *, void *),
- int (*while_check)(int, char **, void *, void *, int),
+ int (*while_check)(int, char **, void *, void *, int),
+ int (*if_check)(int, char **, void *, void *),
int (*function_process)(void *, void *, void *),
void *data)
{
@@ -268,17 +309,35 @@ static int ScheduleTraverseGroup(cHandledData *schedule_groups,
int called_item_entry;
t_sched_group *newgroup;
- /* If there is a while-list associated with this item, check if the group should be
- * exectuted at all.
+ doit = 1;
+
+ /* If there is an if-list associated with this item, check if the
+ * group should be exectuted at all.
*/
- if(n_whiles > 0 && while_check)
+ if(n_ifs > 0 && if_check)
{
- doit = while_check(n_whiles, whiles, attributes, data,1);
+ doit = doit && if_check(n_ifs, ifs, attributes, data);
}
- else
+
+ /* If there is a while-list associated with this item, check if the
+ * group should be exectuted at all.
+ *
+ * If there are both an if-list and a while-list, then both are
+ * checked when the group is entered, but only the while-list is
+ * checked to determine whether the loop should continue. This
+ * means that the if-statement is outside the while-statement, as in
+ *
+ * IF (...)
+ * WHILE (...)
+ * schedule stuff
+ * END WHILE
+ * END IF
+ */
+
+ if(n_whiles > 0 && while_check)
{
- doit = 1;
+ doit = doit && while_check(n_whiles, whiles, attributes, data,1);
}
/* Call a item entry function if it is defined. */
@@ -297,7 +356,7 @@ static int ScheduleTraverseGroup(cHandledData *schedule_groups,
}
/* Now traverse the group. */
- while(doit )
+ while(doit)
{
/* Traverse in the sorted order - assumes group has been sorted ! */
@@ -310,9 +369,12 @@ static int ScheduleTraverseGroup(cHandledData *schedule_groups,
group->scheditems[group->order[item]].attributes,
group->scheditems[group->order[item]].n_whiles,
group->scheditems[group->order[item]].whiles,
+ group->scheditems[group->order[item]].n_ifs,
+ group->scheditems[group->order[item]].ifs,
item_entry,
- item_exit,
+ item_exit,
while_check,
+ if_check,
function_process,
data);
break;
@@ -324,9 +386,12 @@ static int ScheduleTraverseGroup(cHandledData *schedule_groups,
group->scheditems[group->order[item]].attributes,
group->scheditems[group->order[item]].n_whiles,
group->scheditems[group->order[item]].whiles,
+ group->scheditems[group->order[item]].n_ifs,
+ group->scheditems[group->order[item]].ifs,
item_entry,
item_exit,
while_check,
+ if_check,
function_process,
data);
break;
@@ -398,6 +463,20 @@ static int ScheduleTraverseGroup(cHandledData *schedule_groups,
@vcomment
@endvar
+ @var n_ifs
+ @vdesc number of ifs
+ @vtype int
+ @vio in
+ @vcomment
+
+ @endvar
+ @var ifs
+ @vdesc array of if strings
+ @vtype char **
+ @vio in
+ @vcomment
+
+ @endvar
@var item_entry
@vdesc function to be called on entry to an item
@vtype int (*)(void *, void *)
@@ -419,6 +498,13 @@ static int ScheduleTraverseGroup(cHandledData *schedule_groups,
@vcomment
@endvar
+ @var if_check
+ @vdesc function to be called to check a if statement
+ @vtype int (*)(int, char **, void *, void *, int)
+ @vio in
+ @vcomment
+
+ @endvar
@var function_process
@vdesc function to be called on any function
@vtype int (*)(void *, void *, void *)
@@ -443,26 +529,36 @@ static int ScheduleTraverseFunction(void *function,
void *attributes,
int n_whiles,
char **whiles,
+ int n_ifs,
+ char **ifs,
int (*item_entry)(void *, void *),
int (*item_exit)(void *, void *),
- int (*while_check)(int, char **, void *, void *, int),
+ int (*while_check)(int, char **, void *, void *, int),
+ int (*if_check)(int, char **, void *, void *),
int (*function_process)(void *, void *, void *),
void *data)
{
int doit;
int called_item_entry;
- /* If there is a while-list associated with this function, check if the function should be
- * executed at all.
+ doit = 1;
+
+ /* If there is an if-list associated with this function, check if
+ * the function should be executed at all.
*/
- if(n_whiles > 0 && while_check)
+ if(n_ifs > 0 && if_check)
{
- doit = while_check(n_whiles, whiles, attributes, data,1);
+ doit = doit && if_check(n_ifs, ifs, attributes, data);
}
- else
+
+ /* If there is a while-list associated with this function, check if
+ * the function should be executed at all.
+ */
+
+ if(n_whiles > 0 && while_check)
{
- doit = 1;
+ doit = doit && while_check(n_whiles, whiles, attributes, data,1);
}
/* Call a item entry function if it is defined. */
@@ -481,7 +577,7 @@ static int ScheduleTraverseFunction(void *function,
}
/* Now traverse the . */
- while(doit )
+ while(doit)
{
/* Now actually do something with the function. */
@@ -493,7 +589,6 @@ static int ScheduleTraverseFunction(void *function,
doit = while_check(n_whiles, whiles, attributes, data,0) ;
}
else
-
{
doit = 0;
}