-/* Copyright (c) 2010-2018. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
void mpi_comm_free_(int* comm, int* ierr) {
MPI_Comm tmp = simgrid::smpi::Comm::f2c(*comm);
-
- *ierr = MPI_Comm_free(&tmp);
-
- if(*ierr == MPI_SUCCESS) {
+ if(tmp != MPI_COMM_WORLD && tmp != MPI_COMM_NULL) {
+ simgrid::smpi::Comm::destroy(tmp);
simgrid::smpi::Comm::free_f(*comm);
}
+ *ierr = MPI_SUCCESS;
}
void mpi_comm_split_(int* comm, int* color, int* key, int* comm_out, int* ierr) {
void mpi_comm_get_name_ (int* comm, char* name, int* len, int* ierr){
*ierr = MPI_Comm_get_name(simgrid::smpi::Comm::f2c(*comm), name, len);
if(*len>0)
- name[*len]=' ';
+ for(int i = *len; i<MPI_MAX_OBJECT_NAME+1; i++)
+ name[i]=' ';
}
void mpi_comm_compare_ (int* comm1, int* comm2, int *result, int* ierr){
*ierr = MPI_Comm_remote_size(simgrid::smpi::Comm::f2c(*comm), size);
}
-void mpi_comm_set_name_ (int* comm, char* name, int* ierr, int size){
- char* tname = xbt_new(char, size+1);
- strncpy(tname, name, size);
- tname[size]='\0';
+void mpi_comm_set_name_ (int* comm, char* name, int* ierr){
+ int count;
+ for(count=MPI_MAX_OBJECT_NAME-1; count>=0 && name[count]==' '; count--);
+ count+=1;
+ char* tname = xbt_new(char, count+1);
+ strncpy(tname, name, count);
+ tname[count]='\0';
*ierr = MPI_Comm_set_name (simgrid::smpi::Comm::f2c(*comm), tname);
xbt_free(tname);
}