2003-03-31 12:59:04 -05:00
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 09:56:24 -05:00
|
|
|
|
* Copyright by The HDF Group. *
|
2003-03-31 12:59:04 -05:00
|
|
|
|
* Copyright by the Board of Trustees of the University of Illinois. *
|
|
|
|
|
* All rights reserved. *
|
|
|
|
|
* *
|
|
|
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
|
* terms governing use, modification, and redistribution, is contained in *
|
2017-04-17 14:32:16 -05:00
|
|
|
|
* the COPYING file, which can be found at the root of the source code *
|
|
|
|
|
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
|
|
|
|
|
* If you do not have access to either file, you may request a copy from *
|
|
|
|
|
* help@hdfgroup.org. *
|
2003-03-31 12:59:04 -05:00
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
|
1998-11-20 22:36:51 -05:00
|
|
|
|
/*
|
|
|
|
|
* Programmer: Robb Matzke <matzke@llnl.gov>
|
|
|
|
|
* Thursday, November 19, 1998
|
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Purpose: Provides support functions for most of the hdf5 tests cases.
|
2005-08-13 15:53:35 -05:00
|
|
|
|
*
|
1998-11-20 22:36:51 -05:00
|
|
|
|
*/
|
|
|
|
|
|
2011-09-06 11:50:32 -05:00
|
|
|
|
#undef NDEBUG /*override -DNDEBUG */
|
2016-05-04 11:18:11 -05:00
|
|
|
|
|
2002-12-02 08:15:36 -05:00
|
|
|
|
#include "h5test.h"
|
2010-03-18 07:45:29 -05:00
|
|
|
|
#include "H5srcdir.h"
|
2001-04-03 13:09:16 -05:00
|
|
|
|
|
2011-04-15 17:05:23 -05:00
|
|
|
|
/* Necessary for h5_verify_cached_stabs() */
|
2015-09-13 22:58:59 -05:00
|
|
|
|
#define H5G_FRIEND /*suppress error about including H5Gpkg */
|
2011-04-15 17:05:23 -05:00
|
|
|
|
#define H5G_TESTING
|
|
|
|
|
#include "H5Gpkg.h"
|
|
|
|
|
|
2011-09-06 11:50:32 -05:00
|
|
|
|
#ifdef H5_HAVE_WIN32_API
|
2001-01-04 18:52:03 -05:00
|
|
|
|
#include <process.h>
|
2011-09-06 11:50:32 -05:00
|
|
|
|
#endif /* H5_HAVE_WIN32_API */
|
1998-11-20 22:36:51 -05:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Define these environment variables or constants to influence functions in
|
|
|
|
|
* this test support library. The environment variable is used in preference
|
|
|
|
|
* to the cpp constant. If neither is defined then use some default value.
|
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* HDF5_DRIVER: This string describes what low level file driver to
|
|
|
|
|
* use for HDF5 file access. The first word in the
|
|
|
|
|
* value is the name of the driver and subsequent data
|
|
|
|
|
* is interpreted according to the driver. See
|
2018-11-28 19:07:30 -06:00
|
|
|
|
* h5_get_vfd_fapl() for details.
|
|
|
|
|
*
|
|
|
|
|
* HDF5_VOL_CONNECTOR: This string describes what VOL connector to
|
|
|
|
|
* use for HDF5 file access. The first word in the
|
|
|
|
|
* value is the name of the connector and subsequent data
|
2018-11-30 14:12:32 -06:00
|
|
|
|
* is interpreted according to the connector. See
|
2018-11-28 19:07:30 -06:00
|
|
|
|
* h5_get_vol_fapl() for details.
|
|
|
|
|
*
|
|
|
|
|
* HDF5_LIBVER_BOUNDS: This string describes what library version bounds to
|
|
|
|
|
* use for HDF5 file access. See h5_get_libver_fapl() for details.
|
2011-09-06 11:50:32 -05:00
|
|
|
|
*
|
|
|
|
|
* HDF5_PREFIX: A string to add to the beginning of all serial test
|
|
|
|
|
* file names. This can be used to run tests in a
|
|
|
|
|
* different file system (e.g., "/tmp" or "/tmp/myname").
|
|
|
|
|
* The prefix will be separated from the base file name
|
|
|
|
|
* by a slash. See h5_fixname() for details.
|
|
|
|
|
*
|
|
|
|
|
* HDF5_PARAPREFIX: A string to add to the beginning of all parallel test
|
|
|
|
|
* file names. This can be used to tell MPIO what driver
|
|
|
|
|
* to use (e.g., "gfs:", "ufs:", or "nfs:") or to use a
|
|
|
|
|
* different file system (e.g., "/tmp" or "/tmp/myname").
|
|
|
|
|
* The prefix will be separated from the base file name
|
|
|
|
|
* by a slash. See h5_fixname() for details.
|
2000-01-25 23:20:36 -05:00
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
* In a parallel machine, the filesystem suitable for compiling is
|
|
|
|
|
* unlikely a parallel file system that is suitable for parallel I/O.
|
|
|
|
|
* There is no standard pathname for the parallel file system. /tmp
|
|
|
|
|
* is about the best guess.
|
1998-11-20 22:36:51 -05:00
|
|
|
|
*/
|
2000-01-25 23:20:36 -05:00
|
|
|
|
#ifndef HDF5_PARAPREFIX
|
2003-05-08 13:50:14 -05:00
|
|
|
|
#define HDF5_PARAPREFIX ""
|
2000-01-25 23:20:36 -05:00
|
|
|
|
#endif
|
2011-09-06 11:50:32 -05:00
|
|
|
|
char *paraprefix = NULL; /* for command line option para-prefix */
|
2002-05-21 13:49:44 -05:00
|
|
|
|
#ifdef H5_HAVE_PARALLEL
|
2002-05-29 13:40:29 -05:00
|
|
|
|
MPI_Info h5_io_info_g=MPI_INFO_NULL;/* MPI INFO object for IO */
|
2002-05-21 13:49:44 -05:00
|
|
|
|
#endif
|
1998-11-20 22:36:51 -05:00
|
|
|
|
|
2016-09-27 10:29:16 -07:00
|
|
|
|
#define READ_BUF_SIZE 65536
|
2009-10-20 10:08:56 -05:00
|
|
|
|
|
1999-08-17 14:12:59 -05:00
|
|
|
|
/*
|
|
|
|
|
* These are the letters that are appended to the file name when generating
|
|
|
|
|
* names for the split and multi drivers. They are:
|
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* m: All meta data when using the split driver.
|
|
|
|
|
* s: The userblock, superblock, and driver info block
|
|
|
|
|
* b: B-tree nodes
|
|
|
|
|
* r: Dataset raw data
|
|
|
|
|
* g: Global heap
|
|
|
|
|
* l: local heap (object names)
|
|
|
|
|
* o: object headers
|
1999-08-17 14:12:59 -05:00
|
|
|
|
*/
|
2006-12-08 14:44:20 -05:00
|
|
|
|
static const char *multi_letters = "msbrglo";
|
1998-11-20 22:36:51 -05:00
|
|
|
|
|
2016-09-29 13:17:55 -07:00
|
|
|
|
/* Length of multi-file VFD filename buffers */
|
|
|
|
|
#define H5TEST_MULTI_FILENAME_LEN 1024
|
|
|
|
|
|
2016-12-19 20:44:54 -08:00
|
|
|
|
/* Temporary file for sending signal messages */
|
|
|
|
|
#define TMP_SIGNAL_FILE "tmp_signal_file"
|
|
|
|
|
|
|
|
|
|
/* The # of seconds to wait for the message file--used by h5_wait_message() */
|
|
|
|
|
#define MESSAGE_TIMEOUT 300 /* Timeout in seconds */
|
|
|
|
|
|
2015-09-13 22:58:59 -05:00
|
|
|
|
/* Previous error reporting function */
|
|
|
|
|
static H5E_auto2_t err_func = NULL;
|
|
|
|
|
|
2007-08-23 15:25:25 -05:00
|
|
|
|
static herr_t h5_errors(hid_t estack, void *client_data);
|
2014-10-02 10:56:09 -05:00
|
|
|
|
static char * h5_fixname_real(const char *base_name, hid_t fapl, const char *suffix,
|
2015-07-21 12:14:26 -05:00
|
|
|
|
char *fullname, size_t size, hbool_t nest_printf);
|
2003-08-08 14:03:43 -05:00
|
|
|
|
|
1998-11-20 22:36:51 -05:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Function: h5_errors
|
1998-11-20 22:36:51 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Purpose: Displays the error stack after printing "*FAILED*".
|
1998-11-20 22:36:51 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Return: Success: 0
|
1998-11-20 22:36:51 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Failure: -1
|
1998-11-20 22:36:51 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Programmer: Robb Matzke
|
|
|
|
|
* Wednesday, March 4, 1998
|
1998-11-20 22:36:51 -05:00
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2003-08-08 14:03:43 -05:00
|
|
|
|
static herr_t
|
2015-06-01 14:38:09 -05:00
|
|
|
|
h5_errors(hid_t estack, void H5_ATTR_UNUSED *client_data)
|
1998-11-20 22:36:51 -05:00
|
|
|
|
{
|
2001-01-25 12:03:29 -05:00
|
|
|
|
H5_FAILED();
|
2007-08-23 15:25:25 -05:00
|
|
|
|
H5Eprint2(estack, stdout);
|
1998-11-20 22:36:51 -05:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-21 19:21:18 -05:00
|
|
|
|
|
1998-11-20 22:36:51 -05:00
|
|
|
|
/*-------------------------------------------------------------------------
|
2015-09-13 22:58:59 -05:00
|
|
|
|
* Function: h5_clean_files
|
1998-11-20 22:36:51 -05:00
|
|
|
|
*
|
2015-06-05 16:55:24 -05:00
|
|
|
|
* Purpose: Cleanup temporary test files (always).
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* base_name contains the list of test file names.
|
1998-11-20 22:36:51 -05:00
|
|
|
|
*
|
2015-06-03 13:00:58 -05:00
|
|
|
|
* Return: void
|
1998-11-20 22:36:51 -05:00
|
|
|
|
*
|
2015-06-03 13:00:58 -05:00
|
|
|
|
* Programmer: Neil Fortner
|
|
|
|
|
* June 1, 2015
|
1998-11-20 22:36:51 -05:00
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2015-06-03 13:00:58 -05:00
|
|
|
|
void
|
2015-09-13 22:58:59 -05:00
|
|
|
|
h5_clean_files(const char *base_name[], hid_t fapl)
|
1998-11-20 22:36:51 -05:00
|
|
|
|
{
|
2015-06-03 13:00:58 -05:00
|
|
|
|
int i;
|
2014-03-15 23:44:13 -05:00
|
|
|
|
|
2015-06-03 13:00:58 -05:00
|
|
|
|
for(i = 0; base_name[i]; i++) {
|
|
|
|
|
char filename[1024];
|
|
|
|
|
char temp[2048];
|
|
|
|
|
hid_t driver;
|
2014-03-15 23:44:13 -05:00
|
|
|
|
|
2015-06-03 13:00:58 -05:00
|
|
|
|
if(NULL == h5_fixname(base_name[i], fapl, filename, sizeof(filename)))
|
|
|
|
|
continue;
|
1998-11-20 22:36:51 -05:00
|
|
|
|
|
2015-06-03 13:00:58 -05:00
|
|
|
|
driver = H5Pget_driver(fapl);
|
1998-11-20 22:36:51 -05:00
|
|
|
|
|
2015-06-03 13:00:58 -05:00
|
|
|
|
if(driver == H5FD_FAMILY) {
|
|
|
|
|
int j;
|
2001-05-22 18:27:38 -05:00
|
|
|
|
|
2015-06-03 13:00:58 -05:00
|
|
|
|
for(j = 0; /*void*/; j++) {
|
|
|
|
|
HDsnprintf(temp, sizeof temp, filename, j);
|
2001-05-22 18:27:38 -05:00
|
|
|
|
|
2015-06-03 13:00:58 -05:00
|
|
|
|
if(HDaccess(temp, F_OK) < 0)
|
|
|
|
|
break;
|
2014-03-15 23:44:13 -05:00
|
|
|
|
|
2015-06-03 13:00:58 -05:00
|
|
|
|
HDremove(temp);
|
|
|
|
|
} /* end for */
|
|
|
|
|
} else if(driver == H5FD_CORE) {
|
|
|
|
|
hbool_t backing; /* Whether the core file has backing store */
|
2001-05-22 18:27:38 -05:00
|
|
|
|
|
2015-06-03 13:00:58 -05:00
|
|
|
|
H5Pget_fapl_core(fapl, NULL, &backing);
|
2002-10-14 14:48:01 -05:00
|
|
|
|
|
2015-06-03 13:00:58 -05:00
|
|
|
|
/* If the file was stored to disk with bacing store, remove it */
|
|
|
|
|
if(backing)
|
|
|
|
|
HDremove(filename);
|
|
|
|
|
} else if (driver == H5FD_MULTI) {
|
|
|
|
|
H5FD_mem_t mt;
|
2002-10-14 14:48:01 -05:00
|
|
|
|
|
2015-06-03 13:00:58 -05:00
|
|
|
|
HDassert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES);
|
2002-10-14 14:48:01 -05:00
|
|
|
|
|
2015-06-03 13:00:58 -05:00
|
|
|
|
for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) {
|
|
|
|
|
HDsnprintf(temp, sizeof temp, "%s-%c.h5", filename, multi_letters[mt]);
|
|
|
|
|
HDremove(temp); /*don't care if it fails*/
|
|
|
|
|
} /* end for */
|
|
|
|
|
} else {
|
|
|
|
|
HDremove(filename);
|
|
|
|
|
}
|
|
|
|
|
} /* end for */
|
2011-09-06 11:50:32 -05:00
|
|
|
|
|
2015-09-13 22:58:59 -05:00
|
|
|
|
/* Close the FAPL used to access the file */
|
1998-11-20 22:36:51 -05:00
|
|
|
|
H5Pclose(fapl);
|
2015-09-13 22:58:59 -05:00
|
|
|
|
|
2015-06-03 13:00:58 -05:00
|
|
|
|
return;
|
2015-09-13 22:58:59 -05:00
|
|
|
|
} /* end h5_clean_files() */
|
2015-06-03 13:00:58 -05:00
|
|
|
|
|
2016-02-16 23:30:49 -05:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_delete_test_file
|
|
|
|
|
*
|
|
|
|
|
* Purpose Clean up temporary test files.
|
|
|
|
|
*
|
2016-09-24 02:54:00 -04:00
|
|
|
|
* When a test calls h5_fixname() to get a VFD-dependent
|
2016-02-16 23:30:49 -05:00
|
|
|
|
* test file name, this function can be used to clean it up.
|
|
|
|
|
*
|
|
|
|
|
* Return: void
|
|
|
|
|
*
|
|
|
|
|
* Since this is a cleanup file, we don't care if it fails.
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Dana Robinson
|
|
|
|
|
* February 2016
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
h5_delete_test_file(const char *base_name, hid_t fapl)
|
|
|
|
|
{
|
|
|
|
|
char filename[1024]; /* VFD-dependent filename to delete */
|
|
|
|
|
char sub_filename[2048]; /* sub-files in multi & family VFDs */
|
|
|
|
|
hid_t driver = -1; /* VFD ID */
|
|
|
|
|
|
|
|
|
|
/* Get the VFD-dependent filename */
|
|
|
|
|
if(NULL == h5_fixname(base_name, fapl, filename, sizeof(filename)))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
driver = H5Pget_driver(fapl);
|
|
|
|
|
|
|
|
|
|
if(driver == H5FD_FAMILY) {
|
|
|
|
|
int j;
|
|
|
|
|
for(j = 0; /*void*/; j++) {
|
|
|
|
|
HDsnprintf(sub_filename, sizeof(sub_filename), filename, j);
|
|
|
|
|
|
|
|
|
|
/* If we can't access the file, it probably doesn't exist
|
|
|
|
|
* and we are done deleting the sub-files.
|
|
|
|
|
*/
|
|
|
|
|
if(HDaccess(sub_filename, F_OK) < 0)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
HDremove(sub_filename);
|
|
|
|
|
} /* end for */
|
|
|
|
|
} else if(driver == H5FD_CORE) {
|
|
|
|
|
hbool_t backing; /* Whether the core file has backing store */
|
|
|
|
|
|
|
|
|
|
H5Pget_fapl_core(fapl, NULL, &backing);
|
|
|
|
|
|
|
|
|
|
/* If the file was stored to disk with bacing store, remove it */
|
|
|
|
|
if(backing)
|
|
|
|
|
HDremove(filename);
|
|
|
|
|
} else if (driver == H5FD_MULTI) {
|
|
|
|
|
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)) {
|
|
|
|
|
HDsnprintf(sub_filename, sizeof(sub_filename), "%s-%c.h5", filename, multi_letters[mt]);
|
|
|
|
|
HDremove(sub_filename);
|
|
|
|
|
} /* end for */
|
|
|
|
|
} else {
|
|
|
|
|
HDremove(filename);
|
|
|
|
|
} /* end if */
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
} /* end h5_delete_test_file() */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_delete_all_test_files
|
|
|
|
|
*
|
|
|
|
|
* Purpose Clean up temporary test files.
|
|
|
|
|
*
|
|
|
|
|
* When a test calls h5_fixname() get a VFD-dependent
|
|
|
|
|
* test file name, this function can be used to clean it up.
|
|
|
|
|
*
|
|
|
|
|
* This function takes an array of filenames that ends with
|
|
|
|
|
* a NULL string and cleans them all.
|
|
|
|
|
*
|
|
|
|
|
* Return: void
|
|
|
|
|
*
|
|
|
|
|
* Since this is a cleanup file, we don't care if it fails.
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Dana Robinson
|
|
|
|
|
* February 2016
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
h5_delete_all_test_files(const char *base_name[], hid_t fapl)
|
|
|
|
|
{
|
|
|
|
|
int i; /* iterator */
|
|
|
|
|
|
|
|
|
|
for(i = 0; base_name[i]; i++) {
|
|
|
|
|
h5_delete_test_file(base_name[i], fapl);
|
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
} /* end h5_delete_all_test_files() */
|
|
|
|
|
|
2015-09-21 19:21:18 -05:00
|
|
|
|
|
2015-06-03 13:00:58 -05:00
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_cleanup
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Cleanup temporary test files.
|
|
|
|
|
* base_name contains the list of test file names.
|
|
|
|
|
* The file access property list is also closed.
|
|
|
|
|
*
|
|
|
|
|
* Return: Non-zero if cleanup actions were performed; zero otherwise.
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Albert Cheng
|
|
|
|
|
* May 28, 1998
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
int
|
|
|
|
|
h5_cleanup(const char *base_name[], hid_t fapl)
|
|
|
|
|
{
|
|
|
|
|
int retval = 0;
|
|
|
|
|
|
|
|
|
|
if(GetTestCleanup()) {
|
2015-09-20 21:18:45 -05:00
|
|
|
|
/* Clean up files in base_name, and the FAPL */
|
|
|
|
|
h5_clean_files(base_name, fapl);
|
2011-09-06 11:50:32 -05:00
|
|
|
|
|
2014-03-15 23:44:13 -05:00
|
|
|
|
retval = 1;
|
|
|
|
|
} /* end if */
|
2001-05-22 18:27:38 -05:00
|
|
|
|
|
2015-09-13 22:58:59 -05:00
|
|
|
|
/* Restore the original error reporting routine */
|
|
|
|
|
h5_restore_err();
|
|
|
|
|
|
1998-11-25 09:58:22 -05:00
|
|
|
|
return retval;
|
2015-09-13 22:58:59 -05:00
|
|
|
|
} /* end h5_cleanup() */
|
|
|
|
|
|
2016-02-16 23:30:49 -05:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_test_shutdown
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Performs any special test cleanup required before the test
|
|
|
|
|
* ends.
|
|
|
|
|
*
|
|
|
|
|
* NOTE: This function should normally only be called once
|
|
|
|
|
* in a given test, usually just before leaving main(). It
|
|
|
|
|
* is intended for use in the single-file unit tests, not
|
|
|
|
|
* testhdf5.
|
|
|
|
|
*
|
|
|
|
|
* Return: void
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Dana Robinson
|
|
|
|
|
* February 2016
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
h5_test_shutdown(void)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/* Restore the original error reporting routine */
|
|
|
|
|
h5_restore_err();
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
} /* end h5_test_shutdown() */
|
|
|
|
|
|
2015-09-13 22:58:59 -05:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_restore_err
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Restore the default error handler.
|
|
|
|
|
*
|
|
|
|
|
* Return: N/A
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Quincey Koziol
|
|
|
|
|
* Sept 10, 2015
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
h5_restore_err(void)
|
|
|
|
|
{
|
|
|
|
|
/* Restore the original error reporting routine */
|
|
|
|
|
HDassert(err_func != NULL);
|
|
|
|
|
H5Eset_auto2(H5E_DEFAULT, err_func, NULL);
|
|
|
|
|
err_func = NULL;
|
1998-11-20 22:36:51 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Function: h5_reset
|
1998-11-20 22:36:51 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Purpose: Reset the library by closing it.
|
1998-11-20 22:36:51 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Return: void
|
1998-11-20 22:36:51 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Programmer: Robb Matzke
|
1998-11-20 22:36:51 -05:00
|
|
|
|
* Friday, November 20, 1998
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
h5_reset(void)
|
|
|
|
|
{
|
2001-06-18 15:22:10 -05:00
|
|
|
|
HDfflush(stdout);
|
|
|
|
|
HDfflush(stderr);
|
1998-11-20 22:36:51 -05:00
|
|
|
|
H5close();
|
2015-09-13 22:58:59 -05:00
|
|
|
|
|
|
|
|
|
/* Save current error stack reporting routine and redirect to our local one */
|
|
|
|
|
HDassert(err_func == NULL);
|
|
|
|
|
H5Eget_auto2(H5E_DEFAULT, &err_func, NULL);
|
2010-09-27 14:02:48 -05:00
|
|
|
|
H5Eset_auto2(H5E_DEFAULT, h5_errors, NULL);
|
1998-11-25 09:58:22 -05:00
|
|
|
|
|
[svn-r14353] Description:
- Add hash value for skip list string types, to reduce # of string
comparisons.
- Fixed bug with metadata/small data block aggregator adding size == 0
block into file free space list.
- Refactored metadata/small data block aggregator code into single set of
common routines.
- Changed block aggregator code to be smarter about releasing space in the
'other' block when the 'other' block has aggregated enough data.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (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/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
2007-12-20 15:36:08 -05:00
|
|
|
|
/*
|
|
|
|
|
* I commented this chunk of code out because it's not clear what diagnostics
|
|
|
|
|
* were being output and under what circumstances, and creating this file
|
|
|
|
|
* is throwing off debugging some of the tests. I can't see any _direct_
|
|
|
|
|
* harm in keeping this section of code, but I can't see any _direct_
|
|
|
|
|
* benefit right now either. If we figure out under which circumstances
|
|
|
|
|
* diagnostics are being output, we should enable this behavior based on
|
|
|
|
|
* appropriate configure flags/macros. QAK - 2007/12/20
|
|
|
|
|
*/
|
|
|
|
|
#ifdef OLD_WAY
|
|
|
|
|
{
|
2011-09-06 11:50:32 -05:00
|
|
|
|
char filename[1024];
|
[svn-r14353] Description:
- Add hash value for skip list string types, to reduce # of string
comparisons.
- Fixed bug with metadata/small data block aggregator adding size == 0
block into file free space list.
- Refactored metadata/small data block aggregator code into single set of
common routines.
- Changed block aggregator code to be smarter about releasing space in the
'other' block when the 'other' block has aggregated enough data.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (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/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
2007-12-20 15:36:08 -05:00
|
|
|
|
|
1998-11-25 09:58:22 -05:00
|
|
|
|
/*
|
|
|
|
|
* Cause the library to emit some diagnostics early so they don't
|
|
|
|
|
* interfere with other formatted output.
|
|
|
|
|
*/
|
2001-03-31 22:23:49 -05:00
|
|
|
|
sprintf(filename, "/tmp/h5emit-%05d.h5", HDgetpid());
|
1998-11-25 09:58:22 -05:00
|
|
|
|
H5E_BEGIN_TRY {
|
2015-09-13 22:58:59 -05:00
|
|
|
|
hid_t file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT,
|
|
|
|
|
H5P_DEFAULT);
|
|
|
|
|
hid_t grp = H5Gcreate2(file, "emit", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
|
|
|
|
H5Gclose(grp);
|
|
|
|
|
H5Fclose(file);
|
|
|
|
|
HDunlink(filename);
|
1998-11-25 09:58:22 -05:00
|
|
|
|
} H5E_END_TRY;
|
|
|
|
|
}
|
[svn-r14353] Description:
- Add hash value for skip list string types, to reduce # of string
comparisons.
- Fixed bug with metadata/small data block aggregator adding size == 0
block into file free space list.
- Refactored metadata/small data block aggregator code into single set of
common routines.
- Changed block aggregator code to be smarter about releasing space in the
'other' block when the 'other' block has aggregated enough data.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (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/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
2007-12-20 15:36:08 -05:00
|
|
|
|
#endif /* OLD_WAY */
|
|
|
|
|
}
|
1998-11-20 22:36:51 -05:00
|
|
|
|
|
2016-02-16 23:30:49 -05:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_test_init
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Performs any special actions before the test begins.
|
|
|
|
|
*
|
|
|
|
|
* NOTE: This function should normally only be called once
|
|
|
|
|
* in a given test, usually at the beginning of main(). It
|
|
|
|
|
* is intended for use in the single-file unit tests, not
|
|
|
|
|
* testhdf5.
|
|
|
|
|
*
|
|
|
|
|
* Return: void
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Dana Robinson
|
|
|
|
|
* February 2016
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
h5_test_init(void)
|
|
|
|
|
{
|
|
|
|
|
HDfflush(stdout);
|
|
|
|
|
HDfflush(stderr);
|
|
|
|
|
H5close();
|
|
|
|
|
|
|
|
|
|
/* Save current error stack reporting routine and redirect to our local one */
|
|
|
|
|
HDassert(err_func == NULL);
|
|
|
|
|
H5Eget_auto2(H5E_DEFAULT, &err_func, NULL);
|
|
|
|
|
H5Eset_auto2(H5E_DEFAULT, h5_errors, NULL);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
} /* end h5_test_init() */
|
|
|
|
|
|
1998-11-20 22:36:51 -05:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Function: h5_fixname
|
1998-11-20 22:36:51 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Purpose: Create a file name from a file base name like `test' and
|
|
|
|
|
* return it through the FULLNAME (at most SIZE characters
|
|
|
|
|
* counting the null terminator). The full name is created by
|
|
|
|
|
* prepending the contents of HDF5_PREFIX (separated from the
|
|
|
|
|
* base name by a slash) and appending a file extension based on
|
|
|
|
|
* the driver supplied, resulting in something like
|
|
|
|
|
* `ufs:/u/matzke/test.h5'.
|
1998-11-20 22:36:51 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Return: Success: The FULLNAME pointer.
|
1998-11-20 22:36:51 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Failure: NULL if BASENAME or FULLNAME is the null
|
|
|
|
|
* pointer or if FULLNAME isn't large enough for
|
|
|
|
|
* the result.
|
1998-11-20 22:36:51 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Programmer: Robb Matzke
|
1998-11-20 22:36:51 -05:00
|
|
|
|
* Thursday, November 19, 1998
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
char *
|
1999-06-15 09:58:25 -05:00
|
|
|
|
h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size)
|
2014-10-02 10:56:09 -05:00
|
|
|
|
{
|
2015-07-21 12:14:26 -05:00
|
|
|
|
return (h5_fixname_real(base_name, fapl, ".h5", fullname, size, FALSE));
|
2014-10-02 10:56:09 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_fixname_no_suffix
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Same as h5_fixname but with no suffix appended
|
|
|
|
|
*
|
|
|
|
|
* Return: Success: The FULLNAME pointer.
|
|
|
|
|
*
|
|
|
|
|
* Failure: NULL if BASENAME or FULLNAME is the null
|
|
|
|
|
* pointer or if FULLNAME isn't large enough for
|
|
|
|
|
* the result.
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
char *
|
|
|
|
|
h5_fixname_no_suffix(const char *base_name, hid_t fapl, char *fullname, size_t size)
|
|
|
|
|
{
|
2015-07-21 12:14:26 -05:00
|
|
|
|
return (h5_fixname_real(base_name, fapl, NULL, fullname, size, FALSE));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_fixname_printf
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Same as h5_fixname but returns a filename that can be passed
|
|
|
|
|
* through a printf-style function once before being passed to the file
|
|
|
|
|
* driver. Basically, replaces all % characters used by the file
|
|
|
|
|
* driver with %%.
|
|
|
|
|
*
|
|
|
|
|
* Return: Success: The FULLNAME pointer.
|
|
|
|
|
*
|
|
|
|
|
* Failure: NULL if BASENAME or FULLNAME is the null
|
|
|
|
|
* pointer or if FULLNAME isn't large enough for
|
|
|
|
|
* the result.
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Neil Fortner
|
|
|
|
|
* Wednesday, July 15, 2015
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
char *
|
|
|
|
|
h5_fixname_printf(const char *base_name, hid_t fapl, char *fullname, size_t size)
|
|
|
|
|
{
|
|
|
|
|
return (h5_fixname_real(base_name, fapl, ".h5", fullname, size, TRUE));
|
2014-10-02 10:56:09 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_fixname_real
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Create a file name from a file base name like `test' and
|
|
|
|
|
* return it through the FULLNAME (at most SIZE characters
|
|
|
|
|
* counting the null terminator). The full name is created by
|
|
|
|
|
* prepending the contents of HDF5_PREFIX (separated from the
|
|
|
|
|
* base name by a slash) and appending a file extension based on
|
|
|
|
|
* the driver supplied, resulting in something like
|
|
|
|
|
* `ufs:/u/matzke/test.h5'.
|
|
|
|
|
*
|
|
|
|
|
* Return: Success: The FULLNAME pointer.
|
|
|
|
|
*
|
|
|
|
|
* Failure: NULL if BASENAME or FULLNAME is the null
|
|
|
|
|
* pointer or if FULLNAME isn't large enough for
|
|
|
|
|
* the result.
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Robb Matzke
|
|
|
|
|
* Thursday, November 19, 1998
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static char *
|
|
|
|
|
h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix,
|
2015-07-21 12:14:26 -05:00
|
|
|
|
char *fullname, size_t size, hbool_t nest_printf)
|
1998-11-20 22:36:51 -05:00
|
|
|
|
{
|
2001-05-22 18:27:38 -05:00
|
|
|
|
const char *prefix = NULL;
|
2001-05-25 16:00:41 -05:00
|
|
|
|
char *ptr, last = '\0';
|
2014-10-02 10:56:09 -05:00
|
|
|
|
const char *suffix = _suffix;
|
2001-05-22 18:27:38 -05:00
|
|
|
|
size_t i, j;
|
2003-10-22 16:16:46 -05:00
|
|
|
|
hid_t driver = -1;
|
2014-03-21 18:02:24 -05:00
|
|
|
|
int isppdriver = 0; /* if the driver is MPI parallel */
|
2005-08-13 15:53:35 -05:00
|
|
|
|
|
2001-05-22 18:27:38 -05:00
|
|
|
|
if (!base_name || !fullname || size < 1)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2014-03-15 23:44:13 -05:00
|
|
|
|
HDmemset(fullname, 0, size);
|
1998-11-20 22:36:51 -05:00
|
|
|
|
|
2000-01-25 23:20:36 -05:00
|
|
|
|
/* figure out the suffix */
|
2014-03-15 23:44:13 -05:00
|
|
|
|
if(H5P_DEFAULT != fapl) {
|
|
|
|
|
if((driver = H5Pget_driver(fapl)) < 0)
|
2001-05-22 18:27:38 -05:00
|
|
|
|
return NULL;
|
|
|
|
|
|
2014-10-02 10:56:09 -05:00
|
|
|
|
if(suffix) {
|
|
|
|
|
if(H5FD_FAMILY == driver)
|
2015-07-21 12:14:26 -05:00
|
|
|
|
suffix = nest_printf ? "%%05d.h5" : "%05d.h5";
|
2014-10-02 10:56:09 -05:00
|
|
|
|
else if (H5FD_MULTI == driver)
|
|
|
|
|
suffix = NULL;
|
|
|
|
|
}
|
2000-01-25 23:20:36 -05:00
|
|
|
|
}
|
2005-08-13 15:53:35 -05:00
|
|
|
|
|
2006-01-09 13:17:44 -05:00
|
|
|
|
/* Must first check fapl is not H5P_DEFAULT (-1) because H5FD_XXX
|
|
|
|
|
* could be of value -1 if it is not defined.
|
|
|
|
|
*/
|
2014-03-21 18:02:24 -05:00
|
|
|
|
isppdriver = H5P_DEFAULT != fapl && (H5FD_MPIO==driver);
|
2006-01-09 13:17:44 -05:00
|
|
|
|
|
|
|
|
|
/* Check HDF5_NOCLEANUP environment setting.
|
|
|
|
|
* (The #ifdef is needed to prevent compile failure in case MPI is not
|
|
|
|
|
* configured.)
|
|
|
|
|
*/
|
2014-03-15 23:44:13 -05:00
|
|
|
|
if(isppdriver) {
|
2006-01-09 13:17:44 -05:00
|
|
|
|
#ifdef H5_HAVE_PARALLEL
|
2014-03-15 23:44:13 -05:00
|
|
|
|
if(getenv_all(MPI_COMM_WORLD, 0, "HDF5_NOCLEANUP"))
|
|
|
|
|
SetTestNoCleanup();
|
2006-01-09 13:17:44 -05:00
|
|
|
|
#endif /* H5_HAVE_PARALLEL */
|
2014-03-15 23:44:13 -05:00
|
|
|
|
} else {
|
|
|
|
|
if(HDgetenv("HDF5_NOCLEANUP"))
|
|
|
|
|
SetTestNoCleanup();
|
2006-01-09 13:17:44 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check what prefix to use for test files. Process HDF5_PARAPREFIX and
|
|
|
|
|
* HDF5_PREFIX.
|
|
|
|
|
* Use different ones depending on parallel or serial driver used.
|
|
|
|
|
* (The #ifdef is needed to prevent compile failure in case MPI is not
|
|
|
|
|
* configured.)
|
|
|
|
|
*/
|
2014-03-15 23:44:13 -05:00
|
|
|
|
if(isppdriver) {
|
2003-05-19 14:27:41 -05:00
|
|
|
|
#ifdef H5_HAVE_PARALLEL
|
2014-10-02 10:56:09 -05:00
|
|
|
|
/*
|
2003-10-22 16:16:46 -05:00
|
|
|
|
* For parallel:
|
|
|
|
|
* First use command line option, then the environment
|
|
|
|
|
* variable, then try the constant
|
2014-10-02 10:56:09 -05:00
|
|
|
|
*/
|
2003-10-22 16:16:46 -05:00
|
|
|
|
static int explained = 0;
|
|
|
|
|
|
2014-03-15 23:44:13 -05:00
|
|
|
|
prefix = (paraprefix ? paraprefix : getenv_all(MPI_COMM_WORLD, 0, "HDF5_PARAPREFIX"));
|
2003-10-22 16:16:46 -05:00
|
|
|
|
|
2014-03-15 23:44:13 -05:00
|
|
|
|
if (!prefix && !explained) {
|
|
|
|
|
/* print hint by process 0 once. */
|
|
|
|
|
int mpi_rank;
|
2003-10-22 16:16:46 -05:00
|
|
|
|
|
2014-03-15 23:44:13 -05:00
|
|
|
|
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
|
2003-10-22 16:16:46 -05:00
|
|
|
|
|
2014-03-15 23:44:13 -05:00
|
|
|
|
if (mpi_rank == 0)
|
|
|
|
|
printf("*** Hint ***\n"
|
2014-10-02 10:56:09 -05:00
|
|
|
|
"You can use environment variable HDF5_PARAPREFIX to "
|
|
|
|
|
"run parallel test files in a\n"
|
|
|
|
|
"different directory or to add file type prefix. E.g.,\n"
|
|
|
|
|
" HDF5_PARAPREFIX=pfs:/PFS/user/me\n"
|
|
|
|
|
" export HDF5_PARAPREFIX\n"
|
|
|
|
|
"*** End of Hint ***\n");
|
2003-10-22 16:16:46 -05:00
|
|
|
|
|
2014-03-15 23:44:13 -05:00
|
|
|
|
explained = TRUE;
|
2000-01-25 23:20:36 -05:00
|
|
|
|
#ifdef HDF5_PARAPREFIX
|
2001-05-22 18:27:38 -05:00
|
|
|
|
prefix = HDF5_PARAPREFIX;
|
|
|
|
|
#endif /* HDF5_PARAPREFIX */
|
2014-03-15 23:44:13 -05:00
|
|
|
|
}
|
2003-10-22 16:16:46 -05:00
|
|
|
|
#endif /* H5_HAVE_PARALLEL */
|
|
|
|
|
} else {
|
2014-03-15 23:44:13 -05:00
|
|
|
|
/*
|
2003-10-22 16:16:46 -05:00
|
|
|
|
* For serial:
|
|
|
|
|
* First use the environment variable, then try the constant
|
2014-10-02 10:56:09 -05:00
|
|
|
|
*/
|
2014-03-15 23:44:13 -05:00
|
|
|
|
prefix = HDgetenv("HDF5_PREFIX");
|
2001-05-22 18:27:38 -05:00
|
|
|
|
|
1998-11-20 22:36:51 -05:00
|
|
|
|
#ifdef HDF5_PREFIX
|
2014-03-15 23:44:13 -05:00
|
|
|
|
if (!prefix)
|
2001-05-22 18:27:38 -05:00
|
|
|
|
prefix = HDF5_PREFIX;
|
|
|
|
|
#endif /* HDF5_PREFIX */
|
2000-01-25 23:20:36 -05:00
|
|
|
|
}
|
1998-11-20 22:36:51 -05:00
|
|
|
|
|
|
|
|
|
/* Prepend the prefix value to the base name */
|
|
|
|
|
if (prefix && *prefix) {
|
[svn-r24726] Description:
Revert some earlier usage of strncpy, which was incorrect.
Bring Coverity changes from branch back to trunk:
r20821:
Use HDstrncpy. --gh
(Fixed already, with strdup)
r20822:
(Not merged, incorrect use of HDstrncpy())
r20823:
(Not merged, incorrect use of HDstrncpy())
r20824:
Maintenance: Bug fix: addressed CID 666.
Value stored at *expression_len should be used in the call to
HD5packFstring to avoid overflow (and unnecessary arithmetic
calculation and casting)
r20825:
Issue 642: Added check for error and handler with print to stderr and exit.
r20826:
Undo revision 20818, as that issue has already been fixed in the 1.8 branch
and trunk (but not coverity branch)
r20827:
(Not merged, incorrect use of HDstrncpy())
r20828:
Use HDstrncpy. --gh
(Corrected use of strncpy())
r20829:
Check return of H5Lget_val(print_udata->fid, path, targbuf,
linfo->u.val_size + 1, H5P_DEFAULT) and if error set trgbuf[0] to 0.
Check if H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL,
&filename, &objname) was successful and allow print. Otherwise filename
and objname are not created. (init those to NULL)
r20830:
resolved coverity issues 939, 940, 941, 944, and 947.
all were complaints about use of sprintf, and in all cases, the
buffers used were large enough for all eventualities.
Resolved issue by replacing calls to sprintf with calls
to snprintf.
r20831:
Maintenance: Addressed CID 852
Replaced sprintf with snprintf
r20832:
Purpose: Fix valgrind issues with hl/examples/ex_image2
Description:
Modified hl/examples/ex_image2 to free global "gbuf" before exit.
Tested on:
Mac OSX/64 10.9.1 (amaon) w/C++, FORTRAN & Threadsafety
(too minor to require h5committest)
2014-02-20 16:29:26 -05:00
|
|
|
|
if (isppdriver) {
|
2001-05-25 15:01:38 -05:00
|
|
|
|
/* This is a parallel system */
|
|
|
|
|
char *subdir;
|
2001-05-22 18:27:38 -05:00
|
|
|
|
|
2001-06-18 15:22:10 -05:00
|
|
|
|
if (!HDstrcmp(prefix, HDF5_PARAPREFIX)) {
|
2003-10-22 16:16:46 -05:00
|
|
|
|
/*
|
|
|
|
|
* If the prefix specifies the HDF5_PARAPREFIX directory, then
|
2001-05-25 15:01:38 -05:00
|
|
|
|
* default to using the "/tmp/$USER" or "/tmp/$LOGIN"
|
2003-10-22 16:16:46 -05:00
|
|
|
|
* directory instead.
|
|
|
|
|
*/
|
2001-05-25 15:01:38 -05:00
|
|
|
|
char *user, *login;
|
2001-05-22 18:27:38 -05:00
|
|
|
|
|
2001-06-18 15:22:10 -05:00
|
|
|
|
user = HDgetenv("USER");
|
|
|
|
|
login = HDgetenv("LOGIN");
|
2001-05-25 15:01:38 -05:00
|
|
|
|
subdir = (user ? user : login);
|
2001-05-22 18:27:38 -05:00
|
|
|
|
|
2001-05-25 15:01:38 -05:00
|
|
|
|
if (subdir) {
|
|
|
|
|
for (i = 0; i < size && prefix[i]; i++)
|
|
|
|
|
fullname[i] = prefix[i];
|
2001-05-22 18:27:38 -05:00
|
|
|
|
|
2001-05-25 15:01:38 -05:00
|
|
|
|
fullname[i++] = '/';
|
2001-05-22 18:27:38 -05:00
|
|
|
|
|
2003-10-22 16:16:46 -05:00
|
|
|
|
for (j = 0; i < size && subdir[j]; ++i, ++j)
|
2001-05-25 15:01:38 -05:00
|
|
|
|
fullname[i] = subdir[j];
|
|
|
|
|
}
|
2001-05-22 18:27:38 -05:00
|
|
|
|
}
|
|
|
|
|
|
[svn-r24726] Description:
Revert some earlier usage of strncpy, which was incorrect.
Bring Coverity changes from branch back to trunk:
r20821:
Use HDstrncpy. --gh
(Fixed already, with strdup)
r20822:
(Not merged, incorrect use of HDstrncpy())
r20823:
(Not merged, incorrect use of HDstrncpy())
r20824:
Maintenance: Bug fix: addressed CID 666.
Value stored at *expression_len should be used in the call to
HD5packFstring to avoid overflow (and unnecessary arithmetic
calculation and casting)
r20825:
Issue 642: Added check for error and handler with print to stderr and exit.
r20826:
Undo revision 20818, as that issue has already been fixed in the 1.8 branch
and trunk (but not coverity branch)
r20827:
(Not merged, incorrect use of HDstrncpy())
r20828:
Use HDstrncpy. --gh
(Corrected use of strncpy())
r20829:
Check return of H5Lget_val(print_udata->fid, path, targbuf,
linfo->u.val_size + 1, H5P_DEFAULT) and if error set trgbuf[0] to 0.
Check if H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL,
&filename, &objname) was successful and allow print. Otherwise filename
and objname are not created. (init those to NULL)
r20830:
resolved coverity issues 939, 940, 941, 944, and 947.
all were complaints about use of sprintf, and in all cases, the
buffers used were large enough for all eventualities.
Resolved issue by replacing calls to sprintf with calls
to snprintf.
r20831:
Maintenance: Addressed CID 852
Replaced sprintf with snprintf
r20832:
Purpose: Fix valgrind issues with hl/examples/ex_image2
Description:
Modified hl/examples/ex_image2 to free global "gbuf" before exit.
Tested on:
Mac OSX/64 10.9.1 (amaon) w/C++, FORTRAN & Threadsafety
(too minor to require h5committest)
2014-02-20 16:29:26 -05:00
|
|
|
|
if (!fullname[0]) {
|
2001-05-25 15:01:38 -05:00
|
|
|
|
/* We didn't append the prefix yet */
|
[svn-r24726] Description:
Revert some earlier usage of strncpy, which was incorrect.
Bring Coverity changes from branch back to trunk:
r20821:
Use HDstrncpy. --gh
(Fixed already, with strdup)
r20822:
(Not merged, incorrect use of HDstrncpy())
r20823:
(Not merged, incorrect use of HDstrncpy())
r20824:
Maintenance: Bug fix: addressed CID 666.
Value stored at *expression_len should be used in the call to
HD5packFstring to avoid overflow (and unnecessary arithmetic
calculation and casting)
r20825:
Issue 642: Added check for error and handler with print to stderr and exit.
r20826:
Undo revision 20818, as that issue has already been fixed in the 1.8 branch
and trunk (but not coverity branch)
r20827:
(Not merged, incorrect use of HDstrncpy())
r20828:
Use HDstrncpy. --gh
(Corrected use of strncpy())
r20829:
Check return of H5Lget_val(print_udata->fid, path, targbuf,
linfo->u.val_size + 1, H5P_DEFAULT) and if error set trgbuf[0] to 0.
Check if H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL,
&filename, &objname) was successful and allow print. Otherwise filename
and objname are not created. (init those to NULL)
r20830:
resolved coverity issues 939, 940, 941, 944, and 947.
all were complaints about use of sprintf, and in all cases, the
buffers used were large enough for all eventualities.
Resolved issue by replacing calls to sprintf with calls
to snprintf.
r20831:
Maintenance: Addressed CID 852
Replaced sprintf with snprintf
r20832:
Purpose: Fix valgrind issues with hl/examples/ex_image2
Description:
Modified hl/examples/ex_image2 to free global "gbuf" before exit.
Tested on:
Mac OSX/64 10.9.1 (amaon) w/C++, FORTRAN & Threadsafety
(too minor to require h5committest)
2014-02-20 16:29:26 -05:00
|
|
|
|
HDstrncpy(fullname, prefix, size);
|
|
|
|
|
fullname[size -1] = '\0';
|
|
|
|
|
}
|
2001-05-25 15:01:38 -05:00
|
|
|
|
|
2001-06-18 15:22:10 -05:00
|
|
|
|
if (HDstrlen(fullname) + HDstrlen(base_name) + 1 < size) {
|
2003-10-22 16:16:46 -05:00
|
|
|
|
/*
|
|
|
|
|
* Append the base_name with a slash first. Multiple
|
|
|
|
|
* slashes are handled below.
|
|
|
|
|
*/
|
2002-04-19 02:20:41 -05:00
|
|
|
|
h5_stat_t buf;
|
2001-05-25 15:01:38 -05:00
|
|
|
|
|
2001-06-18 15:22:10 -05:00
|
|
|
|
if (HDstat(fullname, &buf) < 0)
|
2001-05-25 15:01:38 -05:00
|
|
|
|
/* The directory doesn't exist just yet */
|
2003-10-22 16:16:46 -05:00
|
|
|
|
if (HDmkdir(fullname, (mode_t)0755) < 0 && errno != EEXIST)
|
|
|
|
|
/*
|
|
|
|
|
* We couldn't make the "/tmp/${USER,LOGIN}"
|
|
|
|
|
* subdirectory. Default to PREFIX's original
|
|
|
|
|
* prefix value.
|
|
|
|
|
*/
|
2001-06-22 16:54:07 -05:00
|
|
|
|
HDstrcpy(fullname, prefix);
|
2001-05-25 15:01:38 -05:00
|
|
|
|
|
2001-06-18 15:22:10 -05:00
|
|
|
|
HDstrcat(fullname, "/");
|
|
|
|
|
HDstrcat(fullname, base_name);
|
2001-05-25 15:01:38 -05:00
|
|
|
|
} else {
|
|
|
|
|
/* Buffer is too small */
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2001-05-22 18:27:38 -05:00
|
|
|
|
} else {
|
2001-05-25 15:01:38 -05:00
|
|
|
|
if (HDsnprintf(fullname, size, "%s/%s", prefix, base_name) == (int)size)
|
|
|
|
|
/* Buffer is too small */
|
|
|
|
|
return NULL;
|
2001-05-22 18:27:38 -05:00
|
|
|
|
}
|
2001-06-18 15:22:10 -05:00
|
|
|
|
} else if (HDstrlen(base_name) >= size) {
|
2014-10-02 10:56:09 -05:00
|
|
|
|
/* Buffer is too small */
|
|
|
|
|
return NULL;
|
1998-11-20 22:36:51 -05:00
|
|
|
|
} else {
|
2014-10-02 10:56:09 -05:00
|
|
|
|
HDstrcpy(fullname, base_name);
|
|
|
|
|
}
|
1998-11-20 22:36:51 -05:00
|
|
|
|
|
|
|
|
|
/* Append a suffix */
|
|
|
|
|
if (suffix) {
|
2014-10-02 10:56:09 -05:00
|
|
|
|
if (HDstrlen(fullname) + HDstrlen(suffix) >= size)
|
2001-05-22 18:27:38 -05:00
|
|
|
|
return NULL;
|
|
|
|
|
|
2014-10-02 10:56:09 -05:00
|
|
|
|
HDstrcat(fullname, suffix);
|
1998-11-20 22:36:51 -05:00
|
|
|
|
}
|
2001-05-22 18:27:38 -05:00
|
|
|
|
|
|
|
|
|
/* Remove any double slashes in the filename */
|
|
|
|
|
for (ptr = fullname, i = j = 0; ptr && i < size; i++, ptr++) {
|
|
|
|
|
if (*ptr != '/' || last != '/')
|
|
|
|
|
fullname[j++] = *ptr;
|
|
|
|
|
|
|
|
|
|
last = *ptr;
|
|
|
|
|
}
|
2001-05-25 16:00:41 -05:00
|
|
|
|
|
1998-11-20 22:36:51 -05:00
|
|
|
|
return fullname;
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-01 17:56:50 -05:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Function: h5_rmprefix
|
2006-06-01 17:56:50 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Purpose: This "removes" the MPIO driver prefix part of the file name
|
|
|
|
|
* by returning a pointer that points at the non-prefix component
|
2006-06-01 17:56:50 -05:00
|
|
|
|
* part of the file name. E.g.,
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Input Return
|
|
|
|
|
* pfs:/scratch1/dataX /scratch1/dataX
|
|
|
|
|
* /scratch2/dataY /scratch2/dataY
|
|
|
|
|
* Note that there is no change to the original file name.
|
2006-06-01 17:56:50 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Return: Success: a pointer at the non-prefix part.
|
2006-06-01 17:56:50 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Programmer: Albert Cheng; Jun 1, 2006
|
2006-06-01 17:56:50 -05:00
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2016-06-28 16:53:48 -05:00
|
|
|
|
H5_ATTR_PURE const char *
|
2006-06-01 17:56:50 -05:00
|
|
|
|
h5_rmprefix(const char *filename)
|
|
|
|
|
{
|
2006-10-02 05:24:03 -05:00
|
|
|
|
const char *ret_ptr;
|
2006-06-01 17:56:50 -05:00
|
|
|
|
|
|
|
|
|
if ((ret_ptr = HDstrstr(filename, ":")) == NULL)
|
2016-06-28 16:53:48 -05:00
|
|
|
|
ret_ptr = filename;
|
2006-06-01 17:56:50 -05:00
|
|
|
|
else
|
2016-06-28 16:53:48 -05:00
|
|
|
|
ret_ptr++;
|
2006-06-27 09:45:06 -05:00
|
|
|
|
|
2006-06-01 17:56:50 -05:00
|
|
|
|
return(ret_ptr);
|
|
|
|
|
}
|
|
|
|
|
|
1998-11-20 22:36:51 -05:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2016-08-17 13:59:45 -05:00
|
|
|
|
* Function: h5_fileaccess
|
1998-11-20 22:36:51 -05:00
|
|
|
|
*
|
2016-08-17 13:59:45 -05:00
|
|
|
|
* Purpose: Returns a file access template which is the default template
|
2018-11-28 17:38:03 -06:00
|
|
|
|
* but with a file driver, VOL connector, or libver bound set
|
2018-12-16 12:41:55 -08:00
|
|
|
|
* according to a constant or environment variable
|
1998-11-20 22:36:51 -05:00
|
|
|
|
*
|
2018-12-16 12:41:55 -08:00
|
|
|
|
* Return: Success: A file access property list
|
|
|
|
|
* Failure: H5I_INVALID_HID
|
1998-11-20 22:36:51 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Programmer: Robb Matzke
|
1998-11-20 22:36:51 -05:00
|
|
|
|
* Thursday, November 19, 1998
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
hid_t
|
|
|
|
|
h5_fileaccess(void)
|
|
|
|
|
{
|
2018-12-16 12:41:55 -08:00
|
|
|
|
hid_t fapl_id = H5I_INVALID_HID;
|
2005-08-13 15:53:35 -05:00
|
|
|
|
|
2018-12-16 12:41:55 -08:00
|
|
|
|
if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0)
|
|
|
|
|
goto error;
|
2004-01-09 20:41:13 -05:00
|
|
|
|
|
2018-11-28 17:38:03 -06:00
|
|
|
|
/* Attempt to set up a file driver first */
|
2018-12-16 12:41:55 -08:00
|
|
|
|
if(h5_get_vfd_fapl(fapl_id) < 0)
|
|
|
|
|
goto error;
|
2004-01-09 20:41:13 -05:00
|
|
|
|
|
2018-11-28 17:38:03 -06:00
|
|
|
|
/* Next, try to set up a VOL connector */
|
2018-12-16 12:41:55 -08:00
|
|
|
|
if(h5_get_vol_fapl(fapl_id) < 0)
|
|
|
|
|
goto error;
|
2018-11-28 17:38:03 -06:00
|
|
|
|
|
|
|
|
|
/* Finally, check for libver bounds */
|
2018-12-16 12:41:55 -08:00
|
|
|
|
if(h5_get_libver_fapl(fapl_id) < 0)
|
|
|
|
|
goto error;
|
2018-11-28 17:38:03 -06:00
|
|
|
|
|
2018-12-16 12:41:55 -08:00
|
|
|
|
return fapl_id;
|
|
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
if(fapl_id != H5I_INVALID_HID)
|
|
|
|
|
H5Pclose(fapl_id);
|
|
|
|
|
return H5I_INVALID_HID;
|
2018-11-28 17:38:03 -06:00
|
|
|
|
} /* end h5_fileaccess() */
|
1998-11-20 22:36:51 -05:00
|
|
|
|
|
2016-02-16 23:30:49 -05:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_get_vfd_fapl
|
|
|
|
|
*
|
2018-11-28 17:38:03 -06:00
|
|
|
|
* Purpose: Sets the file driver for a FAPL according to the value specified
|
|
|
|
|
* in the constant or environment variable "HDF5_DRIVER".
|
2016-02-16 23:30:49 -05:00
|
|
|
|
*
|
2018-11-28 17:38:03 -06:00
|
|
|
|
* Return: Success: 0
|
2016-02-16 23:30:49 -05:00
|
|
|
|
* Failure: -1
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Dana Robinson
|
|
|
|
|
* February 2016
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2018-11-28 17:38:03 -06:00
|
|
|
|
herr_t
|
|
|
|
|
h5_get_vfd_fapl(hid_t fapl)
|
2016-02-16 23:30:49 -05:00
|
|
|
|
{
|
|
|
|
|
const char *env = NULL; /* HDF5_DRIVER environment variable */
|
|
|
|
|
const char *tok = NULL; /* strtok pointer */
|
2018-12-13 17:31:00 -06:00
|
|
|
|
char *lasts = NULL; /* Context pointer for strtok_r() call */
|
2016-02-16 23:30:49 -05:00
|
|
|
|
char buf[1024]; /* buffer for tokenizing HDF5_DRIVER */
|
|
|
|
|
|
|
|
|
|
/* Get the environment variable, if it exists */
|
|
|
|
|
env = HDgetenv("HDF5_DRIVER");
|
2018-11-28 17:38:03 -06:00
|
|
|
|
#ifdef HDF5_DRIVER
|
|
|
|
|
/* Use the environment variable, then the compile-time constant */
|
|
|
|
|
if(!env)
|
|
|
|
|
env = HDF5_DRIVER;
|
|
|
|
|
#endif
|
2016-02-16 23:30:49 -05:00
|
|
|
|
|
|
|
|
|
/* If the environment variable was not set, just return
|
2018-11-28 17:38:03 -06:00
|
|
|
|
* without modifying the FAPL.
|
2016-02-16 23:30:49 -05:00
|
|
|
|
*/
|
|
|
|
|
if(!env || !*env)
|
2018-11-28 17:38:03 -06:00
|
|
|
|
goto done;
|
2016-02-16 23:30:49 -05:00
|
|
|
|
|
|
|
|
|
/* Get the first 'word' of the environment variable.
|
|
|
|
|
* If it's nothing (environment variable was whitespace)
|
|
|
|
|
* just return the default fapl.
|
|
|
|
|
*/
|
|
|
|
|
HDstrncpy(buf, env, sizeof(buf));
|
2018-11-28 17:38:03 -06:00
|
|
|
|
buf[sizeof(buf) - 1] = '\0';
|
2018-12-13 17:31:00 -06:00
|
|
|
|
if(NULL == (tok = HDstrtok_r(buf, " \t\n\r", &lasts)))
|
2018-11-28 17:38:03 -06:00
|
|
|
|
goto done;
|
2016-02-16 23:30:49 -05:00
|
|
|
|
|
|
|
|
|
if(!HDstrcmp(tok, "sec2")) {
|
|
|
|
|
/* POSIX (section 2) read() and write() system calls */
|
|
|
|
|
if(H5Pset_fapl_sec2(fapl) < 0)
|
2018-11-28 17:38:03 -06:00
|
|
|
|
goto error;
|
2016-02-16 23:30:49 -05:00
|
|
|
|
} else if(!HDstrcmp(tok, "stdio")) {
|
|
|
|
|
/* Standard C fread() and fwrite() system calls */
|
|
|
|
|
if(H5Pset_fapl_stdio(fapl) < 0)
|
2018-11-28 17:38:03 -06:00
|
|
|
|
goto error;
|
2016-02-16 23:30:49 -05:00
|
|
|
|
} else if(!HDstrcmp(tok, "core")) {
|
|
|
|
|
/* In-memory driver settings (backing store on, 1 MB increment) */
|
|
|
|
|
if(H5Pset_fapl_core(fapl, (size_t)1, TRUE) < 0)
|
2018-11-28 17:38:03 -06:00
|
|
|
|
goto error;
|
2016-02-16 23:30:49 -05:00
|
|
|
|
} else if(!HDstrcmp(tok, "core_paged")) {
|
|
|
|
|
/* In-memory driver with write tracking and paging on */
|
|
|
|
|
if(H5Pset_fapl_core(fapl, (size_t)1, TRUE) < 0)
|
2018-11-28 17:38:03 -06:00
|
|
|
|
goto error;
|
2016-02-16 23:30:49 -05:00
|
|
|
|
if(H5Pset_core_write_tracking(fapl, TRUE, (size_t)4096) < 0)
|
2018-11-28 17:38:03 -06:00
|
|
|
|
goto error;
|
2016-02-16 23:30:49 -05:00
|
|
|
|
} else if(!HDstrcmp(tok, "split")) {
|
|
|
|
|
/* Split meta data and raw data each using default driver */
|
2018-11-28 17:38:03 -06:00
|
|
|
|
if(H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0)
|
|
|
|
|
goto error;
|
2016-02-16 23:30:49 -05:00
|
|
|
|
} else if(!HDstrcmp(tok, "multi")) {
|
|
|
|
|
/* Multi-file driver, general case of the split driver */
|
|
|
|
|
H5FD_mem_t memb_map[H5FD_MEM_NTYPES];
|
|
|
|
|
hid_t memb_fapl[H5FD_MEM_NTYPES];
|
|
|
|
|
const char *memb_name[H5FD_MEM_NTYPES];
|
2016-09-27 10:29:16 -07:00
|
|
|
|
char *sv[H5FD_MEM_NTYPES];
|
2016-02-16 23:30:49 -05:00
|
|
|
|
haddr_t memb_addr[H5FD_MEM_NTYPES];
|
|
|
|
|
H5FD_mem_t mt;
|
|
|
|
|
|
|
|
|
|
HDmemset(memb_map, 0, sizeof(memb_map));
|
|
|
|
|
HDmemset(memb_fapl, 0, sizeof(memb_fapl));
|
|
|
|
|
HDmemset(memb_name, 0, sizeof(memb_name));
|
|
|
|
|
HDmemset(memb_addr, 0, sizeof(memb_addr));
|
|
|
|
|
|
|
|
|
|
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;
|
2016-09-29 13:17:55 -07:00
|
|
|
|
sv[mt] = (char *)HDmalloc(H5TEST_MULTI_FILENAME_LEN);
|
2016-09-27 10:29:16 -07:00
|
|
|
|
HDassert(sv[mt]);
|
2016-02-16 23:30:49 -05:00
|
|
|
|
HDsprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]);
|
|
|
|
|
memb_name[mt] = sv[mt];
|
|
|
|
|
memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10);
|
|
|
|
|
} /* end for */
|
|
|
|
|
|
2016-09-27 10:29:16 -07:00
|
|
|
|
if(H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, FALSE) < 0)
|
2018-11-28 17:38:03 -06:00
|
|
|
|
goto error;
|
2016-09-27 10:29:16 -07:00
|
|
|
|
|
|
|
|
|
for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt))
|
|
|
|
|
HDfree(sv[mt]);
|
2016-02-16 23:30:49 -05:00
|
|
|
|
} else if(!HDstrcmp(tok, "family")) {
|
|
|
|
|
/* Family of files, each 1MB and using the default driver */
|
2018-11-28 17:38:03 -06:00
|
|
|
|
hsize_t fam_size = 100 * 1024 * 1024; /* 100 MB */
|
2016-02-16 23:30:49 -05:00
|
|
|
|
|
|
|
|
|
/* Was a family size specified in the environment variable? */
|
2018-12-13 17:31:00 -06:00
|
|
|
|
if((tok = HDstrtok_r(NULL, " \t\n\r", &lasts)))
|
2018-11-28 17:38:03 -06:00
|
|
|
|
fam_size = (hsize_t)(HDstrtod(tok, NULL) * 1024 * 1024);
|
2016-02-16 23:30:49 -05:00
|
|
|
|
if(H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT) < 0)
|
2018-11-28 17:38:03 -06:00
|
|
|
|
goto error;
|
2016-02-16 23:30:49 -05:00
|
|
|
|
} else if(!HDstrcmp(tok, "log")) {
|
|
|
|
|
/* Log file access */
|
|
|
|
|
unsigned log_flags = H5FD_LOG_LOC_IO | H5FD_LOG_ALLOC;
|
|
|
|
|
|
|
|
|
|
/* Were special log file flags specified in the environment variable? */
|
2018-12-13 17:31:00 -06:00
|
|
|
|
if((tok = HDstrtok_r(NULL, " \t\n\r", &lasts)))
|
2016-02-16 23:30:49 -05:00
|
|
|
|
log_flags = (unsigned)HDstrtol(tok, NULL, 0);
|
|
|
|
|
|
|
|
|
|
if(H5Pset_fapl_log(fapl, NULL, log_flags, (size_t)0) < 0)
|
2018-11-28 17:38:03 -06:00
|
|
|
|
goto error;
|
2016-02-16 23:30:49 -05:00
|
|
|
|
#ifdef H5_HAVE_DIRECT
|
|
|
|
|
} else if(!HDstrcmp(tok, "direct")) {
|
|
|
|
|
/* Linux direct read() and write() system calls. Set memory boundary,
|
|
|
|
|
* file block size, and copy buffer size to the default values.
|
|
|
|
|
*/
|
2018-11-28 17:38:03 -06:00
|
|
|
|
if(H5Pset_fapl_direct(fapl, 1024, 4096, 8 * 4096) < 0)
|
|
|
|
|
goto error;
|
2016-02-16 23:30:49 -05:00
|
|
|
|
#endif
|
|
|
|
|
} else {
|
|
|
|
|
/* Unknown driver */
|
2018-11-28 17:38:03 -06:00
|
|
|
|
goto error;
|
|
|
|
|
} /* end if */
|
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
return -1;
|
|
|
|
|
} /* end h5_get_vfd_fapl() */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_get_libver_fapl
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Sets the library version bounds for a FAPL according to the
|
|
|
|
|
* value in the constant or environment variable "HDF5_LIBVER_BOUNDS".
|
|
|
|
|
*
|
|
|
|
|
* Return: Success: 0
|
|
|
|
|
* Failure: -1
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Quincey Koziol
|
|
|
|
|
* November 2018
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
herr_t
|
|
|
|
|
h5_get_libver_fapl(hid_t fapl)
|
|
|
|
|
{
|
|
|
|
|
const char *env = NULL; /* HDF5_DRIVER environment variable */
|
|
|
|
|
const char *tok = NULL; /* strtok pointer */
|
2018-12-13 17:31:00 -06:00
|
|
|
|
char *lasts = NULL; /* Context pointer for strtok_r() call */
|
2018-11-28 17:38:03 -06:00
|
|
|
|
char buf[1024]; /* buffer for tokenizing HDF5_DRIVER */
|
|
|
|
|
|
|
|
|
|
/* Get the environment variable, if it exists */
|
|
|
|
|
env = HDgetenv("HDF5_LIBVER_BOUNDS");
|
|
|
|
|
#ifdef HDF5_LIBVER_BOUNDS
|
|
|
|
|
/* Use the environment variable, then the compile-time constant */
|
|
|
|
|
if(!env)
|
|
|
|
|
env = HDF5_LIBVER_BOUNDS;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* If the environment variable was not set, just return
|
|
|
|
|
* without modifying the FAPL.
|
|
|
|
|
*/
|
|
|
|
|
if(!env || !*env)
|
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
|
|
/* Get the first 'word' of the environment variable.
|
|
|
|
|
* If it's nothing (environment variable was whitespace)
|
|
|
|
|
* just return the default fapl.
|
|
|
|
|
*/
|
|
|
|
|
HDstrncpy(buf, env, sizeof(buf));
|
|
|
|
|
buf[sizeof(buf) - 1] = '\0';
|
2018-12-13 17:31:00 -06:00
|
|
|
|
if(NULL == (tok = HDstrtok_r(buf, " \t\n\r", &lasts)))
|
2018-11-28 17:38:03 -06:00
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
|
|
if(!HDstrcmp(tok, "latest")) {
|
|
|
|
|
/* use the latest format */
|
|
|
|
|
if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
|
|
|
|
|
goto error;
|
2016-02-16 23:30:49 -05:00
|
|
|
|
} /* end if */
|
2018-11-28 17:38:03 -06:00
|
|
|
|
else {
|
|
|
|
|
/* Unknown setting */
|
|
|
|
|
goto error;
|
|
|
|
|
} /* end else */
|
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
return 0;
|
2016-02-16 23:30:49 -05:00
|
|
|
|
|
2018-11-28 17:38:03 -06:00
|
|
|
|
error:
|
|
|
|
|
return -1;
|
2018-11-28 19:07:30 -06:00
|
|
|
|
} /* end h5_get_libver_fapl() */
|
2016-02-16 23:30:49 -05:00
|
|
|
|
|
2018-11-28 17:38:03 -06:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_get_vol_fapl
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Returns a file access property list which is the default
|
|
|
|
|
* fapl but with a VOL connector set according to the constant
|
|
|
|
|
* or environment variable HDF5_VOL_CONNECTOR.
|
|
|
|
|
*
|
2018-12-16 12:41:55 -08:00
|
|
|
|
* Return: Success: 0
|
2018-11-28 17:38:03 -06:00
|
|
|
|
* Failure: -1
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Jordan Henderson
|
|
|
|
|
* November 2018
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
herr_t
|
|
|
|
|
h5_get_vol_fapl(hid_t fapl)
|
|
|
|
|
{
|
|
|
|
|
const char *env = NULL;
|
|
|
|
|
const char *tok = NULL;
|
2018-12-13 17:31:00 -06:00
|
|
|
|
char *lasts = NULL; /* Context pointer for strtok_r() call */
|
2018-11-28 17:38:03 -06:00
|
|
|
|
htri_t connector_is_registered;
|
|
|
|
|
char buf[1024]; /* Buffer for tokenizing HDF5_VOL_CONNECTOR */
|
|
|
|
|
void *vol_info = NULL; /* VOL connector info */
|
|
|
|
|
hid_t connector_id = -1;
|
|
|
|
|
|
|
|
|
|
/* Get the environment variable, if it exists */
|
|
|
|
|
env = HDgetenv("HDF5_VOL_CONNECTOR");
|
|
|
|
|
#ifdef HDF5_VOL_CONNECTOR
|
|
|
|
|
/* Use the environment variable, then the compile-time constant */
|
|
|
|
|
if(!env)
|
|
|
|
|
env = HDF5_VOL_CONNECTOR;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* If the environment variable was not set, just return. */
|
|
|
|
|
if(!env || !*env)
|
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
|
|
/* Get the first 'word' of the environment variable.
|
|
|
|
|
* If it's nothing (environment variable was whitespace) just return.
|
|
|
|
|
*/
|
|
|
|
|
HDstrncpy(buf, env, sizeof(buf));
|
|
|
|
|
buf[sizeof(buf) - 1] = '\0';
|
2018-12-13 17:31:00 -06:00
|
|
|
|
if(NULL == (tok = HDstrtok_r(buf, " \t\n\r", &lasts)))
|
2018-11-28 17:38:03 -06:00
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
|
|
/* First, check to see if the connector is already registered */
|
|
|
|
|
if((connector_is_registered = H5VLis_connector_registered(tok)) < 0)
|
|
|
|
|
goto done;
|
|
|
|
|
else if(connector_is_registered) {
|
|
|
|
|
/* Retrieve the ID of the already-registered VOL connector */
|
|
|
|
|
if((connector_id = H5VLget_connector_id(tok)) < 0)
|
|
|
|
|
goto error;
|
|
|
|
|
} /* end else-if */
|
|
|
|
|
else {
|
|
|
|
|
/* Check for VOL connectors that ship with the library */
|
|
|
|
|
if(!HDstrcmp(tok, "native")) {
|
|
|
|
|
connector_id = H5VL_NATIVE;
|
|
|
|
|
if(H5Iinc_ref(connector_id) < 0)
|
|
|
|
|
goto error;
|
|
|
|
|
} else if(!HDstrcmp(tok, "pass_through")) {
|
|
|
|
|
connector_id = H5VL_PASSTHRU;
|
|
|
|
|
if(H5Iinc_ref(connector_id) < 0)
|
|
|
|
|
goto error;
|
|
|
|
|
} else {
|
|
|
|
|
/* Register the VOL connector */
|
|
|
|
|
/* (NOTE: No provisions for vipl_id currently) */
|
|
|
|
|
if((connector_id = H5VLregister_connector_by_name(tok, H5P_DEFAULT)) < 0)
|
|
|
|
|
goto error;
|
|
|
|
|
} /* end else */
|
|
|
|
|
} /* end else */
|
|
|
|
|
|
|
|
|
|
/* Was there any connector info specified in the environment variable? */
|
2018-12-13 17:31:00 -06:00
|
|
|
|
if(NULL != (tok = HDstrtok_r(NULL, " \t\n\r", &lasts)))
|
2018-11-28 17:38:03 -06:00
|
|
|
|
if(H5VLconnector_str_to_info(tok, connector_id, &vol_info) < 0)
|
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
|
|
/* Set the VOL connector in the FAPL */
|
|
|
|
|
if(H5Pset_vol(fapl, connector_id, vol_info) < 0)
|
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
|
|
/* Release VOL connector info, if there was any */
|
|
|
|
|
if(vol_info)
|
|
|
|
|
if(H5VLfree_connector_info(connector_id, vol_info) < 0)
|
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
|
|
/* Close the connector ID */
|
|
|
|
|
if(connector_id >= 0)
|
|
|
|
|
if(H5VLunregister_connector(connector_id) < 0)
|
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
if(vol_info)
|
|
|
|
|
H5VLfree_connector_info(connector_id, vol_info);
|
|
|
|
|
if(connector_id >= 0)
|
|
|
|
|
H5VLunregister_connector(connector_id);
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
} /* end h5_get_vol_fapl() */
|
|
|
|
|
|
1998-11-20 22:36:51 -05:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Function: h5_no_hwconv
|
1998-11-20 22:36:51 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Purpose: Turn off hardware data type conversions.
|
1998-11-20 22:36:51 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Return: void
|
1998-11-20 22:36:51 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Programmer: Robb Matzke
|
1998-11-20 22:36:51 -05:00
|
|
|
|
* Friday, November 20, 1998
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
h5_no_hwconv(void)
|
|
|
|
|
{
|
2014-07-30 15:55:14 -05:00
|
|
|
|
H5Tunregister(H5T_PERS_HARD, NULL, (hid_t)-1, (hid_t)-1, NULL);
|
1998-11-20 22:36:51 -05:00
|
|
|
|
}
|
2002-04-22 12:12:14 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Function: h5_show_hostname
|
2002-04-22 12:12:14 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Purpose: Show hostname. Show process ID if in MPI environment.
|
2002-04-22 12:12:14 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Return: void
|
2002-04-22 12:12:14 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Programmer: Albert Cheng
|
2002-04-22 12:12:14 -05:00
|
|
|
|
* 2002/04/22
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
h5_show_hostname(void)
|
|
|
|
|
{
|
2011-09-06 11:50:32 -05:00
|
|
|
|
char hostname[80];
|
|
|
|
|
#ifdef H5_HAVE_WIN32_API
|
2015-06-10 12:57:32 -05:00
|
|
|
|
WSADATA wsaData;
|
|
|
|
|
int err;
|
2002-04-24 09:58:26 -05:00
|
|
|
|
#endif
|
2002-04-22 12:12:14 -05:00
|
|
|
|
|
|
|
|
|
/* try show the process or thread id in multiple processes cases*/
|
|
|
|
|
#ifdef H5_HAVE_PARALLEL
|
2005-08-13 15:53:35 -05:00
|
|
|
|
{
|
2015-06-10 12:57:32 -05:00
|
|
|
|
int mpi_rank, mpi_initialized, mpi_finalized;
|
|
|
|
|
|
|
|
|
|
MPI_Initialized(&mpi_initialized);
|
|
|
|
|
MPI_Finalized(&mpi_finalized);
|
|
|
|
|
|
|
|
|
|
if(mpi_initialized && !mpi_finalized) {
|
|
|
|
|
MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank);
|
|
|
|
|
printf("MPI-process %d.", mpi_rank);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
printf("thread 0.");
|
2002-04-22 12:12:14 -05:00
|
|
|
|
}
|
|
|
|
|
#elif defined(H5_HAVE_THREADSAFE)
|
2008-06-06 14:11:46 -05:00
|
|
|
|
printf("thread %lu.", HDpthread_self_ulong());
|
2002-04-22 12:12:14 -05:00
|
|
|
|
#else
|
|
|
|
|
printf("thread 0.");
|
|
|
|
|
#endif
|
2011-09-06 11:50:32 -05:00
|
|
|
|
#ifdef H5_HAVE_WIN32_API
|
2002-04-24 09:58:26 -05:00
|
|
|
|
|
2015-06-10 12:57:32 -05:00
|
|
|
|
err = WSAStartup( MAKEWORD(2,2), &wsaData );
|
|
|
|
|
if ( err != 0 ) {
|
|
|
|
|
/* could not find a usable WinSock DLL */
|
|
|
|
|
return;
|
|
|
|
|
}
|
2005-08-13 15:53:35 -05:00
|
|
|
|
|
2015-06-10 12:57:32 -05:00
|
|
|
|
/* Confirm that the WinSock DLL supports 2.2.*/
|
|
|
|
|
/* Note that if the DLL supports versions greater */
|
|
|
|
|
/* than 2.2 in addition to 2.2, it will still return */
|
|
|
|
|
/* 2.2 in wVersion since that is the version we */
|
|
|
|
|
/* requested. */
|
|
|
|
|
|
|
|
|
|
if ( LOBYTE( wsaData.wVersion ) != 2 ||
|
|
|
|
|
HIBYTE( wsaData.wVersion ) != 2 ) {
|
|
|
|
|
/* could not find a usable WinSock DLL */
|
|
|
|
|
WSACleanup( );
|
|
|
|
|
return;
|
|
|
|
|
}
|
2002-04-24 09:58:26 -05:00
|
|
|
|
|
|
|
|
|
#endif
|
2005-09-12 22:20:41 -05:00
|
|
|
|
#ifdef H5_HAVE_GETHOSTNAME
|
2006-10-02 05:24:03 -05:00
|
|
|
|
if (gethostname(hostname, (size_t)80) < 0)
|
2015-06-10 12:57:32 -05:00
|
|
|
|
printf(" gethostname failed\n");
|
2002-04-22 12:12:14 -05:00
|
|
|
|
else
|
2015-06-10 12:57:32 -05:00
|
|
|
|
printf(" hostname=%s\n", hostname);
|
2005-09-19 15:32:18 -05:00
|
|
|
|
#else
|
|
|
|
|
printf(" gethostname not supported\n");
|
|
|
|
|
#endif
|
2011-09-06 11:50:32 -05:00
|
|
|
|
#ifdef H5_HAVE_WIN32_API
|
2002-04-24 09:58:26 -05:00
|
|
|
|
WSACleanup();
|
|
|
|
|
#endif
|
2002-04-22 12:12:14 -05:00
|
|
|
|
}
|
2007-02-26 11:55:45 -05:00
|
|
|
|
|
2002-05-21 13:49:44 -05:00
|
|
|
|
|
|
|
|
|
#ifdef H5_HAVE_PARALLEL
|
|
|
|
|
/*
|
|
|
|
|
* Function: h5_set_info_object
|
2002-05-31 13:43:22 -05:00
|
|
|
|
* Purpose: Process environment variables setting to set up MPI Info
|
|
|
|
|
* object.
|
2002-05-21 13:49:44 -05:00
|
|
|
|
* Return: 0 if all is fine; otherwise non-zero.
|
|
|
|
|
* Programmer: Albert Cheng, 2002/05/21.
|
|
|
|
|
* Modifications:
|
2002-05-31 13:43:22 -05:00
|
|
|
|
* Bill Wendling, 2002/05/31
|
|
|
|
|
* Modified so that the HDF5_MPI_INFO environment variable can
|
|
|
|
|
* be a semicolon separated list of "key=value" pairings. Most
|
|
|
|
|
* of the code is to remove any whitespaces which might be
|
|
|
|
|
* surrounding the "key=value" pairs.
|
2002-05-21 13:49:44 -05:00
|
|
|
|
*/
|
|
|
|
|
int
|
|
|
|
|
h5_set_info_object(void)
|
|
|
|
|
{
|
2011-09-06 11:50:32 -05:00
|
|
|
|
char *envp; /* environment pointer */
|
|
|
|
|
int ret_value=0;
|
2002-05-21 13:49:44 -05:00
|
|
|
|
|
|
|
|
|
/* handle any MPI INFO hints via $HDF5_MPI_INFO */
|
|
|
|
|
if ((envp = getenv("HDF5_MPI_INFO")) != NULL){
|
2002-05-31 13:43:22 -05:00
|
|
|
|
char *next, *valp;
|
2002-05-21 13:49:44 -05:00
|
|
|
|
|
2002-05-31 13:43:22 -05:00
|
|
|
|
valp = envp = next = HDstrdup(envp);
|
|
|
|
|
|
2012-08-08 18:01:20 -05:00
|
|
|
|
if (!valp) return 0;
|
|
|
|
|
|
2002-05-31 13:43:22 -05:00
|
|
|
|
/* create an INFO object if not created yet */
|
|
|
|
|
if (h5_io_info_g == MPI_INFO_NULL)
|
|
|
|
|
MPI_Info_create(&h5_io_info_g);
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
size_t len;
|
|
|
|
|
char *key_val, *endp, *namep;
|
|
|
|
|
|
|
|
|
|
if (*valp == ';')
|
|
|
|
|
valp++;
|
|
|
|
|
|
|
|
|
|
/* copy key/value pair into temporary buffer */
|
|
|
|
|
len = strcspn(valp, ";");
|
|
|
|
|
next = &valp[len];
|
2013-10-30 23:20:36 -05:00
|
|
|
|
key_val = (char *)HDcalloc(1, len + 1);
|
2002-05-31 13:43:22 -05:00
|
|
|
|
|
|
|
|
|
/* increment the next pointer past the terminating semicolon */
|
|
|
|
|
if (*next == ';')
|
|
|
|
|
++next;
|
|
|
|
|
|
|
|
|
|
namep = HDstrncpy(key_val, valp, len);
|
|
|
|
|
|
|
|
|
|
/* pass up any beginning whitespaces */
|
|
|
|
|
while (*namep && (*namep == ' ' || *namep == '\t'))
|
|
|
|
|
namep++;
|
|
|
|
|
|
2012-08-08 18:01:20 -05:00
|
|
|
|
if (!*namep) continue; /* was all white space, so move to next k/v pair */
|
|
|
|
|
|
2002-05-31 13:43:22 -05:00
|
|
|
|
/* eat up any ending white spaces */
|
2012-09-13 12:08:01 -05:00
|
|
|
|
endp = &namep[HDstrlen(namep) - 1];
|
2002-05-31 13:43:22 -05:00
|
|
|
|
|
|
|
|
|
while (endp && (*endp == ' ' || *endp == '\t'))
|
|
|
|
|
*endp-- = '\0';
|
|
|
|
|
|
|
|
|
|
/* find the '=' */
|
|
|
|
|
valp = HDstrchr(namep, '=');
|
|
|
|
|
|
|
|
|
|
if (valp != NULL) { /* it's a valid key/value pairing */
|
|
|
|
|
char *tmp_val = valp + 1;
|
|
|
|
|
|
|
|
|
|
/* change '=' to \0, move valp down one */
|
|
|
|
|
*valp-- = '\0';
|
|
|
|
|
|
|
|
|
|
/* eat up ending whitespace on the "key" part */
|
|
|
|
|
while (*valp == ' ' || *valp == '\t')
|
|
|
|
|
*valp-- = '\0';
|
|
|
|
|
|
|
|
|
|
valp = tmp_val;
|
|
|
|
|
|
|
|
|
|
/* eat up beginning whitespace on the "value" part */
|
|
|
|
|
while (*valp == ' ' || *valp == '\t')
|
|
|
|
|
*valp++ = '\0';
|
|
|
|
|
|
|
|
|
|
/* actually set the darned thing */
|
|
|
|
|
if (MPI_SUCCESS != MPI_Info_set(h5_io_info_g, namep, valp)) {
|
|
|
|
|
printf("MPI_Info_set failed\n");
|
|
|
|
|
ret_value = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
valp = next;
|
|
|
|
|
HDfree(key_val);
|
|
|
|
|
} while (next && *next);
|
|
|
|
|
|
|
|
|
|
HDfree(envp);
|
2002-05-21 13:49:44 -05:00
|
|
|
|
}
|
|
|
|
|
|
2002-05-31 13:43:22 -05:00
|
|
|
|
return ret_value;
|
2002-05-21 13:49:44 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Function: h5_dump_info_object
|
|
|
|
|
* Purpose: Display content of an MPI Info object
|
|
|
|
|
* Return: void
|
|
|
|
|
* Programmer: Albert Cheng 2002/05/21
|
|
|
|
|
* Modifications:
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
h5_dump_info_object(MPI_Info info)
|
|
|
|
|
{
|
2011-09-06 11:50:32 -05:00
|
|
|
|
char key[MPI_MAX_INFO_KEY+1];
|
|
|
|
|
char value[MPI_MAX_INFO_VAL+1];
|
|
|
|
|
int flag;
|
|
|
|
|
int i, nkeys;
|
2002-05-21 13:49:44 -05:00
|
|
|
|
|
2002-06-19 11:06:55 -05:00
|
|
|
|
printf("Dumping MPI Info Object(%d) (up to %d bytes per item):\n", (int)info,
|
2011-09-06 11:50:32 -05:00
|
|
|
|
MPI_MAX_INFO_VAL);
|
2002-05-21 13:49:44 -05:00
|
|
|
|
if (info==MPI_INFO_NULL){
|
2011-09-06 11:50:32 -05:00
|
|
|
|
printf("object is MPI_INFO_NULL\n");
|
2002-05-21 13:49:44 -05:00
|
|
|
|
}
|
|
|
|
|
else {
|
2011-09-06 11:50:32 -05:00
|
|
|
|
MPI_Info_get_nkeys(info, &nkeys);
|
|
|
|
|
printf("object has %d items\n", nkeys);
|
|
|
|
|
for (i=0; i<nkeys; i++){
|
|
|
|
|
MPI_Info_get_nthkey(info, i, key);
|
|
|
|
|
MPI_Info_get(info, key, MPI_MAX_INFO_VAL, value, &flag);
|
|
|
|
|
printf("%s=%s\n", key, value);
|
|
|
|
|
}
|
2002-05-21 13:49:44 -05:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-09-06 11:50:32 -05:00
|
|
|
|
#endif /* H5_HAVE_PARALLEL */
|
2003-06-18 15:43:39 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Function: h5_get_file_size
|
2003-06-18 15:43:39 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Purpose: Get the current size of a file (in bytes)
|
2003-06-18 15:43:39 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Return: Success: Size of file in bytes
|
|
|
|
|
* Failure: -1
|
2003-06-18 15:43:39 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Programmer: Quincey Koziol
|
2003-06-18 15:43:39 -05:00
|
|
|
|
* Saturday, March 22, 2003
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2006-04-20 01:09:51 -05:00
|
|
|
|
h5_stat_size_t
|
[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
2008-10-08 22:44:22 -05:00
|
|
|
|
h5_get_file_size(const char *filename, hid_t fapl)
|
2003-06-18 15:43:39 -05:00
|
|
|
|
{
|
[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
2008-10-08 22:44:22 -05:00
|
|
|
|
char temp[2048]; /* Temporary buffer for file names */
|
2011-09-06 11:50:32 -05:00
|
|
|
|
h5_stat_t sb; /* Structure for querying file info */
|
2014-10-28 11:59:36 -05:00
|
|
|
|
int j = 0;
|
[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
2008-10-08 22:44:22 -05:00
|
|
|
|
|
|
|
|
|
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 {
|
2011-09-06 11:50:32 -05:00
|
|
|
|
hid_t driver; /* VFD used for file */
|
2003-06-18 15:43:39 -05:00
|
|
|
|
|
[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
2008-10-08 22:44:22 -05:00
|
|
|
|
/* 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_WINDOWS
|
2010-01-29 23:29:13 -05:00
|
|
|
|
driver == H5FD_WINDOWS ||
|
[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
2008-10-08 22:44:22 -05:00
|
|
|
|
#endif /* H5_HAVE_WINDOWS */
|
|
|
|
|
#ifdef H5_HAVE_DIRECT
|
2010-01-29 23:29:13 -05:00
|
|
|
|
driver == H5FD_DIRECT ||
|
[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
2008-10-08 22:44:22 -05:00
|
|
|
|
#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 */
|
2014-10-28 11:59:36 -05:00
|
|
|
|
#ifdef H5_HAVE_PARALLEL
|
|
|
|
|
else if(driver == H5FD_MPIO) {
|
|
|
|
|
MPI_File fh; /* MPI file handle used to open the file and verify its size */
|
|
|
|
|
int mpi_ret;
|
|
|
|
|
MPI_Offset file_size;
|
|
|
|
|
|
|
|
|
|
mpi_ret = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, MPI_INFO_NULL, &fh);
|
|
|
|
|
if (mpi_ret != MPI_SUCCESS) return -1;
|
|
|
|
|
mpi_ret = MPI_File_get_size(fh, &file_size);
|
|
|
|
|
if (mpi_ret != MPI_SUCCESS) return -1;
|
|
|
|
|
mpi_ret = MPI_File_close(&fh);
|
|
|
|
|
if (mpi_ret != MPI_SUCCESS) return -1;
|
|
|
|
|
|
|
|
|
|
return file_size;
|
|
|
|
|
}
|
|
|
|
|
#endif /* H5_HAVE_PARALLEL */
|
[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
2008-10-08 22:44:22 -05:00
|
|
|
|
else if(driver == H5FD_FAMILY) {
|
|
|
|
|
h5_stat_size_t tot_size = 0;
|
|
|
|
|
|
|
|
|
|
/* Try all filenames possible, until we find one that's missing */
|
[svn-r15855] Purpose: Bring recent Windows-specific fixes from 1.8 branch to trunk
Description:
This checkin includes revisions 15845, 15846, and 15853 from the 1.8 branch. From the svn log:
r15845:
Purpose: Add Windows-specific version of HDftruncate
Description:
Windows doesn't include a version of the system call ftruncate. There is a similar call, _chsize_s, which performs very similarly. Thus, we map HDftruncate to _chsize_s in our Windows header file, H5win32defs.h.
r15846:
Purpose: Declare loop variable at beginning of function
Description:
On Windows, we were getting compile errors because h5test.c includes a function with variable declarations in the middle of the call. The Microsoft C compiler demands that all variables be declared at the top of the function. This checkin simply moves the declaration to the top to satisfy Visual Studio.
r15853:
Purpose: Decrease size of points array in links test
Description:
In the external_set_elink_fapl2 links test, there is a large array of points which declared on the stack for testing. Previously, the array was 1000 x 1000, which was too large for Visual Studio to handle. As a result, we were getting stack overflows during the test. We've reduced the number to 400, as this seems to be below the limit. The exact number of points in the array isn't important to the test.
Tested:
VS2005 on WinXP
2008-10-13 14:16:54 -05:00
|
|
|
|
for(j = 0; /*void*/; j++) {
|
[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
2008-10-08 22:44:22 -05:00
|
|
|
|
/* 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 */
|
2003-06-18 15:43:39 -05:00
|
|
|
|
|
2006-10-11 22:55:06 -05:00
|
|
|
|
return(-1);
|
2003-06-18 15:43:39 -05:00
|
|
|
|
} /* end get_file_size() */
|
|
|
|
|
|
2004-01-05 16:58:37 -05:00
|
|
|
|
/*
|
2004-01-06 12:53:13 -05:00
|
|
|
|
* This routine is designed to provide equivalent functionality to 'printf'
|
|
|
|
|
* and allow easy replacement for environments which don't have stdin/stdout
|
|
|
|
|
* available. (i.e. Windows & the Mac)
|
2004-01-05 16:58:37 -05:00
|
|
|
|
*/
|
2005-08-13 15:53:35 -05:00
|
|
|
|
int
|
2004-01-06 12:53:13 -05:00
|
|
|
|
print_func(const char *format, ...)
|
2004-01-05 16:58:37 -05:00
|
|
|
|
{
|
2011-09-06 11:50:32 -05:00
|
|
|
|
va_list arglist;
|
|
|
|
|
int ret_value;
|
2004-01-06 12:53:13 -05:00
|
|
|
|
|
2011-09-06 11:50:32 -05:00
|
|
|
|
va_start(arglist, format);
|
|
|
|
|
ret_value = vprintf(format, arglist);
|
|
|
|
|
va_end(arglist);
|
|
|
|
|
return ret_value;
|
2004-01-05 16:58:37 -05:00
|
|
|
|
}
|
|
|
|
|
|
2005-08-13 15:53:35 -05:00
|
|
|
|
#ifdef H5_HAVE_FILTER_SZIP
|
2004-11-02 14:12:06 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Function: h5_szip_can_encode
|
2004-11-02 14:12:06 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Purpose: Retrieve the filter config flags for szip, tell if
|
2004-11-02 14:12:06 -05:00
|
|
|
|
* encoder is available.
|
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Return: 1: decode+encode is enabled
|
|
|
|
|
* 0: only decode is enabled
|
2004-11-02 14:12:06 -05:00
|
|
|
|
* -1: other
|
|
|
|
|
*
|
2005-08-13 15:53:35 -05:00
|
|
|
|
* Programmer:
|
2004-11-02 14:12:06 -05:00
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2005-08-13 15:53:35 -05:00
|
|
|
|
int h5_szip_can_encode(void )
|
2004-11-02 14:12:06 -05:00
|
|
|
|
{
|
2009-07-29 20:59:24 -05:00
|
|
|
|
unsigned int filter_config_flags;
|
|
|
|
|
|
|
|
|
|
H5Zget_filter_info(H5Z_FILTER_SZIP, &filter_config_flags);
|
|
|
|
|
if ((filter_config_flags &
|
|
|
|
|
(H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) == 0) {
|
|
|
|
|
/* filter present but neither encode nor decode is supported (???) */
|
|
|
|
|
return -1;
|
|
|
|
|
} else if ((filter_config_flags &
|
|
|
|
|
(H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
|
|
|
|
|
H5Z_FILTER_CONFIG_DECODE_ENABLED) {
|
|
|
|
|
/* decoder only: read but not write */
|
|
|
|
|
return 0;
|
|
|
|
|
} else if ((filter_config_flags &
|
|
|
|
|
(H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
|
|
|
|
|
H5Z_FILTER_CONFIG_ENCODE_ENABLED) {
|
|
|
|
|
/* encoder only: write but not read (???) */
|
|
|
|
|
return -1;
|
|
|
|
|
} else if ((filter_config_flags &
|
|
|
|
|
(H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
|
|
|
|
|
(H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2005-01-06 12:20:14 -05:00
|
|
|
|
return(-1);
|
2004-11-02 14:12:06 -05:00
|
|
|
|
}
|
|
|
|
|
#endif /* H5_HAVE_FILTER_SZIP */
|
2005-04-05 16:42:02 -05:00
|
|
|
|
|
2005-05-26 18:27:24 -05:00
|
|
|
|
#ifdef H5_HAVE_PARALLEL
|
2005-04-05 16:42:02 -05:00
|
|
|
|
/*-------------------------------------------------------------------------
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Function: getenv_all
|
2005-04-05 16:42:02 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Purpose: Used to get the environment that the root MPI task has.
|
|
|
|
|
* name specifies which environment variable to look for
|
|
|
|
|
* val is the string to which the value of that environment
|
|
|
|
|
* variable will be copied.
|
2005-04-05 16:42:02 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* NOTE: The pointer returned by this function is only
|
|
|
|
|
* valid until the next call to getenv_all and the data
|
|
|
|
|
* stored there must be copied somewhere else before any
|
|
|
|
|
* further calls to getenv_all take place.
|
2005-04-20 16:48:31 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Return: pointer to a string containing the value of the environment variable
|
|
|
|
|
* NULL if the varialbe doesn't exist in task 'root's environment.
|
2005-04-05 16:42:02 -05:00
|
|
|
|
*
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Programmer: Leon Arber
|
2005-04-05 16:42:02 -05:00
|
|
|
|
* 4/4/05
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
2011-09-06 11:50:32 -05:00
|
|
|
|
* Use original getenv if MPI is not initialized. This happens
|
|
|
|
|
* one uses the PHDF5 library to build a serial nature code.
|
|
|
|
|
* Albert 2006/04/07
|
2005-04-05 16:42:02 -05:00
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2009-03-10 14:00:39 -05:00
|
|
|
|
char *
|
|
|
|
|
getenv_all(MPI_Comm comm, int root, const char* name)
|
2005-04-05 16:42:02 -05:00
|
|
|
|
{
|
2015-06-10 12:57:32 -05:00
|
|
|
|
int mpi_size, mpi_rank, mpi_initialized, mpi_finalized;
|
2006-04-07 10:00:47 -05:00
|
|
|
|
int len;
|
2005-04-05 16:42:02 -05:00
|
|
|
|
static char* env = NULL;
|
2005-08-13 15:53:35 -05:00
|
|
|
|
|
2005-04-05 16:42:02 -05:00
|
|
|
|
assert(name);
|
|
|
|
|
|
2006-04-07 10:00:47 -05:00
|
|
|
|
MPI_Initialized(&mpi_initialized);
|
2015-06-10 12:57:32 -05:00
|
|
|
|
MPI_Finalized(&mpi_finalized);
|
|
|
|
|
|
|
|
|
|
if(mpi_initialized && !mpi_finalized) {
|
|
|
|
|
MPI_Comm_rank(comm, &mpi_rank);
|
|
|
|
|
MPI_Comm_size(comm, &mpi_size);
|
|
|
|
|
assert(root < mpi_size);
|
|
|
|
|
|
|
|
|
|
/* The root task does the getenv call
|
|
|
|
|
* and sends the result to the other tasks */
|
|
|
|
|
if(mpi_rank == root) {
|
|
|
|
|
env = HDgetenv(name);
|
|
|
|
|
if(env) {
|
|
|
|
|
len = (int)HDstrlen(env);
|
|
|
|
|
MPI_Bcast(&len, 1, MPI_INT, root, comm);
|
|
|
|
|
MPI_Bcast(env, len, MPI_CHAR, root, comm);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* len -1 indicates that the variable was not in the environment */
|
|
|
|
|
len = -1;
|
|
|
|
|
MPI_Bcast(&len, 1, MPI_INT, root, comm);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
MPI_Bcast(&len, 1, MPI_INT, root, comm);
|
|
|
|
|
if(len >= 0) {
|
|
|
|
|
if(env == NULL)
|
|
|
|
|
env = (char*) HDmalloc((size_t)len+1);
|
|
|
|
|
else if(HDstrlen(env) < (size_t)len)
|
|
|
|
|
env = (char*) HDrealloc(env, (size_t)len+1);
|
|
|
|
|
|
|
|
|
|
MPI_Bcast(env, len, MPI_CHAR, root, comm);
|
|
|
|
|
env[len] = '\0';
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if(env)
|
|
|
|
|
HDfree(env);
|
|
|
|
|
env = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-04-07 10:00:47 -05:00
|
|
|
|
#ifndef NDEBUG
|
2015-06-10 12:57:32 -05:00
|
|
|
|
MPI_Barrier(comm);
|
2006-04-07 10:00:47 -05:00
|
|
|
|
#endif
|
2015-06-10 12:57:32 -05:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* use original getenv */
|
|
|
|
|
if(env)
|
|
|
|
|
HDfree(env);
|
|
|
|
|
env = HDgetenv(name);
|
|
|
|
|
} /* end if */
|
2005-04-05 16:42:02 -05:00
|
|
|
|
|
|
|
|
|
return env;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-10-20 10:08:56 -05:00
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_make_local_copy
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Make copy of file. Some tests write to data files under that
|
|
|
|
|
* are under version control. Those tests should make a copy of
|
2010-01-29 23:29:13 -05:00
|
|
|
|
* the versioned file and write to the copy. This function
|
2009-10-20 10:08:56 -05:00
|
|
|
|
* prepends srcdir to the name of the file to be copied and uses
|
2010-01-29 23:29:13 -05:00
|
|
|
|
* the name of the copy as is.
|
2009-10-20 10:08:56 -05:00
|
|
|
|
*
|
|
|
|
|
* Return: Success: 0
|
|
|
|
|
*
|
|
|
|
|
* Failure: -1
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Larry Knox
|
|
|
|
|
* Monday, October 13, 2009
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2014-07-30 15:55:14 -05:00
|
|
|
|
int
|
2011-10-14 08:28:23 -05:00
|
|
|
|
h5_make_local_copy(const char *origfilename, const char *local_copy_name)
|
2009-10-20 10:08:56 -05:00
|
|
|
|
{
|
|
|
|
|
int fd_old = (-1), fd_new = (-1); /* File descriptors for copying data */
|
|
|
|
|
ssize_t nread; /* Number of bytes read in */
|
2016-11-22 20:55:03 -05:00
|
|
|
|
void *buf = NULL; /* Buffer for copying data */
|
|
|
|
|
const char *filename = H5_get_srcdir_filename(origfilename); /* Get the test file name to copy */
|
2009-10-20 10:08:56 -05:00
|
|
|
|
|
2016-09-27 10:29:16 -07:00
|
|
|
|
/* Allocate copy buffer */
|
2016-11-22 20:55:03 -05:00
|
|
|
|
if(NULL == (buf = HDcalloc((size_t)1, (size_t)READ_BUF_SIZE)))
|
|
|
|
|
goto error;
|
2016-09-27 10:29:16 -07:00
|
|
|
|
|
2009-10-20 10:08:56 -05:00
|
|
|
|
/* Copy old file into temporary file */
|
2017-04-28 18:13:22 -04:00
|
|
|
|
if((fd_old = HDopen(filename, O_RDONLY)) < 0)
|
2016-11-22 20:55:03 -05:00
|
|
|
|
goto error;
|
2017-04-28 18:13:22 -04:00
|
|
|
|
if((fd_new = HDopen(local_copy_name, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0)
|
2016-11-22 20:55:03 -05:00
|
|
|
|
goto error;
|
2009-10-20 10:08:56 -05:00
|
|
|
|
|
|
|
|
|
/* Copy data */
|
|
|
|
|
while((nread = HDread(fd_old, buf, (size_t)READ_BUF_SIZE)) > 0)
|
2016-03-23 22:58:43 -05:00
|
|
|
|
if(HDwrite(fd_new, buf, (size_t)nread) < 0)
|
2016-11-22 20:55:03 -05:00
|
|
|
|
goto error;
|
2016-09-27 10:29:16 -07:00
|
|
|
|
|
2016-11-22 20:55:03 -05:00
|
|
|
|
/* Close files */
|
|
|
|
|
if(HDclose(fd_old) < 0)
|
|
|
|
|
goto error;
|
|
|
|
|
if(HDclose(fd_new) < 0)
|
|
|
|
|
goto error;
|
|
|
|
|
|
2016-09-27 10:29:16 -07:00
|
|
|
|
/* Release memory */
|
|
|
|
|
HDfree(buf);
|
2009-10-20 10:08:56 -05:00
|
|
|
|
|
2010-01-29 23:29:13 -05:00
|
|
|
|
return 0;
|
2016-11-22 20:55:03 -05:00
|
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
/* ignore return values since we're already noted the problem */
|
|
|
|
|
if(fd_old > 0)
|
|
|
|
|
HDclose(fd_old);
|
|
|
|
|
if(fd_new > 0)
|
|
|
|
|
HDclose(fd_new);
|
|
|
|
|
HDfree(buf);
|
|
|
|
|
return -1;
|
2016-03-23 22:58:43 -05:00
|
|
|
|
} /* end h5_make_local_copy() */
|
2011-04-15 17:05:23 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_verify_cached_stabs_cb
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Callback function for h5_verify_cached_stabs.
|
|
|
|
|
*
|
2018-09-20 10:40:51 -07:00
|
|
|
|
* Return: SUCCEED/FAIL
|
2011-04-15 17:05:23 -05:00
|
|
|
|
*
|
|
|
|
|
* Programmer: Neil Fortner
|
|
|
|
|
* Tuesday, April 12, 2011
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static herr_t
|
2015-06-01 14:38:09 -05:00
|
|
|
|
h5_verify_cached_stabs_cb(hid_t oid, const char H5_ATTR_UNUSED *name,
|
|
|
|
|
const H5O_info_t *oinfo, void H5_ATTR_UNUSED *udata)
|
2011-04-15 17:05:23 -05:00
|
|
|
|
{
|
|
|
|
|
if(oinfo->type == H5O_TYPE_GROUP)
|
2018-09-20 10:40:51 -07:00
|
|
|
|
return H5G__verify_cached_stabs_test(oid);
|
2011-04-15 17:05:23 -05:00
|
|
|
|
else
|
2018-09-20 10:40:51 -07:00
|
|
|
|
return SUCCEED;
|
2011-04-15 17:05:23 -05:00
|
|
|
|
} /* end h5_verify_cached_stabs_cb() */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_verify_cached_stabs
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Verify that all groups in every file in base_name have
|
|
|
|
|
* their symbol table information cached (if present, and if
|
|
|
|
|
* the parent group also uses a symbol table). Does not
|
|
|
|
|
* check that the root group's symbol table information is
|
|
|
|
|
* cached in the superblock.
|
|
|
|
|
*
|
|
|
|
|
* Return: Success: 0
|
|
|
|
|
*
|
|
|
|
|
* Failure: -1
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Neil Fortner
|
|
|
|
|
* Tuesday, April 12, 2011
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
herr_t
|
|
|
|
|
h5_verify_cached_stabs(const char *base_name[], hid_t fapl)
|
|
|
|
|
{
|
|
|
|
|
hid_t file = -1;
|
|
|
|
|
char filename[1024];
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
|
|
while(base_name[i]) {
|
|
|
|
|
if (h5_fixname(base_name[i], fapl, filename, sizeof(filename)) == NULL)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
|
file = H5Fopen(filename, H5F_ACC_RDONLY, fapl);
|
|
|
|
|
} H5E_END_TRY
|
|
|
|
|
if(file < 0) {
|
|
|
|
|
i++;
|
|
|
|
|
continue;
|
|
|
|
|
} /* end if */
|
|
|
|
|
|
2018-04-24 15:10:13 -05:00
|
|
|
|
if(H5Ovisit2(file, H5_INDEX_NAME, H5_ITER_NATIVE,
|
2018-05-14 12:26:48 -05:00
|
|
|
|
h5_verify_cached_stabs_cb, NULL, H5O_INFO_BASIC) < 0)
|
2011-04-15 17:05:23 -05:00
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
|
|
if(H5Fclose(file) < 0)
|
|
|
|
|
goto error;
|
|
|
|
|
file = -1;
|
|
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
} /* end while */
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
|
H5Fclose(file);
|
|
|
|
|
} H5E_END_TRY;
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-19 20:44:54 -08:00
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_send_message
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Sends the specified signal.
|
|
|
|
|
*
|
|
|
|
|
* In terms of this test framework, a signal consists of a file
|
|
|
|
|
* on disk. Since there are multiple processes that need to
|
|
|
|
|
* communicate with each other, they do so by writing and
|
|
|
|
|
* reading signal files on disk, the names and contents of
|
|
|
|
|
* which are used to inform a process about when it can
|
|
|
|
|
* proceed and what it should do next.
|
|
|
|
|
*
|
|
|
|
|
* This function writes a signal file. The first argument is
|
|
|
|
|
* the name of the signal file, and the second and third
|
|
|
|
|
* arguments are the contents of the first two lines of the
|
|
|
|
|
* signal file. The last two arguments may be NULL.
|
|
|
|
|
*
|
|
|
|
|
* Return: void
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Mike McGreevy
|
|
|
|
|
* August 18, 2010
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
h5_send_message(const char *send, const char *arg1, const char *arg2)
|
|
|
|
|
{
|
2017-02-08 14:49:25 -05:00
|
|
|
|
FILE *signalfile = NULL;
|
2016-12-19 20:44:54 -08:00
|
|
|
|
|
|
|
|
|
/* Create signal file (which will send signal to some other process) */
|
|
|
|
|
signalfile = HDfopen(TMP_SIGNAL_FILE, "w+");
|
|
|
|
|
|
|
|
|
|
/* Write messages to signal file, if provided */
|
|
|
|
|
if(arg2 != NULL) {
|
|
|
|
|
HDassert(arg1);
|
|
|
|
|
HDfprintf(signalfile, "%s\n%s\n", arg1, arg2);
|
|
|
|
|
} /* end if */
|
|
|
|
|
else if(arg1 != NULL) {
|
|
|
|
|
HDassert(arg2 == NULL);
|
|
|
|
|
HDfprintf(signalfile, "%s\n", arg1);
|
|
|
|
|
} /* end if */
|
|
|
|
|
else {
|
|
|
|
|
HDassert(arg1 == NULL);
|
|
|
|
|
HDassert(arg2 == NULL);
|
|
|
|
|
}/* end else */
|
|
|
|
|
|
|
|
|
|
HDfclose(signalfile);
|
|
|
|
|
|
|
|
|
|
HDrename(TMP_SIGNAL_FILE, send);
|
|
|
|
|
} /* h5_send_message() */
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_wait_message
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Waits for the specified signal.
|
|
|
|
|
*
|
|
|
|
|
* In terms of this test framework, a signal consists of a file
|
|
|
|
|
* on disk. Since there are multiple processes that need to
|
|
|
|
|
* communicate with each other, they do so by writing and
|
|
|
|
|
* reading signal files on disk, the names and contents of
|
|
|
|
|
* which are used to inform a process about when it can
|
|
|
|
|
* proceed and what it should do next.
|
|
|
|
|
*
|
|
|
|
|
* This function continuously attempts to read the specified
|
|
|
|
|
* signal file from disk, and only continues once it has
|
|
|
|
|
* successfully done so (i.e., only after another process has
|
|
|
|
|
* called the "h5_send_message" function to write the signal file).
|
|
|
|
|
* This functon will then immediately remove the file (i.e.,
|
|
|
|
|
* to indicate that it has been received and can be reused),
|
|
|
|
|
* and then exits, allowing the calling function to continue.
|
|
|
|
|
*
|
|
|
|
|
* Return: void
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Mike McGreevy
|
|
|
|
|
* August 18, 2010
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
herr_t
|
|
|
|
|
h5_wait_message(const char *waitfor)
|
|
|
|
|
{
|
|
|
|
|
FILE *returnfile;
|
|
|
|
|
time_t t0,t1;
|
|
|
|
|
|
|
|
|
|
/* Start timer. If this function runs for too long (i.e.,
|
|
|
|
|
expected signal is never received), it will
|
|
|
|
|
return failure */
|
|
|
|
|
HDtime(&t0);
|
|
|
|
|
|
|
|
|
|
/* Wait for return signal from some other process */
|
|
|
|
|
while ((returnfile = HDfopen(waitfor, "r")) == NULL) {
|
|
|
|
|
|
|
|
|
|
/* make note of current time. */
|
|
|
|
|
HDtime(&t1);
|
|
|
|
|
|
|
|
|
|
/* If we've been waiting for a signal for too long, then
|
|
|
|
|
it was likely never sent and we should fail rather
|
|
|
|
|
than loop infinitely */
|
|
|
|
|
if(HDdifftime(t1, t0) > MESSAGE_TIMEOUT) {
|
|
|
|
|
HDfprintf(stdout, "Error communicating between processes. Make sure test script is running.\n");
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
} /* end if */
|
|
|
|
|
} /* end while */
|
|
|
|
|
|
|
|
|
|
HDfclose(returnfile);
|
|
|
|
|
HDunlink(waitfor);
|
|
|
|
|
|
|
|
|
|
return SUCCEED;
|
|
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
return FAIL;
|
|
|
|
|
} /* h5_wait_message() */
|
|
|
|
|
|
2017-12-05 10:41:54 -08:00
|
|
|
|
/* Functions for the dummy VFD class (see below).
|
|
|
|
|
*
|
|
|
|
|
* Useful for testing things like ID handling where we shouldn't mess with the
|
|
|
|
|
* real VFDs.
|
|
|
|
|
*/
|
|
|
|
|
static H5FD_t *dummy_vfd_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr);
|
|
|
|
|
static H5FD_t *dummy_vfd_open(const char H5_ATTR_UNUSED *name, unsigned H5_ATTR_UNUSED flags, hid_t H5_ATTR_UNUSED fapl_id, haddr_t H5_ATTR_UNUSED maxaddr) { return NULL; }
|
|
|
|
|
|
|
|
|
|
static herr_t dummy_vfd_close(H5FD_t *_file);
|
|
|
|
|
static herr_t dummy_vfd_close(H5FD_t H5_ATTR_UNUSED *_file) { return FAIL; }
|
|
|
|
|
|
|
|
|
|
static haddr_t dummy_vfd_get_eoa(const H5FD_t *file, H5FD_mem_t type);
|
|
|
|
|
static haddr_t dummy_vfd_get_eoa(const H5FD_t H5_ATTR_UNUSED *file, H5FD_mem_t H5_ATTR_UNUSED type) { return HADDR_UNDEF; }
|
|
|
|
|
|
|
|
|
|
static herr_t dummy_vfd_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr);
|
|
|
|
|
static herr_t dummy_vfd_set_eoa(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t H5_ATTR_UNUSED addr) { return FAIL; }
|
|
|
|
|
|
|
|
|
|
static haddr_t dummy_vfd_get_eof(const H5FD_t *file, H5FD_mem_t type);
|
|
|
|
|
static haddr_t dummy_vfd_get_eof(const H5FD_t H5_ATTR_UNUSED *file, H5FD_mem_t H5_ATTR_UNUSED type) { return HADDR_UNDEF; }
|
|
|
|
|
|
|
|
|
|
static herr_t dummy_vfd_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, void *buf);
|
|
|
|
|
static herr_t dummy_vfd_read(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED fapl_id, haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED size, void H5_ATTR_UNUSED *buf) { return FAIL; }
|
|
|
|
|
|
|
|
|
|
static herr_t dummy_vfd_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, const void *buf);
|
|
|
|
|
static herr_t dummy_vfd_write(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED fapl_id, haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED size, const void H5_ATTR_UNUSED *buf) { return FAIL; }
|
|
|
|
|
|
|
|
|
|
|
2017-06-30 18:35:09 -07:00
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_get_dummy_vfd_class()
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Returns a disposable, generally non-functional,
|
|
|
|
|
* VFD class struct.
|
|
|
|
|
*
|
|
|
|
|
* In some of the test code, we need a disposable VFD but
|
|
|
|
|
* we don't want to mess with the real VFDs and we also
|
|
|
|
|
* don't have access to the internals of the real VFDs (which
|
|
|
|
|
* use static globals and functions) to easily duplicate
|
|
|
|
|
* them (e.g.: for testing VFD ID handling).
|
|
|
|
|
*
|
|
|
|
|
* This API call will return a pointer to a VFD class that
|
|
|
|
|
* can be used to construct a test VFD using H5FDregister().
|
|
|
|
|
*
|
|
|
|
|
* Return: Success: A pointer to a VFD class struct
|
|
|
|
|
* Failure: NULL
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
H5FD_class_t *
|
|
|
|
|
h5_get_dummy_vfd_class(void)
|
|
|
|
|
{
|
2017-12-05 10:41:54 -08:00
|
|
|
|
H5FD_class_t *vfd_class = NULL; /* Dummy VFD that will be returned */
|
2017-06-30 18:35:09 -07:00
|
|
|
|
|
2017-12-05 10:41:54 -08:00
|
|
|
|
/* Create the class and initialize everything to zero/NULL */
|
|
|
|
|
if(NULL == (vfd_class = (H5FD_class_t *)HDcalloc((size_t)1, sizeof(H5FD_class_t))))
|
2017-06-30 18:35:09 -07:00
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
2017-12-05 10:41:54 -08:00
|
|
|
|
/* Fill in the minimum parameters to make a VFD that
|
|
|
|
|
* can be registered.
|
|
|
|
|
*/
|
|
|
|
|
vfd_class->name = "dummy";
|
|
|
|
|
vfd_class->maxaddr = 1;
|
|
|
|
|
vfd_class->open = dummy_vfd_open;
|
|
|
|
|
vfd_class->close = dummy_vfd_close;
|
|
|
|
|
vfd_class->get_eoa = dummy_vfd_get_eoa;
|
|
|
|
|
vfd_class->set_eoa = dummy_vfd_set_eoa;
|
|
|
|
|
vfd_class->get_eof = dummy_vfd_get_eof;
|
|
|
|
|
vfd_class->read = dummy_vfd_read;
|
|
|
|
|
vfd_class->write = dummy_vfd_write;
|
2017-06-30 18:35:09 -07:00
|
|
|
|
|
|
|
|
|
return vfd_class;
|
|
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
if(vfd_class)
|
|
|
|
|
HDfree(vfd_class);
|
|
|
|
|
return NULL;
|
|
|
|
|
} /* h5_get_dummy_vfd_class */
|
|
|
|
|
|
2018-10-10 08:10:15 -07:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_get_dummy_vol_class()
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Returns a disposable, generally non-functional,
|
|
|
|
|
* VOL class struct.
|
|
|
|
|
*
|
2018-11-30 14:12:32 -06:00
|
|
|
|
* In some of the test code, we need a disposable VOL connector
|
2018-10-10 08:10:15 -07:00
|
|
|
|
* but we don't want to mess with the real VFDs and we also
|
2018-11-30 14:12:32 -06:00
|
|
|
|
* don't have access to the internals of the real VOL connectors
|
2018-10-10 08:10:15 -07:00
|
|
|
|
* (which use static globals and functions) to easily duplicate
|
2018-11-30 14:12:32 -06:00
|
|
|
|
* them (e.g.: for testing VOL connector ID handling).
|
2018-10-10 08:10:15 -07:00
|
|
|
|
*
|
|
|
|
|
* This API call will return a pointer to a VOL class that
|
2018-11-30 14:12:32 -06:00
|
|
|
|
* can be used to construct a test VOL using H5VLregister_connector().
|
2018-10-10 08:10:15 -07:00
|
|
|
|
*
|
|
|
|
|
* Return: Success: A pointer to a VOL class struct
|
|
|
|
|
* Failure: NULL
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
H5VL_class_t *
|
|
|
|
|
h5_get_dummy_vol_class(void)
|
|
|
|
|
{
|
|
|
|
|
H5VL_class_t *vol_class = NULL; /* Dummy VOL class that will be returned */
|
|
|
|
|
|
|
|
|
|
/* Create the class and initialize everything to zero/NULL */
|
|
|
|
|
if(NULL == (vol_class = (H5VL_class_t *)HDcalloc((size_t)1, sizeof(H5VL_class_t))))
|
|
|
|
|
TEST_ERROR;
|
|
|
|
|
|
2018-11-30 14:12:32 -06:00
|
|
|
|
/* Fill in the minimum parameters to make a VOL connector class that
|
2018-10-10 08:10:15 -07:00
|
|
|
|
* can be registered.
|
|
|
|
|
*/
|
|
|
|
|
vol_class->name = "dummy";
|
|
|
|
|
|
|
|
|
|
return vol_class;
|
|
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
if(vol_class)
|
|
|
|
|
HDfree(vol_class);
|
|
|
|
|
return NULL;
|
|
|
|
|
} /* h5_get_dummy_vol_class */
|
|
|
|
|
|