lib/io/writer.cc
/**
 ********************************************************************************************************************************************
 * \brief   Function to initialize the global and local limits for setting file views
 *
 *          All the necessary limits of the local arrays with respect to the global array for setting the
 *          dataspace views for HDF5 are appropriately set here.
 ********************************************************************************************************************************************
 */
\brief   Function to initialize the global and local limits for setting file views
All the necessary limits of the local arrays with respect to the global array for setting the
dataspace views for HDF5 are appropriately set here.
\ brief Function to initialize the global and local limits for setting file views All the necessary limits of the local arrays with respect to the global array for setting the dataspace views for HDF5 are appropriately set here .
void writer::initLimits() {
    hid_t sDSpace;
    hid_t tDSpace;
    herr_t status;
    blitz::TinyVector<int, 3> gloSize, sdStart, locSize;
#ifdef PLANAR
    hsize_t dimsf[2];           
    hsize_t offset[2];          
#else
    hsize_t dimsf[3];           
    hsize_t offset[3];          
#endif
    for (unsigned int i=0; i < wFields.size(); i++) {
        gloSize = mesh.globalSize;
        if (not wFields[i].xStag) {
            gloSize(0) -= 1;
        }
#ifndef PLANAR
        if (not wFields[i].yStag) {
            gloSize(1) -= 1;
        }
#else
        gloSize(1) = 1;
#endif
        if (not wFields[i].zStag) {
            gloSize(2) -= 1;
        }
        locSize = mesh.collocCoreSize;
        if (wFields[i].xStag) {
            locSize(0) = mesh.staggrCoreSize(0) - 1;
            if (mesh.rankData.xRank == mesh.rankData.npX - 1) {
                locSize(0) += 1;
            }
        }
#ifndef PLANAR
        if (wFields[i].yStag) {
            locSize(1) = mesh.staggrCoreSize(1) - 1;
            if (mesh.rankData.yRank == mesh.rankData.npY - 1) {
                locSize(1) += 1;
            }
        }
#else
        locSize(1) = 1;
#endif
        if (wFields[i].zStag) {
            locSize(2) = mesh.staggrCoreSize(2);
        }
        sdStart = mesh.subarrayStarts;
#ifdef PLANAR
        dimsf[0] = locSize(0);
        dimsf[1] = locSize(2);
        sDSpace = H5Screate_simple(2, dimsf, NULL);
#else
        dimsf[0] = locSize(0);
        dimsf[1] = locSize(1);
        dimsf[2] = locSize(2);
        sDSpace = H5Screate_simple(3, dimsf, NULL);
#endif
#ifdef PLANAR
        dimsf[0] = locSize(0);
        dimsf[1] = locSize(2);
        offset[0] = 0;
        offset[1] = 0;
#else
        dimsf[0] = locSize(0);
        dimsf[1] = locSize(1);
        dimsf[2] = locSize(2);
        offset[0] = 0;
        offset[1] = 0;
        offset[2] = 0;
#endif
        status = H5Sselect_hyperslab(sDSpace, H5S_SELECT_SET, offset, NULL, dimsf, NULL);
        if (status) {
            if (mesh.rankData.rank == 0) {
                std::cout << "Error in creating hyperslab while writing data. Aborting" << std::endl;
            }
            MPI_Finalize();
            exit(0);
        }
#ifdef PLANAR
        dimsf[0] = gloSize(0);
        dimsf[1] = gloSize(2);
        tDSpace = H5Screate_simple(2, dimsf, NULL);
#else
        dimsf[0] = gloSize(0);
        dimsf[1] = gloSize(1);
        dimsf[2] = gloSize(2);
        tDSpace = H5Screate_simple(3, dimsf, NULL);
#endif
#ifdef PLANAR
        dimsf[0] = locSize(0);
        dimsf[1] = locSize(2);
        offset[0] = sdStart[0];
        offset[1] = sdStart[2];
#else
        dimsf[0] = locSize(0);
        dimsf[1] = locSize(1);
        dimsf[2] = locSize(2);
        offset[0] = sdStart[0];
        offset[1] = sdStart[1];
        offset[2] = sdStart[2];
#endif
        status = H5Sselect_hyperslab(tDSpace, H5S_SELECT_SET, offset, NULL, dimsf, NULL);
        if (status) {
            if (mesh.rankData.rank == 0) {
                std::cout << "Error in creating hyperslab while writing data. Aborting" << std::endl;
            }
            MPI_Finalize();
            exit(0);
        }
        localSize.push_back(locSize);
        sourceDSpace.push_back(sDSpace);
        targetDSpace.push_back(tDSpace);
    }
}
void writer :: initLimits ( ) { hid_t sDSpace ; hid_t tDSpace ; herr_t status ; blitz :: TinyVector < int , 3 > gloSize , sdStart , locSize ; #ifdef PLANAR hsize_t dimsf [ 2 ] ; hsize_t offset [ 2 ] ; #else hsize_t dimsf [ 3 ] ; hsize_t offset [ 3 ] ; #endif for ( unsigned int i = 0 ; i < wFields . size ( ) ; i ++ ) { gloSize = mesh . globalSize ; if ( not wFields [ i ] . xStag ) { gloSize ( 0 ) -= 1 ; } #ifndef PLANAR if ( not wFields [ i ] . yStag ) { gloSize ( 1 ) -= 1 ; } #else gloSize ( 1 ) = 1 ; #endif if ( not wFields [ i ] . zStag ) { gloSize ( 2 ) -= 1 ; } locSize = mesh . collocCoreSize ; if ( wFields [ i ] . xStag ) { locSize ( 0 ) = mesh . staggrCoreSize ( 0 ) - 1 ; if ( mesh . rankData . xRank == mesh . rankData . npX - 1 ) { locSize ( 0 ) += 1 ; } } #ifndef PLANAR if ( wFields [ i ] . yStag ) { locSize ( 1 ) = mesh . staggrCoreSize ( 1 ) - 1 ; if ( mesh . rankData . yRank == mesh . rankData . npY - 1 ) { locSize ( 1 ) += 1 ; } } #else locSize ( 1 ) = 1 ; #endif if ( wFields [ i ] . zStag ) { locSize ( 2 ) = mesh . staggrCoreSize ( 2 ) ; } sdStart = mesh . subarrayStarts ; #ifdef PLANAR dimsf [ 0 ] = locSize ( 0 ) ; dimsf [ 1 ] = locSize ( 2 ) ; sDSpace = H5Screate_simple ( 2 , dimsf , NULL ) ; #else dimsf [ 0 ] = locSize ( 0 ) ; dimsf [ 1 ] = locSize ( 1 ) ; dimsf [ 2 ] = locSize ( 2 ) ; sDSpace = H5Screate_simple ( 3 , dimsf , NULL ) ; #endif #ifdef PLANAR dimsf [ 0 ] = locSize ( 0 ) ; dimsf [ 1 ] = locSize ( 2 ) ; offset [ 0 ] = 0 ; offset [ 1 ] = 0 ; #else dimsf [ 0 ] = locSize ( 0 ) ; dimsf [ 1 ] = locSize ( 1 ) ; dimsf [ 2 ] = locSize ( 2 ) ; offset [ 0 ] = 0 ; offset [ 1 ] = 0 ; offset [ 2 ] = 0 ; #endif status = H5Sselect_hyperslab ( sDSpace , H5S_SELECT_SET , offset , NULL , dimsf , NULL ) ; if ( status ) { if ( mesh . rankData . rank == 0 ) { std :: cout << " " << std :: endl ; } MPI_Finalize ( ) ; exit ( 0 ) ; } #ifdef PLANAR dimsf [ 0 ] = gloSize ( 0 ) ; dimsf [ 1 ] = gloSize ( 2 ) ; tDSpace = H5Screate_simple ( 2 , dimsf , NULL ) ; #else dimsf [ 0 ] = gloSize ( 0 ) ; dimsf [ 1 ] = gloSize ( 1 ) ; dimsf [ 2 ] = gloSize ( 2 ) ; tDSpace = H5Screate_simple ( 3 , dimsf , NULL ) ; #endif #ifdef PLANAR dimsf [ 0 ] = locSize ( 0 ) ; dimsf [ 1 ] = locSize ( 2 ) ; offset [ 0 ] = sdStart [ 0 ] ; offset [ 1 ] = sdStart [ 2 ] ; #else dimsf [ 0 ] = locSize ( 0 ) ; dimsf [ 1 ] = locSize ( 1 ) ; dimsf [ 2 ] = locSize ( 2 ) ; offset [ 0 ] = sdStart [ 0 ] ; offset [ 1 ] = sdStart [ 1 ] ; offset [ 2 ] = sdStart [ 2 ] ; #endif status = H5Sselect_hyperslab ( tDSpace , H5S_SELECT_SET , offset , NULL , dimsf , NULL ) ; if ( status ) { if ( mesh . rankData . rank == 0 ) { std :: cout << " " << std :: endl ; } MPI_Finalize ( ) ; exit ( 0 ) ; } localSize . push_back ( locSize ) ; sourceDSpace . push_back ( sDSpace ) ; targetDSpace . push_back ( tDSpace ) ; } }
\brief   Function to initialize the global and local limits for setting file views
          All the necessary limits of the local arrays with respect to the global array for setting the
          dataspace views for HDF5 are appropriately set here.
\ brief Function to initialize the global and local limits for setting file views All the necessary limits of the local arrays with respect to the global array for setting the dataspace views for HDF5 are appropriately set here .
/* dataset dimensions */ /* offset of hyperslab */ /* dataset dimensions */ /* offset of hyperslab */ // All subdomains exclude the last point (which is shared across 2 processors), except those at the last rank along X direction, thereby capturing the full domain // As with X direction, all subdomains exclude the last point (which is shared across 2 processors), except those at the last rank along Y direction // Since only the last rank along X and Y directions include the extra point (shared across processors), subArrayStarts are same for all ranks // Create a dataspace representing the full limits of the array - this is the source dataspace // Modify the view of the *source* dataspace by using a hyperslab - *this view will be used to read from memory* // ************* NOTE: Check if the hyperslab view must be changed to take care of the common point at the the MPI decomposed sub-domain boundaries ****************// // Create a dataspace representing the full limits of the global array - i.e. the dataspace for output file // Modify the view of the *target* dataspace by using a hyperslab according to its position in the global file dataspace