Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
separate c2f and type creation. That was a bug (and probably a leak).
[simgrid.git] / src / smpi / smpi_f77.cpp
index 7218835..6eb35b1 100644 (file)
 #include "private.h"
 #include "xbt.h"
 
 #include "private.h"
 #include "xbt.h"
 
-static xbt_dict_t comm_lookup = NULL;
-static xbt_dict_t group_lookup = NULL;
-static xbt_dict_t request_lookup = NULL;
-static xbt_dict_t datatype_lookup = NULL;
-static xbt_dict_t op_lookup = NULL;
-static xbt_dict_t win_lookup = NULL;
-static xbt_dict_t info_lookup = NULL;
+static xbt_dict_t comm_lookup = nullptr;
+static xbt_dict_t group_lookup = nullptr;
+static xbt_dict_t request_lookup = nullptr;
+static xbt_dict_t datatype_lookup = nullptr;
+static xbt_dict_t op_lookup = nullptr;
+static xbt_dict_t win_lookup = nullptr;
+static xbt_dict_t info_lookup = nullptr;
 
 static int running_processes = 0;
 
 
 static int running_processes = 0;
 
@@ -58,53 +58,53 @@ static char* get_key_id(char* key, int id) {
 }
 
 static void smpi_init_fortran_types(){
 }
 
 static void smpi_init_fortran_types(){
-   if(comm_lookup == NULL){
-     comm_lookup = xbt_dict_new_homogeneous(NULL);
+   if(comm_lookup == nullptr){
+     comm_lookup = xbt_dict_new_homogeneous(nullptr);
      smpi_comm_c2f(MPI_COMM_WORLD);
      smpi_comm_c2f(MPI_COMM_WORLD);
-     group_lookup = xbt_dict_new_homogeneous(NULL);
-     request_lookup = xbt_dict_new_homogeneous(NULL);
-     datatype_lookup = xbt_dict_new_homogeneous(NULL);
-     win_lookup = xbt_dict_new_homogeneous(NULL);
-     info_lookup = xbt_dict_new_homogeneous(NULL);
-     smpi_type_c2f(MPI_BYTE);//MPI_BYTE
-     smpi_type_c2f(MPI_CHAR);//MPI_CHARACTER
+     group_lookup = xbt_dict_new_homogeneous(nullptr);
+     request_lookup = xbt_dict_new_homogeneous(nullptr);
+     datatype_lookup = xbt_dict_new_homogeneous(nullptr);
+     win_lookup = xbt_dict_new_homogeneous(nullptr);
+     info_lookup = xbt_dict_new_homogeneous(nullptr);
+     smpi_type_add_f(MPI_BYTE);//MPI_BYTE
+     smpi_type_add_f(MPI_CHAR);//MPI_CHARACTER
 #if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
 #if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
-     smpi_type_c2f(MPI_INT);//MPI_LOGICAL
-     smpi_type_c2f(MPI_INT);//MPI_INTEGER
+     smpi_type_add_f(MPI_C_BOOL);//MPI_LOGICAL
+     smpi_type_add_f(MPI_INT);//MPI_INTEGER
 #else
 #else
-     smpi_type_c2f(MPI_LONG);//MPI_LOGICAL
-     smpi_type_c2f(MPI_LONG);//MPI_INTEGER
+     smpi_type_add_f(MPI_C_BOOL);//MPI_LOGICAL
+     smpi_type_add_f(MPI_LONG);//MPI_INTEGER
 #endif
 #endif
-     smpi_type_c2f(MPI_INT8_T);//MPI_INTEGER1
-     smpi_type_c2f(MPI_INT16_T);//MPI_INTEGER2
-     smpi_type_c2f(MPI_INT32_T);//MPI_INTEGER4
-     smpi_type_c2f(MPI_INT64_T);//MPI_INTEGER8
-     smpi_type_c2f(MPI_FLOAT);//MPI_REAL
-     smpi_type_c2f(MPI_FLOAT);//MPI_REAL4
-     smpi_type_c2f(MPI_DOUBLE);//MPI_REAL8
-     smpi_type_c2f(MPI_DOUBLE);//MPI_DOUBLE_PRECISION
-     smpi_type_c2f(MPI_C_FLOAT_COMPLEX);//MPI_COMPLEX
-     smpi_type_c2f(MPI_C_DOUBLE_COMPLEX);//MPI_DOUBLE_COMPLEX
+     smpi_type_add_f(MPI_INT8_T);//MPI_INTEGER1
+     smpi_type_add_f(MPI_INT16_T);//MPI_INTEGER2
+     smpi_type_add_f(MPI_INT32_T);//MPI_INTEGER4
+     smpi_type_add_f(MPI_INT64_T);//MPI_INTEGER8
+     smpi_type_add_f(MPI_REAL);//MPI_REAL
+     smpi_type_add_f(MPI_REAL4);//MPI_REAL4
+     smpi_type_add_f(MPI_REAL8);//MPI_REAL8
+     smpi_type_add_f(MPI_DOUBLE);//MPI_DOUBLE_PRECISION
+     smpi_type_add_f(MPI_C_FLOAT_COMPLEX);//MPI_COMPLEX
+     smpi_type_add_f(MPI_C_DOUBLE_COMPLEX);//MPI_DOUBLE_COMPLEX
 #if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
 #if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
-     smpi_type_c2f(MPI_2INT);//MPI_2INTEGER
+     smpi_type_add_f(MPI_2INT);//MPI_2INTEGER
 #else
 #else
-     smpi_type_c2f(MPI_2LONG);//MPI_2INTEGER
+     smpi_type_add_f(MPI_2LONG);//MPI_2INTEGER
 #endif
 #endif
-     smpi_type_c2f(MPI_UINT8_T);//MPI_LOGICAL1
-     smpi_type_c2f(MPI_UINT16_T);//MPI_LOGICAL2
-     smpi_type_c2f(MPI_UINT32_T);//MPI_LOGICAL4
-     smpi_type_c2f(MPI_UINT64_T);//MPI_LOGICAL8
-     smpi_type_c2f(MPI_2FLOAT);//MPI_2REAL
-     smpi_type_c2f(MPI_2DOUBLE);//MPI_2DOUBLE_PRECISION
-     smpi_type_c2f(MPI_PTR);//MPI_AINT
-     smpi_type_c2f(MPI_UINT64_T);//MPI_OFFSET
-     smpi_type_c2f(MPI_UINT64_T);//MPI_COUNT
-     smpi_type_c2f(MPI_DATATYPE_NULL);//MPI_REAL16
-     smpi_type_c2f(MPI_DATATYPE_NULL);//MPI_COMPLEX8
-     smpi_type_c2f(MPI_DATATYPE_NULL);//MPI_COMPLEX16
-     smpi_type_c2f(MPI_DATATYPE_NULL);//MPI_COMPLEX32
-     smpi_type_c2f(MPI_DATATYPE_NULL);//MPI_PACKED
-     op_lookup = xbt_dict_new_homogeneous(NULL);
+     smpi_type_add_f(MPI_UINT8_T);//MPI_LOGICAL1
+     smpi_type_add_f(MPI_UINT16_T);//MPI_LOGICAL2
+     smpi_type_add_f(MPI_UINT32_T);//MPI_LOGICAL4
+     smpi_type_add_f(MPI_UINT64_T);//MPI_LOGICAL8
+     smpi_type_add_f(MPI_2FLOAT);//MPI_2REAL
+     smpi_type_add_f(MPI_2DOUBLE);//MPI_2DOUBLE_PRECISION
+     smpi_type_add_f(MPI_PTR);//MPI_AINT
+     smpi_type_add_f(MPI_OFFSET);//MPI_OFFSET
+     smpi_type_add_f(MPI_AINT);//MPI_COUNT
+     smpi_type_add_f(MPI_DATATYPE_NULL);//MPI_REAL16
+     smpi_type_add_f(MPI_DATATYPE_NULL);//MPI_COMPLEX8
+     smpi_type_add_f(MPI_DATATYPE_NULL);//MPI_COMPLEX16
+     smpi_type_add_f(MPI_DATATYPE_NULL);//MPI_COMPLEX32
+     smpi_type_add_f(MPI_DATATYPE_NULL);//MPI_PACKED
+     op_lookup = xbt_dict_new_homogeneous(nullptr);
      smpi_op_c2f(MPI_MAX);
      smpi_op_c2f(MPI_MIN);
      smpi_op_c2f(MPI_MAXLOC);
      smpi_op_c2f(MPI_MAX);
      smpi_op_c2f(MPI_MIN);
      smpi_op_c2f(MPI_MAXLOC);
@@ -123,7 +123,7 @@ static void smpi_init_fortran_types(){
 int smpi_comm_c2f(MPI_Comm comm) {
   static int comm_id = 0;
   char key[KEY_SIZE];
 int smpi_comm_c2f(MPI_Comm comm) {
   static int comm_id = 0;
   char key[KEY_SIZE];
-  xbt_dict_set(comm_lookup, comm==MPI_COMM_WORLD? get_key(key, comm_id) : get_key_id(key, comm_id), comm, NULL);
+  xbt_dict_set(comm_lookup, comm==MPI_COMM_WORLD? get_key(key, comm_id) : get_key_id(key, comm_id), comm, nullptr);
   comm_id++;
   return comm_id-1;
 }
   comm_id++;
   return comm_id-1;
 }
@@ -139,10 +139,10 @@ MPI_Comm smpi_comm_f2c(int comm) {
     return MPI_COMM_SELF;
   } else if(comm==0){
     return MPI_COMM_WORLD;
     return MPI_COMM_SELF;
   } else if(comm==0){
     return MPI_COMM_WORLD;
-  } else if(comm_lookup != NULL && comm >= 0) {
+  } else if(comm_lookup != nullptr && comm >= 0) {
       char key[KEY_SIZE];
       MPI_Comm tmp =  static_cast<MPI_Comm>(xbt_dict_get_or_null(comm_lookup,get_key_id(key, comm)));
       char key[KEY_SIZE];
       MPI_Comm tmp =  static_cast<MPI_Comm>(xbt_dict_get_or_null(comm_lookup,get_key_id(key, comm)));
-      return tmp != NULL ? tmp : MPI_COMM_NULL ;
+      return tmp != nullptr ? tmp : MPI_COMM_NULL ;
   } else {
     return MPI_COMM_NULL;
   }
   } else {
     return MPI_COMM_NULL;
   }
@@ -151,7 +151,7 @@ MPI_Comm smpi_comm_f2c(int comm) {
 int smpi_group_c2f(MPI_Group group) {
   static int group_id = 0;
   char key[KEY_SIZE];
 int smpi_group_c2f(MPI_Group group) {
   static int group_id = 0;
   char key[KEY_SIZE];
-  xbt_dict_set(group_lookup, get_key(key, group_id), group, NULL);
+  xbt_dict_set(group_lookup, get_key(key, group_id), group, nullptr);
   group_id++;
   return group_id-1;
 }
   group_id++;
   return group_id-1;
 }
@@ -160,7 +160,7 @@ MPI_Group smpi_group_f2c(int group) {
   smpi_init_fortran_types();
   if(group == -2) {
     return MPI_GROUP_EMPTY;
   smpi_init_fortran_types();
   if(group == -2) {
     return MPI_GROUP_EMPTY;
-  } else if(group_lookup != NULL && group >= 0) {
+  } else if(group_lookup != nullptr && group >= 0) {
     char key[KEY_SIZE];
     return static_cast<MPI_Group>(xbt_dict_get_or_null(group_lookup, get_key(key, group)));
   } else {
     char key[KEY_SIZE];
     return static_cast<MPI_Group>(xbt_dict_get_or_null(group_lookup, get_key(key, group)));
   } else {
@@ -176,7 +176,7 @@ static void free_group(int group) {
 int smpi_request_c2f(MPI_Request req) {
   static int request_id = 0;
   char key[KEY_SIZE];
 int smpi_request_c2f(MPI_Request req) {
   static int request_id = 0;
   char key[KEY_SIZE];
-  xbt_dict_set(request_lookup, get_key_id(key, request_id), req, NULL);
+  xbt_dict_set(request_lookup, get_key_id(key, request_id), req, nullptr);
   request_id++;
   return request_id-1;
 }
   request_id++;
   return request_id-1;
 }
@@ -195,14 +195,19 @@ static void free_request(int request) {
   xbt_dict_remove(request_lookup, get_key_id(key, request));
 }
 
   xbt_dict_remove(request_lookup, get_key_id(key, request));
 }
 
-int smpi_type_c2f(MPI_Datatype datatype) {
+int smpi_type_add_f(MPI_Datatype datatype){
   static int datatype_id = 0;
   char key[KEY_SIZE];
   static int datatype_id = 0;
   char key[KEY_SIZE];
-  xbt_dict_set(datatype_lookup, get_key(key, datatype_id), datatype, NULL);
+  xbt_dict_set(datatype_lookup, get_key(key, datatype_id), datatype, nullptr);
   datatype_id++;
   return datatype_id-1;
 }
 
   datatype_id++;
   return datatype_id-1;
 }
 
+int smpi_type_c2f(MPI_Datatype datatype) {
+  char* existing_key = xbt_dict_get_key(datatype_lookup, datatype);
+  return atoi(existing_key);
+}
+
 MPI_Datatype smpi_type_f2c(int datatype) {
   smpi_init_fortran_types();
   char key[KEY_SIZE];
 MPI_Datatype smpi_type_f2c(int datatype) {
   smpi_init_fortran_types();
   char key[KEY_SIZE];
@@ -217,7 +222,7 @@ static void free_datatype(int datatype) {
 int smpi_op_c2f(MPI_Op op) {
   static int op_id = 0;
   char key[KEY_SIZE];
 int smpi_op_c2f(MPI_Op op) {
   static int op_id = 0;
   char key[KEY_SIZE];
-  xbt_dict_set(op_lookup, get_key(key, op_id), op, NULL);
+  xbt_dict_set(op_lookup, get_key(key, op_id), op, nullptr);
   op_id++;
   return op_id-1;
 }
   op_id++;
   return op_id-1;
 }
@@ -236,7 +241,7 @@ static void free_op(int op) {
 int smpi_win_c2f(MPI_Win win) {
   static int win_id = 0;
   char key[KEY_SIZE];
 int smpi_win_c2f(MPI_Win win) {
   static int win_id = 0;
   char key[KEY_SIZE];
-  xbt_dict_set(win_lookup, get_key(key, win_id), win, NULL);
+  xbt_dict_set(win_lookup, get_key(key, win_id), win, nullptr);
   win_id++;
   return win_id-1;
 }
   win_id++;
   return win_id-1;
 }
@@ -255,7 +260,7 @@ static void free_win(int win) {
 int smpi_info_c2f(MPI_Info info) {
   static int info_id = 0;
   char key[KEY_SIZE];
 int smpi_info_c2f(MPI_Info info) {
   static int info_id = 0;
   char key[KEY_SIZE];
-  xbt_dict_set(info_lookup, get_key(key, info_id), info, NULL);
+  xbt_dict_set(info_lookup, get_key(key, info_id), info, nullptr);
   info_id++;
   return info_id-1;
 }
   info_id++;
   return info_id-1;
 }
@@ -273,7 +278,7 @@ static void free_info(int info) {
 
 void mpi_init_(int* ierr) {
     smpi_init_fortran_types();
 
 void mpi_init_(int* ierr) {
     smpi_init_fortran_types();
-   *ierr = MPI_Init(NULL, NULL);
+   *ierr = MPI_Init(nullptr, nullptr);
    running_processes++;
 }
 
    running_processes++;
 }
 
@@ -303,11 +308,11 @@ void mpi_comm_size_(int* comm, int* size, int* ierr) {
    *ierr = MPI_Comm_size(smpi_comm_f2c(*comm), size);
 }
 
    *ierr = MPI_Comm_size(smpi_comm_f2c(*comm), size);
 }
 
-double mpi_wtime_(void) {
+double mpi_wtime_() {
    return MPI_Wtime();
 }
 
    return MPI_Wtime();
 }
 
-double mpi_wtick_(void) {
+double mpi_wtick_() {
   return MPI_Wtick();
 }
 
   return MPI_Wtick();
 }
 
@@ -600,9 +605,8 @@ void mpi_test_ (int * request, int *flag, MPI_Status * status, int* ierr){
 }
 
 void mpi_testall_ (int* count, int * requests,  int *flag, MPI_Status * statuses, int* ierr){
 }
 
 void mpi_testall_ (int* count, int * requests,  int *flag, MPI_Status * statuses, int* ierr){
-  MPI_Request* reqs;
   int i;
   int i;
-  reqs = xbt_new(MPI_Request, *count);
+  MPI_Request* reqs = xbt_new(MPI_Request, *count);
   for(i = 0; i < *count; i++) {
     reqs[i] = smpi_request_f2c(requests[i]);
   }
   for(i = 0; i < *count; i++) {
     reqs[i] = smpi_request_f2c(requests[i]);
   }
@@ -613,6 +617,7 @@ void mpi_testall_ (int* count, int * requests,  int *flag, MPI_Status * statuses
         requests[i]=MPI_FORTRAN_REQUEST_NULL;
     }
   }
         requests[i]=MPI_FORTRAN_REQUEST_NULL;
     }
   }
+  xbt_free(reqs);
 }
 
 void mpi_get_processor_name_(char *name, int *resultlen, int* ierr){
 }
 
 void mpi_get_processor_name_(char *name, int *resultlen, int* ierr){
@@ -640,7 +645,7 @@ void mpi_type_vector_(int* count, int* blocklen, int* stride, int* old_type, int
   MPI_Datatype tmp;
   *ierr= MPI_Type_vector(*count, *blocklen, *stride, smpi_type_f2c(*old_type), &tmp);
   if(*ierr == MPI_SUCCESS) {
   MPI_Datatype tmp;
   *ierr= MPI_Type_vector(*count, *blocklen, *stride, smpi_type_f2c(*old_type), &tmp);
   if(*ierr == MPI_SUCCESS) {
-    *newtype = smpi_type_c2f(tmp);
+    *newtype = smpi_type_add_f(tmp);
   }
 }
 
   }
 }
 
@@ -648,7 +653,7 @@ void mpi_type_create_vector_(int* count, int* blocklen, int* stride, int* old_ty
   MPI_Datatype tmp;
   *ierr= MPI_Type_vector(*count, *blocklen, *stride, smpi_type_f2c(*old_type), &tmp);
   if(*ierr == MPI_SUCCESS) {
   MPI_Datatype tmp;
   *ierr= MPI_Type_vector(*count, *blocklen, *stride, smpi_type_f2c(*old_type), &tmp);
   if(*ierr == MPI_SUCCESS) {
-    *newtype = smpi_type_c2f(tmp);
+    *newtype = smpi_type_add_f(tmp);
   }
 }
 
   }
 }
 
@@ -656,7 +661,7 @@ void mpi_type_hvector_(int* count, int* blocklen, MPI_Aint* stride, int* old_typ
   MPI_Datatype tmp;
   *ierr= MPI_Type_hvector (*count, *blocklen, *stride, smpi_type_f2c(*old_type), &tmp);
   if(*ierr == MPI_SUCCESS) {
   MPI_Datatype tmp;
   *ierr= MPI_Type_hvector (*count, *blocklen, *stride, smpi_type_f2c(*old_type), &tmp);
   if(*ierr == MPI_SUCCESS) {
-    *newtype = smpi_type_c2f(tmp);
+    *newtype = smpi_type_add_f(tmp);
   }
 }
 
   }
 }
 
@@ -664,7 +669,7 @@ void mpi_type_create_hvector_(int* count, int* blocklen, MPI_Aint* stride, int*
   MPI_Datatype tmp;
   *ierr= MPI_Type_hvector(*count, *blocklen, *stride, smpi_type_f2c(*old_type), &tmp);
   if(*ierr == MPI_SUCCESS) {
   MPI_Datatype tmp;
   *ierr= MPI_Type_hvector(*count, *blocklen, *stride, smpi_type_f2c(*old_type), &tmp);
   if(*ierr == MPI_SUCCESS) {
-    *newtype = smpi_type_c2f(tmp);
+    *newtype = smpi_type_add_f(tmp);
   }
 }
 
   }
 }
 
@@ -778,10 +783,11 @@ void mpi_info_set_( int *info, char *key, char *value, int* ierr, unsigned int k
   }
   char* tvalue = xbt_new(char,valuelen+1);
   strncpy(tvalue, value, valuelen);
   }
   char* tvalue = xbt_new(char,valuelen+1);
   strncpy(tvalue, value, valuelen);
-
   tvalue[valuelen]='\0'; 
   tvalue[valuelen]='\0'; 
+
   *ierr =  MPI_Info_set( smpi_info_f2c(*info), tkey, tvalue);
   xbt_free(tkey);
   *ierr =  MPI_Info_set( smpi_info_f2c(*info), tkey, tvalue);
   xbt_free(tkey);
+  xbt_free(tvalue);
 }
 
 void mpi_info_get_ (int* info,char *key,int* valuelen, char *value, int *flag, int* ierr, unsigned int keylen ){
 }
 
 void mpi_info_get_ (int* info,char *key,int* valuelen, char *value, int *flag, int* ierr, unsigned int keylen ){
@@ -842,7 +848,7 @@ void mpi_finalized_ (int * flag, int* ierr){
 
 void mpi_init_thread_ (int* required, int *provided, int* ierr){
   smpi_init_fortran_types();
 
 void mpi_init_thread_ (int* required, int *provided, int* ierr){
   smpi_init_fortran_types();
-  *ierr = MPI_Init_thread(NULL, NULL,*required, provided);
+  *ierr = MPI_Init_thread(nullptr, nullptr,*required, provided);
   running_processes++;
 }
 
   running_processes++;
 }
 
@@ -870,7 +876,7 @@ void mpi_type_dup_ (int*  datatype, int* newdatatype, int* ierr){
  MPI_Datatype tmp;
  *ierr = MPI_Type_dup(smpi_type_f2c(*datatype), &tmp);
  if(*ierr == MPI_SUCCESS) {
  MPI_Datatype tmp;
  *ierr = MPI_Type_dup(smpi_type_f2c(*datatype), &tmp);
  if(*ierr == MPI_SUCCESS) {
-   *newdatatype = smpi_type_c2f(tmp);
+   *newdatatype = smpi_type_add_f(tmp);
  }
 }
 
  }
 }
 
@@ -1238,7 +1244,7 @@ void mpi_type_contiguous_ (int* count, int* old_type, int*  newtype, int* ierr)
   MPI_Datatype tmp;
   *ierr = MPI_Type_contiguous(*count, smpi_type_f2c(*old_type), &tmp);
   if(*ierr == MPI_SUCCESS) {
   MPI_Datatype tmp;
   *ierr = MPI_Type_contiguous(*count, smpi_type_f2c(*old_type), &tmp);
   if(*ierr == MPI_SUCCESS) {
-    *newtype = smpi_type_c2f(tmp);
+    *newtype = smpi_type_add_f(tmp);
   }
 }
 
   }
 }
 
@@ -1301,7 +1307,7 @@ void mpi_type_hindexed_ (int* count, int* blocklens, MPI_Aint* indices, int* old
   MPI_Datatype tmp;
   *ierr = MPI_Type_hindexed(*count, blocklens, indices, smpi_type_f2c(*old_type), &tmp);
   if(*ierr == MPI_SUCCESS) {
   MPI_Datatype tmp;
   *ierr = MPI_Type_hindexed(*count, blocklens, indices, smpi_type_f2c(*old_type), &tmp);
   if(*ierr == MPI_SUCCESS) {
-    *newtype = smpi_type_c2f(tmp);
+    *newtype = smpi_type_add_f(tmp);
   }
 }
 
   }
 }
 
@@ -1309,7 +1315,7 @@ void mpi_type_create_hindexed_(int* count, int* blocklens, MPI_Aint* indices, in
   MPI_Datatype tmp;
   *ierr = MPI_Type_create_hindexed(*count, blocklens, indices, smpi_type_f2c(*old_type), &tmp);
   if(*ierr == MPI_SUCCESS) {
   MPI_Datatype tmp;
   *ierr = MPI_Type_create_hindexed(*count, blocklens, indices, smpi_type_f2c(*old_type), &tmp);
   if(*ierr == MPI_SUCCESS) {
-    *newtype = smpi_type_c2f(tmp);
+    *newtype = smpi_type_add_f(tmp);
   }
 }
 
   }
 }
 
@@ -1318,7 +1324,7 @@ void mpi_type_create_hindexed_block_ (int* count, int* blocklength, MPI_Aint* in
   MPI_Datatype tmp;
   *ierr = MPI_Type_create_hindexed_block(*count, *blocklength, indices, smpi_type_f2c(*old_type), &tmp);
   if(*ierr == MPI_SUCCESS) {
   MPI_Datatype tmp;
   *ierr = MPI_Type_create_hindexed_block(*count, *blocklength, indices, smpi_type_f2c(*old_type), &tmp);
   if(*ierr == MPI_SUCCESS) {
-    *newtype = smpi_type_c2f(tmp);
+    *newtype = smpi_type_add_f(tmp);
   }
 }
 
   }
 }
 
