- return info >= 0 ? static_cast<MPI_Info>(xbt_dict_get_or_null(info_lookup, get_key(key, info))) : MPI_INFO_NULL;
-}
-
-static void free_info(int info) {
- char key[KEY_SIZE];
- xbt_dict_remove(info_lookup, get_key(key, info));
-}
+ if(request==MPI_FORTRAN_REQUEST_NULL)
+ return static_cast<MPI_Request>(null_id);
+ return static_cast<MPI_Request>(xbt_dict_get(dict, get_key_id(key, request)));
+}
+
+#define SMPI_F2C_C2F(type, name, null_id)\
+int smpi_##name##_add_f(type name){\
+ return smpi_add_f<type>(name, name##_lookup, &name##_id);\
+}\
+int smpi_##name##_c2f(type name){\
+ return smpi_c2f<type>(name, name##_lookup, &name##_id);\
+}\
+static void free_##name(int id) {\
+ free_f<type>(id, name##_lookup);\
+}\
+type smpi_##name##_f2c(int id){\
+ return smpi_f2c<type>(id, name##_lookup, static_cast<void*>(null_id));\
+}
+
+extern "C" { // This should really use the C linkage to be usable from Fortran
+
+SMPI_F2C_C2F(MPI_Comm, comm, MPI_COMM_NULL)
+SMPI_F2C_C2F(MPI_Group, group, MPI_GROUP_NULL)
+SMPI_F2C_C2F(MPI_Request, request, MPI_REQUEST_NULL)
+SMPI_F2C_C2F(MPI_Datatype, type, MPI_DATATYPE_NULL)
+SMPI_F2C_C2F(MPI_Win, win, MPI_WIN_NULL)
+SMPI_F2C_C2F(MPI_Op, op, MPI_OP_NULL)
+SMPI_F2C_C2F(MPI_Info, info, MPI_INFO_NULL)