[325] | 1 | /* ************************************************************************** * |
---|
[335] | 2 | * Copyright © IPSL/LSCE, xios, Avril 2010 - Octobre 2011 * |
---|
[325] | 3 | * ************************************************************************** */ |
---|
| 4 | |
---|
| 5 | #include <boost/multi_array.hpp> |
---|
| 6 | |
---|
[1542] | 7 | #include <memory> |
---|
| 8 | |
---|
[591] | 9 | #include "xios.hpp" |
---|
[325] | 10 | |
---|
[352] | 11 | #include "attribute_template.hpp" |
---|
| 12 | #include "object_template.hpp" |
---|
| 13 | #include "group_template.hpp" |
---|
[325] | 14 | |
---|
| 15 | #include "icutil.hpp" |
---|
[347] | 16 | #include "timer.hpp" |
---|
[352] | 17 | #include "field.hpp" |
---|
[325] | 18 | |
---|
| 19 | extern "C" |
---|
| 20 | { |
---|
| 21 | // /////////////////////////////// Définitions ////////////////////////////// // |
---|
| 22 | |
---|
| 23 | // ----------------------- Redéfinition de types ---------------------------- |
---|
| 24 | |
---|
[345] | 25 | typedef xios::CField * XFieldPtr; |
---|
| 26 | typedef xios::CFieldGroup * XFieldGroupPtr; |
---|
[325] | 27 | |
---|
[943] | 28 | typedef xios::CDomain * XDomainPtr; |
---|
| 29 | typedef xios::CAxis * XAxisPtr; |
---|
| 30 | typedef xios::CScalar * XScalarPtr; |
---|
| 31 | |
---|
[325] | 32 | // -------------------------------------------------------------------------- |
---|
| 33 | // ------------------------ Création des handle ----------------------------- |
---|
| 34 | // -------------------------------------------------------------------------- |
---|
| 35 | |
---|
| 36 | void cxios_field_handle_create (XFieldPtr * _ret, const char * _id, int _id_len) |
---|
[1622] | 37 | TRY |
---|
[325] | 38 | { |
---|
| 39 | std::string id; |
---|
| 40 | if (!cstr2string(_id, _id_len, id)) return; |
---|
[347] | 41 | CTimer::get("XIOS").resume() ; |
---|
| 42 | *_ret = CField::get(id); |
---|
| 43 | CTimer::get("XIOS").suspend() ; |
---|
[325] | 44 | } |
---|
[1622] | 45 | CATCH_DUMP_STACK |
---|
[325] | 46 | |
---|
| 47 | void cxios_fieldgroup_handle_create (XFieldGroupPtr * _ret, const char * _id, int _id_len) |
---|
[1622] | 48 | TRY |
---|
[325] | 49 | { |
---|
| 50 | std::string id; |
---|
| 51 | if (!cstr2string(_id, _id_len, id)) return; |
---|
[347] | 52 | CTimer::get("XIOS").resume() ; |
---|
| 53 | *_ret = CFieldGroup::get(id); |
---|
| 54 | CTimer::get("XIOS").suspend() ; |
---|
[325] | 55 | } |
---|
[1622] | 56 | CATCH_DUMP_STACK |
---|
[325] | 57 | |
---|
| 58 | // -------------------- Vérification des identifiants ----------------------- |
---|
| 59 | |
---|
| 60 | void cxios_field_valid_id (bool * _ret, const char * _id, int _id_len) |
---|
[1622] | 61 | TRY |
---|
[325] | 62 | { |
---|
| 63 | std::string id; |
---|
| 64 | if (!cstr2string(_id, _id_len, id)) return; |
---|
[347] | 65 | CTimer::get("XIOS").resume() ; |
---|
[346] | 66 | *_ret = CField::has(id); |
---|
[347] | 67 | CTimer::get("XIOS").suspend() ; |
---|
[325] | 68 | } |
---|
[1622] | 69 | CATCH_DUMP_STACK |
---|
[325] | 70 | |
---|
| 71 | void cxios_fieldgroup_valid_id (bool * _ret, const char * _id, int _id_len) |
---|
[1622] | 72 | TRY |
---|
[325] | 73 | { |
---|
| 74 | std::string id; |
---|
| 75 | if (!cstr2string(_id, _id_len, id)) return; |
---|
[347] | 76 | CTimer::get("XIOS").resume() ; |
---|
[346] | 77 | *_ret = CFieldGroup::has(id); |
---|
[347] | 78 | CTimer::get("XIOS").suspend() ; |
---|
[325] | 79 | } |
---|
[1622] | 80 | CATCH_DUMP_STACK |
---|
[325] | 81 | |
---|
| 82 | // ----------------------------------------------------------------------------------------------------- |
---|
[943] | 83 | // ------------------------- Other functions |
---|
[325] | 84 | // ----------------------------------------------------------------------------------------------------- |
---|
| 85 | |
---|
[1158] | 86 | void cxios_field_is_active (XFieldPtr field_hdl, bool at_current_timestep, bool* ret) |
---|
[1622] | 87 | TRY |
---|
[325] | 88 | { |
---|
[347] | 89 | CTimer::get("XIOS").resume() ; |
---|
[1158] | 90 | *ret = field_hdl->isActive(at_current_timestep); |
---|
[347] | 91 | CTimer::get("XIOS").suspend() ; |
---|
[325] | 92 | } |
---|
[1622] | 93 | CATCH_DUMP_STACK |
---|
[943] | 94 | |
---|
| 95 | // ----------------------------------------------------------------------------------------------------- |
---|
| 96 | // ------------------------- Retrieving information of grid associated to field |
---|
| 97 | // ----------------------------------------------------------------------------------------------------- |
---|
| 98 | void cxios_field_get_domain_handle(XDomainPtr * domain_hdl_ret, XFieldPtr field_hdl, int domainIndex) |
---|
[1622] | 99 | TRY |
---|
[943] | 100 | { |
---|
| 101 | CTimer::get("XIOS").resume() ; |
---|
[1869] | 102 | *domain_hdl_ret = field_hdl->getGrid()->getDomain(domainIndex); |
---|
[943] | 103 | CTimer::get("XIOS").suspend(); |
---|
| 104 | } |
---|
[1622] | 105 | CATCH_DUMP_STACK |
---|
[943] | 106 | |
---|
| 107 | void cxios_field_get_axis_handle(XAxisPtr * axis_hdl_ret, XFieldPtr field_hdl, int axisIndex) |
---|
[1622] | 108 | TRY |
---|
[943] | 109 | { |
---|
| 110 | CTimer::get("XIOS").resume() ; |
---|
[1869] | 111 | *axis_hdl_ret = field_hdl->getGrid()->getAxis(axisIndex); |
---|
[943] | 112 | CTimer::get("XIOS").suspend(); |
---|
| 113 | } |
---|
[1622] | 114 | CATCH_DUMP_STACK |
---|
[943] | 115 | |
---|
| 116 | void cxios_field_get_scalar_handle(XScalarPtr * scalar_hdl_ret, XFieldPtr field_hdl, int scalarIndex) |
---|
[1622] | 117 | TRY |
---|
[943] | 118 | { |
---|
| 119 | CTimer::get("XIOS").resume() ; |
---|
[1869] | 120 | *scalar_hdl_ret = field_hdl->getGrid()->getScalar(scalarIndex); |
---|
[943] | 121 | CTimer::get("XIOS").suspend(); |
---|
| 122 | } |
---|
[1622] | 123 | CATCH_DUMP_STACK |
---|
[325] | 124 | } // extern "C" |
---|