@@ -1326,7 +1332,7 @@ void mpi_type_indexed_ (int* count, int* blocklens, int* indices, int* old_type,
   MPI_Datatype tmp;
   *ierr = MPI_Type_indexed(*count, blocklens, indices, smpi_type_f2c(*old_type), &tmp);
   if(*ierr == MPI_SUCCESS) {
   MPI_Datatype tmp;
   *ierr = MPI_Type_indexed(*count, blocklens, indices, smpi_type_f2c(*old_type), &tmp);
   if(*ierr == MPI_SUCCESS) {
-    *newtype = smpi_type_c2f(tmp);
+    *newtype = smpi_type_add_f(tmp);
   }
 }
 
   }
 }
 
@@ -1335,7 +1341,7 @@ void mpi_type_create_indexed_block_ (int* count, int* blocklength, int* indices,
   MPI_Datatype tmp;
   *ierr = MPI_Type_create_indexed_block(*count, *blocklength, indices, smpi_type_f2c(*old_type), &tmp);
   if(*ierr == MPI_SUCCESS) {
   MPI_Datatype tmp;
   *ierr = MPI_Type_create_indexed_block(*count, *blocklength, indices, smpi_type_f2c(*old_type), &tmp);
   if(*ierr == MPI_SUCCESS) {
-    *newtype = smpi_type_c2f(tmp);
+    *newtype = smpi_type_add_f(tmp);
   }
 }
 
   }
 }
 
