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

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

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

File size: 2.4 KB
RevLine 
[591]1#include "xios.hpp"
[545]2
[549]3#include "icdate.hpp"
[545]4#include "exception.hpp"
5#include "timer.hpp"
[2428]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  {
[2428]15    CMemChecker::get("XIOS update calendar").resume();
[545]16    CTimer::get("XIOS").resume();
17    xios::CContext* context = CContext::getCurrent();
[704]18    if (!context->hasServer && !context->client->isAttachedModeEnabled())
19      context->checkBuffersAndListen();
[549]20    context->updateCalendar(step);
21    context->sendUpdateCalendar(step);
[545]22    CTimer::get("XIOS").suspend();
[2428]23    CMemChecker::get("XIOS update calendar").suspend();
[545]24  }
[1622]25  CATCH_DUMP_STACK
[545]26
[549]27  void cxios_get_current_date(cxios_date* current_date_c)
[1622]28  TRY
[545]29  {
30    CTimer::get("XIOS").resume();
[549]31    const xios::CContext* context = CContext::getCurrent();
[1542]32    const std::shared_ptr<xios::CCalendar> cal = context->getCalendar();
[549]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();
[545]43    CTimer::get("XIOS").suspend();
44  }
[1622]45  CATCH_DUMP_STACK
[549]46
47  int cxios_get_year_length_in_seconds(int year)
[1622]48  TRY
[549]49  {
50    CTimer::get("XIOS").resume();
[1542]51    const std::shared_ptr<xios::CCalendar> cal = CContext::getCurrent()->getCalendar();
[549]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  }
[1622]60  CATCH_DUMP_STACK
[549]61
62  int cxios_get_day_length_in_seconds()
[1622]63  TRY
[549]64  {
65    CTimer::get("XIOS").resume();
[1542]66    const std::shared_ptr<xios::CCalendar> cal = CContext::getCurrent()->getCalendar();
[549]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  }
[1622]75  CATCH_DUMP_STACK
[2428]76}
Note: See TracBrowser for help on using the repository browser.