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