From 20231dad31d8b6c5609c4a50a6cde0ae38e9a3da Mon Sep 17 00:00:00 2001 From: allen Date: Sun, 7 Mar 1999 12:37:43 +0000 Subject: Moved rfrTriggerAction and rfrTriggerSaysGo from main/rfrInterface to here because I need to get at the pointer to the data structure with the information about the IO methods ... is there a better way to do this? Added a new registerable function for each IO function TimeToOutput(GH, int variable) which returns true if it time to output a variable git-svn-id: http://svn.cactuscode.org/flesh/trunk@378 17b73243-c579-4c4c-a9d2-2d5706c11dac --- src/IO/IOMethods.c | 178 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 168 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/IO/IOMethods.c b/src/IO/IOMethods.c index 3a262dc4..61292c09 100644 --- a/src/IO/IOMethods.c +++ b/src/IO/IOMethods.c @@ -12,6 +12,7 @@ #include "flesh.h" #include "IOMethods.h" +#include "Groups.h" #include "StoreHandledData.h" static char *rcsid = "$Header$"; @@ -22,17 +23,13 @@ static char *rcsid = "$Header$"; static cHandledData *IOMethods = NULL; static int num_methods = 0; -/* Function which checks that all the functions on all extensions have been - * filled in. - */ -static int CheckAllMethodsSetup(void); - /* Dummy function prototypes. */ static int DummyOutputGH(cGH *GH); static int DummyOutputVarAs(cGH *GH, const char *var, const char *alias); +static int DummyTimeToOutput(cGH *GH, int); /************************************************************************** @@ -56,7 +53,6 @@ static int DummyOutputVarAs(cGH *GH, @@*/ int CCTK_RegisterIOMethod(const char *name) { - int return_val; int handle; @@ -78,7 +74,8 @@ int CCTK_RegisterIOMethod(const char *name) /* Initialise the IO method structure. */ new_method->OutputGH = DummyOutputGH; new_method->OutputVarAs = DummyOutputVarAs; - + new_method->TimeToOutput = DummyTimeToOutput; + /* Remember how many methods there are */ num_methods++; } @@ -174,6 +171,40 @@ int CCTK_RegisterIOMethodOutputVarAs(int handle, int (*func)(cGH *, return return_code; } + /*@@ + @routine CCTK_RegisterIOMethodTimeToOutput + @date Sat 6 March 1999 + @author Gabrielle Allen + @desc + Registers a IO method TimeToOutput function. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ +int CCTK_RegisterIOMethodTimeToOutput(int handle, int (*func)(cGH *, int)) +{ + int return_code; + struct IOMethod *method; + + /* Get the extension. */ + method = CCTK_GetHandledData(IOMethods, handle); + + if(method) + { + method->TimeToOutput = func; + return_code = 1; + } + else + { + return_code = 0; + } + + return return_code; +} /************************************************************************ * @@ -201,9 +232,27 @@ static int DummyOutputGH(cGH *GH) return 0; } + /*@@ + @routine DummyTimeToOutput + @date Sat March 6 1999 + @author Gabrielle Allen + @desc + Dummy for TimeToOutput function. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ +static int DummyTimeToOutput(cGH *GH, int var) +{ + return 0; +} /*@@ - @routine DummyOutputVar + @routine DummyOutputVarAs @date Wed Feb 3 13:37:31 1999 @author Tom Goodale @desc @@ -247,10 +296,119 @@ int CactusDefaultOutputGH(cGH *GH) int CactusDefaultOutputVarAsByMethod(cGH *GH, const char *var, - const char *method, + const char *methodname, const char *alias) { - printf("I'm in the default OutputVarAsByMethod routine\n"); + printf("In default method CactusDefaultOutputVarAsByMethod\n"); + return 0; +} + + +int CCTK_OutputVarAs(cGH *GH, const char *var, const char *alias) +{ + int handle; + char *method; + for (handle = 0;;handle++) + { + method = CCTK_GetHandleName(IOMethods, handle); + printf("Method is %s\n",method); + CCTK_OutputVarAsByMethod(GH, var, method, alias); + } + + return 0; +} + + +int CCTK_OutputVar(cGH *GH, const char *var) +{ + CCTK_OutputVarAs(GH, var, var); + return 0; } + + +int CCTK_OutputVarByMethod(cGH *GH, const char *var, const char *method) +{ + CCTK_OutputVarAsByMethod(GH, var, method, var); + + return 0; +} + + + /*@@ + @routine CCTK_rfrTriggerSaysGo + @date Sat March 6 1999 + @author Gabrielle Allen + @desc + Checks if a triggers registered for a routine is + due for output by any IO method. + @enddesc + @calls + @calledby + @history + + @endhistory + @var variable + @vdesc GH variable index + @vtype int + @vio in + @vcomment + @endvar + */ + +int CCTK_rfrTriggerSaysGo(cGH *GH, int variable) +{ + int handle; + int flag; + struct IOMethod *method; + + for (handle = 0;;handle++) + { + method = (struct IOMethod *)CCTK_GetHandledData(IOMethods, handle); + if (method) + { + flag = method->TimeToOutput(GH, variable); + if (flag) + return 1; + } + else + { + return 0; + } + } + +} + + + + +int CCTK_rfrTriggerAction(void *GH, int variable) +{ + char *varname; + char *fullvarname; + int handle; + int flag; + struct IOMethod *method; + + fullvarname = CCTK_GetFullName(variable); + varname = CCTK_GetVarName(variable); + + for (handle = 0;;handle++) + { + method = (struct IOMethod *)CCTK_GetHandledData(IOMethods, handle); + if (method) + { + flag = method->TimeToOutput(GH, variable); + if (flag) + { + method->OutputVarAs(GH,fullvarname,varname); + } + } + else + { + free(fullvarname); + return 0; + } + } +} -- cgit v1.2.3