source: XIOS2/trunk/src/interface/c/iccalendar.cpp @ 2428

Last change on this file since 2428 was 2428, checked in by jderouillat, 17 months ago

Backport the XIOS3 system to log the memory consumption (commit ID [2418-2420,2425-2426])

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