1 /* Handle Fortran - C conversion for MPI Types*/
3 /* Copyright (c) 2010-2020. The SimGrid Team.
4 * All rights reserved. */
6 /* This program is free software; you can redistribute it and/or modify it
7 * under the terms of the license (GNU LGPL) which comes with this package. */
9 #ifndef SMPI_F2C_HPP_INCLUDED
10 #define SMPI_F2C_HPP_INCLUDED
12 #include <unordered_map>
19 // We use a single lookup table for every type.
20 // Beware of collisions if id in mpif.h is not unique
21 static std::unordered_map<int, F2C*>* f2c_lookup_;
26 static void set_f2c_lookup(std::unordered_map<int, F2C*>* map) { f2c_lookup_ = map; }
27 static int f2c_id() { return f2c_id_; }
28 static void f2c_id_increment() { f2c_id_++; }
31 static void delete_lookup() { delete f2c_lookup_; }
32 static std::unordered_map<int, F2C*>* lookup() { return f2c_lookup_; }
34 virtual ~F2C() = default;
36 // Override these to handle specific values.
38 static void free_f(int id) { f2c_lookup_->erase(id); }
40 static void print_f2c_lookup();
41 // This method should be overridden in all subclasses to avoid casting the result when calling it.
42 // For the default one, the MPI_*_NULL returned is assumed to be NULL.
43 static F2C* f2c(int id);