source: XIOS/dev/dev_ym/XIOS_ONE_SIDED/src/interface/c/iccalendar.cpp @ 1753

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

more timers

YM

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