source: XMLIO_V2/dev/common/src/xmlio/fortran/icaxis.cpp @ 286

Last change on this file since 286 was 286, checked in by ymipsl, 12 years ago

reprise en main de la version de H. Ozdoba. Correction de différentes erreurs de conception et bug.
Version NEMO operationnel en client/server, interoperabilita avec OASIS, reconstition de fichiers via netcdf4/HDF5

YM

File size: 5.1 KB
Line 
1/* ************************************************************************** *
2 *      Copyright © IPSL/LSCE, XMLIOServer, Avril 2010 - Octobre 2011         *
3 * ************************************************************************** */
4
5#include <boost/multi_array.hpp>
6#include <boost/shared_ptr.hpp>
7
8#include "xmlioserver.hpp"
9
10#include "object_template_impl.hpp"
11#include "group_template_impl.hpp"
12#include "attribute_template_impl.hpp"
13
14#include "icutil.hpp"
15
16extern "C"
17{
18// /////////////////////////////// Définitions ////////////////////////////// //
19
20   // ----------------------- Redéfinition de types ----------------------------
21   
22   typedef xmlioserver::tree::CAxis      * XAxisPtr;
23   typedef xmlioserver::tree::CAxisGroup * XAxisGroupPtr;
24
25   // ------------------------- Attributs des axes -----------------------------
26   void cxios_set_axis_name 
27      (XAxisPtr axis_hdl, const char * name , int name_size)
28   {
29      std::string name_str; 
30      if (!cstr2string(name, name_size, name_str)) return;
31
32      axis_hdl->name.setValue(name_str);
33   }
34
35   void cxios_set_axis_standard_name
36      (XAxisPtr axis_hdl, const char * standard_name , int standard_name_size)
37   {
38      std::string standard_name_str; 
39      if (!cstr2string(standard_name, standard_name_size, standard_name_str)) return;
40
41      axis_hdl->standard_name.setValue(standard_name_str);
42   }
43   
44   void cxios_set_axis_long_name 
45      (XAxisPtr axis_hdl, const char * long_name , int long_name_size)
46   {
47      std::string long_name_str; 
48      if (!cstr2string(long_name, long_name_size, long_name_str)) return;
49
50      axis_hdl->long_name.setValue(long_name_str);
51   }
52
53   void cxios_set_axis_unit 
54      (XAxisPtr axis_hdl, const char * unit , int unit_size)
55   {
56      std::string unit_str; 
57      if (!cstr2string(unit, unit_size, unit_str)) return;
58
59      axis_hdl->unit.setValue(unit_str);
60   }
61   
62   void cxios_set_axis_size(XAxisPtr axis_hdl, int size)
63   {
64      axis_hdl->size.setValue(size);
65   }
66
67   void cxios_set_axis_zvalue 
68      (XAxisPtr axis_hdl, const double * zvalue , int zvalue_extent1)
69   {
70      ARRAY(double, 1) zvalue_val(new CArray<double, 1>(boost::extents [zvalue_extent1]));
71      std::copy(zvalue, &(zvalue[zvalue_val->num_elements()]), zvalue_val->data());
72
73      axis_hdl->zvalue.setValue(zvalue_val);
74
75   }
76   
77   // -------------------- Attributs des groupes d'axes -------------------------
78   
79   void cxios_set_axisgroup_name 
80      (XAxisGroupPtr axisgroup_hdl, const char * name , int name_size)
81   {
82      std::string name_str;
83      if (!cstr2string(name, name_size, name_str)) return;
84
85      axisgroup_hdl->name.setValue(name_str);
86   }
87
88   void cxios_set_axisgroup_standard_name
89      (XAxisGroupPtr axisgroup_hdl, const char * standard_name , int standard_name_size)
90   {
91      std::string standard_name_str;
92      if (!cstr2string(standard_name, standard_name_size, standard_name_str)) return;
93
94      axisgroup_hdl->standard_name.setValue(standard_name_str);
95   }
96   
97   void cxios_set_axisgroup_long_name 
98      (XAxisGroupPtr axisgroup_hdl, const char * long_name , int long_name_size)
99   {
100      std::string long_name_str;
101      if (!cstr2string(long_name, long_name_size, long_name_str)) return;
102
103      axisgroup_hdl->long_name.setValue(long_name_str);
104   }
105
106   void cxios_set_axisgroup_unit 
107      (XAxisGroupPtr axisgroup_hdl, const char * unit , int unit_size)
108   {
109      std::string unit_str;
110      if (!cstr2string(unit, unit_size, unit_str)) return;
111
112      axisgroup_hdl->unit.setValue(unit_str);
113   }
114   
115   void cxios_set_axisgroup_size(XAxisGroupPtr axisgroup_hdl, int size)
116   {
117      axisgroup_hdl->size.setValue(size);
118   }
119
120   void cxios_set_axisgroup_zvalue 
121      (XAxisGroupPtr axisgroup_hdl, const double * zvalue , int zvalue_extent1)
122   {
123      ARRAY(double, 1) zvalue_val(new CArray<double, 1>(boost::extents [zvalue_extent1]));
124      std::copy(zvalue, &(zvalue[zvalue_val->num_elements()]), zvalue_val->data());
125
126      axisgroup_hdl->zvalue.setValue(zvalue_val);
127   }
128   
129   // ------------------------ Création des handle -----------------------------
130   
131   void cxios_axis_handle_create (XAxisPtr * _ret, const char * _id, int _id_len)
132   {
133      std::string id; 
134      if (!cstr2string(_id, _id_len, id)) return;
135
136      *_ret = xmlioserver::CObjectFactory::GetObject<xmlioserver::tree::CAxis>(id).get();
137   }
138   
139   void cxios_axisgroup_handle_create (XAxisGroupPtr * _ret, const char * _id, int _id_len)
140   {
141      std::string id; 
142      if (!cstr2string(_id, _id_len, id)) return;
143
144      *_ret = xmlioserver::CObjectFactory::GetObject<xmlioserver::tree::CAxisGroup>(id).get();
145   }
146
147   // -------------------- Vérification des identifiants -----------------------
148
149   void cxios_axis_valid_id (bool * _ret, const char * _id, int _id_len)
150   {
151      std::string id;
152      if (!cstr2string(_id, _id_len, id)) return;
153
154      *_ret = xmlioserver::CObjectFactory::HasObject<xmlioserver::tree::CAxis>(id);
155   }
156
157   void cxios_axisgroup_valid_id (bool * _ret, const char * _id, int _id_len)
158   {
159      std::string id;
160      if (!cstr2string(_id, _id_len, id)) return;
161
162      *_ret = xmlioserver::CObjectFactory::HasObject<xmlioserver::tree::CAxisGroup>(id);
163   }
164   
165} // extern "C"
Note: See TracBrowser for help on using the repository browser.