source: XIOS/dev/branch_openmp/src/interface/c/iccalendar_wrapper.cpp @ 1642

Last change on this file since 1642 was 1642, checked in by yushan, 5 years ago

dev on ADA. add flag switch _usingEP/_usingMPI

File size: 4.6 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  TRY
32  {
33    std::string id;
34    if (!cstr2string(_id, _id_len, id)) return;
35    CTimer::get("XIOS").resume();
36    *_ret = CCalendarWrapper::get(id);
37    CTimer::get("XIOS").suspend();
38  }
39  CATCH_DUMP_STACK
40
41  void cxios_get_current_calendar_wrapper(XCalendarWrapperPtr* _ret)
42  TRY
43  {
44    CTimer::get("XIOS").resume();
45    *_ret = CCalendarWrapper::get(CCalendarWrapper::GetDefName());
46    CTimer::get("XIOS").suspend();
47  }
48  CATCH_DUMP_STACK
49
50  // -------------------- Vérification des identifiants -----------------------
51
52  void cxios_calendar_wrapper_valid_id(bool* _ret, const char* _id, int _id_len)
53  TRY
54  {
55    std::string id;
56    if (!cstr2string(_id, _id_len, id)) return;
57    CTimer::get("XIOS").resume();
58    *_ret = CCalendarWrapper::has(id);
59    CTimer::get("XIOS").suspend();
60  }
61  CATCH_DUMP_STACK
62
63  // ----------------------- Custom getters and setters -----------------------
64
65  void cxios_set_calendar_wrapper_date_start_date(XCalendarWrapperPtr calendarWrapper_hdl, cxios_date start_date_c)
66  TRY
67  {
68    CTimer::get("XIOS").resume();
69    CDate start_date(*calendarWrapper_hdl->getCalendar(true),
70                     start_date_c.year,
71                     start_date_c.month,
72                     start_date_c.day,
73                     start_date_c.hour,
74                     start_date_c.minute,
75                     start_date_c.second);
76    calendarWrapper_hdl->setInitDate(start_date);
77    CTimer::get("XIOS").suspend();
78  }
79  CATCH_DUMP_STACK
80
81  void cxios_get_calendar_wrapper_date_start_date(XCalendarWrapperPtr calendarWrapper_hdl, cxios_date* start_date_c)
82  TRY
83  {
84    CTimer::get("XIOS").resume();
85    const CDate& start_date = calendarWrapper_hdl->getInitDate();
86    start_date_c->year = start_date.getYear();
87    start_date_c->month = start_date.getMonth();
88    start_date_c->day = start_date.getDay();
89    start_date_c->hour = start_date.getHour();
90    start_date_c->minute = start_date.getMinute();
91    start_date_c->second = start_date.getSecond();
92    CTimer::get("XIOS").suspend();
93  }
94  CATCH_DUMP_STACK
95
96  void cxios_set_calendar_wrapper_date_time_origin(XCalendarWrapperPtr calendarWrapper_hdl, cxios_date time_origin_c)
97  TRY
98  {
99    CTimer::get("XIOS").resume();
100    CDate time_origin(*calendarWrapper_hdl->getCalendar(true),
101                      time_origin_c.year,
102                      time_origin_c.month,
103                      time_origin_c.day,
104                      time_origin_c.hour,
105                      time_origin_c.minute,
106                      time_origin_c.second);
107    calendarWrapper_hdl->setTimeOrigin(time_origin);
108    CTimer::get("XIOS").suspend();
109  }
110  CATCH_DUMP_STACK
111
112  void cxios_get_calendar_wrapper_date_time_origin(XCalendarWrapperPtr calendarWrapper_hdl, cxios_date* time_origin_c)
113  TRY
114  {
115    CTimer::get("XIOS").resume();
116    const CDate& time_origin = calendarWrapper_hdl->getTimeOrigin();
117    time_origin_c->year = time_origin.getYear();
118    time_origin_c->month = time_origin.getMonth();
119    time_origin_c->day = time_origin.getDay();
120    time_origin_c->hour = time_origin.getHour();
121    time_origin_c->minute = time_origin.getMinute();
122    time_origin_c->second = time_origin.getSecond();
123    CTimer::get("XIOS").suspend();
124  }
125  CATCH_DUMP_STACK
126
127  // ----------------------- Calendar creation and update ----------------------
128
129  void cxios_create_calendar(XCalendarWrapperPtr calendarWrapper_hdl)
130  TRY
131  {
132    CTimer::get("XIOS").resume();
133    calendarWrapper_hdl->createCalendar();
134    CTimer::get("XIOS").suspend();
135  }
136  CATCH_DUMP_STACK
137
138  void cxios_update_calendar_timestep(XCalendarWrapperPtr calendarWrapper_hdl)
139  TRY
140  {
141    CTimer::get("XIOS").resume();
142    calendarWrapper_hdl->updateTimestep();
143    CTimer::get("XIOS").suspend();
144  }
145  CATCH_DUMP_STACK
146} // extern "C"
Note: See TracBrowser for help on using the repository browser.