[SCM] Gerris Flow Solver branch, upstream, updated. e8f73a07832050124d2b8bf6c6f35b33180e65a8
Stephane Popinet
popinet at users.sf.net
Tue Nov 24 12:24:16 UTC 2009
The following commit has been merged in the upstream branch:
commit 76151b194a680b33623cb3ed440e7939a7f3cfc6
Author: Stephane Popinet <popinet at users.sf.net>
Date: Tue Jun 23 19:24:16 2009 +1000
Improved error messages in parallel (includes processor name)
darcs-hash:20090623092416-d4795-8059dc563d14ecda6d3fc7c21e43b66c6087afce.gz
diff --git a/src/gerris.c b/src/gerris.c
index 7082fdc..6b2861b 100644
--- a/src/gerris.c
+++ b/src/gerris.c
@@ -97,7 +97,7 @@ int main (int argc, char * argv[])
maxlevel = -1;
break;
case 'h': /* help */
- fprintf (stderr,
+ gfs_error (0,
"Usage: gerris [OPTION] FILE\n"
"The Gerris flow solver simulation engine.\n"
"\n"
@@ -122,7 +122,7 @@ int main (int argc, char * argv[])
return 0; /* success */
break;
case 'V': /* version */
- fprintf (stderr,
+ gfs_error (0,
"gerris: using %dD libgfs version %s (%s)\n"
" compiled with flags: %s\n"
" MPI: %s\n"
@@ -154,13 +154,13 @@ int main (int argc, char * argv[])
return 0; /* succes */
break;
case '?': /* wrong options */
- fprintf (stderr, "Try `gerris --help' for more information.\n");
+ gfs_error (0, "Try `gerris --help' for more information.\n");
return 1; /* failure */
}
}
if (optind >= argc) { /* missing FILE */
- fprintf (stderr,
+ gfs_error (0,
"gerris: missing FILE\n"
"Try `gerris --help' for more information.\n");
return 1; /* failure */
@@ -186,13 +186,13 @@ int main (int argc, char * argv[])
g_free (m4_options);
if (fptr == NULL) {
- fprintf (stderr, "gerris: unable to open file `%s'\n", argv[optind]);
+ gfs_error (-1, "gerris: unable to open file `%s'\n", argv[optind]);
return 1;
}
fp = gts_file_new (fptr);
if (!(simulation = gfs_simulation_read (fp))) {
- fprintf (stderr,
+ gfs_error (-1,
"gerris: file `%s' is not a valid simulation file\n"
"%s:%d:%d: %s\n",
argv[optind], argv[optind],
diff --git a/src/init.c b/src/init.c
index 9d0e695..e878738 100644
--- a/src/init.c
+++ b/src/init.c
@@ -54,7 +54,7 @@ static void gfs_log (const gchar * log_domain,
const gchar * message)
{
int rank = -1, type = 0;
- gchar pe[10];
+ gchar * pe;
const gchar stype[][10] = {
"ERROR", "CRITICAL", "WARNING", "MESSAGE", "INFO", "DEBUG"
};
@@ -65,11 +65,15 @@ static void gfs_log (const gchar * log_domain,
MPI_Comm_rank (MPI_COMM_WORLD, &rank);
else
rank = -1;
-#endif /* HAVE_MPI */
- if (rank >= 0)
- snprintf (pe, 10, "PE %d: ", rank);
+ if (rank >= 0) {
+ char name[MPI_MAX_PROCESSOR_NAME];
+ int length;
+ MPI_Get_processor_name (name, &length);
+ pe = g_strdup_printf ("PE %d (%s): ", rank, name);
+ }
else
- pe[0] = '\0';
+#endif /* HAVE_MPI */
+ pe = g_strdup ("");
switch (log_level & G_LOG_LEVEL_MASK) {
case G_LOG_LEVEL_ERROR: type = 0; break;
@@ -82,7 +86,8 @@ static void gfs_log (const gchar * log_domain,
g_assert_not_reached ();
}
fprintf (stderr, "\n%s-%s **: %s%s\n\n",
- log_domain, stype[type], pe, message);
+ log_domain, stype[type], pe, message);
+ g_free (pe);
}
/**
diff --git a/src/utils.h b/src/utils.h
index 97a2fd4..4f8b006 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -31,17 +31,37 @@ extern "C" {
# include "config.h"
# ifdef HAVE_MPI
# include <mpi.h>
-# define gfs_all_reduce(domain, p, type, op) { \
- if ((domain)->pid >= 0) { \
- union { int a; float b; double c;} global; \
- MPI_Allreduce (&(p), &global, 1, type, op, MPI_COMM_WORLD); \
- memcpy (&(p), &global, sizeof (p)); \
- } \
- }
-#else
+
+# define gfs_all_reduce(domain, p, type, op) { \
+ if ((domain)->pid >= 0) { \
+ union { int a; float b; double c;} global; \
+ MPI_Allreduce (&(p), &global, 1, type, op, MPI_COMM_WORLD); \
+ memcpy (&(p), &global, sizeof (p)); \
+ } \
+ }
+
+# define gfs_error(pid, ...) { \
+ int rank; \
+ MPI_Comm_rank (MPI_COMM_WORLD, &rank); \
+ if (rank == (pid)) \
+ fprintf (stderr, __VA_ARGS__); \
+ else if ((pid) < 0) { \
+ int size; \
+ MPI_Comm_size (MPI_COMM_WORLD, &size); \
+ if (size > 1) { \
+ char name[MPI_MAX_PROCESSOR_NAME]; \
+ MPI_Get_processor_name (name, &size); \
+ fprintf (stderr, "PE %d (%s): ", rank, name); \
+ } \
+ fprintf (stderr, __VA_ARGS__); \
+ } \
+ }
+
+# else /* doesn't HAVE_MPI */
/* gfs_all_reduce() defaults to nothing without MPI */
# define gfs_all_reduce(domain, p, type, op)
-# endif /* HAVE_MPI */
+# define gfs_error(pid, ...) fprintf(stderr, __VA_ARGS__)
+# endif /* doesn't HAVE_MPI */
#endif /* HAVE_CONFIG_H */
#define GFS_DOUBLE_TO_POINTER(d) (*((gpointer *) &(d)))
--
Gerris Flow Solver
More information about the debian-science-commits
mailing list