summaryrefslogtreecommitdiffstats
path: root/test/h5test.c
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2002-04-22 17:12:14 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2002-04-22 17:12:14 (GMT)
commit7527ed7d6f3d122e2b00e919c4a8d993b1e196be (patch)
tree53eb4c159681c889f3f7f658cf4e290a05cb9d98 /test/h5test.c
parent2c29bc24ffa74517adb67e822d9aac40534817d2 (diff)
downloadhdf5-7527ed7d6f3d122e2b00e919c4a8d993b1e196be.zip
hdf5-7527ed7d6f3d122e2b00e919c4a8d993b1e196be.tar.gz
hdf5-7527ed7d6f3d122e2b00e919c4a8d993b1e196be.tar.bz2
[svn-r5218] 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)
Diffstat (limited to 'test/h5test.c')
-rw-r--r--test/h5test.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/h5test.c b/test/h5test.c
index 2f8e183..08de54a 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -503,3 +503,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);
+}