aboutsummaryrefslogtreecommitdiff
path: root/src/ChooseOutput.c
blob: a1b4955ca18e34cec716d8272c047d98c85c0a83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*@@
  @file ChooseOutput.c
  @author Gabrielle Allen
  @date July 6 2000
  @desc
  Choose what data to write for different IO methods in IOHDF5
  @enddesc 

  @history
  @hauthor 
  @hdesc 
  @version $Header$
@@*/

#include "cctk.h"
#include "cctk_Arguments.h"
#include "cctk_Parameters.h"
#include "CactusBase/IOUtil/src/ioGH.h"
#include "ioFlexGH.h"

static char *rcsid = "$Header$";
CCTK_FILEVERSION(CactusPUGHIO_IOHDF5_ChooseOutput_c)


/*@@
  @routine IOFlexIO_Choose2D
  @author Gabrielle Allen
  @date July 6 2000
  @desc
  Use parameters to choose the 2D planes through the output data. 
  @enddesc

  @history
  @hauthor 
  @hdesc 
  @version $Header$
@@*/

void IOFlexIO_Choose2D(CCTK_ARGUMENTS)
{
  DECLARE_CCTK_PARAMETERS

  int i;
  int maxdim;
  flexioGH *myGH;                   /* FlexIO extension handle */
  CCTK_INT *origin_index;           /* Specify output planes by indices */
  CCTK_REAL *origin_phys;           /* Specify output planes by coordinates */
  cGroup groupinfo;                 /* variable's group info */

  myGH     = (flexioGH *) cctkGH->extensions 
    [CCTK_GHExtensionHandle ("IOFlexIO")];

  /* Set up lines to be output */
  maxdim = CCTK_MaxDim();
  origin_phys     = (CCTK_REAL *)calloc(maxdim*sizeof(CCTK_REAL ));
  origin_index    = (CCTK_INT  *)calloc(maxdim*sizeof(CCTK_INT ));
    
  /* Set parameters using 
     1. Indices from IOFlexIO
     2. Indices from IOUtil
     3. Coords from IOFlexIO
     4. Coords from IOUtil
  */

  if (CCTK_ParameterQueryTimesSet("out2D_yzplane_xi","IOFlexIO")>0)
  {
    origin_index[0] = out2D_yzplane_xi;
  }
  else if (CCTK_ParameterQueryTimesSet("out_yzplane_xi","IOUtil")>0)
  {
    origin_index[0] = out_yzplane_xi;
  }
  else
  {
    origin_index[0]  = -1;
    if (CCTK_ParameterQueryTimesSet("out2D_yzplane_x","IOFlexIO")>0)
    {
      origin_phys[0] = out2D_yzplane_x;
    }
    else
    {
      origin_phys[0] = out_yzplane_x;
    }
  }

  if (CCTK_ParameterQueryTimesSet("out2D_xzplane_yi","IOFlexIO")>0)
  {
    origin_index[1] = out2D_xzplane_yi;
  } 
  else if (CCTK_ParameterQueryTimesSet("out_xzplane_yi","IOUtil")>0)
  {
    origin_index[1] = out_xzplane_yi;
  }
  else
  {
    origin_index[1]  = -1;
    if (CCTK_ParameterQueryTimesSet("out2D_xzplane_y","IOFlexIO")>0)
    {
      origin_phys[1] = out2D_xzplane_y;
    }
    else
    {
      origin_phys[1] = out_xzplane_y;
    }
  }

  if (CCTK_ParameterQueryTimesSet("out2D_xyplane_zi","IOFlexIO")>0)
  {
    origin_index[2] = out2D_xyplane_zi;
  }
  else if (CCTK_ParameterQueryTimesSet("out_xyplane_zi","IOUtil")>0)
  {
    origin_index[2] = out_xyplane_zi;
  }
  else
  {
    origin_index[2]  = -1;
    if (CCTK_ParameterQueryTimesSet("out2D_xyplane_z","IOFlexIO")>0)
    {
      origin_phys[2] = out2D_xyplane_z;
    }
    else
    {
      origin_phys[2] = out_xyplane_z;
    }
  }

  if (myGH) 
  {
    for (i=1;i<=CCTK_MaxDim();i++)
    {
      IOUtil_2DPlanes (cctkGH, i, origin_index, 
		       origin_phys, myGH->sp2xyz[i-1]);
    }
  }
  else
  {
    CCTK_WARN(1,"IOFlexIO_Choose2D: FlexIO GH extension not found");
  }

  return;
}