@@ -1348,7 +1354,7 @@ void mpi_type_struct_ (int* count, int* blocklens, MPI_Aint* indices, int* old_t
   }
   *ierr = MPI_Type_struct(*count, blocklens, indices, types, &tmp);
   if(*ierr == MPI_SUCCESS) {
   }
   *ierr = MPI_Type_struct(*count, blocklens, indices, types, &tmp);
   if(*ierr == MPI_SUCCESS) {
-    *newtype = smpi_type_c2f(tmp);
+    *newtype = smpi_type_add_f(tmp);
   }
   xbt_free(types);
 }
   }
   xbt_free(types);
 }
@@ -1362,7 +1368,7 @@ void mpi_type_create_struct_(int* count, int* blocklens, MPI_Aint* indices, int*
   }
   *ierr = MPI_Type_create_struct(*count, blocklens, indices, types, &tmp);
   if(*ierr == MPI_SUCCESS) {
   }
   *ierr = MPI_Type_create_struct(*count, blocklens, indices, types, &tmp);
   if(*ierr == MPI_SUCCESS) {
-    *newtype = smpi_type_c2f(tmp);
+    *newtype = smpi_type_add_f(tmp);
   }
   xbt_free(types);
 }
   }
   xbt_free(types);
 }
@@ -1506,7 +1512,7 @@ void mpi_type_create_darray_ (int* size, int* rank, int* ndims, int* array_of_gs
   array_of_distribs,  array_of_dargs,  array_of_psizes,
   *order,  smpi_type_f2c(*oldtype), &tmp) ;
   if(*ierr == MPI_SUCCESS) {
   array_of_distribs,  array_of_dargs,  array_of_psizes,
   *order,  smpi_type_f2c(*oldtype), &tmp) ;
   if(*ierr == MPI_SUCCESS) {
-    *newtype = smpi_type_c2f(tmp);
+    *newtype = smpi_type_add_f(tmp);
   }
 }
 
   }
 }
 
