source: XIOS/dev/dev_ym/XIOS_SERVICES/src/interface/c/iccalendar.cpp @ 1758

Last change on this file since 1758 was 1753, checked in by ymipsl, 5 years ago

more timers

YM

File size: 2.3 KB
Line 
1#include "xios.hpp"
2
3#include "icdate.hpp"
4#include "exception.hpp"
5#include "timer.hpp"
6#include "context.hpp"
7#include "context_client.hpp"
8
9extern "C"
10{
11  void cxios_update_calendar(int step)
12  TRY
13  {
14    CTimer::get("XIOS").resume();
15    CTimer::get("XIOS update calendar").resume();
16    xios::CContext* context = CContext::getCurrent();
17    if (!context->hasServer && !context->client->isAttachedModeEnabled())
18      context->checkBuffersAndListen();
19    context->updateCalendar(step);
20    context->sendUpdateCalendar(step);
21    CTimer::get("XIOS update calendar").suspend();
22    CTimer::get("XIOS").suspend();
23  }
24  CATCH_DUMP_STACK
25
26  void cxios_get_current_date(cxios_date* current_date_c)
27  TRY
28  {
29    CTimer::get("XIOS").resume();
30    const xios::CContext* context = CContext::getCurrent();
31    const std::shared_ptr<xios::CCalendar> cal = context->getCalendar();
32    if (!cal)
33      ERROR("void cxios_get_current_date(cxios_date* current_date_c)",
34            << "Impossible to get the current date: no calendar was defined.");
35    const CDate& currentDate = cal->getCurrentDate();
36    current_date_c->year = currentDate.getYear();
37    current_date_c->month = currentDate.getMonth();
38    current_date_c->day = currentDate.getDay();
39    current_date_c->hour = currentDate.getHour();
40    current_date_c->minute = currentDate.getMinute();
41    current_date_c->second = currentDate.getSecond();
42    CTimer::get("XIOS").suspend();
43  }
44  CATCH_DUMP_STACK
45
46  int cxios_get_year_length_in_seconds(int year)
47  TRY
48  {
49    CTimer::get("XIOS").resume();
50    const std::shared_ptr<xios::CCalendar> cal = CContext::getCurrent()->getCalendar();
51    if (!cal)
52      ERROR("int cxios_get_year_length_in_seconds(int year)",
53            << "Impossible to get the year length: no calendar was defined.");
54    int length = cal->getYearTotalLength(CDate(*cal, year, 01, 01));
55    CTimer::get("XIOS").suspend();
56
57    return length;
58  }
59  CATCH_DUMP_STACK
60
61  int cxios_get_day_length_in_seconds()
62  TRY
63  {
64    CTimer::get("XIOS").resume();
65    const std::shared_ptr<xios::CCalendar> cal = CContext::getCurrent()->getCalendar();
66    if (!cal)
67      ERROR("int cxios_get_day_length_in_seconds()",
68            << "Impossible to get the day length: no calendar was defined.");
69    int length = cal->getDayLengthInSeconds();
70    CTimer::get("XIOS").suspend();
71
72    return length;
73  }
74  CATCH_DUMP_STACK
75}
Note: See TracBrowser for help on using the repository browser.