[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) |
---|
| 37 | { |
---|
| 38 | std::string id; |
---|
| 39 | if (!cstr2string(_id, _id_len, id)) return; |
---|
[347] | 40 | CTimer::get("XIOS").resume() ; |
---|
| 41 | *_ret = CField::get(id); |
---|
| 42 | CTimer::get("XIOS").suspend() ; |
---|
[325] | 43 | } |
---|
| 44 | |
---|
| 45 | void cxios_fieldgroup_handle_create (XFieldGroupPtr * _ret, const char * _id, int _id_len) |
---|
| 46 | { |
---|
| 47 | std::string id; |
---|
| 48 | if (!cstr2string(_id, _id_len, id)) return; |
---|
[347] | 49 | CTimer::get("XIOS").resume() ; |
---|
| 50 | *_ret = CFieldGroup::get(id); |
---|
| 51 | CTimer::get("XIOS").suspend() ; |
---|
[325] | 52 | } |
---|
| 53 | |
---|
| 54 | |
---|
| 55 | // -------------------- Vérification des identifiants ----------------------- |
---|
| 56 | |
---|
| 57 | void cxios_field_valid_id (bool * _ret, const char * _id, int _id_len) |
---|
| 58 | { |
---|
| 59 | std::string id; |
---|
| 60 | if (!cstr2string(_id, _id_len, id)) return; |
---|
[347] | 61 | CTimer::get("XIOS").resume() ; |
---|
[346] | 62 | *_ret = CField::has(id); |
---|
[347] | 63 | CTimer::get("XIOS").suspend() ; |
---|
[325] | 64 | } |
---|
| 65 | |
---|
| 66 | void cxios_fieldgroup_valid_id (bool * _ret, const char * _id, int _id_len) |
---|
| 67 | { |
---|
| 68 | std::string id; |
---|
| 69 | if (!cstr2string(_id, _id_len, id)) return; |
---|
[347] | 70 | CTimer::get("XIOS").resume() ; |
---|
[346] | 71 | *_ret = CFieldGroup::has(id); |
---|
[347] | 72 | CTimer::get("XIOS").suspend() ; |
---|
[325] | 73 | } |
---|
| 74 | |
---|
| 75 | // ----------------------------------------------------------------------------------------------------- |
---|
[943] | 76 | // ------------------------- Other functions |
---|
[325] | 77 | // ----------------------------------------------------------------------------------------------------- |
---|
| 78 | |
---|
[1158] | 79 | void cxios_field_is_active (XFieldPtr field_hdl, bool at_current_timestep, bool* ret) |
---|
[325] | 80 | { |
---|
[347] | 81 | CTimer::get("XIOS").resume() ; |
---|
[1158] | 82 | *ret = field_hdl->isActive(at_current_timestep); |
---|
[347] | 83 | CTimer::get("XIOS").suspend() ; |
---|
[325] | 84 | } |
---|
[943] | 85 | |
---|
| 86 | // ----------------------------------------------------------------------------------------------------- |
---|
| 87 | // ------------------------- Retrieving information of grid associated to field |
---|
| 88 | // ----------------------------------------------------------------------------------------------------- |
---|
| 89 | void cxios_field_get_domain_handle(XDomainPtr * domain_hdl_ret, XFieldPtr field_hdl, int domainIndex) |
---|
| 90 | { |
---|
| 91 | CTimer::get("XIOS").resume() ; |
---|
| 92 | *domain_hdl_ret = field_hdl->grid->getDomain(domainIndex); |
---|
| 93 | CTimer::get("XIOS").suspend(); |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | void cxios_field_get_axis_handle(XAxisPtr * axis_hdl_ret, XFieldPtr field_hdl, int axisIndex) |
---|
| 97 | { |
---|
| 98 | CTimer::get("XIOS").resume() ; |
---|
| 99 | *axis_hdl_ret = field_hdl->grid->getAxis(axisIndex); |
---|
| 100 | CTimer::get("XIOS").suspend(); |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | void cxios_field_get_scalar_handle(XScalarPtr * scalar_hdl_ret, XFieldPtr field_hdl, int scalarIndex) |
---|
| 104 | { |
---|
| 105 | CTimer::get("XIOS").resume() ; |
---|
| 106 | *scalar_hdl_ret = field_hdl->grid->getScalar(scalarIndex); |
---|
| 107 | CTimer::get("XIOS").suspend(); |
---|
| 108 | } |
---|
[325] | 109 | } // extern "C" |
---|