2004-03-20 04:54:18 +03:00
|
|
|
/*
|
2004-03-19 09:12:43 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "ompi_config.h"
|
2004-03-19 09:12:43 +03:00
|
|
|
|
|
|
|
#include "communicator/communicator.h"
|
|
|
|
#include "win/win.h"
|
|
|
|
#include "file/file.h"
|
|
|
|
#include "errhandler/errhandler.h"
|
|
|
|
#include "errhandler/errhandler_predefined.h"
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "class/ompi_pointer_array.h"
|
2004-03-19 09:12:43 +03:00
|
|
|
|
|
|
|
|
2004-03-19 22:01:09 +03:00
|
|
|
/*
|
|
|
|
* Table for Fortran <-> C errhandler handle conversion
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_pointer_array_t *ompi_errhandler_f_to_c_table;
|
2004-03-19 09:12:43 +03:00
|
|
|
|
2004-03-19 22:01:09 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Class information
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
static void ompi_errhandler_construct(ompi_errhandler_t *eh);
|
|
|
|
static void ompi_errhandler_destruct(ompi_errhandler_t *eh);
|
2004-03-19 09:12:43 +03:00
|
|
|
|
|
|
|
|
2004-04-21 02:17:20 +04:00
|
|
|
/*
|
|
|
|
* Class instance
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
OBJ_CLASS_INSTANCE(ompi_errhandler_t, ompi_object_t, ompi_errhandler_construct,
|
|
|
|
ompi_errhandler_destruct);
|
2004-03-19 09:12:43 +03:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* MPI_ERRHANDLER_NULL
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_errhandler_t ompi_mpi_errhandler_null = {
|
2004-03-19 09:12:43 +03:00
|
|
|
{ NULL, 0 },
|
|
|
|
|
|
|
|
"MPI_ERRHANDLER_NULL",
|
2004-07-27 02:24:56 +04:00
|
|
|
OMPI_ERRHANDLER_TYPE_COMM,
|
2004-03-19 21:01:03 +03:00
|
|
|
true,
|
2004-03-19 09:12:43 +03:00
|
|
|
false,
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* MPI_ERRORS_ARE_FATAL
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_errhandler_t ompi_mpi_errors_are_fatal = {
|
2004-03-19 09:12:43 +03:00
|
|
|
{ NULL, 0 },
|
|
|
|
|
|
|
|
"MPI_ERRORS_ARE_FATAL",
|
2004-07-27 02:24:56 +04:00
|
|
|
OMPI_ERRHANDLER_TYPE_COMM,
|
2004-03-19 21:01:03 +03:00
|
|
|
true,
|
2004-03-19 09:12:43 +03:00
|
|
|
false,
|
2004-06-07 19:33:53 +04:00
|
|
|
{ ompi_mpi_errors_are_fatal_handler },
|
2004-03-19 09:12:43 +03:00
|
|
|
-1
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* MPI_ERRORS_RETURN
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_errhandler_t ompi_mpi_errors_return = {
|
2004-03-19 09:12:43 +03:00
|
|
|
{ NULL, 0 },
|
|
|
|
|
2004-07-27 02:24:56 +04:00
|
|
|
"MPI_ERRORS_RETURN",
|
|
|
|
OMPI_ERRHANDLER_TYPE_COMM,
|
2004-03-19 21:01:03 +03:00
|
|
|
true,
|
2004-03-19 09:12:43 +03:00
|
|
|
false,
|
2004-06-07 19:33:53 +04:00
|
|
|
{ ompi_mpi_errors_return_handler },
|
2004-03-19 09:12:43 +03:00
|
|
|
-1
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2004-06-07 19:33:53 +04:00
|
|
|
* Initialize OMPI errhandler infrastructure
|
2004-03-19 09:12:43 +03:00
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_errhandler_init(void)
|
2004-03-19 09:12:43 +03:00
|
|
|
{
|
2004-06-07 19:33:53 +04:00
|
|
|
/* initialize ompi_errhandler_f_to_c_table */
|
2004-03-19 09:12:43 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_errhandler_f_to_c_table = OBJ_NEW(ompi_pointer_array_t);
|
|
|
|
if (NULL == ompi_errhandler_f_to_c_table){
|
|
|
|
return OMPI_ERROR;
|
2004-03-19 09:12:43 +03:00
|
|
|
}
|
|
|
|
|
2004-05-01 00:11:07 +04:00
|
|
|
/* Initialize the predefined error handlers */
|
2004-06-07 19:33:53 +04:00
|
|
|
OBJ_CONSTRUCT( &ompi_mpi_errhandler_null, ompi_errhandler_t );
|
|
|
|
if( ompi_mpi_errhandler_null.eh_f_to_c_index != OMPI_ERRHANDLER_NULL_FORTRAN )
|
|
|
|
return OMPI_ERROR;
|
2004-03-19 09:12:43 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
OBJ_CONSTRUCT( &ompi_mpi_errors_are_fatal, ompi_errhandler_t );
|
|
|
|
if( ompi_mpi_errors_are_fatal.eh_f_to_c_index != OMPI_ERRORS_ARE_FATAL_FORTRAN )
|
|
|
|
return OMPI_ERROR;
|
2004-03-19 09:12:43 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
OBJ_CONSTRUCT( &ompi_mpi_errors_return, ompi_errhandler_t );
|
|
|
|
if( ompi_mpi_errors_return.eh_f_to_c_index != OMPI_ERRORS_RETURN_FORTRAN )
|
|
|
|
return OMPI_ERROR;
|
2004-03-19 09:12:43 +03:00
|
|
|
|
|
|
|
/* All done */
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_SUCCESS;
|
2004-03-19 09:12:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clean up the errorhandler resources
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_errhandler_finalize(void)
|
2004-03-19 09:12:43 +03:00
|
|
|
{
|
|
|
|
/* Remove errhandler F2C table */
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
OBJ_RELEASE(ompi_errhandler_f_to_c_table);
|
2004-03-19 09:12:43 +03:00
|
|
|
|
|
|
|
/* All done */
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_SUCCESS;
|
2004-03-26 08:00:29 +03:00
|
|
|
}
|
2004-03-19 20:29:39 +03:00
|
|
|
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_errhandler_t *ompi_errhandler_create(ompi_errhandler_type_t object_type,
|
|
|
|
ompi_errhandler_fortran_handler_fn_t *func)
|
2004-03-19 20:29:39 +03:00
|
|
|
{
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_errhandler_t *new_errhandler;
|
2004-03-19 20:29:39 +03:00
|
|
|
|
|
|
|
/* Create a new object and ensure that it's valid */
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
new_errhandler = OBJ_NEW(ompi_errhandler_t);
|
2004-03-19 20:29:39 +03:00
|
|
|
if (NULL == new_errhandler) {
|
2004-06-07 19:33:53 +04:00
|
|
|
if (OMPI_ERROR == new_errhandler->eh_f_to_c_index) {
|
2004-03-19 20:29:39 +03:00
|
|
|
OBJ_RELEASE(new_errhandler);
|
|
|
|
new_errhandler = NULL;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* The new object is valid -- initialize it. If this is being
|
|
|
|
created from fortran, the fortran MPI API wrapper function
|
|
|
|
will override the eh_fortran_field directly. We cast the
|
|
|
|
function pointer type to the fortran type arbitrarily -- it
|
|
|
|
only has to be a function pointer in order to store properly,
|
|
|
|
it doesn't matter what type it is (we'll cast it to the Right
|
|
|
|
type when we *use* it). */
|
|
|
|
|
|
|
|
new_errhandler->eh_mpi_object_type = object_type;
|
2004-04-21 03:10:44 +04:00
|
|
|
new_errhandler->eh_is_intrinsic = false;
|
2004-03-19 20:29:39 +03:00
|
|
|
new_errhandler->eh_fortran_function = false;
|
|
|
|
new_errhandler->eh_func.fort_fn = func;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* All done */
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_SUCCESS;
|
2004-03-19 20:29:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* Static functions
|
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Errhandler constructor
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
static void ompi_errhandler_construct(ompi_errhandler_t *new_errhandler)
|
2004-03-19 20:29:39 +03:00
|
|
|
{
|
|
|
|
int ret_val;
|
|
|
|
|
|
|
|
/* assign entry in fortran <-> c translation array */
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ret_val = ompi_pointer_array_add(ompi_errhandler_f_to_c_table,
|
2004-03-19 20:29:39 +03:00
|
|
|
new_errhandler);
|
|
|
|
new_errhandler->eh_f_to_c_index = ret_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Errhandler destructor
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
static void ompi_errhandler_destruct(ompi_errhandler_t *errhandler)
|
2004-03-19 20:29:39 +03:00
|
|
|
{
|
2004-06-07 19:33:53 +04:00
|
|
|
/* reset the ompi_errhandler_f_to_c_table entry - make sure that the
|
2004-03-19 20:29:39 +03:00
|
|
|
entry is in the table */
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
if (NULL!= ompi_pointer_array_get_item(ompi_errhandler_f_to_c_table,
|
2004-03-19 20:29:39 +03:00
|
|
|
errhandler->eh_f_to_c_index)) {
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_pointer_array_set_item(ompi_errhandler_f_to_c_table,
|
2004-03-19 20:29:39 +03:00
|
|
|
errhandler->eh_f_to_c_index, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|