@@ -1514,7 +1520,7 @@ void mpi_type_create_resized_ (int* oldtype,MPI_Aint* lb, MPI_Aint* extent, int*
   MPI_Datatype tmp;
   *ierr = MPI_Type_create_resized(smpi_type_f2c(*oldtype),*lb, *extent, &tmp);
   if(*ierr == MPI_SUCCESS) {
   MPI_Datatype tmp;
   *ierr = MPI_Type_create_resized(smpi_type_f2c(*oldtype),*lb, *extent, &tmp);
   if(*ierr == MPI_SUCCESS) {
-    *newtype = smpi_type_c2f(tmp);
+    *newtype = smpi_type_add_f(tmp);
   }
 }
 
   }
 }
 
@@ -1524,7 +1530,7 @@ void mpi_type_create_subarray_ (int* ndims,int *array_of_sizes, int *array_of_su
   *ierr = MPI_Type_create_subarray(*ndims,array_of_sizes, array_of_subsizes, array_of_starts, *order,
                                    smpi_type_f2c(*oldtype), &tmp);
   if(*ierr == MPI_SUCCESS) {
   *ierr = MPI_Type_create_subarray(*ndims,array_of_sizes, array_of_subsizes, array_of_starts, *order,
                                    smpi_type_f2c(*oldtype), &tmp);
   if(*ierr == MPI_SUCCESS) {
-    *newtype = smpi_type_c2f(tmp);
+    *newtype = smpi_type_add_f(tmp);
   }
 }
 
   }
 }
 
