source: XIOS/trunk/src/interface/c_attr/iccontext_attr.cpp @ 532

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

Add a new attribute type for dates and use it for the context's start_date and time_origin.

The "xios_date" type should now be used to get/set date attributes through the Fortran interface. This avoids using strings to manipulate dates.

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
  • Property svn:eol-style set to native
File size: 6.1 KB
RevLine 
[325]1/* ************************************************************************** *
2 *               Interface auto generated - do not modify                   *
3 * ************************************************************************** */
4
5#include <boost/multi_array.hpp>
6#include <boost/shared_ptr.hpp>
7#include "xmlioserver.hpp"
[352]8#include "attribute_template.hpp"
9#include "object_template.hpp"
10#include "group_template.hpp"
[325]11#include "icutil.hpp"
[532]12#include "icdate.hpp"
[347]13#include "timer.hpp"
[369]14#include "node_type.hpp"
[325]15
16extern "C"
17{
[345]18  typedef xios::CContext*  context_Ptr;
[325]19 
20  void cxios_set_context_calendar_type(context_Ptr context_hdl, const char * calendar_type, int calendar_type_size)
21  {
22    std::string calendar_type_str;
23    if(!cstr2string(calendar_type, calendar_type_size, calendar_type_str)) return;
[347]24     CTimer::get("XIOS").resume();
[526]25    context_hdl->calendar_type.fromString(calendar_type_str);
[347]26     CTimer::get("XIOS").suspend();
[325]27  }
28 
29  void cxios_get_context_calendar_type(context_Ptr context_hdl, char * calendar_type, int calendar_type_size)
30  {
[347]31     CTimer::get("XIOS").resume();
[526]32    if(!string_copy(context_hdl->calendar_type.getInheritedStringValue(),calendar_type , calendar_type_size))
[325]33      ERROR("void cxios_get_context_calendar_type(context_Ptr context_hdl, char * calendar_type, int calendar_type_size)", <<"Input string is to short");
[347]34     CTimer::get("XIOS").suspend();
[325]35  }
36 
[432]37  bool cxios_is_defined_context_calendar_type(context_Ptr context_hdl )
38  {
39     CTimer::get("XIOS").resume();
[445]40    return context_hdl->calendar_type.hasInheritedValue();
[432]41     CTimer::get("XIOS").suspend();
42  }
[325]43 
[432]44 
45 
[325]46  void cxios_set_context_output_dir(context_Ptr context_hdl, const char * output_dir, int output_dir_size)
47  {
48    std::string output_dir_str;
49    if(!cstr2string(output_dir, output_dir_size, output_dir_str)) return;
[347]50     CTimer::get("XIOS").resume();
[325]51    context_hdl->output_dir.setValue(output_dir_str);
[347]52     CTimer::get("XIOS").suspend();
[325]53  }
54 
55  void cxios_get_context_output_dir(context_Ptr context_hdl, char * output_dir, int output_dir_size)
56  {
[347]57     CTimer::get("XIOS").resume();
[445]58    if(!string_copy(context_hdl->output_dir.getInheritedValue(),output_dir , output_dir_size))
[325]59      ERROR("void cxios_get_context_output_dir(context_Ptr context_hdl, char * output_dir, int output_dir_size)", <<"Input string is to short");
[347]60     CTimer::get("XIOS").suspend();
[325]61  }
62 
[432]63  bool cxios_is_defined_context_output_dir(context_Ptr context_hdl )
64  {
65     CTimer::get("XIOS").resume();
[445]66    return context_hdl->output_dir.hasInheritedValue();
[432]67     CTimer::get("XIOS").suspend();
68  }
[325]69 
[432]70 
71 
[532]72  void cxios_set_context_start_date(context_Ptr context_hdl, cxios_date start_date_c)
[325]73  {
[532]74    CTimer::get("XIOS").resume();
75    context_hdl->start_date.allocate();
76    CDate& start_date = context_hdl->start_date.get();
77    start_date.setDate(start_date_c.year,
78                           start_date_c.month,
79                           start_date_c.day,
80                           start_date_c.hour,
81                           start_date_c.minute,
82                           start_date_c.second);
83    if (start_date.hasRelCalendar())
84      start_date.checkDate();
85    CTimer::get("XIOS").suspend();
[325]86  }
87 
[532]88  void cxios_get_context_start_date(context_Ptr context_hdl, cxios_date* start_date_c)
[325]89  {
[532]90    CTimer::get("XIOS").resume();
91    CDate start_date = context_hdl->start_date.getInheritedValue();
92    start_date_c->year = start_date.getYear();
93    start_date_c->month = start_date.getMonth();
94    start_date_c->day = start_date.getDay();
95    start_date_c->hour = start_date.getHour();
96    start_date_c->minute = start_date.getMinute();
97    start_date_c->second = start_date.getSecond();
98    CTimer::get("XIOS").suspend();
[325]99  }
100 
[432]101  bool cxios_is_defined_context_start_date(context_Ptr context_hdl )
102  {
103     CTimer::get("XIOS").resume();
[445]104    return context_hdl->start_date.hasInheritedValue();
[432]105     CTimer::get("XIOS").suspend();
106  }
[325]107 
[432]108 
109 
[532]110  void cxios_set_context_time_origin(context_Ptr context_hdl, cxios_date time_origin_c)
[336]111  {
[532]112    CTimer::get("XIOS").resume();
113    context_hdl->time_origin.allocate();
114    CDate& time_origin = context_hdl->time_origin.get();
115    time_origin.setDate(time_origin_c.year,
116                           time_origin_c.month,
117                           time_origin_c.day,
118                           time_origin_c.hour,
119                           time_origin_c.minute,
120                           time_origin_c.second);
121    if (time_origin.hasRelCalendar())
122      time_origin.checkDate();
123    CTimer::get("XIOS").suspend();
[336]124  }
125 
[532]126  void cxios_get_context_time_origin(context_Ptr context_hdl, cxios_date* time_origin_c)
[336]127  {
[532]128    CTimer::get("XIOS").resume();
129    CDate time_origin = context_hdl->time_origin.getInheritedValue();
130    time_origin_c->year = time_origin.getYear();
131    time_origin_c->month = time_origin.getMonth();
132    time_origin_c->day = time_origin.getDay();
133    time_origin_c->hour = time_origin.getHour();
134    time_origin_c->minute = time_origin.getMinute();
135    time_origin_c->second = time_origin.getSecond();
136    CTimer::get("XIOS").suspend();
[336]137  }
138 
[432]139  bool cxios_is_defined_context_time_origin(context_Ptr context_hdl )
140  {
141     CTimer::get("XIOS").resume();
[445]142    return context_hdl->time_origin.hasInheritedValue();
[432]143     CTimer::get("XIOS").suspend();
144  }
[336]145 
[432]146 
147 
[325]148  void cxios_set_context_timestep(context_Ptr context_hdl, const char * timestep, int timestep_size)
149  {
150    std::string timestep_str;
151    if(!cstr2string(timestep, timestep_size, timestep_str)) return;
[347]152     CTimer::get("XIOS").resume();
[325]153    context_hdl->timestep.setValue(timestep_str);
[347]154     CTimer::get("XIOS").suspend();
[325]155  }
156 
157  void cxios_get_context_timestep(context_Ptr context_hdl, char * timestep, int timestep_size)
158  {
[347]159     CTimer::get("XIOS").resume();
[445]160    if(!string_copy(context_hdl->timestep.getInheritedValue(),timestep , timestep_size))
[325]161      ERROR("void cxios_get_context_timestep(context_Ptr context_hdl, char * timestep, int timestep_size)", <<"Input string is to short");
[347]162     CTimer::get("XIOS").suspend();
[325]163  }
164 
[432]165  bool cxios_is_defined_context_timestep(context_Ptr context_hdl )
166  {
167     CTimer::get("XIOS").resume();
[445]168    return context_hdl->timestep.hasInheritedValue();
[432]169     CTimer::get("XIOS").suspend();
170  }
[325]171 
172 
[432]173 
174 
[325]175}
Note: See TracBrowser for help on using the repository browser.