From 0a550f9be142fd56dada20c41181520dca066f37 Mon Sep 17 00:00:00 2001 From: lanfer Date: Wed, 15 Sep 1999 14:14:59 +0000 Subject: adding return values to the iterface git-svn-id: http://svn.cactuscode.org/arrangements/CactusElliptic/EllBase/trunk@10 57bc7290-fb3d-4efd-a9b1-28e84cce6043 --- src/Ell_Interface.c | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/Ell_Interface.c b/src/Ell_Interface.c index 33fe70e..f302920 100644 --- a/src/Ell_Interface.c +++ b/src/Ell_Interface.c @@ -13,6 +13,9 @@ static pNamedData *LinConfMetricSolverDB; static pNamedData *LinMetricSolverDB; static pNamedData *LinFlatSolverDB; +#define ELLBASE_NOSOLVER 1 +#define ELLBASE_OK 0 + /*########## Elliptic Equation class: LinEllConfMetric */ @@ -31,7 +34,7 @@ void Ell_LinConfMetricRegistry(void (*function), const char *sname) { grid hierarchy, integer array of the metric+conf.factor indeces, field index, Mindex, Nindex, real array for absolute tolerances and relative tolerances, the registration name of the solver */ -void Ell_LinConfMetricSolver(cGH *GH, int *MetricPsi, int *FieldIndex, +int Ell_LinConfMetricSolver(cGH *GH, int *MetricPsi, int *FieldIndex, int *MIndex, int *NIndex, CCTK_REAL *AbsTol, CCTK_REAL *RelTol, const char *sname) { @@ -42,20 +45,24 @@ void Ell_LinConfMetricSolver(cGH *GH, int *MetricPsi, int *FieldIndex, /* derive the fucntion name from the requested name and hope it is there */ fn = (void(*))GetNamedData(LinConfMetricSolverDB,sname); - if (!fn) CCTK_WARN(0,"Cannot find solver! "); + if (!fn) { + CCTK_WARN(2,"Cannot find solver! "); + return(ELLBASE_NOSOLVER); + } /* Call the solver and pass through all the necessary arguments */ fn(GH, MetricPsi, FieldIndex, MIndex, NIndex, AbsTol, RelTol); + return(ELLBASE_OK); } /* Fortran wrappr for the routine Ell_LinConfMetricSolver */ void FMODIFIER FORTRAN_NAME(Ell_LinConfMetricSolver) - (cGH *GH, int *MetricPsi, int *FieldIndex, + (int *ierr, cGH *GH, int *MetricPsi, int *FieldIndex, int *MIndex, int *NIndex, int *AbsTol, int *RelTol, ONE_FORTSTRING_ARG) { ONE_FORTSTRING_CREATE(sname); - Ell_LinConfMetricSolver(GH, MetricPsi, FieldIndex, MIndex, NIndex, - AbsTol, RelTol, sname); + *ierr = Ell_LinConfMetricSolver(GH, MetricPsi, FieldIndex, MIndex, NIndex, + AbsTol, RelTol, sname); free(sname); } @@ -66,23 +73,27 @@ void Ell_LinMetricRegistry(void (*function), const char *sname) { StoreNamedData(&LinMetricSolverDB,sname,(void*)function); } -void Ell_LinMetricSolver(cGH *GH, int *Metric, int *FieldIndex, - int *MIndex, int *NIndex, int *AbsTol, int *RelTol, const char *sname) { +int Ell_LinMetricSolver(cGH *GH, int *Metric, int *FieldIndex, + int *MIndex, int *NIndex, int *AbsTol, int *RelTol, const char *sname) { void (*fn)(cGH *GH,int *Metric, int *FieldIndex, int *MIndex, int *NIndex, int *AbsTol, int *RelTol); fn = (void(*))GetNamedData(LinMetricSolverDB,sname); - if (!fn) CCTK_WARN(0,"Cannot find solver! "); + if (!fn) { + CCTK_WARN(2,"Cannot find solver! "); + return(ELLBASE_NOSOLVER); + } fn(GH, Metric, FieldIndex, MIndex, NIndex, AbsTol, RelTol); + return(ELLBASE_OK); } void FMODIFIER FORTRAN_NAME(Ell_LinMetricSolver) - (cGH *GH, int *Metric, int *FieldIndex, + (int *ierr, cGH *GH, int *Metric, int *FieldIndex, int *MIndex, int *NIndex, int *AbsTol, int *RelTol, ONE_FORTSTRING_ARG) { ONE_FORTSTRING_CREATE(sname); - Ell_LinMetricSolver(GH, Metric, FieldIndex, MIndex, NIndex, AbsTol, RelTol, sname); + *ierr = Ell_LinMetricSolver(GH, Metric, FieldIndex, MIndex, NIndex, AbsTol, RelTol, sname); free(sname); } @@ -93,22 +104,26 @@ void Ell_LinFlatRegistry(void (*function), const char *sname) { StoreNamedData(&LinFlatSolverDB,sname,(void*)function); } -void Ell_LinFlatSolver(cGH *GH, int *FieldIndex, int *MIndex, int *NIndex, +int Ell_LinFlatSolver(cGH *GH, int *FieldIndex, int *MIndex, int *NIndex, int *AbsTol, int *RelTol, const char *sname) { void (*fn)(cGH *GH, int *FieldIndex, int *MIndex, int *NIndex, int *AbsTol, int *RelTol); fn = (void(*))GetNamedData(LinFlatSolverDB,sname); - if (!fn) CCTK_WARN(0,"Cannot find solver! "); + if (!fn) { + CCTK_WARN(2,"Cannot find solver! "); + return(ELLBASE_NOSOLVER); + } fn(GH, FieldIndex, MIndex, NIndex, AbsTol, RelTol); + return(ELLBASE_OK); } void FMODIFIER FORTRAN_NAME(Ell_LinFlatSolver) - (cGH *GH, int *FieldIndex, + (int *ierr, cGH *GH, int *FieldIndex, int *MIndex, int *NIndex, int *AbsTol, int *RelTol, ONE_FORTSTRING_ARG) { ONE_FORTSTRING_CREATE(sname); - Ell_LinFlatSolver(GH, FieldIndex, MIndex, NIndex, AbsTol, RelTol, sname); + *ierr = Ell_LinFlatSolver(GH, FieldIndex, MIndex, NIndex, AbsTol, RelTol, sname); free(sname); } -- cgit v1.2.3