+2011-07-14 Daniel Carrera <dcarrera@gmail.com>
+
+ * caf/single.c: Include stdarg.h header.
+ (caf_runtime_error): New function. Use "exit(EXIT_FAILURE)".
+ (_gfortran_caf_register): Use caf_runtime_error.
+ (_gfortran_caf_sync_images): Use "exit(EXIT_FAILURE)".
+ * caf/mpi.c (caf_runtime_error): Remove "error" parameter.
+ Return EXIT_FAILURE instead.
+ (_gfortran_caf_register): Update call to caf_runtime_error.
+ (_gfortran_caf_sync_all): Ditto.
+ (_gfortran_caf_sync_images): Ditto.
+ (_gfortran_caf_error_stop_str): Use "exit(EXIT_FAILURE)".
+
2011-07-13 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/49296
caf_static_t *caf_static_list = NULL;
+/* Keep in sync with single.c. */
static void
-caf_runtime_error (int error, const char *message, ...)
+caf_runtime_error (const char *message, ...)
{
va_list ap;
fprintf (stderr, "Fortran runtime error on image %d: ", caf_this_image);
/* FIXME: Shutdown the Fortran RTL to flush the buffer. PR 43849. */
/* FIXME: Do some more effort than just MPI_ABORT. */
- MPI_Abort (MPI_COMM_WORLD, error);
+ MPI_Abort (MPI_COMM_WORLD, EXIT_FAILURE);
/* Should be unreachable, but to make sure also call exit. */
- exit (2);
+ exit (EXIT_FAILURE);
}
}
}
else
- caf_runtime_error (caf_is_finalized ? STAT_STOPPED_IMAGE : 1, msg);
+ caf_runtime_error (msg);
}
return NULL;
memset (&errmsg[len], ' ', errmsg_len-len);
}
else
- caf_runtime_error (caf_is_finalized ? STAT_STOPPED_IMAGE : ierr, msg);
+ caf_runtime_error (msg);
}
}
memset (&errmsg[len], ' ', errmsg_len-len);
}
else
- caf_runtime_error (caf_is_finalized ? STAT_STOPPED_IMAGE : ierr, msg);
+ caf_runtime_error (msg);
}
}
#include <stdio.h> /* For fputs and fprintf. */
#include <stdlib.h> /* For exit and malloc. */
#include <string.h> /* For memcpy and memset. */
+#include <stdarg.h> /* For variadic arguments. */
/* Define GFC_CAF_CHECK to enable run-time checking. */
/* #define GFC_CAF_CHECK 1 */
caf_static_t *caf_static_list = NULL;
+/* Keep in sync with mpi.c. */
+static void
+caf_runtime_error (const char *message, ...)
+{
+ va_list ap;
+ fprintf (stderr, "Fortran runtime error: ");
+ va_start (ap, message);
+ fprintf (stderr, message, ap);
+ va_end (ap);
+ fprintf (stderr, "\n");
+
+ /* FIXME: Shutdown the Fortran RTL to flush the buffer. PR 43849. */
+ exit (EXIT_FAILURE);
+}
+
void
_gfortran_caf_init (int *argc __attribute__ ((unused)),
char ***argv __attribute__ ((unused)),
if (unlikely (local == NULL || token == NULL))
{
+ const char msg[] = "Failed to allocate coarray";
if (stat)
{
*stat = 1;
if (errmsg_len > 0)
{
- const char msg[] = "Failed to allocate coarray";
int len = ((int) sizeof (msg) > errmsg_len) ? errmsg_len
: (int) sizeof (msg);
memcpy (errmsg, msg, len);
return NULL;
}
else
- {
- fprintf (stderr, "ERROR: Failed to allocate coarray");
- exit (1);
- }
+ caf_runtime_error (msg);
}
if (stat)
{
fprintf (stderr, "COARRAY ERROR: Invalid image index %d to SYNC "
"IMAGES", images[i]);
- exit (1);
+ exit (EXIT_FAILURE);
}
#endif