aboutsummaryrefslogtreecommitdiff
path: root/src/Ell_Register.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ell_Register.c')
-rw-r--r--src/Ell_Register.c49
1 files changed, 40 insertions, 9 deletions
diff --git a/src/Ell_Register.c b/src/Ell_Register.c
index 09e39f2..ee233b7 100644
--- a/src/Ell_Register.c
+++ b/src/Ell_Register.c
@@ -1,3 +1,12 @@
+ /*@@
+ @header Ell_Register.h
+ @date
+ @author Gerd Lanferman
+ @desc
+ Registration routines for elliptic classes and solvers
+ @enddesc
+ @version $Header$
+ @@*/
#include <stdio.h>
#include <stdlib.h>
@@ -7,11 +16,13 @@
#include "cctk_parameters.h"
#include "cctk_WarnLevel.h"
+#include "EllBase.h"
+
#include "StoreNamedData.h"
static pNamedData *EqNameDB;
-/* Ell_RegisterEq takes a routine ("function") and registers that routi ne
+/* Ell_RegisterEq takes a routine ("function") and registers that routine
under the name "eqname" in the EqNameDB"
Application: Call Ell_Register with the routine that registers a solver
for a elliptic equation class. */
@@ -21,13 +32,27 @@ int Ell_RegisterEq(void *(function)(const char *, void*), const char *eqname)
DECLARE_CCTK_PARAMETERS
- if (StoreNamedData(&EqNameDB, eqname, (void*)function)==0)
+ /* Register if function not already there with this name */
+
+ if (!GetNamedData(EqNameDB, eqname))
{
- if CCTK_EQUALS(elliptic_verbose,"yes")
+
+ if (StoreNamedData(&EqNameDB, eqname, (void*)function)==0)
+ {
+ if CCTK_EQUALS(elliptic_verbose,"yes")
+ {
+ char *msg;
+ msg = (char *)malloc( (200+strlen(eqname))*sizeof(char) );
+ sprintf(msg,"Registered elliptic class: %s",eqname);
+ CCTK_INFO(msg);
+ free(msg);
+ }
+ }
+ else
{
char *msg;
msg = (char *)malloc( (200+strlen(eqname))*sizeof(char) );
- sprintf(msg,"Registered elliptic class: %s",eqname);
+ sprintf(msg,"Failed to register elliptic class: %s",eqname);
CCTK_INFO(msg);
free(msg);
}
@@ -36,14 +61,14 @@ int Ell_RegisterEq(void *(function)(const char *, void*), const char *eqname)
{
char *msg;
msg = (char *)malloc( (200+strlen(eqname))*sizeof(char) );
- sprintf(msg,"Failed to register elliptic class: %s",eqname);
+ sprintf(msg,"Elliptic class %s already registered",eqname);
CCTK_INFO(msg);
free(msg);
}
}
-/* Ell_RegistersSolver takes a routine ("function") and registers that
+/* Ell_RegisterSolver takes a routine ("function") and registers that
routine under the name "sname" with the database specified by "eqname".
So, how do we get to the database, after all it needs to be hardcoded
as pNamedData ? Well, we know its name and in Ell_RegisterEq we have
@@ -54,13 +79,14 @@ int Ell_RegisterEq(void *(function)(const char *, void*), const char *eqname)
declaration) in his own routine and does not have to put it in a central
place. Amen*/
-void Ell_RegisterSolver(void (*function),
- const char *sname,
- const char *eqname)
+int Ell_RegisterSolver(void (*function),
+ const char *sname,
+ const char *eqname)
{
DECLARE_CCTK_PARAMETERS
+ int retval;
void (*fn)(void *, const char *);
fn = (void(*)(void (*function), const char *sname))
@@ -79,10 +105,15 @@ void Ell_RegisterSolver(void (*function),
CCTK_INFO(msg);
free(msg);
}
+
+ retval = ELL_SUCCESS;
}
else
{
CCTK_WARN(0,"Cannot get function in EqName");
+ retval = ELL_NOCLASS;
}
+ return retval;
+
}