+MPI_Comm Comm::f2c(int id) {
+ if(id == -2) {
+ return MPI_COMM_SELF;
+ } else if(id==0){
+ return MPI_COMM_WORLD;
+ } else if(Comm::f2c_lookup_ != nullptr && id >= 0) {
+ char key[KEY_SIZE];
+ MPI_Comm tmp = static_cast<MPI_Comm>(xbt_dict_get_or_null(Comm::f2c_lookup_,get_key_id(key, id)));
+ return tmp != nullptr ? tmp : MPI_COMM_NULL ;
+ } else {
+ return MPI_COMM_NULL;
+ }
+}
+
+void Comm::free_f(int id) {
+ char key[KEY_SIZE];
+ xbt_dict_remove(Comm::f2c_lookup_, id==0? get_key(key, id) : get_key_id(key, id));
+}
+
+int Comm::add_f() {
+ if(Comm::f2c_lookup_==nullptr){
+ Comm::f2c_lookup_=xbt_dict_new_homogeneous(nullptr);
+ }
+ char key[KEY_SIZE];
+ xbt_dict_set(Comm::f2c_lookup_, this==MPI_COMM_WORLD? get_key(key, Comm::f2c_id_) : get_key_id(key,Comm::f2c_id_), this, nullptr);
+ Comm::f2c_id_++;
+ return Comm::f2c_id_-1;
+}
+
+