2003-04-01 01:59:04 +08:00
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
|
* Copyright by The HDF Group. *
|
2003-04-01 01:59:04 +08: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 *
|
|
|
|
|
* the files COPYING and Copyright.html. COPYING can be found at the root *
|
|
|
|
|
* of the source code distribution tree; Copyright.html can be found at the *
|
|
|
|
|
* root level of an installed copy of the electronic HDF5 document set and *
|
|
|
|
|
* is linked from the top-level documents page. It can also be found at *
|
2007-02-07 22:56:24 +08:00
|
|
|
|
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
|
|
|
|
|
* access to either file, you may request a copy from help@hdfgroup.org. *
|
2003-04-01 01:59:04 +08:00
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
|
1998-11-21 11:36:51 +08:00
|
|
|
|
/*
|
|
|
|
|
* Programmer: Robb Matzke <matzke@llnl.gov>
|
|
|
|
|
* Thursday, November 19, 1998
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Provides support functions for most of the hdf5 tests cases.
|
2005-08-14 04:53:35 +08:00
|
|
|
|
*
|
1998-11-21 11:36:51 +08:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#undef NDEBUG /*override -DNDEBUG */
|
2001-06-19 04:22:10 +08:00
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/stat.h>
|
2002-12-02 21:15:36 +08:00
|
|
|
|
#include "h5test.h"
|
2001-04-04 02:09:16 +08:00
|
|
|
|
|
2007-05-18 23:14:43 +08:00
|
|
|
|
#ifdef _WIN32
|
2001-01-05 07:52:03 +08:00
|
|
|
|
#include <process.h>
|
2001-06-22 04:06:32 +08:00
|
|
|
|
#include <direct.h>
|
2002-04-24 22:58:26 +08:00
|
|
|
|
#include <winsock.h>
|
2007-05-18 23:14:43 +08:00
|
|
|
|
#endif /* _WIN32 */
|
1998-11-21 11:36:51 +08: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.
|
|
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
* h5_fileaccess() for details.
|
|
|
|
|
*
|
2000-01-26 12:20:36 +08: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.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
* 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-21 11:36:51 +08:00
|
|
|
|
*/
|
2000-01-26 12:20:36 +08:00
|
|
|
|
#ifndef HDF5_PARAPREFIX
|
|
|
|
|
#ifdef __PUMAGON__
|
|
|
|
|
/* For the PFS of TFLOPS */
|
2000-10-10 12:35:39 +08:00
|
|
|
|
#define HDF5_PARAPREFIX "pfs:/pfs_grande/multi/tmp_1"
|
2000-01-26 12:20:36 +08:00
|
|
|
|
#else
|
2003-05-09 02:50:14 +08:00
|
|
|
|
#define HDF5_PARAPREFIX ""
|
2000-01-26 12:20:36 +08:00
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
char *paraprefix = NULL; /* for command line option para-prefix */
|
2002-05-22 02:49:44 +08:00
|
|
|
|
#ifdef H5_HAVE_PARALLEL
|
2002-05-30 02:40:29 +08:00
|
|
|
|
MPI_Info h5_io_info_g=MPI_INFO_NULL;/* MPI INFO object for IO */
|
2002-05-22 02:49:44 +08:00
|
|
|
|
#endif
|
1998-11-21 11:36:51 +08:00
|
|
|
|
|
1999-08-18 03:12:59 +08:00
|
|
|
|
/*
|
|
|
|
|
* These are the letters that are appended to the file name when generating
|
|
|
|
|
* names for the split and multi drivers. They are:
|
|
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
*/
|
2006-12-09 03:44:20 +08:00
|
|
|
|
static const char *multi_letters = "msbrglo";
|
1998-11-21 11:36:51 +08:00
|
|
|
|
|
2007-08-24 04:25:25 +08:00
|
|
|
|
static herr_t h5_errors(hid_t estack, void *client_data);
|
2003-08-09 03:03:43 +08:00
|
|
|
|
|
1998-11-21 11:36:51 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_errors
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Displays the error stack after printing "*FAILED*".
|
|
|
|
|
*
|
|
|
|
|
* Return: Success: 0
|
|
|
|
|
*
|
|
|
|
|
* Failure: -1
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Robb Matzke
|
|
|
|
|
* Wednesday, March 4, 1998
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2003-08-09 03:03:43 +08:00
|
|
|
|
static herr_t
|
2007-08-24 04:25:25 +08:00
|
|
|
|
h5_errors(hid_t estack, void UNUSED *client_data)
|
1998-11-21 11:36:51 +08:00
|
|
|
|
{
|
2001-01-26 01:03:29 +08:00
|
|
|
|
H5_FAILED();
|
2007-08-24 04:25:25 +08:00
|
|
|
|
H5Eprint2(estack, stdout);
|
1998-11-21 11:36:51 +08:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_cleanup
|
|
|
|
|
*
|
2000-09-10 08:08:27 +08:00
|
|
|
|
* Purpose: Cleanup temporary test files.
|
|
|
|
|
* base_name contains the list of test file names.
|
|
|
|
|
* The file access property list is also closed.
|
1998-11-21 11:36:51 +08:00
|
|
|
|
*
|
1998-11-25 22:58:22 +08:00
|
|
|
|
* Return: Non-zero if cleanup actions were performed; zero otherwise.
|
1998-11-21 11:36:51 +08:00
|
|
|
|
*
|
|
|
|
|
* Programmer: Albert Cheng
|
|
|
|
|
* May 28, 1998
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
2000-09-10 08:08:27 +08:00
|
|
|
|
* Albert Cheng, 2000-09-09
|
|
|
|
|
* Added the explicite base_name argument to replace the
|
|
|
|
|
* global variable FILENAME.
|
1998-11-21 11:36:51 +08:00
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
1998-11-25 22:58:22 +08:00
|
|
|
|
int
|
2000-09-10 08:08:27 +08:00
|
|
|
|
h5_cleanup(const char *base_name[], hid_t fapl)
|
1998-11-21 11:36:51 +08:00
|
|
|
|
{
|
|
|
|
|
char filename[1024];
|
|
|
|
|
char temp[2048];
|
|
|
|
|
int i, j;
|
1998-11-25 22:58:22 +08:00
|
|
|
|
int retval=0;
|
1999-08-11 04:21:32 +08:00
|
|
|
|
hid_t driver;
|
1998-11-21 11:36:51 +08:00
|
|
|
|
|
2006-01-09 13:14:54 +08:00
|
|
|
|
if (GetTestCleanup()){
|
2001-05-23 07:27:38 +08:00
|
|
|
|
for (i = 0; base_name[i]; i++) {
|
|
|
|
|
if (h5_fixname(base_name[i], fapl, filename, sizeof(filename)) == NULL)
|
1998-11-21 11:36:51 +08:00
|
|
|
|
continue;
|
|
|
|
|
|
2003-10-23 05:16:46 +08:00
|
|
|
|
driver = H5Pget_driver(fapl);
|
2001-05-23 07:27:38 +08:00
|
|
|
|
|
|
|
|
|
if (driver == H5FD_FAMILY) {
|
|
|
|
|
for (j = 0; /*void*/; j++) {
|
1998-11-24 23:53:55 +08:00
|
|
|
|
HDsnprintf(temp, sizeof temp, filename, j);
|
2001-05-23 07:27:38 +08:00
|
|
|
|
|
2001-06-19 04:22:10 +08:00
|
|
|
|
if (HDaccess(temp, F_OK) < 0)
|
2001-05-23 07:27:38 +08:00
|
|
|
|
break;
|
|
|
|
|
|
2001-06-19 04:22:10 +08:00
|
|
|
|
HDremove(temp);
|
1998-11-21 11:36:51 +08:00
|
|
|
|
}
|
2001-05-23 07:27:38 +08:00
|
|
|
|
} else if (driver == H5FD_CORE) {
|
2002-10-15 03:48:01 +08:00
|
|
|
|
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);
|
|
|
|
|
|
2001-05-23 07:27:38 +08:00
|
|
|
|
} else if (driver == H5FD_MULTI) {
|
1999-08-18 03:12:59 +08:00
|
|
|
|
H5FD_mem_t mt;
|
2004-01-10 09:41:13 +08:00
|
|
|
|
assert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES);
|
2001-05-23 07:27:38 +08:00
|
|
|
|
|
2002-05-21 02:43:31 +08:00
|
|
|
|
for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) {
|
1999-08-18 03:12:59 +08:00
|
|
|
|
HDsnprintf(temp, sizeof temp, "%s-%c.h5",
|
|
|
|
|
filename, multi_letters[mt]);
|
2001-06-19 04:22:10 +08:00
|
|
|
|
HDremove(temp); /*don't care if it fails*/
|
1999-08-18 03:12:59 +08:00
|
|
|
|
}
|
1999-08-11 04:21:32 +08:00
|
|
|
|
} else {
|
2001-06-19 04:22:10 +08:00
|
|
|
|
HDremove(filename);
|
1998-11-21 11:36:51 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2001-05-23 07:27:38 +08:00
|
|
|
|
|
|
|
|
|
retval = 1;
|
1998-11-21 11:36:51 +08:00
|
|
|
|
}
|
2001-05-23 07:27:38 +08:00
|
|
|
|
|
1998-11-21 11:36:51 +08:00
|
|
|
|
H5Pclose(fapl);
|
1998-11-25 22:58:22 +08:00
|
|
|
|
return retval;
|
1998-11-21 11:36:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_reset
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Reset the library by closing it.
|
|
|
|
|
*
|
|
|
|
|
* Return: void
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Robb Matzke
|
|
|
|
|
* Friday, November 20, 1998
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
h5_reset(void)
|
|
|
|
|
{
|
2001-06-19 04:22:10 +08:00
|
|
|
|
HDfflush(stdout);
|
|
|
|
|
HDfflush(stderr);
|
1998-11-21 11:36:51 +08:00
|
|
|
|
H5close();
|
2007-08-22 05:08:27 +08:00
|
|
|
|
H5Eset_auto2(H5E_DEFAULT, h5_errors, NULL);
|
1998-11-25 22:58:22 +08: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-21 04:36:08 +08: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
|
|
|
|
|
{
|
|
|
|
|
char filename[1024];
|
|
|
|
|
|
1998-11-25 22:58:22 +08:00
|
|
|
|
/*
|
|
|
|
|
* Cause the library to emit some diagnostics early so they don't
|
|
|
|
|
* interfere with other formatted output.
|
|
|
|
|
*/
|
2001-04-01 11:23:49 +08:00
|
|
|
|
sprintf(filename, "/tmp/h5emit-%05d.h5", HDgetpid());
|
1998-11-25 22:58:22 +08:00
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
|
hid_t file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT,
|
|
|
|
|
H5P_DEFAULT);
|
2007-08-24 04:25:25 +08:00
|
|
|
|
hid_t grp = H5Gcreate2(file, "emit", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
1998-11-25 22:58:22 +08:00
|
|
|
|
H5Gclose(grp);
|
|
|
|
|
H5Fclose(file);
|
2001-06-19 04:22:10 +08:00
|
|
|
|
HDunlink(filename);
|
1998-11-25 22:58:22 +08: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-21 04:36:08 +08:00
|
|
|
|
#endif /* OLD_WAY */
|
|
|
|
|
}
|
1998-11-21 11:36:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_fixname
|
|
|
|
|
*
|
|
|
|
|
* 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
|
2000-09-10 08:08:27 +08:00
|
|
|
|
* the driver supplied, resulting in something like
|
|
|
|
|
* `ufs:/u/matzke/test.h5'.
|
1998-11-21 11:36:51 +08:00
|
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
1999-08-11 04:21:32 +08:00
|
|
|
|
* Robb Matzke, 1999-08-03
|
|
|
|
|
* Modified to use the virtual file layer.
|
2000-01-26 12:20:36 +08:00
|
|
|
|
*
|
|
|
|
|
* Albert Cheng, 2000-01-25
|
|
|
|
|
* Added prefix for parallel test files.
|
2003-05-09 02:50:14 +08:00
|
|
|
|
*
|
|
|
|
|
* Albert Cheng, 2003-05-08
|
|
|
|
|
* Changed the default parallel prefix back to NULL but added
|
|
|
|
|
* an explanation remark of $HDF5_PARAPREFIX.
|
1998-11-21 11:36:51 +08:00
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
char *
|
1999-06-15 22:58:25 +08:00
|
|
|
|
h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size)
|
1998-11-21 11:36:51 +08:00
|
|
|
|
{
|
2001-05-23 07:27:38 +08:00
|
|
|
|
const char *prefix = NULL;
|
2003-10-23 05:16:46 +08:00
|
|
|
|
const char *suffix = ".h5"; /* suffix has default */
|
2001-05-26 05:00:41 +08:00
|
|
|
|
char *ptr, last = '\0';
|
2001-05-23 07:27:38 +08:00
|
|
|
|
size_t i, j;
|
2003-10-23 05:16:46 +08:00
|
|
|
|
hid_t driver = -1;
|
2006-01-10 02:17:44 +08:00
|
|
|
|
int isppdriver = 0; /* if the driver is MPI parallel */
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2001-05-23 07:27:38 +08:00
|
|
|
|
if (!base_name || !fullname || size < 1)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
memset(fullname, 0, size);
|
1998-11-21 11:36:51 +08:00
|
|
|
|
|
2000-01-26 12:20:36 +08:00
|
|
|
|
/* figure out the suffix */
|
2003-10-23 05:16:46 +08:00
|
|
|
|
if (H5P_DEFAULT != fapl) {
|
2001-05-23 07:27:38 +08:00
|
|
|
|
if ((driver = H5Pget_driver(fapl)) < 0)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
if (H5FD_FAMILY == driver)
|
2000-01-26 12:20:36 +08:00
|
|
|
|
suffix = "%05d.h5";
|
2007-07-21 01:05:00 +08:00
|
|
|
|
else if (H5FD_MULTI == driver)
|
2000-01-26 12:20:36 +08:00
|
|
|
|
suffix = NULL;
|
|
|
|
|
}
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2006-01-10 02:17:44 +08:00
|
|
|
|
/* Must first check fapl is not H5P_DEFAULT (-1) because H5FD_XXX
|
|
|
|
|
* could be of value -1 if it is not defined.
|
|
|
|
|
*/
|
2006-06-27 22:45:06 +08:00
|
|
|
|
isppdriver = H5P_DEFAULT != fapl &&
|
2006-04-21 07:54:47 +08:00
|
|
|
|
(H5FD_MPIO==driver || H5FD_MPIPOSIX==driver);
|
2006-01-10 02:17:44 +08:00
|
|
|
|
|
|
|
|
|
/* Check HDF5_NOCLEANUP environment setting.
|
|
|
|
|
* (The #ifdef is needed to prevent compile failure in case MPI is not
|
|
|
|
|
* configured.)
|
|
|
|
|
*/
|
|
|
|
|
if (isppdriver){
|
|
|
|
|
#ifdef H5_HAVE_PARALLEL
|
|
|
|
|
if (getenv_all(MPI_COMM_WORLD, 0, "HDF5_NOCLEANUP"))
|
|
|
|
|
SetTestNoCleanup();
|
|
|
|
|
#endif /* H5_HAVE_PARALLEL */
|
|
|
|
|
}else{
|
|
|
|
|
if (HDgetenv("HDF5_NOCLEANUP"))
|
|
|
|
|
SetTestNoCleanup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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.)
|
|
|
|
|
*/
|
|
|
|
|
if (isppdriver){
|
2003-05-20 03:27:41 +08:00
|
|
|
|
#ifdef H5_HAVE_PARALLEL
|
2003-10-23 05:16:46 +08:00
|
|
|
|
/*
|
|
|
|
|
* For parallel:
|
|
|
|
|
* First use command line option, then the environment
|
|
|
|
|
* variable, then try the constant
|
2000-01-26 12:20:36 +08:00
|
|
|
|
*/
|
2003-10-23 05:16:46 +08:00
|
|
|
|
static int explained = 0;
|
|
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
|
prefix = (paraprefix ? paraprefix : getenv_all(MPI_COMM_WORLD, 0, "HDF5_PARAPREFIX"));
|
2003-10-23 05:16:46 +08:00
|
|
|
|
|
|
|
|
|
if (!prefix && !explained) {
|
2003-05-20 03:27:41 +08:00
|
|
|
|
/* print hint by process 0 once. */
|
|
|
|
|
int mpi_rank;
|
2003-10-23 05:16:46 +08:00
|
|
|
|
|
2003-05-20 03:27:41 +08:00
|
|
|
|
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
|
2003-10-23 05:16:46 +08:00
|
|
|
|
|
2003-05-20 03:27:41 +08:00
|
|
|
|
if (mpi_rank == 0)
|
|
|
|
|
printf("*** Hint ***\n"
|
2003-05-09 02:50:14 +08: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"
|
2003-05-20 03:27:41 +08:00
|
|
|
|
"*** End of Hint ***\n");
|
2003-10-23 05:16:46 +08:00
|
|
|
|
|
|
|
|
|
explained = TRUE;
|
2000-01-26 12:20:36 +08:00
|
|
|
|
#ifdef HDF5_PARAPREFIX
|
2001-05-23 07:27:38 +08:00
|
|
|
|
prefix = HDF5_PARAPREFIX;
|
|
|
|
|
#endif /* HDF5_PARAPREFIX */
|
2003-05-09 02:50:14 +08:00
|
|
|
|
}
|
2003-10-23 05:16:46 +08:00
|
|
|
|
#endif /* H5_HAVE_PARALLEL */
|
|
|
|
|
} else {
|
|
|
|
|
/*
|
|
|
|
|
* For serial:
|
|
|
|
|
* First use the environment variable, then try the constant
|
2000-01-26 12:20:36 +08:00
|
|
|
|
*/
|
2005-05-27 07:27:24 +08:00
|
|
|
|
prefix = HDgetenv("HDF5_PREFIX");
|
2001-05-23 07:27:38 +08:00
|
|
|
|
|
1998-11-21 11:36:51 +08:00
|
|
|
|
#ifdef HDF5_PREFIX
|
2001-05-23 07:27:38 +08:00
|
|
|
|
if (!prefix)
|
|
|
|
|
prefix = HDF5_PREFIX;
|
|
|
|
|
#endif /* HDF5_PREFIX */
|
2000-01-26 12:20:36 +08:00
|
|
|
|
}
|
1998-11-21 11:36:51 +08:00
|
|
|
|
|
|
|
|
|
/* Prepend the prefix value to the base name */
|
|
|
|
|
if (prefix && *prefix) {
|
2006-01-10 02:17:44 +08:00
|
|
|
|
if (isppdriver){
|
2001-05-26 04:01:38 +08:00
|
|
|
|
/* This is a parallel system */
|
|
|
|
|
char *subdir;
|
2001-05-23 07:27:38 +08:00
|
|
|
|
|
2001-06-19 04:22:10 +08:00
|
|
|
|
if (!HDstrcmp(prefix, HDF5_PARAPREFIX)) {
|
2003-10-23 05:16:46 +08:00
|
|
|
|
/*
|
|
|
|
|
* If the prefix specifies the HDF5_PARAPREFIX directory, then
|
2001-05-26 04:01:38 +08:00
|
|
|
|
* default to using the "/tmp/$USER" or "/tmp/$LOGIN"
|
2003-10-23 05:16:46 +08:00
|
|
|
|
* directory instead.
|
|
|
|
|
*/
|
2001-05-26 04:01:38 +08:00
|
|
|
|
char *user, *login;
|
2001-05-23 07:27:38 +08:00
|
|
|
|
|
2001-06-19 04:22:10 +08:00
|
|
|
|
user = HDgetenv("USER");
|
|
|
|
|
login = HDgetenv("LOGIN");
|
2001-05-26 04:01:38 +08:00
|
|
|
|
subdir = (user ? user : login);
|
2001-05-23 07:27:38 +08:00
|
|
|
|
|
2001-05-26 04:01:38 +08:00
|
|
|
|
if (subdir) {
|
|
|
|
|
for (i = 0; i < size && prefix[i]; i++)
|
|
|
|
|
fullname[i] = prefix[i];
|
2001-05-23 07:27:38 +08:00
|
|
|
|
|
2001-05-26 04:01:38 +08:00
|
|
|
|
fullname[i++] = '/';
|
2001-05-23 07:27:38 +08:00
|
|
|
|
|
2003-10-23 05:16:46 +08:00
|
|
|
|
for (j = 0; i < size && subdir[j]; ++i, ++j)
|
2001-05-26 04:01:38 +08:00
|
|
|
|
fullname[i] = subdir[j];
|
|
|
|
|
}
|
2001-05-23 07:27:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
2001-05-26 04:01:38 +08:00
|
|
|
|
if (!fullname[0])
|
|
|
|
|
/* We didn't append the prefix yet */
|
2001-06-19 04:22:10 +08:00
|
|
|
|
HDstrncpy(fullname, prefix, MIN(strlen(prefix), size));
|
2001-05-26 04:01:38 +08:00
|
|
|
|
|
2001-06-19 04:22:10 +08:00
|
|
|
|
if (HDstrlen(fullname) + HDstrlen(base_name) + 1 < size) {
|
2003-10-23 05:16:46 +08:00
|
|
|
|
/*
|
|
|
|
|
* Append the base_name with a slash first. Multiple
|
|
|
|
|
* slashes are handled below.
|
|
|
|
|
*/
|
2002-04-19 15:20:41 +08:00
|
|
|
|
h5_stat_t buf;
|
2001-05-26 04:01:38 +08:00
|
|
|
|
|
2001-06-19 04:22:10 +08:00
|
|
|
|
if (HDstat(fullname, &buf) < 0)
|
2001-05-26 04:01:38 +08:00
|
|
|
|
/* The directory doesn't exist just yet */
|
2003-10-23 05:16:46 +08: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-23 05:54:07 +08:00
|
|
|
|
HDstrcpy(fullname, prefix);
|
2001-05-26 04:01:38 +08:00
|
|
|
|
|
2001-06-19 04:22:10 +08:00
|
|
|
|
HDstrcat(fullname, "/");
|
|
|
|
|
HDstrcat(fullname, base_name);
|
2001-05-26 04:01:38 +08:00
|
|
|
|
} else {
|
|
|
|
|
/* Buffer is too small */
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2001-05-23 07:27:38 +08:00
|
|
|
|
} else {
|
2001-05-26 04:01:38 +08:00
|
|
|
|
if (HDsnprintf(fullname, size, "%s/%s", prefix, base_name) == (int)size)
|
|
|
|
|
/* Buffer is too small */
|
|
|
|
|
return NULL;
|
2001-05-23 07:27:38 +08:00
|
|
|
|
}
|
2001-06-19 04:22:10 +08:00
|
|
|
|
} else if (HDstrlen(base_name) >= size) {
|
2001-05-23 07:27:38 +08:00
|
|
|
|
/* Buffer is too small */
|
|
|
|
|
return NULL;
|
1998-11-21 11:36:51 +08:00
|
|
|
|
} else {
|
2001-06-19 04:22:10 +08:00
|
|
|
|
HDstrcpy(fullname, base_name);
|
2001-05-26 04:01:38 +08:00
|
|
|
|
}
|
1998-11-21 11:36:51 +08:00
|
|
|
|
|
|
|
|
|
/* Append a suffix */
|
|
|
|
|
if (suffix) {
|
2001-06-19 04:22:10 +08:00
|
|
|
|
if (HDstrlen(fullname) + HDstrlen(suffix) >= size)
|
2001-05-23 07:27:38 +08:00
|
|
|
|
return NULL;
|
|
|
|
|
|
2001-06-19 04:22:10 +08:00
|
|
|
|
HDstrcat(fullname, suffix);
|
1998-11-21 11:36:51 +08:00
|
|
|
|
}
|
2001-05-23 07:27:38 +08: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-26 05:00:41 +08:00
|
|
|
|
|
1998-11-21 11:36:51 +08:00
|
|
|
|
return fullname;
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-02 06:56:50 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_rmprefix
|
|
|
|
|
*
|
|
|
|
|
* Purpose: This "removes" the MPIO driver prefix part of the file name
|
|
|
|
|
* by returning a pointer that points at the non-prefix component
|
|
|
|
|
* part of the file name. E.g.,
|
|
|
|
|
* Input Return
|
|
|
|
|
* pfs:/scratch1/dataX /scratch1/dataX
|
|
|
|
|
* /scratch2/dataY /scratch2/dataY
|
|
|
|
|
* Note that there is no change to the original file name.
|
|
|
|
|
*
|
|
|
|
|
* Return: Success: a pointer at the non-prefix part.
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Albert Cheng; Jun 1, 2006
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2006-10-02 18:24:03 +08:00
|
|
|
|
const char *
|
2006-06-02 06:56:50 +08:00
|
|
|
|
h5_rmprefix(const char *filename)
|
|
|
|
|
{
|
2006-10-02 18:24:03 +08:00
|
|
|
|
const char *ret_ptr;
|
2006-06-02 06:56:50 +08:00
|
|
|
|
|
|
|
|
|
if ((ret_ptr = HDstrstr(filename, ":")) == NULL)
|
|
|
|
|
ret_ptr = filename;
|
|
|
|
|
else
|
|
|
|
|
ret_ptr++;
|
2006-06-27 22:45:06 +08:00
|
|
|
|
|
2006-06-02 06:56:50 +08:00
|
|
|
|
return(ret_ptr);
|
|
|
|
|
}
|
|
|
|
|
|
1998-11-21 11:36:51 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_fileaccess
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Returns a file access template which is the default template
|
|
|
|
|
* but with a file driver set according to the constant or
|
|
|
|
|
* environment variable HDF5_DRIVER
|
|
|
|
|
*
|
|
|
|
|
* Return: Success: A file access property list
|
|
|
|
|
*
|
|
|
|
|
* Failure: -1
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Robb Matzke
|
|
|
|
|
* Thursday, November 19, 1998
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
hid_t
|
|
|
|
|
h5_fileaccess(void)
|
|
|
|
|
{
|
|
|
|
|
const char *val = NULL;
|
|
|
|
|
const char *name;
|
2000-08-05 06:20:47 +08:00
|
|
|
|
char s[1024];
|
|
|
|
|
hid_t fapl = -1;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
1998-11-21 11:36:51 +08:00
|
|
|
|
/* First use the environment variable, then the constant */
|
2001-06-19 04:22:10 +08:00
|
|
|
|
val = HDgetenv("HDF5_DRIVER");
|
1998-11-21 11:36:51 +08:00
|
|
|
|
#ifdef HDF5_DRIVER
|
|
|
|
|
if (!val) val = HDF5_DRIVER;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if ((fapl=H5Pcreate(H5P_FILE_ACCESS))<0) return -1;
|
|
|
|
|
if (!val || !*val) return fapl; /*use default*/
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2001-06-19 04:22:10 +08:00
|
|
|
|
HDstrncpy(s, val, sizeof s);
|
1998-11-21 11:36:51 +08:00
|
|
|
|
s[sizeof(s)-1] = '\0';
|
2001-06-19 04:22:10 +08:00
|
|
|
|
if (NULL==(name=HDstrtok(s, " \t\n\r"))) return fapl;
|
1998-11-21 11:36:51 +08:00
|
|
|
|
|
2001-06-19 04:22:10 +08:00
|
|
|
|
if (!HDstrcmp(name, "sec2")) {
|
1998-11-21 11:36:51 +08:00
|
|
|
|
/* Unix read() and write() system calls */
|
1999-08-11 04:21:32 +08:00
|
|
|
|
if (H5Pset_fapl_sec2(fapl)<0) return -1;
|
2001-06-19 04:22:10 +08:00
|
|
|
|
} else if (!HDstrcmp(name, "stdio")) {
|
1999-10-21 01:51:27 +08:00
|
|
|
|
/* Standard C fread() and fwrite() system calls */
|
|
|
|
|
if (H5Pset_fapl_stdio(fapl)<0) return -1;
|
2001-06-19 04:22:10 +08:00
|
|
|
|
} else if (!HDstrcmp(name, "core")) {
|
1998-11-21 11:36:51 +08:00
|
|
|
|
/* In-core temporary file with 1MB increment */
|
2007-06-16 03:11:59 +08:00
|
|
|
|
if (H5Pset_fapl_core(fapl, (size_t)1024*1024, TRUE)<0) return -1;
|
2001-06-19 04:22:10 +08:00
|
|
|
|
} else if (!HDstrcmp(name, "split")) {
|
1998-11-21 11:36:51 +08:00
|
|
|
|
/* Split meta data and raw data each using default driver */
|
1999-08-18 03:12:59 +08:00
|
|
|
|
if (H5Pset_fapl_split(fapl,
|
|
|
|
|
"-m.h5", H5P_DEFAULT,
|
|
|
|
|
"-r.h5", H5P_DEFAULT)<0)
|
1998-11-21 11:36:51 +08:00
|
|
|
|
return -1;
|
2001-06-19 04:22:10 +08:00
|
|
|
|
} else if (!HDstrcmp(name, "multi")) {
|
1999-08-18 03:12:59 +08:00
|
|
|
|
/* 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];
|
|
|
|
|
char sv[H5FD_MEM_NTYPES][1024];
|
|
|
|
|
haddr_t memb_addr[H5FD_MEM_NTYPES];
|
2004-01-10 09:41:13 +08:00
|
|
|
|
H5FD_mem_t mt;
|
1999-08-18 03:12:59 +08:00
|
|
|
|
|
2001-06-19 04:22:10 +08:00
|
|
|
|
HDmemset(memb_map, 0, sizeof memb_map);
|
|
|
|
|
HDmemset(memb_fapl, 0, sizeof memb_fapl);
|
2002-06-20 00:06:55 +08:00
|
|
|
|
HDmemset(memb_name, 0, sizeof memb_name);
|
2001-06-19 04:22:10 +08:00
|
|
|
|
HDmemset(memb_addr, 0, sizeof memb_addr);
|
1999-08-18 03:12:59 +08:00
|
|
|
|
|
2001-06-19 04:22:10 +08:00
|
|
|
|
assert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES);
|
2002-05-21 02:43:31 +08:00
|
|
|
|
for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) {
|
1999-08-18 03:12:59 +08:00
|
|
|
|
memb_fapl[mt] = H5P_DEFAULT;
|
|
|
|
|
sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]);
|
|
|
|
|
memb_name[mt] = sv[mt];
|
|
|
|
|
memb_addr[mt] = MAX(mt-1,0)*(HADDR_MAX/10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name,
|
1999-08-24 20:52:10 +08:00
|
|
|
|
memb_addr, FALSE)<0) {
|
1999-08-18 03:12:59 +08:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
2001-06-19 04:22:10 +08:00
|
|
|
|
} else if (!HDstrcmp(name, "family")) {
|
2004-01-10 09:41:13 +08:00
|
|
|
|
hsize_t fam_size = 100*1024*1024; /*100 MB*/
|
|
|
|
|
|
1998-11-21 11:36:51 +08:00
|
|
|
|
/* Family of files, each 1MB and using the default driver */
|
2004-01-10 09:41:13 +08:00
|
|
|
|
if ((val=HDstrtok(NULL, " \t\n\r")))
|
2001-11-28 00:29:13 +08:00
|
|
|
|
fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024);
|
2004-01-10 09:41:13 +08:00
|
|
|
|
if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0)
|
|
|
|
|
return -1;
|
2001-06-19 04:22:10 +08:00
|
|
|
|
} else if (!HDstrcmp(name, "log")) {
|
2007-07-21 13:59:55 +08:00
|
|
|
|
unsigned log_flags = H5FD_LOG_LOC_IO | H5FD_LOG_ALLOC;
|
2004-01-10 09:41:13 +08:00
|
|
|
|
|
2000-06-24 01:46:17 +08:00
|
|
|
|
/* Log file access */
|
2001-06-19 04:22:10 +08:00
|
|
|
|
if ((val = HDstrtok(NULL, " \t\n\r")))
|
2004-12-29 22:26:20 +08:00
|
|
|
|
log_flags = (unsigned)HDstrtol(val, NULL, 0);
|
2000-08-05 06:20:47 +08:00
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
if (H5Pset_fapl_log(fapl, NULL, log_flags, (size_t)0) < 0)
|
2000-08-05 06:20:47 +08:00
|
|
|
|
return -1;
|
2006-10-11 04:07:16 +08:00
|
|
|
|
} else if (!HDstrcmp(name, "direct")) {
|
|
|
|
|
#ifdef H5_HAVE_DIRECT
|
2006-10-17 06:31:27 +08:00
|
|
|
|
/* Linux direct read() and write() system calls. Set memory boundary, file block size,
|
|
|
|
|
* and copy buffer size to the default values. */
|
2006-11-07 06:17:46 +08:00
|
|
|
|
if (H5Pset_fapl_direct(fapl, 1024, 4096, 8*4096)<0) return -1;
|
2006-10-11 04:07:16 +08:00
|
|
|
|
#endif
|
[svn-r14362] Description:
Switched from "H5P[gs]et_latest_format" to "H5P[gs]et_format_bounds".
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
2008-01-03 21:55:39 +08:00
|
|
|
|
} else if(!HDstrcmp(name, "latest")) {
|
2007-07-05 15:38:38 +08:00
|
|
|
|
/* use the latest format */
|
[svn-r14413] Description:
Change H5P[gs]et_format_bounds() => H5P[gs]et_libver_bounds() and also
enumerated values H5F_FORMAT_{EARLIEST, LATEST} => H5F_LIBVER_{EARLIEST, LATEST}
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
2008-01-15 07:49:12 +08:00
|
|
|
|
if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
|
[svn-r14362] Description:
Switched from "H5P[gs]et_latest_format" to "H5P[gs]et_format_bounds".
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
2008-01-03 21:55:39 +08:00
|
|
|
|
return -1;
|
1998-11-21 11:36:51 +08:00
|
|
|
|
} else {
|
|
|
|
|
/* Unknown driver */
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fapl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_no_hwconv
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Turn off hardware data type conversions.
|
|
|
|
|
*
|
|
|
|
|
* Return: void
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Robb Matzke
|
|
|
|
|
* Friday, November 20, 1998
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
h5_no_hwconv(void)
|
|
|
|
|
{
|
1998-12-18 03:35:20 +08:00
|
|
|
|
H5Tunregister(H5T_PERS_HARD, NULL, -1, -1, NULL);
|
1998-11-21 11:36:51 +08:00
|
|
|
|
}
|
2002-04-23 01:12:14 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_show_hostname
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Show hostname. Show process ID if in MPI environment.
|
|
|
|
|
*
|
|
|
|
|
* Return: void
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Albert Cheng
|
|
|
|
|
* 2002/04/22
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
h5_show_hostname(void)
|
|
|
|
|
{
|
|
|
|
|
char hostname[80];
|
2007-05-18 23:14:43 +08:00
|
|
|
|
#ifdef _WIN32
|
2002-04-24 22:58:26 +08:00
|
|
|
|
WSADATA wsaData;
|
|
|
|
|
int err;
|
|
|
|
|
#endif
|
2002-04-23 01:12:14 +08:00
|
|
|
|
|
|
|
|
|
/* try show the process or thread id in multiple processes cases*/
|
|
|
|
|
#ifdef H5_HAVE_PARALLEL
|
2005-08-14 04:53:35 +08:00
|
|
|
|
{
|
2002-04-23 01:12:14 +08:00
|
|
|
|
int mpi_rank, mpi_initialized;
|
|
|
|
|
|
|
|
|
|
MPI_Initialized(&mpi_initialized);
|
|
|
|
|
if (mpi_initialized){
|
|
|
|
|
MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank);
|
|
|
|
|
printf("MPI-process %d.", mpi_rank);
|
|
|
|
|
}else
|
|
|
|
|
printf("thread 0.");
|
|
|
|
|
}
|
|
|
|
|
#elif defined(H5_HAVE_THREADSAFE)
|
2007-05-18 23:14:43 +08:00
|
|
|
|
#ifdef _WIN32
|
2008-06-03 04:39:52 +08:00
|
|
|
|
/* use GetCurrentThreadId because pthread_self return cannot be cast */
|
|
|
|
|
/* as an int on Windows */
|
|
|
|
|
fprintf("thread %d.", (int)GetCurrentThreadId());
|
2005-08-26 04:49:21 +08:00
|
|
|
|
#else
|
2002-04-23 01:12:14 +08:00
|
|
|
|
printf("thread %d.", (int)pthread_self());
|
2005-08-26 04:49:21 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
2002-04-23 01:12:14 +08:00
|
|
|
|
#else
|
|
|
|
|
printf("thread 0.");
|
|
|
|
|
#endif
|
2007-05-18 23:14:43 +08:00
|
|
|
|
#ifdef _WIN32
|
2002-04-24 22:58:26 +08:00
|
|
|
|
|
|
|
|
|
err = WSAStartup( MAKEWORD(2,2), &wsaData );
|
|
|
|
|
if ( err != 0 ) {
|
|
|
|
|
/* could not find a usable WinSock DLL */
|
|
|
|
|
return;
|
|
|
|
|
}
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2002-04-24 22:58:26 +08: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. */
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2002-04-24 22:58:26 +08:00
|
|
|
|
if ( LOBYTE( wsaData.wVersion ) != 2 ||
|
|
|
|
|
HIBYTE( wsaData.wVersion ) != 2 ) {
|
|
|
|
|
/* could not find a usable WinSock DLL */
|
|
|
|
|
WSACleanup( );
|
2005-08-14 04:53:35 +08:00
|
|
|
|
return;
|
2002-04-24 22:58:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
2005-09-13 11:20:41 +08:00
|
|
|
|
#ifdef H5_HAVE_GETHOSTNAME
|
2006-10-02 18:24:03 +08:00
|
|
|
|
if (gethostname(hostname, (size_t)80) < 0)
|
2002-04-23 01:12:14 +08:00
|
|
|
|
printf(" gethostname failed\n");
|
|
|
|
|
else
|
|
|
|
|
printf(" hostname=%s\n", hostname);
|
2005-09-20 04:32:18 +08:00
|
|
|
|
#else
|
|
|
|
|
printf(" gethostname not supported\n");
|
|
|
|
|
#endif
|
2007-05-18 23:14:43 +08:00
|
|
|
|
#ifdef _WIN32
|
2002-04-24 22:58:26 +08:00
|
|
|
|
WSACleanup();
|
|
|
|
|
#endif
|
2002-04-23 01:12:14 +08:00
|
|
|
|
}
|
2007-02-27 00:55:45 +08:00
|
|
|
|
|
2002-05-22 02:49:44 +08:00
|
|
|
|
|
|
|
|
|
#ifdef H5_HAVE_PARALLEL
|
|
|
|
|
/*
|
|
|
|
|
* Function: h5_set_info_object
|
2002-06-01 02:43:22 +08:00
|
|
|
|
* Purpose: Process environment variables setting to set up MPI Info
|
|
|
|
|
* object.
|
2002-05-22 02:49:44 +08:00
|
|
|
|
* Return: 0 if all is fine; otherwise non-zero.
|
|
|
|
|
* Programmer: Albert Cheng, 2002/05/21.
|
|
|
|
|
* Modifications:
|
2002-06-01 02:43:22 +08: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-22 02:49:44 +08:00
|
|
|
|
*/
|
|
|
|
|
int
|
|
|
|
|
h5_set_info_object(void)
|
|
|
|
|
{
|
|
|
|
|
char *envp; /* environment pointer */
|
|
|
|
|
int ret_value=0;
|
|
|
|
|
|
|
|
|
|
/* handle any MPI INFO hints via $HDF5_MPI_INFO */
|
|
|
|
|
if ((envp = getenv("HDF5_MPI_INFO")) != NULL){
|
2002-06-01 02:43:22 +08:00
|
|
|
|
char *next, *valp;
|
2002-05-22 02:49:44 +08:00
|
|
|
|
|
2002-06-01 02:43:22 +08:00
|
|
|
|
valp = envp = next = HDstrdup(envp);
|
|
|
|
|
|
|
|
|
|
/* 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];
|
|
|
|
|
key_val = calloc(1, len + 1);
|
|
|
|
|
|
|
|
|
|
/* 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++;
|
|
|
|
|
|
|
|
|
|
/* eat up any ending white spaces */
|
|
|
|
|
endp = &namep[strlen(namep) - 1];
|
|
|
|
|
|
|
|
|
|
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-22 02:49:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
2002-06-01 02:43:22 +08:00
|
|
|
|
return ret_value;
|
2002-05-22 02:49:44 +08: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)
|
|
|
|
|
{
|
|
|
|
|
char key[MPI_MAX_INFO_KEY+1];
|
|
|
|
|
char value[MPI_MAX_INFO_VAL+1];
|
|
|
|
|
int flag;
|
|
|
|
|
int i, nkeys;
|
|
|
|
|
|
2002-06-20 00:06:55 +08:00
|
|
|
|
printf("Dumping MPI Info Object(%d) (up to %d bytes per item):\n", (int)info,
|
2002-05-22 02:49:44 +08:00
|
|
|
|
MPI_MAX_INFO_VAL);
|
|
|
|
|
if (info==MPI_INFO_NULL){
|
|
|
|
|
printf("object is MPI_INFO_NULL\n");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif /* H5_HAVE_PARALLEL */
|
2003-06-19 04:43:39 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_get_file_size
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Get the current size of a file (in bytes)
|
|
|
|
|
*
|
2006-10-12 11:55:06 +08:00
|
|
|
|
* Return: Success: Size of file in bytes
|
|
|
|
|
* Failure: -1
|
2003-06-19 04:43:39 +08:00
|
|
|
|
*
|
|
|
|
|
* Programmer: Quincey Koziol
|
|
|
|
|
* Saturday, March 22, 2003
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
2006-10-12 11:55:06 +08:00
|
|
|
|
* Albert Cheng, Oct 11, 2006
|
|
|
|
|
* Changed Failure return value to -1.
|
2003-06-19 04:43:39 +08:00
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2006-04-20 14:09:51 +08:00
|
|
|
|
h5_stat_size_t
|
2003-06-19 04:43:39 +08:00
|
|
|
|
h5_get_file_size(const char *filename)
|
|
|
|
|
{
|
|
|
|
|
h5_stat_t sb;
|
|
|
|
|
|
|
|
|
|
/* Get the file's statistics */
|
2006-10-12 11:55:06 +08:00
|
|
|
|
if (HDstat(filename, &sb)==0)
|
2006-04-20 14:09:51 +08:00
|
|
|
|
return((h5_stat_size_t)sb.st_size);
|
2003-06-19 04:43:39 +08:00
|
|
|
|
|
2006-10-12 11:55:06 +08:00
|
|
|
|
return(-1);
|
2003-06-19 04:43:39 +08:00
|
|
|
|
} /* end get_file_size() */
|
|
|
|
|
|
2004-01-06 05:58:37 +08:00
|
|
|
|
/*
|
2004-01-07 01:53:13 +08: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-06 05:58:37 +08:00
|
|
|
|
*/
|
2005-08-14 04:53:35 +08:00
|
|
|
|
int
|
2004-01-07 01:53:13 +08:00
|
|
|
|
print_func(const char *format, ...)
|
2004-01-06 05:58:37 +08:00
|
|
|
|
{
|
2004-01-07 01:53:13 +08:00
|
|
|
|
va_list arglist;
|
|
|
|
|
int ret_value;
|
|
|
|
|
|
|
|
|
|
va_start(arglist, format);
|
|
|
|
|
ret_value = vprintf(format, arglist);
|
|
|
|
|
va_end(arglist);
|
|
|
|
|
return ret_value;
|
2004-01-06 05:58:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
|
#ifdef H5_HAVE_FILTER_SZIP
|
2004-11-03 03:12:06 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: h5_szip_can_encode
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Retrieve the filter config flags for szip, tell if
|
|
|
|
|
* encoder is available.
|
|
|
|
|
*
|
|
|
|
|
* Return: 1: decode+encode is enabled
|
|
|
|
|
* 0: only decode is enabled
|
|
|
|
|
* -1: other
|
|
|
|
|
*
|
2005-08-14 04:53:35 +08:00
|
|
|
|
* Programmer:
|
2004-11-03 03:12:06 +08:00
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2005-08-14 04:53:35 +08:00
|
|
|
|
int h5_szip_can_encode(void )
|
2004-11-03 03:12:06 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
herr_t status;
|
|
|
|
|
unsigned int filter_config_flags;
|
|
|
|
|
|
|
|
|
|
status =H5Zget_filter_info(H5Z_FILTER_SZIP, &filter_config_flags);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
if ((filter_config_flags &
|
2004-11-03 03:12:06 +08:00
|
|
|
|
(H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) == 0) {
|
|
|
|
|
/* filter present but neither encode nor decode is supported (???) */
|
|
|
|
|
return -1;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
} else if ((filter_config_flags &
|
|
|
|
|
(H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
|
2004-11-03 03:12:06 +08:00
|
|
|
|
H5Z_FILTER_CONFIG_DECODE_ENABLED) {
|
|
|
|
|
/* decoder only: read but not write */
|
|
|
|
|
return 0;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
} else if ((filter_config_flags &
|
|
|
|
|
(H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
|
2004-11-03 03:12:06 +08:00
|
|
|
|
H5Z_FILTER_CONFIG_ENCODE_ENABLED) {
|
|
|
|
|
/* encoder only: write but not read (???) */
|
|
|
|
|
return -1;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
} 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)) {
|
2004-11-03 03:12:06 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
2005-01-07 01:20:14 +08:00
|
|
|
|
return(-1);
|
2004-11-03 03:12:06 +08:00
|
|
|
|
}
|
|
|
|
|
#endif /* H5_HAVE_FILTER_SZIP */
|
2005-04-06 05:42:02 +08:00
|
|
|
|
|
2005-05-27 07:27:24 +08:00
|
|
|
|
#ifdef H5_HAVE_PARALLEL
|
2005-04-06 05:42:02 +08:00
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: getenv_all
|
|
|
|
|
*
|
|
|
|
|
* 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-21 05:48:31 +08: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.
|
|
|
|
|
*
|
|
|
|
|
* 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-06 05:42:02 +08:00
|
|
|
|
*
|
|
|
|
|
* Programmer: Leon Arber
|
|
|
|
|
* 4/4/05
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
2006-04-07 23:00:47 +08: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-06 05:42:02 +08:00
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
char* getenv_all(MPI_Comm comm, int root, const char* name)
|
|
|
|
|
{
|
2006-04-07 23:00:47 +08:00
|
|
|
|
int mpi_size, mpi_rank, mpi_initialized;
|
|
|
|
|
int len;
|
2005-04-06 05:42:02 +08:00
|
|
|
|
static char* env = NULL;
|
|
|
|
|
MPI_Status Status;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2005-04-06 05:42:02 +08:00
|
|
|
|
assert(name);
|
|
|
|
|
|
2006-04-07 23:00:47 +08:00
|
|
|
|
MPI_Initialized(&mpi_initialized);
|
|
|
|
|
if (!mpi_initialized){
|
|
|
|
|
/* use original getenv */
|
2005-04-06 05:42:02 +08:00
|
|
|
|
if(env)
|
2006-04-07 23:00:47 +08:00
|
|
|
|
HDfree(env);
|
2006-06-27 22:45:06 +08:00
|
|
|
|
env = HDgetenv(name);
|
2006-04-07 23:00:47 +08:00
|
|
|
|
}else{
|
|
|
|
|
MPI_Comm_rank(comm, &mpi_rank);
|
|
|
|
|
MPI_Comm_size(comm, &mpi_size);
|
|
|
|
|
assert(root < mpi_size);
|
2005-04-06 05:42:02 +08:00
|
|
|
|
|
2006-04-07 23:00:47 +08:00
|
|
|
|
/* 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 = 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);
|
|
|
|
|
}
|
2005-04-06 05:42:02 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2006-04-07 23:00:47 +08:00
|
|
|
|
MPI_Bcast(&len, 1, MPI_INT, root, comm);
|
|
|
|
|
if(len >= 0)
|
|
|
|
|
{
|
|
|
|
|
if(env == NULL)
|
|
|
|
|
env = (char*) HDmalloc(len+1);
|
|
|
|
|
else if(strlen(env) < len)
|
|
|
|
|
env = (char*) HDrealloc(env, len+1);
|
|
|
|
|
|
|
|
|
|
MPI_Bcast(env, len, MPI_CHAR, root, comm);
|
|
|
|
|
env[len] = '\0';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(env)
|
|
|
|
|
HDfree(env);
|
|
|
|
|
env = NULL;
|
|
|
|
|
}
|
2005-04-06 05:42:02 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-07 23:00:47 +08:00
|
|
|
|
#ifndef NDEBUG
|
2005-04-06 05:42:02 +08:00
|
|
|
|
MPI_Barrier(comm);
|
2006-04-07 23:00:47 +08:00
|
|
|
|
#endif
|
2005-04-06 05:42:02 +08:00
|
|
|
|
|
|
|
|
|
return env;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|