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.c60
1 files changed, 54 insertions, 6 deletions
diff --git a/src/Ell_Register.c b/src/Ell_Register.c
index 931daf0..09e39f2 100644
--- a/src/Ell_Register.c
+++ b/src/Ell_Register.c
@@ -15,8 +15,32 @@ static pNamedData *EqNameDB;
under the name "eqname" in the EqNameDB"
Application: Call Ell_Register with the routine that registers a solver
for a elliptic equation class. */
-void Ell_RegisterEq(void *(function)(const char *, void*), const char *eqname) {
- StoreNamedData(&EqNameDB, eqname, (void*)function);
+
+int Ell_RegisterEq(void *(function)(const char *, void*), const char *eqname)
+{
+
+ DECLARE_CCTK_PARAMETERS
+
+ 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,"Failed to register elliptic class: %s",eqname);
+ CCTK_INFO(msg);
+ free(msg);
+ }
+
}
/* Ell_RegistersSolver takes a routine ("function") and registers that
@@ -30,11 +54,35 @@ void 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) {
+void Ell_RegisterSolver(void (*function),
+ const char *sname,
+ const char *eqname)
+{
+
+ DECLARE_CCTK_PARAMETERS
+
void (*fn)(void *, const char *);
- fn = (void(*)(void (*function), const char *sname))GetNamedData(EqNameDB, eqname);
- if (!fn) CCTK_WARN(0,"Cannot get function in EqName");
+ fn = (void(*)(void (*function), const char *sname))
+ GetNamedData(EqNameDB, eqname);
+
+ if (fn)
+ {
+
+ fn(function,sname);
+
+ if CCTK_EQUALS(elliptic_verbose,"yes")
+ {
+ char *msg;
+ msg = (char *)malloc( (200+strlen(eqname)+strlen(sname))*sizeof(char) );
+ sprintf(msg,"Registered elliptic solver %s for %s",sname,eqname);
+ CCTK_INFO(msg);
+ free(msg);
+ }
+ }
+ else
+ {
+ CCTK_WARN(0,"Cannot get function in EqName");
+ }
- fn(function,sname);
}