source: XIOS/dev/branch_yushan/extern/src_ep_dev/ep_fortran.cpp @ 1037

Last change on this file since 1037 was 1037, checked in by yushan, 7 years ago

initialize the branch

File size: 1.3 KB
Line 
1//#include "ep_lib.hpp"
2#include "ep_lib_fortran.hpp"
3#include <mpi.h>
4#include <map>
5#include <utility>
6#undef MPI_Comm_f2c(comm)
7#undef MPI_Comm_c2f(comm)
8
9
10namespace ep_lib
11{
12
13
14  MPI_Fint MPI_Comm_c2f(MPI_Comm comm)
15  {
16    Debug("MPI_Comm_c2f");
17    int fint;
18    fint = (::MPI_Fint)(comm.mpi_comm);
19   
20    std::map<std::pair<int, int>, MPI_Comm  > ::iterator it;
21   
22    it = fc_comm_map.find(std::make_pair(fint, omp_get_thread_num()));
23    if(it == fc_comm_map.end())
24    {
25      fc_comm_map.insert(std::make_pair( std::make_pair( fint, omp_get_thread_num()) , comm));
26      printf("MAP insert: %d, %d, %p\n", fint, omp_get_thread_num(), &comm);
27    }
28   
29    MPI_Fint Fint;
30    Fint.mpi_fint = fint;
31    return Fint;
32   
33  }
34
35
36  MPI_Comm MPI_Comm_f2c(MPI_Fint comm)
37  {
38    Debug("MPI_Comm_f2c");
39   
40   
41    std::map<std::pair<int, int>, MPI_Comm  > ::iterator it;
42   
43    it = fc_comm_map.find(std::make_pair(comm.mpi_fint, omp_get_thread_num()));
44    if(it != fc_comm_map.end())
45    {
46      MPI_Comm comm_ptr;
47      comm_ptr =  it->second;
48      printf("MAP find: %d, %d, %p\n", it->first.first, it->first.second, &comm_ptr);
49      return  comm_ptr;
50    }
51    else
52    {     
53      MPI_Comm return_comm;
54      return_comm.mpi_comm = (::MPI_Comm)(comm.mpi_fint);
55      return return_comm;
56    }
57  }
58
59}
60
61
Note: See TracBrowser for help on using the repository browser.