diff options
author | Neil Fortner <nfortne2@hdfgroup.org> | 2015-06-05 21:55:24 (GMT) |
---|---|---|
committer | Neil Fortner <nfortne2@hdfgroup.org> | 2015-06-05 21:55:24 (GMT) |
commit | c27904bc5fec9b7c65f6a943bcf9816622df4662 (patch) | |
tree | d4481c5c9f3e61d3a7095a2e95638b60a60b72b9 | |
parent | 8f74cc85d8c0f499277622a40d90679a4b0b1db1 (diff) | |
download | hdf5-c27904bc5fec9b7c65f6a943bcf9816622df4662.zip hdf5-c27904bc5fec9b7c65f6a943bcf9816622df4662.tar.gz hdf5-c27904bc5fec9b7c65f6a943bcf9816622df4662.tar.bz2 |
[svn-r27153] Implement fill value support for VDS.
Add testing for this.
Fix bug in printf string parsing.
Add test for this.
Other minor fixes/cleanup.
Tested: ummon
-rw-r--r-- | src/H5Dvirtual.c | 487 | ||||
-rw-r--r-- | src/H5Oprivate.h | 3 | ||||
-rw-r--r-- | src/H5Shyper.c | 110 | ||||
-rw-r--r-- | src/H5Spkg.h | 1 | ||||
-rw-r--r-- | src/H5Sprivate.h | 1 | ||||
-rw-r--r-- | src/H5Sselect.c | 89 | ||||
-rw-r--r-- | test/h5test.c | 12 | ||||
-rw-r--r-- | test/h5test.h | 2 | ||||
-rw-r--r-- | test/vds.c | 1878 |
9 files changed, 1560 insertions, 1023 deletions
diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c index baaea16..fc88b6f 100644 --- a/src/H5Dvirtual.c +++ b/src/H5Dvirtual.c @@ -61,9 +61,6 @@ /********************/ /* Layout operation callbacks */ -static herr_t H5D__virtual_io_init(const H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, hsize_t nelmts, const H5S_t *file_space, - const H5S_t *mem_space, H5D_chunk_map_t *cm); static herr_t H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t *fm); @@ -88,12 +85,16 @@ static herr_t H5D__virtual_build_source_name(char *source_name, size_t nsubs, hsize_t blockno, char **built_name); static herr_t H5D__virtual_read_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, const H5S_t *file_space, - const H5S_t *mem_space, H5O_storage_virtual_ent_t *virtual_ent, + H5O_storage_virtual_ent_t *virtual_ent, H5O_storage_virtual_srcdset_t *source_dset); static herr_t H5D__virtual_write_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, const H5S_t *file_space, - const H5S_t *mem_space, H5O_storage_virtual_ent_t *virtual_ent, + H5O_storage_virtual_ent_t *virtual_ent, H5O_storage_virtual_srcdset_t *source_dset); +static herr_t H5D__virtual_pre_io(H5D_io_info_t *io_info, + H5O_storage_virtual_t *storage, const H5S_t *file_space, + const H5S_t *mem_space, hsize_t *tot_nelmts); +static herr_t H5D__virtual_post_io(H5O_storage_virtual_t *storage); /*********************/ @@ -105,7 +106,7 @@ const H5D_layout_ops_t H5D_LOPS_VIRTUAL[1] = {{ NULL, H5D__virtual_init, H5D__virtual_is_space_alloc, - H5D__virtual_io_init, + NULL, H5D__virtual_read, H5D__virtual_write, #ifdef H5_HAVE_PARALLEL @@ -502,6 +503,10 @@ H5D__virtual_reset_source_dset(H5O_storage_virtual_ent_t *virtual_ent, source_dset->virtual_select = NULL; } /* end if */ + /* The projected memory space should never exist when this function is + * called */ + HDassert(!source_dset->projected_mem_space); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_reset_source_dset() */ @@ -523,7 +528,6 @@ static herr_t H5D__virtual_str_append(const char *src, size_t src_len, char **p, char **buf, size_t *buf_size) { - size_t p_offset; /* Offset of p within buf */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -547,22 +551,26 @@ H5D__virtual_str_append(const char *src, size_t src_len, char **p, char **buf, *buf_size = src_len + (size_t)1; *p = *buf; } /* end if */ - else if(((p_offset = (size_t)(*p - *buf)) + src_len + (size_t)1) - > *buf_size) { - char *tmp_buf; - size_t tmp_buf_size; - - /* Calculate new size of buffer */ - tmp_buf_size = MAX(p_offset + src_len + (size_t)1, - *buf_size * (size_t)2); - - /* Reallocate buffer */ - if(NULL == (tmp_buf = (char *)H5MM_realloc(*buf, tmp_buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to reallocate name segment buffer") - *buf = tmp_buf; - *buf_size = tmp_buf_size; - *p = *buf + p_offset; - } /* end if */ + else { + size_t p_offset = (size_t)(*p - *buf); /* Offset of p within buf */ + + /* Extend buffer if necessary */ + if((p_offset + src_len + (size_t)1) > *buf_size) { + char *tmp_buf; + size_t tmp_buf_size; + + /* Calculate new size of buffer */ + tmp_buf_size = MAX(p_offset + src_len + (size_t)1, + *buf_size * (size_t)2); + + /* Reallocate buffer */ + if(NULL == (tmp_buf = (char *)H5MM_realloc(*buf, tmp_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to reallocate name segment buffer") + *buf = tmp_buf; + *buf_size = tmp_buf_size; + *p = *buf + p_offset; + } /* end if */ + } /* end else */ /* Copy string to *p. Note that since src in not NULL terminated, we must * use memcpy */ @@ -730,8 +738,12 @@ H5D__virtual_copy_parsed_name(H5O_storage_virtual_name_seg_t **dst, HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate name segment struct") /* Duplicate name segment */ - if(NULL == ((*p_dst)->name_segment = HDstrdup(p_src->name_segment))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to duplicate name segment") + if(p_src->name_segment) { + if(NULL == ((*p_dst)->name_segment = HDstrdup(p_src->name_segment))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to duplicate name segment") + } /* end if */ + else + (*p_dst)->name_segment = NULL; /* Advance pointers */ p_src = p_src->next; @@ -1281,28 +1293,226 @@ H5D__virtual_is_space_alloc(const H5O_storage_t UNUSED *storage) /*------------------------------------------------------------------------- - * Function: H5D__virtual_io_init + * Function: H5D__virtual_pre_io * - * Purpose: Performs initialization before any sort of I/O on the raw data + * Purpose: Project all virtual mappings onto mem_space, with the + * results stored in projected_mem_space for each mapping. + * Opens all source datasets if possible. The total number + * of elements is stored in tot_nelmts. * * Return: Non-negative on success/Negative on failure * * Programmer: Neil Fortner - * February 6, 2015 + * June 3, 2015 * *------------------------------------------------------------------------- */ static herr_t -H5D__virtual_io_init(const H5D_io_info_t UNUSED *io_info, const H5D_type_info_t UNUSED *type_info, - hsize_t UNUSED nelmts, const H5S_t UNUSED *file_space, const H5S_t UNUSED *mem_space, - H5D_chunk_map_t UNUSED *cm) +H5D__virtual_pre_io(H5D_io_info_t *io_info, + H5O_storage_virtual_t *storage, const H5S_t *file_space, + const H5S_t *mem_space, hsize_t *tot_nelmts) { - FUNC_ENTER_STATIC_NOERR + H5S_t *tmp_space = NULL; /* Copied virtual_select VDSINC */ + hssize_t select_nelmts; /* Number of elements in selection */ + size_t i, j; /* Local index variables */ + herr_t ret_value = SUCCEED; /* Return value */ - /* No-op for now. Delete if we never add anything here. VDSINC */ + FUNC_ENTER_STATIC - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5D__virtual_io_init() */ + /* Sanity check */ + HDassert(storage); + HDassert(mem_space); + HDassert(file_space); + HDassert(tot_nelmts); + + /* Initialize tot_nelmts */ + *tot_nelmts = 0; + + /* Iterate over mappings */ + for(i = 0; i < storage->list_nused; i++) { + /* Sanity check that the virtual space has been patched by now */ + HDassert(storage->list[i].virtual_space_status == H5O_VIRTUAL_STATUS_CORRECT); + + /* Check for "printf" source dataset resolution */ + if(storage->list[i].parsed_source_file_name + || storage->list[i].parsed_source_dset_name) { + /* Iterate over sub-source dsets */ + for(j = 0; j < storage->list[i].sub_dset_nused; j++) { + H5S_t *virtual_select; /* Pointer to real virtual_select VDSINC */ + + /* Quick hack to make this work with printf VDSINC */ + if(storage->view == H5D_VDS_LAST_AVAILABLE) { + virtual_select = storage->list[i].sub_dset[j].virtual_select; + } /* end if */ + else { + hsize_t start[H5S_MAX_RANK]; + hsize_t count[H5S_MAX_RANK]; + + /* Quick hack to make this work with FIRST_MISSING */ + /* Copy virtual selection */ + if(NULL == (tmp_space = H5S_copy(storage->list[i].sub_dset[j].virtual_select, FALSE, TRUE))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy virtual selection") + + /* Get virtual extent dimensions */ + if(H5S_get_simple_extent_dims(tmp_space, count, NULL) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get virtual dataspace dimensions") + + /* Set start to zeroes */ + (void)HDmemset(start, 0, sizeof(start)); + + /* Clip tmp_space selection to extent */ + if(H5S_select_hyperslab(tmp_space, H5S_SELECT_AND, start, NULL, count, NULL) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "can't clip selection to extent") + + /* Check for no elements selected */ + if((select_nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(tmp_space)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection") + if(select_nelmts == 0) { + if(H5S_close(tmp_space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close temporary space") + tmp_space = NULL; + continue; + } /* end if */ + + virtual_select = tmp_space; + } /* end else */ + + /* Project intersection of file space and mapping virtual space onto + * memory space */ + if(H5S_select_project_intersection(file_space, mem_space, virtual_select, &storage->list[i].sub_dset[j].projected_mem_space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "can't project virtual intersection onto memory space") + + /* Close temporary space VDSINC */ + if(tmp_space) { + if(H5S_close(tmp_space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close temporary space") + tmp_space = NULL; + } /* end if */ + + /* Check number of elements selected */ + if((select_nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(storage->list[i].sub_dset[j].projected_mem_space)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection") + + /* Check if anything is selected */ + if(select_nelmts > (hssize_t)0) { + /* Open source dataset */ + if(!storage->list[i].sub_dset[j].dset) + /* Try to open dataset */ + if(H5D__virtual_open_source_dset(io_info->dset, &storage->list[i], &storage->list[i].sub_dset[j], io_info->dxpl_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open source dataset") + + /* If the source dataset is not open, mark the selected + * elements as zero so projected_mem_space is freed */ + if(!storage->list[i].sub_dset[j].dset) + select_nelmts = (hssize_t)0; + } /* end if */ + + /* If there are not elements selected in this mapping, free + * projected_mem_space, otherwise update tot_nelmts */ + if(select_nelmts == (hssize_t)0) { + if(H5S_close(storage->list[i].sub_dset[j].projected_mem_space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected memory space") + storage->list[i].sub_dset[j].projected_mem_space = NULL; + } /* end if */ + else + *tot_nelmts += (hsize_t)select_nelmts; + } /* end for */ + } /* end if */ + else { + /* Project intersection of file space and mapping virtual space onto + * memory space */ + if(H5S_select_project_intersection(file_space, mem_space, storage->list[i].source_dset.virtual_select, &storage->list[i].source_dset.projected_mem_space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "can't project virtual intersection onto memory space") + + /* Check number of elements selected, add to tot_nelmts */ + if((select_nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(storage->list[i].source_dset.projected_mem_space)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection") + + /* Check if anything is selected */ + if(select_nelmts > (hssize_t)0) { + /* Open source dataset */ + if(!storage->list[i].source_dset.dset) + /* Try to open dataset */ + if(H5D__virtual_open_source_dset(io_info->dset, &storage->list[i], &storage->list[i].source_dset, io_info->dxpl_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open source dataset") + + /* If the source dataset is not open, mark the selected elements + * as zero so projected_mem_space is freed */ + if(!storage->list[i].source_dset.dset) { + HDassert(0 && "Checking code coverage..."); //VDSINC + select_nelmts = (hssize_t)0; + } //VDSINC + } /* end if */ + + /* If there are not elements selected in this mapping, free + * projected_mem_space, otherwise update tot_nelmts */ + if(select_nelmts == (hssize_t)0) { + if(H5S_close(storage->list[i].source_dset.projected_mem_space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected memory space") + storage->list[i].source_dset.projected_mem_space = NULL; + } /* end if */ + else + *tot_nelmts += (hsize_t)select_nelmts; + } /* end else */ + } /* end for */ + +done: + /* Release tmp_space VDSINC */ + if(tmp_space) + if(H5S_close(tmp_space) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close temporary space") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__virtual_pre_io() */ + + +/*------------------------------------------------------------------------- + * Function: H5D__virtual_post_io + * + * Purpose: VDSINC + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Neil Fortner + * June 4, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__virtual_post_io(H5O_storage_virtual_t *storage) +{ + size_t i, j; /* Local index variables */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(storage); + + /* Iterate over mappings */ + for(i = 0; i < storage->list_nused; i++) + /* Check for "printf" source dataset resolution */ + if(storage->list[i].parsed_source_file_name + || storage->list[i].parsed_source_dset_name) { + /* Iterate over sub-source dsets */ + for(j = 0; j < storage->list[i].sub_dset_nused; j++) + /* Close projected memory space */ + if(storage->list[i].sub_dset[j].projected_mem_space) { + if(H5S_close(storage->list[i].sub_dset[j].projected_mem_space) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close temporary space") + storage->list[i].sub_dset[j].projected_mem_space = NULL; + } /* end if */ + } /* end if */ + else + /* Close projected memory space */ + if(storage->list[i].source_dset.projected_mem_space) { + if(H5S_close(storage->list[i].source_dset.projected_mem_space) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close temporary space") + storage->list[i].source_dset.projected_mem_space = NULL; + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__virtual_post_io() */ /*------------------------------------------------------------------------- @@ -1319,13 +1529,10 @@ H5D__virtual_io_init(const H5D_io_info_t UNUSED *io_info, const H5D_type_info_t */ static herr_t H5D__virtual_read_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - const H5S_t *file_space, const H5S_t *mem_space, - H5O_storage_virtual_ent_t *virtual_ent, + const H5S_t *file_space, H5O_storage_virtual_ent_t *virtual_ent, H5O_storage_virtual_srcdset_t *source_dset) { - H5S_t *projected_mem_space = NULL; /* Memory space for selection in a single mapping */ H5S_t *projected_src_space = NULL; /* File space for selection in a single source dataset */ - hssize_t select_nelmts; /* Number of elements in selection */ H5S_t *tmp_space = NULL; /* Copied virtual_select VDSINC */ H5S_t *virtual_select; /* Pointer to real virtual_select VDSINC */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1336,12 +1543,14 @@ H5D__virtual_read_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, HDassert(source_dset); /* Quick hack to make this work with printf VDSINC */ - if(source_dset == &virtual_ent->source_dset) { + if((source_dset == &virtual_ent->source_dset) + || (io_info->dset->shared->layout.storage.u.virt.view == H5D_VDS_LAST_AVAILABLE)) { virtual_select = source_dset->virtual_select; } /* end if */ else { hsize_t start[H5S_MAX_RANK]; hsize_t count[H5S_MAX_RANK]; + hssize_t select_nelmts; /* Copy virtual selection */ if(NULL == (tmp_space = H5S_copy(source_dset->virtual_select, FALSE, TRUE))) @@ -1367,63 +1576,37 @@ H5D__virtual_read_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, virtual_select = tmp_space; } /* end else */ - /* Project intersection of file space and mapping virtual space onto - * memory space */ - if(H5S_select_project_intersection(file_space, mem_space, virtual_select, &projected_mem_space) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "can't project virtual intersection onto memory space") + /* Only perform I/O if there is a projected memory space, otherwise there + * were no elements in the projection or the source dataset could not be + * opened */ + if(source_dset->projected_mem_space) { + HDassert(source_dset->dset); - /* Get number of elements in projected dataspace */ - if((select_nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(projected_mem_space)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection") + /* Sanity check that the source space has been patched by now */ + HDassert(virtual_ent->source_space_status == H5O_VIRTUAL_STATUS_CORRECT); - /* Only perform I/O if there are any elements */ - if(select_nelmts > 0) { - /* Open source dataset */ - if(!source_dset->dset) - /* Try to open dataset */ - if(H5D__virtual_open_source_dset(io_info->dset, virtual_ent, source_dset, io_info->dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open source dataset") + /* Project intersection of file space and mapping virtual space onto + * mapping source space */ + if(H5S_select_project_intersection(virtual_select, virtual_ent->source_select, file_space, &projected_src_space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "can't project virtual intersection onto source space") - /* Check if source dataset is open */ - if(source_dset->dset) { - /* Sanity check that the source space has been patched by now */ - HDassert(virtual_ent->source_space_status == H5O_VIRTUAL_STATUS_CORRECT); + /* Perform read on source dataset */ + if(H5D__read(source_dset->dset, type_info->dst_type_id, source_dset->projected_mem_space, projected_src_space, io_info->dxpl_id, io_info->u.rbuf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read source dataset") - /* Project intersection of file space and mapping virtual space onto - * mapping source space */ - if(H5S_select_project_intersection(virtual_select, virtual_ent->source_select, file_space, &projected_src_space) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "can't project virtual intersection onto source space") - - /* Perform read on source dataset */ - if(H5D__read(source_dset->dset, type_info->dst_type_id, projected_mem_space, projected_src_space, io_info->dxpl_id, io_info->u.rbuf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read source dataset") - - /* Close projected_src_space */ - if(H5S_close(projected_src_space) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected source space") - projected_src_space = NULL; - } /* end if */ + /* Close projected_src_space */ + if(H5S_close(projected_src_space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected source space") + projected_src_space = NULL; } /* end if */ - /* Close projected_mem_space */ - if(H5S_close(projected_mem_space) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected memory space") - projected_mem_space = NULL; - done: /* Release allocated resources on failure */ - if(ret_value < 0) { - if(projected_src_space) - if(H5S_close(projected_src_space) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected source space") - if(projected_mem_space) - if(H5S_close(projected_mem_space) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected memory space") + if(projected_src_space) { + HDassert(ret_value < 0); + if(H5S_close(projected_src_space) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected source space") } /* end if */ - else { - HDassert(!projected_src_space); - HDassert(!projected_mem_space); - } /* end else */ /* Release tmp_space VDSINC */ if(tmp_space) @@ -1452,6 +1635,8 @@ H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, H5D_chunk_map_t UNUSED *fm) { H5O_storage_virtual_t *storage; /* Convenient pointer into layout struct */ + hsize_t tot_nelmts; /* Total number of elements mapped to mem_space */ + H5S_t *fill_space = NULL; /* Space to fill with fill value */ size_t i, j; /* Local index variables */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1467,6 +1652,10 @@ H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, storage = &io_info->dset->shared->layout.storage.u.virt; HDassert((storage->view == H5D_VDS_FIRST_MISSING) || (storage->view == H5D_VDS_LAST_AVAILABLE)); + /* Prepare for I/O operation */ + if(H5D__virtual_pre_io(io_info, storage, file_space, mem_space, &tot_nelmts) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "unable to prepare for I/O operation") + /* Iterate over mappings */ for(i = 0; i < storage->list_nused; i++) { /* Sanity check that the virtual space has been patched by now */ @@ -1477,19 +1666,70 @@ H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, || storage->list[i].parsed_source_dset_name) { /* Iterate over sub-source dsets */ for(j = 0; j < storage->list[i].sub_dset_nused; j++) - if(H5D__virtual_read_one(io_info, type_info, file_space, mem_space, &storage->list[i], &storage->list[i].sub_dset[j]) < 0) + if(H5D__virtual_read_one(io_info, type_info, file_space, &storage->list[i], &storage->list[i].sub_dset[j]) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to read source dataset") } /* end if */ else /* Read from source dataset */ - if(H5D__virtual_read_one(io_info, type_info, file_space, mem_space, &storage->list[i], &storage->list[i].source_dset) < 0) + if(H5D__virtual_read_one(io_info, type_info, file_space, &storage->list[i], &storage->list[i].source_dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to read source dataset") } /* end for */ - /* Fill unmapped part of buffer with fill value. Keep track of total number - * elements written to memory buffer and assert that it == nelmts VDSINC */ + /* Fill unmapped part of buffer with fill value */ + if(tot_nelmts != nelmts) { + HDassert(tot_nelmts < nelmts); + + /* Start with fill space equal to memory space */ + if(NULL == (fill_space = H5S_copy(mem_space, FALSE, TRUE))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy memory selection") + + /* Iterate over mappings */ + for(i = 0; i < storage->list_nused; i++) + /* Check for "printf" source dataset resolution */ + if(storage->list[i].parsed_source_file_name + || storage->list[i].parsed_source_dset_name) { + /* Iterate over sub-source dsets */ + for(j = 0; j < storage->list[i].sub_dset_nused; j++) + if(storage->list[i].sub_dset[j].projected_mem_space) + if(H5S_select_subtract(fill_space, storage->list[i].sub_dset[j].projected_mem_space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "unable to clip fill selection") + } /* end if */ + else + if(storage->list[i].source_dset.projected_mem_space) + /* Subtract projected memory space from fill space */ + if(H5S_select_subtract(fill_space, storage->list[i].source_dset.projected_mem_space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "unable to clip fill selection") + + /* Write fill values to memory buffer */ + if(H5D__fill(io_info->dset->shared->dcpl_cache.fill.buf, io_info->dset->shared->type, io_info->u.rbuf, type_info->mem_type, fill_space, io_info->dxpl_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "filling buf failed") + +#ifndef NDEBUG + /* Make sure the total number of elements written (including fill + * values) == nelmts */ + { + hssize_t select_nelmts; /* Number of elements in selection */ + + /* Get number of elements in fill dataspace */ + if((select_nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(fill_space)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection") + + /* Verify number of elements is correct */ + HDassert((tot_nelmts + (hsize_t)select_nelmts) == nelmts); + } /* end block */ +#endif /* NDEBUG */ + } /* end if */ done: + /* Cleanup I/O operation */ + if(H5D__virtual_post_io(storage) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't cleanup I/O operation") + + /* Close fill space */ + if(fill_space) + if(H5S_close(fill_space) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close fill space") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_read() */ @@ -1508,13 +1748,10 @@ done: */ static herr_t H5D__virtual_write_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - const H5S_t *file_space, const H5S_t *mem_space, - H5O_storage_virtual_ent_t *virtual_ent, + const H5S_t *file_space, H5O_storage_virtual_ent_t *virtual_ent, H5O_storage_virtual_srcdset_t *source_dset) { - H5S_t *projected_mem_space = NULL; /* Memory space for selection in a single mapping */ H5S_t *projected_src_space = NULL; /* File space for selection in a single source dataset */ - hssize_t select_nelmts; /* Number of elements in selection */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1522,25 +1759,10 @@ H5D__virtual_write_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, HDassert(virtual_ent); HDassert(source_dset); - /* Project intersection of file space and mapping virtual space onto - * memory space */ - if(H5S_select_project_intersection(file_space, mem_space, source_dset->virtual_select, &projected_mem_space) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "can't project virtual intersection onto memory space") - - /* Get number of elements in projected dataspace */ - if((select_nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(projected_mem_space)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection") - - /* Only perform I/O if there are any elements */ - if(select_nelmts > 0) { - /* Open source dataset */ - if(!source_dset->dset) { - /* Try to open dataset */ - if(H5D__virtual_open_source_dset(io_info->dset, virtual_ent, source_dset, io_info->dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open source dataset") - if(!source_dset->dset) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "did not open source dataset") - } /* end if */ + /* Only perform I/O if there is a projected memory space, otherwise there + * were no elements in the projection */ + if(source_dset->projected_mem_space) { + HDassert(source_dset->dset); /* Sanity check that the source space has been patched by now */ HDassert(virtual_ent->source_space_status == H5O_VIRTUAL_STATUS_CORRECT); @@ -1553,7 +1775,7 @@ H5D__virtual_write_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "can't project virtual intersection onto source space") /* Perform write on source dataset */ - if(H5D__write(source_dset->dset, type_info->dst_type_id, projected_mem_space, projected_src_space, io_info->dxpl_id, io_info->u.wbuf) < 0) + if(H5D__write(source_dset->dset, type_info->dst_type_id, source_dset->projected_mem_space, projected_src_space, io_info->dxpl_id, io_info->u.wbuf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write to source dataset") /* Close projected_src_space */ @@ -1562,11 +1784,6 @@ H5D__virtual_write_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, projected_src_space = NULL; } /* end if */ - /* Close projected_mem_space */ - if(H5S_close(projected_mem_space) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected memory space") - projected_mem_space = NULL; - done: /* Release allocated resources on failure */ if(projected_src_space) { @@ -1574,11 +1791,6 @@ done: if(H5S_close(projected_src_space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected source space") } /* end if */ - if(projected_mem_space) { - HDassert(ret_value < 0); - if(H5S_close(projected_mem_space) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected memory space") - } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_write_one() */ @@ -1602,6 +1814,7 @@ H5D__virtual_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, H5D_chunk_map_t UNUSED *fm) { H5O_storage_virtual_t *storage; /* Convenient pointer into layout struct */ + hsize_t tot_nelmts; /* Total number of elements mapped to mem_space */ size_t i, j; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1617,6 +1830,17 @@ H5D__virtual_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, storage = &io_info->dset->shared->layout.storage.u.virt; HDassert((storage->view == H5D_VDS_FIRST_MISSING) || (storage->view == H5D_VDS_LAST_AVAILABLE)); + /* Prepare for I/O operation */ + if(H5D__virtual_pre_io(io_info, storage, file_space, mem_space, &tot_nelmts) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "unable to prepare for I/O operation") + + /* Fail if there are unmapped parts of the selection as they would not be + * written */ + if(tot_nelmts != nelmts) { + HDassert(0 && "Checking code coverage..."); //VDSINC + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "write requested to unmapped portion of virtual dataset") + } //VDSINC + /* Iterate over mappings */ for(i = 0; i < storage->list_nused; i++) { /* Sanity check that virtual space has been patched by now */ @@ -1628,20 +1852,21 @@ H5D__virtual_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, /* Iterate over sub-source dsets */ for(j = 0; j < storage->list[i].sub_dset_nused; j++) { HDassert(0 && "Checking code coverage..."); //VDSINC - if(H5D__virtual_write_one(io_info, type_info, file_space, mem_space, &storage->list[i], &storage->list[i].sub_dset[j]) < 0) + if(H5D__virtual_write_one(io_info, type_info, file_space, &storage->list[i], &storage->list[i].sub_dset[j]) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to write to source dataset") } //VDSINC } /* end if */ else /* Write to source dataset */ - if(H5D__virtual_write_one(io_info, type_info, file_space, mem_space, &storage->list[i], &storage->list[i].source_dset) < 0) + if(H5D__virtual_write_one(io_info, type_info, file_space, &storage->list[i], &storage->list[i].source_dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to write to source dataset") } /* end for */ - /* Keep track of total number elements written to disk buffer and issure - * error if it != nelmts VDSINC */ - done: + /* Cleanup I/O operation */ + if(H5D__virtual_post_io(storage) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't cleanup I/O operation") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_write() */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 6dc39d4..7063de5 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -420,6 +420,9 @@ typedef struct H5O_storage_virtual_srcdset_t { /* Not stored */ struct H5D_t *dset; /* Source dataset */ + + /* Temporary - only used during I/O operation, NULL at all other times */ + struct H5S_t *projected_mem_space; /* Selection within mem_space for this mapping */ } H5O_storage_virtual_srcdset_t; typedef struct H5O_storage_virtual_name_seg_t { diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 399d009..87fb3a9 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -9627,6 +9627,116 @@ done: /*-------------------------------------------------------------------------- NAME + H5S__hyper_subtract + PURPOSE + VDSINC + USAGE + VDSINC + RETURNS + Non-negative on success/Negative on failure. + DESCRIPTION + VDSINC + + Note this function basically duplicates a subset of the functionality + of H5S_select_select(). It should probably be removed when that + function is enabled. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5S__hyper_subtract (H5S_t *space, H5S_t *subtract_space) +{ + H5S_hyper_span_info_t *a_not_b = NULL; /* Span tree for hyperslab spans in old span tree and not in new span tree */ + H5S_hyper_span_info_t *a_and_b = NULL; /* Span tree for hyperslab spans in both old and new span trees */ + H5S_hyper_span_info_t *b_not_a = NULL; /* Span tree for hyperslab spans in new span tree and not in old span tree */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Check args */ + HDassert(space); + HDassert(subtract_space); + + /* Check that the space selections both have span trees */ + if(space->select.sel_info.hslab->span_lst == NULL) + if(H5S_hyper_generate_spans(space) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree") + if(subtract_space->select.sel_info.hslab->span_lst == NULL) + if(H5S_hyper_generate_spans(subtract_space) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree") + + /* Generate lists of spans which overlap and don't overlap */ + if(H5S_hyper_clip_spans(space->select.sel_info.hslab->span_lst, subtract_space->select.sel_info.hslab->span_lst, &a_not_b, &a_and_b, &b_not_a)<0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information") + + /* Reset the other dataspace selection information */ + if(H5S_SELECT_RELEASE(space) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection") + + /* Allocate space for the hyperslab selection information */ + if((space->select.sel_info.hslab = H5FL_CALLOC(H5S_hyper_sel_t)) == NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab info") + + /* Set unlim_dim */ + space->select.sel_info.hslab->unlim_dim = -1; + + /* Check for anything returned in a_not_b */ + if(a_not_b) { + /* Update spans in space */ + space->select.sel_info.hslab->span_lst = a_not_b; + a_not_b = NULL; + + /* Update number of elements */ + space->select.num_elem = H5S_hyper_spans_nelem(space->select.sel_info.hslab->span_lst); + + /* Attempt to rebuild "optimized" start/stride/count/block information. + * from resulting hyperslab span tree */ + if(H5S_hyper_rebuild(space) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't rebuild hyperslab info") + } /* end if */ + else { + H5S_hyper_span_info_t *spans; /* Empty hyperslab span tree */ + + HDassert(0 && "Checking code coverage..."); //VDSINC + /* Set number of elements */ + space->select.num_elem = 0; + + /* Allocate a span info node */ + if(NULL == (spans = H5FL_MALLOC(H5S_hyper_span_info_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span") + + /* Set the reference count */ + spans->count = 1; + + /* Reset the scratch pad space */ + spans->scratch = 0; + + /* Set to empty tree */ + spans->head = NULL; + + /* Set pointer to empty span tree */ + space->select.sel_info.hslab->span_lst = spans; + } /* end if */ + +done: + /* Free span trees */ + if(a_and_b) + H5S_hyper_free_span_info(a_and_b); + if(b_not_a) + H5S_hyper_free_span_info(b_not_a); + if(a_not_b) { + HDassert(ret_value < 0); + H5S_hyper_free_span_info(b_not_a); + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5S__hyper_subtract() */ + + +/*-------------------------------------------------------------------------- + NAME H5S__hyper_get_clip_diminfo PURPOSE Calculates the count and block required to clip the specified diff --git a/src/H5Spkg.h b/src/H5Spkg.h index 77ca954..1359b00 100644 --- a/src/H5Spkg.h +++ b/src/H5Spkg.h @@ -276,6 +276,7 @@ H5_DLL herr_t H5S_extent_copy_real(H5S_extent_t *dst, const H5S_extent_t *src, H5_DLL herr_t H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, const H5S_t *src_intersect_space, H5S_t *proj_space); +H5_DLL herr_t H5S__hyper_subtract (H5S_t *space, H5S_t *subtract_space); /* Testing functions */ #ifdef H5S_TESTING diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index 342a9cc..976c968 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -241,6 +241,7 @@ H5_DLL herr_t H5S_select_project_simple(const H5S_t *space, H5S_t *new_space, hs H5_DLL herr_t H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, const H5S_t *src_intersect_space, H5S_t **new_space_ptr); +H5_DLL herr_t H5S_select_subtract(H5S_t *space, H5S_t *subtract_space); /* Operations on all selections */ H5_DLL herr_t H5S_select_all(H5S_t *space, hbool_t rel_prev); diff --git a/src/H5Sselect.c b/src/H5Sselect.c index c120769..0af3dfa 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -2259,3 +2259,92 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5S_select_project_intersection() */ + +/*-------------------------------------------------------------------------- + NAME + H5S_select_subtract + + PURPOSE + VDSINC + + USAGE + VDSINC + + RETURNS + Non-negative on success/Negative on failure. + + DESCRIPTION + VDSINC + + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5S_select_subtract(H5S_t *space, H5S_t *subtract_space) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(space); + HDassert(subtract_space); + + /* If either space is using the none selection, then we do not need to do + * anything */ + if((space->select.type->type != H5S_SEL_NONE) + && (subtract_space->select.type->type != H5S_SEL_NONE)) { + /* If subtract_space is using the all selection, set space to none */ + if(subtract_space->select.type->type == H5S_SEL_ALL) { + HDassert(0 && "Checking code coverage...");//VDSINC + /* Change to "none" selection */ + if(H5S_select_none(space) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") + } /* end if */ + else { + /* Check for point selection in subtract_space, convert to + * hyperslab */ + if(subtract_space->select.type->type == H5S_SEL_POINTS) + HDassert(0 && "Not yet implemented...");//VDSINC + + /* Check for point or all selection in space, convert to hyperslab + */ + if(space->select.type->type == H5S_SEL_ALL) { + /* Convert current "all" selection to "real" hyperslab selection */ + /* Then allow operation to proceed */ + hsize_t tmp_start[H5O_LAYOUT_NDIMS]; /* Temporary start information */ + hsize_t tmp_stride[H5O_LAYOUT_NDIMS]; /* Temporary stride information */ + hsize_t tmp_count[H5O_LAYOUT_NDIMS]; /* Temporary count information */ + hsize_t tmp_block[H5O_LAYOUT_NDIMS]; /* Temporary block information */ + unsigned i; /* Local index variable */ + + /* Fill in temporary information for the dimensions */ + for(i = 0; i < space->extent.rank; i++) { + tmp_start[i] = 0; + tmp_stride[i] = 1; + tmp_count[i] = 1; + tmp_block[i] = space->extent.size[i]; + } /* end for */ + + /* Convert to hyperslab selection */ + if(H5S_select_hyperslab(space, H5S_SELECT_SET, tmp_start, tmp_stride, tmp_count, tmp_block) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") + } /* end if */ + else if(space->select.type->type == H5S_SEL_POINTS) + HDassert(0 && "Not yet implemented...");//VDSINC + + HDassert(space->select.type->type == H5S_SEL_HYPERSLABS); + HDassert(subtract_space->select.type->type == H5S_SEL_HYPERSLABS); + + /* Both spaces are now hyperslabs, perform the operation */ + if(H5S__hyper_subtract(space, subtract_space) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't subtract hyperslab") + } /* end else */ + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5S_select_subtract() */ + diff --git a/test/h5test.c b/test/h5test.c index 88a8afa..848712c 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -122,9 +122,9 @@ h5_errors(hid_t estack, void UNUSED *client_data) /*------------------------------------------------------------------------- - * Function: h5_close_files + * Function: h5_cleanup_files * - * Purpose: Cleanup temporary test files (always closes). + * Purpose: Cleanup temporary test files (always). * base_name contains the list of test file names. * * Return: void @@ -137,7 +137,7 @@ h5_errors(hid_t estack, void UNUSED *client_data) *------------------------------------------------------------------------- */ void -h5_close_files(const char *base_name[], hid_t fapl) +h5_cleanup_files(const char *base_name[], hid_t fapl) { int i; @@ -185,7 +185,7 @@ h5_close_files(const char *base_name[], hid_t fapl) } /* end for */ return; -} /* end h5_close_files() */ +} /* end h5_cleanup_files() */ /*------------------------------------------------------------------------- @@ -208,8 +208,8 @@ h5_cleanup(const char *base_name[], hid_t fapl) int retval = 0; if(GetTestCleanup()) { - /* Close files in base_name */ - h5_close_files(base_name, fapl); + /* Clean up files in base_name */ + h5_cleanup_files(base_name, fapl); retval = 1; } /* end if */ diff --git a/test/h5test.h b/test/h5test.h index e033322..46c73b6 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -142,7 +142,7 @@ extern "C" { /* Generally useful testing routines */ H5TEST_DLL int h5_cleanup(const char *base_name[], hid_t fapl); -H5TEST_DLL void h5_close_files(const char *base_name[], hid_t fapl); +H5TEST_DLL void h5_cleanup_files(const char *base_name[], hid_t fapl); H5TEST_DLL char *h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size); H5TEST_DLL char *h5_fixname_no_suffix(const char *base_name, hid_t fapl, char *fullname, size_t size); H5TEST_DLL hid_t h5_fileaccess(void); @@ -1009,8 +1009,10 @@ test_basic_io(unsigned config, hid_t fapl) hsize_t coord[10]; /* Point selection array */ int buf[10][26]; /* Write and expected read buffer */ int rbuf[10][26]; /* Read buffer */ + int rbuf99[9][9]; /* 9x9 Read buffer */ int evbuf[10][26]; /* Expected VDS "buffer" */ int erbuf[10][26]; /* Expected read buffer */ + int fill = -1; /* Fill value */ int i, j; TESTING("basic virtual dataset I/O") @@ -1022,6 +1024,10 @@ test_basic_io(unsigned config, hid_t fapl) if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR + /* Set fill value */ + if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill) < 0) + TEST_ERROR + /* * Test 1: All - all selection */ @@ -2314,8 +2320,8 @@ test_basic_io(unsigned config, hid_t fapl) /* Select hyperslab in memory space */ start[0] = 0; start[1] = 0; - count[0] = 3; - count[1] = 9; + count[0] = 9; + count[1] = 3; if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL ,count, NULL) < 0) TEST_ERROR @@ -2341,16 +2347,19 @@ test_basic_io(unsigned config, hid_t fapl) /* Update erbuf */ HDmemset(erbuf, 0, sizeof(erbuf)); + for(i = 0; i < 9; i++) + for(j = 0; j < 3; j++) + erbuf[i][j] = fill; erbuf[0][0] = buf[0][0]; erbuf[0][2] = buf[0][1]; - erbuf[0][6] = buf[0][8]; - erbuf[0][8] = buf[0][9]; - erbuf[2][0] = buf[1][0]; - erbuf[2][2] = buf[1][1]; - erbuf[2][6] = buf[1][8]; - erbuf[2][8] = buf[1][9]; - erbuf[1][3] = buf[0][13]; - erbuf[1][5] = buf[0][14]; + erbuf[2][0] = buf[0][8]; + erbuf[2][2] = buf[0][9]; + erbuf[6][0] = buf[1][0]; + erbuf[6][2] = buf[1][1]; + erbuf[8][0] = buf[1][8]; + erbuf[8][2] = buf[1][9]; + erbuf[4][0] = buf[0][13]; + erbuf[4][2] = buf[0][14]; /* Verify read data */ for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) @@ -2373,30 +2382,45 @@ test_basic_io(unsigned config, hid_t fapl) if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL ,count, NULL) < 0) TEST_ERROR + /* Select hyperslab in memory space */ + start[0] = 0; + start[1] = 3; + count[0] = 9; + count[1] = 3; + if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL ,count, NULL) < 0) + TEST_ERROR + /* Read second stripe pattern */ if(H5Dread(vdset, H5T_NATIVE_INT, memspace, vspace[0], H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Update erbuf */ - HDmemset(erbuf, 0, sizeof(erbuf)); - erbuf[0][3] = buf[0][4]; - erbuf[0][5] = buf[0][5]; - erbuf[1][0] = buf[0][6]; - erbuf[1][1] = buf[0][7]; - erbuf[1][2] = buf[0][12]; - erbuf[1][3] = buf[0][15]; - erbuf[1][5] = buf[1][4]; - erbuf[1][6] = buf[1][7]; - erbuf[1][7] = buf[1][12]; - erbuf[1][8] = buf[1][13]; - erbuf[2][3] = buf[1][14]; - erbuf[2][5] = buf[1][15]; + for(i = 0; i < 9; i++) + for(j = 3; j < 6; j++) + erbuf[i][j] = fill; + erbuf[1][3] = buf[0][4]; + erbuf[1][5] = buf[0][5]; + erbuf[3][3] = buf[0][6]; + erbuf[3][4] = buf[0][7]; + erbuf[3][5] = buf[0][12]; + erbuf[4][3] = buf[0][15]; + erbuf[4][5] = buf[1][4]; + erbuf[5][3] = buf[1][7]; + erbuf[5][4] = buf[1][12]; + erbuf[5][5] = buf[1][13]; + erbuf[7][3] = buf[1][14]; + erbuf[7][5] = buf[1][15]; /* Verify read data */ for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + if((j >= 3) && (j < 6)) { + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != 0) + TEST_ERROR /* Reset rbuf */ HDmemset(rbuf[0], 0, sizeof(rbuf)); @@ -2413,27 +2437,62 @@ test_basic_io(unsigned config, hid_t fapl) if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL ,count, NULL) < 0) TEST_ERROR + /* Select hyperslab in memory space */ + start[0] = 0; + start[1] = 6; + count[0] = 9; + count[1] = 3; + if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL ,count, NULL) < 0) + TEST_ERROR + /* Read third stripe pattern */ if(H5Dread(vdset, H5T_NATIVE_INT, memspace, vspace[0], H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Update erbuf */ - HDmemset(erbuf, 0, sizeof(erbuf)); - erbuf[0][0] = buf[0][2]; - erbuf[0][2] = buf[0][3]; - erbuf[0][6] = buf[0][10]; - erbuf[0][8] = buf[0][11]; - erbuf[2][0] = buf[1][2]; - erbuf[2][2] = buf[1][3]; - erbuf[2][6] = buf[1][10]; - erbuf[2][8] = buf[1][11]; - erbuf[1][3] = buf[1][5]; - erbuf[1][5] = buf[1][6]; + for(i = 0; i < 9; i++) + for(j = 6; j < 9; j++) + erbuf[i][j] = fill; + erbuf[0][6] = buf[0][2]; + erbuf[0][8] = buf[0][3]; + erbuf[2][6] = buf[0][10]; + erbuf[2][8] = buf[0][11]; + erbuf[6][6] = buf[1][2]; + erbuf[6][8] = buf[1][3]; + erbuf[8][6] = buf[1][10]; + erbuf[8][8] = buf[1][11]; + erbuf[4][6] = buf[1][5]; + erbuf[4][8] = buf[1][6]; /* Verify read data */ for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != erbuf[i][j]) + if((j >= 6) && (j < 9)) { + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != 0) + TEST_ERROR + + /* Now read entire VDS */ + /* Set memory space extent to 9x9, select all in order to reach part of the + * code in H5S_select_subtract() */ + dims[0] = 9; + dims[1] = 9; + if(H5Sset_extent_simple(memspace, 2, dims, NULL) < 0) + TEST_ERROR + if(H5Sselect_all(memspace) < 0) + TEST_ERROR + + /* Read third stripe pattern */ + if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf99[0]) < 0) + TEST_ERROR + + /* Verify read data */ + for(i = 0; i < (int)(sizeof(rbuf99) / sizeof(rbuf99[0])); i++) + for(j = 0; j < (int)(sizeof(rbuf99[0]) / sizeof(rbuf99[0][0])); j++) + if(rbuf99[i][j] != erbuf[i][j]) TEST_ERROR /* Adjust write buffer */ @@ -2442,16 +2501,46 @@ test_basic_io(unsigned config, hid_t fapl) buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); /* Write data through virtual dataset by hyperslab */ - /* Select stripe */ + /* Select stripe (only select mapped elements) */ start[0] = 0; start[1] = 0; start[2] = 0; start[3] = 0; - count[0] = 3; - count[1] = 3; + stride[0] = 2; + stride[1] = 2; + stride[2] = 1; + stride[3] = 2; + count[0] = 2; + count[1] = 2; count[2] = 1; - count[3] = 3; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL ,count, NULL) < 0) + count[3] = 2; + if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride ,count, NULL) < 0) + TEST_ERROR + start[0] = 1; + start[1] = 1; + start[2] = 0; + start[3] = 0; + stride[0] = 1; + stride[1] = 1; + stride[2] = 1; + stride[3] = 2; + count[0] = 1; + count[1] = 1; + count[2] = 1; + count[3] = 2; + if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_OR, start, stride ,count, NULL) < 0) + TEST_ERROR + + /* Reset extent of memspace, select hyperslab */ + dims[0] = 10; + dims[1] = 26; + if(H5Sset_extent_simple(memspace, 2, dims, NULL) < 0) + TEST_ERROR + start[0] = 0; + start[1] = 0; + count[0] = 1; + count[1] = 10; + if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL ,count, NULL) < 0) TEST_ERROR /* Write data through virtual dataset by hyperslab */ @@ -2462,31 +2551,57 @@ test_basic_io(unsigned config, hid_t fapl) /* Update erbuf */ HDmemset(erbuf, 0, sizeof(erbuf)); erbuf[0][0] = buf[0][0]; - erbuf[0][1] = buf[0][2]; - erbuf[0][8] = buf[0][6]; - erbuf[0][9] = buf[0][8]; - erbuf[1][0] = buf[2][0]; - erbuf[1][1] = buf[2][2]; - erbuf[1][8] = buf[2][6]; - erbuf[1][9] = buf[2][8]; - erbuf[0][13] = buf[1][3]; - erbuf[0][14] = buf[1][5]; + erbuf[0][1] = buf[0][1]; + erbuf[0][8] = buf[0][2]; + erbuf[0][9] = buf[0][3]; + erbuf[1][0] = buf[0][6]; + erbuf[1][1] = buf[0][7]; + erbuf[1][8] = buf[0][8]; + erbuf[1][9] = buf[0][9]; + erbuf[0][13] = buf[0][4]; + erbuf[0][14] = buf[0][5]; /* Adjust write buffer */ for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); - /* Select stripe */ + /* Select stripe (only select mapped elements) */ start[0] = 0; - start[1] = 0; + start[1] = 1; start[2] = 1; start[3] = 0; + stride[0] = 1; + stride[1] = 1; + stride[2] = 1; + stride[3] = 2; count[0] = 3; - count[1] = 3; + count[1] = 1; + count[2] = 1; + count[3] = 2; + if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride ,count, NULL) < 0) + TEST_ERROR + start[0] = 1; + start[1] = 0; + start[2] = 1; + start[3] = 0; + stride[0] = 1; + stride[1] = 2; + stride[2] = 1; + stride[3] = 1; + count[0] = 1; + count[1] = 2; count[2] = 1; count[3] = 3; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL ,count, NULL) < 0) + if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_OR, start, stride ,count, NULL) < 0) + TEST_ERROR + + /* Select hyperslab in memory space */ + start[0] = 0; + start[1] = 0; + count[0] = 1; + count[1] = 12; + if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL ,count, NULL) < 0) TEST_ERROR /* Write second slice */ @@ -2494,34 +2609,60 @@ test_basic_io(unsigned config, hid_t fapl) TEST_ERROR /* Update erbuf */ - erbuf[0][4] = buf[0][3]; - erbuf[0][5] = buf[0][5]; - erbuf[0][6] = buf[1][0]; - erbuf[0][7] = buf[1][1]; - erbuf[0][12] = buf[1][2]; - erbuf[0][15] = buf[1][3]; - erbuf[1][4] = buf[1][5]; - erbuf[1][7] = buf[1][6]; - erbuf[1][12] = buf[1][7]; - erbuf[1][13] = buf[1][8]; - erbuf[1][14] = buf[2][3]; - erbuf[1][15] = buf[2][5]; + erbuf[0][4] = buf[0][0]; + erbuf[0][5] = buf[0][1]; + erbuf[0][6] = buf[0][2]; + erbuf[0][7] = buf[0][3]; + erbuf[0][12] = buf[0][4]; + erbuf[0][15] = buf[0][5]; + erbuf[1][4] = buf[0][6]; + erbuf[1][7] = buf[0][7]; + erbuf[1][12] = buf[0][8]; + erbuf[1][13] = buf[0][9]; + erbuf[1][14] = buf[0][10]; + erbuf[1][15] = buf[0][11]; /* Adjust write buffer */ for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); - /* Select stripe */ + /* Select stripe (only select mapped elements) */ start[0] = 0; start[1] = 0; start[2] = 2; start[3] = 0; - count[0] = 3; - count[1] = 3; + stride[0] = 2; + stride[1] = 2; + stride[2] = 1; + stride[3] = 2; + count[0] = 2; + count[1] = 2; count[2] = 1; - count[3] = 3; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL ,count, NULL) < 0) + count[3] = 2; + if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride ,count, NULL) < 0) + TEST_ERROR + start[0] = 1; + start[1] = 1; + start[2] = 2; + start[3] = 0; + stride[0] = 1; + stride[1] = 1; + stride[2] = 1; + stride[3] = 2; + count[0] = 1; + count[1] = 1; + count[2] = 1; + count[3] = 2; + if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_OR, start, stride ,count, NULL) < 0) + TEST_ERROR + + /* Select hyperslab in memory space */ + start[0] = 0; + start[1] = 0; + count[0] = 1; + count[1] = 10; + if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL ,count, NULL) < 0) TEST_ERROR /* Write third slice */ @@ -2530,15 +2671,15 @@ test_basic_io(unsigned config, hid_t fapl) /* Update erbuf */ erbuf[0][2] = buf[0][0]; - erbuf[0][3] = buf[0][2]; - erbuf[0][10] = buf[0][6]; - erbuf[0][11] = buf[0][8]; - erbuf[1][2] = buf[2][0]; - erbuf[1][3] = buf[2][2]; - erbuf[1][10] = buf[2][6]; - erbuf[1][11] = buf[2][8]; - erbuf[1][5] = buf[1][3]; - erbuf[1][6] = buf[1][5]; + erbuf[0][3] = buf[0][1]; + erbuf[0][10] = buf[0][2]; + erbuf[0][11] = buf[0][3]; + erbuf[1][2] = buf[0][6]; + erbuf[1][3] = buf[0][7]; + erbuf[1][10] = buf[0][8]; + erbuf[1][11] = buf[0][9]; + erbuf[1][5] = buf[0][4]; + erbuf[1][6] = buf[0][5]; /* Reopen srcdset and srcfile if config option specified */ if(config & TEST_IO_CLOSE_SRC) { @@ -2684,6 +2825,7 @@ test_unlim(unsigned config, hid_t fapl) int rbuf[10][20]; /* Read buffer */ int erbuf[10][20]; /* Expected read buffer */ int ndims; /* Number of dimensions */ + int fill = -1; /* Fill value */ int i, j; TESTING("virtual dataset I/O with unlimited selections") @@ -2697,14 +2839,18 @@ test_unlim(unsigned config, hid_t fapl) if((srcdcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - /* Create DAPL */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + /* Set fill value */ + if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill) < 0) TEST_ERROR /* Set chunk dimensions */ if(H5Pset_chunk(srcdcpl, 2, cdims) < 0) TEST_ERROR + /* Create DAPL */ + if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + TEST_ERROR + /* Create memory space */ if((memspace = H5Screate_simple(2, mdims, NULL)) < 0) TEST_ERROR @@ -2784,7 +2930,7 @@ test_unlim(unsigned config, hid_t fapl) /* Initialize erbuf */ for(i = 0; i < (int)mdims[0]; i++) for(j = 0; j < (int)mdims[1]; j++) - erbuf[i][j] = -1; + erbuf[i][j] = fill; /* Write data directly to source datasets */ /* Select hyperslab in memory */ @@ -2872,12 +3018,7 @@ test_unlim(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ start[0] = 0; @@ -2890,9 +3031,15 @@ test_unlim(unsigned config, hid_t fapl) /* Verify read data */ for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end for */ /* Close VDS and reopen with view set to H5D_VDS_FIRST_MISSING, reopen file * as well if config option specified */ @@ -2936,12 +3083,7 @@ test_unlim(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Read data */ if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) @@ -2949,9 +3091,15 @@ test_unlim(unsigned config, hid_t fapl) /* Verify read data */ for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end for */ /* Reopen srcdset[0] and srcfile if config option specified */ if(config & TEST_IO_CLOSE_SRC) { @@ -3040,12 +3188,7 @@ test_unlim(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ start[1] = 0; @@ -3058,9 +3201,15 @@ test_unlim(unsigned config, hid_t fapl) /* Verify read data */ for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end for */ /* Close VDS and reopen with view set to H5D_VDS_LAST_AVAILABLE, reopen file * as well if config option specified */ @@ -3110,12 +3259,7 @@ test_unlim(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ start[1] = 0; @@ -3128,9 +3272,15 @@ test_unlim(unsigned config, hid_t fapl) /* Verify read data */ for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end for */ /* Reopen srcdset[1] and srcfile if config option specified */ if(config & TEST_IO_CLOSE_SRC) { @@ -3222,12 +3372,7 @@ test_unlim(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ start[1] = 0; @@ -3245,9 +3390,7 @@ test_unlim(unsigned config, hid_t fapl) TEST_ERROR /* Now just read middle 2 rows */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); start[0] = 4; count[0] = 2; count[1] = 20; @@ -3265,7 +3408,7 @@ test_unlim(unsigned config, hid_t fapl) TEST_ERROR } /* end if */ else - if(rbuf[i][j] != -1) + if(rbuf[i][j] != 0) TEST_ERROR /* Close VDS and reopen with view set to H5D_VDS_FIRST_MISSING, reopen file @@ -3288,7 +3431,7 @@ test_unlim(unsigned config, hid_t fapl) * change to H5D_VDS_FIRST_MISSING */ for(i = 5; i < 10; i++) for(j = 15; j < 20; j++) - erbuf[i][j] = -1; + erbuf[i][j] = fill; /* Get VDS space */ if((filespace = H5Dget_space(vdset)) < 0) @@ -3316,12 +3459,7 @@ test_unlim(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ start[0] = 0; @@ -3335,9 +3473,15 @@ test_unlim(unsigned config, hid_t fapl) /* Verify read data */ for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end for */ /* Close */ if(!(config & TEST_IO_CLOSE_SRC)) { @@ -3456,7 +3600,7 @@ test_unlim(unsigned config, hid_t fapl) /* Initialize erbuf */ for(i = 0; i < (int)mdims[0]; i++) for(j = 0; j < (int)mdims[1]; j++) - erbuf[i][j] = -1; + erbuf[i][j] = fill; /* Write data directly to source datasets */ /* Select hyperslab in memory */ @@ -3544,12 +3688,7 @@ test_unlim(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -3561,9 +3700,15 @@ test_unlim(unsigned config, hid_t fapl) /* Verify read data */ for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end for */ /* Close VDS and reopen with view set to H5D_VDS_FIRST_MISSING, reopen file * as well if config option specified */ @@ -3607,12 +3752,7 @@ test_unlim(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Read data */ if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) @@ -3620,9 +3760,15 @@ test_unlim(unsigned config, hid_t fapl) /* Verify read data */ for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end for */ /* Reopen srcdset[0] and srcfile if config option specified */ if(config & TEST_IO_CLOSE_SRC) { @@ -3716,12 +3862,7 @@ test_unlim(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -3733,9 +3874,15 @@ test_unlim(unsigned config, hid_t fapl) /* Verify read data */ for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end for */ /* Close VDS and reopen with view set to H5D_VDS_LAST_AVAILABLE, reopen file * as well if config option specified */ @@ -3784,12 +3931,7 @@ test_unlim(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -3801,9 +3943,15 @@ test_unlim(unsigned config, hid_t fapl) /* Verify read data */ for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end for */ /* Reopen srcdset[1] and srcfile if config option specified */ if(config & TEST_IO_CLOSE_SRC) { @@ -3895,12 +4043,7 @@ test_unlim(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -3917,9 +4060,7 @@ test_unlim(unsigned config, hid_t fapl) TEST_ERROR /* Now just read middle 2 rows */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); start[0] = 4; count[0] = 2; count[1] = 20; @@ -3938,7 +4079,7 @@ test_unlim(unsigned config, hid_t fapl) TEST_ERROR } /* end if */ else - if(rbuf[i][j] != -1) + if(rbuf[i][j] != 0) TEST_ERROR /* Close VDS and reopen with view set to H5D_VDS_FIRST_MISSING, reopen file @@ -3961,7 +4102,7 @@ test_unlim(unsigned config, hid_t fapl) * change to H5D_VDS_FIRST_MISSING */ for(i = 0; i < 10; i++) for(j = 15; j < 20; j += 2) - erbuf[i][j] = -1; + erbuf[i][j] = fill; /* Get VDS space */ if((filespace = H5Dget_space(vdset)) < 0) @@ -3989,12 +4130,7 @@ test_unlim(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -4006,9 +4142,15 @@ test_unlim(unsigned config, hid_t fapl) /* Verify read data */ for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end for */ /* Close */ if(!(config & TEST_IO_CLOSE_SRC)) { @@ -4148,7 +4290,7 @@ test_unlim(unsigned config, hid_t fapl) /* Initialize erbuf */ for(i = 0; i < (int)mdims[0]; i++) for(j = 0; j < (int)mdims[1]; j++) - erbuf[i][j] = -1; + erbuf[i][j] = fill; /* Write data directly to source datasets */ /* Select hyperslab in memory */ @@ -4264,12 +4406,7 @@ test_unlim(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -4281,9 +4418,15 @@ test_unlim(unsigned config, hid_t fapl) /* Verify read data */ for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end for */ /* Close VDS and reopen with view set to H5D_VDS_FIRST_MISSING, reopen file * as well if config option specified */ @@ -4327,12 +4470,7 @@ test_unlim(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Read data */ if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) @@ -4340,9 +4478,15 @@ test_unlim(unsigned config, hid_t fapl) /* Verify read data */ for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end for */ /* Reopen srcdset[0] and srcfile if config option specified */ if(config & TEST_IO_CLOSE_SRC) { @@ -4430,12 +4574,7 @@ test_unlim(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -4447,9 +4586,15 @@ test_unlim(unsigned config, hid_t fapl) /* Verify read data */ for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end for */ /* Close VDS and reopen with view set to H5D_VDS_LAST_AVAILABLE, reopen file * as well if config option specified */ @@ -4501,12 +4646,7 @@ test_unlim(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -4518,9 +4658,15 @@ test_unlim(unsigned config, hid_t fapl) /* Verify read data */ for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end for */ /* Reopen srcdset[2] and srcfile if config option specified */ if(config & TEST_IO_CLOSE_SRC) { @@ -4615,12 +4761,7 @@ test_unlim(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -4632,9 +4773,15 @@ test_unlim(unsigned config, hid_t fapl) /* Verify read data */ for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end for */ /* Close VDS and reopen with view set to H5D_VDS_FIRST_MISSING, reopen file * as well if config option specified */ @@ -4678,12 +4825,7 @@ test_unlim(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -4693,17 +4835,17 @@ test_unlim(unsigned config, hid_t fapl) if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR - /* Verify read data - algorithmically check for no data past the extent so - * we don't have to wipe out erbuf and then restore it afterwards */ + /* Verify read data */ for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(j < 14) { - if(rbuf[i][j] != erbuf[i][j]) + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) TEST_ERROR } /* end if */ else - if(rbuf[i][j] != -1) + if(rbuf[i][j] != erbuf[i][j]) TEST_ERROR + } /* end for */ /* Reopen srcdset[1] and srcfile if config option specified */ if(config & TEST_IO_CLOSE_SRC) { @@ -4796,12 +4938,7 @@ test_unlim(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -4811,17 +4948,17 @@ test_unlim(unsigned config, hid_t fapl) if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR - /* Verify read data - algorithmically check for no data past the extent so - * we don't have to wipe out erbuf and then restore it afterwards */ + /* Verify read data */ for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(j < 17) { - if(rbuf[i][j] != erbuf[i][j]) + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) TEST_ERROR } /* end if */ else - if(rbuf[i][j] != -1) + if(rbuf[i][j] != erbuf[i][j]) TEST_ERROR + } /* end for */ /* Close VDS and reopen with view set to H5D_VDS_LAST_AVAILABLE, reopen file * as well if config option specified */ @@ -4861,12 +4998,7 @@ test_unlim(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -4878,14 +5010,18 @@ test_unlim(unsigned config, hid_t fapl) /* Verify read data */ for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end for */ /* Now just read middle 2 rows */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); start[0] = 4; count[0] = 2; count[1] = 19; @@ -4905,12 +5041,16 @@ test_unlim(unsigned config, hid_t fapl) * read */ for(i = 0; i < (int)mdims[0]; i++) for(j = 0; j < (int)mdims[1]; j++) - if((i == 4) || (i == 5)) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else if((i == 4) || (i == 5)) { if(rbuf[i][j] != erbuf[i][j]) TEST_ERROR } /* end if */ else - if(rbuf[i][j] != -1) + if(rbuf[i][j] != 0) TEST_ERROR /* Close */ @@ -5056,6 +5196,7 @@ test_printf(unsigned config, hid_t fapl) int rbuf[10][20]; /* Read buffer */ int erbuf[10][20]; /* Expected read buffer */ int ndims; /* Number of dimensions */ + int fill = -1; /* Fill value */ int i, j; TESTING("virtual dataset I/O with printf source") @@ -5069,6 +5210,10 @@ test_printf(unsigned config, hid_t fapl) if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR + /* Set fill value */ + if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill) < 0) + TEST_ERROR + /* Create DAPL */ if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) TEST_ERROR @@ -5193,7 +5338,7 @@ test_printf(unsigned config, hid_t fapl) /* Initialize erbuf */ for(i = 0; i < (int)mdims[0]; i++) for(j = 0; j < (int)mdims[1]; j++) - erbuf[i][j] = -1; + erbuf[i][j] = fill; /* Write to srcdset[0] */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) @@ -5276,12 +5421,7 @@ test_printf(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -5293,9 +5433,15 @@ test_printf(unsigned config, hid_t fapl) /* Verify read data */ for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end for */ /* Reopen srcfile if config option specified */ if((config & TEST_IO_CLOSE_SRC) && (config & TEST_IO_DIFFERENT_FILE)) @@ -5375,12 +5521,7 @@ test_printf(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -5392,9 +5533,15 @@ test_printf(unsigned config, hid_t fapl) /* Verify read data */ for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end for */ /* Close */ if(!(config & TEST_IO_CLOSE_SRC)) { @@ -5554,7 +5701,7 @@ test_printf(unsigned config, hid_t fapl) /* Initialize erbuf */ for(i = 0; i < (int)mdims[0]; i++) for(j = 0; j < (int)mdims[1]; j++) - erbuf[i][j] = -1; + erbuf[i][j] = fill; /* Write to srcdset[0] */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) @@ -5686,12 +5833,7 @@ test_printf(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -5705,7 +5847,7 @@ test_printf(unsigned config, hid_t fapl) for(i = 0; i < (int)mdims[0]; i++) for(j = 0; j < (int)mdims[1]; j++) { if(j >= (int)dims[1]) { - if(rbuf[i][j] != -1) + if(rbuf[i][j] != 0) TEST_ERROR } /* end if */ else @@ -5755,12 +5897,7 @@ test_printf(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -5774,7 +5911,7 @@ test_printf(unsigned config, hid_t fapl) for(i = 0; i < (int)mdims[0]; i++) for(j = 0; j < (int)mdims[1]; j++) { if(j >= (int)dims[1]) { - if(rbuf[i][j] != -1) + if(rbuf[i][j] != 0) TEST_ERROR } /* end if */ else @@ -5824,12 +5961,7 @@ test_printf(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -5843,7 +5975,7 @@ test_printf(unsigned config, hid_t fapl) for(i = 0; i < (int)mdims[0]; i++) for(j = 0; j < (int)mdims[1]; j++) { if(j >= (int)dims[1]) { - if(rbuf[i][j] != -1) + if(rbuf[i][j] != 0) TEST_ERROR } /* end if */ else @@ -5893,12 +6025,7 @@ test_printf(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -5912,7 +6039,7 @@ test_printf(unsigned config, hid_t fapl) for(i = 0; i < (int)mdims[0]; i++) for(j = 0; j < (int)mdims[1]; j++) { if(j >= (int)dims[1]) { - if(rbuf[i][j] != -1) + if(rbuf[i][j] != 0) TEST_ERROR } /* end if */ else @@ -5962,12 +6089,7 @@ test_printf(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -5981,7 +6103,7 @@ test_printf(unsigned config, hid_t fapl) for(i = 0; i < (int)mdims[0]; i++) for(j = 0; j < (int)mdims[1]; j++) { if(j >= (int)dims[1]) { - if(rbuf[i][j] != -1) + if(rbuf[i][j] != 0) TEST_ERROR } /* end if */ else @@ -6031,12 +6153,7 @@ test_printf(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -6050,7 +6167,7 @@ test_printf(unsigned config, hid_t fapl) for(i = 0; i < (int)mdims[0]; i++) for(j = 0; j < (int)mdims[1]; j++) { if(j >= (int)dims[1]) { - if(rbuf[i][j] != -1) + if(rbuf[i][j] != 0) TEST_ERROR } /* end if */ else @@ -6094,619 +6211,628 @@ test_printf(unsigned config, hid_t fapl) vspace[0] = -1; - /* - * Test 3: 1 Source dataset mapping, 10x5 blocks, printf source file - */ - /* Clean up files so the source files do not exist yet */ - h5_close_files(FILENAME, fapl); + /* Next 2 tests are always run with a different source file, so only run if + * that config option is set (so they're not run twice with the same + * configuration) */ + if(config & TEST_IO_DIFFERENT_FILE) { + /* + * Test 3: 1 Source dataset mapping, 10x5 blocks, printf source file + */ + /* Clean up files so the source files do not exist yet */ + h5_cleanup_files(FILENAME, fapl); - /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) - TEST_ERROR + /* Clear virtual layout in DCPL */ + if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + TEST_ERROR - /* Create virtual dataspaces */ - if((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) - TEST_ERROR + /* Create virtual dataspaces */ + if((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) + TEST_ERROR - /* Create source dataspace */ - dims[1] = 5; - if((srcspace = H5Screate_simple(2, dims, NULL)) < 0) - TEST_ERROR + /* Create source dataspace */ + dims[1] = 5; + if((srcspace = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR - /* Select hyperslabs in virtual space */ - stride[0] = 1; - stride[1] = 5; - count[0] = 1; - count[1] = H5S_UNLIMITED; - block[0] = 10; - block[1] = 5; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) - TEST_ERROR + /* Select hyperslabs in virtual space */ + stride[0] = 1; + stride[1] = 5; + count[0] = 1; + count[1] = H5S_UNLIMITED; + block[0] = 10; + block[1] = 5; + if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) + TEST_ERROR - /* Add virtual layout mapping */ - if(H5Pset_virtual(dcpl, vspace[0], printf_srcfilename, "src_dset", srcspace) < 0) - TEST_ERROR + /* Add virtual layout mapping */ + if(H5Pset_virtual(dcpl, vspace[0], printf_srcfilename, "src_dset", srcspace) < 0) + TEST_ERROR - /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR + /* Create virtual file */ + if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR - /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) - TEST_ERROR + /* Create virtual dataset */ + if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) + TEST_ERROR - /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + /* Reopen virtual dataset and file if config option specified */ + if(config & TEST_IO_REOPEN_VIRT) { + if(H5Dclose(vdset) < 0) + TEST_ERROR + vdset = -1; + if(H5Fclose(vfile) < 0) + TEST_ERROR + vfile = -1; + if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR + if((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) + TEST_ERROR + } /* end if */ + + /* Get VDS space */ + if((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR - vdset = -1; - if(H5Fclose(vfile) < 0) + + /* Get VDS space dimensions */ + if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if(ndims != 2) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) + if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + TEST_ERROR + if(dims[0] != 10) + TEST_ERROR + if(dims[1] != 0) + TEST_ERROR + if(mdims[0] != 10) + TEST_ERROR + if(mdims[1] != 20) TEST_ERROR - } /* end if */ - /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) - TEST_ERROR + /* Close filespace */ + if(H5Sclose(filespace) < 0) + TEST_ERROR - /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) - TEST_ERROR - if(ndims != 2) - TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) - TEST_ERROR - if(dims[0] != 10) - TEST_ERROR - if(dims[1] != 0) - TEST_ERROR - if(mdims[0] != 10) - TEST_ERROR - if(mdims[1] != 20) - TEST_ERROR + /* Create 2 source files, one source dataset */ + if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if((srcfile[1] = H5Fcreate(srcfilename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR - /* Close filespace */ - if(H5Sclose(filespace) < 0) - TEST_ERROR + /* Populate write buffer */ + for(i = 0; i < (int)mdims[0]; i++) + for(j = 0; j < (int)mdims[1]; j++) + buf[i][j] = (i * (int)mdims[1]) + j; - /* Create 2 source files, one source dataset */ - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - TEST_ERROR - if((srcfile[1] = H5Fcreate(srcfilename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR + /* Initialize erbuf */ + for(i = 0; i < (int)mdims[0]; i++) + for(j = 0; j < (int)mdims[1]; j++) + erbuf[i][j] = fill; - /* Populate write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - buf[i][j] = (i * (int)mdims[1]) + j; + /* Write to srcdset[0] */ + if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + TEST_ERROR + if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + TEST_ERROR - /* Initialize erbuf */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - erbuf[i][j] = -1; + /* Update erbuf */ + for(i = 0; i < 10; i++) + for(j = 0; j < 5; j++) + erbuf[i][j] = buf[i][j]; - /* Write to srcdset[0] */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) - TEST_ERROR - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) - TEST_ERROR + /* Close srcdset and srcfiles if config option specified */ + if(config & TEST_IO_CLOSE_SRC) { + if(H5Dclose(srcdset[0]) < 0) + TEST_ERROR + srcdset[0] = -1; + if(H5Fclose(srcfile[0]) < 0) + TEST_ERROR + srcfile[0] = -1; + if(H5Fclose(srcfile[1]) < 0) + TEST_ERROR + srcfile[1] = -1; + } /* end if */ - /* Update erbuf */ - for(i = 0; i < 10; i++) - for(j = 0; j < 5; j++) - erbuf[i][j] = buf[i][j]; + /* Reopen virtual dataset and file if config option specified */ + if(config & TEST_IO_REOPEN_VIRT) { + if(H5Dclose(vdset) < 0) + TEST_ERROR + vdset = -1; + if(H5Fclose(vfile) < 0) + TEST_ERROR + vfile = -1; + if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR + if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + TEST_ERROR + } /* end if */ - /* Close srcdset and srcfiles if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + /* Get VDS space */ + if((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR - srcdset[0] = -1; - if(H5Fclose(srcfile[0]) < 0) + + /* Get VDS space dimensions */ + if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - srcfile[0] = -1; - if(H5Fclose(srcfile[1]) < 0) + if(ndims != 2) TEST_ERROR - srcfile[1] = -1; - } /* end if */ - - /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - vdset = -1; - if(H5Fclose(vfile) < 0) + if(dims[0] != 10) TEST_ERROR - vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if(dims[1] != 5) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if(mdims[0] != 10) + TEST_ERROR + if(mdims[1] != 20) TEST_ERROR - } /* end if */ - - /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) - TEST_ERROR - /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) - TEST_ERROR - if(ndims != 2) - TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) - TEST_ERROR - if(dims[0] != 10) - TEST_ERROR - if(dims[1] != 5) - TEST_ERROR - if(mdims[0] != 10) - TEST_ERROR - if(mdims[1] != 20) - TEST_ERROR + /* Close filespace */ + if(H5Sclose(filespace) < 0) + TEST_ERROR - /* Close filespace */ - if(H5Sclose(filespace) < 0) - TEST_ERROR + /* Read data through virtual dataset */ + /* Reset rbuf */ + HDmemset(rbuf[0], 0, sizeof(rbuf)); - /* Read data through virtual dataset */ - /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + /* Select hyperslab in memory space */ + if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + TEST_ERROR - /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) - TEST_ERROR + /* Read data */ + if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + TEST_ERROR - /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) - TEST_ERROR + /* Verify read data */ + for(i = 0; i < (int)mdims[0]; i++) + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end for */ - /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) + /* Reopen srcfile[1] if config option specified */ + if(config & TEST_IO_CLOSE_SRC) + if((srcfile[1] = H5Fopen(srcfilename2, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR - /* Reopen srcfile[1] if config option specified */ - if(config & TEST_IO_CLOSE_SRC) - if((srcfile[1] = H5Fopen(srcfilename2, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + /* Create 2nd source dataset */ + if((srcdset[1] = H5Dcreate2(srcfile[1], "src_dset", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* Create 2nd source dataset */ - if((srcdset[1] = H5Dcreate2(srcfile[1], "src_dset", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - TEST_ERROR + /* Adjust write buffer */ + for(i = 0; i < (int)mdims[0]; i++) + for(j = 0; j < (int)mdims[1]; j++) + buf[i][j] += (int)mdims[0] * (int)mdims[1]; - /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - buf[i][j] += (int)mdims[0] * (int)mdims[1]; + /* Write to srcdset[1] */ + if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + TEST_ERROR + if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + TEST_ERROR - /* Write to srcdset[1] */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) - TEST_ERROR - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) - TEST_ERROR + /* Update erbuf */ + for(i = 0; i < 10; i++) + for(j = 0; j < 5; j++) + erbuf[i][j + 5] = buf[i][j]; - /* Update erbuf */ - for(i = 0; i < 10; i++) - for(j = 0; j < 5; j++) - erbuf[i][j + 5] = buf[i][j]; + /* Close srcdset[1] and srcfile[1] if config option specified */ + if(config & TEST_IO_CLOSE_SRC) { + if(H5Dclose(srcdset[1]) < 0) + TEST_ERROR + srcdset[1] = -1; + if(H5Fclose(srcfile[1]) < 0) + TEST_ERROR + srcfile[1] = -1; + } /* end if */ - /* Close srcdset[1] and srcfile[1] if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[1]) < 0) - TEST_ERROR - srcdset[1] = -1; - if(H5Fclose(srcfile[1]) < 0) + /* Reopen virtual dataset and file if config option specified */ + if(config & TEST_IO_REOPEN_VIRT) { + if(H5Dclose(vdset) < 0) + TEST_ERROR + vdset = -1; + if(H5Fclose(vfile) < 0) + TEST_ERROR + vfile = -1; + if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR + if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + TEST_ERROR + } /* end if */ + + /* Get VDS space */ + if((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR - srcfile[1] = -1; - } /* end if */ - /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + /* Get VDS space dimensions */ + if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - vdset = -1; - if(H5Fclose(vfile) < 0) + if(ndims != 2) TEST_ERROR - vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if(dims[0] != 10) + TEST_ERROR + if(dims[1] != 10) + TEST_ERROR + if(mdims[0] != 10) + TEST_ERROR + if(mdims[1] != 20) TEST_ERROR - } /* end if */ - - /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) - TEST_ERROR - /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) - TEST_ERROR - if(ndims != 2) - TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) - TEST_ERROR - if(dims[0] != 10) - TEST_ERROR - if(dims[1] != 10) - TEST_ERROR - if(mdims[0] != 10) - TEST_ERROR - if(mdims[1] != 20) - TEST_ERROR + /* Close filespace */ + if(H5Sclose(filespace) < 0) + TEST_ERROR - /* Close filespace */ - if(H5Sclose(filespace) < 0) - TEST_ERROR + /* Read data through virtual dataset */ + /* Reset rbuf */ + HDmemset(rbuf[0], 0, sizeof(rbuf)); - /* Read data through virtual dataset */ - /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + /* Select hyperslab in memory space */ + if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + TEST_ERROR - /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) - TEST_ERROR + /* Read data */ + if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + TEST_ERROR - /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) - TEST_ERROR + /* Verify read data */ + for(i = 0; i < (int)mdims[0]; i++) + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end for */ - /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) + /* Close */ + if(!(config & TEST_IO_CLOSE_SRC)) { + if(H5Dclose(srcdset[0]) < 0) TEST_ERROR - - /* Close */ - if(!(config & TEST_IO_CLOSE_SRC)) { - if(H5Dclose(srcdset[0]) < 0) + srcdset[0] = -1; + if(H5Dclose(srcdset[1]) < 0) + TEST_ERROR + srcdset[1] = -1; + if(H5Fclose(srcfile[0]) < 0) + TEST_ERROR + srcfile[0] = -1; + if(H5Fclose(srcfile[1]) < 0) + TEST_ERROR + srcfile[1] = -1; + } /* end if */ + if(H5Dclose(vdset) < 0) TEST_ERROR - srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + vdset = -1; + if(H5Fclose(vfile) < 0) TEST_ERROR - srcdset[1] = -1; - if(H5Fclose(srcfile[0]) < 0) + vfile = -1; + if(H5Sclose(srcspace) < 0) TEST_ERROR - srcfile[0] = -1; - if(H5Fclose(srcfile[1]) < 0) + srcspace = -1; + if(H5Sclose(vspace[0]) < 0) TEST_ERROR - srcfile[1] = -1; - } /* end if */ - if(H5Dclose(vdset) < 0) - TEST_ERROR - vdset = -1; - if(H5Fclose(vfile) < 0) - TEST_ERROR - vfile = -1; - if(H5Sclose(srcspace) < 0) - TEST_ERROR - srcspace = -1; - if(H5Sclose(vspace[0]) < 0) - TEST_ERROR - vspace[0] = -1; + vspace[0] = -1; - /* - * Test 4: 1 Source dataset mapping, 10x5 blocks, printf source file and - * source dset, extra %%s in source dataset name - */ - /* Clean up files so the source files do not exist yet */ - h5_close_files(FILENAME, fapl); + /* + * Test 4: 1 Source dataset mapping, 10x5 blocks, printf source file and + * source dset, extra %%s in source dataset name + */ + /* Clean up files so the source files do not exist yet */ + h5_cleanup_files(FILENAME, fapl); - /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) - TEST_ERROR + /* Clear virtual layout in DCPL */ + if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + TEST_ERROR - /* Create virtual dataspaces */ - if((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) - TEST_ERROR + /* Create virtual dataspaces */ + if((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) + TEST_ERROR - /* Create source dataspace */ - dims[1] = 5; - if((srcspace = H5Screate_simple(2, dims, NULL)) < 0) - TEST_ERROR + /* Create source dataspace */ + dims[1] = 5; + if((srcspace = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR - /* Select hyperslabs in virtual space */ - stride[0] = 1; - stride[1] = 5; - count[0] = 1; - count[1] = H5S_UNLIMITED; - block[0] = 10; - block[1] = 5; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) - TEST_ERROR + /* Select hyperslabs in virtual space */ + stride[0] = 1; + stride[1] = 5; + count[0] = 1; + count[1] = H5S_UNLIMITED; + block[0] = 10; + block[1] = 5; + if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) + TEST_ERROR - /* Add virtual layout mapping */ - if(H5Pset_virtual(dcpl, vspace[0], printf_srcfilename, "%%src%%_dset%%%b", srcspace) < 0) - TEST_ERROR + /* Add virtual layout mapping */ + if(H5Pset_virtual(dcpl, vspace[0], printf_srcfilename, "%%src%%_dset%%%b", srcspace) < 0) + TEST_ERROR - /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR + /* Create virtual file */ + if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR - /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) - TEST_ERROR + /* Create virtual dataset */ + if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) + TEST_ERROR - /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + /* Reopen virtual dataset and file if config option specified */ + if(config & TEST_IO_REOPEN_VIRT) { + if(H5Dclose(vdset) < 0) + TEST_ERROR + vdset = -1; + if(H5Fclose(vfile) < 0) + TEST_ERROR + vfile = -1; + if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR + if((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) + TEST_ERROR + } /* end if */ + + /* Get VDS space */ + if((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR - vdset = -1; - if(H5Fclose(vfile) < 0) + + /* Get VDS space dimensions */ + if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if(ndims != 2) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) + if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + TEST_ERROR + if(dims[0] != 10) + TEST_ERROR + if(dims[1] != 0) + TEST_ERROR + if(mdims[0] != 10) + TEST_ERROR + if(mdims[1] != 20) TEST_ERROR - } /* end if */ - /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) - TEST_ERROR + /* Close filespace */ + if(H5Sclose(filespace) < 0) + TEST_ERROR - /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) - TEST_ERROR - if(ndims != 2) - TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) - TEST_ERROR - if(dims[0] != 10) - TEST_ERROR - if(dims[1] != 0) - TEST_ERROR - if(mdims[0] != 10) - TEST_ERROR - if(mdims[1] != 20) - TEST_ERROR + /* Create 2 source files, one source dataset */ + if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if((srcdset[0] = H5Dcreate2(srcfile[0], "%src%_dset%0", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if((srcfile[1] = H5Fcreate(srcfilename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR - /* Close filespace */ - if(H5Sclose(filespace) < 0) - TEST_ERROR + /* Populate write buffer */ + for(i = 0; i < (int)mdims[0]; i++) + for(j = 0; j < (int)mdims[1]; j++) + buf[i][j] = (i * (int)mdims[1]) + j; - /* Create 2 source files, one source dataset */ - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - if((srcdset[0] = H5Dcreate2(srcfile[0], "%src%_dset%0", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - TEST_ERROR - if((srcfile[1] = H5Fcreate(srcfilename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR + /* Initialize erbuf */ + for(i = 0; i < (int)mdims[0]; i++) + for(j = 0; j < (int)mdims[1]; j++) + erbuf[i][j] = fill; - /* Populate write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - buf[i][j] = (i * (int)mdims[1]) + j; + /* Write to srcdset[0] */ + if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + TEST_ERROR + if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + TEST_ERROR - /* Initialize erbuf */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - erbuf[i][j] = -1; + /* Update erbuf */ + for(i = 0; i < 10; i++) + for(j = 0; j < 5; j++) + erbuf[i][j] = buf[i][j]; - /* Write to srcdset[0] */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) - TEST_ERROR - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) - TEST_ERROR + /* Close srcdset and srcfiles if config option specified */ + if(config & TEST_IO_CLOSE_SRC) { + if(H5Dclose(srcdset[0]) < 0) + TEST_ERROR + srcdset[0] = -1; + if(H5Fclose(srcfile[0]) < 0) + TEST_ERROR + srcfile[0] = -1; + if(H5Fclose(srcfile[1]) < 0) + TEST_ERROR + srcfile[1] = -1; + } /* end if */ - /* Update erbuf */ - for(i = 0; i < 10; i++) - for(j = 0; j < 5; j++) - erbuf[i][j] = buf[i][j]; + /* Reopen virtual dataset and file if config option specified */ + if(config & TEST_IO_REOPEN_VIRT) { + if(H5Dclose(vdset) < 0) + TEST_ERROR + vdset = -1; + if(H5Fclose(vfile) < 0) + TEST_ERROR + vfile = -1; + if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR + if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + TEST_ERROR + } /* end if */ - /* Close srcdset and srcfiles if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + /* Get VDS space */ + if((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR - srcdset[0] = -1; - if(H5Fclose(srcfile[0]) < 0) + + /* Get VDS space dimensions */ + if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - srcfile[0] = -1; - if(H5Fclose(srcfile[1]) < 0) + if(ndims != 2) TEST_ERROR - srcfile[1] = -1; - } /* end if */ - - /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - vdset = -1; - if(H5Fclose(vfile) < 0) + if(dims[0] != 10) TEST_ERROR - vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if(dims[1] != 5) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if(mdims[0] != 10) + TEST_ERROR + if(mdims[1] != 20) TEST_ERROR - } /* end if */ - - /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) - TEST_ERROR - /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) - TEST_ERROR - if(ndims != 2) - TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) - TEST_ERROR - if(dims[0] != 10) - TEST_ERROR - if(dims[1] != 5) - TEST_ERROR - if(mdims[0] != 10) - TEST_ERROR - if(mdims[1] != 20) - TEST_ERROR + /* Close filespace */ + if(H5Sclose(filespace) < 0) + TEST_ERROR - /* Close filespace */ - if(H5Sclose(filespace) < 0) - TEST_ERROR + /* Read data through virtual dataset */ + /* Reset rbuf */ + HDmemset(rbuf[0], 0, sizeof(rbuf)); - /* Read data through virtual dataset */ - /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + /* Select hyperslab in memory space */ + if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + TEST_ERROR - /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) - TEST_ERROR + /* Read data */ + if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + TEST_ERROR - /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) - TEST_ERROR + /* Verify read data */ + for(i = 0; i < (int)mdims[0]; i++) + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end for */ - /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) + /* Reopen srcfile[1] if config option specified */ + if(config & TEST_IO_CLOSE_SRC) + if((srcfile[1] = H5Fopen(srcfilename2, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR - /* Reopen srcfile[1] if config option specified */ - if(config & TEST_IO_CLOSE_SRC) - if((srcfile[1] = H5Fopen(srcfilename2, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + /* Create 2nd source dataset */ + if((srcdset[1] = H5Dcreate2(srcfile[1], "%src%_dset%1", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* Create 2nd source dataset */ - if((srcdset[1] = H5Dcreate2(srcfile[1], "%src%_dset%1", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - TEST_ERROR + /* Adjust write buffer */ + for(i = 0; i < (int)mdims[0]; i++) + for(j = 0; j < (int)mdims[1]; j++) + buf[i][j] += (int)mdims[0] * (int)mdims[1]; - /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - buf[i][j] += (int)mdims[0] * (int)mdims[1]; + /* Write to srcdset[1] */ + if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + TEST_ERROR + if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + TEST_ERROR - /* Write to srcdset[1] */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) - TEST_ERROR - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) - TEST_ERROR + /* Update erbuf */ + for(i = 0; i < 10; i++) + for(j = 0; j < 5; j++) + erbuf[i][j + 5] = buf[i][j]; - /* Update erbuf */ - for(i = 0; i < 10; i++) - for(j = 0; j < 5; j++) - erbuf[i][j + 5] = buf[i][j]; + /* Close srcdset[1] and srcfile[1] if config option specified */ + if(config & TEST_IO_CLOSE_SRC) { + if(H5Dclose(srcdset[1]) < 0) + TEST_ERROR + srcdset[1] = -1; + if(H5Fclose(srcfile[1]) < 0) + TEST_ERROR + srcfile[1] = -1; + } /* end if */ - /* Close srcdset[1] and srcfile[1] if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[1]) < 0) - TEST_ERROR - srcdset[1] = -1; - if(H5Fclose(srcfile[1]) < 0) + /* Reopen virtual dataset and file if config option specified */ + if(config & TEST_IO_REOPEN_VIRT) { + if(H5Dclose(vdset) < 0) + TEST_ERROR + vdset = -1; + if(H5Fclose(vfile) < 0) + TEST_ERROR + vfile = -1; + if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR + if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + TEST_ERROR + } /* end if */ + + /* Get VDS space */ + if((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR - srcfile[1] = -1; - } /* end if */ - /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + /* Get VDS space dimensions */ + if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - vdset = -1; - if(H5Fclose(vfile) < 0) + if(ndims != 2) TEST_ERROR - vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if(dims[0] != 10) + TEST_ERROR + if(dims[1] != 10) + TEST_ERROR + if(mdims[0] != 10) + TEST_ERROR + if(mdims[1] != 20) TEST_ERROR - } /* end if */ - - /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) - TEST_ERROR - /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) - TEST_ERROR - if(ndims != 2) - TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) - TEST_ERROR - if(dims[0] != 10) - TEST_ERROR - if(dims[1] != 10) - TEST_ERROR - if(mdims[0] != 10) - TEST_ERROR - if(mdims[1] != 20) - TEST_ERROR + /* Close filespace */ + if(H5Sclose(filespace) < 0) + TEST_ERROR - /* Close filespace */ - if(H5Sclose(filespace) < 0) - TEST_ERROR + /* Read data through virtual dataset */ + /* Reset rbuf */ + HDmemset(rbuf[0], 0, sizeof(rbuf)); - /* Read data through virtual dataset */ - /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + /* Select hyperslab in memory space */ + if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + TEST_ERROR - /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) - TEST_ERROR + /* Read data */ + if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + TEST_ERROR - /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) - TEST_ERROR + /* Verify read data */ + for(i = 0; i < (int)mdims[0]; i++) + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end for */ - /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) + /* Close */ + if(!(config & TEST_IO_CLOSE_SRC)) { + if(H5Dclose(srcdset[0]) < 0) TEST_ERROR - - /* Close */ - if(!(config & TEST_IO_CLOSE_SRC)) { - if(H5Dclose(srcdset[0]) < 0) + srcdset[0] = -1; + if(H5Dclose(srcdset[1]) < 0) + TEST_ERROR + srcdset[1] = -1; + if(H5Fclose(srcfile[0]) < 0) + TEST_ERROR + srcfile[0] = -1; + if(H5Fclose(srcfile[1]) < 0) + TEST_ERROR + srcfile[1] = -1; + } /* end if */ + if(H5Dclose(vdset) < 0) TEST_ERROR - srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + vdset = -1; + if(H5Fclose(vfile) < 0) TEST_ERROR - srcdset[1] = -1; - if(H5Fclose(srcfile[0]) < 0) + vfile = -1; + if(H5Sclose(srcspace) < 0) TEST_ERROR - srcfile[0] = -1; - if(H5Fclose(srcfile[1]) < 0) + srcspace = -1; + if(H5Sclose(vspace[0]) < 0) TEST_ERROR - srcfile[1] = -1; + vspace[0] = -1; } /* end if */ - if(H5Dclose(vdset) < 0) - TEST_ERROR - vdset = -1; - if(H5Fclose(vfile) < 0) - TEST_ERROR - vfile = -1; - if(H5Sclose(srcspace) < 0) - TEST_ERROR - srcspace = -1; - if(H5Sclose(vspace[0]) < 0) - TEST_ERROR - vspace[0] = -1; /* @@ -6751,7 +6877,7 @@ test_printf(unsigned config, hid_t fapl) start[1] = 0; /* Add virtual layout mappings */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename : ".", "src_dset_a%b%%", srcspace) < 0) + if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename : ".", "%bsrc_dset_a%b%%", srcspace) < 0) TEST_ERROR if(H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename : ".", "src_dset_b%b%%%%", srcspace) < 0) TEST_ERROR @@ -6828,7 +6954,7 @@ test_printf(unsigned config, hid_t fapl) TEST_ERROR /* Create 2 source datasets */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset_a0%", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if((srcdset[0] = H5Dcreate2(srcfile[0], "0src_dset_a0%", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR if((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset_b0%%", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -6841,7 +6967,7 @@ test_printf(unsigned config, hid_t fapl) /* Initialize erbuf */ for(i = 0; i < (int)mdims[0]; i++) for(j = 0; j < (int)mdims[1]; j++) - erbuf[i][j] = -1; + erbuf[i][j] = fill; /* Write to srcdset[0] */ block[0] = 10; @@ -6924,12 +7050,7 @@ test_printf(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -6941,9 +7062,15 @@ test_printf(unsigned config, hid_t fapl) /* Verify read data */ for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end for */ /* Reopen srcfile if config option specified */ if((config & TEST_IO_CLOSE_SRC) && (config & TEST_IO_DIFFERENT_FILE)) @@ -7022,12 +7149,7 @@ test_printf(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -7039,9 +7161,15 @@ test_printf(unsigned config, hid_t fapl) /* Verify read data */ for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + for(j = 0; j < (int)mdims[1]; j++) { + if(j >= (int)dims[1]) { + if(rbuf[i][j] != 0) + TEST_ERROR + } /* end if */ + else + if(rbuf[i][j] != erbuf[i][j]) + TEST_ERROR + } /* end for */ /* Close VDS and reopen with view set to H5D_VDS_FIRST_MISSING, reopen file * as well if config option specified */ @@ -7086,12 +7214,7 @@ test_printf(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -7105,7 +7228,7 @@ test_printf(unsigned config, hid_t fapl) for(i = 0; i < (int)mdims[0]; i++) for(j = 0; j < (int)mdims[1]; j++) { if(j >= (int)dims[1]) { - if(rbuf[i][j] != -1) + if(rbuf[i][j] != 0) TEST_ERROR } /* end if */ else @@ -7119,7 +7242,7 @@ test_printf(unsigned config, hid_t fapl) TEST_ERROR /* Create 4th source dataset */ - if((srcdset[3] = H5Dcreate2(srcfile[0], "src_dset_a2%", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if((srcdset[3] = H5Dcreate2(srcfile[0], "2src_dset_a2%", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Adjust write buffer */ @@ -7190,12 +7313,7 @@ test_printf(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -7209,7 +7327,7 @@ test_printf(unsigned config, hid_t fapl) for(i = 0; i < (int)mdims[0]; i++) for(j = 0; j < (int)mdims[1]; j++) { if(j >= (int)dims[1]) { - if(rbuf[i][j] != -1) + if(rbuf[i][j] != 0) TEST_ERROR } /* end if */ else @@ -7260,12 +7378,7 @@ test_printf(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -7279,7 +7392,7 @@ test_printf(unsigned config, hid_t fapl) for(i = 0; i < (int)mdims[0]; i++) for(j = 0; j < (int)mdims[1]; j++) { if(j >= (int)dims[1]) { - if(rbuf[i][j] != -1) + if(rbuf[i][j] != 0) TEST_ERROR } /* end if */ else @@ -7330,12 +7443,7 @@ test_printf(unsigned config, hid_t fapl) /* Read data through virtual dataset */ /* Reset rbuf */ - //HDmemset(rbuf[0], 0, sizeof(rbuf)); VDSINC - /* Initialize erbuf - used now instead of setting fill value because fill - * values do not work VDSINC */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - rbuf[i][j] = -1; + HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) @@ -7349,7 +7457,7 @@ test_printf(unsigned config, hid_t fapl) for(i = 0; i < (int)mdims[0]; i++) for(j = 0; j < (int)mdims[1]; j++) { if(j >= (int)dims[1]) { - if(rbuf[i][j] != -1) + if(rbuf[i][j] != 0) TEST_ERROR } /* end if */ else |