@@ -1729,7 +1735,7 @@ void mpi_comm_accept_ ( char *port_name, int* info, int* root, int* comm, int*ne
 void mpi_comm_spawn_ ( char *command, char *argv, int* maxprocs, int* info, int* root, int* comm, int* intercomm,
                        int* array_of_errcodes, int* ierr){
   MPI_Comm tmp;
 void mpi_comm_spawn_ ( char *command, char *argv, int* maxprocs, int* info, int* root, int* comm, int* intercomm,
                        int* array_of_errcodes, int* ierr){
   MPI_Comm tmp;
-  *ierr = MPI_Comm_spawn( command, NULL, *maxprocs, *reinterpret_cast<MPI_Info*>(info), *root, smpi_comm_f2c(*comm), &tmp,
+  *ierr = MPI_Comm_spawn( command, nullptr, *maxprocs, *reinterpret_cast<MPI_Info*>(info), *root, smpi_comm_f2c(*comm), &tmp,
                           array_of_errcodes);
   if(*ierr == MPI_SUCCESS) {
     *intercomm = smpi_comm_c2f(tmp);
                           array_of_errcodes);
   if(*ierr == MPI_SUCCESS) {
     *intercomm = smpi_comm_c2f(tmp);
@@ -1754,3 +1760,28 @@ void mpi_comm_get_parent_ ( int* parent, int* ierr){
     *parent = smpi_comm_c2f(tmp);
   }
 }
     *parent = smpi_comm_c2f(tmp);
   }
 }
+
+void mpi_file_close_ ( int* file, int* ierr){
+  *ierr= MPI_File_close(reinterpret_cast<MPI_File*>(*file));
+}
+
+void mpi_file_delete_ ( char* filename, int* info, int* ierr){
+  *ierr= MPI_File_delete(filename, smpi_info_f2c(*info));
+}
+
+void mpi_file_open_ ( int* comm, char* filename, int* amode, int* info, int* fh, int* ierr){
+  *ierr= MPI_File_open(smpi_comm_f2c(*comm), filename, *amode, smpi_info_f2c(*info), reinterpret_cast<MPI_File*>(*fh));
+}
+
+void mpi_file_set_view_ ( int* fh, long long int* offset, int* etype, int* filetype, char* datarep, int* info, int* ierr){
+  *ierr= MPI_File_set_view(reinterpret_cast<MPI_File>(*fh) , reinterpret_cast<MPI_Offset>(*offset), smpi_type_f2c(*etype), smpi_type_f2c(*filetype), datarep, smpi_info_f2c(*info));
+}
+
+void mpi_file_read_ ( int* fh, void* buf, int* count, int* datatype, MPI_Status* status, int* ierr){
+  *ierr=  MPI_File_read(reinterpret_cast<MPI_File>(*fh), buf, *count, smpi_type_f2c(*datatype), status);
+}
+
+void mpi_file_write_ ( int* fh, void* buf, int* count, int* datatype, MPI_Status* status, int* ierr){
+  *ierr=  MPI_File_write(reinterpret_cast<MPI_File>(*fh), buf, *count, smpi_type_f2c(*datatype), status);
+}
+