From 2886017da6a48c67eac9d428975b47f9bfc454b4 Mon Sep 17 00:00:00 2001 From: schnetter <> Date: Mon, 1 Mar 2004 21:22:00 +0000 Subject: Replace [] array accesses with .at() array accesses. Replace [] array accesses with .at() array accesses. Track and check whether all grid points of a variable have been initialised. Abort if it is not so. darcs-hash:20040301212246-07bb3-4b03051d52085be708bdf6643fbdd899512cf56e.gz --- CarpetAttic/CarpetIOFlexIO/src/ioflexio.cc | 40 ++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'CarpetAttic') diff --git a/CarpetAttic/CarpetIOFlexIO/src/ioflexio.cc b/CarpetAttic/CarpetIOFlexIO/src/ioflexio.cc index fec40357d..f4384bba4 100644 --- a/CarpetAttic/CarpetIOFlexIO/src/ioflexio.cc +++ b/CarpetAttic/CarpetIOFlexIO/src/ioflexio.cc @@ -15,7 +15,7 @@ #include "cctk_Parameters.h" extern "C" { - static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/CarpetAttic/CarpetIOFlexIO/src/ioflexio.cc,v 1.44 2004/02/27 16:23:34 schnetter Exp $"; + static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/CarpetAttic/CarpetIOFlexIO/src/ioflexio.cc,v 1.45 2004/03/01 22:22:46 schnetter Exp $"; CCTK_FILEVERSION(Carpet_CarpetIOFlexIO_ioflexio_cc); } @@ -322,8 +322,8 @@ namespace CarpetIOFlexIO { const ggf* ff = 0; - assert (var < (int)arrdata[group][Carpet::map].data.size()); - ff = (ggf*)arrdata[group][Carpet::map].data[var]; + assert (var < (int)arrdata.at(group).at(Carpet::map).data.size()); + ff = (ggf*)arrdata.at(group).at(Carpet::map).data.at(var); const gdata* const data = (*ff) (tl, rl, component, mglevel); @@ -441,7 +441,7 @@ namespace CarpetIOFlexIO { WriteAttribute (writer, "carpet_map", Carpet::map); WriteAttribute (writer, "carpet_maps", maps); WriteAttribute (writer, "carpet_component", component); - WriteAttribute (writer, "carpet_components", vhh[Carpet::map]->components(reflevel)); + WriteAttribute (writer, "carpet_components", vhh.at(Carpet::map)->components(reflevel)); } // Delete temporary copy @@ -677,6 +677,7 @@ namespace CarpetIOFlexIO { // Read some datasets bool did_read_something = false; + vector regions_read(Carpet::maps); for (int dataset=0; dataset* ff = 0; - assert (var < (int)arrdata[group][Carpet::map].data.size()); - ff = (ggf*)arrdata[group][Carpet::map].data[var]; + assert (var < (int)arrdata.at(group).at(Carpet::map).data.size()); + ff = (ggf*)arrdata.at(group).at(Carpet::map).data.at(var); gdata* const data = (*ff) (tl, rl, component, mglevel); @@ -770,6 +771,7 @@ namespace CarpetIOFlexIO { // Initialise with what is found in the file -- this does // not guarantee that everything is initialised. const bbox overlap = tmp->extent() & data->extent(); + regions_read.at(Carpet::map) |= overlap; // Copy into grid function for (comm_state state; !state.done(); state.step()) { @@ -803,6 +805,22 @@ namespace CarpetIOFlexIO { reader = 0; } + // Was everything initialised? + if (did_read_something) { + for (int m=0; m& thedd = *arrdata.at(group).at(m).dd; + ibset all_exterior; + for (size_t c=0; c values1(alength); - reader->readAttribute (attrnum, &values1[0]); + reader->readAttribute (attrnum, &values1.at(0)); for (int i=0; i values1(alength); - reader->readAttribute (attrnum, &values1[0]); + reader->readAttribute (attrnum, &values1.at(0)); for (int i=0; i values1(alength); - reader->readAttribute (attrnum, &values1[0]); + reader->readAttribute (attrnum, &values1.at(0)); for (int i=0; iwriteAttribute (name, IObase::Int32, nvalues, &values1[0]); + writer->writeAttribute (name, IObase::Int32, nvalues, &values1.at(0)); } void WriteAttribute (IObase* writer, const char* name, CCTK_REAL value) @@ -1050,7 +1068,7 @@ namespace CarpetIOFlexIO { for (int i=0; iwriteAttribute (name, IObase::Float64, nvalues, &values1[0]); + writer->writeAttribute (name, IObase::Float64, nvalues, &values1.at(0)); } void WriteAttribute (IObase* writer, const char* name, char value) -- cgit v1.2.3