From 07830d05a7212e348fb065750c6f9ac042e187d6 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Wed, 3 Jul 2019 09:39:02 +0900 Subject: [PATCH] fortran/mpif-h: correctly handle array_of_errcodes in ompi_comm_spawn[_multiple]_f Since array_of_errcodes is only allocated when MPI_ERRCODES_IGNORE is not used, it should not be cleaned when MPI_ERRCODES_IGNORE is used. Correctly allocate array_of_errcodes with the right size (e.g. maxprocs). Thanks Gyevi-Nagy Laszlo for reporting this issue. Signed-off-by: Gilles Gouaillardet --- ompi/mpi/fortran/mpif-h/comm_spawn_f.c | 13 +++++------ .../fortran/mpif-h/comm_spawn_multiple_f.c | 22 +++++++++---------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/ompi/mpi/fortran/mpif-h/comm_spawn_f.c b/ompi/mpi/fortran/mpif-h/comm_spawn_f.c index 17c290e561..e866a9f97d 100644 --- a/ompi/mpi/fortran/mpif-h/comm_spawn_f.c +++ b/ompi/mpi/fortran/mpif-h/comm_spawn_f.c @@ -10,8 +10,8 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2010-2018 Cisco Systems, Inc. All rights reserved - * Copyright (c) 2015-2017 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2015-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -76,7 +76,7 @@ void ompi_comm_spawn_f(char *command, char *argv, MPI_Fint *maxprocs, { MPI_Comm c_comm, c_new_comm; MPI_Info c_info; - int size, c_ierr; + int c_ierr; int *c_errs; char **c_argv; char *c_command; @@ -84,7 +84,6 @@ void ompi_comm_spawn_f(char *command, char *argv, MPI_Fint *maxprocs, c_comm = PMPI_Comm_f2c(*comm); c_info = PMPI_Info_f2c(*info); - PMPI_Comm_size(c_comm, &size); ompi_fortran_string_f2c(command, cmd_len, &c_command); /* It's allowed to ignore the errcodes */ @@ -92,7 +91,7 @@ void ompi_comm_spawn_f(char *command, char *argv, MPI_Fint *maxprocs, if (OMPI_IS_FORTRAN_ERRCODES_IGNORE(array_of_errcodes)) { c_errs = MPI_ERRCODES_IGNORE; } else { - OMPI_ARRAY_FINT_2_INT_ALLOC(array_of_errcodes, size); + OMPI_ARRAY_FINT_2_INT_ALLOC(array_of_errcodes, OMPI_FINT_2_INT(*maxprocs)); c_errs = OMPI_ARRAY_NAME_CONVERT(array_of_errcodes); } @@ -119,9 +118,7 @@ void ompi_comm_spawn_f(char *command, char *argv, MPI_Fint *maxprocs, opal_argv_free(c_argv); } if (!OMPI_IS_FORTRAN_ERRCODES_IGNORE(array_of_errcodes)) { - OMPI_ARRAY_INT_2_FINT(array_of_errcodes, size); - } else { - OMPI_ARRAY_FINT_2_INT_CLEANUP(array_of_errcodes); + OMPI_ARRAY_INT_2_FINT(array_of_errcodes, OMPI_FINT_2_INT(*maxprocs)); } } diff --git a/ompi/mpi/fortran/mpif-h/comm_spawn_multiple_f.c b/ompi/mpi/fortran/mpif-h/comm_spawn_multiple_f.c index c4b2d4270d..93eda2f341 100644 --- a/ompi/mpi/fortran/mpif-h/comm_spawn_multiple_f.c +++ b/ompi/mpi/fortran/mpif-h/comm_spawn_multiple_f.c @@ -10,8 +10,8 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2010-2018 Cisco Systems, Inc. All rights reserved - * Copyright (c) 2015-2017 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2015-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * Copyright (c) 2016 Los Alamos National Security, LLC. All rights * reserved. * $COPYRIGHT$ @@ -82,25 +82,29 @@ void ompi_comm_spawn_multiple_f(MPI_Fint *count, char *array_commands, { MPI_Comm c_comm, c_new_comm; MPI_Info *c_info; - int size, array_size, i, c_ierr; + int array_size, i, c_ierr; int *c_errs; char **c_array_commands; char ***c_array_argv; + int maxprocs; OMPI_ARRAY_NAME_DECL(array_maxprocs); OMPI_ARRAY_NAME_DECL(array_errcds); c_comm = PMPI_Comm_f2c(*comm); - PMPI_Comm_size(c_comm, &size); - array_size = OMPI_FINT_2_INT(*count); + OMPI_ARRAY_FINT_2_INT(array_maxprocs, array_size); /* It's allowed to ignore the errcodes */ if (OMPI_IS_FORTRAN_ERRCODES_IGNORE(array_errcds)) { c_errs = MPI_ERRCODES_IGNORE; } else { - OMPI_ARRAY_FINT_2_INT_ALLOC(array_errcds, size); + maxprocs = 0; + for (i=0; i