summaryrefslogtreecommitdiff
path: root/src/IO
diff options
context:
space:
mode:
authorallen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-03-07 12:37:43 +0000
committerallen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-03-07 12:37:43 +0000
commit20231dad31d8b6c5609c4a50a6cde0ae38e9a3da (patch)
tree256fa7746a50711ac111cc44603014a902dfa7c4 /src/IO
parent100193846e31e3bc7a621e328815217679cf55e4 (diff)
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
Diffstat (limited to 'src/IO')
-rw-r--r--src/IO/IOMethods.c178
1 files changed, 168 insertions, 10 deletions
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;
+ }
+ }
+}