- Timestamp:
- 11/17/10 14:40:14 (14 years ago)
- Location:
- XMLIO_V2/dev/dev_rv/src/XMLIO
- Files:
-
- 1 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/src/XMLIO/NetCDF4_data_output.hpp
r131 r137 22 22 void writeVarData(const string& id, const Array<float, 1>& vdata) 23 23 { 24 //if (!latVar->put(lats, NLAT)) 25 // return NC_ERR; 26 } 27 28 virtual ~NetCDF4DataOutput() 24 25 } 26 27 virtual ~NetCDF4DataOutput( void) 29 28 { if (dataFile != NULL) delete dataFile; } 30 29 … … 192 191 hm["long_name"] = "Latitude" ; 193 192 hm["nav_model"] = domid ; 194 if ((*itt)-> yvalue.hasValue())195 { 196 hmf["valid_min"] = ((Array<double, 1>)(*itt)-> yvalue)(0);197 hmf["valid_max"] = ((Array<double, 1>)(*itt)-> yvalue)(((Array<double, 1>)(*itt)->yvalue).size()-1);193 if ((*itt)->latvalue.hasValue()) 194 { 195 hmf["valid_min"] = ((Array<double, 1>)(*itt)->latvalue)(0); 196 hmf["valid_max"] = ((Array<double, 1>)(*itt)->latvalue)(((Array<double, 1>)(*itt)->latvalue).size()-1); 198 197 this->addStringAttributesToVar(latVar, hmf); 199 198 hmf.clear(); … … 208 207 hm["long_name"] = "Longitude" ; 209 208 hm["nav_model"] = domid ; 210 if ((*itt)-> xvalue.hasValue())211 { 212 hmf["valid_min"] = ((Array<double, 1>)(*itt)-> xvalue)(0);213 hmf["valid_max"] = ((Array<double, 1>)(*itt)-> xvalue)(((Array<double, 1>)(*itt)->xvalue).size()-1);209 if ((*itt)->lonvalue.hasValue()) 210 { 211 hmf["valid_min"] = ((Array<double, 1>)(*itt)->lonvalue)(0); 212 hmf["valid_max"] = ((Array<double, 1>)(*itt)->lonvalue)(((Array<double, 1>)(*itt)->lonvalue).size()-1); 214 213 this->addStringAttributesToVar(lonVar, hmf); 215 214 hmf.clear(); … … 218 217 hm.clear(); 219 218 220 if ((*itt)-> yvalue.hasValue())221 this->writeCoords(lonid, (*itt)-> xvalue);219 if ((*itt)->lonvalue.hasValue()) 220 this->writeCoords(lonid, (*itt)->lonvalue); 222 221 else throw XMLIOUndefinedValueException 223 222 ("Les coordonnées de longitude (xvalue) ne sont pas définies pour le domaine \""+domid+"\"."); 224 223 225 if ((*itt)-> xvalue.hasValue())226 this->writeCoords(latid, (*itt)-> yvalue);224 if ((*itt)->latvalue.hasValue()) 225 this->writeCoords(latid, (*itt)->latvalue); 227 226 else throw XMLIOUndefinedValueException 228 227 ("Les coordonnées de latitude (yvalue) ne sont pas définies pour le domaine \""+domid+"\"."); … … 244 243 if ((*it)->long_name.hasValue()) hm["long_name"] = (*it)->long_name ; 245 244 if ((*it)->unit.hasValue()) hm["units"] = (*it)->unit; 246 if ((*it)-> value.hasValue())247 { 248 hmf["valid_min"] = ((Array<double, 1>)(*it)-> value)(0);249 hmf["valid_max"] = ((Array<double, 1>)(*it)-> value)(((Array<double, 1>)(*it)->value).size()-1);245 if ((*it)->zvalue.hasValue()) 246 { 247 hmf["valid_min"] = ((Array<double, 1>)(*it)->zvalue)(0); 248 hmf["valid_max"] = ((Array<double, 1>)(*it)->zvalue)(((Array<double, 1>)(*it)->zvalue).size()-1); 250 249 this->addStringAttributesToVar(othvar, hmf); 251 250 hmf.clear(); … … 254 253 hm.clear(); 255 254 256 if ((*it)-> value.hasValue())257 this->writeCoords(axisid, (*it)-> value);255 if ((*it)->zvalue.hasValue()) 256 this->writeCoords(axisid, (*it)->zvalue); 258 257 else throw XMLIOUndefinedValueException 259 258 ("Les coordonnées de l'axe \""+axisid+"\" (value) ne sont pas définies."); -
XMLIO_V2/dev/dev_rv/src/XMLIO/abstract_data_output.hpp
r126 r137 4 4 namespace XMLIOSERVER 5 5 { 6 7 6 class CFile; 8 7 … … 25 24 } 26 25 27 virtual ~AbstractDataOutput( )26 virtual ~AbstractDataOutput(void) 28 27 { /* Ne rien faire de plus */ } 29 28 -
XMLIO_V2/dev/dev_rv/src/XMLIO/attribut.hpp
r128 r137 17 17 18 18 Attribut(void) 19 : BaseAttribut(), _hasValue(false) 19 : BaseAttribut(), _hasValue(false), value() 20 20 { /* Ne rien faire de plus */ } 21 21 … … 37 37 operator Ctype() const 38 38 { 39 if (!_hasValue) throw XMLIOUndefinedValueException("L'attribut \"" + this->getName() + "\" est invalide !"); 39 if (!_hasValue) 40 throw XMLIOUndefinedValueException("L'attribut \"" + this->getName() + "\" est invalide !"); 40 41 return (value) ; 42 } 43 44 Ctype* getValue(void) 45 { 46 //if (!_hasValue) return(NULL); // REVOIR: 4 h de debug à cause de ça !!! 47 return (&value); 41 48 } 42 49 … … 60 67 61 68 virtual ostream& print(std::ostream & _out) const 62 { if (_hasValue) _out << " " << getName() << "=\"" << boolalpha << value << "\"" ; return (_out) ; } 69 { 70 if (_hasValue) 71 { 72 _out << " " << getName() 73 << "=\"" << boolalpha << value << "\"" ; 74 } 75 return (_out) ; 76 } 63 77 64 78 virtual void setValue(const Ctype & value_) 65 79 { _hasValue = true ; value = value_ ;} 66 80 67 Ctype* getValue(void)68 { if (!_hasValue) return(NULL); return (&value); }69 70 81 virtual void getValue(Ctype & value_) const 71 82 { … … 74 85 } 75 86 76 virtual ~Attribut( )87 virtual ~Attribut(void) 77 88 { /* Ne rien faire de plus */ } 78 89 … … 89 100 { _hasValue = true ; value.resize(val.shape()); value = val ; } 90 101 91 #define PRINT_ARRAY (type)\102 #define PRINT_ARRAY1(type) \ 92 103 template <> \ 93 104 ostream& Attribut<Array<type, 1> >::print(ostream & _out) const \ 94 105 { \ 95 if (_hasValue) _out << " " << getName() << "=\"" << value(0); \ 96 _out << "..." << value(value.size()-1); _out << "\"" ; \ 106 if (_hasValue) \ 107 _out << " " << getName() << "=\"" << value(0) \ 108 << "(" << value.extent(0) << ")" \ 109 << value(value.size()-1); _out << "\"" ; \ 97 110 return (_out) ; \ 98 111 } 99 112 113 #define PRINT_ARRAY2(type) \ 114 template <> \ 115 ostream& Attribut<Array<type, 2> >::print(ostream & _out) const \ 116 { \ 117 if (_hasValue) \ 118 _out << " " << getName() << "=\"" << value(0, 0) \ 119 << "(" << value.extent(0) << "," << value.extent(1) << ")" \ 120 << value(value.extent(0)-1, value.extent(1)-1) \ 121 << "\"" ; \ 122 return (_out) ; \ 123 } 124 100 125 #define SET_ARRAY_TYPE(type) \ 101 PRINT_ARRAY(type) \ 126 PRINT_ARRAY1(type) \ 127 PRINT_ARRAY2(type) \ 102 128 SET_ARRAY_DIM(type, 1) \ 103 129 SET_ARRAY_DIM(type, 2) \ … … 167 193 void Attribut<bool>::setFromString(const std::string& str) 168 194 { 169 istringstream iss(str) ;170 const bool val = (! iss.str().compare(string(".TRUE."))) ? true : false;195 const bool val = 196 (str.compare(string(".TRUE.")) == 0) ? true : false; 171 197 this->setValue(val); 172 198 } -
XMLIO_V2/dev/dev_rv/src/XMLIO/axis_attribut.hpp
r126 r137 16 16 DECLARE_ATTR(unit , string) ; 17 17 DECLARE_ATTR(size , int) ; 18 DECLARE_ATTR( value, Array(double, 1)) ;18 DECLARE_ATTR(zvalue , Array(double, 1)) ; 19 19 20 20 AxisAttribut(void) : AttributRegistrar() … … 30 30 RegisterAttribut(&unit) ; 31 31 RegisterAttribut(&size) ; 32 RegisterAttribut(& value) ;32 RegisterAttribut(&zvalue) ; 33 33 } 34 34 -
XMLIO_V2/dev/dev_rv/src/XMLIO/c_interface.cpp
r134 r137 2 2 3 3 /* ********************************************************** */ 4 /* CONVERSION FUNCTION */5 /* ********************************************************** */6 7 static inline std::string stringXtoStd(const XString _str)8 {9 char * const temp = new char[_str.len+1]();10 memset(temp, '\0', _str.len+1);11 memcpy(temp, _str.str, _str.len);12 std::string _retstr(temp);13 size_t d = _retstr.find_first_not_of(' ');14 size_t f = _retstr.find_last_not_of (' ');15 16 delete[] temp;17 return (_retstr.substr(d, f-d+1));18 }19 20 static inline XString stringXtoStd(const std::string& _str) // Non testée21 {22 XString _retstr = {new char[_str.size()](), _str.size()};23 memcpy(_retstr.str, _str.c_str(), _str.size());24 return (_retstr);25 }26 27 static inline Duration durationXtoXMLIO(const XDuration * const _xdur) // Non testée28 {29 Duration __dur= { _xdur->year, _xdur->month , _xdur->day,30 _xdur->hour, _xdur->minute, _xdur->second };31 return (__dur);32 }33 34 /* ********************************************************** */35 4 /* HANDLE INTERFACE */ 36 5 /* ********************************************************** */ 37 6 38 void xios_handle_create_(XHandle * const _ret, const XDType * const _dtype, const XString _id) 39 { 40 // Si le handle n'est pas initialisé à 0, on ne fait aucun traitement. 41 if (!isNullHandle(*_ret)) return; 42 std::string __id = stringXtoStd(_id); 43 switch(*_dtype) 44 { 45 /* EAXIS, EDOMAIN, EFIELD, EFILE, EGRID, GAXIS, GDOMAIN, GFIELD, GFILE, GGRID*/ 7 #define CASE_ELEM(elem_enum, elem_class) \ 8 case (E##elem_enum): \ 9 *_ret = (!C##elem_class::HasObject(__id)) ? \ 10 0 : C##elem_class::GetObject(__id); \ 11 return; \ 12 case (G##elem_enum): \ 13 *_ret = (!elem_class##Group::HasObject(__id)) ? \ 14 0 : elem_class##Group::GetObject(__id); \ 15 return; 16 17 void xios_handle_create (XPtr * const _ret, XDType _dtype, 18 const XString _id, XSize _id_len) 19 { 20 MAKE_STRING(__id, _id, _id_len); 21 switch(_dtype) 22 { 46 23 case (ECONTEXT): 47 24 // Si le context n'existe pas, on retourne un handle vide/nul. 48 if (!Context::HasContext(__id)) { *_ret = NULLHANDLE; return ; } 49 _ret->data_type = *_dtype; 50 _ret->data_ptr = Context::GetContext(__id); 25 *_ret = (!Context::HasContext(__id)) ? 0 : Context::GetContext(__id) ; 51 26 return ; 52 27 CASE_ELEM(AXIS , Axis); 28 CASE_ELEM(DOMAIN , Domain); 29 CASE_ELEM(FIELD , Field); 30 CASE_ELEM(FILE , File); 31 CASE_ELEM(GRID , Grid); 53 32 default : 54 *_ret = NULLHANDLE;33 *_ret = 0; 55 34 return ; 56 35 }; 57 36 } 58 37 38 #undef CASE_ELEM 39 59 40 /* ********************************************************** */ 60 41 /* XML INTERFACE */ 61 42 /* ********************************************************** */ 62 43 63 void xios_xml_parse_file _(const XString _filename)64 { 65 std::string __filename = stringXtoStd(_filename);44 void xios_xml_parse_file(const XString _filename, XSize _filename_len) 45 { 46 MAKE_STRING(__filename, _filename, _filename_len); 66 47 std::ifstream __istr( __filename.c_str() , std::ifstream::in ); 67 48 68 49 // On commence la lecture du flux de donnée xml. 69 50 XMLNode node = XMLNode::CreateNode(__istr, Context::GetRootName()); 70 71 51 // On parse le fichier xml noeud par noeud 72 52 // (ie on construit dynamiquement notre arbre d'objets). 73 53 XMLParser::Parse(node); 74 } 75 76 void xios_xml_parse_string_(const XString _xmlcontent) 77 { 78 std::string __xmlcontent = stringXtoStd(_xmlcontent); 54 55 } 56 57 void xios_xml_parse_string(const XString _xmlcontent, XSize _xmlcontent_len) 58 { 59 MAKE_STRING(__xmlcontent, _xmlcontent, _xmlcontent_len); 79 60 std::istringstream __istr(__xmlcontent); 80 61 81 62 // On commence la lecture du flux de donnée xml. 82 63 XMLNode node = XMLNode::CreateNode(__istr, Context::GetRootName()); 83 84 // On parse le fichier xml noeud par noeud 85 // (ie on construit dynamiquement notre arbre d'objets). 64 // On parse le document xml noeud par noeud 86 65 XMLParser::Parse(node); 87 66 } 88 89 /* ********************************************************** */ 90 /* DATA TREATMENT INTERFACE */ 91 /* ********************************************************** */ 92 67 /* ********************************************************** */ 68 /* CONTEXT INTERFACE */ 69 /* ********************************************************** */ 70 71 void xios_context_set_current (XPtr _ctx, bool _wswap) 72 { 73 Context* const __ctxt = (Context*) _ctx; 74 Context::SetCurrentContext(__ctxt->getId(), _wswap) ; 75 } 76 77 void xios_context_create (XPtr * _ctx, const XString _ctx_id, 78 XSize _ctx_id_len, XCalendarType _calType) 79 { 80 MAKE_STRING(__ctx_id, _ctx_id, _ctx_id_len); 81 // si le contexte existe déjà , on arrête le traitement. 82 if (Context::HasContext(__ctx_id)) { _ctx = NULL; return ; } 83 84 Context::SetCurrentContext(__ctx_id, false, false); 85 Context * context = Context::CreateObject(__ctx_id); 86 context->createDefinitions(); *_ctx = context; 87 88 if (!Context::HasContext(__ctx_id)) // Au cas où ... 89 std::cerr << "La création du contexte a échoué ???" << std::endl; 90 91 switch(_calType) 92 { 93 case (D360) : 94 context->setCalendar(new D360Calendar()); return; 95 case (ALLLEAP) : 96 context->setCalendar(new AllLeapCalendar()); return; 97 case (NOLEAP) : 98 context->setCalendar(new NoLeapCalendar()); return; 99 case (JULIAN) : 100 context->setCalendar(new JulianCalendar()); return; 101 case (GREGORIAN) : 102 context->setCalendar(new GregorianCalendar()); return; 103 default: 104 std::cerr << "[context_create] Type de calendrier invalide [0-5]" << std::endl; 105 return; 106 } 107 } 108 109 /* ********************************************************** */ 110 /* XML TREE INTERFACE */ 111 /* ********************************************************** */ 112 113 #define CASE_ELEM0(elem_enum, elem_class, group_enum, group_class) \ 114 case (group_enum) : { \ 115 group_class * _group = (group_class *) _parent; \ 116 switch(_child_type) { \ 117 case (group_enum) : \ 118 if ((_child_id_len != -1) && \ 119 (group_class::HasObject(___child_id))) return; \ 120 *_child = (_child_id_len != -1) \ 121 ? (group_class *)(&_group->createGroup(___child_id)) \ 122 : (group_class *)(&_group->createGroup()); \ 123 break; \ 124 case (elem_enum) : \ 125 if ((_child_id_len != -1) && \ 126 (elem_class::HasObject(___child_id))) return; \ 127 *_child = (_child_id_len != -1) \ 128 ? (elem_class *)(&_group->createChild(___child_id)) \ 129 : (elem_class *)(&_group->createChild()); \ 130 break; \ 131 default : \ 132 std::cerr << "[xml_tree_add] Type enfant invalide" << std::endl; \ 133 }; return; } 134 135 void xios_xml_tree_add (const XPtr _parent, XDType _parent_type, XPtr * _child, 136 XDType _child_type, const XString _child_id, XSize _child_id_len) 137 { 138 string ___child_id; 139 if (_child_id_len != -1) 140 { 141 MAKE_STRING(__child_id, _child_id, _child_id_len); 142 ___child_id = __child_id; 143 } 144 145 switch (_parent_type) 146 { 147 case (EFILE) : 148 { 149 CFile * _file = (CFile *) _parent; 150 FieldGroup * _field_group = _file->createVirtualFieldGroup(_file->getId()); 151 xios_xml_tree_add (_field_group, GFIELD, _child, _child_type, _child_id, _child_id_len); 152 return; 153 } 154 CASE_ELEM0(EAXIS, CAxis, GAXIS, AxisGroup); 155 CASE_ELEM0(EGRID, CGrid, GGRID, GridGroup); 156 CASE_ELEM0(EDOMAIN, CDomain, GDOMAIN, DomainGroup); 157 CASE_ELEM0(EFIELD, CField, GFIELD, FieldGroup); 158 CASE_ELEM0(EFILE, CFile, GFILE, FileGroup); 159 default : 160 std::cerr << "[xml_tree_add] Type parent invalide" << std::endl; 161 return; 162 } 163 } 164 165 #undef CASE_ELEM0 166 167 void xios_xml_tree_show(const XString _filename, XSize _filename_len) 168 { 169 string ___filename; 170 if (_filename_len != -1) 171 { 172 MAKE_STRING(__filename, _filename, _filename_len); 173 ___filename = __filename; 174 } 175 if (_filename_len == -1) 176 // On écrit l'arborescence résultante du traitement sur la sortie de log. 177 Context::ShowTree(std::clog); 178 else 179 { 180 std::ofstream __outfile (___filename.c_str()); 181 // On écrit l'arborescence résultante du traitement dans le fichier. 182 Context::ShowTree(__outfile); 183 __outfile.close(); 184 } 185 } 186 187 #undef XML_SET 188 #undef XML_SET_STRING 189 190 #define XML_SET(ttype, type, type_var, var, long_var) \ 191 void xios_xml_set_##type##_##var \ 192 (XPtr const _##type, XDType _dtype, type_var var){ \ 193 if (_dtype >= 10 && _dtype <= 14) { \ 194 ttype##Group * __##type = (ttype##Group *) _##type; \ 195 __##type->set_##long_var(var); \ 196 } else { \ 197 C##ttype * __##type = (C##ttype *) _##type; \ 198 __##type->set_##long_var(var); \ 199 }} 200 201 202 #define XML_SET_STRING(ttype, type, var, long_var) \ 203 void xios_xml_set_##type##_##var(XPtr const _##type, \ 204 XDType _dtype, const XString _##var, XSize _##var##_len) {\ 205 MAKE_STRING(___##var, _##var, _##var##_len); \ 206 if (_dtype >= 10 && _dtype <= 14) { \ 207 ttype##Group * __##type = (ttype##Group *) _##type; \ 208 __##type->set_##long_var(___##var); \ 209 } else { \ 210 C##ttype * __##type = (C##ttype *) _##type; \ 211 __##type->set_##long_var(___##var); \ 212 }} 213 214 // Attributs de field ou field_group // 215 XML_SET_STRING(Field, field, name, name) 216 XML_SET_STRING(Field, field, sname, standard_name) 217 XML_SET_STRING(Field, field, lname, long_name) 218 XML_SET_STRING(Field, field, unit, unit) 219 XML_SET_STRING(Field, field, operation, operation) 220 221 void xios_xml_set_field_freq_op(XPtr const _field, XDType _dtype, 222 double year, double month, double day, 223 double hour, double minute, double second) 224 { 225 const Duration _dur = {year, month, day, hour, minute, second}; 226 if (_dtype >= 10 && _dtype <= 14) 227 { 228 FieldGroup * __field = (FieldGroup *) _field; 229 __field->set_freq_op(_dur); 230 } else { 231 CField * __field = (CField *) _field; 232 __field->set_freq_op(_dur); 233 } 234 } 235 236 XML_SET(Field, field, int, level, level) 237 XML_SET(Field, field, int, prec, prec) 238 XML_SET(Field, field, bool, enabled, enabled) 239 240 XML_SET_STRING(Field, field, dref, domain_ref) 241 XML_SET_STRING(Field, field, aref, axis_ref) 242 XML_SET_STRING(Field, field, gref, grid_ref) 243 XML_SET_STRING(Field, field, zref, zoom_ref) 244 XML_SET_STRING(Field, field, fref, field_ref) 245 246 // Attributs de file ou file_group 247 XML_SET_STRING(File, file, name, name) 248 XML_SET_STRING(File, file, description, description) 249 250 void xios_xml_set_file_output_freq(XPtr const _file, XDType _dtype, 251 double year, double month, double day, 252 double hour, double minute, double second) 253 { 254 const Duration _dur = {year, month, day, hour, minute, second}; 255 if (_dtype >= 10 && _dtype <= 14) 256 { 257 FileGroup * __file = (FileGroup *) _file; 258 __file->set_output_freq(_dur); 259 } else { 260 CFile * __file= (CFile *) _file; 261 __file->set_output_freq(_dur); 262 } 263 } 264 265 XML_SET(File, file, int, olevel, output_level) 266 XML_SET(File, file, bool, enabled, enabled) 267 268 // Attributs de grid ou grid_group 269 XML_SET_STRING(Grid, grid, name, name) 270 XML_SET_STRING(Grid, grid, description, description) 271 XML_SET_STRING(Grid, grid, dref, domain_ref) 272 XML_SET_STRING(Grid, grid, aref, axis_ref) 273 274 // Attribut de axis ou axis group 275 XML_SET_STRING(Axis, axis, name, name) 276 XML_SET_STRING(Axis, axis, sname, standard_name) 277 XML_SET_STRING(Axis, axis, lname, long_name) 278 279 XML_SET_STRING(Axis, axis, unit, unit) 280 281 void xios_xml_set_axis_value(XPtr const _axis, XDType _dtype, double value[], XSize value_size) 282 { 283 Array<double, 1> __arr(value, shape(value_size), neverDeleteData, FortranArray<1>()); 284 if (_dtype >= 10 && _dtype <= 14) 285 { 286 AxisGroup * __axis = (AxisGroup *) _axis; 287 __axis->set_size(value_size); 288 __axis->zvalue.getValue()->resize(value_size); 289 __axis->set_zvalue(__arr); 290 } else { 291 CAxis * __axis = (CAxis *) _axis; 292 __axis->set_size(value_size); 293 __axis->zvalue.getValue()->resize(value_size); 294 __axis->set_zvalue(__arr); 295 } 296 } 297 298 // Attribut de domain ou domain_group 299 XML_SET_STRING(Domain, domain, name, name) 300 XML_SET_STRING(Domain, domain, sname, standard_name) 301 XML_SET_STRING(Domain, domain, lname, long_name) 302 303 XML_SET(Domain, domain, int, niglo, ni_glo) 304 XML_SET(Domain, domain, int, njglo, nj_glo) 305 306 XML_SET(Domain, domain, int, ibegin, ibegin) 307 XML_SET(Domain, domain, int, iend, iend) 308 XML_SET(Domain, domain, int, ni, ni) 309 310 XML_SET(Domain, domain, int, jbegin, jbegin) 311 XML_SET(Domain, domain, int, jend, jend) 312 XML_SET(Domain, domain, int, nj, nj) 313 314 void xios_xml_set_domain_mask(XPtr const _domain, XDType _dtype, bool * _mask , XSize _maskXsize, XSize _maskYsize) 315 { 316 Array<bool, 2> __arr(_mask, shape(_maskXsize, _maskYsize), neverDeleteData, FortranArray<2>()); 317 if (_dtype >= 10 && _dtype <= 14) 318 { 319 DomainGroup * __domain = (DomainGroup *) _domain; 320 __domain->mask.getValue()->resize(shape(_maskXsize, _maskYsize)); 321 __domain->set_mask(__arr); 322 } else { 323 CDomain * __domain = (CDomain *) _domain; 324 __domain->mask.getValue()->resize(shape(_maskXsize, _maskYsize)); 325 __domain->set_mask(__arr); 326 } 327 328 } 329 330 XML_SET(Domain, domain, int, ddim, data_dim) 331 XML_SET(Domain, domain, int, dni, data_ni) 332 XML_SET(Domain, domain, int, dnj, data_nj) 333 XML_SET(Domain, domain, int, dibegin, data_ibegin) 334 XML_SET(Domain, domain, int, djbegin, data_jbegin) 335 336 XML_SET(Domain, domain, int, dnindex, data_n_index) 337 338 void xios_xml_set_domain_diindex(XPtr const _domain, XDType _dtype, int _diindex[], XSize _diindex_size) 339 { 340 Array<int, 1> __arr(_diindex, shape(_diindex_size), neverDeleteData, FortranArray<1>()); 341 if (_dtype >= 10 && _dtype <= 14) 342 { 343 DomainGroup * __domain = (DomainGroup *) _domain; 344 __domain->data_i_index.getValue()->resize(_diindex_size); 345 __domain->set_data_i_index(__arr); 346 } else { 347 CDomain * __domain = (CDomain *) _domain; 348 __domain->data_i_index.getValue()->resize(_diindex_size); 349 __domain->set_data_i_index(__arr); 350 } 351 } 352 353 void xios_xml_set_domain_djindex(XPtr const _domain, XDType _dtype, int _djindex[], XSize _djindex_size) 354 { 355 Array<int, 1> __arr(_djindex, shape(_djindex_size), neverDeleteData, FortranArray<1>()); 356 if (_dtype >= 10 && _dtype <= 14) 357 { 358 DomainGroup * __domain = (DomainGroup *) _domain; 359 __domain->data_j_index.getValue()->resize(_djindex_size); 360 __domain->set_data_j_index(__arr); 361 } else { 362 CDomain * __domain = (CDomain *) _domain; 363 __domain->data_j_index.getValue()->resize(_djindex_size); 364 __domain->set_data_j_index(__arr); 365 } 366 } 367 368 void xios_xml_set_domain_lonvalue(XPtr const _domain, XDType _dtype, double _lonvalue[], XSize _lonvalue_Xsize, XSize _lonvalue_Ysize) 369 { 370 XSize __size = (_lonvalue_Ysize == -1) 371 ? _lonvalue_Xsize : (_lonvalue_Ysize*_lonvalue_Xsize); 372 Array<double, 1> __arr(_lonvalue, shape(__size), neverDeleteData, FortranArray<1>()); 373 if (_dtype >= 10 && _dtype <= 14) 374 { 375 DomainGroup * __domain = (DomainGroup *) _domain; 376 __domain->lonvalue.getValue()->resize(__size); 377 __domain->set_lonvalue(__arr); 378 } else { 379 CDomain * __domain = (CDomain *) _domain; 380 __domain->lonvalue.getValue()->resize(__size); 381 __domain->set_lonvalue(__arr); 382 } 383 } 384 385 void xios_xml_set_domain_latvalue(XPtr const _domain, XDType _dtype, double _latvalue[], XSize _latvalue_Xsize, XSize _latvalue_Ysize) 386 { 387 XSize __size = (_latvalue_Ysize == -1) 388 ? _latvalue_Xsize : (_latvalue_Ysize*_latvalue_Xsize); 389 Array<double, 1> __arr(_latvalue, shape(__size), neverDeleteData, FortranArray<1>()); 390 if (_dtype >= 10 && _dtype <= 14) 391 { 392 DomainGroup * __domain = (DomainGroup *) _domain; 393 __domain->latvalue.getValue()->resize(__size); 394 __domain->set_latvalue(__arr); 395 } else { 396 CDomain * __domain = (CDomain *) _domain; 397 __domain->latvalue.getValue()->resize(__size); 398 __domain->set_latvalue(__arr); 399 } 400 } 401 402 XML_SET_STRING(Domain, domain, domtype, domtype) 403 404 /* ********************************************************** */ 405 /* DATA TREATMENT INTERFACE */ 406 /* ********************************************************** */ 93 407 static std::vector<DataTreatment *> AllDataTreatment; 94 408 … … 101 415 } 102 416 103 void xios_dtreatment_ new_(XHandle * const _dt, const XHandle * const _hd)417 void xios_dtreatment_start(XPtr const _context, XFileType filetype) 104 418 { 105 419 static bool called = false; 106 107 // Si le handle de traitement n'est pas initialisé à 0, on ne fait aucun traitement. 108 if (!isNullHandle(*_dt) || (_hd->data_type != ECONTEXT)) return; 109 Context * const __ctxt = (Context*) _hd->data_ptr; 420 Context * const __ctxt = (Context *) _context; 110 421 DataTreatment * const __dtrt =__ctxt->setDataTreatment<DataTreatment>(); 111 112 422 if (__dtrt != NULL) 113 423 { 114 424 AllDataTreatment.push_back(__dtrt); 115 _dt->data_type = DTREATMENT;116 _dt->data_ptr = __dtrt;117 425 if (!called) 118 426 { … … 123 431 } 124 432 125 void xios_dtreatment_create_files_and_headers_(const XHandle * const _hd, const XFileType * const _ft) 126 { 127 if (isNullHandle(*_hd) || (_hd->data_type != DTREATMENT)) return; 128 DataTreatment * const __dt = (DataTreatment*)_hd->data_ptr; 129 switch(*_ft) 130 { 131 case (NETCDF4): 132 __dt->createDataOutput<NetCDF4DataOutput>(); 133 return; 134 // Autres formats de fichiers si disponibles... 135 default: 136 return; 137 } 138 } 139 140 /* ********************************************************** */ 141 /* CONTEXT INTERFACE */ 142 /* ********************************************************** */ 143 144 void xios_context_set_current_(const XHandle * const _ctxt, const bool * const _wswap) 145 { 146 bool __wswap = (_wswap == NULL) ? false : *_wswap; 147 if (isNullHandle(*_ctxt) || (_ctxt->data_type != ECONTEXT)) return; 148 Context* const __ctxt = (Context*) _ctxt->data_ptr; 149 Context::SetCurrentContext(__ctxt->getId(), __wswap) ; 150 } 151 152 void xios_context_get_current_ (XHandle * _ctxt) 153 { 154 // Si le handle de traitement n'est pas initialisé à 0, on ne fait aucun traitement. 155 if ((Context::GetAllListObject().size() == 0) || 156 !isNullHandle(*_ctxt)) return; 157 _ctxt->data_type = ECONTEXT; 158 _ctxt->data_ptr = Context::GetCurrentContext(); 159 } 160 161 void xios_context_get_calendar_(const XHandle * const _ctxt, XHandle * _cal) 162 { 163 if (!isNullHandle(*_cal) || isNullHandle(*_ctxt) || 164 (_ctxt->data_type != ECONTEXT)) return; 165 Context* const __ctxt = (Context*) _ctxt->data_ptr; 166 AbstractCalendar * const __cal = __ctxt->getCalendar(); 167 if (__cal != NULL) 168 { 169 _cal->data_type = CALENDAR; 170 _cal->data_ptr = __cal; 171 } 172 } 173 174 /* ********************************************************** */ 175 /* CALENDAR INTERFACE */ 176 /* ********************************************************** */ 177 178 void xios_calendar_set_timestep_(const XHandle * const _cal, const XDuration * const _dur) 179 { 180 if (isNullHandle(*_cal) || (_cal->data_type != CALENDAR)) return; 181 const Duration __dur = durationXtoXMLIO(_dur); 182 AbstractCalendar * const __cal = (AbstractCalendar*) _cal->data_ptr; 183 __cal->setTimeStep(__dur); 184 } 185 433 #undef XML_SET 434 #undef XML_SET_STRING 186 435 #undef isNullHandle -
XMLIO_V2/dev/dev_rv/src/XMLIO/c_interface.hpp
r134 r137 7 7 using namespace XMLIOSERVER::XML; 8 8 9 typedef long int XInt, XSize; // Integer 10 typedef bool XBool; // Logical 11 typedef void * XPtr; // Pointeur C non typé 12 typedef char * XString; // Pointeur C non typé 13 14 typedef enum 15 { 16 NOTYPE = 0, 17 DTREATMENT/* UNUSED */, DATE, CALENDAR, ECONTEXT, 18 EAXIS, EDOMAIN, EFIELD, EFILE, EGRID, 19 GAXIS, GDOMAIN, GFIELD, GFILE, GGRID 20 } XDType; 21 22 typedef enum 23 { 24 NETCDF4 = 0 25 } XFileType; 26 27 typedef enum 28 { D360 = 0 , ALLLEAP, NOLEAP, JULIAN, GREGORIAN } XCalendarType ; 29 30 typedef struct // Référence C à une objet de la bibliothÚque. 31 { XDType data_type; XPtr data_ptr; } XHandle; 32 33 #define MAKE_STRING(var_name, str_arg, int_arg) \ 34 std::string var_name##temp; \ 35 var_name##temp.append (str_arg, int_arg); \ 36 size_t d = var_name##temp.find_first_not_of(' '); \ 37 size_t f = var_name##temp.find_last_not_of (' '); \ 38 std::string var_name = var_name##temp.substr(d, f-d+1) 39 40 #define XML_SET(type, type_var, var, long_var) \ 41 void xios_xml_set_##type##_##var(XPtr const _##type, XDType _dtype, type_var var) 42 43 #define XML_SET_STRING(type, var, long_var) \ 44 void xios_xml_set_##type##_##var(XPtr const _##type, XDType _dtype, const XString _##var, XSize _##var##_len) 45 9 46 #ifdef __cplusplus 10 47 extern"C" … … 12 49 #endif //__cplusplus 13 50 14 typedef long int XInt; // Integer 15 typedef bool XBool;// Logical 16 typedef void *XPtr; // Pointeur C non typé 51 /* ******************** HANDLE INTERFACE ******************** */ 52 void xios_handle_create (XPtr * const _ret, XDType _dtype, const XString _id, XSize _id_len); 17 53 18 typedef enum _datatype 19 { 20 NOTYPE = 0, 21 DTREATMENT, DATE, CALENDAR, ECONTEXT, 22 EAXIS, EDOMAIN, EFIELD, EFILE, EGRID, 23 GAXIS, GDOMAIN, GFIELD, GFILE, GGRID 24 } XDType; 54 /* ******************** XML INTERFACE *********************** */ 55 void xios_xml_parse_file (const XString _filename, XSize _filename_len); 56 void xios_xml_parse_string(const XString _xmlcontent, XSize _xmlcontent_len); 25 57 26 typedef enum _filetype 27 { 28 NETCDF4 = 0 29 } XFileType; 58 /* ******************** CONTEXT INTERFACE ******************* */ 59 void xios_context_set_current (XPtr const _ctx, bool _wswap); 60 void xios_context_create (XPtr * _ctx, const XString _ctx_id, XSize _ctx_id_len, XCalendarType _calType); 30 61 31 typedef struct _handle // Référence C à une objet de la bibliothÚque. 32 { XDType data_type; XPtr data_ptr; } XHandle; 62 /* ****************** XML TREE INTERFACE ******************* */ 63 void xios_xml_tree_add(const XPtr _parent, XDType _parent_type, XPtr * _child, 64 XDType _child_type, const XString _child_id, XSize _child_id_len); 65 void xios_xml_tree_show(const XString _filename, XSize _filename_len); 33 66 34 typedef struct _string // Chaîne de caractÚres. 35 { char * str; int len; } XString; 67 // Attributs de field ou field_group 68 XML_SET_STRING(field, name, name); 69 XML_SET_STRING(field, sname, standard_name); 70 XML_SET_STRING(field, lname, long_name); 71 XML_SET_STRING(field, unit, unit); 72 XML_SET_STRING(field, operation, operation); 36 73 37 typedef struct _ymdhms_int 38 { int year, month, day, hour, minute, second; } XDate; 74 void xios_xml_set_field_freq_op(XPtr const _field, XDType _dtype, 75 double year, double month, double day, 76 double hour, double minute, double second); 39 77 40 typedef struct _ymdhms_double 41 { double year, month, day, hour, minute, second; } XDuration; 78 XML_SET(field, int, level, level); 79 XML_SET(field, int, prec, prec); 80 XML_SET(field, bool, enabled, enabled); 42 81 43 const XHandle NULLHANDLE = { NOTYPE, NULL }; 82 XML_SET_STRING(field, dref, domain_ref); 83 XML_SET_STRING(field, aref, axis_ref); 84 XML_SET_STRING(field, gref, grid_ref); 85 XML_SET_STRING(field, zref, zoom_ref); 86 XML_SET_STRING(field, fref, field_ref); 44 87 45 #define isNullHandle(hdl) \ 46 ((hdl).data_type == NOTYPE && (hdl).data_ptr == NULL) 88 // Attributs de file ou file_group 89 XML_SET_STRING(file, name, name) ; 90 XML_SET_STRING(file, description, description); 91 void xios_xml_set_file_output_freq(XPtr const _file, XDType _dtype, 92 double year, double month, double day, 93 double hour, double minute, double second); 47 94 48 /* ******************** HANDLE INTERFACE ******************** */ 49 void xios_handle_create_ (XHandle * const _ret, const XDType * const _dtype, const XString _id);95 XML_SET(file, int, olevel, output_level); 96 XML_SET(file, bool, enabled, enabled); 50 97 51 /* ******************** XML INTERFACE *********************** */ 52 void xios_xml_parse_file_ (const XString _filename); 53 void xios_xml_parse_string_(const XString _xmlcontent); 98 // Attributs de grid ou grid_group 99 XML_SET_STRING(grid, name, name) ; 100 XML_SET_STRING(grid, description, description) ; 101 XML_SET_STRING(grid, dref, domain_ref) ; 102 XML_SET_STRING(grid, aref, axis_ref) ; 54 103 55 /* ******************** DATA TREATMENT INTERFACE ************ */ 56 void xios_dtreatment_new_(XHandle * const _dt, const XHandle * const _hd); 57 void xios_dtreatment_create_files_and_headers_(const XHandle * const _hd, const XFileType * const _ft); 104 // Attribut de axis ou axis_group 105 XML_SET_STRING(axis, name, name) ; 106 XML_SET_STRING(axis, sname, standard_name) ; 107 XML_SET_STRING(axis, lname, long_name) ; 58 108 59 /* ******************** CONTEXT INTERFACE ******************* */ 60 void xios_context_set_current_ (const XHandle * const _ctxt, const bool * const _wswap); 61 void xios_context_get_current_ (XHandle * _ctxt); 62 void xios_context_get_calendar_(const XHandle * const _ctxt, XHandle * _cal); 63 /// void xios_context_ShowTree_ (void); 109 XML_SET_STRING(axis, unit, unit) ; 64 110 65 /* ******************** CALENDAR INTERFACE ****************** */ 66 void xios_calendar_set_timestep_(const XHandle * const _cal, const XDuration * const _dur); 111 void xios_xml_set_axis_value(XPtr const _file, XDType _dtype, double value[], XSize value_size); 112 113 114 // Attribut de domain ou domain_group 115 XML_SET_STRING(domain, name, name) ; 116 XML_SET_STRING(domain, sname, standard_name) ; 117 XML_SET_STRING(domain, lname, long_name) ; 118 119 XML_SET(domain, int, niglo, ni_glo); 120 XML_SET(domain, int, njglo, nj_glo); 121 122 XML_SET(domain, int, ibegin, ibegin); 123 XML_SET(domain, int, iend, iend); 124 XML_SET(domain, int, ni, ni); 125 126 XML_SET(domain, int, jbegin, jbegin); 127 XML_SET(domain, int, jend, jend); 128 XML_SET(domain, int, nj, nj); 129 130 void xios_xml_set_domain_mask(XPtr const _domain, XDType _dtype, bool * _mask , XSize _maskXsize, XSize _maskYsize); 131 132 XML_SET(domain, int, ddim, data_dim); 133 XML_SET(domain, int, dni, data_ni); 134 XML_SET(domain, int, dnj, data_nj); 135 XML_SET(domain, int, dibegin, data_ibegin); 136 XML_SET(domain, int, djbegin, data_jbegin); 137 138 XML_SET(domain, int, dnindex, data_n_index); 139 140 void xios_xml_set_domain_diindex(XPtr const _domain, XDType _dtype, int _diindex[], XSize _diindex_size); 141 void xios_xml_set_domain_djindex(XPtr const _domain, XDType _dtype, int _djindex[], XSize _djindex_size); 142 143 void xios_xml_set_domain_lonvalue(XPtr const _domain, XDType _dtype, double _lonvalue[], XSize _lonvalue_Xsize, XSize _lonvalue_Ysize); 144 void xios_xml_set_domain_latvalue(XPtr const _domain, XDType _dtype, double _latvalue[], XSize _latvalue_Xsize, XSize _latvalue_Ysize); 145 146 XML_SET_STRING(domain, domtype, domtype) ; 147 148 /* ****************** DATA TREATMENT INTERFACE ******************* */ 149 void xios_dtreatment_start(XPtr const _context, XFileType filetype); 67 150 68 151 #ifdef __cplusplus -
XMLIO_V2/dev/dev_rv/src/XMLIO/context.hpp
r134 r137 23 23 { /* Ne rien faire de plus */ } 24 24 25 bool createDefinitions(void) 26 { 27 if (hasChild()) return false; 28 this->fieldDef = 29 (FieldDefinition*) FieldDefinition ::CreateObject(FieldDefinition ::GetDefName()); 30 this->fileDef = 31 (FileDefinition*) FileDefinition ::CreateObject(FileDefinition ::GetDefName()); 32 this->axisDef = 33 (AxisDefinition*) AxisDefinition ::CreateObject(AxisDefinition ::GetDefName()); 34 this->gridDef = 35 (GridDefinition*) GridDefinition ::CreateObject(GridDefinition ::GetDefName()); 36 this->domainDef = 37 (DomainDefinition*)DomainDefinition::CreateObject(DomainDefinition::GetDefName()); 38 return (true); 39 } 40 25 41 FieldDefinition * getFieldDefinition (void) const { return (this->fieldDef ); } 26 42 FileDefinition * getFileDefinition (void) const { return (this->fileDef ); } … … 31 47 AbstractCalendar * getCalendar (void) const { return (ccalendar ); } 32 48 DataTreatment * getDataTreatment(void) const { return (dtreatment); } 49 50 AbstractCalendar * setCalendar(AbstractCalendar * const _cal) { return (ccalendar = _cal);} 33 51 34 52 AbstractCalendar * setCalendar(const string& _calName, const string& _dateStr) … … 82 100 else 83 101 { 84 do { // Parcours des context s pour traitement.102 do { // Parcours des contextes pour traitement. 85 103 86 104 string name = _node.getElementName(); -
XMLIO_V2/dev/dev_rv/src/XMLIO/declare_attribut.hpp
r131 r137 26 26 \ 27 27 const Attr_##att_name& getAttr_##att_name(void) const { return (att_name); } \ 28 const Attr_##att_name& get_##att_name(void) const { return (att_name); } \ 29 \ 30 void setAttr##att_name(const Attr_##att_name& _newattr) { att_name = _newattr; } \ 31 void set_##att_name (const Attr_##att_name& _newattr) { att_name = _newattr; }\ 32 \ 33 void setAttr##att_name(const att_type& _newattr) { att_name.setValue(_newattr); }\ 34 void set_##att_name (const att_type& _newattr) { att_name.setValue(_newattr); }\ 28 void set_##att_name (const Attr_##att_name& _newattr) { att_name = _newattr; } \ 29 void set_##att_name (const att_type& _newattr) { att_name.setValue(_newattr); } \ 35 30 \ 36 31 Attr_##att_name att_name -
XMLIO_V2/dev/dev_rv/src/XMLIO/declare_group.hpp
r127 r137 27 27 typedef child_type##Group child_type##Definition; \ 28 28 } 29 30 29 #endif // __DECLARE_GROUP__ -
XMLIO_V2/dev/dev_rv/src/XMLIO/domain.hpp
r125 r137 11 11 public: 12 12 13 CDomain(void) : ObjectTemplate<CDomain>(), DomainAttribut() 14 { /* Ne rien faire de plus */ } 15 CDomain(const string& _id) : ObjectTemplate<CDomain>(_id), DomainAttribut() 13 CDomain(void) 14 : ObjectTemplate<CDomain>(), DomainAttribut() 16 15 { /* Ne rien faire de plus */ } 17 16 18 static string GetName(void) {return ("domain"); } 17 CDomain(const string& _id) 18 : ObjectTemplate<CDomain>(_id), DomainAttribut() 19 { /* Ne rien faire de plus */ } 20 21 static string GetName(void) { return ("domain"); } 19 22 static string GetDefName(void) { return (CDomain::GetName()); } 20 23 21 24 inline void check(void) ; 22 25 23 ~CDomain(void) { /* Ne rien faire de plus */ } 26 ~CDomain(void) 27 { /* Ne rien faire de plus */ } 24 28 25 29 }; // class Domain 26 30 27 31 void CDomain::check(void) 28 { 29 //static bool isChecked = false ; 32 { // Recodée en partie le 17/11/10 30 33 31 //if (isChecked) return; // Si la vérification a été faite, on arrête tout. 34 // Domaine global // 35 if ((!ni_glo.hasValue() || ni_glo <= 0 ) || 36 (!nj_glo.hasValue() || nj_glo <= 0 )) 37 ERROR("Le domaine global est mal défini, vérifiez les valeurs de \'ni_glo\' et \'nj_glo\' !") ; 32 38 33 // domaine global 34 if (!ni_glo.hasValue() || ni_glo<=0 ) throw XMLIOSERVER::XMLIOUndefinedValueException("domaine global mal defini") ; 35 if (!nj_glo.hasValue() || nj_glo<=0 ) throw XMLIOSERVER::XMLIOUndefinedValueException("domaine global mal defini") ; 39 // Domaine local en i // 40 if (ni.hasValue() && ibegin.hasValue() && !iend.hasValue()) 41 iend = ibegin + ni - 1 ; 42 else if (ni.hasValue() && iend.hasValue() && !ibegin.hasValue()) 43 ibegin = ni - iend + 1 ; 44 else if (ibegin.hasValue() && iend.hasValue() && !ni.hasValue()) 45 ni = iend - ibegin - 1 ; 46 else if (ibegin.hasValue() && iend.hasValue() && 47 ni.hasValue() && (iend != ibegin + ni - 1)) 48 ERROR("Le domaine est mal défini, iend est différent de (ibegin + ni - 1) !") ; 49 else 50 ERROR("Le domaine est mal défini, deux valeurs au moins parmis iend, ibegin, ni doivent être définies !") ; 36 51 37 //domaine local en i 38 if ( ni.hasValue() && ibegin.hasValue()) 52 if (ni < 0 || ibegin > iend || 53 ibegin < 1 || iend > ni_glo) 54 ERROR("Domaine local mal défini, vérifiez les valeurs ni, ni_glo, ibegin, iend") ; 55 56 // Domaine local en j // 57 if (nj.hasValue() && jbegin.hasValue() && !jend.hasValue()) 58 jend = jbegin + nj - 1 ; 59 else if (nj.hasValue() && jend.hasValue() && !jbegin.hasValue()) 60 jbegin = nj - jend + 1 ; 61 else if (jbegin.hasValue() && jend.hasValue() && !nj.hasValue()) 62 nj = jend - jbegin - 1 ; 63 else if (jbegin.hasValue() && jend.hasValue() && 64 nj.hasValue() && (jend != jbegin + nj - 1)) 65 ERROR("Le domaine est mal défini, jend est différent de (jbegin + nj - 1) !") ; 66 else 67 ERROR("Le domaine est mal défini, deux valeurs au moins parmis jend, jbegin, nj doivent être définjes !") ; 68 69 if (nj < 0 || jbegin > jend || 70 jbegin < 1 || jend > nj_glo) 71 ERROR("Domaine local mal défini, vérifiez les valeurs nj, nj_glo, jbegin, jend") ; 72 73 // Masque de domaine // 74 if (mask.hasValue()) 39 75 { 40 if (iend.hasValue() && iend!=ibegin+ni-1) throw XMLIOSERVER::XMLIOUndefinedValueException("domain local mal défini 1") ; 41 iend = ibegin + ni - 1 ; 76 if ((mask->extent(0) != ni) || 77 (mask->extent(1) != nj)) 78 ERROR("Le masque n'a pas la même taille que le domaine local") ; 42 79 } 43 else if (ni.hasValue() && iend.hasValue()) 44 { 45 if (ibegin != ni-iend+1) throw XMLIOSERVER::XMLIOUndefinedValueException("domain local mal défini 2") ; 46 ibegin = ni - iend + 1 ; 47 } 48 else if (ibegin.hasValue() && iend.hasValue()) 49 { 50 if (ni!=iend-ibegin-1) throw XMLIOSERVER::XMLIOUndefinedValueException("domain local mal défini 3") ; 51 ni = iend - ibegin - 1 ; 52 } 53 else throw XMLIOSERVER::XMLIOUndefinedValueException("domain local non défini 4") ; 54 55 if (ni<0 || ibegin>iend || ibegin<1 || iend>ni_glo) throw XMLIOSERVER::XMLIOUndefinedValueException("domain local mal défini 5") ; 56 57 //domaine local en j 58 if ( nj.hasValue() && jbegin.hasValue()) 59 { 60 if (jend.hasValue() && jend!=jbegin+nj-1) throw XMLIOSERVER::XMLIOUndefinedValueException("domain local mal défini 6") ; 61 jend = jbegin + nj - 1 ; 62 } 63 else if (nj.hasValue() && jend.hasValue()) 64 { 65 if (jbegin!=nj-jend+1) throw XMLIOSERVER::XMLIOUndefinedValueException("domain local mal défini 7") ; 66 jbegin = nj - jend + 1 ; 67 } 68 else if (jbegin.hasValue() && jend.hasValue()) 69 { 70 if (nj!=jend-jbegin-1) throw XMLIOSERVER::XMLIOUndefinedValueException("domain local mal défini 8") ; 71 nj = jend - jbegin - 1 ; 72 } 73 else throw XMLIOSERVER::XMLIOUndefinedValueException("domain local non défini 9") ; 74 75 if (nj<0 || jbegin>jend || jbegin<1 || jend>nj_glo) throw XMLIOSERVER::XMLIOUndefinedValueException("domain local mal défini 10") ; 76 77 //cout<<"mask ni "<<mask->extent(0)<<" nj "<<mask->extent(1)<<" "<<mask<<endl ; 78 if (mask.hasValue()) 79 if (mask->extent(0) != ni || mask->extent(1) != nj) 80 throw XMLIOSERVER::XMLIOUndefinedValueException("le champ mask n'a pas la même taille que le domaine local") ; 81 82 if (data_dim.hasValue()) 83 { 84 if (!(data_dim==1 || data_dim==2)) throw XMLIOSERVER::XMLIOUndefinedValueException("dimension non comptatible (doit être 1 ou 2)") ; 85 } 86 else throw XMLIOSERVER::XMLIOUndefinedValueException("Dimension des donnée non définie") ; 87 88 if (data_ni.hasValue()) 89 { 90 if (data_ni<=0) throw XMLIOSERVER::XMLIOUndefinedValueException("Dimension des données négative") ; 91 } 92 else 93 { 94 if (data_dim==1) data_ni=ni*nj ; 95 else data_ni=(int) ni ; 80 else // (!mask.hasValue()) 81 { // Si aucun masque n'est défini, on en crée un nouveau qui valide l'intégralité du domaine. 82 Array<bool, 2> __arr(shape(ni, nj)); 83 __arr = true ; 84 mask->resize(shape(ni,nj)) ; 85 this->set_mask(__arr); 96 86 } 97 87 98 if (!data_ibegin.hasValue()) data_ibegin=0 ; 88 // Données du domaine // 89 if (!data_jbegin.hasValue()) data_jbegin = 0 ; 90 if (!data_ibegin.hasValue()) data_ibegin = 0 ; 99 91 100 if (data_ nj.hasValue())101 {102 if (data_nj<=0) throw XMLIOSERVER::XMLIOUndefinedValueException("Dimension des données négative") ;103 }104 else data_nj=(int) nj;92 if (data_dim.hasValue() && 93 !(data_dim==1 || data_dim==2)) 94 ERROR("Dimension des données non comptatible (doit être 1 ou 2) !") ; 95 else if (! data_dim.hasValue()) 96 ERROR("Dimension des données non définie !") ; 105 97 106 if (!data_jbegin.hasValue()) data_jbegin=0 ; 98 if (data_ni.hasValue() && (data_ni <= 0)) 99 ERROR("Dimension des données négative (data_ni).") ; 100 else if (!data_ni.hasValue()) 101 data_ni = (data_dim == 1) ? (ni * nj) : (int) ni; 107 102 108 if (!mask.hasValue()) 109 { // Si aucun masque n'est défini, on en crée un nouveau qui valide l'intégralité du domaine. 110 mask->resize(shape(ni,nj)) ; 111 *mask=true ; 112 } 103 if (data_nj.hasValue() && (data_nj <= 0)) 104 ERROR("Dimension des données négative (data_nj).") ; 105 else if (!data_nj.hasValue()) 106 data_nj = (int) nj ; 113 107 114 // Gestion de la compression 115 108 // Gestion de la compression // 116 109 if (data_i_index.hasValue()) 117 110 { 118 if (data_n_index.hasValue()) 111 if (data_n_index.hasValue() && 112 (data_n_index != data_i_index->extent(0))) 113 ERROR("Dimension data_i_index incompatible avec data_n_index.") ; 114 else if (!data_n_index.hasValue()) 115 data_n_index = data_i_index->extent(0) ; 116 117 if (data_dim == 2) 119 118 { 120 if (data_n_index!=data_i_index->extent(0)) 121 throw XMLIOSERVER::XMLIOUndefinedValueException("Dimension data_i_index incompatible avec data_n_index") ; 122 } 123 else data_n_index=data_i_index->extent(0) ; 124 125 if (data_dim==2) 126 { 127 if (data_j_index.hasValue()) 128 { 129 if (data_j_index->extent(0)!=data_i_index->extent(0)) 130 throw XMLIOSERVER::XMLIOUndefinedValueException("Dimension data_j_index incompatible avec data_i_index") ; 131 } 132 else throw XMLIOSERVER::XMLIOUndefinedValueException("data_j_index non défini") ; 119 if (data_j_index.hasValue() && 120 (data_j_index->extent(0) != data_i_index->extent(0))) 121 ERROR("Dimension data_j_index incompatible avec data_i_index.") ; 122 else if (!data_j_index.hasValue()) 123 ERROR("La donnée data_j_index doit être renseignée !") ; 133 124 } 134 125 } 135 126 else 136 127 { 137 if (data_n_index.hasValue() || (data_dim==2 && data_j_index.hasValue())) 138 throw XMLIOSERVER::XMLIOUndefinedValueException("data_i_index non défini") ; 128 if (data_n_index.hasValue() || 129 ((data_dim == 2) && (data_j_index.hasValue()))) 130 ERROR("data_i_index non défini") ; 139 131 } 140 //cout<<"data_n_index.hasValue() "<<data_n_index.hasValue()<<endl ; 132 141 133 if (!data_n_index.hasValue()) 142 { 143 if (data_dim ==1)134 { // -> bloc re-vérfié OK 135 if (data_dim == 1) 144 136 { 145 int i ; 146 data_n_index=*data_ni ; 147 //cout <<"data_n_index "<<data_n_index<<" "<<data_ni<<" "<<data_nj<<endl ; 148 149 data_i_index->resize(data_n_index) ; 150 151 for (i=0;i<data_ni;i++) (*data_i_index)(i)=i ; 152 //cout <<"data_i_index "<<*data_i_index<<endl ; 137 const int dni = data_ni; 138 Array<int, 1> __arri(shape(dni)); 139 this->set_data_n_index(dni) ; 140 for (int i = 0; i < dni; i++) 141 __arri(i) = i+1 ; 142 data_i_index->resize(dni) ; 143 this->set_data_i_index(__arri) ; 153 144 } 154 else // data_dim=2145 else // (data_dim == 2) 155 146 { 156 int i ; 157 int j ; 158 int count ; 159 160 data_n_index = data_ni * data_nj ; 161 data_i_index -> resize(data_n_index) ; 162 data_j_index -> resize(data_n_index) ; 163 for(count=0,i=0; i<data_ni;i++) 164 for(j=0; j<data_nj;j++) 165 { 166 (*data_i_index)(count)=i ; 167 // cout<<count<<" "<<(*data_i_index)(count)<<endl ; 168 (*data_j_index)(count)=j ; 169 //cout<<count<<" "<<(*data_j_index)(count)<<endl ; 170 count++ ; 171 } 172 //cout<<data_ni<<" "<<data_nj<<" "<<data_n_index<<" "<<*data_i_index<<" "<<*data_j_index<<endl ; 147 const int dni = data_ni * data_nj; 148 Array<int, 1> __arri(shape(dni)), __arrj(shape(dni)); 149 this->set_data_n_index(dni) ; 150 for(int count = 0, i = 0; i <data_ni; i++) 151 for(int j = 0; j < data_nj; j++, count++) 152 { __arri(count) = i+1 ; __arrj(count) = j+1 ; } 153 data_i_index -> resize(dni) ; 154 data_j_index -> resize(dni) ; 155 this->set_data_i_index(__arri) ; 156 this->set_data_j_index(__arrj) ; 173 157 } 174 158 } 175 176 //isChecked = true ;177 159 } 178 160 -
XMLIO_V2/dev/dev_rv/src/XMLIO/domain_attribut.hpp
r127 r137 37 37 DECLARE_ATTR(data_j_index , Array(int, 1)) ; 38 38 39 DECLARE_ATTR(xvalue , Array(double, 1)) ; 40 DECLARE_ATTR(yvalue , Array(double, 1)) ; 39 DECLARE_ATTR(lonvalue , Array(double, 1)) ; 40 DECLARE_ATTR(latvalue , Array(double, 1)) ; 41 DECLARE_ATTR(domtype , string); 41 42 42 43 DomainAttribut(void) : AttributRegistrar() … … 69 70 RegisterAttribut(&data_j_index) ; 70 71 71 RegisterAttribut(&xvalue) ; 72 RegisterAttribut(&yvalue) ; 72 RegisterAttribut(&lonvalue) ; 73 RegisterAttribut(&latvalue) ; 74 RegisterAttribut(&domtype) ; 73 75 } 74 76 -
XMLIO_V2/dev/dev_rv/src/XMLIO/duration.hpp
r131 r137 28 28 if(d.hour != 0.0) { testValue = false; out << d.hour << "h " ; } 29 29 if(d.minute != 0.0) { testValue = false; out << d.minute << "mi "; } 30 if(d.second != 0.0 || testValue) { out << d.second << "s " ; }30 if(d.second != 0.0 || testValue) { out << d.second << "s " ; } 31 31 32 32 _out << (out.str().substr(0, out.str().size()-1)); // << suppression de l'espace en fin de chaîne. … … 76 76 } 77 77 78 struct _duration& resolve(const AbstractCalendar&);78 inline struct _duration& resolve(const AbstractCalendar&); 79 79 80 80 std::string toString(void) const -
XMLIO_V2/dev/dev_rv/src/XMLIO/exception.hpp
r131 r137 34 34 { /* Ne rien faire de plus */ } 35 35 36 ~XMLIOException( ) throw()37 { /* Ne rien faire de plus */}36 ~XMLIOException(void) throw() 37 { std::cerr << displayText() << std::endl; } 38 38 39 39 XMLIOException& operator = (const XMLIOException& _exc) … … 43 43 virtual const char* className(void) const throw() { return (typeid(*this).name()); } 44 44 45 virtual Exception* clone(void) const { 45 virtual Exception* clone(void) const { return new XMLIOException(*this); } 46 46 virtual void rethrow(void) const { throw *this; } 47 47 … … 57 57 const char* name(void) const throw() 58 58 { return ("XMLIO>UndefinedValueException"); } 59 60 ~XMLIOUndefinedValueException(void) throw() 61 { std::cerr << displayText() << std::endl; } 59 62 60 63 }; //class XMLIOUndefinedException -
XMLIO_V2/dev/dev_rv/src/XMLIO/file.hpp
r130 r137 25 25 const std::vector<CField*>& getEnabledFields (void) const { return (enabledFields); } 26 26 27 FieldGroup * createVirtualFieldGroup(const std::string _id) 28 { 29 return (vfieldGroup == NULL) 30 ? vfieldGroup = (FieldGroup*) FieldGroup::CreateObject(_id) 31 : vfieldGroup; 32 } 33 27 34 void initializeDataOutput(AbstractDataOutput* _output) 28 35 { … … 94 101 int default_outputlevel = 5, int default_level = 1, bool default_enabled = true ) 95 102 { 96 const int _outputlevel = (output_level.hasValue()) ? (int)output_level : default_outputlevel; 103 const int _outputlevel = 104 (output_level.hasValue()) ? (int)output_level : default_outputlevel; 97 105 std::vector<CField*>::iterator it; 98 106 … … 163 171 } 164 172 165 virtual bool hasChild(void) const { return (vfieldGroup != NULL); } 166 virtual void printChild(ostream& out) const { out << *vfieldGroup << std::endl; } 173 virtual bool hasChild(void) const 174 { return (vfieldGroup != NULL); } 175 176 virtual void printChild(ostream& out) const 177 { out << *vfieldGroup << std::endl; } 167 178 168 179 virtual void solveDescInheritance(const AttributRegistrar* const _parent = 0) -
XMLIO_V2/dev/dev_rv/src/XMLIO/group_template.hpp
r128 r137 168 168 attributes.clear(); _node.getAttributes(attributes); 169 169 170 if (name.compare(W::GetName()) == 0) { createGroupAndParse<W>(attributes, _node); continue; } 171 if (name.compare(T::GetName()) == 0) { createChildAndParse<T>(attributes, _node); continue; } 170 if (name.compare(W::GetName()) == 0) 171 { createGroupAndParse<W>(attributes, _node); continue; } 172 173 if (name.compare(T::GetName()) == 0) 174 { createChildAndParse<T>(attributes, _node); continue; } 172 175 173 176 WARNING("Un objet de type \""+W::GetName()+"\" ne peut contenir qu'un object de type \""+T::GetName()+"\" ou \""+W::GetName()+"\" !"); -
XMLIO_V2/dev/dev_rv/src/XMLIO/logger.hpp
r128 r137 2 2 #define __XMLIO_LOGGER__ 3 3 4 // Entête Poco logging5 4 #include <csignal> 6 5 … … 92 91 } 93 92 94 std::ostream& IncIndent(std::ostream& out) { Indent++; return (NIndent(out)); } 95 std::ostream& DecEndl (std::ostream& out) { Indent--; return (out); } 93 std::ostream& IncIndent(std::ostream& out) 94 { Indent++; return (NIndent(out)); } 95 96 std::ostream& DecEndl (std::ostream& out) 97 { Indent--; return (out); } 96 98 ///////////////////////////////////////////////////////////////////// 97 99 -
XMLIO_V2/dev/dev_rv/src/XMLIO/main.f90
r134 r137 1 1 ! --------------------------------------------------- ! 2 ! ------------- XMLIO SERVER MAIN TEST -------------!2 ! XMLIO SERVER MAIN TEST ! 3 3 ! --------------------------------------------------- ! 4 4 5 MODULE XTYPE6 IMPLICIT NONE7 8 ! Ne jamais modifier les valeurs internes de ce type dans le code fortran.9 TYPE XHandle10 INTEGER :: dtype11 INTEGER :: daddr12 END TYPE XHandle13 14 TYPE XDate15 INTEGER :: year, month, day, hour, minute, second16 END TYPE XDate17 18 TYPE XDuration19 REAL(kind = 8) :: year, month, day, hour, minute, second20 END TYPE XDuration21 22 ! enum XDType23 INTEGER, PARAMETER :: NOTYPE = 024 INTEGER, PARAMETER :: DTREATMENT = 1, DDATE = 2, CALENDAR = 3, ECONTEXT = 425 INTEGER, PARAMETER :: EAXIS = 5 , EDOMAIN = 6 , EFIELD = 7 , EFILE = 8 , EGRID = 926 INTEGER, PARAMETER :: GAXIS = 10, GDOMAIN = 11, GFIELD = 12, GFILE = 13, GGRID = 1427 28 ! enum XFileType29 INTEGER, PARAMETER :: NETCDF4 = 030 31 ! Autres constantes32 TYPE(XHandle) , PARAMETER :: NULLHANDLE = XHandle(0, 0)33 TYPE(XDuration), PARAMETER :: NONEDUR = XDuration(0., 0., 0., 0., 0., 0.)34 35 END MODULE XTYPE36 37 MODULE IXHANDLE38 39 INTERFACE40 41 SUBROUTINE xios_handle_create(ret, dtype, idt)42 USE XTYPE43 TYPE(XHandle), INTENT(OUT) :: ret44 INTEGER , INTENT(IN) :: dtype45 CHARACTER*(*), INTENT(IN) :: idt46 END SUBROUTINE xios_handle_create47 48 END INTERFACE49 50 END MODULE IXHANDLE51 52 MODULE IXML53 IMPLICIT NONE54 INTERFACE55 56 SUBROUTINE xios_xml_Parse_File(filename)57 CHARACTER*(*), INTENT(IN) :: filename58 END SUBROUTINE xios_xml_Parse_File59 60 SUBROUTINE xios_xml_Parse_String(xmlcontent)61 CHARACTER*(*), INTENT(IN) :: xmlcontent62 END SUBROUTINE xios_xml_Parse_String63 64 END INTERFACE65 END MODULE IXML66 67 MODULE ICONTEXT68 IMPLICIT NONE69 INTERFACE70 71 SUBROUTINE xios_context_set_current(context, withswap)72 USE XTYPE73 TYPE(XHandle), INTENT(IN) :: context74 LOGICAL, OPTIONAL, INTENT(IN) :: withswap75 END SUBROUTINE xios_context_set_current76 77 SUBROUTINE xios_context_get_current(context)78 USE XTYPE79 TYPE(XHandle), INTENT(IN) :: context80 END SUBROUTINE xios_context_get_current81 82 SUBROUTINE xios_context_get_calendar(context, calend)83 USE XTYPE84 TYPE(XHandle), INTENT(IN) :: context85 TYPE(XHandle), INTENT(OUT) :: calend86 END SUBROUTINE xios_context_get_calendar87 88 END INTERFACE89 90 END MODULE ICONTEXT91 92 MODULE ICALENDAR93 IMPLICIT NONE94 INTERFACE95 96 SUBROUTINE xios_calendar_set_timestep(calend, dur)97 USE XTYPE98 TYPE(XHandle) , INTENT(IN) :: calend99 TYPE(XDuration), INTENT(IN) :: dur100 END SUBROUTINE xios_calendar_set_timestep101 102 END INTERFACE103 104 END MODULE ICALENDAR105 106 MODULE IDATATREATMENT107 IMPLICIT NONE108 INTERFACE109 110 SUBROUTINE xios_dtreatment_new(dt, context)111 USE XTYPE112 TYPE(XHandle), INTENT(OUT) :: dt113 TYPE(XHandle), INTENT(IN) :: context114 END SUBROUTINE xios_dtreatment_new115 116 SUBROUTINE xios_dtreatment_create_files_and_headers(dt, ftype)117 USE XTYPE118 TYPE(XHandle), INTENT(IN) :: dt119 INTEGER , INTENT(IN) :: ftype120 END SUBROUTINE xios_dtreatment_create_files_and_headers121 122 END INTERFACE123 END MODULE IDATATREATMENT124 125 5 PROGRAM MAIN 126 USE XTYPE127 6 USE IXHANDLE 128 7 USE IXML 8 USE IXMLTREE 129 9 USE ICONTEXT 10 USE ICALENDAR 11 USE IEXTENDED 130 12 USE IDATATREATMENT 131 USE ICALENDAR132 13 133 I MPLICIT NONE14 INTEGER :: compt = 0 134 15 135 INTEGER :: compt 136 TYPE(XHandle) :: context1 = NULLHANDLE 137 TYPE(XHandle) :: dtreat = NULLHANDLE 138 TYPE(XHandle) :: calend = NULLHANDLE 16 TYPE(XHandle) :: nemo_style_ctxt = NULLHANDLE, & 17 orchidee_style_ctxt = NULLHANDLE, & 18 lmdz_style_ctxt = NULLHANDLE 19 20 TYPE(XHandle) :: temp_mod = NULLHANDLE, & 21 temp_mod_ = NULLHANDLE 22 23 ! Axes verticaux 24 REAL(kind = 8), DIMENSION(10) :: vaxis = (/(i, i=1, 10)/) 25 !vvaxis = (/(i, i=1, 5)/) 26 27 ! Domaines horizontaux 28 REAL(kind = 8), DIMENSION(20) :: lonrect_orch0 = (/(i, i=11, 30)/),& 29 latrect_orch0 = (/(i, i=11, 30)/) 30 31 REAL(kind = 8), DIMENSION(10,10) :: loncurv_nemo0 = 1, & 32 latcurv_nemo0 = 1 33 34 ! Les durées 139 35 TYPE(XDuration) :: timestep_1h = XDuration(0., 0., 0., 1., 0., 0.) 36 !timestep_2h = XDuration(0., 0., 0., 2., 0., 0.) 37 38 ! Les masques 39 LOGICAL(kind = 1), DIMENSION(20, 20) :: mask0 = .TRUE._1 40 41 CHARACTER(len = *), PARAMETER :: filename = & 42 "/local/XMLIOSERVER_DEV/dev_rv/test/iodef_simple_test.xml" 43 44 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 140 45 141 46 ! Parsing du document xml depuis un fichier situé sur le disque. 142 CALL x ios_xml_Parse_File("/local/XMLIOSERVER_DEV/dev_rv/test/iodef_simple_test.xml")47 CALL xml_Parse_File(filename) 143 48 144 ! Le calendrier doit être initialisé ici s'il ne l'a pas déjà été depuis le document xml. 49 ! Création de handle sur les contextes exstants dans lequels on souhaite travailler. 50 CALL handle_create(nemo_style_ctxt, ECONTEXT, "nemo_style") 51 CALL context_set_current(nemo_style_ctxt) 145 52 146 ! Création d'un handle sur le contexte dans lequel on souhaite travailler, cà d 'context1' ici. 147 CALL xios_handle_create(context1, ECONTEXT, "context1") 148 iF ((context1%dtype == 0) .AND. (context1%daddr == 0)) THEN 149 PRINT *, "Impossible de créer un handle sur l'élément context1 !" 150 STOP 151 END IF 53 CALL handle_create(temp_mod, EDOMAIN, "domaine0") 54 CALL xml_domain_addAttribut(domain_hdl = temp_mod, & 55 lonvalue_curv = loncurv_nemo0, & 56 latvalue_curv = latcurv_nemo0, & 57 domtype = "curvilinear") 58 59 CALL handle_create(lmdz_style_ctxt, ECONTEXT, "lmdz_style") 60 CALL context_set_current(lmdz_style_ctxt) 61 62 !!!!!!!!!!!!!!!!!!!! EXEMPLE RECONSTRUCTION !!!!!!!!!!!!!!!!!!!!! 63 ! On crée un nouveau context et on lui associe un handle. 64 CALL context_create(context_hdl = orchidee_style_ctxt, & 65 context_id = "orchidee_style", & 66 calendar_type = GREGORIAN) 67 68 ! ---------> field_définition 69 CALL handle_create(temp_mod, GFIELD, "field_definition") 70 CALL xml_tree_add(parent_hdl = temp_mod, & 71 child_hdl = temp_mod_, & 72 child_type = GFIELD, & 73 child_id = "ss_fieldgroup") 74 CALL xml_group_field_addAttribut(gfield_hdl = temp_mod_, & 75 flevel = 1, & 76 fprec = 4, & 77 fenabled = .TRUE._1) 78 CALL xml_tree_add(parent_hdl = temp_mod_, & 79 child_hdl = temp_mod , & 80 child_type = EFIELD, & 81 child_id = "field0") 82 CALL xml_field_addAttribut(field_hdl = temp_mod, & 83 fname = "field0_name", & 84 fstandard_name = "field0_sname", & 85 flong_name = "field0_lname", & 86 funit = "Pa", & 87 foperation = "inst", & 88 ffreq_op = timestep_1h, & 89 fgrid_ref = "grid0") 90 ! ---------> axis_définition 91 CALL handle_create(temp_mod, GAXIS, "axis_definition") 92 CALL xml_tree_add(parent_hdl = temp_mod, & 93 child_hdl = temp_mod_, & 94 child_type = GAXIS, & 95 child_id = "ss_axisgroup") 96 CALL xml_group_axis_addAttribut(gaxis_hdl = temp_mod_, & 97 aunit = "SI") 98 CALL xml_tree_add(parent_hdl = temp_mod_, & 99 child_hdl = temp_mod , & 100 child_type = EAXIS, & 101 child_id = "axis0") 102 CALL xml_axis_addAttribut(axis_hdl = temp_mod, & 103 aname = "saxev", & 104 astandard_name = "saxev", & 105 along_name = "Simple axe vertical",& 106 avalue = vaxis) 107 108 ! ---------> domain_définition 109 CALL handle_create(temp_mod, GDOMAIN, "domain_definition") 110 CALL xml_tree_add(parent_hdl = temp_mod, & 111 child_hdl = temp_mod_, & 112 child_type = GDOMAIN, & 113 child_id = "ss_domaingroup") 114 CALL xml_group_domain_addAttribut(gdomain_hdl = temp_mod_, & 115 ni_glo = 40, & 116 nj_glo = 40) 117 CALL xml_tree_add(parent_hdl = temp_mod_, & 118 child_hdl = temp_mod , & 119 child_type = EDOMAIN, & 120 child_id = "domain0") 121 CALL xml_domain_addAttribut(domain_hdl = temp_mod, & 122 dname = "Compressee", & 123 dstandard_name = "DomOrchTest", & 124 dlong_name = "Test type orchidee", & 125 ibegin = 10, & 126 iend = 31, & 127 jbegin = 10, & 128 jend = 31, & 129 mask = mask0, & 130 data_dim = 1, & 131 data_ni = 400, & 132 data_ibegin = 1, & 133 lonvalue_rect = lonrect_orch0, & 134 latvalue_rect = latrect_orch0, & 135 domtype = "rectilinear") 136 137 ! ---------> file_définition 138 CALL handle_create(temp_mod, GFILE, "file_definition") 139 CALL xml_tree_add(parent_hdl = temp_mod, & 140 child_hdl = temp_mod_, & 141 child_type = GFILE) 142 CALL xml_group_file_addAttribut(gfile_hdl = temp_mod_, & 143 fofreq = timestep_1h, & 144 folevel = 2, & 145 fenabled = .TRUE._1) 146 CALL xml_tree_add(parent_hdl = temp_mod_, & 147 child_hdl = temp_mod , & 148 child_type = EFILE, & 149 child_id = "file0") 150 CALL xml_file_addAttribut(file_hdl = temp_mod, & 151 fname = "data/orchidee_test.nc", & 152 fdescription = "Test sur grille type orchidee") 153 CALL xml_tree_add(parent_hdl = temp_mod , & 154 child_hdl = temp_mod_, & 155 child_type = EFIELD) 156 CALL xml_field_addAttribut(field_hdl = temp_mod_, & 157 ffield_ref = "field0") 158 159 ! ---------> grid_définition 160 CALL handle_create(temp_mod, GGRID, "grid_definition") 161 CALL xml_tree_add(parent_hdl = temp_mod, & 162 child_hdl = temp_mod_, & 163 child_type = GGRID, & 164 child_id = "ss_gridgroup") 165 CALL xml_group_grid_addAttribut(ggrid_hdl = temp_mod_, & 166 gdomain_ref = "domain0", & 167 gaxis_ref = "axis0"); 168 CALL xml_tree_add(parent_hdl = temp_mod_, & 169 child_hdl = temp_mod , & 170 child_type = EGRID, & 171 child_id = "grid0") 172 CALL xml_grid_addAttribut(grid_hdl = temp_mod, & 173 gname = "GRectiCompressee", & 174 gdescription = "Grille orchidee"); 175 176 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 177 178 ! Affichage de l'arbre xml au niveau de la sortie. 179 CALL xml_tree_show("xmlio_tree_prev.log") 180 ! CALL xml_tree_show() 152 181 153 182 ! ----------- Début du traitement ----------- ! 154 155 CALL xios_context_set_current(context1, .TRUE.) 156 157 ! Création et initialisation d'une instance de traitement des données dans 'context1'. 158 CALL xios_dtreatment_new(dtreat, context1) 159 iF ((dtreat%dtype == 0) .AND. (dtreat%daddr == 0)) THEN 160 PRINT *, "Impossible d'initialiser l'instance de traitement !" 161 STOP 162 END IF 163 164 ! Création des fichiers et des entêtes dans le contexte. 165 CALL xios_dtreatment_create_files_and_headers(dtreat, NETCDF4) 166 167 ! On récupére le calendrier associé au contexte en cours de traitement. 168 CALL xios_context_get_calendar(context1, calend) 169 iF ((calend%dtype == 0) .AND. (calend%daddr == 0)) THEN 170 PRINT *, "Impossible de récupérer le calendrier !" 171 STOP 172 END IF 173 174 ! On change la durée du timestep. 175 CALL xios_calendar_set_timestep(calend, timestep_1h) 183 ! On choisit le context dans lequel on va travailler et on commence le traitement des données. 184 CALL dtreatment_start(orchidee_style_ctxt, NETCDF4) 176 185 177 186 ! Exécution de la boucle de calcul-écriture. … … 180 189 END DO 181 190 191 ! Affichage de l'arbre xml au niveau de la sortie. 192 CALL xml_tree_show("xmlio_tree_next.log") 193 182 194 END PROGRAM MAIN -
XMLIO_V2/dev/dev_rv/src/XMLIO/object_template.hpp
r128 r137 147 147 } 148 148 149 static const StrHashMap<T>& GetCurrentListObject(void) { return (AllListObj[CurrContext]); } 150 static Poco::HashMap<string, StrHashMap<T> >& GetAllListObject(void) { return (AllListObj); } 151 152 static void SetContext(const string& id) { ObjectTemplate<T>::CurrContext = id; } 153 154 static string& GetCurrentContextId(void) { return (ObjectTemplate<T>::CurrContext); } 149 static const StrHashMap<T>& GetCurrentListObject(void) 150 { return (AllListObj[CurrContext]); } 151 152 static Poco::HashMap<string, StrHashMap<T> >& GetAllListObject(void) 153 { return (AllListObj); } 154 155 static void SetContext(const string& id) 156 { ObjectTemplate<T>::CurrContext = id; } 157 158 static string& GetCurrentContextId(void) 159 { return (ObjectTemplate<T>::CurrContext); } 155 160 156 161 protected : … … 179 184 } 180 185 181 template <class V> static V* CreateInstanceAndParse(XMLNode& _node, const char* defaultId, bool parseAttr = true ) 186 template <class V> 187 static V* CreateInstanceAndParse(XMLNode& _node, const char* defaultId, bool parseAttr = true ) 182 188 { 183 189 V* instance_ptr = NULL; string did(defaultId); -
XMLIO_V2/dev/dev_rv/src/XMLIO/xml_node.hpp
r132 r137 36 36 bool goToChildElement(void) 37 37 { 38 Poco::XML::Node * nextElement = this->getCNode()->firstChild();38 Poco::XML::Node * nextElement = this->getCNode()->firstChild(); 39 39 40 40 // On parcourt la liste des enfants jusqu'à trouver un élément quelconque.
Note: See TracChangeset
for help on using the changeset viewer.