source: CONFIG_DEVT/IPSLCM6.5_work_ENSEMBLES/modeles/XIOS/src/interface/c/oasis_cinterface.cpp @ 5861

Last change on this file since 5861 was 5861, checked in by ymipsl, 3 years ago
  • Adapt XIOS sources to manage ensemble runs, using new version of oasis

YM

File size: 1.5 KB
Line 
1#include "oasis_cinterface.hpp"
2#include <oasis_c.h>
3#include <string>
4#include "mpi.hpp"
5#include <cstring>
6
7namespace xios
8{ 
9 
10  void oasis_init(const std::string& server_id)
11  {
12    fxios_oasis_init(server_id.data(),server_id.size()) ;
13  }
14 
15  void oasis_finalize(void)
16  {
17    fxios_oasis_finalize() ;
18  }
19 
20  void oasis_enddef(void)
21  {
22    fxios_oasis_enddef() ;
23  }
24
25  void oasis_get_localcomm(MPI_Comm& comm)
26  {
27    MPI_Fint f_comm ;
28   
29    fxios_oasis_get_localcomm(&f_comm) ;
30    comm=MPI_Comm_f2c(f_comm) ;
31  }
32 
33  void oasis_get_intracomm(MPI_Comm& comm_client_server,const std::string& server_id)
34  {
35    MPI_Fint f_comm ;
36   
37    fxios_oasis_get_intracomm(&f_comm,server_id.data(),server_id.size()) ;
38    comm_client_server=MPI_Comm_f2c(f_comm) ;
39  }
40 
41  void oasis_get_intercomm(MPI_Comm& comm_client_server,const std::string& server_id)
42  {
43    MPI_Fint f_comm ;
44   
45    fxios_oasis_get_intercomm(&f_comm,server_id.data(),server_id.size()) ;
46    comm_client_server=MPI_Comm_f2c(f_comm) ;
47  }
48 
49  void oasis_get_multi_intracomm(MPI_Comm& comm_clients_server,const std::vector<std::string>& codesId, std::vector<int> &rootRanks)
50  {
51    int size = codesId.size() ;
52    char** cdnam = new char*[size] ;
53    for(int i=0;i<size;i++)
54    {
55      cdnam[i]=new char[codesId[i].length()+1] ;
56      std::strcpy(cdnam[i], codesId[i].c_str());
57    }
58    rootRanks.resize(size) ;
59    oasis_c_get_multi_intracomm(&comm_clients_server, size, cdnam, rootRanks.data()) ;
60  }
61
62}
Note: See TracBrowser for help on using the repository browser.