From 8b6b44b9e1f56070073ad852aa41b453f3f65896 Mon Sep 17 00:00:00 2001 From: allen Date: Mon, 18 Dec 2000 10:21:33 +0000 Subject: Checking for non-valid case of coordinate direction = 0, and adding to grdoc and docs Fixes Cactus/401 git-svn-id: http://svn.cactuscode.org/flesh/trunk@1974 17b73243-c579-4c4c-a9d2-2d5706c11dac --- doc/UsersGuide/FunctionReference.tex | 7 +++--- src/main/Coord.c | 47 +++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/doc/UsersGuide/FunctionReference.tex b/doc/UsersGuide/FunctionReference.tex index cf149818..c5f43f5e 100644 --- a/doc/UsersGuide/FunctionReference.tex +++ b/doc/UsersGuide/FunctionReference.tex @@ -100,7 +100,7 @@ available from C, not all are currently available from Fortran. \item[CCTK\_CoordIndex] [\pageref{CoordIndex}] - Give the grid variable index for a given coordinate name. + Give the grid variable index for a given coordinate. \item[CCTK\_CoordRange] [\pageref{CoordRange}] @@ -888,12 +888,11 @@ The coordinate name is independent of the grid function name. The coordinate name is independent of the grid variable name. To find the index, the coordinate system name must be given, and either the coordinate direction or the coordinate name. The coordinate name -will be used if the coordinate direction is given as -1, otherwise the -coordinate name will be used. +will be used if the coordinate direction is given as less than or equal to zero, otherwise the coordinate name will be used. \end{discussion} \begin{examples} \begin{tabular}{@{}p{3cm}cp{11cm}} -\hfill {\bf C} && {\t index = CCTK\_CoordIndex(1,"xdir","cart3d")}; +\hfill {\bf C} && {\t index = CCTK\_CoordIndex(-1,"xdir","cart3d")}; \\ \hfill {\bf Fortran} && one = 1 \\ diff --git a/src/main/Coord.c b/src/main/Coord.c index a59e6e73..81cd4c68 100644 --- a/src/main/Coord.c +++ b/src/main/Coord.c @@ -410,7 +410,52 @@ void CCTK_FCALL CCTK_FNAME(CCTK_CoordRegisterRange) + /*@@ + @routine CoordIndex + @date + @author Gabrielle Allen + @desc + Return the index for a grid variable registered as a coordinate, taking + as input the coordinate system name and either the coordinate name or the + coordinate direction + @enddesc + @calls + @var dir + @vdesc the direction of the coordinate + @vtype int + @vio in + @vcomment + The range of the coordinate direction is (1,coord system dimension) + If the coord direction is > 0 it is used to calculate the coordinate grid + variable index, if it is <=0 then the coordinate name is used + @endvar + @var name + @vdesc the name of the coordinate (used only if dir <= 0) + @vtype const char * + @vio in + @vcomment + If the coord direction is > 0 it is used to calculate the coordinate grid + variable index, if it is <=0 then the coordinate name is used + @endvar + @var systemname + @vdesc the name of the coordinate system + @vtype const char * + @vio in + @vcomment + + @endvar + + @returntype int + @returndesc + >=0 = grid variable index for coordinate + -1 = no coordinate systems registered + -2 = coordinate system not registered + -3 = coordinate name not found + -4 = coordinate direction greater than system dimension + @endreturndesc + + @@*/ int CCTK_CoordIndex(int dir, const char *name, const char *systemname) { @@ -427,7 +472,7 @@ int CCTK_CoordIndex(int dir, const char *name, const char *systemname) 0); if (data) { - if (dir>-1) + if (dir>0) { if (dir>data->dimension) { -- cgit v1.2.3