bool seissol::checkpoint::h5::Wavefield::validate(hid_t h5file) const { // Turn of error printing H5ErrHandler errHandler; // Check #partitions hid_t h5attr = H5Aopen(h5file, "partitions", H5P_DEFAULT); if (h5attr < 0) { logWarning(rank()) << "Checkpoint does not have a partition attribute."; return false; } int p; herr_t err = H5Aread(h5attr, H5T_NATIVE_INT, &p); checkH5Err(H5Aclose(h5attr)); if (err < 0 || p != partitions()) { logWarning(rank()) << "Partitions in checkpoint do not match."; return false; } // Check dimensions hid_t h5data = H5Dopen(h5file, "values", H5P_DEFAULT); if (h5data < 0) { logWarning(rank()) << "Checkpoint does not contains a data array."; return false; } hid_t h5space = H5Dget_space(h5data); checkH5Err(H5Dclose(h5data)); if (h5space < 0) { logWarning(rank()) << "Could not get space identifier in checkpoint."; return false; } bool isValid = true; int dims = H5Sget_simple_extent_ndims(h5space); if (dims != 1) { isValid = false; logWarning(rank()) << "Number of dimensions in checkpoint does not match."; } else { hsize_t dimSize; if (H5Sget_simple_extent_dims(h5space, &dimSize, 0L) != 1) { isValid = false; logWarning(rank()) << "Could not get dimension sizes of checkpoint."; } else { if (dimSize != numTotalElems()) { isValid = false; logWarning(rank()) << "Number of elements in checkpoint does not match."; } } } checkH5Err(H5Sclose(h5space)); return isValid; }
bool seissol::checkpoint::h5::Fault::validate(hid_t h5file) const { // Turn of error printing H5ErrHandler errHandler; // Check dimensions for (unsigned int i = 0; i < NUM_VARIABLES; i++) { hid_t h5data = H5Dopen(h5file, VAR_NAMES[i], H5P_DEFAULT); if (h5data < 0) { logWarning(rank()) << "Dataset" << VAR_NAMES[i] << "not found in checkpoint."; return false; } hid_t h5space = H5Dget_space(h5data); checkH5Err(H5Dclose(h5data)); if (h5space < 0) { logWarning(rank()) << "Could not get space identifier for" << VAR_NAMES[i] << "in checkpoint."; return false; } bool isValid = true; int dims = H5Sget_simple_extent_ndims(h5space); if (dims != 2) { isValid = false; logWarning() << "Number of dimensions for" << VAR_NAMES[i] << "in checkpoint does not match."; } else { hsize_t dimSize[2]; if (H5Sget_simple_extent_dims(h5space, dimSize, 0L) != 2) { isValid = false; logWarning(rank()) << "Could not get dimension sizes for" << VAR_NAMES[i] << "of checkpoint."; } else { if (dimSize[0] != numTotalElems()) { isValid = false; logWarning(rank()) << "Number of elements for" << VAR_NAMES[i] << "in checkpoint does not match."; } if (dimSize[1] != numBndGP()) { logWarning(rank()) << "Number of boundary points for" << VAR_NAMES[i] << "in checkpoint does not match."; isValid = false; } } } checkH5Err(H5Sclose(h5space)); // Dimensions for at least one variable do not match -> invalid if (!isValid) return false; } return true; }
bool seissol::checkpoint::h5::Wavefield::init(unsigned int numDofs, unsigned int groupSize) { seissol::checkpoint::Wavefield::init(numDofs, groupSize); // Data space for the file hsize_t fileSize = numTotalElems(); m_h5fSpaceData = H5Screate_simple(1, &fileSize, 0L); checkH5Err(m_h5fSpaceData); setupXferList(); return exists(); }
bool seissol::checkpoint::h5::Fault::init( double* mu, double* slipRate1, double* slipRate2, double* slip1, double* slip2, double* state, double* strength, unsigned int numSides, unsigned int numBndGP) { seissol::checkpoint::Fault::init(mu, slipRate1, slipRate2, slip1, slip2, state, strength, numSides, numBndGP); if (numSides == 0) return true; // Compute total number of cells and local offset setSumOffset(numSides); // Dataspace for the file hsize_t fileSize[2] = {numTotalElems(), numBndGP}; m_h5fSpaceData = H5Screate_simple(2, fileSize, 0L); checkH5Err(m_h5fSpaceData); setupXferList(); return exists(); }