source: XIOS/trunk/src/interface/c/iccalendar_wrapper.cpp @ 1542

Last change on this file since 1542 was 1542, checked in by oabramkina, 2 years ago

Replacing Boost's unordered_map and shared_pointer by its STL counterparts.

Two notes for Curie:

  • one can see the content of unordered_map with ddt only if XIOS has been compiled with gnu
  • XIOS will not compile any more with pgi (all available versions use old STL which are not up to the c++11 norms)
File size: 4.4 KB
Line 
1/* ************************************************************************** *
2 *      Copyright © IPSL/LSCE, xios, Avril 2010 - Octobre 2011         *
3 * ************************************************************************** */
4
5#include <boost/multi_array.hpp>
6
7#include <memory>
8
9#include "xios.hpp"
10
11#include "attribute_template.hpp"
12#include "object_template.hpp"
13#include "group_template.hpp"
14
15#include "icutil.hpp"
16#include "icdate.hpp"
17#include "timer.hpp"
18#include "calendar_wrapper.hpp"
19
20extern "C"
21{
22// /////////////////////////////// Définitions ////////////////////////////// //
23
24  // ----------------------- Redéfinition de type ----------------------------
25
26  typedef xios::CCalendarWrapper *XCalendarWrapperPtr;
27
28  // ------------------------ Création des handle -----------------------------
29
30  void cxios_calendar_wrapper_handle_create(XCalendarWrapperPtr* _ret, const char* _id, int _id_len)
31  {
32    std::string id;
33    if (!cstr2string(_id, _id_len, id)) return;
34    CTimer::get("XIOS").resume();
35    *_ret = CCalendarWrapper::get(id);
36    CTimer::get("XIOS").suspend();
37  }
38
39  void cxios_get_current_calendar_wrapper(XCalendarWrapperPtr* _ret)
40  {
41    CTimer::get("XIOS").resume();
42    *_ret = CCalendarWrapper::get(CCalendarWrapper::GetDefName());
43    CTimer::get("XIOS").suspend();
44  }
45
46  // -------------------- Vérification des identifiants -----------------------
47
48  void cxios_calendar_wrapper_valid_id(bool* _ret, const char* _id, int _id_len)
49  {
50    std::string id;
51    if (!cstr2string(_id, _id_len, id)) return;
52    CTimer::get("XIOS").resume();
53    *_ret = CCalendarWrapper::has(id);
54    CTimer::get("XIOS").suspend();
55  }
56
57  // ----------------------- Custom getters and setters -----------------------
58
59  void cxios_set_calendar_wrapper_date_start_date(XCalendarWrapperPtr calendarWrapper_hdl, cxios_date start_date_c)
60  {
61    CTimer::get("XIOS").resume();
62    CDate start_date(*calendarWrapper_hdl->getCalendar(true),
63                     start_date_c.year,
64                     start_date_c.month,
65                     start_date_c.day,
66                     start_date_c.hour,
67                     start_date_c.minute,
68                     start_date_c.second);
69    calendarWrapper_hdl->setInitDate(start_date);
70    CTimer::get("XIOS").suspend();
71  }
72
73  void cxios_get_calendar_wrapper_date_start_date(XCalendarWrapperPtr calendarWrapper_hdl, cxios_date* start_date_c)
74  {
75    CTimer::get("XIOS").resume();
76    const CDate& start_date = calendarWrapper_hdl->getInitDate();
77    start_date_c->year = start_date.getYear();
78    start_date_c->month = start_date.getMonth();
79    start_date_c->day = start_date.getDay();
80    start_date_c->hour = start_date.getHour();
81    start_date_c->minute = start_date.getMinute();
82    start_date_c->second = start_date.getSecond();
83    CTimer::get("XIOS").suspend();
84  }
85
86  void cxios_set_calendar_wrapper_date_time_origin(XCalendarWrapperPtr calendarWrapper_hdl, cxios_date time_origin_c)
87  {
88    CTimer::get("XIOS").resume();
89    CDate time_origin(*calendarWrapper_hdl->getCalendar(true),
90                      time_origin_c.year,
91                      time_origin_c.month,
92                      time_origin_c.day,
93                      time_origin_c.hour,
94                      time_origin_c.minute,
95                      time_origin_c.second);
96    calendarWrapper_hdl->setTimeOrigin(time_origin);
97    CTimer::get("XIOS").suspend();
98  }
99
100  void cxios_get_calendar_wrapper_date_time_origin(XCalendarWrapperPtr calendarWrapper_hdl, cxios_date* time_origin_c)
101  {
102    CTimer::get("XIOS").resume();
103    const CDate& time_origin = calendarWrapper_hdl->getTimeOrigin();
104    time_origin_c->year = time_origin.getYear();
105    time_origin_c->month = time_origin.getMonth();
106    time_origin_c->day = time_origin.getDay();
107    time_origin_c->hour = time_origin.getHour();
108    time_origin_c->minute = time_origin.getMinute();
109    time_origin_c->second = time_origin.getSecond();
110    CTimer::get("XIOS").suspend();
111  }
112
113  // ----------------------- Calendar creation and update ----------------------
114
115  void cxios_create_calendar(XCalendarWrapperPtr calendarWrapper_hdl)
116  {
117    CTimer::get("XIOS").resume();
118    calendarWrapper_hdl->createCalendar();
119    CTimer::get("XIOS").suspend();
120  }
121
122  void cxios_update_calendar_timestep(XCalendarWrapperPtr calendarWrapper_hdl)
123  {
124    CTimer::get("XIOS").resume();
125    calendarWrapper_hdl->updateTimestep();
126    CTimer::get("XIOS").suspend();
127  }
128} // extern "C"
Note: See TracBrowser for help on using the repository browser.