From fbb484dea24a53dc23d539d188260c2a8a254299 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Mon, 21 Aug 2006 19:35:33 +0000 Subject: [PATCH] MPI_COMM_GET_NAME had the compiler-added extra string length parameter (but didn't use it), but MPI_TYPE_GET_NAME and MPI_WIN_GET_NAME did not. This commit changes all three functions to pass the compile-added string length parameter to clear out the remainder of the string with spaces (i.e., the rest of the string that was not set with the name). This is what was done in LAM/MPI, and apparently what was done in Sun's MPI, because the test that Rolf attached now passes. Fixes trac:274. This commit was SVN r11301. The following Trac tickets were found above: Ticket 274 --> https://svn.open-mpi.org/trac/ompi/ticket/274 --- ompi/mpi/f77/comm_get_name_f.c | 4 ++-- ompi/mpi/f77/prototypes_mpi.h | 5 +++-- ompi/mpi/f77/type_get_name_f.c | 30 +++++++++++++++--------------- ompi/mpi/f77/win_get_name_f.c | 30 +++++++++++++++--------------- 4 files changed, 35 insertions(+), 34 deletions(-) diff --git a/ompi/mpi/f77/comm_get_name_f.c b/ompi/mpi/f77/comm_get_name_f.c index 2f90fbbd66..d9b5ff6aa6 100644 --- a/ompi/mpi/f77/comm_get_name_f.c +++ b/ompi/mpi/f77/comm_get_name_f.c @@ -9,6 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -70,8 +71,7 @@ void mpi_comm_get_name_f(MPI_Fint *comm, char *comm_name, err = MPI_Comm_get_name(c_comm, c_name, &c_len); if (MPI_SUCCESS == err) { - ompi_fortran_string_c2f(c_name, comm_name, - OMPI_FINT_2_INT(*resultlen)); + ompi_fortran_string_c2f(c_name, comm_name, name_len); *resultlen = OMPI_INT_2_FINT(c_len); *ierr = OMPI_INT_2_FINT(MPI_SUCCESS); } else { diff --git a/ompi/mpi/f77/prototypes_mpi.h b/ompi/mpi/f77/prototypes_mpi.h index f432dcfc85..8dbf91d850 100644 --- a/ompi/mpi/f77/prototypes_mpi.h +++ b/ompi/mpi/f77/prototypes_mpi.h @@ -9,6 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -295,7 +296,7 @@ PN(void, mpi_type_get_attr, MPI_TYPE_GET_ATTR, (MPI_Fint *type, MPI_Fint *type_k PN(void, mpi_type_get_contents, MPI_TYPE_GET_CONTENTS, (MPI_Fint *mtype, MPI_Fint *max_integers, MPI_Fint *max_addresses, MPI_Fint *max_datatypes, MPI_Fint *array_of_integers, MPI_Fint *array_of_addresses, MPI_Fint *array_of_datatypes, MPI_Fint *ierr)); PN(void, mpi_type_get_envelope, MPI_TYPE_GET_ENVELOPE, (MPI_Fint *type, MPI_Fint *num_integers, MPI_Fint *num_addresses, MPI_Fint *num_datatypes, MPI_Fint *combiner, MPI_Fint *ierr)); PN(void, mpi_type_get_extent, MPI_TYPE_GET_EXTENT, (MPI_Fint *type, MPI_Aint *lb, MPI_Aint *extent, MPI_Fint *ierr)); -PN(void, mpi_type_get_name, MPI_TYPE_GET_NAME, (MPI_Fint *type, char *type_name, MPI_Fint *resultlen, MPI_Fint *ierr)); +PN(void, mpi_type_get_name, MPI_TYPE_GET_NAME, (MPI_Fint *type, char *type_name, MPI_Fint *resultlen, MPI_Fint *ierr, int name_len)); PN(void, mpi_type_get_true_extent, MPI_TYPE_GET_TRUE_EXTENT, (MPI_Fint *datatype, MPI_Aint *true_lb, MPI_Aint *true_extent, MPI_Fint *ierr)); PN(void, mpi_type_hindexed, MPI_TYPE_HINDEXED, (MPI_Fint *count, MPI_Fint *array_of_blocklengths, MPI_Fint *array_of_displacements, MPI_Fint *oldtype, MPI_Fint *newtype, MPI_Fint *ierr)); PN(void, mpi_type_hvector, MPI_TYPE_HVECTOR, (MPI_Fint *count, MPI_Fint *blocklength, MPI_Fint *stride, MPI_Fint *oldtype, MPI_Fint *newtype, MPI_Fint *ierr)); @@ -327,7 +328,7 @@ PN(void, mpi_win_free_keyval, MPI_WIN_FREE_KEYVAL, (MPI_Fint *win_keyval, MPI_Fi PN(void, mpi_win_get_attr, MPI_WIN_GET_ATTR, (MPI_Fint *win, MPI_Fint *win_keyval, MPI_Aint *attribute_val, MPI_Flogical *flag, MPI_Fint *ierr)); PN(void, mpi_win_get_errhandler, MPI_WIN_GET_ERRHANDLER, (MPI_Fint *win, MPI_Fint *errhandler, MPI_Fint *ierr)); PN(void, mpi_win_get_group, MPI_WIN_GET_GROUP, (MPI_Fint *win, MPI_Fint *group, MPI_Fint *ierr)); -PN(void, mpi_win_get_name, MPI_WIN_GET_NAME, (MPI_Fint *win, char *win_name, MPI_Fint *resultlen, MPI_Fint *ierr)); +PN(void, mpi_win_get_name, MPI_WIN_GET_NAME, (MPI_Fint *win, char *win_name, MPI_Fint *resultlen, MPI_Fint *ierr, int name_len)); PN(void, mpi_win_lock, MPI_WIN_LOCK, (MPI_Fint *lock_type, MPI_Fint *rank, MPI_Fint *assert, MPI_Fint *win, MPI_Fint *ierr)); PN(void, mpi_win_post, MPI_WIN_POST, (MPI_Fint *group, MPI_Fint *assert, MPI_Fint *win, MPI_Fint *ierr)); PN(void, mpi_win_set_attr, MPI_WIN_SET_ATTR, (MPI_Fint *win, MPI_Fint *win_keyval, MPI_Aint *attribute_val, MPI_Fint *ierr)); diff --git a/ompi/mpi/f77/type_get_name_f.c b/ompi/mpi/f77/type_get_name_f.c index c1ab55e7b0..0eaee485f2 100644 --- a/ompi/mpi/f77/type_get_name_f.c +++ b/ompi/mpi/f77/type_get_name_f.c @@ -9,6 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -30,12 +31,12 @@ #pragma weak pmpi_type_get_name__ = mpi_type_get_name_f #elif OMPI_PROFILE_LAYER OMPI_GENERATE_F77_BINDINGS (PMPI_TYPE_GET_NAME, - pmpi_type_get_name, - pmpi_type_get_name_, - pmpi_type_get_name__, - pmpi_type_get_name_f, - (MPI_Fint *type, char *type_name, MPI_Fint *resultlen, MPI_Fint *ierr), - (type, type_name, resultlen, ierr) ) + pmpi_type_get_name, + pmpi_type_get_name_, + pmpi_type_get_name__, + pmpi_type_get_name_f, + (MPI_Fint *type, char *type_name, MPI_Fint *resultlen, MPI_Fint *ierr, int name_len), + (type, type_name, resultlen, ierr, name_len) ) #endif #if OMPI_HAVE_WEAK_SYMBOLS @@ -47,12 +48,12 @@ OMPI_GENERATE_F77_BINDINGS (PMPI_TYPE_GET_NAME, #if ! OMPI_HAVE_WEAK_SYMBOLS && ! OMPI_PROFILE_LAYER OMPI_GENERATE_F77_BINDINGS (MPI_TYPE_GET_NAME, - mpi_type_get_name, - mpi_type_get_name_, - mpi_type_get_name__, - mpi_type_get_name_f, - (MPI_Fint *type, char *type_name, MPI_Fint *resultlen, MPI_Fint *ierr), - (type, type_name, resultlen, ierr) ) + mpi_type_get_name, + mpi_type_get_name_, + mpi_type_get_name__, + mpi_type_get_name_f, + (MPI_Fint *type, char *type_name, MPI_Fint *resultlen, MPI_Fint *ierr, int name_len), + (type, type_name, resultlen, ierr, name_len) ) #endif @@ -60,7 +61,7 @@ OMPI_GENERATE_F77_BINDINGS (MPI_TYPE_GET_NAME, #include "ompi/mpi/f77/profile/defines.h" #endif -void mpi_type_get_name_f(MPI_Fint *type, char *type_name, MPI_Fint *resultlen, MPI_Fint *ierr) +void mpi_type_get_name_f(MPI_Fint *type, char *type_name, MPI_Fint *resultlen, MPI_Fint *ierr, int name_len) { int err, c_len; MPI_Datatype c_type = MPI_Type_f2c(*type); @@ -68,8 +69,7 @@ void mpi_type_get_name_f(MPI_Fint *type, char *type_name, MPI_Fint *resultlen, M err = MPI_Type_get_name(c_type, c_name, &c_len); if (MPI_SUCCESS == err) { - ompi_fortran_string_c2f(c_name, type_name, - OMPI_FINT_2_INT(*resultlen)); + ompi_fortran_string_c2f(c_name, type_name, name_len); *resultlen = OMPI_INT_2_FINT(c_len); *ierr = OMPI_INT_2_FINT(MPI_SUCCESS); } else { diff --git a/ompi/mpi/f77/win_get_name_f.c b/ompi/mpi/f77/win_get_name_f.c index 20704cd961..99a4c50be4 100644 --- a/ompi/mpi/f77/win_get_name_f.c +++ b/ompi/mpi/f77/win_get_name_f.c @@ -9,6 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -31,12 +32,12 @@ #pragma weak pmpi_win_get_name__ = mpi_win_get_name_f #elif OMPI_PROFILE_LAYER OMPI_GENERATE_F77_BINDINGS (PMPI_WIN_GET_NAME, - pmpi_win_get_name, - pmpi_win_get_name_, - pmpi_win_get_name__, - pmpi_win_get_name_f, - (MPI_Fint *win, char *win_name, MPI_Fint *resultlen, MPI_Fint *ierr), - (win, win_name, resultlen, ierr) ) + pmpi_win_get_name, + pmpi_win_get_name_, + pmpi_win_get_name__, + pmpi_win_get_name_f, + (MPI_Fint *win, char *win_name, MPI_Fint *resultlen, MPI_Fint *ierr, int name_len), + (win, win_name, resultlen, ierr, name_len) ) #endif #if OMPI_HAVE_WEAK_SYMBOLS @@ -48,12 +49,12 @@ OMPI_GENERATE_F77_BINDINGS (PMPI_WIN_GET_NAME, #if ! OMPI_HAVE_WEAK_SYMBOLS && ! OMPI_PROFILE_LAYER OMPI_GENERATE_F77_BINDINGS (MPI_WIN_GET_NAME, - mpi_win_get_name, - mpi_win_get_name_, - mpi_win_get_name__, - mpi_win_get_name_f, - (MPI_Fint *win, char *win_name, MPI_Fint *resultlen, MPI_Fint *ierr), - (win, win_name, resultlen, ierr) ) + mpi_win_get_name, + mpi_win_get_name_, + mpi_win_get_name__, + mpi_win_get_name_f, + (MPI_Fint *win, char *win_name, MPI_Fint *resultlen, MPI_Fint *ierr, int name_len), + (win, win_name, resultlen, ierr, name_len) ) #endif @@ -62,7 +63,7 @@ OMPI_GENERATE_F77_BINDINGS (MPI_WIN_GET_NAME, #endif void mpi_win_get_name_f(MPI_Fint *win, char *win_name, - MPI_Fint *resultlen, MPI_Fint *ierr) + MPI_Fint *resultlen, MPI_Fint *ierr, int name_len) { int err, c_len; MPI_Win c_win = MPI_Win_f2c(*win); @@ -70,8 +71,7 @@ void mpi_win_get_name_f(MPI_Fint *win, char *win_name, err = MPI_Win_get_name(c_win, c_name, &c_len); if (MPI_SUCCESS == err) { - ompi_fortran_string_c2f(c_name, win_name, - OMPI_FINT_2_INT(*resultlen)); + ompi_fortran_string_c2f(c_name, win_name, name_len); *resultlen = OMPI_INT_2_FINT(c_len); *ierr = OMPI_INT_2_FINT(MPI_SUCCESS); } else {