source: XIOS3/trunk/src/interface/c/iccalendar.cpp @ 2426

Last change on this file since 2426 was 2426, checked in by jderouillat, 19 months ago

Clean MemCheckcer?, add memory consumption accumulators in main XIOS interfaces for clients, and in the NetCDF interface for servers.

File size: 2.5 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    CTimer::get("XIOS update calendar").resume();
18    xios::CContext* context = CContext::getCurrent();
19//    if (!context->hasServer && !context->client->isAttachedModeEnabled())
20      context->eventLoop();
21//ym      context->checkBuffersAndListen();
22     
23    context->updateCalendar(step);
24    context->sendUpdateCalendar(step);
25    CTimer::get("XIOS update calendar").suspend();
26    CTimer::get("XIOS").suspend();
27    CMemChecker::get("XIOS update calendar").suspend();
28  }
29  CATCH_DUMP_STACK
30
31  void cxios_get_current_date(cxios_date* current_date_c)
32  TRY
33  {
34    CTimer::get("XIOS").resume();
35    const xios::CContext* context = CContext::getCurrent();
36    const std::shared_ptr<xios::CCalendar> cal = context->getCalendar();
37    if (!cal)
38      ERROR("void cxios_get_current_date(cxios_date* current_date_c)",
39            << "Impossible to get the current date: no calendar was defined.");
40    const CDate& currentDate = cal->getCurrentDate();
41    current_date_c->year = currentDate.getYear();
42    current_date_c->month = currentDate.getMonth();
43    current_date_c->day = currentDate.getDay();
44    current_date_c->hour = currentDate.getHour();
45    current_date_c->minute = currentDate.getMinute();
46    current_date_c->second = currentDate.getSecond();
47    CTimer::get("XIOS").suspend();
48  }
49  CATCH_DUMP_STACK
50
51  int cxios_get_year_length_in_seconds(int year)
52  TRY
53  {
54    CTimer::get("XIOS").resume();
55    const std::shared_ptr<xios::CCalendar> cal = CContext::getCurrent()->getCalendar();
56    if (!cal)
57      ERROR("int cxios_get_year_length_in_seconds(int year)",
58            << "Impossible to get the year length: no calendar was defined.");
59    int length = cal->getYearTotalLength(CDate(*cal, year, 01, 01));
60    CTimer::get("XIOS").suspend();
61
62    return length;
63  }
64  CATCH_DUMP_STACK
65
66  int cxios_get_day_length_in_seconds()
67  TRY
68  {
69    CTimer::get("XIOS").resume();
70    const std::shared_ptr<xios::CCalendar> cal = CContext::getCurrent()->getCalendar();
71    if (!cal)
72      ERROR("int cxios_get_day_length_in_seconds()",
73            << "Impossible to get the day length: no calendar was defined.");
74    int length = cal->getDayLengthInSeconds();
75    CTimer::get("XIOS").suspend();
76
77    return length;
78  }
79  CATCH_DUMP_STACK
80}
Note: See TracBrowser for help on using the repository browser.