Skip to content

Commit c2d35aa

Browse files
Merge pull request #6790 from ggouaillardet/topic/ompi_comm_spawn_f
fortran/mpif-h: correctly handle array_of_errcodes in ompi_comm_spawn…
2 parents 5d51b23 + 07830d0 commit c2d35aa

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

ompi/mpi/fortran/mpif-h/comm_spawn_f.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
1212
* Copyright (c) 2010-2018 Cisco Systems, Inc. All rights reserved
13-
* Copyright (c) 2015-2017 Research Organization for Information Science
14-
* and Technology (RIST). All rights reserved.
13+
* Copyright (c) 2015-2019 Research Organization for Information Science
14+
* and Technology (RIST). All rights reserved.
1515
* $COPYRIGHT$
1616
*
1717
* Additional copyrights may follow
@@ -76,23 +76,22 @@ void ompi_comm_spawn_f(char *command, char *argv, MPI_Fint *maxprocs,
7676
{
7777
MPI_Comm c_comm, c_new_comm;
7878
MPI_Info c_info;
79-
int size, c_ierr;
79+
int c_ierr;
8080
int *c_errs;
8181
char **c_argv;
8282
char *c_command;
8383
OMPI_ARRAY_NAME_DECL(array_of_errcodes);
8484

8585
c_comm = PMPI_Comm_f2c(*comm);
8686
c_info = PMPI_Info_f2c(*info);
87-
PMPI_Comm_size(c_comm, &size);
8887
ompi_fortran_string_f2c(command, cmd_len, &c_command);
8988

9089
/* It's allowed to ignore the errcodes */
9190

9291
if (OMPI_IS_FORTRAN_ERRCODES_IGNORE(array_of_errcodes)) {
9392
c_errs = MPI_ERRCODES_IGNORE;
9493
} else {
95-
OMPI_ARRAY_FINT_2_INT_ALLOC(array_of_errcodes, size);
94+
OMPI_ARRAY_FINT_2_INT_ALLOC(array_of_errcodes, OMPI_FINT_2_INT(*maxprocs));
9695
c_errs = OMPI_ARRAY_NAME_CONVERT(array_of_errcodes);
9796
}
9897

@@ -119,9 +118,7 @@ void ompi_comm_spawn_f(char *command, char *argv, MPI_Fint *maxprocs,
119118
opal_argv_free(c_argv);
120119
}
121120
if (!OMPI_IS_FORTRAN_ERRCODES_IGNORE(array_of_errcodes)) {
122-
OMPI_ARRAY_INT_2_FINT(array_of_errcodes, size);
123-
} else {
124-
OMPI_ARRAY_FINT_2_INT_CLEANUP(array_of_errcodes);
121+
OMPI_ARRAY_INT_2_FINT(array_of_errcodes, OMPI_FINT_2_INT(*maxprocs));
125122
}
126123
}
127124

ompi/mpi/fortran/mpif-h/comm_spawn_multiple_f.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
1212
* Copyright (c) 2010-2018 Cisco Systems, Inc. All rights reserved
13-
* Copyright (c) 2015-2017 Research Organization for Information Science
14-
* and Technology (RIST). All rights reserved.
13+
* Copyright (c) 2015-2019 Research Organization for Information Science
14+
* and Technology (RIST). All rights reserved.
1515
* Copyright (c) 2016 Los Alamos National Security, LLC. All rights
1616
* reserved.
1717
* $COPYRIGHT$
@@ -82,25 +82,29 @@ void ompi_comm_spawn_multiple_f(MPI_Fint *count, char *array_commands,
8282
{
8383
MPI_Comm c_comm, c_new_comm;
8484
MPI_Info *c_info;
85-
int size, array_size, i, c_ierr;
85+
int array_size, i, c_ierr;
8686
int *c_errs;
8787
char **c_array_commands;
8888
char ***c_array_argv;
89+
int maxprocs;
8990
OMPI_ARRAY_NAME_DECL(array_maxprocs);
9091
OMPI_ARRAY_NAME_DECL(array_errcds);
9192

9293
c_comm = PMPI_Comm_f2c(*comm);
9394

94-
PMPI_Comm_size(c_comm, &size);
95-
9695
array_size = OMPI_FINT_2_INT(*count);
96+
OMPI_ARRAY_FINT_2_INT(array_maxprocs, array_size);
9797

9898
/* It's allowed to ignore the errcodes */
9999

100100
if (OMPI_IS_FORTRAN_ERRCODES_IGNORE(array_errcds)) {
101101
c_errs = MPI_ERRCODES_IGNORE;
102102
} else {
103-
OMPI_ARRAY_FINT_2_INT_ALLOC(array_errcds, size);
103+
maxprocs = 0;
104+
for (i=0; i<array_size; i++) {
105+
maxprocs += OMPI_ARRAY_NAME_CONVERT(array_maxprocs)[i];
106+
}
107+
OMPI_ARRAY_FINT_2_INT_ALLOC(array_errcds, maxprocs);
104108
c_errs = OMPI_ARRAY_NAME_CONVERT(array_errcds);
105109
}
106110

@@ -113,8 +117,6 @@ void ompi_comm_spawn_multiple_f(MPI_Fint *count, char *array_commands,
113117
argv_string_len, &c_array_argv);
114118
}
115119

116-
OMPI_ARRAY_FINT_2_INT(array_maxprocs, array_size);
117-
118120
ompi_fortran_argv_count_f2c(array_commands, array_size, cmd_string_len,
119121
cmd_string_len, &c_array_commands);
120122

@@ -138,9 +140,7 @@ void ompi_comm_spawn_multiple_f(MPI_Fint *count, char *array_commands,
138140
}
139141

140142
if (!OMPI_IS_FORTRAN_ERRCODES_IGNORE(array_errcds)) {
141-
OMPI_ARRAY_INT_2_FINT(array_errcds, size);
142-
} else {
143-
OMPI_ARRAY_FINT_2_INT_CLEANUP(array_errcds);
143+
OMPI_ARRAY_INT_2_FINT(array_errcds, maxprocs);
144144
}
145145
OMPI_ARRAY_FINT_2_INT_CLEANUP(array_maxprocs);
146146

0 commit comments

Comments
 (0)