summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt6
-rw-r--r--test/CMakeTests.cmake47
-rw-r--r--test/cache.c36
-rw-r--r--test/cache_common.c6
-rw-r--r--test/h5test.c158
5 files changed, 129 insertions, 124 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 55b3c44..651e4eb 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -85,7 +85,7 @@ if (BUILD_SHARED_LIBS)
TARGET ${HDF5_TEST_PLUGIN_LIB_TARGET}
POST_BUILD
COMMAND ${CMAKE_COMMAND}
- ARGS -E copy_if_different
+ ARGS -E copy_if_different
"$<TARGET_FILE:${HDF5_TEST_PLUGIN_LIB_TARGET}>"
"${CMAKE_BINARY_DIR}/testdir1/$<TARGET_FILE_NAME:${HDF5_TEST_PLUGIN_LIB_TARGET}>"
)
@@ -116,7 +116,7 @@ if (BUILD_SHARED_LIBS)
TARGET ${HDF5_TEST_PLUGIN_LIB_TARGET}
POST_BUILD
COMMAND ${CMAKE_COMMAND}
- ARGS -E copy_if_different
+ ARGS -E copy_if_different
"$<TARGET_FILE:${HDF5_TEST_PLUGIN_LIB_TARGET}>"
"${CMAKE_BINARY_DIR}/testdir2/$<TARGET_FILE_NAME:${HDF5_TEST_PLUGIN_LIB_TARGET}>"
)
@@ -293,7 +293,7 @@ set_target_properties (links_env PROPERTIES FOLDER test)
#-- Adding test for libinfo
set (GREP_RUNNER ${PROJECT_BINARY_DIR}/GrepRunner.cmake)
-file (WRITE ${GREP_RUNNER}
+file (WRITE ${GREP_RUNNER}
"file (STRINGS \${TEST_PROGRAM} TEST_RESULT REGEX \"SUMMARY OF THE HDF5 CONFIGURATION\")
if (\${TEST_RESULT} STREQUAL \"0\")
message (FATAL_ERROR \"Failed: The output: \${TEST_RESULT} of \${TEST_PROGRAM} did not contain SUMMARY OF THE HDF5 CONFIGURATION\")
diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake
index 92e4574..c7803f6 100644
--- a/test/CMakeTests.cmake
+++ b/test/CMakeTests.cmake
@@ -204,7 +204,7 @@ endif (HDF5_TEST_VFD)
add_test (
NAME H5TEST-clear-testhdf5-objects
COMMAND ${CMAKE_COMMAND}
- -E remove
+ -E remove
coord.h5
dtypes10.h5
sys_file1
@@ -259,7 +259,7 @@ else (HDF5_ENABLE_USING_MEMCHECKER)
WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST
)
endif (HDF5_ENABLE_USING_MEMCHECKER)
-
+
##############################################################################
##############################################################################
### T H E T E S T S M A C R O S ###
@@ -270,7 +270,7 @@ endif (HDF5_ENABLE_USING_MEMCHECKER)
add_test (
NAME H5TEST-clear-objects
COMMAND ${CMAKE_COMMAND}
- -E remove
+ -E remove
dt_arith1.h5
dt_arith2.h5
dtransform.h5
@@ -335,9 +335,16 @@ add_test (
)
foreach (test ${H5_TESTS})
- add_test (NAME H5TEST-${test} COMMAND $<TARGET_FILE:${test}>)
+ if (${test} STREQUAL "big" AND CYGWIN)
+ add_test (
+ NAME H5TEST-${test}
+ COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${test}"
+ )
+ else (${test} STREQUAL "big" AND CYGWIN)
+ add_test (NAME H5TEST-${test} COMMAND $<TARGET_FILE:${test}>)
+ endif (${test} STREQUAL "big" AND CYGWIN)
set_tests_properties (H5TEST-${test} PROPERTIES
- DEPENDS H5TEST-clear-objects
+ DEPENDS H5TEST-clear-objects
ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST"
WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST
)
@@ -358,7 +365,7 @@ set_tests_properties (H5TEST-big PROPERTIES TIMEOUT 1800)
add_test (
NAME H5TEST-clear-cache-objects
COMMAND ${CMAKE_COMMAND}
- -E remove
+ -E remove
cache_test.h5
WORKING_DIRECTORY
${HDF5_TEST_BINARY_DIR}/H5TEST
@@ -374,14 +381,14 @@ set_tests_properties (H5TEST-cache PROPERTIES
add_test (
NAME H5TEST-clear-cache_api-objects
COMMAND ${CMAKE_COMMAND}
- -E remove
+ -E remove
cache_api_test.h5
WORKING_DIRECTORY
${HDF5_TEST_BINARY_DIR}/H5TEST
)
add_test (NAME H5TEST-cache_api COMMAND $<TARGET_FILE:cache_api>)
set_tests_properties (H5TEST-cache_api PROPERTIES
- DEPENDS H5TEST-clear-cache_api-objects
+ DEPENDS H5TEST-clear-cache_api-objects
ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST"
WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST
)
@@ -390,7 +397,7 @@ set_tests_properties (H5TEST-cache_api PROPERTIES
add_test (
NAME H5TEST-clear-cache_tagging-objects
COMMAND ${CMAKE_COMMAND}
- -E remove
+ -E remove
tagging_test.h5
tagging_ext_test.h5
WORKING_DIRECTORY
@@ -407,7 +414,7 @@ set_tests_properties (H5TEST-cache_tagging PROPERTIES
add_test (
NAME H5TEST-clear-ttsafe-objects
COMMAND ${CMAKE_COMMAND}
- -E remove
+ -E remove
ttsafe_error.h5
ttsafe_dcreate.h5
ttsafe_cancel.h5
@@ -427,7 +434,7 @@ if (HDF5_ENABLE_DEPRECATED_SYMBOLS)
add_test (
NAME H5TEST-clear-err_compat-objects
COMMAND ${CMAKE_COMMAND}
- -E remove
+ -E remove
err_compat.txt
err_compat.txt.err
WORKING_DIRECTORY
@@ -454,7 +461,7 @@ endif (HDF5_ENABLE_DEPRECATED_SYMBOLS)
add_test (
NAME H5TEST-clear-error_test-objects
COMMAND ${CMAKE_COMMAND}
- -E remove
+ -E remove
error_test.txt
error_test.txt.err
WORKING_DIRECTORY
@@ -470,7 +477,7 @@ add_test (NAME H5TEST-error_test COMMAND "${CMAKE_COMMAND}"
-D "TEST_FOLDER=${PROJECT_BINARY_DIR}/H5TEST"
-P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
)
-set_tests_properties (H5TEST-error_test PROPERTIES
+set_tests_properties (H5TEST-error_test PROPERTIES
DEPENDS H5TEST-clear-error_test-objects
ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST;HDF5_PLUGIN_PRELOAD=::"
WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST
@@ -482,7 +489,7 @@ add_test (
COMMAND ${CMAKE_COMMAND}
-E remove
links_env.txt
- links_env.txt.err
+ links_env.txt.err
extlinks_env0.h5
extlinks_env1.h5
tmp/extlinks_env1.h5
@@ -610,7 +617,7 @@ if (HDF5_TEST_VFD)
if (${vfdname} STREQUAL "multi" OR ${vfdname} STREQUAL "split")
if (NOT BUILD_SHARED_LIBS AND NOT CMAKE_BUILD_TYPE MATCHES Debug)
add_test (
- NAME VFD-${vfdname}-${vfdtest}
+ NAME VFD-${vfdname}-${vfdtest}
COMMAND "${CMAKE_COMMAND}"
-D "TEST_PROGRAM=$<TARGET_FILE:${vfdtest}>"
-D "TEST_ARGS:STRING="
@@ -632,7 +639,7 @@ if (HDF5_TEST_VFD)
endif(NOT BUILD_SHARED_LIBS AND NOT CMAKE_BUILD_TYPE MATCHES Debug)
else (${vfdname} STREQUAL "multi" OR ${vfdname} STREQUAL "split")
add_test (
- NAME VFD-${vfdname}-${vfdtest}
+ NAME VFD-${vfdname}-${vfdtest}
COMMAND "${CMAKE_COMMAND}"
-D "TEST_PROGRAM=$<TARGET_FILE:${vfdtest}>"
-D "TEST_ARGS:STRING="
@@ -649,7 +656,7 @@ if (HDF5_TEST_VFD)
endif (${vfdname} STREQUAL "multi" OR ${vfdname} STREQUAL "split")
else (${vfdtest} STREQUAL "flush1" OR ${vfdtest} STREQUAL "flush2")
add_test (
- NAME VFD-${vfdname}-${vfdtest}
+ NAME VFD-${vfdname}-${vfdtest}
COMMAND "${CMAKE_COMMAND}"
-D "TEST_PROGRAM=$<TARGET_FILE:${vfdtest}>"
-D "TEST_ARGS:STRING="
@@ -672,7 +679,7 @@ if (HDF5_TEST_VFD)
CHECK_VFD_TEST (${test} ${vfdname} ${resultcode})
else (WIN32)
add_test (
- NAME VFD-${vfdname}-${test}
+ NAME VFD-${vfdname}-${test}
COMMAND "${CMAKE_COMMAND}"
-D "TEST_PROGRAM=$<TARGET_FILE:${test}>"
-D "TEST_ARGS:STRING="
@@ -693,7 +700,7 @@ if (HDF5_TEST_VFD)
set_tests_properties (VFD-${vfdname}-flush2 PROPERTIES TIMEOUT 10)
if (HDF5_TEST_FHEAP_VFD)
add_test (
- NAME VFD-${vfdname}-fheap
+ NAME VFD-${vfdname}-fheap
COMMAND "${CMAKE_COMMAND}"
-D "TEST_PROGRAM=$<TARGET_FILE:fheap>"
-D "TEST_ARGS:STRING="
@@ -710,7 +717,7 @@ if (HDF5_TEST_VFD)
)
endif (HDF5_TEST_FHEAP_VFD)
ENDMACRO (ADD_VFD_TEST)
-
+
# Run test with different Virtual File Driver
foreach (vfd ${VFD_LIST})
ADD_VFD_TEST (${vfd} 0)
diff --git a/test/cache.c b/test/cache.c
index 8d6076a..9bf225e 100644
--- a/test/cache.c
+++ b/test/cache.c
@@ -271,7 +271,7 @@ smoke_check_1(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- row_major_scan_forward(/* file_ptr */ file_ptr,
+ row_major_scan_forward(/* file_ptr */ file_ptr,
/* lag */ lag,
/* verbose */ FALSE,
/* reset_stats */ TRUE,
@@ -289,7 +289,7 @@ smoke_check_1(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- row_major_scan_backward(/* file_ptr */ file_ptr,
+ row_major_scan_backward(/* file_ptr */ file_ptr,
/* lag */ lag,
/* verbose */ FALSE,
/* reset_stats */ TRUE,
@@ -307,7 +307,7 @@ smoke_check_1(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- row_major_scan_forward(/* file_ptr */ file_ptr,
+ row_major_scan_forward(/* file_ptr */ file_ptr,
/* lag */ lag,
/* verbose */ FALSE,
/* reset_stats */ TRUE,
@@ -336,7 +336,7 @@ smoke_check_1(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- col_major_scan_forward(/* file_ptr */ file_ptr,
+ col_major_scan_forward(/* file_ptr */ file_ptr,
/* lag */ lag,
/* verbose */ FALSE,
/* reset_stats */ TRUE,
@@ -360,7 +360,7 @@ smoke_check_1(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- col_major_scan_backward(/* file_ptr */ file_ptr,
+ col_major_scan_backward(/* file_ptr */ file_ptr,
/* lag */ lag,
/* verbose */ FALSE,
/* reset_stats */ TRUE,
@@ -456,7 +456,7 @@ smoke_check_2(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- row_major_scan_forward(/* file_ptr */ file_ptr,
+ row_major_scan_forward(/* file_ptr */ file_ptr,
/* lag */ lag,
/* verbose */ FALSE,
/* reset_stats */ TRUE,
@@ -474,7 +474,7 @@ smoke_check_2(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- row_major_scan_backward(/* file_ptr */ file_ptr,
+ row_major_scan_backward(/* file_ptr */ file_ptr,
/* lag */ lag,
/* verbose */ FALSE,
/* reset_stats */ TRUE,
@@ -492,7 +492,7 @@ smoke_check_2(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- row_major_scan_forward(/* file_ptr */ file_ptr,
+ row_major_scan_forward(/* file_ptr */ file_ptr,
/* lag */ lag,
/* verbose */ FALSE,
/* reset_stats */ TRUE,
@@ -521,7 +521,7 @@ smoke_check_2(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- col_major_scan_forward(/* file_ptr */ file_ptr,
+ col_major_scan_forward(/* file_ptr */ file_ptr,
/* lag */ lag,
/* verbose */ FALSE,
/* reset_stats */ TRUE,
@@ -545,7 +545,7 @@ smoke_check_2(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- col_major_scan_backward(/* file_ptr */ file_ptr,
+ col_major_scan_backward(/* file_ptr */ file_ptr,
/* lag */ lag,
/* verbose */ FALSE,
/* reset_stats */ TRUE,
@@ -640,7 +640,7 @@ smoke_check_3(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- row_major_scan_forward(/* file_ptr */ file_ptr,
+ row_major_scan_forward(/* file_ptr */ file_ptr,
/* lag */ lag,
/* verbose */ FALSE,
/* reset_stats */ TRUE,
@@ -825,7 +825,7 @@ smoke_check_4(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- row_major_scan_forward(/* file_ptr */ file_ptr,
+ row_major_scan_forward(/* file_ptr */ file_ptr,
/* lag */ lag,
/* verbose */ FALSE,
/* reset_stats */ TRUE,
@@ -843,7 +843,7 @@ smoke_check_4(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- row_major_scan_backward(/* file_ptr */ file_ptr,
+ row_major_scan_backward(/* file_ptr */ file_ptr,
/* lag */ lag,
/* verbose */ FALSE,
/* reset_stats */ TRUE,
@@ -861,7 +861,7 @@ smoke_check_4(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- row_major_scan_forward(/* file_ptr */ file_ptr,
+ row_major_scan_forward(/* file_ptr */ file_ptr,
/* lag */ lag,
/* verbose */ FALSE,
/* reset_stats */ TRUE,
@@ -890,7 +890,7 @@ smoke_check_4(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- col_major_scan_forward(/* file_ptr */ file_ptr,
+ col_major_scan_forward(/* file_ptr */ file_ptr,
/* lag */ lag,
/* verbose */ FALSE,
/* reset_stats */ TRUE,
@@ -914,7 +914,7 @@ smoke_check_4(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- col_major_scan_backward(/* file_ptr */ file_ptr,
+ col_major_scan_backward(/* file_ptr */ file_ptr,
/* lag */ lag,
/* verbose */ FALSE,
/* reset_stats */ TRUE,
@@ -13206,8 +13206,8 @@ check_expunge_entry(void)
*/
result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size,
- &in_cache, &is_dirty, &is_protected,
- &is_pinned, NULL, NULL);
+ &in_cache, &is_dirty, &is_protected,
+ &is_pinned, NULL, NULL);
if ( result < 0 ) {
diff --git a/test/cache_common.c b/test/cache_common.c
index cce87a9..12001b2 100644
--- a/test/cache_common.c
+++ b/test/cache_common.c
@@ -19,7 +19,6 @@
* This file contains common code for tests of the cache
* implemented in H5C.c
*/
-#include "H5private.h" /* Put this first, so H5open() isn't invoked in public macros */
#include "h5test.h"
#include "H5Cprivate.h"
#include "H5Iprivate.h"
@@ -799,7 +798,6 @@ notify_dest(H5F_t * f, void * thing)
*
*-------------------------------------------------------------------------
*/
-
herr_t
flush(H5F_t *f,
hid_t H5_ATTR_UNUSED dxpl_id,
@@ -871,7 +869,6 @@ flush(H5F_t *f,
}
return(SUCCEED);
-
} /* flush() */
herr_t
@@ -962,7 +959,6 @@ notify_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
return(flush(f, dxpl_id, dest, addr, thing, flags_ptr));
}
-
/*-------------------------------------------------------------------------
* Function: load & friends
@@ -1108,7 +1104,6 @@ notify_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata)
*
*-------------------------------------------------------------------------
*/
-
herr_t
size(H5F_t H5_ATTR_UNUSED * f,
void * thing,
@@ -1134,7 +1129,6 @@ size(H5F_t H5_ATTR_UNUSED * f,
*size_ptr = entry_ptr->size;
return(SUCCEED);
-
} /* size() */
herr_t
diff --git a/test/h5test.c b/test/h5test.c
index d73c120..fefacda 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -700,21 +700,24 @@ h5_show_hostname(void)
{
char hostname[80];
#ifdef H5_HAVE_WIN32_API
- WSADATA wsaData;
- int err;
+ WSADATA wsaData;
+ int err;
#endif
/* try show the process or thread id in multiple processes cases*/
#ifdef H5_HAVE_PARALLEL
{
- 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.");
+ 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.");
}
#elif defined(H5_HAVE_THREADSAFE)
printf("thread %lu.", HDpthread_self_ulong());
@@ -723,31 +726,31 @@ h5_show_hostname(void)
#endif
#ifdef H5_HAVE_WIN32_API
- err = WSAStartup( MAKEWORD(2,2), &wsaData );
- if ( err != 0 ) {
- /* could not find a usable WinSock DLL */
- return;
- }
-
-/* 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;
- }
+ err = WSAStartup( MAKEWORD(2,2), &wsaData );
+ if ( err != 0 ) {
+ /* could not find a usable WinSock DLL */
+ return;
+ }
+
+ /* 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;
+ }
#endif
#ifdef H5_HAVE_GETHOSTNAME
if (gethostname(hostname, (size_t)80) < 0)
- printf(" gethostname failed\n");
+ printf(" gethostname failed\n");
else
- printf(" hostname=%s\n", hostname);
+ printf(" hostname=%s\n", hostname);
#else
printf(" gethostname not supported\n");
#endif
@@ -1099,61 +1102,62 @@ int h5_szip_can_encode(void )
char *
getenv_all(MPI_Comm comm, int root, const char* name)
{
- int mpi_size, mpi_rank, mpi_initialized;
+ int mpi_size, mpi_rank, mpi_initialized, mpi_finalized;
int len;
static char* env = NULL;
assert(name);
MPI_Initialized(&mpi_initialized);
- if(!mpi_initialized) {
- /* use original getenv */
- if(env)
- HDfree(env);
- env = HDgetenv(name);
- } /* end if */
- else {
- 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;
- }
- }
- }
-
+ 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;
+ }
+ }
#ifndef NDEBUG
- MPI_Barrier(comm);
+ MPI_Barrier(comm);
#endif
+ }
+ else {
+ /* use original getenv */
+ if(env)
+ HDfree(env);
+ env = HDgetenv(name);
+ } /* end if */
return env;
}