aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortradke <tradke@38c3d835-c875-442e-b0fe-21c19ce1d001>2001-12-28 21:42:15 +0000
committertradke <tradke@38c3d835-c875-442e-b0fe-21c19ce1d001>2001-12-28 21:42:15 +0000
commita1063cbd7ddb585ac878ce431bc929a5fd8271e9 (patch)
tree0e67f344d8204f4116a55afc48b1a92a994ee9be /src
parent479143043f760896065a8d7c4a2e059adb8c41c5 (diff)
Fixed return codes of I/O methods.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOPanda/trunk@28 38c3d835-c875-442e-b0fe-21c19ce1d001
Diffstat (limited to 'src')
-rw-r--r--src/Output3D.c72
1 files changed, 50 insertions, 22 deletions
diff --git a/src/Output3D.c b/src/Output3D.c
index 3af7864..860f96a 100644
--- a/src/Output3D.c
+++ b/src/Output3D.c
@@ -38,7 +38,7 @@ void Panda_WriteAttribute(const char *, const char *, int, int, const void *);
static int CheckOutputVar (int vindex);
static void CheckSteerableParameters (pandaGH *myGH);
static void SetOutputFlag (int vindex, const char *optstring, void *arg);
-static void IOPanda_Timestep (const cGH *GH, int vindex, const char *alias);
+static int IOPanda_Timestep (const cGH *GH, int vindex, const char *alias);
static void IOPanda_IEEEIOStructDump (const cGH *GH, const char *fname);
static void IOPanda_AddCommonAttributes (const cGH *GH, int vindex, int timelevel, int global_size[3], char *fname);
static void IOPanda_AddChunkAttributes (const cGH *GH, int vindex, CCTK_INT4 *geom, char *fname);
@@ -55,14 +55,20 @@ static void IOPanda_AddChunkAttributes (const cGH *GH, int vindex, CCTK_INT4 *ge
@vtype const cGH *
@vio in
@endvar
+
+ @returntype int
+ @returndesc
+ the number of variables which were output at this iteration
+ (or 0 if it wasn't time to output yet)
+ @endreturndesc
@@*/
int IOPanda_Output3DGH (const cGH *GH)
{
- DECLARE_CCTK_PARAMETERS
- int vindex;
+ int vindex, retval;
char *fullname;
const char *name;
pandaGH *myGH;
+ DECLARE_CCTK_PARAMETERS
/* Get the GH extension for IOPanda */
@@ -76,7 +82,7 @@ int IOPanda_Output3DGH (const cGH *GH)
}
/* Loop over all variables */
- for (vindex = 0; vindex < CCTK_NumVars (); vindex++)
+ for (vindex = retval = 0; vindex < CCTK_NumVars (); vindex++)
{
if (IOPanda_TimeFor3D (GH, vindex))
{
@@ -91,14 +97,16 @@ int IOPanda_Output3DGH (const cGH *GH)
}
/* Do the 3D output */
- IOPanda_Timestep (GH, vindex, name);
-
- /* Register variable as having 3D output this iteration */
- myGH->out3D_last [vindex] = GH->cctk_iteration;
+ if (IOPanda_Timestep (GH, vindex, name) == 0)
+ {
+ /* Register variable as having 3D output this iteration */
+ myGH->out3D_last [vindex] = GH->cctk_iteration;
+ retval++;
+ }
}
}
- return (0);
+ return (retval);
}
@@ -127,13 +135,18 @@ int IOPanda_Output3DGH (const cGH *GH)
@vtype const char *
@vio in
@endvar
+
+ @returntype int
+ @returndesc
+ return code of @seeroutine IOPanda_Timestep
+ @endreturndesc
@@*/
int IOPanda_Output3DVarAs (const cGH *GH,
const char *fullname,
const char *alias)
{
+ int vindex, retval;
DECLARE_CCTK_PARAMETERS
- int vindex;
vindex = CCTK_VarIndex(fullname);
@@ -146,9 +159,9 @@ int IOPanda_Output3DVarAs (const cGH *GH,
}
/* Do the 3D output */
- IOPanda_Timestep (GH, vindex, alias);
+ retval = IOPanda_Timestep (GH, vindex, alias);
- return (0);
+ return (retval);
}
@@ -171,6 +184,12 @@ int IOPanda_Output3DVarAs (const cGH *GH,
@vtype int
@vio in
@endvar
+
+ @returntype int
+ @returndesc
+ 1 if output should take place at this iteration, or<BR>
+ 0 if not
+ @endreturndesc
@@*/
int IOPanda_TimeFor3D (const cGH *GH,
int vindex)
@@ -229,13 +248,19 @@ int IOPanda_TimeFor3D (const cGH *GH,
@vtype int
@vio in
@endvar
+
+ @returntype int
+ @returndesc
+ return code of @seeroutine IOPanda_Timestep
+ @endreturndesc
@@*/
int IOPanda_TriggerOutput3D (const cGH *GH,
int vindex)
{
- DECLARE_CCTK_PARAMETERS
+ int retval;
pandaGH *myGH;
const char *varname;
+ DECLARE_CCTK_PARAMETERS
varname = CCTK_VarName (vindex);
@@ -250,12 +275,15 @@ int IOPanda_TriggerOutput3D (const cGH *GH,
}
/* Do the 3D output */
- IOPanda_Timestep (GH, vindex, varname);
+ retval = IOPanda_Timestep (GH, vindex, varname);
- /* Register variable as having 3D output this iteration */
- myGH->out3D_last [vindex] = GH->cctk_iteration;
+ if (retval == 0)
+ {
+ /* Register variable as having 3D output this iteration */
+ myGH->out3D_last [vindex] = GH->cctk_iteration;
+ }
- return (0);
+ return (retval);
}
@@ -347,11 +375,8 @@ static void SetOutputFlag (int vindex,
}
-static void IOPanda_Timestep (const cGH *GH,
- int vindex,
- const char *alias)
+static int IOPanda_Timestep (const cGH *GH, int vindex, const char *alias)
{
- DECLARE_CCTK_PARAMETERS
void *data;
int tmp[1], tmp1[3], tmp2[3];
Distribution dist1[3], dist2[3];
@@ -365,6 +390,7 @@ static void IOPanda_Timestep (const cGH *GH,
char *non_const_char;
const char *const_char;
} cast_to_const;
+ DECLARE_CCTK_PARAMETERS
/* prevent compiler warning "cast discards `const' from pointer target type"*/
@@ -379,7 +405,7 @@ static void IOPanda_Timestep (const cGH *GH,
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
"No IOPanda 3D output for '%s' (no storage)", fullname);
free (fullname);
- return;
+ return (-1);
}
/* get the handles for PUGH and IOUtil GH extensions */
@@ -467,6 +493,8 @@ static void IOPanda_Timestep (const cGH *GH,
{
IOPanda_IEEEIOStructDump(GH, ainfo.name_);
}
+
+ return (0);
}