source: XIOS/trunk/src/interface/c/iccalendar.cpp @ 1542

Last change on this file since 1542 was 1542, checked in by oabramkina, 6 years ago

Replacing Boost's unordered_map and shared_pointer by its STL counterparts.

Two notes for Curie:

  • one can see the content of unordered_map with ddt only if XIOS has been compiled with gnu
  • XIOS will not compile any more with pgi (all available versions use old STL which are not up to the c++11 norms)
File size: 2.1 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)
[545]12  {
13    CTimer::get("XIOS").resume();
14    xios::CContext* context = CContext::getCurrent();
[704]15    if (!context->hasServer && !context->client->isAttachedModeEnabled())
16      context->checkBuffersAndListen();
[549]17    context->updateCalendar(step);
18    context->sendUpdateCalendar(step);
[545]19    CTimer::get("XIOS").suspend();
20  }
21
[549]22  void cxios_get_current_date(cxios_date* current_date_c)
[545]23  {
24    CTimer::get("XIOS").resume();
[549]25    const xios::CContext* context = CContext::getCurrent();
[1542]26    const std::shared_ptr<xios::CCalendar> cal = context->getCalendar();
[549]27    if (!cal)
28      ERROR("void cxios_get_current_date(cxios_date* current_date_c)",
29            << "Impossible to get the current date: no calendar was defined.");
30    const CDate& currentDate = cal->getCurrentDate();
31    current_date_c->year = currentDate.getYear();
32    current_date_c->month = currentDate.getMonth();
33    current_date_c->day = currentDate.getDay();
34    current_date_c->hour = currentDate.getHour();
35    current_date_c->minute = currentDate.getMinute();
36    current_date_c->second = currentDate.getSecond();
[545]37    CTimer::get("XIOS").suspend();
38  }
[549]39
40  int cxios_get_year_length_in_seconds(int year)
41  {
42    CTimer::get("XIOS").resume();
[1542]43    const std::shared_ptr<xios::CCalendar> cal = CContext::getCurrent()->getCalendar();
[549]44    if (!cal)
45      ERROR("int cxios_get_year_length_in_seconds(int year)",
46            << "Impossible to get the year length: no calendar was defined.");
47    int length = cal->getYearTotalLength(CDate(*cal, year, 01, 01));
48    CTimer::get("XIOS").suspend();
49
50    return length;
51  }
52
53  int cxios_get_day_length_in_seconds()
54  {
55    CTimer::get("XIOS").resume();
[1542]56    const std::shared_ptr<xios::CCalendar> cal = CContext::getCurrent()->getCalendar();
[549]57    if (!cal)
58      ERROR("int cxios_get_day_length_in_seconds()",
59            << "Impossible to get the day length: no calendar was defined.");
60    int length = cal->getDayLengthInSeconds();
61    CTimer::get("XIOS").suspend();
62
63    return length;
64  }
[545]65}
Note: See TracBrowser for help on using the repository browser.