From 8a3dc0fad80859a805b14dfba31d44781c1ec22d Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Sat, 2 Dec 2000 17:53:02 -0500 Subject: [svn-r3070] Purpose: Feature Description: H5Eprint used to print "thread 0" even in MPI-application. Added code to print MPI-process rank ID (as in MPI_COMM_WORLD) to give more information of which process is printing the messages. Platforms tested: IRIX64-64, both serial and parallel. --- src/H5E.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/H5E.c b/src/H5E.c index 2d216b2..b4928ff 100644 --- a/src/H5E.c +++ b/src/H5E.c @@ -343,6 +343,8 @@ H5Eclear(void) * Friday, February 27, 1998 * * Modifications: + * Albert Cheng, 2000/12/02 + * Show MPI process rank id if applicable. * *------------------------------------------------------------------------- */ @@ -357,11 +359,21 @@ H5Eprint(FILE *stream) /*NO TRACE*/ if (!stream) stream = stderr; -#ifdef H5_HAVE_THREADSAFE - fprintf (stream, "HDF5-DIAG: Error detected in thread %d." - ,(int)pthread_self()); + fprintf (stream, "HDF5-DIAG: Error detected in "); + /* 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); + fprintf (stream, "MPI-process %d.", mpi_rank); + }else + fprintf (stream, "thread 0."); + } +#elif defined(H5_HAVE_THREADSAFE) + fprintf (stream, "thread %d.", (int)pthread_self()); #else - fprintf (stream, "HDF5-DIAG: Error detected in thread 0."); + fprintf (stream, "thread 0."); #endif if (estack && estack->nused>0) fprintf (stream, " Back trace follows."); HDfputc ('\n', stream); -- cgit v0.12