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