aboutsummaryrefslogtreecommitdiff
path: root/src/ChooseOutput.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ChooseOutput.c')
-rw-r--r--src/ChooseOutput.c75
1 files changed, 42 insertions, 33 deletions
diff --git a/src/ChooseOutput.c b/src/ChooseOutput.c
index ca6a739..55fb071 100644
--- a/src/ChooseOutput.c
+++ b/src/ChooseOutput.c
@@ -3,7 +3,7 @@
@author Gabrielle Allen
@date July 6 2000
@desc
- Choose what data to write for different IO methods in IOASCII
+ Choose what 1D slices and 2D planes to output by IOASCII.
@enddesc
@version $Id$
@@ -13,7 +13,6 @@
#include <string.h>
#include "cctk.h"
-#include "cctk_Arguments.h"
#include "cctk_Parameters.h"
#include "CactusBase/IOUtil/src/ioutil_Utils.h"
#include "ioASCIIGH.h"
@@ -23,6 +22,9 @@ static const char *rcsid = "$Header$";
CCTK_FILEVERSION(CactusBase_IOASCII_ChooseOutput_c)
+/********************************************************************
+ ******************** Macro Definitions ************************
+ ********************************************************************/
/* macro to choose origin according actual parameter settings:
1. Indices from IOASCII
2. Indices from IOUtil
@@ -30,6 +32,7 @@ CCTK_FILEVERSION(CactusBase_IOASCII_ChooseOutput_c)
4. Coords from IOUtil
*/
#define GET_SLICE(IOASCII_param, IOUtil_param, origin_index, origin_phys) \
+ { \
origin_index = -1; \
if (CCTK_ParameterQueryTimesSet (#IOASCII_param "i", "IOASCII") > 0)\
{ \
@@ -46,11 +49,15 @@ CCTK_FILEVERSION(CactusBase_IOASCII_ChooseOutput_c)
else \
{ \
origin_phys = IOUtil_param; \
- }
+ } \
+ }
+
-/* prototypes of routines defined in this source file */
-void IOASCII_Choose1D (cGH *GH);
-void IOASCII_Choose2D (cGH *GH);
+/********************************************************************
+ ******************** External Routines ************************
+ ********************************************************************/
+void IOASCII_Choose1D (const cGH *GH);
+void IOASCII_Choose2D (const cGH *GH);
/*@@
@@ -58,7 +65,7 @@ void IOASCII_Choose2D (cGH *GH);
@author Gabrielle Allen
@date July 6 2000
@desc
- Use parameters to choose the 1D slices through the output data.
+ Use parameters to choose the 1D slices through the output data.
@enddesc
@calls CCTK_ParameterQueryTimesSet
@@ -66,17 +73,17 @@ void IOASCII_Choose2D (cGH *GH);
@var GH
@vdesc Pointer to CCTK grid hierarchy
- @vtype cGH *
+ @vtype const cGH *
@vio in
@endvar
@@*/
-void IOASCII_Choose1D (cGH *GH)
+void IOASCII_Choose1D (const cGH *GH)
{
- DECLARE_CCTK_PARAMETERS
- int i, j;
+ int i, j, maxdim;
asciiioGH *myGH;
int *origin_index[3];
CCTK_REAL *origin_phys[3];
+ DECLARE_CCTK_PARAMETERS
/* allocate arrays for origins */
@@ -95,20 +102,22 @@ void IOASCII_Choose1D (cGH *GH)
GET_SLICE (out1D_zline_x, out_zline_x, origin_index[2][0], origin_phys[2][0]);
GET_SLICE (out1D_zline_y, out_zline_y, origin_index[2][1], origin_phys[2][1]);
+ maxdim = CCTK_MaxDim ();
myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII");
+ myGH->spxyz = (int ***) malloc (maxdim * sizeof (int **));
- for (i = 1; i <= CCTK_MaxDim (); i++)
+ for (i = 0; i < maxdim; i++)
{
- if (i <= 3)
+ myGH->spxyz[i] = (int **) malloc ((i + 1) * sizeof (int *));
+
+ for (j = 0; j <= i; j++)
{
- IOUtil_1DLines (GH, i, origin_index, origin_phys, myGH->spxyz[i-1]);
+ myGH->spxyz[i][j] = (int *) calloc (i + 1, sizeof (int));
}
- else
+
+ if (i < 3)
{
- for (j = 0; j < i; j++)
- {
- memset (myGH->spxyz[i-1][j], 0, i);
- }
+ IOUtil_1DLines (GH, i + 1, origin_index, origin_phys, myGH->spxyz[i]);
}
}
@@ -123,7 +132,7 @@ void IOASCII_Choose1D (cGH *GH)
@author Gabrielle Allen
@date July 6 2000
@desc
- Use parameters to choose the 2D slices through the output data.
+ Use parameters to choose the 2D slices through the output data.
@enddesc
@calls CCTK_ParameterQueryTimesSet
@@ -131,34 +140,34 @@ void IOASCII_Choose1D (cGH *GH)
@var GH
@vdesc Pointer to CCTK grid hierarchy
- @vtype cGH *
+ @vtype const cGH *
@vio in
@endvar
@@*/
-void IOASCII_Choose2D (cGH *GH)
+void IOASCII_Choose2D (const cGH *GH)
{
+ int i, maxdim;
+ asciiioGH *myGH;
+ int origin_index[3];
+ CCTK_REAL origin_phys[3];
DECLARE_CCTK_PARAMETERS
- int i;
- asciiioGH *myGH; /* IOASCII extension handle */
- int origin_index[3]; /* Specify output planes by indices */
- CCTK_REAL origin_phys[3]; /* Specify output planes by coordinates */
GET_SLICE (out2D_xyplane_z, out_xyplane_z, origin_index[0], origin_phys[0]);
GET_SLICE (out2D_xzplane_y, out_xzplane_y, origin_index[1], origin_phys[1]);
GET_SLICE (out2D_yzplane_x, out_yzplane_x, origin_index[2], origin_phys[2]);
+ maxdim = CCTK_MaxDim ();
myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII");
+ myGH->sp2xyz = (int **) malloc (3 * sizeof (int *));
- for (i = 1; i <= CCTK_MaxDim (); i++)
+ for (i = 0; i < maxdim; i++)
{
- if (i > 1 && i <= 3)
- {
- IOUtil_2DPlanes (GH, i, origin_index, origin_phys, myGH->sp2xyz[i-1]);
- }
- else
+ myGH->sp2xyz[i] = (int *) calloc (i + 1, sizeof (int));
+
+ if (i > 0 && i < 3)
{
- memset (myGH->sp2xyz[i-1], 0, i * sizeof (myGH->sp2xyz[i-1][0]));
+ IOUtil_2DPlanes (GH, i + 1, origin_index, origin_phys, myGH->sp2xyz[i]);
}
}
}