source: XIOS3/branches/xios-3.0-beta/src/interface/c/iccalendar.cpp @ 2427

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

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

File size: 2.5 KB
RevLine 
[591]1#include "xios.hpp"
[545]2
[549]3#include "icdate.hpp"
[545]4#include "exception.hpp"
5#include "timer.hpp"
[2427]6#include "mem_checker.hpp"
[545]7#include "context.hpp"
8#include "context_client.hpp"
9
10extern "C"
11{
[549]12  void cxios_update_calendar(int step)
[1622]13  TRY
[545]14  {
[2427]15    CMemChecker::get("XIOS update calendar").resume();
[545]16    CTimer::get("XIOS").resume();
[1753]17    CTimer::get("XIOS update calendar").resume();
[545]18    xios::CContext* context = CContext::getCurrent();
[704]19    if (!context->hasServer && !context->client->isAttachedModeEnabled())
[1761]20      context->eventLoop();
21//ym      context->checkBuffersAndListen();
22     
[549]23    context->updateCalendar(step);
24    context->sendUpdateCalendar(step);
[1753]25    CTimer::get("XIOS update calendar").suspend();
[545]26    CTimer::get("XIOS").suspend();
[2427]27    CMemChecker::get("XIOS update calendar").suspend();
[545]28  }
[1622]29  CATCH_DUMP_STACK
[545]30
[549]31  void cxios_get_current_date(cxios_date* current_date_c)
[1622]32  TRY
[545]33  {
34    CTimer::get("XIOS").resume();
[549]35    const xios::CContext* context = CContext::getCurrent();
[1542]36    const std::shared_ptr<xios::CCalendar> cal = context->getCalendar();
[549]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();
[545]47    CTimer::get("XIOS").suspend();
48  }
[1622]49  CATCH_DUMP_STACK
[549]50
51  int cxios_get_year_length_in_seconds(int year)
[1622]52  TRY
[549]53  {
54    CTimer::get("XIOS").resume();
[1542]55    const std::shared_ptr<xios::CCalendar> cal = CContext::getCurrent()->getCalendar();
[549]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  }
[1622]64  CATCH_DUMP_STACK
[549]65
66  int cxios_get_day_length_in_seconds()
[1622]67  TRY
[549]68  {
69    CTimer::get("XIOS").resume();
[1542]70    const std::shared_ptr<xios::CCalendar> cal = CContext::getCurrent()->getCalendar();
[549]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  }
[1622]79  CATCH_DUMP_STACK
[2427]80}
Note: See TracBrowser for help on using the repository browser.