From 245ff0db067dcb4f22095e539c2364620f8504d2 Mon Sep 17 00:00:00 2001 From: cott <> Date: Thu, 11 Mar 2004 23:13:00 +0000 Subject: Recovery sort of working - does not crash, but does the strangest things... I have to fix this tomorrow with Erik's help. Recovery sort of working - does not crash, but does the strangest things... I have to fix this tomorrow with Erik's help. Good night. darcs-hash:20040311231325-19929-996452fe821c4ec4feaa66088c9bd994b02f0f3b.gz --- Carpet/CarpetIOHDF5/src/iohdf5.cc | 495 +++++++++++++++++++++++--------------- 1 file changed, 295 insertions(+), 200 deletions(-) (limited to 'Carpet/CarpetIOHDF5/src/iohdf5.cc') diff --git a/Carpet/CarpetIOHDF5/src/iohdf5.cc b/Carpet/CarpetIOHDF5/src/iohdf5.cc index 543bfd843..a11519714 100644 --- a/Carpet/CarpetIOHDF5/src/iohdf5.cc +++ b/Carpet/CarpetIOHDF5/src/iohdf5.cc @@ -17,7 +17,7 @@ #include "cctk_Parameters.h" extern "C" { - static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOHDF5/src/iohdf5.cc,v 1.13 2004/03/11 11:50:51 cott Exp $"; + static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOHDF5/src/iohdf5.cc,v 1.14 2004/03/12 00:13:25 cott Exp $"; CCTK_FILEVERSION(Carpet_CarpetIOHDF5_iohdf5_cc); } @@ -280,6 +280,8 @@ namespace CarpetIOHDF5 { const int var = n - n0; assert (var>=0 && vartimelevel==0) tl = 0; @@ -327,181 +333,203 @@ namespace CarpetIOHDF5 { gdata* const tmp = data->make_typed (n); tmp->allocate (ext, 0); - for (comm_state state; !state.done(); state.step()) { - tmp->copy_from (state, data, ext); - } - - // Write data - if (CCTK_MyProc(cctkGH)==0) { - - hsize_t shape[dim]; - for (int d=0; d=0); + + if ( !((cgdata.disttype == CCTK_DISTRIB_CONSTANT) && + (arrdata[group][Carpet::map].hh->processors[reflevel][component]!=0))) { + + if (cgdata.disttype == CCTK_DISTRIB_CONSTANT) { + assert(grouptype == CCTK_ARRAY || grouptype == CCTK_SCALAR); + if(component!=0) continue; + } else { + for (comm_state state; !state.done(); state.step()) { + tmp->copy_from (state, data, ext); + } + } + // Write data + if (CCTK_MyProc(cctkGH)==0) { + int ldim; + if ( grouptype==CCTK_SCALAR ) { + ldim = 1; + } else { + ldim = gpdim; + } + + hsize_t shape[ldim]; + for (int d=0; d=0); + +// hsize_t shape[dim]; +// for (int d=0; d=0); +// // Select datatype #if 0 - assert (true - || (CCTK_VarTypeI(n) == CCTK_VARIABLE_REAL8 - && sizeof(CCTK_REAL8) == sizeof(double)) - || (CCTK_VarTypeI(n) == CCTK_VARIABLE_REAL - && sizeof(CCTK_REAL) == sizeof(double))); - // TODO: Set datatype correctly + assert (true + || (CCTK_VarTypeI(n) == CCTK_VARIABLE_REAL8 + && sizeof(CCTK_REAL8) == sizeof(double)) + || (CCTK_VarTypeI(n) == CCTK_VARIABLE_REAL + && sizeof(CCTK_REAL) == sizeof(double))); + // TODO: Set datatype correctly #endif - const hid_t datatype = h5DataType(CCTK_VarTypeI(n)); - - ostringstream datasetnamebuf; - datasetnamebuf << varname - << " it=" << cctk_iteration - << " tl=" << tl - << " ml=" << mglevel - << " rl=" << rl - << " m=" << Carpet::map - << " c=" << component; - string datasetnamestr = datasetnamebuf.str(); - const char * const datasetname = datasetnamestr.c_str(); - const hid_t dataset = H5Dcreate (writer, datasetname, datatype, dataspace, H5P_DEFAULT); - assert (dataset>=0); - - const void * const data = (void*)tmp->storage(); - herr = H5Dwrite (dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); - assert (!herr); - - // Write FlexIO attributes - WriteAttribute (dataset, "level", rl); - { - CCTK_REAL origin[dim], delta[dim]; - CCTK_REAL min_ext[dim], max_ext[dim]; - for (int d=0; dcomponents(reflevel)); + ostringstream datasetnamebuf; + datasetnamebuf << varname + << " it=" << cctk_iteration + << " tl=" << tl + << " ml=" << mglevel + << " rl=" << rl + << " m=" << Carpet::map + << " c=" << component; + string datasetnamestr = datasetnamebuf.str(); + const char * const datasetname = datasetnamestr.c_str(); + const hid_t dataset = H5Dcreate (writer, datasetname, datatype, dataspace, H5P_DEFAULT); + assert (dataset>=0); - herr = H5Dclose (dataset); - assert (!herr); - - herr = H5Sclose (dataspace); - assert (!herr); + const void * const data = (void*)tmp->storage(); + herr = H5Dwrite (dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); + assert (!herr); - } // if on root processor - - // Delete temporary copy - delete tmp; - + // Write FlexIO attributes + WriteAttribute (dataset, "level", rl); + { + CCTK_REAL origin[dim], delta[dim]; + CCTK_REAL min_ext[dim], max_ext[dim]; + for (int d=0; dcomponents(reflevel)); + + herr = H5Dclose (dataset); + assert (!herr); + + herr = H5Sclose (dataspace); + assert (!herr); + + } // if on root processor + + // Delete temporary copy + delete tmp; + } //if( !((CCTK_DISTRIB_BLAH) } END_COMPONENT_LOOP; } END_MAP_LOOP; @@ -595,7 +623,7 @@ namespace CarpetIOHDF5 { } -#if 1 + int ReadVar (const cGH* const cctkGH, const hid_t reader, const char* const varname, const hid_t dataset, vector ®ions_read, const int called_from_recovery) { @@ -610,11 +638,17 @@ namespace CarpetIOHDF5 { assert (n0>=0 && n0=0 && var=0); - hsize_t rank=H5Sget_simple_extent_ndims(dataspace); + hsize_t rank = H5Sget_simple_extent_ndims(dataspace); hsize_t shape[rank]; int rank2 = H5Sget_simple_extent_dims (dataspace, shape, NULL); herr = H5Sclose(dataspace); assert(!herr); assert (rank2 == rank); - assert (gpdim == rank); - + + if(grouptype == CCTK_SCALAR) { + assert (gpdim+1 == rank); + } else { + assert (gpdim == rank); + } + int datalength=1; for(int i=0;i=0); // cout << "amr_origin[0] " << amr_origin[0] << "\n"; - - herr = H5Dclose(dataset); - assert(!herr); - for (int d=0; d*)arrdata.at(group).at(Carpet::map).data.at(var); - + + if(called_from_recovery) tl = recovery_tl; + gdata* const data = (*ff) (tl, rl, component, mglevel); // Create temporary data storage on processor 0 - const vect str + vect str = vect(maxreflevelfact/reflevelfact); - const vect lb = vect::ref(amr_origin) * str; - const vect ub + vect lb = vect::ref(amr_origin) * str; + vect ub = lb + (vect::ref(amr_dims) - 1) * str; - const bbox ext(lb,ub,str); - + + // cout << "lb: " << lb << endl; + // cout << "ub: " << ub << endl; + // cout << "str: " << str << endl; gdata* const tmp = data->make_typed (n); + //cout << "overlap " << overlap << endl; + //cout << "tmp->extent " << tmp->extent() << endl; + //cout << "data->extent " << data->extent() << endl; + + cGroup cgdata; + int ierr = CCTK_GroupData(group,&cgdata); + assert(ierr==0); + + // cout << "trying to handle DISTRIB=const data " << endl; + + // handle distrib=constant vars + + if(grouptype == CCTK_SCALAR || grouptype == CCTK_ARRAY) + str = vect (1); + + if (cgdata.disttype == CCTK_DISTRIB_CONSTANT) { + assert(grouptype == CCTK_ARRAY || grouptype == CCTK_SCALAR); + if (grouptype == CCTK_SCALAR) { + lb[0] = arrdata[group][Carpet::map].hh->processors.at(rl).at(component); + ub[0] = arrdata[group][Carpet::map].hh->processors.at(rl).at(component); + for(int i=1;iprocessors.at(rl).at(component)); + ub[dim-1] = ub[dim-1] + (ub[dim-1]-lb[dim-1]+1)*(arrdata[group][Carpet::map].hh->processors.at(rl).at(component)); + // cout << "lb: " << lb << endl; + // cout << "ub: " << ub << endl; + } + } + const bbox ext(lb,ub,str); + + // cout << ext << endl; + if (CCTK_MyProc(cctkGH)==0) { tmp->allocate (ext, 0, h5data); } else { tmp->allocate (ext, 0); } - + // 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; - - //cout << "overlap " << overlap << endl; - //cout << "tmp->extent " << tmp->extent() << endl; - //cout << "data->extent " << data->extent() << endl; - + + + // Copy into grid function for (comm_state state; !state.done(); state.step()) { data->copy_from (state, tmp, overlap); @@ -735,7 +824,13 @@ namespace CarpetIOHDF5 { // Delete temporary copy delete tmp; - + + // set tt (ask Erik why...) + if (called_from_recovery) { + arrdata[group][Carpet::map].tt->set_time(reflevel,mglevel, + (CCTK_REAL) cctkGH->cctk_iteration/maxreflevelfact); + } + } END_COMPONENT_LOOP; } END_MAP_LOOP; @@ -749,7 +844,7 @@ namespace CarpetIOHDF5 { } -#endif + int InputVarAs (const cGH* const cctkGH, const char* const varname, const char* const alias) { @@ -821,8 +916,8 @@ namespace CarpetIOHDF5 { MPI_Bcast (&ndatasets, 1, MPI_INT, 0, dist::comm); assert (ndatasets>=0); - - for (int datasetid=0; datasetid