diff options
author | Albert Cheng <acheng@hdfgroup.org> | 2002-04-22 17:12:11 (GMT) |
---|---|---|
committer | Albert Cheng <acheng@hdfgroup.org> | 2002-04-22 17:12:11 (GMT) |
commit | e23d11cc194ab9a93cef40eca12a93b71f01c001 (patch) | |
tree | e5eafe01acaf8f06e9878d67dde7625064175845 | |
parent | 15b39dd123f8bfa831e0508b8656d9f32fa6356b (diff) | |
download | hdf5-e23d11cc194ab9a93cef40eca12a93b71f01c001.zip hdf5-e23d11cc194ab9a93cef40eca12a93b71f01c001.tar.gz hdf5-e23d11cc194ab9a93cef40eca12a93b71f01c001.tar.bz2 |
[svn-r5217] Purpose:
New feature
Description:
Added h5_show_hostname to display the hostname of the host in
which the process runs. It can help identify location of process
in multiple processes or batch launching environments.
Platforms tested:
Eirene (pp)
-rw-r--r-- | test/h5test.c | 44 | ||||
-rw-r--r-- | test/h5test.h | 6 |
2 files changed, 47 insertions, 3 deletions
diff --git a/test/h5test.c b/test/h5test.c index fd45a7e..8bbc3c7 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -580,3 +580,47 @@ h5_no_hwconv(void) { H5Tunregister(H5T_PERS_HARD, NULL, -1, -1, NULL); } + + +/*------------------------------------------------------------------------- + * 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]; + + /* 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."); + } +#elif defined(H5_HAVE_THREADSAFE) + printf("thread %d.", (int)pthread_self()); +#else + printf("thread 0."); +#endif + if (gethostname(hostname, 80) < 0){ + printf(" gethostname failed\n"); + } + else + printf(" hostname=%s\n", hostname); +} diff --git a/test/h5test.h b/test/h5test.h index f1a3dec..cc627ab 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -1,5 +1,5 @@ /* - * Copyright © 1998 NCSA + * Copyright (c) 1998-2002 NCSA * All rights reserved. * * Programmer: Robb Matzke <matzke@llnl.gov> @@ -12,8 +12,8 @@ #undef NDEBUG #include "hdf5.h" - #include "H5private.h" + #ifdef STDC_HEADERS # include <signal.h> #endif @@ -21,7 +21,6 @@ #define H5T_PACKAGE #include "H5Tpkg.h" /*to turn off hardware conversions*/ - /* * This contains the filename prefix specificied as command line option for * the parallel test files. @@ -60,6 +59,7 @@ char *h5_fixname(const char *base_name, hid_t fapl, char *fullname, hid_t h5_fileaccess(void); void h5_no_hwconv(void); void h5_reset(void); +void h5_show_hostname(void); #ifdef __cplusplus } |