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

Last change on this file since 545 was 545, checked in by rlacroix, 9 years ago

Expose the calendar operations through the Fortran interface.

  • Add arithmetic operations on the xios_duration and xios_date types:
    • xios_duration + xios_duration = xios_duration
    • xios_duration - xios_duration = xios_duration
    • scalar * xios_duration = xios_duration * scalar = xios_duration
    • - xios_duration = xios_duration
    • xios_date + xios_duration = xios_date
    • xios_date - xios_duration = xios_date
    • xios_date - xios_date = xios_duration
  • Add comparison operations on the xios_duration and xios_date types:
    • xios_duration: ==, /=
    • xios_date: ==, /=, <, <=, >, >=
  • Add a new function "xios_date_convert_to_seconds" to convert a date into the number of seconds since the time origin of the calendar
  • Define some constant durations "xios_second", "xios_minute", "xios_hour", "xios_day", "xios_month", "xios_year" et "xios_timestep" to ease the definition of new durations (for example, 10h is just 10 * xios_hour)
  • Add a new function "xios_set_calendar" so that one can manually create the calendar attached to the current context and thus use the calendar operations before calling "xios_close_context_definition". This function can accept optional parameters so that the calendar attributes (calendar_type, start_date, time_origin and timestep) can be easily overwritten. Note that you cannot define a new calendar after one was already created (either because "xios_set_calendar" or "xios_close_context_definition" was used)
  • Readd the function "xios_set_timestep" as a simplified alias of "xios_set_context_attr(context, timestep)" for the current context
File size: 671 bytes
Line 
1#include "xmlioserver.hpp"
2
3#include "exception.hpp"
4#include "timer.hpp"
5#include "context.hpp"
6#include "context_client.hpp"
7
8extern "C"
9{
10  void cxios_create_calendar()
11  {
12    CTimer::get("XIOS").resume();
13    xios::CContext* context = CContext::getCurrent();
14    if (context->hasClient)
15      context->solveCalendar();
16    CTimer::get("XIOS").suspend();
17  }
18
19  void cxios_update_calendar(int step)
20  {
21    CTimer::get("XIOS").resume();
22    xios::CContext* context = CContext::getCurrent();
23    if (!context->hasServer) context->client->checkBuffers();
24    context->updateCalendar(step);
25    context->sendUpdateCalendar(step);
26    CTimer::get("XIOS").suspend();
27  }
28}
Note: See TracBrowser for help on using the repository browser.