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