summaryrefslogtreecommitdiffstats
path: root/test/h5test.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2008-10-09 03:44:22 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2008-10-09 03:44:22 (GMT)
commit05cc7c234ff463721c4f8e8999d4ca8e0ce3bdbf (patch)
treebe8e7233ad49c73ff5d8c86147a9c1410d843434 /test/h5test.c
parent70b4cf15ac7a213b88be6ff3614817e5a4011514 (diff)
downloadhdf5-05cc7c234ff463721c4f8e8999d4ca8e0ce3bdbf.zip
hdf5-05cc7c234ff463721c4f8e8999d4ca8e0ce3bdbf.tar.gz
hdf5-05cc7c234ff463721c4f8e8999d4ca8e0ce3bdbf.tar.bz2
[svn-r15825] Description:
Fix various problems with a the core & sec2 VFDs. Improve the h5_get_file_size() routine to handle files created with VFDs that use multiple files. Tested on: Mac OS X/32 10.5.5 (amazon) in debug mode Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Diffstat (limited to 'test/h5test.c')
-rw-r--r--test/h5test.c100
1 files changed, 86 insertions, 14 deletions
diff --git a/test/h5test.c b/test/h5test.c
index 98508ff..03fa3b7 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -541,7 +541,7 @@ h5_fileaccess(void)
if (H5Pset_fapl_stdio(fapl)<0) return -1;
} else if (!HDstrcmp(name, "core")) {
/* In-core temporary file with 1MB increment */
- if (H5Pset_fapl_core(fapl, (size_t)1024*1024, TRUE)<0) return -1;
+ if (H5Pset_fapl_core(fapl, (size_t)1, TRUE)<0) return -1;
} else if (!HDstrcmp(name, "split")) {
/* Split meta data and raw data each using default driver */
if (H5Pset_fapl_split(fapl,
@@ -562,13 +562,13 @@ h5_fileaccess(void)
HDmemset(memb_name, 0, sizeof memb_name);
HDmemset(memb_addr, 0, sizeof memb_addr);
- assert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES);
- for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) {
+ HDassert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES);
+ for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) {
memb_fapl[mt] = H5P_DEFAULT;
sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]);
memb_name[mt] = sv[mt];
- memb_addr[mt] = MAX(mt-1,0)*(HADDR_MAX/10);
- }
+ memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10);
+ } /* end for */
if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name,
memb_addr, FALSE)<0) {
@@ -847,20 +847,92 @@ h5_dump_info_object(MPI_Info info)
* Programmer: Quincey Koziol
* Saturday, March 22, 2003
*
- * Modifications:
- * Albert Cheng, Oct 11, 2006
- * Changed Failure return value to -1.
- *
*-------------------------------------------------------------------------
*/
h5_stat_size_t
-h5_get_file_size(const char *filename)
+h5_get_file_size(const char *filename, hid_t fapl)
{
- h5_stat_t sb;
+ char temp[2048]; /* Temporary buffer for file names */
+ h5_stat_t sb; /* Structure for querying file info */
+
+ if(fapl == H5P_DEFAULT) {
+ /* Get the file's statistics */
+ if(0 == HDstat(filename, &sb))
+ return((h5_stat_size_t)sb.st_size);
+ } /* end if */
+ else {
+ hid_t driver; /* VFD used for file */
- /* Get the file's statistics */
- if (HDstat(filename, &sb)==0)
- return((h5_stat_size_t)sb.st_size);
+ /* Get the driver used when creating the file */
+ if((driver = H5Pget_driver(fapl)) < 0)
+ return(-1);
+
+ /* Check for simple cases */
+ if(driver == H5FD_SEC2 || driver == H5FD_STDIO || driver == H5FD_CORE ||
+#ifdef H5_HAVE_PARALLEL
+ driver == H5FD_MPIO || driver == H5FD_MPIPOSIX ||
+#endif /* H5_HAVE_PARALLEL */
+#ifdef H5_HAVE_WINDOWS
+ driver == H5FD_WINDOWS ||
+#endif /* H5_HAVE_WINDOWS */
+#ifdef H5_HAVE_DIRECT
+ driver == H5FD_DIRECT ||
+#endif /* H5_HAVE_DIRECT */
+ driver == H5FD_LOG) {
+ /* Get the file's statistics */
+ if(0 == HDstat(filename, &sb))
+ return((h5_stat_size_t)sb.st_size);
+ } /* end if */
+ else if(driver == H5FD_MULTI) {
+ H5FD_mem_t mt;
+ h5_stat_size_t tot_size = 0;
+
+ HDassert(HDstrlen(multi_letters) == H5FD_MEM_NTYPES);
+ for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) {
+ /* Create the filename to query */
+ HDsnprintf(temp, sizeof temp, "%s-%c.h5", filename, multi_letters[mt]);
+
+ /* Check for existence of file */
+ if(0 == HDaccess(temp, F_OK)) {
+ /* Get the file's statistics */
+ if(0 != HDstat(temp, &sb))
+ return(-1);
+
+ /* Add to total size */
+ tot_size += (h5_stat_size_t)sb.st_size;
+ } /* end if */
+ } /* end for */
+
+ /* Return total size */
+ return(tot_size);
+ } /* end if */
+ else if(driver == H5FD_FAMILY) {
+ h5_stat_size_t tot_size = 0;
+
+ /* Try all filenames possible, until we find one that's missing */
+ for(int j = 0; /*void*/; j++) {
+ /* Create the filename to query */
+ HDsnprintf(temp, sizeof temp, filename, j);
+
+ /* Check for existence of file */
+ if(HDaccess(temp, F_OK) < 0)
+ break;
+
+ /* Get the file's statistics */
+ if(0 != HDstat(temp, &sb))
+ return(-1);
+
+ /* Add to total size */
+ tot_size += (h5_stat_size_t)sb.st_size;
+ } /* end for */
+
+ /* Return total size */
+ return(tot_size);
+ } /* end if */
+ else {
+ HDassert(0 && "Unknown VFD!");
+ } /* end else */
+ } /* end else */
return(-1);
} /* end get_file_size() */