diff --git a/src/mpi/c/comm_f2c.c b/src/mpi/c/comm_f2c.c index 74b2f98ca8..03f72fa70f 100644 --- a/src/mpi/c/comm_f2c.c +++ b/src/mpi/c/comm_f2c.c @@ -27,11 +27,14 @@ MPI_Comm MPI_Comm_f2c(MPI_Fint comm) if ( MPI_PARAM_CHECK ) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + } - if ( 0 > o_index || - o_index >= ompi_pointer_array_get_size(&ompi_mpi_communicators)) { - return MPI_COMM_NULL; - } + /* Per MPI-2:4.12.4, do not invoke an error handler if we get an + invalid fortran handle */ + + if ( 0 > o_index || + o_index >= ompi_pointer_array_get_size(&ompi_mpi_communicators)) { + return MPI_COMM_NULL; } return ompi_mpi_communicators.addr[o_index]; diff --git a/src/mpi/c/errhandler_f2c.c b/src/mpi/c/errhandler_f2c.c index 6de88557db..316411ceb9 100644 --- a/src/mpi/c/errhandler_f2c.c +++ b/src/mpi/c/errhandler_f2c.c @@ -22,20 +22,22 @@ static const char FUNC_NAME[] = "MPI_Errhandler_f2c"; MPI_Errhandler MPI_Errhandler_f2c(MPI_Fint errhandler_f) { - size_t eh_index = (size_t) errhandler_f; + size_t eh_index = (size_t) errhandler_f; - /* Error checking */ + /* Error checking */ - if (MPI_PARAM_CHECK) { - OMPI_ERR_INIT_FINALIZE(FUNC_NAME); - - if (0 > eh_index || - eh_index >= ompi_pointer_array_get_size(ompi_errhandler_f_to_c_table)) { - return MPI_ERRHANDLER_NULL; + if (MPI_PARAM_CHECK) { + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + } + + /* Per MPI-2:4.12.4, do not invoke an error handler if we get an + invalid fortran handle */ + + if (eh_index < 0 || + eh_index >= + ompi_pointer_array_get_size(ompi_errhandler_f_to_c_table)) { + return MPI_ERRHANDLER_NULL; } - } - /* All done */ - - return ompi_errhandler_f_to_c_table->addr[eh_index]; + return ompi_errhandler_f_to_c_table->addr[eh_index]; } diff --git a/src/mpi/c/file_f2c.c b/src/mpi/c/file_f2c.c index 62c47e6dfd..7215237ffe 100644 --- a/src/mpi/c/file_f2c.c +++ b/src/mpi/c/file_f2c.c @@ -27,12 +27,15 @@ MPI_File MPI_File_f2c(MPI_Fint file_f) if (MPI_PARAM_CHECK) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); - if (file_index < 0 || - file_index >= ompi_pointer_array_get_size(&ompi_file_f_to_c_table)) { - (void) OMPI_ERRHANDLER_INVOKE(MPI_FILE_NULL, MPI_ERR_FILE, - FUNC_NAME); - return MPI_FILE_NULL; - } + } + + /* Per MPI-2:4.12.4, do not invoke an error handler if we get an + invalid fortran handle */ + + if (file_index < 0 || + file_index >= + ompi_pointer_array_get_size(&ompi_file_f_to_c_table)) { + return MPI_FILE_NULL; } return ompi_file_f_to_c_table.addr[file_index]; diff --git a/src/mpi/c/group_f2c.c b/src/mpi/c/group_f2c.c index 24a00908ca..153ac464b7 100644 --- a/src/mpi/c/group_f2c.c +++ b/src/mpi/c/group_f2c.c @@ -28,19 +28,17 @@ MPI_Group MPI_Group_f2c(MPI_Fint group_f) group_index = (size_t) group_f; - /* error checks */ if (MPI_PARAM_CHECK) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); - if (0 > group_index) { - (void) OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_GROUP, - FUNC_NAME); - return MPI_GROUP_NULL; - } - if (group_index >= ompi_group_f_to_c_table->size) { - (void) OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_GROUP, - FUNC_NAME); - return MPI_GROUP_NULL; - } + } + + /* Per MPI-2:4.12.4, do not invoke an error handler if we get an + invalid fortran handle */ + + if (group_index < 0 || + group_index >= + ompi_pointer_array_get_size(ompi_group_f_to_c_table)) { + return MPI_GROUP_NULL; } group_c = ompi_group_f_to_c_table->addr[group_index]; diff --git a/src/mpi/c/info_f2c.c b/src/mpi/c/info_f2c.c index 3838a88a08..57b800a1ec 100644 --- a/src/mpi/c/info_f2c.c +++ b/src/mpi/c/info_f2c.c @@ -36,14 +36,16 @@ MPI_Info MPI_Info_f2c(MPI_Fint info) if (MPI_PARAM_CHECK) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); - if (info_index < 0 || - info_index >= ompi_pointer_array_get_size(&ompi_info_f_to_c_table)) { - (void) OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_INFO, - FUNC_NAME); - return MPI_INFO_NULL; - } } - /* return the index */ + /* Per MPI-2:4.12.4, do not invoke an error handler if we get an + invalid fortran handle */ + + if (info_index < 0 || + info_index >= + ompi_pointer_array_get_size(&ompi_info_f_to_c_table)) { + return MPI_INFO_NULL; + } + return ompi_info_f_to_c_table.addr[info_index]; } diff --git a/src/mpi/c/op_f2c.c b/src/mpi/c/op_f2c.c index b7ba8e64a4..80e21cf401 100644 --- a/src/mpi/c/op_f2c.c +++ b/src/mpi/c/op_f2c.c @@ -23,19 +23,22 @@ static const char FUNC_NAME[] = "MPI_Op_f2c"; MPI_Op MPI_Op_f2c(MPI_Fint op_f) { - size_t o_index = (size_t) op_f; + size_t op_index = (size_t) op_f; - /* Error checking */ + /* Error checking */ - if (MPI_PARAM_CHECK) { - OMPI_ERR_INIT_FINALIZE(FUNC_NAME); - if (0 > o_index || - o_index >= ompi_pointer_array_get_size(ompi_op_f_to_c_table)) { - return MPI_OP_NULL; + if (MPI_PARAM_CHECK) { + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + } + + /* Per MPI-2:4.12.4, do not invoke an error handler if we get an + invalid fortran handle */ + + if (op_index < 0 || + op_index >= + ompi_pointer_array_get_size(ompi_op_f_to_c_table)) { + return MPI_OP_NULL; } - } - /* All done */ - - return ompi_op_f_to_c_table->addr[o_index]; + return ompi_op_f_to_c_table->addr[op_index]; } diff --git a/src/mpi/c/request_f2c.c b/src/mpi/c/request_f2c.c index 3615172b86..3af1c494a2 100644 --- a/src/mpi/c/request_f2c.c +++ b/src/mpi/c/request_f2c.c @@ -23,26 +23,22 @@ static const char FUNC_NAME[] = "MPI_Request_f2c"; MPI_Request MPI_Request_f2c(MPI_Fint request) { - /* local variables */ - ompi_request_t *request_c; size_t request_index; request_index = (size_t) request; - /* Error checks */ if (MPI_PARAM_CHECK) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); - if (0 > request_index) { - (void)OMPI_ERRHANDLER_INVOKE( MPI_COMM_WORLD, MPI_ERR_REQUEST, - FUNC_NAME); - } - } - if (request_index >= ompi_req_f_to_c_table->size) { - (void) OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_REQUEST, - FUNC_NAME); - return MPI_REQUEST_NULL; } - request_c = ompi_req_f_to_c_table->addr[request_index]; - return (MPI_Request) request_c; + /* Per MPI-2:4.12.4, do not invoke an error handler if we get an + invalid fortran handle */ + + if (request_index < 0 || + request_index >= + ompi_pointer_array_get_size(ompi_req_f_to_c_table)) { + return MPI_REQUEST_NULL; + } + + return ompi_req_f_to_c_table->addr[request_index]; } diff --git a/src/mpi/c/type_f2c.c b/src/mpi/c/type_f2c.c index 1c0a45ab91..7006d4055b 100644 --- a/src/mpi/c/type_f2c.c +++ b/src/mpi/c/type_f2c.c @@ -23,14 +23,21 @@ static const char FUNC_NAME[] = "MPI_Type_f2c"; MPI_Datatype MPI_Type_f2c(MPI_Fint datatype) { - /* check the arguments */ + size_t datatype_index = (size_t) datatype; + if (MPI_PARAM_CHECK) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); - if (0 > datatype || datatype >= ompi_pointer_array_get_size(ompi_datatype_f_to_c_table)) { - return MPI_DATATYPE_NULL; - } } - /* return the index */ + + /* Per MPI-2:4.12.4, do not invoke an error handler if we get an + invalid fortran handle */ + + if (datatype_index < 0 || + datatype_index >= + ompi_pointer_array_get_size(ompi_datatype_f_to_c_table)) { + return MPI_DATATYPE_NULL; + } + return ompi_datatype_f_to_c_table->addr[datatype]; } diff --git a/src/mpi/c/win_f2c.c b/src/mpi/c/win_f2c.c index e7a41847cc..4dc2af3c80 100644 --- a/src/mpi/c/win_f2c.c +++ b/src/mpi/c/win_f2c.c @@ -26,6 +26,9 @@ MPI_Win MPI_Win_f2c(MPI_Fint win) OMPI_ERR_INIT_FINALIZE(FUNC_NAME); } + /* NOTE: Be sure to see the other *f2c functions before implementing + this one -- they should all be the same! */ + /* This function is not yet implemented */ return (MPI_Win) OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_OTHER, FUNC_NAME);