Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix fortran mpi_type_struct and mpi_type_create_struct functions
authordegomme <augustin.degomme@unibas.ch>
Fri, 10 Jul 2015 13:32:53 +0000 (15:32 +0200)
committerdegomme <augustin.degomme@unibas.ch>
Thu, 16 Jul 2015 09:11:10 +0000 (11:11 +0200)
src/smpi/smpi_f77.c

index b044802..405e6c8 100644 (file)
@@ -1357,18 +1357,30 @@ void mpi_type_create_indexed_block_ (int* count, int* blocklength, int* indices,
 
 void mpi_type_struct_ (int* count, int* blocklens, MPI_Aint* indices, int* old_types, int*  newtype, int* ierr) {
   MPI_Datatype tmp;
 
 void mpi_type_struct_ (int* count, int* blocklens, MPI_Aint* indices, int* old_types, int*  newtype, int* ierr) {
   MPI_Datatype tmp;
-  *ierr = MPI_Type_struct(*count, blocklens, indices, (MPI_Datatype*)old_types, &tmp);
+  int i=0;
+  MPI_Datatype* types = (MPI_Datatype*)xbt_malloc(*count*sizeof(MPI_Datatype));
+  for(i=0; i< *count; i++){
+    types[i] = smpi_type_f2c(old_types[i]);
+  }
+  *ierr = MPI_Type_struct(*count, blocklens, indices, types, &tmp);
   if(*ierr == MPI_SUCCESS) {
     *newtype = smpi_type_c2f(tmp);
   }
   if(*ierr == MPI_SUCCESS) {
     *newtype = smpi_type_c2f(tmp);
   }
+  xbt_free(types);
 }
 
 void mpi_type_create_struct_ (int* count, int* blocklens, MPI_Aint* indices, int*  old_types, int*  newtype, int* ierr) {
   MPI_Datatype tmp;
 }
 
 void mpi_type_create_struct_ (int* count, int* blocklens, MPI_Aint* indices, int*  old_types, int*  newtype, int* ierr) {
   MPI_Datatype tmp;
-  *ierr = MPI_Type_create_struct(*count, blocklens, indices, (MPI_Datatype*)old_types, &tmp);
+  int i=0;
+  MPI_Datatype* types = (MPI_Datatype*)xbt_malloc(*count*sizeof(MPI_Datatype));
+  for(i=0; i< *count; i++){
+    types[i] = smpi_type_f2c(old_types[i]);
+  }
+  *ierr = MPI_Type_create_struct(*count, blocklens, indices, types, &tmp);
   if(*ierr == MPI_SUCCESS) {
     *newtype = smpi_type_c2f(tmp);
   }
   if(*ierr == MPI_SUCCESS) {
     *newtype = smpi_type_c2f(tmp);
   }
+  xbt_free(types);
 }
 
 void mpi_ssend_ (void* buf, int* count, int* datatype, int* dest, int* tag, int* comm, int* ierr) {
 }
 
 void mpi_ssend_ (void* buf, int* count, int* datatype, int* dest, int* tag, int* comm, int* ierr) {