source: XIOS/dev/branch_openmp/src/interface/c/iccalendar.cpp @ 1545

Last change on this file since 1545 was 1545, checked in by yushan, 6 years ago

branch_openmp merged with trunk r1544

File size: 2.1 KB
Line 
1#include "xios.hpp"
2
3#include "icdate.hpp"
4#include "exception.hpp"
5#include "timer.hpp"
6#include "context.hpp"
7#include "context_client.hpp"
8
9extern "C"
10{
11  void cxios_update_calendar(int step)
12  {
13    CTimer::get("XIOS").resume();
14    xios::CContext* context = CContext::getCurrent();
15    if (!context->hasServer && !context->client->isAttachedModeEnabled())
16      context->checkBuffersAndListen();
17    context->updateCalendar(step);
18    context->sendUpdateCalendar(step);
19    CTimer::get("XIOS").suspend();
20  }
21
22  void cxios_get_current_date(cxios_date* current_date_c)
23  {
24    CTimer::get("XIOS").resume();
25    const xios::CContext* context = CContext::getCurrent();
26    const std::shared_ptr<xios::CCalendar> cal = context->getCalendar();
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();
37    CTimer::get("XIOS").suspend();
38  }
39
40  int cxios_get_year_length_in_seconds(int year)
41  {
42    CTimer::get("XIOS").resume();
43    const std::shared_ptr<xios::CCalendar> cal = CContext::getCurrent()->getCalendar();
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();
56    const std::shared_ptr<xios::CCalendar> cal = CContext::getCurrent()->getCalendar();
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  }
65}
Note: See TracBrowser for help on using the repository browser.