From e7d2623d32fa5481c3b0a874813e52f1502f23d9 Mon Sep 17 00:00:00 2001 From: lanfer Date: Thu, 27 Apr 2000 15:28:47 +0000 Subject: fixing bug in mixed_slicing git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinBase/CoordGauge/trunk@26 edbb7e70-9571-45d5-a481-0a560a9b4751 --- src/Slicing.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/src/Slicing.c b/src/Slicing.c index 2a5639a..ccb7cd7 100644 --- a/src/Slicing.c +++ b/src/Slicing.c @@ -29,7 +29,7 @@ static char *rcsid = "$Id$"; #include "Slicing.h" #include "ErrorCodes.h" -/*#define ESLIC_DEBUG*/ +/*$#define ESLIC_DEBUG$*/ /* Local data holding info on slicings..*/ @@ -223,11 +223,10 @@ void Einstein_ActivateSlicing(cGH *GH) struct Einstein_slicing *slic; CCTK_INT *active_slicing_handle; - int handle, priority,i; + int handle, priority,i,h, ierr; char *err, *split_string; char *item=NULL, *after=NULL; - /* Get our grid scalar pointer: initialize with -1*/ i = CCTK_VarIndex("Einstein::active_slicing_handle"); if (i<0) CCTK_WARN(0,"INTERNAL ERROR: cannot find grid scalar: active_slicing_handle"); @@ -243,9 +242,12 @@ void Einstein_ActivateSlicing(cGH *GH) if (handle<0) { /* If slicing is set to "none", only warn level 2 (could be initial data only) */ - if (CCTK_Equals(slicing,"none")) { + if (CCTK_Equals(slicing,"none")) + { CCTK_WARN(2,"No slicing set. Prob. fatal when you enter evolution loop (itlast>0).\n"); - } else { + } + else + { err = (char*)malloc(256*sizeof(char)); sprintf(err,"%s%s%s%s", "WARNING: cannot get handle for slicing: >>", @@ -283,11 +285,18 @@ void Einstein_ActivateSlicing(cGH *GH) 2) set slicing->param_active, counting from 1 to n according to the position. The higher the number the lower the priority (0=inactive!!) */ - priority = 1; - split_string= mixed_slicing; + + /* we attach an additional space for string splitting */ + split_string= (char*)malloc(strlen(mixed_slicing)*sizeof(char)+2); + sprintf(split_string,"%s ",mixed_slicing); /* Here we take the string appart */ - while (Util_SplitString(&item,&after,split_string," ")==0) { + ierr=Util_SplitString(&item,&after,split_string," "); + /*printf(" item >%s< after: >%s< \n",item,after);*/ + + priority = 1; + while (item) + { slic = Util_GetHandledData(Eslicings,Util_GetHandle(Eslicings,item,NULL)); if (!slic) { @@ -300,9 +309,11 @@ void Einstein_ActivateSlicing(cGH *GH) slic->param_active = priority; #ifdef ESLIC_DEBUG printf("ACTIVATE_SLICING: found %s priority %d \n",item, priority); -#endif +#endif priority++; split_string = after; + ierr=Util_SplitString(&item,&after,split_string," "); + /*printf(" item >%s< after: >%s< %d\n",item,after,ierr);*/ } if (item) free(item); @@ -461,7 +472,7 @@ void Einstein_SetNextSlicing(cGH *GH) { for (h=0;hparam_active,h_yes, h_egal); - + printf(" handle: %d pactive: %d yes: %d egal: %d \n",h,slic->param_active,h_yes, h_egal); #endif if ((slic->param_active>0)) { if (slic->timetoslice!=NULL) { @@ -491,9 +501,9 @@ void Einstein_SetNextSlicing(cGH *GH) { } } - /* First try to set the scalar to the highest priority that cares (h_yes), else - to the highest prio, that doesn;t care (h_egal). If that fails, we are in trouble. - */ + /* First try to set the scalar to the highest priority that + cares (h_yes), else to the highest prio, that doesn;t + care (h_egal). If that fails, we are in trouble. */ if (h_yes!=num_slicings) *active_slicing_handle = h_yes; else -- cgit v1.2.3