From 5d83fceb99edc8eb9b2c488e212d9e7c521f30c9 Mon Sep 17 00:00:00 2001 From: lanfer Date: Thu, 4 Nov 1999 13:10:03 +0000 Subject: more error checking git-svn-id: http://svn.cactuscode.org/arrangements/CactusElliptic/EllBase/trunk@22 57bc7290-fb3d-4efd-a9b1-28e84cce6043 --- src/Ell_DBstructure.c | 19 ++++++++++++++++--- src/Ell_DBstructure.h | 2 +- src/Startup.c | 12 ++++++------ 3 files changed, 23 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/Ell_DBstructure.c b/src/Ell_DBstructure.c index c6f574d..cfdc16c 100644 --- a/src/Ell_DBstructure.c +++ b/src/Ell_DBstructure.c @@ -107,6 +107,10 @@ int Ell_SetRealKey(CCTK_REAL value, const char *keychain) { setme = GetNamedData(EllInfoDB, keychain); if (!(setme)) { retval = ELLSET_FAILED; + } else if (setme->type!=CCTK_VARIABLE_REAL) { + retval = ELLSET_BADTYPE; + printf("Ell_SetRealKey: The key you try to set is not of type CCTK_REAL: >%s< (type %d)\n", + keychain,setme->type); } else { setme->type = CCTK_VARIABLE_REAL; @@ -133,6 +137,11 @@ int Ell_SetIntKey(CCTK_INT value, const char *keychain) { if (!(setme)) { retval = ELLSET_FAILED; } + else if (setme->type!=CCTK_VARIABLE_INT) { + retval = ELLSET_BADTYPE; + printf("Ell_SetIntKey: The key you try to set is not of type CCTK_INT: >%s< (type %d)\n", + keychain,setme->type); + } else { setme->type = CCTK_VARIABLE_INT; setme->vals.i = value; @@ -156,6 +165,10 @@ int Ell_SetStrKey(char *value, const char *keychain) { setme = GetNamedData(EllInfoDB, keychain); if (!(setme)) { retval = ELLSET_FAILED; + } else if (setme->type!=CCTK_VARIABLE_STRING) { + retval = ELLSET_BADTYPE; + printf("Ell_SetStrKey: The key you try to set is not of type STRING: >%s< (type %d)\n", + keychain,setme->type); } else { setme->type = CCTK_VARIABLE_STRING; @@ -236,7 +249,7 @@ int Ell_GetIntKey(CCTK_INT *value,const char *keychain) { retval = ELLGET_BADTYPE; } else if (getme->been_set==ELL_NO) { - printf("Ell_GetIntKey: Key has not been set to any value: >%s< type %d",keychain,getme->type); + printf("Ell_GetIntKey: Key has not been set to any value: >%s< type %d\n",keychain,getme->type); retval = ELLGET_NOTSET; } else { *value=getme->vals.i; @@ -271,7 +284,7 @@ int Ell_GetStrKey(char *value, const char *keychain) { retval = ELLGET_BADTYPE; } else if (getme->been_set==ELL_NO) { - printf("Key has not been set"); + printf("Key has not been set\n"); retval = ELLGET_NOTSET; } else { *value=getme->vals.r; @@ -291,7 +304,7 @@ void FMODIFIER FORTRAN_NAME(Ell_GetStrKey) { char *message; message = (char *)malloc( (200+strlen(*cstring))*sizeof(char) ); - sprintf(message,"Cannot output %s to char* of length %d", + sprintf(message,"Cannot output %s to char* of length %d\n", *cstring,cctk_strlen1); CCTK_Warn (1,__LINE__,__FILE__,"Cactus",message); free(message); diff --git a/src/Ell_DBstructure.h b/src/Ell_DBstructure.h index 670649e..efad201 100644 --- a/src/Ell_DBstructure.h +++ b/src/Ell_DBstructure.h @@ -15,7 +15,7 @@ #define ELLGET_NOTSET -3 #define ELLSET_FAILED -1 - +#define ELLSET_BADTYPE -2 #ifdef CCODE diff --git a/src/Startup.c b/src/Startup.c index fad462d..2b3d7d2 100644 --- a/src/Startup.c +++ b/src/Startup.c @@ -43,18 +43,18 @@ void Ell_RegisterBaseEqTypes(cGH *GH) { err = Ell_CreateKey(CCTK_VARIABLE_STRING,"EllLinMetric::Bnd"); /* Register the variables needed to use these boundaries */ - err = Ell_CreateKey(CCTK_VARIABLE_REAL, "EllLinConfMetric::Bnd::Robin::V0"); - err = Ell_CreateKey(CCTK_VARIABLE_INT, "EllLinConfMetric::Bnd::Robin::V1"); + err = Ell_CreateKey(CCTK_VARIABLE_REAL, "EllLinConfMetric::Bnd::Robin::inf"); + err = Ell_CreateKey(CCTK_VARIABLE_INT, "EllLinConfMetric::Bnd::Robin::falloff"); err = Ell_CreateKey(CCTK_VARIABLE_REAL, "EllLinConfMetric::Bnd::Const::V0"); /* Register the variables needed to use these boundaries */ - err = Ell_CreateKey(CCTK_VARIABLE_REAL, "EllLinMetric::Bnd::Robin::V0"); - err = Ell_CreateKey(CCTK_VARIABLE_INT, "EllLinMetric::Bnd::Robin::V1"); + err = Ell_CreateKey(CCTK_VARIABLE_REAL, "EllLinMetric::Bnd::Robin::inf"); + err = Ell_CreateKey(CCTK_VARIABLE_INT, "EllLinMetric::Bnd::Robin::falloff"); err = Ell_CreateKey(CCTK_VARIABLE_REAL, "EllLinMetric::Bnd::Const::V0"); /* Register the variables needed to use these boundaries */ - err = Ell_CreateKey(CCTK_VARIABLE_REAL, "EllLinFlat::Bnd::Robin::V0"); - err = Ell_CreateKey(CCTK_VARIABLE_INT, "EllLinFlat::Bnd::Robin::V1"); + err = Ell_CreateKey(CCTK_VARIABLE_REAL, "EllLinFlat::Bnd::Robin::inf"); + err = Ell_CreateKey(CCTK_VARIABLE_INT, "EllLinFlat::Bnd::Robin::falloff"); err = Ell_CreateKey(CCTK_VARIABLE_REAL, "EllLinFlat::Bnd::Const::V0"); } -- cgit v1.2.3