[325] | 1 | /* ************************************************************************** * |
---|
[335] | 2 | * Copyright © IPSL/LSCE, xios, Avril 2010 - Octobre 2011 * |
---|
[325] | 3 | * ************************************************************************** */ |
---|
| 4 | |
---|
| 5 | #include <boost/multi_array.hpp> |
---|
[1542] | 6 | #include <memory> |
---|
[325] | 7 | |
---|
[591] | 8 | #include "xios.hpp" |
---|
[325] | 9 | |
---|
[352] | 10 | #include "attribute_template.hpp" |
---|
| 11 | #include "object_template.hpp" |
---|
| 12 | #include "group_template.hpp" |
---|
[325] | 13 | |
---|
| 14 | #include "icutil.hpp" |
---|
[347] | 15 | #include "timer.hpp" |
---|
[352] | 16 | #include "context.hpp" |
---|
[891] | 17 | #include "node_type.hpp" |
---|
[325] | 18 | |
---|
| 19 | extern "C" |
---|
| 20 | { |
---|
| 21 | // /////////////////////////////// Définitions ////////////////////////////// // |
---|
| 22 | |
---|
| 23 | // ----------------------- Redéfinition de types ---------------------------- |
---|
| 24 | |
---|
[345] | 25 | typedef xios::CContext * XContextPtr; |
---|
[325] | 26 | |
---|
[345] | 27 | typedef xios::CGrid * XGridPtr; |
---|
| 28 | typedef xios::CGridGroup * XGridGroupPtr; |
---|
[325] | 29 | |
---|
[345] | 30 | typedef xios::CFile * XFilePtr; |
---|
| 31 | typedef xios::CFileGroup * XFileGroupPtr; |
---|
[325] | 32 | |
---|
[345] | 33 | typedef xios::CField * XFieldPtr; |
---|
| 34 | typedef xios::CFieldGroup * XFieldGroupPtr; |
---|
[325] | 35 | |
---|
[345] | 36 | typedef xios::CDomain * XDomainPtr; |
---|
| 37 | typedef xios::CDomainGroup * XDomainGroupPtr; |
---|
[325] | 38 | |
---|
[891] | 39 | typedef xios::CScalar * XScalarPtr; |
---|
| 40 | typedef xios::CScalarGroup * XScalarGroupPtr; |
---|
| 41 | |
---|
[345] | 42 | typedef xios::CAxis * XAxisPtr; |
---|
| 43 | typedef xios::CAxisGroup * XAxisGroupPtr; |
---|
[509] | 44 | |
---|
[472] | 45 | typedef xios::CVariable * XVariablePtr; |
---|
| 46 | typedef xios::CVariableGroup * XVariableGroupPtr; |
---|
[509] | 47 | |
---|
[836] | 48 | typedef xios::CTransformation<CDomain> * XTransformationDomainPtr; |
---|
| 49 | typedef xios::CZoomDomain * XZoomDomainPtr; |
---|
| 50 | typedef xios::CInterpolateDomain * XInterpolateDomainPtr; |
---|
| 51 | typedef xios::CGenerateRectilinearDomain * XGenerateRectilinearDomainPtr; |
---|
[934] | 52 | typedef xios::CComputeConnectivityDomain * XComputeConnectivityDomainPtr; |
---|
[981] | 53 | typedef xios::CExpandDomain * XExpandDomainPtr; |
---|
[836] | 54 | |
---|
[981] | 55 | typedef xios::CTransformation<CAxis> * XTransformationAxisPtr; |
---|
| 56 | typedef xios::CZoomAxis * XZoomAxisPtr; |
---|
| 57 | typedef xios::CInterpolateAxis * XInterpolateAxisPtr; |
---|
| 58 | typedef xios::CInverseAxis * XInverseAxisPtr; |
---|
| 59 | typedef xios::CExtractDomainToAxis * XExtractDomainToAxisPtr; |
---|
| 60 | typedef xios::CReduceDomainToAxis * XReduceDomainToAxisPtr; |
---|
[836] | 61 | |
---|
[891] | 62 | typedef xios::CTransformation<CScalar> * XTransformationScalarPtr; |
---|
| 63 | typedef xios::CReduceAxisToScalar * XReduceAxisToScalarPtr; |
---|
[981] | 64 | typedef xios::CReduceDomainToScalar * XReduceDomainToScalarPtr; |
---|
| 65 | typedef xios::CExtractAxisToScalar * XExtractAxisToScalarPtr; |
---|
[891] | 66 | |
---|
[981] | 67 | |
---|
[325] | 68 | // ----------------------- Ajout d'enfant à un parent ----------------------- |
---|
[509] | 69 | |
---|
[325] | 70 | void cxios_xml_tree_add_field |
---|
| 71 | (XFieldGroupPtr parent_, XFieldPtr * child_, const char * child_id, int child_id_size) |
---|
| 72 | { |
---|
[509] | 73 | std::string child_id_str; |
---|
[347] | 74 | CTimer::get("XIOS").resume() ; |
---|
[325] | 75 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 76 | { |
---|
[347] | 77 | *child_ = parent_->createChild(child_id_str) ; |
---|
[325] | 78 | } |
---|
| 79 | else |
---|
| 80 | { |
---|
[347] | 81 | *child_ = parent_->createChild() ; |
---|
[325] | 82 | } |
---|
[347] | 83 | CTimer::get("XIOS").suspend() ; |
---|
[325] | 84 | } |
---|
[509] | 85 | |
---|
[325] | 86 | void cxios_xml_tree_add_grid |
---|
| 87 | (XGridGroupPtr parent_, XGridPtr * child_, const char * child_id, int child_id_size) |
---|
| 88 | { |
---|
[509] | 89 | std::string child_id_str; |
---|
[347] | 90 | CTimer::get("XIOS").resume() ; |
---|
[325] | 91 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 92 | { |
---|
[347] | 93 | *child_ = parent_->createChild(child_id_str) ; |
---|
[325] | 94 | } |
---|
| 95 | else |
---|
| 96 | { |
---|
[347] | 97 | *child_ = parent_->createChild() ; |
---|
[325] | 98 | } |
---|
[347] | 99 | CTimer::get("XIOS").suspend() ; |
---|
[325] | 100 | } |
---|
[509] | 101 | |
---|
[325] | 102 | void cxios_xml_tree_add_file |
---|
| 103 | (XFileGroupPtr parent_, XFilePtr * child_, const char * child_id, int child_id_size) |
---|
| 104 | { |
---|
[509] | 105 | std::string child_id_str; |
---|
[347] | 106 | CTimer::get("XIOS").resume() ; |
---|
[325] | 107 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 108 | { |
---|
[347] | 109 | *child_ = parent_->createChild(child_id_str) ; |
---|
[325] | 110 | } |
---|
| 111 | else |
---|
| 112 | { |
---|
[347] | 113 | *child_ = parent_->createChild() ; |
---|
[325] | 114 | } |
---|
[347] | 115 | CTimer::get("XIOS").suspend() ; |
---|
[325] | 116 | } |
---|
[509] | 117 | |
---|
[325] | 118 | void cxios_xml_tree_add_axis |
---|
| 119 | (XAxisGroupPtr parent_, XAxisPtr * child_, const char * child_id, int child_id_size) |
---|
| 120 | { |
---|
[509] | 121 | std::string child_id_str; |
---|
[347] | 122 | CTimer::get("XIOS").resume() ; |
---|
[325] | 123 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 124 | { |
---|
[347] | 125 | *child_ = parent_->createChild(child_id_str) ; |
---|
[325] | 126 | } |
---|
| 127 | else |
---|
| 128 | { |
---|
[347] | 129 | *child_ = parent_->createChild() ; |
---|
[325] | 130 | } |
---|
[347] | 131 | CTimer::get("XIOS").suspend() ; |
---|
[325] | 132 | } |
---|
[509] | 133 | |
---|
[891] | 134 | void cxios_xml_tree_add_scalar |
---|
| 135 | (XScalarGroupPtr parent_, XScalarPtr * child_, const char * child_id, int child_id_size) |
---|
| 136 | { |
---|
| 137 | std::string child_id_str; |
---|
| 138 | CTimer::get("XIOS").resume() ; |
---|
| 139 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 140 | { |
---|
| 141 | *child_ = parent_->createChild(child_id_str) ; |
---|
| 142 | } |
---|
| 143 | else |
---|
| 144 | { |
---|
| 145 | *child_ = parent_->createChild() ; |
---|
| 146 | } |
---|
| 147 | CTimer::get("XIOS").suspend() ; |
---|
| 148 | } |
---|
| 149 | |
---|
[325] | 150 | void cxios_xml_tree_add_domain |
---|
| 151 | (XDomainGroupPtr parent_, XDomainPtr * child_, const char * child_id, int child_id_size) |
---|
| 152 | { |
---|
[347] | 153 | std::string child_id_str; |
---|
| 154 | CTimer::get("XIOS").resume() ; |
---|
[325] | 155 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 156 | { |
---|
[347] | 157 | *child_ = parent_->createChild(child_id_str) ; |
---|
[325] | 158 | } |
---|
| 159 | else |
---|
| 160 | { |
---|
[347] | 161 | *child_ = parent_->createChild() ; |
---|
[325] | 162 | } |
---|
[347] | 163 | CTimer::get("XIOS").suspend() ; |
---|
[325] | 164 | } |
---|
[509] | 165 | |
---|
[325] | 166 | void cxios_xml_tree_add_fieldtofile |
---|
| 167 | (XFilePtr parent_, XFieldPtr * child_, const char * child_id, int child_id_size) |
---|
| 168 | { |
---|
[347] | 169 | std::string child_id_str; |
---|
| 170 | CTimer::get("XIOS").resume() ; |
---|
[509] | 171 | |
---|
[325] | 172 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 173 | { |
---|
[347] | 174 | *child_ = parent_->addField(child_id_str); |
---|
[325] | 175 | } |
---|
| 176 | else |
---|
| 177 | { |
---|
[347] | 178 | *child_ = parent_->addField(); |
---|
[325] | 179 | } |
---|
[347] | 180 | CTimer::get("XIOS").suspend() ; |
---|
[325] | 181 | } |
---|
| 182 | |
---|
[472] | 183 | void cxios_xml_tree_add_variabletofile |
---|
| 184 | (XFilePtr parent_, XVariablePtr * child_, const char * child_id, int child_id_size) |
---|
| 185 | { |
---|
| 186 | std::string child_id_str; |
---|
| 187 | CTimer::get("XIOS").resume() ; |
---|
[509] | 188 | |
---|
[472] | 189 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 190 | { |
---|
| 191 | *child_ = parent_->addVariable(child_id_str); |
---|
| 192 | } |
---|
| 193 | else |
---|
| 194 | { |
---|
| 195 | *child_ = parent_->addVariable(); |
---|
| 196 | } |
---|
| 197 | CTimer::get("XIOS").suspend() ; |
---|
| 198 | } |
---|
[509] | 199 | |
---|
[472] | 200 | void cxios_xml_tree_add_variabletofield |
---|
| 201 | (XFieldPtr parent_, XVariablePtr * child_, const char * child_id, int child_id_size) |
---|
| 202 | { |
---|
| 203 | std::string child_id_str; |
---|
| 204 | CTimer::get("XIOS").resume() ; |
---|
[509] | 205 | |
---|
[472] | 206 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 207 | { |
---|
| 208 | *child_ = parent_->addVariable(child_id_str); |
---|
| 209 | } |
---|
| 210 | else |
---|
| 211 | { |
---|
| 212 | *child_ = parent_->addVariable(); |
---|
| 213 | } |
---|
| 214 | CTimer::get("XIOS").suspend() ; |
---|
[509] | 215 | } |
---|
[325] | 216 | // ----------------------- Ajout de groupe à un parent ---------------------- |
---|
| 217 | |
---|
| 218 | void cxios_xml_tree_add_fieldgroup |
---|
| 219 | (XFieldGroupPtr parent_, XFieldGroupPtr * child_, const char * child_id, int child_id_size) |
---|
| 220 | { |
---|
[509] | 221 | std::string child_id_str; |
---|
[347] | 222 | CTimer::get("XIOS").resume() ; |
---|
[325] | 223 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 224 | { |
---|
[347] | 225 | *child_ = parent_->createChildGroup(child_id_str) ; |
---|
[325] | 226 | } |
---|
| 227 | else |
---|
| 228 | { |
---|
[347] | 229 | *child_ = parent_->createChildGroup() ; |
---|
[325] | 230 | } |
---|
[347] | 231 | CTimer::get("XIOS").suspend() ; |
---|
[325] | 232 | } |
---|
| 233 | |
---|
| 234 | void cxios_xml_tree_add_gridgroup |
---|
| 235 | (XGridGroupPtr parent_, XGridGroupPtr * child_, const char * child_id, int child_id_size) |
---|
| 236 | { |
---|
| 237 | std::string child_id_str; |
---|
[347] | 238 | CTimer::get("XIOS").resume() ; |
---|
[325] | 239 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 240 | { |
---|
[347] | 241 | *child_ = parent_->createChildGroup(child_id_str) ; |
---|
[325] | 242 | } |
---|
| 243 | else |
---|
| 244 | { |
---|
[347] | 245 | *child_ = parent_->createChildGroup() ; |
---|
[325] | 246 | } |
---|
[347] | 247 | CTimer::get("XIOS").suspend() ; |
---|
[325] | 248 | } |
---|
| 249 | |
---|
| 250 | void cxios_xml_tree_add_filegroup |
---|
| 251 | (XFileGroupPtr parent_, XFileGroupPtr * child_, const char * child_id, int child_id_size) |
---|
| 252 | { |
---|
| 253 | std::string child_id_str; |
---|
[347] | 254 | CTimer::get("XIOS").resume() ; |
---|
[325] | 255 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 256 | { |
---|
[347] | 257 | *child_ = parent_->createChildGroup(child_id_str) ; |
---|
[325] | 258 | } |
---|
| 259 | else |
---|
| 260 | { |
---|
[347] | 261 | *child_ = parent_->createChildGroup() ; |
---|
[325] | 262 | } |
---|
[347] | 263 | CTimer::get("XIOS").suspend() ; |
---|
[325] | 264 | } |
---|
| 265 | |
---|
[891] | 266 | void cxios_xml_tree_add_scalargroup |
---|
| 267 | (XScalarGroupPtr parent_, XScalarGroupPtr * child_, const char * child_id, int child_id_size) |
---|
| 268 | { |
---|
| 269 | std::string child_id_str; |
---|
| 270 | CTimer::get("XIOS").resume() ; |
---|
| 271 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 272 | { |
---|
| 273 | *child_ = parent_->createChildGroup(child_id_str) ; |
---|
| 274 | } |
---|
| 275 | else |
---|
| 276 | { |
---|
| 277 | *child_ = parent_->createChildGroup() ; |
---|
| 278 | } |
---|
| 279 | CTimer::get("XIOS").suspend() ; |
---|
| 280 | } |
---|
| 281 | |
---|
[325] | 282 | void cxios_xml_tree_add_axisgroup |
---|
| 283 | (XAxisGroupPtr parent_, XAxisGroupPtr * child_, const char * child_id, int child_id_size) |
---|
| 284 | { |
---|
| 285 | std::string child_id_str; |
---|
[347] | 286 | CTimer::get("XIOS").resume() ; |
---|
[325] | 287 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 288 | { |
---|
[347] | 289 | *child_ = parent_->createChildGroup(child_id_str) ; |
---|
[325] | 290 | } |
---|
| 291 | else |
---|
| 292 | { |
---|
[347] | 293 | *child_ = parent_->createChildGroup() ; |
---|
[325] | 294 | } |
---|
[347] | 295 | CTimer::get("XIOS").suspend() ; |
---|
[325] | 296 | } |
---|
| 297 | |
---|
| 298 | void cxios_xml_tree_add_domaingroup |
---|
| 299 | (XDomainGroupPtr parent_, XDomainGroupPtr * child_, const char * child_id, int child_id_size) |
---|
| 300 | { |
---|
| 301 | std::string child_id_str; |
---|
[347] | 302 | CTimer::get("XIOS").resume() ; |
---|
[325] | 303 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 304 | { |
---|
[347] | 305 | *child_ = parent_->createChildGroup(child_id_str) ; |
---|
[325] | 306 | } |
---|
| 307 | else |
---|
| 308 | { |
---|
[347] | 309 | *child_ = parent_->createChildGroup() ; |
---|
[325] | 310 | } |
---|
[347] | 311 | CTimer::get("XIOS").suspend() ; |
---|
[325] | 312 | } |
---|
| 313 | |
---|
| 314 | void cxios_xml_tree_add_fieldgrouptofile |
---|
| 315 | (XFilePtr parent_, XFieldGroupPtr * child_, const char * child_id, int child_id_size) |
---|
| 316 | { |
---|
[509] | 317 | std::string child_id_str; |
---|
[347] | 318 | CTimer::get("XIOS").resume() ; |
---|
[325] | 319 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 320 | { |
---|
[347] | 321 | *child_ = parent_->addFieldGroup(child_id_str); |
---|
[325] | 322 | } |
---|
| 323 | else |
---|
| 324 | { |
---|
[347] | 325 | *child_ = parent_->addFieldGroup(); |
---|
[325] | 326 | } |
---|
[347] | 327 | CTimer::get("XIOS").suspend() ; |
---|
[325] | 328 | } |
---|
[509] | 329 | |
---|
[472] | 330 | void cxios_xml_tree_add_variablegrouptofile |
---|
| 331 | (XFilePtr parent_, XVariableGroupPtr * child_, const char * child_id, int child_id_size) |
---|
| 332 | { |
---|
[509] | 333 | std::string child_id_str; |
---|
[472] | 334 | CTimer::get("XIOS").resume() ; |
---|
| 335 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 336 | { |
---|
| 337 | *child_ = parent_->addVariableGroup(child_id_str); |
---|
| 338 | } |
---|
| 339 | else |
---|
| 340 | { |
---|
| 341 | *child_ = parent_->addVariableGroup(); |
---|
| 342 | } |
---|
| 343 | CTimer::get("XIOS").suspend() ; |
---|
| 344 | } |
---|
[509] | 345 | |
---|
[472] | 346 | void cxios_xml_tree_add_variablegrouptofield |
---|
| 347 | (XFieldPtr parent_, XVariableGroupPtr * child_, const char * child_id, int child_id_size) |
---|
| 348 | { |
---|
[509] | 349 | std::string child_id_str; |
---|
[472] | 350 | CTimer::get("XIOS").resume() ; |
---|
| 351 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 352 | { |
---|
| 353 | *child_ = parent_->addVariableGroup(child_id_str); |
---|
| 354 | } |
---|
| 355 | else |
---|
| 356 | { |
---|
| 357 | *child_ = parent_->addVariableGroup(); |
---|
| 358 | } |
---|
| 359 | CTimer::get("XIOS").suspend() ; |
---|
[509] | 360 | } |
---|
| 361 | |
---|
[891] | 362 | void cxios_xml_tree_add_scalartogrid |
---|
| 363 | (XGridPtr parent_, XScalarPtr * child_, const char * child_id, int child_id_size) |
---|
| 364 | { |
---|
| 365 | std::string child_id_str; |
---|
| 366 | CTimer::get("XIOS").resume() ; |
---|
| 367 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 368 | { |
---|
| 369 | *child_ = parent_->addScalar(child_id_str); |
---|
| 370 | } |
---|
| 371 | else |
---|
| 372 | { |
---|
| 373 | *child_ = parent_->addScalar(); |
---|
| 374 | } |
---|
| 375 | CTimer::get("XIOS").suspend() ; |
---|
| 376 | } |
---|
| 377 | |
---|
[835] | 378 | void cxios_xml_tree_add_axistogrid |
---|
| 379 | (XGridPtr parent_, XAxisPtr * child_, const char * child_id, int child_id_size) |
---|
| 380 | { |
---|
| 381 | std::string child_id_str; |
---|
| 382 | CTimer::get("XIOS").resume() ; |
---|
| 383 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 384 | { |
---|
| 385 | *child_ = parent_->addAxis(child_id_str); |
---|
| 386 | } |
---|
| 387 | else |
---|
| 388 | { |
---|
| 389 | *child_ = parent_->addAxis(); |
---|
| 390 | } |
---|
| 391 | CTimer::get("XIOS").suspend() ; |
---|
| 392 | } |
---|
[509] | 393 | |
---|
[835] | 394 | void cxios_xml_tree_add_domaintogrid |
---|
| 395 | (XGridPtr parent_, XDomainPtr * child_, const char * child_id, int child_id_size) |
---|
| 396 | { |
---|
| 397 | std::string child_id_str; |
---|
| 398 | CTimer::get("XIOS").resume() ; |
---|
| 399 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 400 | { |
---|
| 401 | *child_ = parent_->addDomain(child_id_str); |
---|
| 402 | } |
---|
| 403 | else |
---|
| 404 | { |
---|
| 405 | *child_ = parent_->addDomain(); |
---|
| 406 | } |
---|
| 407 | CTimer::get("XIOS").suspend() ; |
---|
| 408 | } |
---|
| 409 | |
---|
[981] | 410 | //--------------------------------------------------------------------------- |
---|
| 411 | //-------------------------Transformations ----------------------------------- |
---|
| 412 | //--------------------------------------------------------------------------- |
---|
[836] | 413 | void cxios_xml_tree_add_zoomdomaintodomain |
---|
| 414 | (XDomainPtr parent_, XZoomDomainPtr * child_, const char * child_id, int child_id_size) |
---|
| 415 | { |
---|
| 416 | std::string child_id_str; |
---|
| 417 | XTransformationDomainPtr tmpChild_; |
---|
| 418 | CTimer::get("XIOS").resume() ; |
---|
| 419 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 420 | { |
---|
| 421 | tmpChild_ = parent_->addTransformation(TRANS_ZOOM_DOMAIN, child_id_str); |
---|
| 422 | } |
---|
| 423 | else |
---|
| 424 | { |
---|
| 425 | tmpChild_ = parent_->addTransformation(TRANS_ZOOM_DOMAIN); |
---|
| 426 | } |
---|
| 427 | *child_ = static_cast<XZoomDomainPtr>(tmpChild_); |
---|
| 428 | CTimer::get("XIOS").suspend() ; |
---|
| 429 | } |
---|
| 430 | |
---|
| 431 | void cxios_xml_tree_add_interpolatedomaintodomain |
---|
| 432 | (XDomainPtr parent_, XInterpolateDomainPtr * child_, const char * child_id, int child_id_size) |
---|
| 433 | { |
---|
| 434 | std::string child_id_str; |
---|
| 435 | XTransformationDomainPtr tmpChild_; |
---|
| 436 | CTimer::get("XIOS").resume() ; |
---|
| 437 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 438 | { |
---|
| 439 | tmpChild_ = parent_->addTransformation(TRANS_INTERPOLATE_DOMAIN, child_id_str); |
---|
| 440 | } |
---|
| 441 | else |
---|
| 442 | { |
---|
| 443 | tmpChild_ = parent_->addTransformation(TRANS_INTERPOLATE_DOMAIN); |
---|
| 444 | } |
---|
| 445 | *child_ = static_cast<XInterpolateDomainPtr>(tmpChild_); |
---|
| 446 | CTimer::get("XIOS").suspend() ; |
---|
| 447 | } |
---|
| 448 | |
---|
| 449 | void cxios_xml_tree_add_generatedomaintodomain |
---|
| 450 | (XDomainPtr parent_, XGenerateRectilinearDomainPtr * child_, const char * child_id, int child_id_size) |
---|
| 451 | { |
---|
| 452 | std::string child_id_str; |
---|
| 453 | XTransformationDomainPtr tmpChild_; |
---|
| 454 | CTimer::get("XIOS").resume() ; |
---|
| 455 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 456 | { |
---|
| 457 | tmpChild_ = parent_->addTransformation(TRANS_GENERATE_RECTILINEAR_DOMAIN, child_id_str); |
---|
| 458 | } |
---|
| 459 | else |
---|
| 460 | { |
---|
| 461 | tmpChild_ = parent_->addTransformation(TRANS_GENERATE_RECTILINEAR_DOMAIN); |
---|
| 462 | } |
---|
| 463 | *child_ = static_cast<XGenerateRectilinearDomainPtr>(tmpChild_); |
---|
| 464 | CTimer::get("XIOS").suspend() ; |
---|
| 465 | } |
---|
| 466 | |
---|
[934] | 467 | void cxios_xml_tree_add_computeconnectivitydomaintodomain |
---|
| 468 | (XDomainPtr parent_, XComputeConnectivityDomainPtr * child_, const char * child_id, int child_id_size) |
---|
| 469 | { |
---|
| 470 | std::string child_id_str; |
---|
| 471 | XTransformationDomainPtr tmpChild_; |
---|
| 472 | CTimer::get("XIOS").resume() ; |
---|
| 473 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 474 | { |
---|
[981] | 475 | tmpChild_ = parent_->addTransformation(TRANS_EXPAND_DOMAIN, child_id_str); |
---|
| 476 | } |
---|
| 477 | else |
---|
| 478 | { |
---|
| 479 | tmpChild_ = parent_->addTransformation(TRANS_EXPAND_DOMAIN); |
---|
| 480 | } |
---|
| 481 | *child_ = static_cast<XComputeConnectivityDomainPtr>(tmpChild_); |
---|
| 482 | CTimer::get("XIOS").suspend() ; |
---|
| 483 | } |
---|
| 484 | |
---|
| 485 | void cxios_xml_tree_add_expanddomaintodomain |
---|
| 486 | (XDomainPtr parent_, XExpandDomainPtr * child_, const char * child_id, int child_id_size) |
---|
| 487 | { |
---|
| 488 | std::string child_id_str; |
---|
| 489 | XTransformationDomainPtr tmpChild_; |
---|
| 490 | CTimer::get("XIOS").resume() ; |
---|
| 491 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 492 | { |
---|
[934] | 493 | tmpChild_ = parent_->addTransformation(TRANS_COMPUTE_CONNECTIVITY_DOMAIN, child_id_str); |
---|
| 494 | } |
---|
| 495 | else |
---|
| 496 | { |
---|
| 497 | tmpChild_ = parent_->addTransformation(TRANS_COMPUTE_CONNECTIVITY_DOMAIN); |
---|
| 498 | } |
---|
[981] | 499 | *child_ = static_cast<XExpandDomainPtr>(tmpChild_); |
---|
[934] | 500 | CTimer::get("XIOS").suspend() ; |
---|
| 501 | } |
---|
| 502 | |
---|
[981] | 503 | // -----------------------Axis transformation-------------------------------- |
---|
[836] | 504 | void cxios_xml_tree_add_zoomaxistoaxis |
---|
| 505 | (XAxisPtr parent_, XZoomAxisPtr * child_, const char * child_id, int child_id_size) |
---|
| 506 | { |
---|
| 507 | std::string child_id_str; |
---|
| 508 | XTransformationAxisPtr tmpChild_; |
---|
| 509 | CTimer::get("XIOS").resume() ; |
---|
| 510 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 511 | { |
---|
| 512 | tmpChild_ = parent_->addTransformation(TRANS_ZOOM_AXIS, child_id_str); |
---|
| 513 | } |
---|
| 514 | else |
---|
| 515 | { |
---|
| 516 | tmpChild_ = parent_->addTransformation(TRANS_ZOOM_AXIS); |
---|
| 517 | } |
---|
| 518 | *child_ = static_cast<XZoomAxisPtr>(tmpChild_); |
---|
| 519 | CTimer::get("XIOS").suspend() ; |
---|
| 520 | } |
---|
| 521 | |
---|
| 522 | void cxios_xml_tree_add_interpolateaxistoaxis |
---|
| 523 | (XAxisPtr parent_, XInterpolateAxisPtr * child_, const char * child_id, int child_id_size) |
---|
| 524 | { |
---|
| 525 | std::string child_id_str; |
---|
| 526 | XTransformationAxisPtr tmpChild_; |
---|
| 527 | CTimer::get("XIOS").resume() ; |
---|
| 528 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 529 | { |
---|
| 530 | tmpChild_ = parent_->addTransformation(TRANS_INTERPOLATE_AXIS, child_id_str); |
---|
| 531 | } |
---|
| 532 | else |
---|
| 533 | { |
---|
| 534 | tmpChild_ = parent_->addTransformation(TRANS_INTERPOLATE_AXIS); |
---|
| 535 | } |
---|
| 536 | *child_ = static_cast<XInterpolateAxisPtr>(tmpChild_); |
---|
| 537 | CTimer::get("XIOS").suspend() ; |
---|
| 538 | } |
---|
| 539 | |
---|
| 540 | void cxios_xml_tree_add_inverseaxistoaxis |
---|
| 541 | (XAxisPtr parent_, XInverseAxisPtr * child_, const char * child_id, int child_id_size) |
---|
| 542 | { |
---|
| 543 | std::string child_id_str; |
---|
| 544 | XTransformationAxisPtr tmpChild_; |
---|
| 545 | CTimer::get("XIOS").resume() ; |
---|
| 546 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 547 | { |
---|
| 548 | tmpChild_ = parent_->addTransformation(TRANS_INVERSE_AXIS, child_id_str); |
---|
| 549 | } |
---|
| 550 | else |
---|
| 551 | { |
---|
| 552 | tmpChild_ = parent_->addTransformation(TRANS_INVERSE_AXIS); |
---|
| 553 | } |
---|
| 554 | *child_ = static_cast<XInverseAxisPtr>(tmpChild_); |
---|
| 555 | CTimer::get("XIOS").suspend() ; |
---|
| 556 | } |
---|
| 557 | |
---|
[981] | 558 | void cxios_xml_tree_add_extractdomaintoaxistoaxis |
---|
| 559 | (XAxisPtr parent_, XExtractDomainToAxisPtr * child_, const char * child_id, int child_id_size) |
---|
| 560 | { |
---|
| 561 | std::string child_id_str; |
---|
| 562 | XTransformationAxisPtr tmpChild_; |
---|
| 563 | CTimer::get("XIOS").resume() ; |
---|
| 564 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 565 | { |
---|
| 566 | tmpChild_ = parent_->addTransformation(TRANS_EXTRACT_DOMAIN_TO_AXIS, child_id_str); |
---|
| 567 | } |
---|
| 568 | else |
---|
| 569 | { |
---|
| 570 | tmpChild_ = parent_->addTransformation(TRANS_EXTRACT_DOMAIN_TO_AXIS); |
---|
| 571 | } |
---|
| 572 | *child_ = static_cast<XExtractDomainToAxisPtr>(tmpChild_); |
---|
| 573 | CTimer::get("XIOS").suspend() ; |
---|
| 574 | } |
---|
| 575 | |
---|
| 576 | void cxios_xml_tree_add_reducedomaintoaxistoaxis |
---|
| 577 | (XAxisPtr parent_, XReduceDomainToAxisPtr * child_, const char * child_id, int child_id_size) |
---|
| 578 | { |
---|
| 579 | std::string child_id_str; |
---|
| 580 | XTransformationAxisPtr tmpChild_; |
---|
| 581 | CTimer::get("XIOS").resume() ; |
---|
| 582 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 583 | { |
---|
| 584 | tmpChild_ = parent_->addTransformation(TRANS_REDUCE_DOMAIN_TO_AXIS, child_id_str); |
---|
| 585 | } |
---|
| 586 | else |
---|
| 587 | { |
---|
| 588 | tmpChild_ = parent_->addTransformation(TRANS_REDUCE_DOMAIN_TO_AXIS); |
---|
| 589 | } |
---|
| 590 | *child_ = static_cast<XReduceDomainToAxisPtr>(tmpChild_); |
---|
| 591 | CTimer::get("XIOS").suspend() ; |
---|
| 592 | } |
---|
| 593 | |
---|
| 594 | |
---|
[891] | 595 | void cxios_xml_tree_add_reduceaxistoscalartoscalar |
---|
| 596 | (XScalarPtr parent_, XReduceAxisToScalarPtr * child_, const char * child_id, int child_id_size) |
---|
| 597 | { |
---|
| 598 | std::string child_id_str; |
---|
| 599 | XTransformationScalarPtr tmpChild_; |
---|
| 600 | CTimer::get("XIOS").resume() ; |
---|
| 601 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 602 | { |
---|
| 603 | tmpChild_ = parent_->addTransformation(TRANS_REDUCE_AXIS_TO_SCALAR, child_id_str); |
---|
| 604 | } |
---|
| 605 | else |
---|
| 606 | { |
---|
| 607 | tmpChild_ = parent_->addTransformation(TRANS_REDUCE_AXIS_TO_SCALAR); |
---|
| 608 | } |
---|
| 609 | *child_ = static_cast<XReduceAxisToScalarPtr>(tmpChild_); |
---|
| 610 | CTimer::get("XIOS").suspend() ; |
---|
| 611 | } |
---|
| 612 | |
---|
[981] | 613 | void cxios_xml_tree_add_reducedomaintoscalartoscalar |
---|
| 614 | (XScalarPtr parent_, XReduceDomainToScalarPtr * child_, const char * child_id, int child_id_size) |
---|
| 615 | { |
---|
| 616 | std::string child_id_str; |
---|
| 617 | XTransformationScalarPtr tmpChild_; |
---|
| 618 | CTimer::get("XIOS").resume() ; |
---|
| 619 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 620 | { |
---|
| 621 | tmpChild_ = parent_->addTransformation(TRANS_REDUCE_DOMAIN_TO_SCALAR, child_id_str); |
---|
| 622 | } |
---|
| 623 | else |
---|
| 624 | { |
---|
| 625 | tmpChild_ = parent_->addTransformation(TRANS_REDUCE_DOMAIN_TO_SCALAR); |
---|
| 626 | } |
---|
| 627 | *child_ = static_cast<XReduceDomainToScalarPtr>(tmpChild_); |
---|
| 628 | CTimer::get("XIOS").suspend() ; |
---|
| 629 | } |
---|
| 630 | |
---|
| 631 | void cxios_xml_tree_add_extractaxistoscalartoscalar |
---|
| 632 | (XScalarPtr parent_, XExtractAxisToScalarPtr * child_, const char * child_id, int child_id_size) |
---|
| 633 | { |
---|
| 634 | std::string child_id_str; |
---|
| 635 | XTransformationScalarPtr tmpChild_; |
---|
| 636 | CTimer::get("XIOS").resume() ; |
---|
| 637 | if (cstr2string(child_id, child_id_size, child_id_str)) |
---|
| 638 | { |
---|
| 639 | tmpChild_ = parent_->addTransformation(TRANS_EXTRACT_AXIS_TO_SCALAR, child_id_str); |
---|
| 640 | } |
---|
| 641 | else |
---|
| 642 | { |
---|
| 643 | tmpChild_ = parent_->addTransformation(TRANS_EXTRACT_AXIS_TO_SCALAR); |
---|
| 644 | } |
---|
| 645 | *child_ = static_cast<XExtractAxisToScalarPtr>(tmpChild_); |
---|
| 646 | CTimer::get("XIOS").suspend() ; |
---|
| 647 | } |
---|
| 648 | |
---|
[325] | 649 | // ----------------------- Affichage de l'arborescence ---------------------- |
---|
[509] | 650 | |
---|
| 651 | // void cxios_xml_tree_show (const char * filename, int filename_size) |
---|
[346] | 652 | // { |
---|
| 653 | // std::string filename_str; |
---|
| 654 | // try |
---|
| 655 | // { |
---|
| 656 | // if (cstr2string(filename, filename_size, filename_str)) |
---|
| 657 | // xios::CTreeManager::PrintTreeToFile(filename_str); |
---|
| 658 | // else |
---|
| 659 | // xios::CTreeManager::PrintTreeToStream(std::clog); |
---|
| 660 | // } |
---|
| 661 | // catch (xios::CException & exc) |
---|
| 662 | // { |
---|
| 663 | // std::cerr << exc.getMessage() << std::endl; |
---|
| 664 | // exit (EXIT_FAILURE); |
---|
| 665 | // } |
---|
| 666 | // } |
---|
[509] | 667 | |
---|
| 668 | |
---|
[325] | 669 | // ----------------------- Parsing de document xml -------------------------- |
---|
[509] | 670 | |
---|
[346] | 671 | // void cxios_xml_parse_file (const char * filename , int filename_size)// |
---|
| 672 | // { |
---|
[509] | 673 | // std::string filename_str; |
---|
[346] | 674 | // if (!cstr2string(filename, filename_size, filename_str)) return; |
---|
| 675 | // |
---|
| 676 | // try |
---|
| 677 | // { |
---|
| 678 | // xios::CTreeManager::ParseFile(filename_str); |
---|
| 679 | // } |
---|
| 680 | // catch (xios::CException & exc) |
---|
| 681 | // { |
---|
| 682 | // std::cerr << exc.getMessage() << std::endl; |
---|
| 683 | // exit (EXIT_FAILURE); |
---|
| 684 | // } |
---|
| 685 | // } |
---|
[509] | 686 | |
---|
[346] | 687 | // void cxios_xml_parse_string(const char * xmlcontent, int xmlcontent_size) |
---|
| 688 | // { |
---|
[509] | 689 | // std::string xmlcontent_str; |
---|
[346] | 690 | // if (!cstr2string(xmlcontent, xmlcontent_size, xmlcontent_str)) return; |
---|
| 691 | // |
---|
| 692 | // try |
---|
| 693 | // { |
---|
| 694 | // xios::CTreeManager::ParseString(xmlcontent_str); |
---|
| 695 | // } |
---|
| 696 | // catch (xios::CException & exc) |
---|
| 697 | // { |
---|
| 698 | // std::cerr << exc.getMessage() << std::endl; |
---|
| 699 | // exit (EXIT_FAILURE); |
---|
| 700 | // } |
---|
| 701 | // } |
---|
[325] | 702 | |
---|
| 703 | |
---|
[509] | 704 | |
---|
[325] | 705 | } // extern "C" |
---|