diff options
author | tradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a> | 2002-04-17 18:01:50 +0000 |
---|---|---|
committer | tradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a> | 2002-04-17 18:01:50 +0000 |
commit | e7b5e1e51708eca4912aed95860f06a8b5a522f1 (patch) | |
tree | f6062873e2e0cf56b3e64fe6889fb7c9338b3fad /src/ChooseOutput.c | |
parent | f7f7a801866271138a1888a493ae0c50ca372b52 (diff) |
Tidying up the code to make it consistent with the structure in IOHDF5.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOFlexIO/trunk@230 ebee0441-1374-4afa-a3b5-247f3ba15b9a
Diffstat (limited to 'src/ChooseOutput.c')
-rw-r--r-- | src/ChooseOutput.c | 194 |
1 files changed, 73 insertions, 121 deletions
diff --git a/src/ChooseOutput.c b/src/ChooseOutput.c index 3f9b2fb..896af8c 100644 --- a/src/ChooseOutput.c +++ b/src/ChooseOutput.c @@ -1,149 +1,101 @@ -/*@@ - @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$ + /*@@ + @file ChooseOutput.c + @author Gabrielle Allen + @date July 6 2000 + @desc + Choose what data to write for different I/O methods in IOFlexIO + @enddesc + @version $Id$ @@*/ #include <stdlib.h> #include "cctk.h" -#include "cctk_Arguments.h" #include "cctk_Parameters.h" #include "CactusBase/IOUtil/src/ioutil_Utils.h" #include "ioFlexGH.h" +/* the rcs ID and its dummy function to use it */ static const char *rcsid = "$Header$"; CCTK_FILEVERSION(CactusPUGHIO_IOFlexIO_ChooseOutput_c) -/* prototypes of routines defined in this source file */ -void IOFlexIO_Choose2D(CCTK_ARGUMENTS); - - -/*@@ - @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 */ - int *origin_index; /* Specify output planes by indices */ - CCTK_REAL *origin_phys; /* Specify output planes by coordinates */ - - 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 = (int *)calloc(maxdim,sizeof(int )); - - /* Set parameters using +/******************************************************************** + ******************** Macro Definitions ************************ + ********************************************************************/ +/* macro to choose origin according actual parameter settings: 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; - } - } + */ +#define GET_SLICE(my_param, IOUtil_param, origin_index, origin_phys) \ + { \ + origin_index = -1; \ + if (CCTK_ParameterQueryTimesSet (#my_param "i", "IOFlexIO") > 0) \ + { \ + origin_index = my_param##i; \ + } \ + else if (CCTK_ParameterQueryTimesSet (#IOUtil_param "i", "IOUtil")>0)\ + { \ + origin_index = IOUtil_param##i; \ + } \ + else if (CCTK_ParameterQueryTimesSet (#my_param, "IOFlexIO") > 0) \ + { \ + origin_phys = my_param; \ + } \ + else \ + { \ + origin_phys = IOUtil_param; \ + } \ + } + + +/******************************************************************** + ******************** External Routines ************************ + ********************************************************************/ +void IOFlexIO_Choose2D (cGH *GH); + + + /*@@ + @routine IOFlexIO_Choose2D + @author Gabrielle Allen + @date July 6 2000 + @desc + Use parameters to choose the 2D planes through the output data. + @enddesc +@@*/ +void IOFlexIO_Choose2D (cGH *GH) +{ + int i; + flexioGH *myGH; + int origin_index[3]; + CCTK_REAL origin_phys[3]; + DECLARE_CCTK_PARAMETERS - 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) + /* get the handle for IOFlexIO extensions */ + myGH = (flexioGH *) CCTK_GHExtension (GH, "IOFlexIO"); + if (myGH == NULL) { - origin_index[2] = out_xyplane_zi; + CCTK_WARN (1, "IOFlexIO_Choose2D: IOFlexIO GH extension not found"); } 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; - } - } + 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]); - if (myGH) - { - for (i=1;i<=CCTK_MaxDim();i++) + for (i = 1; i <= CCTK_MaxDim (); i++) { - IOUtil_2DPlanes (cctkGH, i, origin_index, - origin_phys, myGH->sp2xyz[i-1]); + if (i > 1 && i <= 3) + { + IOUtil_2DPlanes (GH, i, origin_index, origin_phys, myGH->sp2xyz[i-1]); + } + else + { + memset (myGH->sp2xyz[i-1], 0, i * sizeof (myGH->sp2xyz[i-1][0])); + } } } - else - { - CCTK_WARN(1,"IOFlexIO_Choose2D: FlexIO GH extension not found"); - } - - return; } - - |