diff options
Diffstat (limited to 'src/CoordinateStuff.c')
-rw-r--r-- | src/CoordinateStuff.c | 62 |
1 files changed, 38 insertions, 24 deletions
diff --git a/src/CoordinateStuff.c b/src/CoordinateStuff.c index 6173e0f..9334e2a 100644 --- a/src/CoordinateStuff.c +++ b/src/CoordinateStuff.c @@ -25,7 +25,6 @@ @@*/ - int IndexFloorC(cGH *GH, CCTK_REAL coord_value, int d) { int index_low,idummy; @@ -33,21 +32,27 @@ int IndexFloorC(cGH *GH, CCTK_REAL coord_value, int d) CCTK_REAL cmin,cmax; if (d==0) + { CCTK_CoordRange(GH,&cmin,&cmax, 1, "x", "cart3d"); + } else if (d==1) + { CCTK_CoordRange(GH,&cmin,&cmax, 2, "y", "cart3d"); + } else if (d==2) + { CCTK_CoordRange(GH,&cmin,&cmax, 3, "z", "cart3d"); - else - CCTK_WARN(0,"IndexFloor: dimension is not valid. Fortran:1..3 C:0..2"); - - if ((coord_value<cmin)||(coord_value>cmax)) { - message = (char*)malloc(128*sizeof(char)); - sprintf(message, - "IndexFloor: coordinate value outside grid [%f,%f]: %f \n", - cmin, cmax, coord_value); - CCTK_WARN(2,message); - free(message); + } + else + { + CCTK_WARN(0,"IndexFloor: dimension is not valid. Fortran:1..3 C:0..2"); + } + + if ((coord_value<cmin)||(coord_value>cmax)) + { + CCTK_VWarn(2,__LINE__,__FILE__,CCTK_THORNSTRING, + "IndexFloor: coordinate value outside grid [%f,%f]: %f \n", + cmin, cmax, coord_value); return(-3); } @@ -55,11 +60,13 @@ int IndexFloorC(cGH *GH, CCTK_REAL coord_value, int d) index_low = idummy-GH->cctk_lbnd[d]; if (index_low<0) + { index_low = -1; - + } if (index_low>=GH->cctk_lsh[d]) + { index_low = -1; - + } return(index_low); } @@ -91,22 +98,27 @@ int IndexCeilC(cGH *GH, CCTK_REAL coord_value, int d) CCTK_REAL cmin,cmax; if (d==0) + { CCTK_CoordRange(GH,&cmin,&cmax, -1, "x", "cart3d"); + } else if (d==1) + { CCTK_CoordRange(GH,&cmin,&cmax, -1, "y", "cart3d"); + } else if (d==2) + { CCTK_CoordRange(GH,&cmin,&cmax, -1, "z", "cart3d"); + } else - CCTK_WARN(0,"IndexCeil: dimension is not valid. Fortran:1..3 C:0..2"); - + { + CCTK_WARN(0,"IndexCeilC: dimension is not valid. Fortran:1..3 C:0..2"); + } - if ((coord_value<cmin)||(coord_value>cmax)) { - message = (char*) malloc(256*sizeof(char)); - sprintf(message, - "IndexCeil: coordinate value outside grid [%f,%f]: %f \n", - cmin,cmax, coord_value); - CCTK_WARN(2,message); - free(message); + if ((coord_value<cmin)||(coord_value>cmax)) + { + CCTK_VWarn(2,__LINE__,__FILE__,CCTK_THORNSTRING, + "IndexCeil: coordinate value outside grid [%f,%f]: %f \n", + cmin,cmax, coord_value); return(-3); } @@ -114,11 +126,13 @@ int IndexCeilC(cGH *GH, CCTK_REAL coord_value, int d) index_up = idummy-GH->cctk_lbnd[d]; if (index_up<0) + { index_up = -1; - + } if (index_up>=GH->cctk_lsh[d]) + { index_up = -1; - + } return(index_up); } |