From d670632ee12507b1d4ac2e6348edc7b6e6b5278c Mon Sep 17 00:00:00 2001 From: cvs_anon <> Date: Tue, 23 Sep 2003 10:35:00 +0000 Subject: New file containing util routines. darcs-hash:20030923103550-62b91-5ab4d33553469e5e3298597d0148cf4ed1ecdc8a.gz --- .../CarpetIOFlexIOCheckpoint/src/ioflexioUtil.cc | 164 +++++++++------------ 1 file changed, 70 insertions(+), 94 deletions(-) (limited to 'CarpetAttic') diff --git a/CarpetAttic/CarpetIOFlexIOCheckpoint/src/ioflexioUtil.cc b/CarpetAttic/CarpetIOFlexIOCheckpoint/src/ioflexioUtil.cc index 1342cbfa5..8d9af6b5b 100644 --- a/CarpetAttic/CarpetIOFlexIOCheckpoint/src/ioflexioUtil.cc +++ b/CarpetAttic/CarpetIOFlexIOCheckpoint/src/ioflexioUtil.cc @@ -30,6 +30,10 @@ #undef BYTE #undef CHAR +//#include "CactusBase/IOUtil/src/ioGH.h" +//#include "CactusBase/IOUtil/src/ioutil_CheckpointRecovery.h" +//#include "CactusBase/IOUtil/src/ioutil_Utils.h" + #include "bbox.hh" #include "data.hh" #include "gdata.hh" @@ -46,9 +50,9 @@ namespace CarpetIOFlexIOUtil { using namespace Carpet; using namespace CarpetIOFlexIO; - IObase::DataType FlexIODataType (int cctk_type){ - //we need this to have the FlexIO data types on hand - //for WriteGFAs +IObase::DataType FlexIODataType (int cctk_type){ + //we need this to have the FlexIO data types on hand + //for WriteGFAs int retval; @@ -86,102 +90,74 @@ namespace CarpetIOFlexIOUtil { } - void DumpCommonAttributes (const cGH *cgh, IObase* writer, ioRequest* request) - { - int tl; - CCTK_INT attr_int,dimscalar; - DECLARE_CCTK_PARAMETERS; - - /* attributes describing the variable */ - - char *name = CCTK_FullName (request->vindex); - WriteAttribute(writer,"name",name); - free(name); - - char* groupname = CCTK_GroupNameFromVarI (request->vindex); - WriteAttribute(writer,"groupname",groupname); - free (groupname); - - WriteAttribute(writer,"grouptype",CCTK_GroupTypeFromVarI (request->vindex)); - WriteAttribute(writer,"reflevel",reflevel); - WriteAttribute(writer,"component",component); - WriteAttribute(writer,"mglevel",mglevel); - - - WriteAttribute (writer,"ntimelevels",CCTK_MaxTimeLevelsVI (request->vindex)); - - // lets get the correct Carpet time level (which is the (-1) * timelevel): - if (request->timelevel==0) - tl = 0; - else - tl = - request->timelevel; - WriteAttribute (writer, "timelevel", tl); - - WriteAttribute (writer, "carpet_flexio_version", 1); - WriteAttribute (writer, "cctk_dim", cgh->cctk_dim); - WriteAttribute (writer, "cctk_iteration", cgh->cctk_iteration); - WriteAttribute (writer, "cctk_gsh", cgh->cctk_gsh, dim); - WriteAttribute (writer, "cctk_lsh", cgh->cctk_lsh, dim); - WriteAttribute (writer, "cctk_lbnd", cgh->cctk_lbnd, dim); - WriteAttribute (writer, "cctk_delta_time", cgh->cctk_delta_time); - WriteAttribute (writer, "cctk_delta_space", cgh->cctk_delta_space, dim); - WriteAttribute (writer, "cctk_origin_space", cgh->cctk_origin_space, dim); - WriteAttribute (writer, "cctk_bbox", cgh->cctk_bbox, 2*dim); - WriteAttribute (writer, "cctk_levfac", cgh->cctk_levfac, dim); - WriteAttribute (writer, "cctk_levoff", cgh->cctk_levoff, dim); - WriteAttribute (writer, "cctk_levoffdenom", cgh->cctk_levoffdenom, dim); - WriteAttribute (writer, "cctk_timefac", cgh->cctk_timefac); - WriteAttribute (writer, "cctk_convlevel", cgh->cctk_convlevel); - WriteAttribute (writer, "cctk_nghostzones", cgh->cctk_nghostzones, dim); - WriteAttribute (writer, "cctk_time", cgh->cctk_time); - } +void DumpCommonAttributes (const cGH *cgh, IObase* writer, ioRequest* request) +{ + int dim, vdim; + CCTK_INT attr_int; + CCTK_REAL *attr_real; + char coord_system_name[20]; + DECLARE_CCTK_PARAMETERS - - void WriteAttribute (IObase* writer, const char* name, int value) - { - WriteAttribute (writer, name, &value, 1); - } - - void WriteAttribute (IObase* writer, const char* name, - const int* values, int nvalues) - { - assert (writer); - assert (name); - assert (values); - vector values1(nvalues); - for (int i=0; iwriteAttribute (name, IObase::Int32, nvalues, &values1[0]); - } - - void WriteAttribute (IObase* writer, const char* name, CCTK_REAL value) - { - WriteAttribute (writer, name, &value, 1); - } - - void WriteAttribute (IObase* writer, const char* name, - const CCTK_REAL* values, int nvalues) + int varindex = request->vindex; + + /* attributes describing the variable */ + char* groupname = CCTK_GroupNameFromVarI (varindex); + + //DEBUG + //CCTK_VInfo (CCTK_THORNSTRING, "DUMPATTRIB reflevel,component,mglevel %d,%d,%d",reflevel,component,mglevel); + + writer->writeAttribute("groupname",IObase::Char,strlen(groupname)+1,groupname); + free (groupname); + + CCTK_INT attr_int = CCTK_GroupTypeFromVarI (varindex); + writer->writeAttribute("grouptype",FlexIODataType(CCTK_VARIABLE_INT),1,&attr_int); + + writer->writeAttribute("reflevel",FlexIODataType(CCTK_VARIABLE_INT),1,&reflevel); + writer->writeAttribute("component",FlexIODataType(CCTK_VARIABLE_INT),1,&component); + writer->writeAttribute("mglevel",FlexIODataType(CCTK_VARIABLE_INT),1,&mglevel); + + attr_int = CCTK_MaxTimeLevelsVI (varindex); + writer->writeAttribute("ntimelevels",FlexIODataType(CCTK_VARIABLE_INT),1,&attr_int); + + writer->writeAttribute("timelevel",FlexIODataType(CCTK_VARIABLE_INT),1,&request->timelevel); + + writer->writeAttribute("global_size",FlexIODataType(CCTK_VARIABLE_INT),request->hdim,request->hsize); + writer->writeAttribute("time",FlexIODataType(CCTK_VARIABLE_REAL),1,&cgh->cctk_time); + + /* attributes describing the underlying grid + These are only stored for CCTK_GF variables if they are associated + with coordinates. */ + /* FIXME: This is hardcoded for cartesian coordinate systems. + A better solution would be to be able to query the coordinate + system which is associated with the variable. */ + vdim = CCTK_GroupDimFromVarI (request->vindex); + sprintf (coord_system_name, "cart%dd", vdim); + if (CCTK_GroupTypeFromVarI (request->vindex) == CCTK_GF && + CCTK_CoordSystemHandle (coord_system_name) >= 0) { - assert (writer); - assert (name); - assert (values); - vector values1(nvalues); - for (int i=0; iorigin[dim] * cgh->cctk_delta_space[dim]; + attr_real[dim + 2*vdim] = + cgh->cctk_delta_space[dim] * request->downsample[dim]; + attr_real[dim + 1*vdim] = attr_real[dim + 0*vdim] + + ((request->extent[dim] + request->downsample[dim]-1) / + request->downsample[dim] - 1) * attr_real[dim + 2*vdim]; } - writer->writeAttribute (name, IObase::Float64, nvalues, &values1[0]); - } - void WriteAttribute (IObase* writer, const char* name, - const char* valuestring) - { - assert (writer); - assert (name); - assert (valuestring); - writer->writeAttribute (name, IObase::String, strlen(valuestring)+1, valuestring); + writer->writeAttribute ("origin", FlexIODataType(CCTK_VARIABLE_REAL), vdim, attr_real); + writer->writeAttribute ("min_ext", FlexIODataType(CCTK_VARIABLE_REAL), vdim, attr_real); + writer->writeAttribute ("max_ext", FlexIODataType(CCTK_VARIABLE_REAL), vdim, attr_real+vdim); + writer->writeAttribute ("delta", FlexIODataType(CCTK_VARIABLE_REAL), vdim, attr_real+2*vdim); + free (attr_real); } - +} + } // namespace CarpetIOFlexIOUtil -- cgit v1.2.3