Merge branch 'ParPrintf' of github.com:hypre-space/hypre into parspgemm

This commit is contained in:
Ruipeng Li 2022-03-18 15:20:52 -07:00
commit 5513fd5115
3 changed files with 29 additions and 0 deletions

View File

@ -86,6 +86,7 @@ HYPRE_Int hypre_sprintf( char *s, const char *format, ... );
HYPRE_Int hypre_scanf( const char *format, ... );
HYPRE_Int hypre_fscanf( FILE *stream, const char *format, ... );
HYPRE_Int hypre_sscanf( char *s, const char *format, ... );
HYPRE_Int hypre_ParPrintf(MPI_Comm comm, const char *format, ...);
// #else
// #define hypre_printf printf
// #define hypre_fprintf fprintf

View File

@ -227,6 +227,33 @@ hypre_sscanf( char *s, const char *format, ...)
return ierr;
}
HYPRE_Int
hypre_ParPrintf(MPI_Comm comm, const char *format, ...)
{
HYPRE_Int my_id;
HYPRE_Int ierr = hypre_MPI_Comm_rank(comm, &my_id);
if (ierr)
{
return ierr;
}
if (!my_id)
{
va_list ap;
char *newformat;
va_start(ap, format);
new_format(format, &newformat);
ierr = vprintf(newformat, ap);
free_format(newformat);
va_end(ap);
fflush(stdout);
}
return ierr;
}
// #else
//
// /* this is used only to eliminate compiler warnings */

View File

@ -19,6 +19,7 @@ HYPRE_Int hypre_sprintf( char *s, const char *format, ... );
HYPRE_Int hypre_scanf( const char *format, ... );
HYPRE_Int hypre_fscanf( FILE *stream, const char *format, ... );
HYPRE_Int hypre_sscanf( char *s, const char *format, ... );
HYPRE_Int hypre_ParPrintf(MPI_Comm comm, const char *format, ...);
// #else
// #define hypre_printf printf
// #define hypre_fprintf fprintf