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