aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortradke <tradke@38c3d835-c875-442e-b0fe-21c19ce1d001>2001-05-13 23:23:32 +0000
committertradke <tradke@38c3d835-c875-442e-b0fe-21c19ce1d001>2001-05-13 23:23:32 +0000
commit4fd4e74a1cf8fb6a6ef86277d21ca914e0d76fa4 (patch)
tree167b484cfc06cb0cdd3f8e7dad64a79808f732fb /src
parent11f7e518048c32ec85408fe6fcb3d0bebd58b4d8 (diff)
Added file info and fixed couple of compiler warnings.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOPanda/trunk@25 38c3d835-c875-442e-b0fe-21c19ce1d001
Diffstat (limited to 'src')
-rw-r--r--src/Output3D.c204
-rw-r--r--src/make.code.defn3
2 files changed, 118 insertions, 89 deletions
diff --git a/src/Output3D.c b/src/Output3D.c
index db14d4b..35b2b47 100644
--- a/src/Output3D.c
+++ b/src/Output3D.c
@@ -3,9 +3,8 @@
@date 01 Oct 1999
@author Jonghyun Lee
@desc Functions to deal 3D output of GFs
- @enddesc
- @history
- @hendhistory
+ @enddesc
+ @version $Id$
@@*/
#include <stdio.h>
@@ -16,27 +15,33 @@
#include "cctk_Parameters.h"
#include "CactusBase/IOUtil/src/ioGH.h"
#include "CactusPUGH/PUGH/src/include/pugh.h"
-#include "external/FlexIO/src/IOProtos.h"
+#include "CactusExternal/FlexIO/src/IOProtos.h"
#include "ioPandaGH.h"
#include "Panda/c_interface.h"
+/* the rcs ID and its dummy funtion to use it */
+static const char *rcsid = "$Header$";
+CCTK_FILEVERSION(BetaThorns_IOPanda_Output3D_c)
+
/* function prototypes */
+int IOPanda_Output3DGH (cGH *GH);
+int IOPanda_TriggerOutput3D (cGH *GH, int vindex);
int IOPanda_Output3DVarAs (cGH *GH, const char *var, const char *alias);
-int IOPanda_TimeFor3D (cGH *GH, int index);
-void IOPanda_getDumpData (cGH *GH, int index, int timelevel, void **outme,
+int IOPanda_TimeFor3D (cGH *GH, int vindex);
+void IOPanda_getDumpData (cGH *GH, int vindex, int timelevel, void **outme,
int *free_outme, CCTK_INT4 *geom, int element_size);
void PandaTimestep(ArrayInfo *);
int PandaIsNewFile(char *);
-void Panda_WriteAttribute(char *, char *, int, int, void *);
+void Panda_WriteAttribute(const char *, const char *, int, int, const void *);
-static int CheckOutputVar (int index);
+static int CheckOutputVar (int vindex);
static void CheckSteerableParameters (pandaGH *myGH);
-static void SetOutputFlag (int index, const char *optstring, void *arg);
-static void IOPanda_Timestep (cGH *GH, int index, const char *alias);
-static void IOPanda_IEEEIOStructDump (cGH *GH, char *fname);
-static void IOPanda_AddCommonAttributes (cGH *GH, int index, int timelevel, int global_size[3], char *fname);
-static void IOPanda_AddChunkAttributes (cGH *GH, int index, CCTK_INT4 *geom, char *fname);
+static void SetOutputFlag (int vindex, const char *optstring, void *arg);
+static void IOPanda_Timestep (cGH *GH, int vindex, const char *alias);
+static void IOPanda_IEEEIOStructDump (cGH *GH, const char *fname);
+static void IOPanda_AddCommonAttributes (cGH *GH, int vindex, int timelevel, int global_size[3], char *fname);
+static void IOPanda_AddChunkAttributes (cGH *GH, int vindex, CCTK_INT4 *geom, char *fname);
/*@@
@routine IOPanda_Output3DGH
@@ -54,14 +59,14 @@ static void IOPanda_AddChunkAttributes (cGH *GH, int index, CCTK_INT4 *geom, cha
int IOPanda_Output3DGH (cGH *GH)
{
DECLARE_CCTK_PARAMETERS
- int index;
+ int vindex;
char *fullname;
const char *name;
pandaGH *myGH;
/* Get the GH extension for IOPanda */
- myGH = (pandaGH *) GH->extensions [CCTK_GHExtensionHandle ("IOPanda")];
+ myGH = (pandaGH *) CCTK_GHExtension (GH, "IOPanda");
CheckSteerableParameters (myGH);
@@ -71,25 +76,25 @@ int IOPanda_Output3DGH (cGH *GH)
}
/* Loop over all variables */
- for (index = 0; index < CCTK_NumVars (); index++)
+ for (vindex = 0; vindex < CCTK_NumVars (); vindex++)
{
- if (IOPanda_TimeFor3D (GH, index))
+ if (IOPanda_TimeFor3D (GH, vindex))
{
- name = CCTK_VarName (index);
+ name = CCTK_VarName (vindex);
if (verbose)
{
- fullname = CCTK_FullName (index);
+ fullname = CCTK_FullName (vindex);
CCTK_VInfo (CCTK_THORNSTRING, "IOPanda_Output3DGH: "
"(fullname, name) = (%s, %s)", fullname, name);
free (fullname);
}
/* Do the 3D output */
- IOPanda_Timestep (GH, index, name);
+ IOPanda_Timestep (GH, vindex, name);
/* Register variable as having 3D output this iteration */
- myGH->out3D_last [index] = GH->cctk_iteration;
+ myGH->out3D_last [vindex] = GH->cctk_iteration;
}
}
@@ -128,20 +133,20 @@ int IOPanda_Output3DVarAs (cGH *GH,
const char *alias)
{
DECLARE_CCTK_PARAMETERS
- int index;
+ int vindex;
- index = CCTK_VarIndex(fullname);
+ vindex = CCTK_VarIndex(fullname);
if (verbose)
{
CCTK_VInfo (CCTK_THORNSTRING, "IOPanda_Output3DVarAs: "
"(fullname, alias, index) = (%s, %s, %d)",
- fullname, alias, index);
+ fullname, alias, vindex);
}
/* Do the 3D output */
- IOPanda_Timestep (GH, index, alias);
+ IOPanda_Timestep (GH, vindex, alias);
return (0);
}
@@ -161,20 +166,20 @@ int IOPanda_Output3DVarAs (cGH *GH,
@vtype cGH
@vio in
@endvar
- @var index
+ @var vindex
@vdesc index of variable
@vtype int
@vio in
@endvar
@@*/
int IOPanda_TimeFor3D (cGH *GH,
- int index)
+ int vindex)
{
pandaGH *myGH;
/* Get the GH extension for IOPanda */
- myGH = (pandaGH *) GH->extensions [CCTK_GHExtensionHandle ("IOPanda")];
+ myGH = (pandaGH *) CCTK_GHExtension (GH, "IOPanda");
CheckSteerableParameters (myGH);
@@ -185,15 +190,15 @@ int IOPanda_TimeFor3D (cGH *GH,
}
/* Check this variable should be output */
- if (! (myGH->do_out3D [index] && GH->cctk_iteration % myGH->out3D_every == 0))
+ if (! (myGH->do_out3D [vindex] && GH->cctk_iteration % myGH->out3D_every == 0))
{
return (0);
}
/* Check variable not already output this iteration */
- if (myGH->out3D_last [index] == GH->cctk_iteration)
+ if (myGH->out3D_last [vindex] == GH->cctk_iteration)
{
- char *fullname = CCTK_FullName (index);
+ char *fullname = CCTK_FullName (vindex);
CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING,
@@ -219,36 +224,36 @@ int IOPanda_TimeFor3D (cGH *GH,
@vtype cGH
@vio in
@endvar
- @var index
+ @var vindex
@vdesc index of variable to output
@vtype int
@vio in
@endvar
@@*/
int IOPanda_TriggerOutput3D (cGH *GH,
- int index)
+ int vindex)
{
DECLARE_CCTK_PARAMETERS
pandaGH *myGH;
const char *varname;
- varname = CCTK_VarName (index);
+ varname = CCTK_VarName (vindex);
/* Get the GH extension for IOPanda */
- myGH = (pandaGH *) GH->extensions [CCTK_GHExtensionHandle ("IOPanda")];
+ myGH = (pandaGH *) CCTK_GHExtension (GH, "IOPanda");
if (verbose)
{
CCTK_VInfo (CCTK_THORNSTRING, "TriggerOutput3D: "
- "name, index = %s, %d", varname, index);
+ "name, index = %s, %d", varname, vindex);
}
/* Do the 3D output */
- IOPanda_Timestep (GH, index, varname);
+ IOPanda_Timestep (GH, vindex, varname);
/* Register variable as having 3D output this iteration */
- myGH->out3D_last [index] = GH->cctk_iteration;
+ myGH->out3D_last [vindex] = GH->cctk_iteration;
return (0);
}
@@ -286,7 +291,7 @@ static void CheckSteerableParameters (pandaGH *myGH)
/* check if this variable can be output (static conditions) */
-static int CheckOutputVar (int index)
+static int CheckOutputVar (int vindex)
{
char *errormsg;
char *fullname;
@@ -298,18 +303,18 @@ static int CheckOutputVar (int index)
so somehow CCTK_COMPLEX has to be mapped onto REALs or so.
We have to check this already here because if an IEEEIO file
is created and nothing is written to, it crashes at re-opening. ***/
- if (CCTK_VarTypeI (index) == CCTK_VARIABLE_COMPLEX)
+ if (CCTK_VarTypeI (vindex) == CCTK_VARIABLE_COMPLEX)
{
errormsg = "IOPanda 3D output for complex variable '%s' not yet supported";
}
- else if (CCTK_GroupTypeFromVarI (index) == CCTK_SCALAR)
+ else if (CCTK_GroupTypeFromVarI (vindex) == CCTK_SCALAR)
{
errormsg = "IOPanda 3D output for scalar variable '%s' not supported";
}
if (errormsg)
{
- fullname = CCTK_FullName (index);
+ fullname = CCTK_FullName (vindex);
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
errormsg, fullname);
free (fullname);
@@ -321,7 +326,7 @@ static int CheckOutputVar (int index)
/* callback for CCTK_TraverseString() to set the output flag
for the given variable */
-static void SetOutputFlag (int index,
+static void SetOutputFlag (int vindex,
const char *optstring,
void *arg)
{
@@ -329,9 +334,9 @@ static void SetOutputFlag (int index,
/* Check the variable type */
- if (CheckOutputVar (index) == 0)
+ if (CheckOutputVar (vindex) == 0)
{
- flags[index] = 1;
+ flags[vindex] = 1;
}
if (optstring)
@@ -343,7 +348,7 @@ static void SetOutputFlag (int index,
static void IOPanda_Timestep (cGH *GH,
- int index,
+ int vindex,
const char *alias)
{
DECLARE_CCTK_PARAMETERS
@@ -355,12 +360,20 @@ static void IOPanda_Timestep (cGH *GH,
ArrayInfo ainfo;
ioGH *ioUtilGH;
pGH *pughGH;
+ union
+ {
+ char *non_const_char;
+ const char *const_char;
+ } cast_to_const;
+ /* prevent compiler warning "cast discards `const' from pointer target type"*/
+ cast_to_const.const_char = alias;
+
/* check if variable has storage assigned */
- if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (index)))
+ if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (vindex)))
{
- char *fullname = CCTK_FullName (index);
+ char *fullname = CCTK_FullName (vindex);
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
@@ -371,17 +384,17 @@ static void IOPanda_Timestep (cGH *GH,
/* get the handles for PUGH and IOUtil GH extensions */
pughGH = PUGH_pGH (GH);
- ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
-
- ainfo.name_ = (char *)alias;
-
+ ioUtilGH = (ioGH *) CCTK_GHExtension (GH, "IO");
+
+ ainfo.name_ = cast_to_const.non_const_char;
+
ainfo.rank_ = 3;
- tmp1[0] = GH->cctk_gsh[2];
- tmp1[1] = GH->cctk_gsh[1];
- tmp1[2] = GH->cctk_gsh[0];
+ tmp1[0] = GH->cctk_gsh[2];
+ tmp1[1] = GH->cctk_gsh[1];
+ tmp1[2] = GH->cctk_gsh[0];
ainfo.size_ = tmp1;
-
- switch (CCTK_VarTypeI (index))
+
+ switch (CCTK_VarTypeI (vindex))
{
case CCTK_VARIABLE_CHAR:
ainfo.esize_ = CHAR;
@@ -408,10 +421,10 @@ static void IOPanda_Timestep (cGH *GH,
ainfo.esize_ = FLOAT64;
#elif CCTK_REAL_PRECISION_4
ainfo.esize_ = FLOAT32;
-#endif
+#endif
}
}
-
+
/* FIXME: rank */
ainfo.mem_rank_ = 3;
tmp2[0] = pughGH->Connectivity [2]->nprocs [2];
@@ -420,17 +433,17 @@ static void IOPanda_Timestep (cGH *GH,
ainfo.mem_layout_ = tmp2;
dist1[0] = dist1[1] = dist1[2] = BLOCK;
ainfo.mem_dist_ = dist1;
-
+
ainfo.disk_rank_ = 1;
dist2[0] = BLOCK; dist2[1] = dist2[2] = NONE;
tmp[0]= ((CCTK_nProcs(GH) - 1) / ioUtilGH->ioproc_every + 1);
-
+
ainfo.disk_layout_ = tmp;
ainfo.disk_dist_ = dist2;
timelevel = 0;
- IOPanda_getDumpData(GH, index, timelevel, &data, &free_flag, bnd, ainfo.esize_);
+ IOPanda_getDumpData(GH, vindex, timelevel, &data, &free_flag, bnd, ainfo.esize_);
ainfo.data_ = (char *)data;
/*** FIXME: asymmetric ghostzones */
@@ -442,12 +455,12 @@ static void IOPanda_Timestep (cGH *GH,
free (data);
}
- IOPanda_AddCommonAttributes(GH, index, timelevel, ainfo.size_, ainfo.name_);
+ IOPanda_AddCommonAttributes(GH, vindex, timelevel, ainfo.size_, ainfo.name_);
if (! ioUtilGH->unchunked)
{
/* Write chunk attributes */
- IOPanda_AddChunkAttributes (GH, index, bnd, ainfo.name_);
+ IOPanda_AddChunkAttributes (GH, vindex, bnd, ainfo.name_);
}
if (PandaIsNewFile(ainfo.name_))
@@ -458,7 +471,7 @@ static void IOPanda_Timestep (cGH *GH,
static void IOPanda_AddCommonAttributes (cGH *GH,
- int index,
+ int vindex,
int timelevel,
int global_size[3],
char *fname)
@@ -470,40 +483,28 @@ static void IOPanda_AddCommonAttributes (cGH *GH,
CCTK_REAL dummy;
char *name, *gname;
ioGH *ioUtilGH;
- char *char_time_date = "";
-
-#ifdef SGI
- time_t t = time(NULL);
- char_time_date = asctime (localtime (&t));
-#endif
/* Get the handle for IO extensions */
- ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
+ ioUtilGH = (ioGH *) CCTK_GHExtension (GH, "IO");
- name = CCTK_FullName (index);
+ name = CCTK_FullName (vindex);
Panda_WriteAttribute (fname, "name", BYTE, strlen (name) + 1, name);
free (name);
- gname = CCTK_GroupNameFromVarI (index);
+ gname = CCTK_GroupNameFromVarI (vindex);
Panda_WriteAttribute (fname, "groupname", BYTE, strlen (gname) + 1, gname);
free (gname);
- i_to_IO = CCTK_GroupTypeFromVarI (index);
+ i_to_IO = CCTK_GroupTypeFromVarI (vindex);
Panda_WriteAttribute (fname, "grouptype", INT32, 1, &i_to_IO);
- i_to_IO = CCTK_NumTimeLevelsFromVarI (index);
+ i_to_IO = CCTK_NumTimeLevelsFromVarI (vindex);
Panda_WriteAttribute (fname, "ntimelevels", INT32, 1, &i_to_IO);
i_to_IO = timelevel;
Panda_WriteAttribute (fname, "timelevel", INT32, 1, &i_to_IO);
- if (char_time_date && out3D_datestamp)
- {
- Panda_WriteAttribute (fname, "date", BYTE,
- strlen (char_time_date) + 1, char_time_date);
- }
-
Panda_WriteAttribute (fname, "time", FLOAT64, 1,&GH->cctk_time);
d3_to_IO [0] = CCTK_CoordRange (GH, &d3_to_IO [0], &dummy, -1, "x", "cart3d");
@@ -548,11 +549,11 @@ static void IOPanda_AddCommonAttributes (cGH *GH,
i_to_IO = GH->cctk_iteration;
Panda_WriteAttribute (fname, "iteration", INT32, 1, &i_to_IO);
-}
+}
static void IOPanda_AddChunkAttributes (cGH *GH,
- int index,
+ int vindex,
CCTK_INT4 *geom,
char *fname)
{
@@ -566,7 +567,7 @@ static void IOPanda_AddChunkAttributes (cGH *GH,
return;
/* get the dimension of the variable */
- dim = CCTK_GroupDimI (CCTK_GroupIndexFromVarI (index));
+ dim = CCTK_GroupDimI (CCTK_GroupIndexFromVarI (vindex));
Panda_WriteAttribute (fname, "chunk_origin", INT32, dim, &geom[0]);
Panda_WriteAttribute (fname, "subchunk_lb", INT32, dim, &geom[0]);
@@ -575,21 +576,24 @@ static void IOPanda_AddChunkAttributes (cGH *GH,
i_to_IO = GH->cctk_iteration;
Panda_WriteAttribute (fname, "chunk_dataset", INT32, 1, &i_to_IO);
- name = CCTK_FullName (index);
+ name = CCTK_FullName (vindex);
Panda_WriteAttribute (fname, "name", CHAR, strlen (name)+1, name);
free (name);
}
static void IOPanda_IEEEIOStructDump (cGH *GH,
- char *fname)
+ const char *fname)
{
+ DECLARE_CCTK_PARAMETERS
+ int len;
CCTK_INT4 i_temp;
CCTK_REAL d_temp;
ioGH *ioUtilGH;
+ char buffer[128];
-
- ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
+
+ ioUtilGH = (ioGH *) CCTK_GHExtension (GH, "IO");
i_temp = GH->cctk_iteration;
Panda_WriteAttribute (fname, "GH$iteration", INT32, 1, &i_temp);
@@ -602,4 +606,26 @@ static void IOPanda_IEEEIOStructDump (cGH *GH,
d_temp = GH->cctk_time;
Panda_WriteAttribute (fname, "GH$time", FLOAT64, 1, &d_temp);
+
+ /* add the parameter filename and the creation date
+ as file identification attributes */
+ if (CCTK_Equals (out_fileinfo, "parameter filename") ||
+ CCTK_Equals (out_fileinfo, "all"))
+ {
+ buffer[0] = 0;
+ CCTK_ParameterFilename (sizeof (buffer), buffer);
+ Panda_WriteAttribute (fname, "parameter file", CHAR,
+ strlen (buffer) + 1, buffer);
+ }
+ if (CCTK_Equals (out_fileinfo, "creation date") ||
+ CCTK_Equals (out_fileinfo, "all"))
+ {
+ buffer[0] = 0;
+ Util_CurrentDate (sizeof (buffer), buffer);
+ len = strlen (buffer) + 1;
+ buffer[len-1] = ' ';
+ Util_CurrentTime (sizeof (buffer) - len, buffer + len);
+ Panda_WriteAttribute (fname, "creation date", CHAR,
+ strlen (buffer) + 1, buffer);
+ }
}
diff --git a/src/make.code.defn b/src/make.code.defn
index 174c78b..4ab0091 100644
--- a/src/make.code.defn
+++ b/src/make.code.defn
@@ -1,3 +1,6 @@
SRCS = Startup.c GHExtension.c Output3D.c DumpVar.c
SUBDIRS = Panda
+
+# all compilers should understand ANSI C
+CFLAGS += -DANSI