From d343abf923e35b78006a639966f0f26ae70c0c63 Mon Sep 17 00:00:00 2001 From: goodale Date: Wed, 15 Sep 1999 21:24:51 +0000 Subject: Lots of tidying and reorganisation. Tom git-svn-id: http://svn.cactuscode.org/flesh/trunk@929 17b73243-c579-4c4c-a9d2-2d5706c11dac --- src/schedule/Makefile | 2 +- src/schedule/Schedule.h | 27 ++-- src/schedule/ScheduleCreater.c | 360 +++++++++++++++++++++++------------------ src/schedule/ScheduleSorter.c | 163 ++++++++++++++----- 4 files changed, 348 insertions(+), 204 deletions(-) (limited to 'src/schedule') diff --git a/src/schedule/Makefile b/src/schedule/Makefile index 796cd3cb..8bc56212 100644 --- a/src/schedule/Makefile +++ b/src/schedule/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -g -DDEBUG_SCHEDULAR -DTEST_SCHEDULECREATOR +CFLAGS = -g -Wall -DDEBUG_SCHEDULAR -DTEST_SCHEDULECREATOR SRCS = ScheduleCreater.c ScheduleSorter.c ../util/StoreHandledData.c INCDIRS = ../include diff --git a/src/schedule/Schedule.h b/src/schedule/Schedule.h index 342fb111..29a2704d 100644 --- a/src/schedule/Schedule.h +++ b/src/schedule/Schedule.h @@ -8,22 +8,31 @@ @version $Header$ @@*/ +#include "cctki_schedule.h" + #ifndef _SCHEDULE_H_ #define _SCHEDULE_H_ -typedef enum {sched_item_none, sched_group, sched_function} t_sched_item_type; +#ifdef __cplusplus +extern "C" { +#endif -typedef enum {sched_mod_none, sched_before, sched_after, sched_while} t_sched_modifier_type; -typedef struct T_SCHED_MODIFIER -{ - struct T_SCHED_MODIFIER *next; +int *CCTKi_ScheduleCreateIVec(int size); +void CCTKi_ScheduleDestroyIVec(int size, int *vector); +signed char **CCTKi_ScheduleCreateArray(int size); +void CCTKi_ScheduleDestroyArray(int size, signed char **array); - t_sched_modifier_type type; - - char *argument; +int CCTKi_ScheduleAddRow(int size, + signed char **array, + int *order, + int item, + int *thisorders); -} t_sched_modifier; +int CCTKi_ScheduleSort(int size, signed char **array, int *order); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/schedule/ScheduleCreater.c b/src/schedule/ScheduleCreater.c index 59f03666..5e80c6af 100644 --- a/src/schedule/ScheduleCreater.c +++ b/src/schedule/ScheduleCreater.c @@ -14,6 +14,10 @@ #include "Schedule.h" #include "StoreHandledData.h" +/* Internal type data */ + +typedef enum {sched_item_none, sched_group, sched_function} t_sched_item_type; + typedef struct { char *name; @@ -42,34 +46,43 @@ typedef struct } t_sched_group; +/* Internal routine prototypes */ + +static int ScheduleCreateGroup(const char *name); + +static t_sched_item *ScheduleCreateItem(const char *name, + t_sched_modifier *modifiers, + void *attributes); + +static int ScheduleAddItem(int ghandle, t_sched_item *item); + +static int ScheduleSortGroup(t_sched_group *group); + +static t_sched_modifier_type ScheduleTranslateModifierType(const char *modifier); +static int ScheduleItemNumber(t_sched_group *group, + const char *name); -t_sched_item *CCTKi_ScheduleCreateItem(const char *name, t_sched_modifier *modifiers, void *attributes); -t_sched_modifier_type CCTKi_ScheduleTranslateModifierType(const char *modifier); -int CCTKi_ScheduleItemNumber(t_sched_group *group, const char *name); -int *ScheduleCreateIVec(int size); -void ScheduleDestroyIVec(int size, int *vector); -signed char **ScheduleCreateArray(int size); -void ScheduleDestroyArray(int size, signed char **array); +static int ScheduleSetupWhiles(t_sched_item *item); -int CCTKi_ScheduleAddRow(int size, - signed char **array, - int *order, - int item, - int *thisorders); +/* Local variables. */ static char *rcsid="$Header$"; static int n_schedule_groups = 0; static cHandledData *schedule_groups = NULL; +/******************************************************************** + ******************** External Routines ************************ + ********************************************************************/ + /*@@ - @routine CCTKi_ScheduleCreateGroup - @date Wed Sep 8 11:15:32 1999 + @routine CCTKi_ScheduleAddModifer + @date Thu Sep 9 21:45:25 1999 @author Tom Goodale @desc - Creates a schedule group. + Adds a schedule modifier to a modifier list. @enddesc @calls @calledby @@ -78,56 +91,37 @@ static cHandledData *schedule_groups = NULL; @endhistory @@*/ -int CCTKi_ScheduleCreateGroup(const char *name) +t_sched_modifier *CCTKi_ScheduleAddModifer(t_sched_modifier *orig, + const char *modifier, + const char *argument) { - int retcode; - int handle; - - t_sched_group *this_group; + t_sched_modifier *this; - handle = Util_GetHandle(schedule_groups, name, (void **)&this_group); + this = (t_sched_modifier *)malloc(sizeof(t_sched_modifier)); - if(handle > -1) - { - /* Group already exists */ - retcode = -1; - } - else + if(this) { - this_group = (t_sched_group *)malloc(sizeof(t_sched_group)); - - if(this_group) + this->argument = (char *)malloc((strlen(argument)+1)*sizeof(char)); + if(this->argument) { - this_group->name = (char *)malloc((strlen(name)+1)*sizeof(char)); + strcpy(this->argument, argument); - if(this_group->name) - { - strcpy(this_group->name, name); + this->type = ScheduleTranslateModifierType(modifier); - this_group->order = NULL; - this_group->n_scheditems = 0; - this_group->scheditems = NULL; - retcode = Util_NewHandle(&schedule_groups, name, (void *)this_group); - n_schedule_groups++; - } - else - { - free(this_group); - - retcode = -2; - } + this->next = orig; } else { - retcode = -2; + free(this); + this = NULL; } } - return retcode; + return this; } /*@@ - @routine CCTK_ScheduleFunction + @routine CCTKi_ScheduleFunction @date Thu Sep 9 21:42:58 1999 @author Tom Goodale @desc @@ -140,7 +134,11 @@ int CCTKi_ScheduleCreateGroup(const char *name) @endhistory @@*/ -int CCTK_ScheduleFunction(const char *gname, const char *fname, void *func, t_sched_modifier *modifiers, void *attributes) +int CCTKi_ScheduleFunction(const char *gname, + const char *fname, + void *func, + t_sched_modifier *modifiers, + void *attributes) { int retcode; int handle; @@ -151,7 +149,7 @@ int CCTK_ScheduleFunction(const char *gname, const char *fname, void *func, t_sc if(handle < 0) { - handle = CCTKi_ScheduleCreateGroup(gname); + handle = ScheduleCreateGroup(gname); } if(handle < 0) @@ -160,13 +158,13 @@ int CCTK_ScheduleFunction(const char *gname, const char *fname, void *func, t_sc } else { - newitem = CCTKi_ScheduleCreateItem(fname, modifiers, attributes); + newitem = ScheduleCreateItem(fname, modifiers, attributes); if(newitem) { newitem->type = sched_function; newitem->function = func; - retcode = CCTKi_ScheduleAddItem(handle, newitem); + retcode = ScheduleAddItem(handle, newitem); } else { @@ -178,7 +176,7 @@ int CCTK_ScheduleFunction(const char *gname, const char *fname, void *func, t_sc } /*@@ - @routine CCTK_ScheduleGroup + @routine CCTKi_ScheduleGroup @date Thu Sep 9 21:43:44 1999 @author Tom Goodale @desc @@ -191,7 +189,10 @@ int CCTK_ScheduleFunction(const char *gname, const char *fname, void *func, t_sc @endhistory @@*/ -int CCTK_ScheduleGroup(const char *gname, const char *thisname, t_sched_modifier *modifiers, void *attributes) +int CCTKi_ScheduleGroup(const char *gname, + const char *thisname, + t_sched_modifier *modifiers, + void *attributes) { int retcode; int handle; @@ -202,7 +203,7 @@ int CCTK_ScheduleGroup(const char *gname, const char *thisname, t_sched_modifier if(handle < 0) { - handle = CCTKi_ScheduleCreateGroup(gname); + handle = ScheduleCreateGroup(gname); } if(handle < 0) @@ -211,13 +212,13 @@ int CCTK_ScheduleGroup(const char *gname, const char *thisname, t_sched_modifier } else { - newitem = CCTKi_ScheduleCreateItem(thisname, modifiers, attributes); + newitem = ScheduleCreateItem(thisname, modifiers, attributes); if(newitem) { newitem->type = sched_group; newitem->group = handle; - retcode = CCTKi_ScheduleAddItem(handle, newitem); + retcode = ScheduleAddItem(handle, newitem); } else { @@ -229,7 +230,117 @@ int CCTK_ScheduleGroup(const char *gname, const char *thisname, t_sched_modifier } /*@@ - @routine CCTKi_ScheduleCreateItem + @routine CCTKi_ScheduleSortAllGroups + @date Wed Sep 15 22:37:49 1999 + @author Tom Goodale + @desc + Sorts all the schedule groups. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ +int CCTKi_ScheduleSortAllGroups(void) +{ + int group; + t_sched_group *gdata; + int errcode; + int n_errors; + + n_errors = 0; + + for(group = 0; group < n_schedule_groups; group++) + { + if((gdata = (t_sched_group *)Util_GetHandledData(schedule_groups, group))) + { + errcode = ScheduleSortGroup(gdata); + + if(errcode) + { + fprintf(stderr, + "Error while dorting group '%s' - %d remaining unsorted routines.\n", + gdata->name, + -errcode); + + n_errors += -errcode; + } + } + } + + return -n_errors; +} + +/******************************************************************** + ********************* Local Routines ************************* + ********************************************************************/ + + /*@@ + @routine ScheduleCreateGroup + @date Wed Sep 8 11:15:32 1999 + @author Tom Goodale + @desc + Creates a schedule group. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ +static int ScheduleCreateGroup(const char *name) +{ + int retcode; + int handle; + + t_sched_group *this_group; + + handle = Util_GetHandle(schedule_groups, name, (void **)&this_group); + + if(handle > -1) + { + /* Group already exists */ + retcode = -1; + } + else + { + this_group = (t_sched_group *)malloc(sizeof(t_sched_group)); + + if(this_group) + { + this_group->name = (char *)malloc((strlen(name)+1)*sizeof(char)); + + if(this_group->name) + { + strcpy(this_group->name, name); + + this_group->order = NULL; + this_group->n_scheditems = 0; + this_group->scheditems = NULL; + retcode = Util_NewHandle(&schedule_groups, name, (void *)this_group); + n_schedule_groups++; + } + else + { + free(this_group); + + retcode = -2; + } + } + else + { + retcode = -2; + } + } + + return retcode; +} + + /*@@ + @routine ScheduleCreateItem @date Thu Sep 9 21:44:17 1999 @author Tom Goodale @desc @@ -242,7 +353,7 @@ int CCTK_ScheduleGroup(const char *gname, const char *thisname, t_sched_modifier @endhistory @@*/ -t_sched_item *CCTKi_ScheduleCreateItem(const char *name, t_sched_modifier *modifiers, void *attributes) +static t_sched_item *ScheduleCreateItem(const char *name, t_sched_modifier *modifiers, void *attributes) { t_sched_item *this; @@ -264,6 +375,8 @@ t_sched_item *CCTKi_ScheduleCreateItem(const char *name, t_sched_modifier *modif this->n_whiles = 0; this->whiles = NULL; + ScheduleSetupWhiles(this); + this->attributes = attributes; #ifdef DEBUG_SCHEDULAR @@ -282,7 +395,7 @@ t_sched_item *CCTKi_ScheduleCreateItem(const char *name, t_sched_modifier *modif } /*@@ - @routine CCTKi_ScheduleAddItem + @routine ScheduleAddItem @date Thu Sep 9 21:45:03 1999 @author Tom Goodale @desc @@ -295,7 +408,7 @@ t_sched_item *CCTKi_ScheduleCreateItem(const char *name, t_sched_modifier *modif @endhistory @@*/ -int CCTKi_ScheduleAddItem(int ghandle, t_sched_item *item) +static int ScheduleAddItem(int ghandle, t_sched_item *item) { int retcode; t_sched_group *this_group; @@ -329,50 +442,10 @@ int CCTKi_ScheduleAddItem(int ghandle, t_sched_item *item) return retcode; } - /*@@ - @routine CCTK_ScheduleAddModifer - @date Thu Sep 9 21:45:25 1999 - @author Tom Goodale - @desc - Adds a schedule modifier to a modifier list. - @enddesc - @calls - @calledby - @history - - @endhistory - -@@*/ -t_sched_modifier *CCTK_ScheduleAddModifer(t_sched_modifier *orig, const char *modifier, const char *argument) -{ - t_sched_modifier *this; - - this = (t_sched_modifier *)malloc(sizeof(t_sched_modifier)); - - if(this) - { - this->argument = (char *)malloc((strlen(argument)+1)*sizeof(char)); - if(this->argument) - { - strcpy(this->argument, argument); - - this->type = CCTKi_ScheduleTranslateModifierType(modifier); - - this->next = orig; - } - else - { - free(this); - this = NULL; - } - } - - return this; -} /*@@ - @routine CCTKi_ScheduleTranslateModifierType + @routine ScheduleTranslateModifierType @date Thu Sep 9 21:45:56 1999 @author Tom Goodale @desc @@ -385,7 +458,7 @@ t_sched_modifier *CCTK_ScheduleAddModifer(t_sched_modifier *orig, const char *mo @endhistory @@*/ -t_sched_modifier_type CCTKi_ScheduleTranslateModifierType(const char *modifier) +static t_sched_modifier_type ScheduleTranslateModifierType(const char *modifier) { /* FIXME */ @@ -414,7 +487,7 @@ t_sched_modifier_type CCTKi_ScheduleTranslateModifierType(const char *modifier) } /*@@ - @routine CCTKi_ScheduleSortGroup + @routine ScheduleSortGroup @date Mon Sep 13 11:30:19 1999 @author Tom Goodale @desc @@ -427,7 +500,7 @@ t_sched_modifier_type CCTKi_ScheduleTranslateModifierType(const char *modifier) @endhistory @@*/ -int CCTKi_ScheduleSortGroup(t_sched_group *group) +static int ScheduleSortGroup(t_sched_group *group) { int item; int *order; @@ -440,9 +513,9 @@ int CCTKi_ScheduleSortGroup(t_sched_group *group) int errcode; /* Create the data staructures */ - array = ScheduleCreateArray(group->n_scheditems); - order = ScheduleCreateIVec(group->n_scheditems); - thisorders = ScheduleCreateIVec(group->n_scheditems); + array = CCTKi_ScheduleCreateArray(group->n_scheditems); + order = CCTKi_ScheduleCreateIVec(group->n_scheditems); + thisorders = CCTKi_ScheduleCreateIVec(group->n_scheditems); for(item=0; item < group->n_scheditems; item++) { @@ -455,7 +528,7 @@ int CCTKi_ScheduleSortGroup(t_sched_group *group) { continue; } - number = CCTKi_ScheduleItemNumber(group, modifier->argument); + number = ScheduleItemNumber(group, modifier->argument); #ifdef DEBUG_SCHEDULAR printf("Scheduling against item %d '%s' - mod-type %d\n", number, group->scheditems[number].name, modifier->type); @@ -517,7 +590,7 @@ int CCTKi_ScheduleSortGroup(t_sched_group *group) printf("Sorting array...\n"); #endif - errcode = ScheduleSort(group->n_scheditems, array, order); + errcode = CCTKi_ScheduleSort(group->n_scheditems, array, order); if(errcode) { @@ -545,8 +618,8 @@ int CCTKi_ScheduleSortGroup(t_sched_group *group) #endif /* Free memory */ - ScheduleDestroyIVec(group->n_scheditems,thisorders); - ScheduleDestroyArray(group->n_scheditems, array); + CCTKi_ScheduleDestroyIVec(group->n_scheditems,thisorders); + CCTKi_ScheduleDestroyArray(group->n_scheditems, array); group->order = order; @@ -554,7 +627,7 @@ int CCTKi_ScheduleSortGroup(t_sched_group *group) } /*@@ - @routine CCTKi_ScheduleItemNumber + @routine ScheduleItemNumber @date Mon Sep 13 11:30:49 1999 @author Tom Goodale @desc @@ -567,7 +640,7 @@ int CCTKi_ScheduleSortGroup(t_sched_group *group) @endhistory @@*/ -int CCTKi_ScheduleItemNumber(t_sched_group *group, const char *name) +static int ScheduleItemNumber(t_sched_group *group, const char *name) { int retval; int i; @@ -588,38 +661,9 @@ int CCTKi_ScheduleItemNumber(t_sched_group *group, const char *name) return retval; } -int CCTKi_ScheduleAllGroups(void) -{ - int group; - t_sched_group *gdata; - int errcode; - int n_errors; - - n_errors = 0; - - for(group = 0; group < n_schedule_groups; group++) - { - if(gdata = (t_sched_group *)Util_GetHandledData(schedule_groups, group)) - { - errcode = CCTKi_ScheduleSortGroup(gdata); - - if(errcode) - { - fprintf(stderr, - "Error while dorting group '%s' - %d remaining unsorted routines.\n", - gdata->name, - -errcode); - - n_errors += -errcode; - } - } - } - - return -n_errors; -} /*@@ - @routine CCTKi_ScheduleSetupWhiles + @routine ScheduleSetupWhiles @date Wed Sep 15 20:10:28 1999 @author Tom Goodale @desc @@ -632,7 +676,7 @@ int CCTKi_ScheduleAllGroups(void) @endhistory @@*/ -int CCTKi_ScheduleSetupWhiles(t_sched_item *item) +static int ScheduleSetupWhiles(t_sched_item *item) { int retval; t_sched_modifier *modifier; @@ -672,6 +716,10 @@ int CCTKi_ScheduleSetupWhiles(t_sched_item *item) return retval; } +/******************************************************************** + ******************************************************************** + ********************************************************************/ + #ifdef TEST_SCHEDULECREATOR #define func_x(x) \ @@ -685,21 +733,19 @@ func_x(c) int main(int argc, char *argv[]) { - int handle; t_sched_modifier *modifier; - t_sched_group *this_group; - modifier = CCTK_ScheduleAddModifer(NULL, "before", "c"); - modifier = CCTK_ScheduleAddModifer(modifier, "after", "a"); + modifier = CCTKi_ScheduleAddModifer(NULL, "before", "c"); + modifier = CCTKi_ScheduleAddModifer(modifier, "after", "a"); - CCTK_ScheduleFunction("group_a", "c", func_c, NULL, NULL); - CCTK_ScheduleFunction("group_a", "b", func_b, modifier, NULL); - CCTK_ScheduleFunction("group_a", "a", func_a, NULL, NULL); - CCTK_ScheduleFunction("group_b", "a", func_a, NULL, NULL); - CCTK_ScheduleFunction("group_b", "b", func_a, NULL, NULL); - CCTK_ScheduleGroup("group_a", "group_b", modifier, NULL); + CCTKi_ScheduleFunction("group_a", "c", func_c, NULL, NULL); + CCTKi_ScheduleFunction("group_a", "b", func_b, modifier, NULL); + CCTKi_ScheduleFunction("group_a", "a", func_a, NULL, NULL); + CCTKi_ScheduleFunction("group_b", "a", func_a, NULL, NULL); + CCTKi_ScheduleFunction("group_b", "b", func_a, NULL, NULL); + CCTKi_ScheduleGroup("group_a", "group_b", modifier, NULL); - CCTKi_ScheduleAllGroups(); + CCTKi_ScheduleSortAllGroups(); return 0; } diff --git a/src/schedule/ScheduleSorter.c b/src/schedule/ScheduleSorter.c index 4f77689f..a3332742 100644 --- a/src/schedule/ScheduleSorter.c +++ b/src/schedule/ScheduleSorter.c @@ -10,12 +10,14 @@ #include #include +#include "Schedule.h" + static char *rcsid = "$Header$"; static void ScheduleSwap(int size, signed char **array, int *order, int row, int column); /*@@ - @routine ScheduleSort + @routine CCTKi_ScheduleSort @date Mon Aug 30 11:44:35 1999 @author Tom Goodale @desc @@ -29,7 +31,7 @@ static void ScheduleSwap(int size, signed char **array, int *order, int row, int @@*/ -int ScheduleSort(int size, signed char **array, int *order) +int CCTKi_ScheduleSort(int size, signed char **array, int *order) { int iter; int row, column; @@ -70,33 +72,20 @@ int ScheduleSort(int size, signed char **array, int *order) return retval; } -static void ScheduleSwap(int size, signed char **array, int *order, int row, int column) -{ - signed char *tmp; - signed char tmp_char; - int tmp_int; - int this_row; - - /* Swap the rows */ - tmp = array[row]; - array[row] = array[column]; - array[column] = tmp; - - /* Swap the columns */ - for(this_row = 0; this_row < size; this_row++) - { - tmp_char = array[this_row][column]; - array[this_row][column] = array[this_row][row]; - array[this_row][row]=tmp_char; - } - - /* Swap routine orders */ - tmp_int = order[column]; - order[column]=order[row]; - order[row] = tmp_int; - -} + /*@@ + @routine CCTKi_ScheduleAddRow + @date Wed Sep 15 22:28:09 1999 + @author Tom Goodale + @desc + Adds a row to the scheduling array, and fills in the corresponding column entries. + @enddesc + @calls + @calledby + @history + + @endhistory +@@*/ int CCTKi_ScheduleAddRow(int size, signed char **array, int *order, @@ -107,7 +96,6 @@ int CCTKi_ScheduleAddRow(int size, int row; int column; - int i; retval = 0; @@ -128,7 +116,21 @@ int CCTKi_ScheduleAddRow(int size, return retval; } -signed char **ScheduleCreateArray(int size) + /*@@ + @routine CCTKi_ScheduleCreateArray + @date Wed Sep 15 22:28:50 1999 + @author Tom Goodale + @desc + Creates a scheduling array. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ +signed char **CCTKi_ScheduleCreateArray(int size) { int i, j; signed char **array; @@ -147,7 +149,7 @@ signed char **ScheduleCreateArray(int size) if(i < size) { /* Free already allocated memory */ - for(i-1; i >=0; i--) + for(i--; i >=0; i--) { free(array[i]); } @@ -171,7 +173,21 @@ signed char **ScheduleCreateArray(int size) return array; } -void ScheduleDestroyArray(int size, signed char **array) + /*@@ + @routine CCTKi_ScheduleDestroyArray + @date Wed Sep 15 22:29:10 1999 + @author Tom Goodale + @desc + Destroys a scheduling array. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ +void CCTKi_ScheduleDestroyArray(int size, signed char **array) { int i; @@ -181,7 +197,21 @@ void ScheduleDestroyArray(int size, signed char **array) } } -int *ScheduleCreateIVec(int size) + /*@@ + @routine CCTKi_ScheduleCreateIVec + @date Wed Sep 15 22:29:57 1999 + @author Tom Goodale + @desc + Creates a vector of integers. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ +int *CCTKi_ScheduleCreateIVec(int size) { int i; int *vector; @@ -199,11 +229,70 @@ int *ScheduleCreateIVec(int size) return vector; } -void ScheduleDestroyIVec(int size, int *vector) + /*@@ + @routine CCTKi_ScheduleDestroyIVec + @date Wed Sep 15 22:29:29 1999 + @author Tom Goodale + @desc + Destroys a vector of integers. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ +void CCTKi_ScheduleDestroyIVec(int size, int *vector) { free(vector); } + /*@@ + @routine ScheduleSwap + @date Wed Sep 15 22:26:50 1999 + @author Tom Goodale + @desc + Swaps two rows and columns in the scheduling array. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ +static void ScheduleSwap(int size, signed char **array, int *order, int row, int column) +{ + signed char *tmp; + signed char tmp_char; + int tmp_int; + int this_row; + + /* Swap the rows */ + tmp = array[row]; + array[row] = array[column]; + array[column] = tmp; + + /* Swap the columns */ + for(this_row = 0; this_row < size; this_row++) + { + tmp_char = array[this_row][column]; + array[this_row][column] = array[this_row][row]; + array[this_row][row]=tmp_char; + } + + /* Swap routine orders */ + tmp_int = order[column]; + order[column]=order[row]; + order[row] = tmp_int; + +} + +/******************************************************************** + ******************************************************************** + ********************************************************************/ + #ifdef TEST_SORTER int main(int argc, char *argv[]) { @@ -244,9 +333,9 @@ int main(int argc, char *argv[]) size = 5; } - order = ScheduleCreateIVec(size); + order = CCTKi_ScheduleCreateIVec(size); - array = ScheduleCreateArray(size); + array = CCTKi_ScheduleCreateArray(size); for(i=0; i < size; i++) { @@ -296,7 +385,7 @@ int main(int argc, char *argv[]) printf("Sorting array...\n"); - errcode = ScheduleSort(size, array, order); + errcode = CCTKi_ScheduleSort(size, array, order); if(errcode) { -- cgit v1.2.3