+
+static char* get_key(char* key, int id) {
+ snprintf(key, KEY_SIZE, "%x",id);
+ return key;
+}
+static char* get_key_id(char* key, int id) {
+ snprintf(key, KEY_SIZE, "%x_%d",id, smpi_process_index());
+ return key;
+}
+
+
+
+static void smpi_init_fortran_types(){
+ if(!comm_lookup){
+ comm_lookup = xbt_dict_new_homogeneous(NULL);
+ 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);
+ smpi_type_c2f(MPI_CHAR);
+ #if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
+ smpi_type_c2f(MPI_INT);
+ smpi_type_c2f(MPI_INT);
+ #else
+ smpi_type_c2f(MPI_LONG);
+ smpi_type_c2f(MPI_LONG);
+ #endif
+ smpi_type_c2f(MPI_INT8_T);
+ smpi_type_c2f(MPI_INT16_T);
+ smpi_type_c2f(MPI_INT32_T);
+ smpi_type_c2f(MPI_INT64_T);
+ smpi_type_c2f(MPI_FLOAT);
+ smpi_type_c2f(MPI_FLOAT);
+ smpi_type_c2f(MPI_DOUBLE);
+ smpi_type_c2f(MPI_DOUBLE);
+ smpi_type_c2f(MPI_C_FLOAT_COMPLEX);
+ smpi_type_c2f(MPI_C_DOUBLE_COMPLEX);
+ #if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
+ smpi_type_c2f(MPI_2INT);
+ #else
+ smpi_type_c2f(MPI_2LONG);
+ #endif
+ smpi_type_c2f(MPI_UINT8_T);
+ smpi_type_c2f(MPI_UINT16_T);
+ smpi_type_c2f(MPI_UINT32_T);
+ smpi_type_c2f(MPI_UINT64_T);
+ smpi_type_c2f(MPI_2FLOAT);
+ smpi_type_c2f(MPI_2DOUBLE);
+ smpi_type_c2f(MPI_DOUBLE);
+ smpi_type_c2f(MPI_DOUBLE);
+ smpi_type_c2f(MPI_INT);
+ smpi_type_c2f(MPI_DATATYPE_NULL);
+ smpi_type_c2f(MPI_DATATYPE_NULL);
+ smpi_type_c2f(MPI_DATATYPE_NULL);
+ smpi_type_c2f(MPI_DATATYPE_NULL);
+ op_lookup = xbt_dict_new_homogeneous(NULL);
+ smpi_op_c2f(MPI_MAX);
+ smpi_op_c2f(MPI_MIN);
+ smpi_op_c2f(MPI_MAXLOC);
+ smpi_op_c2f(MPI_MINLOC);
+ smpi_op_c2f(MPI_SUM);
+ smpi_op_c2f(MPI_PROD);
+ smpi_op_c2f(MPI_LAND);
+ smpi_op_c2f(MPI_LOR);
+ smpi_op_c2f(MPI_LXOR);
+ smpi_op_c2f(MPI_BAND);
+ smpi_op_c2f(MPI_BOR);
+ smpi_op_c2f(MPI_BXOR);
+ }
+}
+
+
+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);
+ comm_id++;
+ return comm_id-1;