aboutsummaryrefslogtreecommitdiff
path: root/src/Output3D.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Output3D.c')
-rw-r--r--src/Output3D.c143
1 files changed, 60 insertions, 83 deletions
diff --git a/src/Output3D.c b/src/Output3D.c
index ea97b62..c7ef26a 100644
--- a/src/Output3D.c
+++ b/src/Output3D.c
@@ -9,24 +9,17 @@
@@*/
#include <stdio.h>
-#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "cctk.h"
#include "cctk_Parameters.h"
-#include "cctk_DefineThorn.h"
-#include "ioPandaGH.h"
-#include "Panda/c_interface.h"
#include "CactusBase/IOUtil/src/ioGH.h"
-#ifdef CACTUSPUGH_PUGH
#include "CactusPUGH/PUGH/src/include/pugh.h"
-#endif
-#ifdef SGI
-#include <time.h>
-#endif
-
#include "external/IEEEIO/src/IOProtos.h"
+#include "ioPandaGH.h"
+#include "Panda/c_interface.h"
+
int IOPanda_Output3DVarAs (cGH *GH, const char *var, const char *alias);
int IOPanda_TimeFor3D (cGH *GH, int index);
@@ -43,10 +36,9 @@ void IOPanda_IEEEIOStructDump (cGH *GH, char *fname);
@enddesc
@calls CCTK_GHExtensionHandle
CCTK_NumVars
- CCTK_ImplementationFromVar
CCTK_VarName
IOPanda_TimeFor3D
- IOPanda_Output3DVarAs
+ IOPanda_Timestep
@calledby
@history
@@ -63,41 +55,30 @@ int IOPanda_Output3DGH (cGH *GH)
{
int i;
pandaGH *myGH;
- char *implementation;
- char *name;
- char *fullname;
DECLARE_CCTK_PARAMETERS
/* Get the GH extension for IOPanda */
myGH = (pandaGH *) GH->extensions [CCTK_GHExtensionHandle ("IOPanda")];
- if (myGH->IO_3Devery <= 0)
- return;
+ if (myGH->out3D_every <= 0)
+ return (0);
/* Loop over all variables */
for (i = 0; i < CCTK_NumVars (); i++) {
if (IOPanda_TimeFor3D (GH, i)) {
- implementation = CCTK_ImpFromVarI (i);
- name = CCTK_VarName (i);
- fullname = (char *) malloc (strlen (implementation) +
- strlen (name) + 3);
- assert (fullname);
- sprintf (fullname, "%s::%s", implementation, name);
-
if (verbose) {
+ char *fullname = CCTK_FullName (i);
+
printf ("IOPanda Output3DGH : \n");
- printf (" fullname/name = %s/%s\n", fullname, name);
+ printf (" index/fullname = %d/%s\n", i, fullname);
+ free (fullname);
}
- IOPanda_Output3DVarAs (GH, fullname, name);
-
- free (fullname);
+ /* Do the 3D output */
+ IOPanda_Timestep (GH, i, CCTK_VarName (i));
- /* Register another 3D output for this GF */
- myGH->IO_3Dnum [i]++;
-
- /* Register GF as having 3D output this iteration */
- myGH->IO_3Dlast [i] = GH->cctk_iteration;
+ /* Register variable as having 3D output this iteration */
+ myGH->out3D_last [i] = GH->cctk_iteration;
}
}
@@ -144,18 +125,12 @@ int IOPanda_Output3DVarAs (cGH *GH, const char *fullname, const char *alias)
{
DECLARE_CCTK_PARAMETERS
int index;
- pandaGH *myGH;
index = CCTK_VarIndex(fullname);
- /* Get the GH extension for IOPanda */
- myGH = (pandaGH *) GH->extensions [CCTK_GHExtensionHandle ("IOPanda")];
-
if (verbose) {
printf ("\nIn IOPanda Output3DVarAs\n-------------------\n");
- printf (" Fullname = -%s-\n", fullname);
- printf (" Alias = -%s-\n", alias);
- printf (" Index = %d\n", index);
+ printf (" index/fullname/alias = %d/%s/%s\n", index, fullname, alias);
}
/* Do the 3D output */
@@ -173,11 +148,6 @@ int IOPanda_Output3DVarAs (cGH *GH, const char *fullname, const char *alias)
Decides if it is time to output a variable using the IOPanda 3D output
method
@enddesc
- @calls CCTK_GHExtensionHandle
- CCTK_GroupTypeFromVarI
- CCTK_WARN
- CCTK_QueryGroupStorageI
- CCTK_GroupNameFromVarI
@calledby IOPanda_Output3DGH
@history
@@ -203,28 +173,18 @@ int IOPanda_TimeFor3D (cGH *GH, int index)
/* Get the GH extension for IOPanda */
myGH = (pandaGH *) GH->extensions [CCTK_GHExtensionHandle ("IOPanda")];
- /* Check this GF should be output */
- if (! (myGH->IO_3Dnum [index] != 0 &&
- GH->cctk_iteration % myGH->IO_3Devery == 0))
+ /* Check this variable should be output */
+ if (! (myGH->do_out3D [index] && GH->cctk_iteration % myGH->out3D_every == 0))
return (0);
- /* Check GF not already output this iteration */
- if (myGH->IO_3Dlast [index] == GH->cctk_iteration) {
- CCTK_WARN (2, "Already done 3D output in IOPanda");
- return (0);
- }
-
- /* Check GF has storage */
- if (! CCTK_QueryGroupStorageI (GH,
- CCTK_GroupIndexFromVarI(index))) {
- char *fullname = CCTK_FullName (index);
- char *msg = (char *) malloc (80 + strlen (fullname));
+ /* Check variable not already output this iteration */
+ if (myGH->out3D_last [index] == GH->cctk_iteration) {
+ char *fullname = CCTK_FullName (index);
- sprintf (msg, "No IOPandaIO 3D output for '%s' (no storage)", fullname);
- CCTK_WARN (2, msg);
- free (fullname);
- free (msg);
- return (0);
+ CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Already done IOPanda 3D output for '%s'", fullname);
+ free (fullname);
+ return (0);
}
return (1);
@@ -264,7 +224,7 @@ int IOPanda_TriggerOutput3D (cGH *GH, int index)
{
DECLARE_CCTK_PARAMETERS
pandaGH *myGH;
- char *varname;
+ const char *varname;
varname = CCTK_VarName (index);
@@ -273,23 +233,19 @@ int IOPanda_TriggerOutput3D (cGH *GH, int index)
if (verbose) {
printf("\nIn IOPanda TriggerOutput3D\n---------------------\n");
- printf(" Index = %d\n", index);
- printf(" Variable = -%s-\n", varname);
+ printf(" index/name = %d/%s\n", index, varname);
}
/* Do the 3D output */
IOPanda_Timestep (GH, index, varname);
- /* Register another 3D output for this GF */
- myGH->IO_3Dnum [index]++;
-
- /* Register GF as having 3D output this iteration */
- myGH->IO_3Dlast [index] = GH->cctk_iteration;
+ /* Register variable as having 3D output this iteration */
+ myGH->out3D_last [index] = GH->cctk_iteration;
return (0);
}
-void IOPanda_Timestep(cGH *GH, int index, const char *alias)
+void IOPanda_Timestep (cGH *GH, int index, const char *alias)
{
DECLARE_CCTK_PARAMETERS
void *data;
@@ -307,8 +263,19 @@ void IOPanda_Timestep(cGH *GH, int index, const char *alias)
return;
}
+ /* check if variable has storage assigned */
+ if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (index))) {
+ char *fullname = CCTK_FullName (index);
+
+ CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "No IOPanda 3D output for '%s' (no storage)", fullname);
+ free (fullname);
+ return;
+ }
+
+ /* get the handles for PUGH and IOUtil GH extensions */
+ pughGH = PUGH_pGH (GH);
ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
- pughGH = (pGH *) GH->extensions [CCTK_GHExtensionHandle ("PUGH")];
ainfo.name_ = (char *)alias;
@@ -342,8 +309,11 @@ void IOPanda_Timestep(cGH *GH, int index, const char *alias)
}
}
+ /* FIXME: rank */
ainfo.mem_rank_ = 3;
- tmp2[0] = pughGH->nprocz; tmp2[1] = pughGH->nprocy; tmp2[2] = pughGH->nprocx;
+ tmp2[0] = pughGH->Connectivity [2]->nprocs [2];
+ tmp2[1] = pughGH->Connectivity [2]->nprocs [1];
+ tmp2[2] = pughGH->Connectivity [2]->nprocs [0];
ainfo.mem_layout_ = tmp2;
dist1[0] = dist1[1] = dist1[2] = BLOCK;
ainfo.mem_dist_ = dist1;
@@ -361,12 +331,18 @@ void IOPanda_Timestep(cGH *GH, int index, const char *alias)
IOPanda_getDumpData(GH, index, timelevel, &data, &free_flag, bnd,
ainfo.esize_);
ainfo.data_ = (char *)data;
- ainfo.stencil_width_ = pughGH->nghostzones;
+ /*** FIXME: asymmetric ghostzones */
+ ainfo.stencil_width_ = GH->cctk_nghostzones [0];
PandaTimestep(&ainfo);
+ if (free_flag)
+ free (data);
+
IOPanda_AddCommonAttributes(GH, index, timelevel, ainfo.size_, ainfo.name_);
- if (PandaIsNewFile(ainfo.name_)) IOPanda_IEEEIOStructDump(GH, ainfo.name_);
+
+ if (PandaIsNewFile(ainfo.name_))
+ IOPanda_IEEEIOStructDump(GH, ainfo.name_);
}
void IOPanda_AddCommonAttributes (cGH *GH, int index, int timelevel,
@@ -425,14 +401,15 @@ void IOPanda_AddCommonAttributes (cGH *GH, int index, int timelevel,
Panda_WriteAttribute (fname, "min_ext",FLOAT64,3,d3_to_IO);
Panda_WriteAttribute (fname, "max_ext",FLOAT64, 3,d3_to_IO+3);
- d3_to_IO [0] = GH->cctk_delta_space [0] * ioUtilGH->downsample_x;
- d3_to_IO [1] = GH->cctk_delta_space [1] * ioUtilGH->downsample_y;
- d3_to_IO [2] = GH->cctk_delta_space [2] * ioUtilGH->downsample_z;
+ /* FIXME: dimension */
+ d3_to_IO [0] = GH->cctk_delta_space [0] * ioUtilGH->downsample[0];
+ d3_to_IO [1] = GH->cctk_delta_space [1] * ioUtilGH->downsample[1];
+ d3_to_IO [2] = GH->cctk_delta_space [2] * ioUtilGH->downsample[2];
Panda_WriteAttribute (fname, "delta", FLOAT64, 3,d3_to_IO);
- if (ioUtilGH->downsample_x > 1 ||
- ioUtilGH->downsample_y > 1 ||
- ioUtilGH->downsample_z > 1) {
+ if (ioUtilGH->downsample[0] > 1 ||
+ ioUtilGH->downsample[1] > 1 ||
+ ioUtilGH->downsample[2] > 1) {
d3_to_IO [0] = GH->cctk_delta_space [0];
d3_to_IO [1] = GH->cctk_delta_space [1];
d3_to_IO [2] = GH->cctk_delta_space [2];