diff options
author | lanfer <lanfer@57bc7290-fb3d-4efd-a9b1-28e84cce6043> | 1999-10-28 20:02:59 +0000 |
---|---|---|
committer | lanfer <lanfer@57bc7290-fb3d-4efd-a9b1-28e84cce6043> | 1999-10-28 20:02:59 +0000 |
commit | 4fdbe7dd0905ee76fe451729b5b04a306e319cb5 (patch) | |
tree | 0057089907212a84eb06488a277c778b165dbfe8 | |
parent | 861b88ff2f0e393eff74c7b86f569c740b9d10a4 (diff) |
database for elliptic
git-svn-id: http://svn.cactuscode.org/arrangements/CactusElliptic/EllBase/trunk@16 57bc7290-fb3d-4efd-a9b1-28e84cce6043
-rw-r--r-- | src/Ell_DBstructure.c | 117 | ||||
-rw-r--r-- | src/Ell_DBstructure.h | 13 |
2 files changed, 130 insertions, 0 deletions
diff --git a/src/Ell_DBstructure.c b/src/Ell_DBstructure.c new file mode 100644 index 0000000..572bf61 --- /dev/null +++ b/src/Ell_DBstructure.c @@ -0,0 +1,117 @@ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "cctk.h" +#include "cctk_parameters.h" +#include "cctk_WarnLevel.h" +#include "cctk_FortranString.h" + +#include "StoreNamedData.h" + +#include "Ell_DBstructure.h" + +static pNamedData *EllInfoDB; + +struct t_ellthingy +{ + int type; + int been_set; + union + { + CCTK_REAL r; + CCTK_INT i; + char *s; + } vals; +}; + +int Ell_CreateKey(int vartype, const char *keychain) { + + struct t_ellthingy* new; + int retval; + + if ((struct t_ellthingy*)GetNamedData(EllInfoDB, keychain)) { + retval = ELLCREATE_TWICE; + } else { + + new = (struct t_ellthingy*)malloc(sizeof(struct t_ellthingy)); + + new->type = vartype; + new->been_set = 0; + new->vals.r = 0.0; + new->vals.i = 0; + new->vals.s = NULL; + + printf("Ell_Base: Creating key >%s< (type %d) \n",keychain,new->type); + retval = StoreNamedData(&EllInfoDB, keychain, new); + if (retval!=0) retval = ELLCREATE_FAILED; + } + + return(retval); +} + + + +int Ell_GetRealKey(CCTK_REAL *value, const char *keychain) { + + struct t_ellthingy *getme=NULL; + int retval; + + getme = (struct t_ellthingy*)GetNamedData(EllInfoDB, keychain); + + if (!(getme)) { + printf("Ell_GetRealKey: Cannot get structure with key >%s< \n",keychain); + printf("Ell_GetRealKey: Create first!\n"); + retval = ELLGETREAL_NKEY; + } + else if (getme->type!=CCTK_VARIABLE_REAL) { + printf("You are not getting a CCTK_REAL value off this key: >%s< type: %d\n", + keychain,getme->type); + retval = ELLGETREAL_NREAL; + } + else { + *value=getme->vals.r; + retval=0; + } + return(retval); +} + +void FMODIFIER FORTRAN_NAME(Ell_GetRealKey) + (int *ierr, CCTK_REAL *value, ONE_FORTSTRING_ARG) { + ONE_FORTSTRING_CREATE(key) + *ierr = Ell_GetRealKey(value, key); + free(key); +} + + +int Ell_SetRealKey(CCTK_REAL value, const char *keychain) { + int retval; + + struct t_ellthingy *setme; + + setme = GetNamedData(EllInfoDB, keychain); + if (!(setme)) { + retval = ELLSETREAL_FAILED; + } + else { + setme->type = CCTK_VARIABLE_REAL; + setme->vals.r = value; + setme->been_set = 1; + retval=0; + } + return(retval); +} + +void FMODIFIER FORTRAN_NAME(Ell_SetRealKey) + (int *ierr, CCTK_REAL *value, ONE_FORTSTRING_ARG) { + + ONE_FORTSTRING_CREATE(key) + *ierr = Ell_SetRealKey(*value, key); + free(key); + +} + + + + diff --git a/src/Ell_DBstructure.h b/src/Ell_DBstructure.h new file mode 100644 index 0000000..673c4b5 --- /dev/null +++ b/src/Ell_DBstructure.h @@ -0,0 +1,13 @@ +#ifndef _ELLBASE_H_ +#define _ELLBASE_H_ + + +#define ELLCREATE_FAILED -1 +#define ELLCREATE_TWICE -2 + +#define ELLGETREAL_NKEY -1 +#define ELLGETREAL_NREAL -2 + +#define ELLSETREAL_FAILED -1 + +#endif |