1 | #ifndef __XIOS_GENERATE_INTERFACE_IMPL_HPP__ |
---|
2 | #define __XIOS_GENERATE_INTERFACE_IMPL_HPP__ |
---|
3 | |
---|
4 | #include "xios_spl.hpp" |
---|
5 | #include "generate_interface.hpp" |
---|
6 | #include "type_util.hpp" |
---|
7 | #include "indent.hpp" |
---|
8 | #include "enum.hpp" |
---|
9 | #include "array_new.hpp" |
---|
10 | #include "date.hpp" |
---|
11 | |
---|
12 | namespace xios |
---|
13 | { |
---|
14 | template<> string CInterface::getStrFortranType<int>(void) { return string("INTEGER"); } |
---|
15 | template<> string CInterface::getStrFortranType<bool>(void) { return string("LOGICAL"); } |
---|
16 | template<> string CInterface::getStrFortranType<double>(void) { return string("REAL"); } |
---|
17 | template<> string CInterface::getStrFortranType<float>(void) { return string("REAL"); } |
---|
18 | template<> string CInterface::getStrFortranType<CDate>(void) { return string("TYPE(txios(date))"); } |
---|
19 | template<> string CInterface::getStrFortranType<CDuration>(void) { return string("TYPE(txios(duration))"); } |
---|
20 | |
---|
21 | template<> string CInterface::getStrFortranKind<int>(void) { return string(""); } |
---|
22 | template<> string CInterface::getStrFortranKind<bool>(void) { return string(""); } |
---|
23 | template<> string CInterface::getStrFortranKind<double>(void) { return string("(KIND=8)"); } |
---|
24 | template<> string CInterface::getStrFortranKind<float>(void) { return string("(KIND=4)"); } |
---|
25 | template<> string CInterface::getStrFortranKind<CDate>(void) { return string(""); } |
---|
26 | template<> string CInterface::getStrFortranKind<CDuration>(void) { return string(""); } |
---|
27 | |
---|
28 | template<> string CInterface::getStrFortranKindC<int>(void) { return string("(KIND=C_INT)"); } |
---|
29 | template<> string CInterface::getStrFortranKindC<bool>(void) { return string("(KIND=C_BOOL)"); } |
---|
30 | template<> string CInterface::getStrFortranKindC<double>(void) { return string("(KIND=C_DOUBLE)"); } |
---|
31 | template<> string CInterface::getStrFortranKindC<float>(void) { return string("(KIND=C_FLOAT)"); } |
---|
32 | template<> string CInterface::getStrFortranKindC<CDate>(void) { return string(""); } |
---|
33 | template<> string CInterface::getStrFortranKindC<CDuration>(void) { return string(""); } |
---|
34 | |
---|
35 | template<> bool CInterface::matchingTypeCFortran<int>(void) { return true; } |
---|
36 | template<> bool CInterface::matchingTypeCFortran<bool>(void) { return false; } |
---|
37 | template<> bool CInterface::matchingTypeCFortran<double>(void) { return true; } |
---|
38 | template<> bool CInterface::matchingTypeCFortran<float>(void) { return true; } |
---|
39 | template<> bool CInterface::matchingTypeCFortran<CDate>(void) { return true; } |
---|
40 | template<> bool CInterface::matchingTypeCFortran<CDuration>(void) { return true; } |
---|
41 | |
---|
42 | // ///////////////////////////////////////////////// |
---|
43 | // // C Interface // |
---|
44 | // ///////////////////////////////////////////////// |
---|
45 | |
---|
46 | void CInterface::AttributeIsDefinedCInterface(ostream& oss, const string& className, const string& name) |
---|
47 | { |
---|
48 | oss << "bool cxios_is_defined_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl)" << iendl; |
---|
49 | oss << "{" << iendl; |
---|
50 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; |
---|
51 | oss << " bool isDefined = " << className << "_hdl->" << name << ".hasInheritedValue();" << iendl; |
---|
52 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; |
---|
53 | oss << " return isDefined;" << iendl; |
---|
54 | oss << "}" << std::endl; |
---|
55 | } |
---|
56 | |
---|
57 | template <class T> |
---|
58 | void CInterface::AttributeCInterface(ostream& oss, const string& className, const string& name) |
---|
59 | { |
---|
60 | string typeName = getStrType<T>(); |
---|
61 | |
---|
62 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << " " << name << ")" << iendl; |
---|
63 | oss << "{" << iendl; |
---|
64 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; |
---|
65 | oss << " " << className << "_hdl->" << name << ".setValue(" << name << ");" << iendl; |
---|
66 | // oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl; |
---|
67 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; |
---|
68 | oss << "}" << std::endl; |
---|
69 | |
---|
70 | oss << iendl; |
---|
71 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ")" << iendl; |
---|
72 | oss << "{" << iendl; |
---|
73 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; |
---|
74 | oss << " *" << name << " = " << className << "_hdl->" << name << ".getInheritedValue();" << iendl; |
---|
75 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; |
---|
76 | oss << "}" << std::endl; |
---|
77 | } |
---|
78 | |
---|
79 | template<> |
---|
80 | void CInterface::AttributeCInterface<string>(ostream& oss, const string& className, const string& name) |
---|
81 | { |
---|
82 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, const char * " << name << ", int " << name << "_size)" << iendl; |
---|
83 | oss << "{" << iendl; |
---|
84 | oss << " std::string " << name << "_str;" << iendl; |
---|
85 | oss << " if (!cstr2string(" << name << ", " << name << "_size, " << name << "_str)) return;" << iendl; |
---|
86 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; |
---|
87 | oss << " " << className << "_hdl->" << name << ".setValue(" << name << "_str);" << iendl; |
---|
88 | // oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl; |
---|
89 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; |
---|
90 | oss << "}" << std::endl; |
---|
91 | |
---|
92 | oss << iendl; |
---|
93 | |
---|
94 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, char * " << name << ", int " << name << "_size)" << iendl; |
---|
95 | oss << "{" << iendl; |
---|
96 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; |
---|
97 | oss << " if (!string_copy(" << className << "_hdl->" << name << ".getInheritedValue(), " << name << ", " << name << "_size))" << iendl; |
---|
98 | oss << " ERROR(\"void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, char * " << name << ", int " |
---|
99 | << name << "_size)\", << \"Input string is too short\");" << iendl; |
---|
100 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; |
---|
101 | oss << "}" << std::endl; |
---|
102 | } |
---|
103 | |
---|
104 | template<> |
---|
105 | void CInterface::AttributeCInterface<CEnumBase>(ostream& oss, const string& className, const string& name) |
---|
106 | { |
---|
107 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, const char * " << name << ", int " << name << "_size)" << iendl; |
---|
108 | oss << "{" << iendl; |
---|
109 | oss << " std::string " << name << "_str;" << iendl; |
---|
110 | oss << " if (!cstr2string(" << name << ", " << name << "_size, " << name << "_str)) return;" << iendl; |
---|
111 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; |
---|
112 | oss << " " << className << "_hdl->" << name << ".fromString(" << name << "_str);" << iendl; |
---|
113 | // oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl; |
---|
114 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; |
---|
115 | oss << "}" << std::endl; |
---|
116 | |
---|
117 | oss << iendl; |
---|
118 | |
---|
119 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, char * " << name << ", int " << name << "_size)" << iendl; |
---|
120 | oss << "{" << iendl; |
---|
121 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; |
---|
122 | oss << " if (!string_copy(" << className << "_hdl->" << name << ".getInheritedStringValue(), " << name << ", " << name << "_size))" << iendl; |
---|
123 | oss << " ERROR(\"void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, char * " << name << ", int " |
---|
124 | << name << "_size)\", << \"Input string is too short\");" << iendl; |
---|
125 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; |
---|
126 | oss << "}" << std::endl; |
---|
127 | } |
---|
128 | |
---|
129 | template<> |
---|
130 | void CInterface::AttributeCInterface<CDate>(ostream& oss, const string& className, const string& name) |
---|
131 | { |
---|
132 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, cxios_date " << name << "_c)" << iendl; |
---|
133 | oss << "{" << iendl; |
---|
134 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; |
---|
135 | oss << " " << className << "_hdl->" << name << ".allocate();" << iendl; |
---|
136 | oss << " CDate& " << name << " = " << className << "_hdl->" << name << ".get();" << iendl; |
---|
137 | oss << " " << name << ".setDate(" << name << "_c.year," << iendl; |
---|
138 | oss << " " << name << "_c.month," << iendl; |
---|
139 | oss << " " << name << "_c.day," << iendl; |
---|
140 | oss << " " << name << "_c.hour," << iendl; |
---|
141 | oss << " " << name << "_c.minute," << iendl; |
---|
142 | oss << " " << name << "_c.second);" << iendl; |
---|
143 | oss << " if (" << name << ".hasRelCalendar())" << iendl; |
---|
144 | oss << " " << name << ".checkDate();" << iendl; |
---|
145 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; |
---|
146 | oss << "}" << std::endl; |
---|
147 | |
---|
148 | oss << iendl; |
---|
149 | |
---|
150 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, cxios_date* " << name << "_c)" << iendl; |
---|
151 | oss << "{" << iendl; |
---|
152 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; |
---|
153 | oss << " CDate " << name << " = " << className << "_hdl->" << name << ".getInheritedValue();" << iendl; |
---|
154 | oss << " " << name << "_c->year = " << name << ".getYear();" << iendl; |
---|
155 | oss << " " << name << "_c->month = " << name << ".getMonth();" << iendl; |
---|
156 | oss << " " << name << "_c->day = " << name << ".getDay();" << iendl; |
---|
157 | oss << " " << name << "_c->hour = " << name << ".getHour();" << iendl; |
---|
158 | oss << " " << name << "_c->minute = " << name << ".getMinute();" << iendl; |
---|
159 | oss << " " << name << "_c->second = " << name << ".getSecond();" << iendl; |
---|
160 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; |
---|
161 | oss << "}" << std::endl; |
---|
162 | } |
---|
163 | |
---|
164 | template<> |
---|
165 | void CInterface::AttributeCInterface<CDuration>(ostream& oss, const string& className, const string& name) |
---|
166 | { |
---|
167 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, cxios_duration " << name << "_c)" << iendl; |
---|
168 | oss << "{" << iendl; |
---|
169 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; |
---|
170 | oss << " " << className << "_hdl->" << name << ".allocate();" << iendl; |
---|
171 | oss << " CDuration& " << name << " = " << className << "_hdl->" << name << ".get();" << iendl; |
---|
172 | oss << " " << name << ".year = " << name << "_c.year;" << iendl; |
---|
173 | oss << " " << name << ".month = " << name << "_c.month;" << iendl; |
---|
174 | oss << " " << name << ".day = " << name << "_c.day;" << iendl; |
---|
175 | oss << " " << name << ".hour = " << name << "_c.hour;" << iendl; |
---|
176 | oss << " " << name << ".minute = " << name << "_c.minute;" << iendl; |
---|
177 | oss << " " << name << ".second = " << name << "_c.second;" << iendl; |
---|
178 | oss << " " << name << ".timestep = " << name << "_c.timestep;" << iendl; |
---|
179 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; |
---|
180 | oss << "}" << std::endl; |
---|
181 | |
---|
182 | oss << iendl; |
---|
183 | |
---|
184 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, cxios_duration* " << name << "_c)" << iendl; |
---|
185 | oss << "{" << iendl; |
---|
186 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; |
---|
187 | oss << " CDuration " << name << " = " << className << "_hdl->" << name << ".getInheritedValue();" << iendl; |
---|
188 | oss << " " << name << "_c->year = " << name << ".year;" << iendl; |
---|
189 | oss << " " << name << "_c->month = " << name << ".month;" << iendl; |
---|
190 | oss << " " << name << "_c->day = " << name << ".day;" << iendl; |
---|
191 | oss << " " << name << "_c->hour = " << name << ".hour;" << iendl; |
---|
192 | oss << " " << name << "_c->minute = " << name << ".minute;" << iendl; |
---|
193 | oss << " " << name << "_c->second = " << name << ".second;" << iendl; |
---|
194 | oss << " " << name << "_c->timestep = " << name << ".timestep;" << iendl; |
---|
195 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; |
---|
196 | oss << "}" << std::endl; |
---|
197 | } |
---|
198 | |
---|
199 | /* |
---|
200 | #define macro(T) \ |
---|
201 | template <> \ |
---|
202 | void CInterface::AttributeCInterface<ARRAY(T,1)>(ostream& oss, const string& className, const string& name) \ |
---|
203 | { \ |
---|
204 | string typeName=getStrType<T>(); \ |
---|
205 | \ |
---|
206 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int extent1)" << iendl; \ |
---|
207 | oss << "{" << iendl; \ |
---|
208 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
209 | oss << " ARRAY(" << typeName << ",1) array_tmp(new CArray<" << typeName << ",1>(boost::extents[extent1]));" << iendl; \ |
---|
210 | oss << " std::copy(" << name << ", &(" << name << "[array_tmp->num_elements()]), array_tmp->data());" << iendl; \ |
---|
211 | oss << " " << className << "_hdl->" << name << ".setValue(array_tmp);" << iendl; \ |
---|
212 | // oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl; \ |
---|
213 | oss << "}" << std::endl; \ |
---|
214 | oss << iendl; \ |
---|
215 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int extent1)" << iendl; \ |
---|
216 | oss << "{" << iendl; \ |
---|
217 | oss << " if (!array_copy(" << className << "_hdl->" << name << ".getValue(), " << name << ", extent1))" << iendl; \ |
---|
218 | oss << " ERROR(\"void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int extent1)\", << " \ |
---|
219 | << "\"Output array size is not conform to array size attribute\");" << iendl; \ |
---|
220 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
221 | oss << "}" << std::endl; \ |
---|
222 | } \ |
---|
223 | \ |
---|
224 | template <> \ |
---|
225 | void CInterface::AttributeCInterface<ARRAY(T,2)>(ostream& oss, const string& className, const string& name) \ |
---|
226 | { \ |
---|
227 | string typeName=getStrType<T>(); \ |
---|
228 | \ |
---|
229 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int extent1, int extent2)" << iendl; \ |
---|
230 | oss << "{" << iendl; \ |
---|
231 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
232 | oss << " ARRAY(" << typeName << ",2) array_tmp(new CArray<" << typeName << ",2>(boost::extents[extent1][extent2]));" << iendl; \ |
---|
233 | oss << " std::copy(" << name << ", &(" << name << "[array_tmp->num_elements()]), array_tmp->data());" << iendl; \ |
---|
234 | oss << " " << className << "_hdl->" << name << ".setValue(array_tmp);" << iendl; \ |
---|
235 | // oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl; \ |
---|
236 | oss << "}" << std::endl; \ |
---|
237 | oss << iendl; \ |
---|
238 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int extent1, int extent2)" << iendl; \ |
---|
239 | oss << "{" << iendl; \ |
---|
240 | oss << " if (!array_copy(" << className << "_hdl->" << name << ".getValue(), " << name << ", extent1, extent2))" << iendl; \ |
---|
241 | oss << " ERROR(\"void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int extent1, int extent2)\", << " \ |
---|
242 | << "\"Output array size is not conform to array size attribute\");" << iendl; \ |
---|
243 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
244 | oss << "}" << std::endl; \ |
---|
245 | } \ |
---|
246 | \ |
---|
247 | template <> \ |
---|
248 | void CInterface::AttributeCInterface<ARRAY(T,3)>(ostream& oss, const string& className, const string& name) \ |
---|
249 | { \ |
---|
250 | string typeName=getStrType<T>(); \ |
---|
251 | \ |
---|
252 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int extent1, int extent2, int extent3)" << iendl; \ |
---|
253 | oss << "{" << iendl; \ |
---|
254 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
255 | oss << " ARRAY(" << typeName << ",3) array_tmp(new CArray<" << typeName << ",3>(boost::extents[extent1][extent2][extent3]));" << iendl; \ |
---|
256 | oss << " std::copy(" << name << ", &(" << name << "[array_tmp->num_elements()]), array_tmp->data());" << iendl; \ |
---|
257 | oss << " " << className << "_hdl->" << name << ".setValue(array_tmp);" << iendl; \ |
---|
258 | // oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl; \ |
---|
259 | oss << "}" << std::endl; \ |
---|
260 | oss << iendl; \ |
---|
261 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int extent1, int extent2, int extent3)" << iendl; \ |
---|
262 | oss << "{" << iendl; \ |
---|
263 | oss << " if (!array_copy(" << className << "_hdl->" << name << ".getValue(), " << name << ", extent1))" << iendl; \ |
---|
264 | oss << " ERROR(\"void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int extent1, int extent2, int extent3)\", << " \ |
---|
265 | << "\"Output array size is not conform to array size attribute\");" << iendl; \ |
---|
266 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
267 | oss << "}" << std::endl; \ |
---|
268 | } |
---|
269 | |
---|
270 | macro(bool) |
---|
271 | macro(double) |
---|
272 | macro(int) |
---|
273 | */ |
---|
274 | |
---|
275 | #undef macro |
---|
276 | |
---|
277 | // ///////////////////////////////////////////////// |
---|
278 | // // Fortran 2003 Interface // |
---|
279 | // ///////////////////////////////////////////////// |
---|
280 | void CInterface::AttributeIsDefinedFortran2003Interface(ostream& oss, const string& className, const string& name) |
---|
281 | { |
---|
282 | oss << "FUNCTION cxios_is_defined_" << className << "_" << name << "(" << className << "_hdl) BIND(C)" << iendl; |
---|
283 | oss << " USE ISO_C_BINDING" << iendl; |
---|
284 | oss << " LOGICAL(kind=C_BOOL) :: cxios_is_defined_" << className << "_" << name << iendl; |
---|
285 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; |
---|
286 | oss << "END FUNCTION cxios_is_defined_" << className << "_" << name << std::endl; |
---|
287 | } |
---|
288 | |
---|
289 | template <class T> |
---|
290 | void CInterface::AttributeFortran2003Interface(ostream& oss, const string& className, const string& name) |
---|
291 | { |
---|
292 | string fortranType=getStrFortranType<T>(); |
---|
293 | string fortranKindC=getStrFortranKindC<T>(); |
---|
294 | |
---|
295 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; |
---|
296 | oss << " USE ISO_C_BINDING" << iendl; |
---|
297 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; |
---|
298 | oss << " " << fortranType << " " << fortranKindC << " , VALUE :: " << name << iendl; |
---|
299 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; |
---|
300 | oss << iendl; |
---|
301 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; |
---|
302 | oss << " USE ISO_C_BINDING" << iendl; |
---|
303 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; |
---|
304 | oss << " " << fortranType << " " << fortranKindC << " :: " << name << iendl; |
---|
305 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; |
---|
306 | } |
---|
307 | |
---|
308 | template <> |
---|
309 | void CInterface::AttributeFortran2003Interface<string>(ostream& oss, const string& className, const string& name) |
---|
310 | { |
---|
311 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", " << name << "_size) BIND(C)" << iendl; |
---|
312 | oss << " USE ISO_C_BINDING" << iendl; |
---|
313 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; |
---|
314 | oss << " CHARACTER(kind = C_CHAR) , DIMENSION(*) :: " << name << iendl; |
---|
315 | oss << " INTEGER (kind = C_INT) , VALUE :: " << name << "_size" << iendl; |
---|
316 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; |
---|
317 | oss << iendl; |
---|
318 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", " << name << "_size) BIND(C)" << iendl; |
---|
319 | oss << " USE ISO_C_BINDING" << iendl; |
---|
320 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; |
---|
321 | oss << " CHARACTER(kind = C_CHAR) , DIMENSION(*) :: " << name << iendl; |
---|
322 | oss << " INTEGER (kind = C_INT) , VALUE :: " << name << "_size" << iendl; |
---|
323 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; |
---|
324 | } |
---|
325 | |
---|
326 | template <> |
---|
327 | void CInterface::AttributeFortran2003Interface<CDate>(ostream& oss, const string& className, const string& name) |
---|
328 | { |
---|
329 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; |
---|
330 | oss << " USE ISO_C_BINDING" << iendl; |
---|
331 | oss << " USE IDATE" << iendl; |
---|
332 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; |
---|
333 | oss << " TYPE(txios(date)), VALUE :: " << name << iendl; |
---|
334 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; |
---|
335 | oss << iendl; |
---|
336 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; |
---|
337 | oss << " USE ISO_C_BINDING" << iendl; |
---|
338 | oss << " USE IDATE" << iendl; |
---|
339 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; |
---|
340 | oss << " TYPE(txios(date)) :: " << name << iendl; |
---|
341 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; |
---|
342 | } |
---|
343 | |
---|
344 | template <> |
---|
345 | void CInterface::AttributeFortran2003Interface<CDuration>(ostream& oss, const string& className, const string& name) |
---|
346 | { |
---|
347 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; |
---|
348 | oss << " USE ISO_C_BINDING" << iendl; |
---|
349 | oss << " USE IDURATION" << iendl; |
---|
350 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; |
---|
351 | oss << " TYPE(txios(duration)), VALUE :: " << name << iendl; |
---|
352 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; |
---|
353 | oss << iendl; |
---|
354 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; |
---|
355 | oss << " USE ISO_C_BINDING" << iendl; |
---|
356 | oss << " USE IDURATION" << iendl; |
---|
357 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; |
---|
358 | oss << " TYPE(txios(duration)) :: " << name << iendl; |
---|
359 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; |
---|
360 | } |
---|
361 | |
---|
362 | /* |
---|
363 | #define macro(T) \ |
---|
364 | template <> \ |
---|
365 | void CInterface::AttributeFortran2003Interface<ARRAY(T,1)>(ostream& oss, const string& className, const string& name) \ |
---|
366 | { \ |
---|
367 | string fortranType=getStrFortranType<T>(); \ |
---|
368 | string fortranKindC=getStrFortranKindC<T>(); \ |
---|
369 | \ |
---|
370 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent1) BIND(C)" << iendl; \ |
---|
371 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
372 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
373 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
374 | oss << " INTEGER (kind = C_INT), VALUE :: extent1" << iendl; \ |
---|
375 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ |
---|
376 | oss << iendl; \ |
---|
377 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent1) BIND(C)" << iendl; \ |
---|
378 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
379 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
380 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
381 | oss << " INTEGER (kind = C_INT), VALUE :: extent1" << iendl; \ |
---|
382 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ |
---|
383 | } \ |
---|
384 | \ |
---|
385 | template <> \ |
---|
386 | void CInterface::AttributeFortran2003Interface<ARRAY(T,2)>(ostream& oss, const string& className, const string& name) \ |
---|
387 | { \ |
---|
388 | string fortranType=getStrFortranType<T>(); \ |
---|
389 | string fortranKindC=getStrFortranKindC<T>(); \ |
---|
390 | \ |
---|
391 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent1, extent2) BIND(C)" << iendl; \ |
---|
392 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
393 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
394 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
395 | oss << " INTEGER (kind = C_INT), VALUE :: extent1" << iendl; \ |
---|
396 | oss << " INTEGER (kind = C_INT), VALUE :: extent2" << iendl; \ |
---|
397 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ |
---|
398 | oss << iendl; \ |
---|
399 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent1, extent2) BIND(C)" << iendl; \ |
---|
400 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
401 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
402 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
403 | oss << " INTEGER (kind = C_INT), VALUE :: extent1" << iendl; \ |
---|
404 | oss << " INTEGER (kind = C_INT), VALUE :: extent2" << iendl; \ |
---|
405 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ |
---|
406 | } \ |
---|
407 | \ |
---|
408 | template <> \ |
---|
409 | void CInterface::AttributeFortran2003Interface<ARRAY(T,3)>(ostream& oss, const string& className, const string& name) \ |
---|
410 | { \ |
---|
411 | string fortranType=getStrFortranType<T>(); \ |
---|
412 | string fortranKindC=getStrFortranKindC<T>(); \ |
---|
413 | \ |
---|
414 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent1, extent2, extent3) BIND(C)" << iendl; \ |
---|
415 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
416 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
417 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
418 | oss << " INTEGER (kind = C_INT), VALUE :: extent1" << iendl; \ |
---|
419 | oss << " INTEGER (kind = C_INT), VALUE :: extent2" << iendl; \ |
---|
420 | oss << " INTEGER (kind = C_INT), VALUE :: extent3" << iendl; \ |
---|
421 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ |
---|
422 | oss << iendl; \ |
---|
423 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent1, extent2, extent3) BIND(C)" << iendl; \ |
---|
424 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
425 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
426 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
427 | oss << " INTEGER (kind = C_INT), VALUE :: extent1" << iendl; \ |
---|
428 | oss << " INTEGER (kind = C_INT), VALUE :: extent2" << iendl; \ |
---|
429 | oss << " INTEGER (kind = C_INT), VALUE :: extent3" << iendl; \ |
---|
430 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ |
---|
431 | } |
---|
432 | |
---|
433 | macro(bool) |
---|
434 | macro(double) |
---|
435 | macro(int) |
---|
436 | |
---|
437 | #undef macro |
---|
438 | */ |
---|
439 | template <class T> |
---|
440 | void CInterface::AttributeFortranInterfaceDeclaration(ostream& oss, const string& className, const string& name) |
---|
441 | { |
---|
442 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name; |
---|
443 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " :: " << name << "_tmp"; |
---|
444 | } |
---|
445 | |
---|
446 | template <class T> |
---|
447 | void CInterface::AttributeFortranInterfaceGetDeclaration(ostream& oss, const string& className, const string& name) |
---|
448 | { |
---|
449 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name; |
---|
450 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " :: " << name << "_tmp"; |
---|
451 | } |
---|
452 | |
---|
453 | void CInterface::AttributeFortranInterfaceIsDefinedDeclaration(ostream& oss, const string& className, const string& name) |
---|
454 | { |
---|
455 | oss << "LOGICAL, OPTIONAL, INTENT(OUT) :: " << name << iendl; |
---|
456 | oss << "LOGICAL(KIND=C_BOOL) :: " << name << "_tmp"; |
---|
457 | } |
---|
458 | |
---|
459 | template <> |
---|
460 | void CInterface::AttributeFortranInterfaceDeclaration<string>(ostream& oss, const string& className, const string& name) |
---|
461 | { |
---|
462 | oss << "CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: " << name; |
---|
463 | } |
---|
464 | |
---|
465 | template <> |
---|
466 | void CInterface::AttributeFortranInterfaceGetDeclaration<string>(ostream& oss, const string& className, const string& name) |
---|
467 | { |
---|
468 | oss << "CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: " << name; |
---|
469 | } |
---|
470 | |
---|
471 | /* |
---|
472 | #define macro(T) \ |
---|
473 | template <> \ |
---|
474 | void CInterface::AttributeFortranInterfaceDeclaration<ARRAY(T,1)>(ostream& oss, const string& className, const string& name) \ |
---|
475 | { \ |
---|
476 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:)"; \ |
---|
477 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:)"; \ |
---|
478 | } \ |
---|
479 | template <> \ |
---|
480 | void CInterface::AttributeFortranInterfaceGetDeclaration<ARRAY(T,1)>(ostream& oss, const string& className, const string& name) \ |
---|
481 | { \ |
---|
482 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:)"; \ |
---|
483 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:)"; \ |
---|
484 | } \ |
---|
485 | \ |
---|
486 | template <> \ |
---|
487 | void CInterface::AttributeFortranInterfaceDeclaration<ARRAY(T,2)>(ostream& oss, const string& className, const string& name) \ |
---|
488 | { \ |
---|
489 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:)"; \ |
---|
490 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:)"; \ |
---|
491 | } \ |
---|
492 | \ |
---|
493 | template <> \ |
---|
494 | void CInterface::AttributeFortranInterfaceGetDeclaration<ARRAY(T,2)>(ostream& oss, const string& className, const string& name) \ |
---|
495 | { \ |
---|
496 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:)"; \ |
---|
497 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:)"; \ |
---|
498 | } \ |
---|
499 | \ |
---|
500 | template <> \ |
---|
501 | void CInterface::AttributeFortranInterfaceDeclaration<ARRAY(T,3)>(ostream& oss, const string& className, const string& name) \ |
---|
502 | { \ |
---|
503 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:)"; \ |
---|
504 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:)"; \ |
---|
505 | } \ |
---|
506 | \ |
---|
507 | template <> \ |
---|
508 | void CInterface::AttributeFortranInterfaceGetDeclaration<ARRAY(T,3)>(ostream& oss, const string& className, const string& name) \ |
---|
509 | { \ |
---|
510 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:)"; \ |
---|
511 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:)"; \ |
---|
512 | } |
---|
513 | |
---|
514 | macro(bool) |
---|
515 | macro(double) |
---|
516 | macro(int) |
---|
517 | |
---|
518 | #undef macro |
---|
519 | */ |
---|
520 | |
---|
521 | template <class T> |
---|
522 | void CInterface::AttributeFortranInterfaceBody(ostream& oss, const string& className, const string& name) |
---|
523 | { |
---|
524 | string name_tmp=name+"__tmp"; |
---|
525 | |
---|
526 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; |
---|
527 | if (!matchingTypeCFortran<T>()) |
---|
528 | { |
---|
529 | oss << " " << name_tmp << " = " << name << "_" << iendl; |
---|
530 | oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ")" << iendl; |
---|
531 | } |
---|
532 | else oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_)" << iendl; |
---|
533 | oss << "ENDIF"; |
---|
534 | } |
---|
535 | |
---|
536 | template <class T> |
---|
537 | void CInterface::AttributeFortranInterfaceGetBody(ostream& oss, const string& className, const string& name) |
---|
538 | { |
---|
539 | string name_tmp=name+"__tmp"; |
---|
540 | |
---|
541 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; |
---|
542 | if (!matchingTypeCFortran<T>()) |
---|
543 | { |
---|
544 | oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ")" << iendl; |
---|
545 | oss << " " << name << "_ = " << name_tmp << iendl; |
---|
546 | } |
---|
547 | else oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_)" << iendl; |
---|
548 | oss << "ENDIF"; |
---|
549 | } |
---|
550 | |
---|
551 | void CInterface::AttributeFortranInterfaceIsDefinedBody(ostream& oss, const string& className, const string& name) |
---|
552 | { |
---|
553 | string name_tmp=name+"__tmp"; |
---|
554 | |
---|
555 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; |
---|
556 | oss << " " << name << "__tmp = cxios_is_defined_" << className << "_" << name << "(" << className << "_hdl%daddr)" << iendl; |
---|
557 | oss << " " << name << "_ = " << name_tmp << iendl; |
---|
558 | oss << "ENDIF"; |
---|
559 | } |
---|
560 | |
---|
561 | template <> |
---|
562 | void CInterface::AttributeFortranInterfaceBody<string>(ostream& oss, const string& className, const string& name) |
---|
563 | { |
---|
564 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; |
---|
565 | oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, len(" << name << "_))" << iendl; |
---|
566 | oss << "ENDIF"; |
---|
567 | } |
---|
568 | |
---|
569 | template <> |
---|
570 | void CInterface::AttributeFortranInterfaceGetBody<string>(ostream& oss, const string& className, const string& name) |
---|
571 | { |
---|
572 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; |
---|
573 | oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, len(" << name << "_))" << iendl; |
---|
574 | oss << "ENDIF"; |
---|
575 | } |
---|
576 | |
---|
577 | /* |
---|
578 | #define macro(T) \ |
---|
579 | template <> \ |
---|
580 | void CInterface::AttributeFortranInterfaceBody< ARRAY(T,1) >(ostream& oss, const string& className, const string& name) \ |
---|
581 | { \ |
---|
582 | string name_tmp=name+"__tmp"; \ |
---|
583 | \ |
---|
584 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
585 | if (!matchingTypeCFortran<T>()) \ |
---|
586 | { \ |
---|
587 | oss << " ALLOCATE(" << name_tmp << "(size(" << name << "_,1)))" << iendl; \ |
---|
588 | oss << " " << name_tmp << " = " << name << "_" << iendl; \ |
---|
589 | oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", size(" << name << "_,1))" << iendl; \ |
---|
590 | } \ |
---|
591 | else oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, size(" << name << "_,1))" << iendl; \ |
---|
592 | oss << "ENDIF"; \ |
---|
593 | } \ |
---|
594 | \ |
---|
595 | template <> \ |
---|
596 | void CInterface::AttributeFortranInterfaceBody< ARRAY(T,2) >(ostream& oss, const string& className, const string& name) \ |
---|
597 | { \ |
---|
598 | string name_tmp=name+"__tmp"; \ |
---|
599 | \ |
---|
600 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
601 | if (!matchingTypeCFortran<T>()) \ |
---|
602 | { \ |
---|
603 | oss << " ALLOCATE(" << name_tmp << "(size(" << name << "_,1), size(" << name << "_,2)))" << iendl; \ |
---|
604 | oss << " " << name_tmp << " = " << name << "_" << iendl; \ |
---|
605 | oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", size(" << name << "_,1), size(" << name << "_,2))" << iendl; \ |
---|
606 | } \ |
---|
607 | else oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, size(" << name << "_,1), size(" << name << "_,2))" << iendl; \ |
---|
608 | oss << "ENDIF"; \ |
---|
609 | } \ |
---|
610 | \ |
---|
611 | template <> \ |
---|
612 | void CInterface::AttributeFortranInterfaceBody< ARRAY(T,3) >(ostream& oss, const string& className, const string& name) \ |
---|
613 | { \ |
---|
614 | string name_tmp=name+"__tmp"; \ |
---|
615 | \ |
---|
616 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
617 | if (!matchingTypeCFortran<T>()) \ |
---|
618 | { \ |
---|
619 | oss << " ALLOCATE(" << name_tmp << "(size(" << name << "_,1), size(" << name << "_,2), size(" << name << "_,3)))" << iendl; \ |
---|
620 | oss << " " << name_tmp << " = " << name << "_" << iendl; \ |
---|
621 | oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", size(" << name << "_,1), size(" << name << "_,2), size(" << name << "_,3))" << iendl; \ |
---|
622 | } \ |
---|
623 | else oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, size(" << name << "_,1), size(" << name << "_,2), size(" << name << "_,3))" << iendl; \ |
---|
624 | oss << "ENDIF"; \ |
---|
625 | } |
---|
626 | |
---|
627 | macro(bool) |
---|
628 | macro(double) |
---|
629 | macro(int) |
---|
630 | |
---|
631 | #undef macro |
---|
632 | */ |
---|
633 | |
---|
634 | /* |
---|
635 | #define macro(T) \ |
---|
636 | template <> \ |
---|
637 | void CInterface::AttributeFortranInterfaceGetBody< ARRAY(T,1) >(ostream& oss, const string& className, const string& name) \ |
---|
638 | { \ |
---|
639 | string name_tmp=name+"__tmp"; \ |
---|
640 | \ |
---|
641 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
642 | if (!matchingTypeCFortran<T>()) \ |
---|
643 | { \ |
---|
644 | oss << " ALLOCATE(" << name_tmp << "(size(" << name << "_,1)))" << iendl; \ |
---|
645 | oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", size(" << name << "_,1))" << iendl; \ |
---|
646 | oss << " " << name << "_ = " << name_tmp << iendl; \ |
---|
647 | } \ |
---|
648 | else oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, size(" << name << "_,1))" << iendl; \ |
---|
649 | oss << "ENDIF"; \ |
---|
650 | } \ |
---|
651 | \ |
---|
652 | template <> \ |
---|
653 | void CInterface::AttributeFortranInterfaceGetBody< ARRAY(T,2) >(ostream& oss, const string& className, const string& name) \ |
---|
654 | { \ |
---|
655 | string name_tmp=name+"__tmp"; \ |
---|
656 | \ |
---|
657 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
658 | if (!matchingTypeCFortran<T>()) \ |
---|
659 | { \ |
---|
660 | oss << " ALLOCATE(" << name_tmp << "(size(" << name << "_,1), size(" << name << "_,2)))" << iendl; \ |
---|
661 | oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", size(" << name << "_,1), size(" << name << "_,2))" << iendl; \ |
---|
662 | oss << " " << name << "_ = " << name_tmp << iendl; \ |
---|
663 | } \ |
---|
664 | else oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, size(" << name << "_,1), size(" << name << "_,2))" << iendl; \ |
---|
665 | oss << "ENDIF"; \ |
---|
666 | } \ |
---|
667 | \ |
---|
668 | template <> \ |
---|
669 | void CInterface::AttributeFortranInterfaceGetBody< ARRAY(T,3) >(ostream& oss, const string& className, const string& name) \ |
---|
670 | { \ |
---|
671 | string name_tmp=name+"__tmp"; \ |
---|
672 | \ |
---|
673 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
674 | if (!matchingTypeCFortran<T>()) \ |
---|
675 | { \ |
---|
676 | oss << " ALLOCATE(" << name_tmp << "(size(" << name << "_,1), size(" << name << "_,2), size(" << name << "_,3)))" << iendl; \ |
---|
677 | oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", size(" << name << "_,1), size(" << name << "_,2), size(" << name << "_,3))" << iendl; \ |
---|
678 | oss << " " << name << "_ = " << name_tmp << iendl; \ |
---|
679 | } \ |
---|
680 | else oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, size(" << name << "_,1), size(" << name << "_,2), size(" << name << "_,3))" << iendl; \ |
---|
681 | oss << "ENDIF"; \ |
---|
682 | } |
---|
683 | |
---|
684 | macro(bool) |
---|
685 | macro(double) |
---|
686 | macro(int) |
---|
687 | |
---|
688 | #undef macro |
---|
689 | */ |
---|
690 | |
---|
691 | // declaration for CArray |
---|
692 | |
---|
693 | #define macro(T) \ |
---|
694 | template <> \ |
---|
695 | void CInterface::AttributeCInterface<CArray<T,1> >(ostream& oss, const string& className, const string& name) \ |
---|
696 | { \ |
---|
697 | string typeName=getStrType<T>(); \ |
---|
698 | \ |
---|
699 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int extent1)" << iendl; \ |
---|
700 | oss << "{" << iendl; \ |
---|
701 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
702 | oss << " CArray<" << typeName << ",1> tmp(" << name << ", shape(extent1), neverDeleteData);" << iendl; \ |
---|
703 | oss << " " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \ |
---|
704 | /*oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \ |
---|
705 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
706 | oss << "}" << std::endl; \ |
---|
707 | oss << iendl; \ |
---|
708 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int extent1)" << iendl; \ |
---|
709 | oss << "{" << iendl; \ |
---|
710 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
711 | oss << " CArray<" << typeName << ",1> tmp(" << name << ", shape(extent1), neverDeleteData);" << iendl; \ |
---|
712 | oss << " tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \ |
---|
713 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
714 | oss << "}" << std::endl; \ |
---|
715 | } \ |
---|
716 | \ |
---|
717 | template <> \ |
---|
718 | void CInterface::AttributeCInterface<CArray<T,2> >(ostream& oss, const string& className, const string& name) \ |
---|
719 | { \ |
---|
720 | string typeName=getStrType<T>(); \ |
---|
721 | \ |
---|
722 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int extent1, int extent2)" << iendl; \ |
---|
723 | oss << "{" << iendl; \ |
---|
724 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
725 | oss << " CArray<" << typeName << ",2> tmp(" << name << ", shape(extent1, extent2), neverDeleteData);" << iendl; \ |
---|
726 | oss << " " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \ |
---|
727 | /*oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \ |
---|
728 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
729 | oss << "}" << std::endl; \ |
---|
730 | oss << iendl; \ |
---|
731 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int extent1, int extent2)" << iendl; \ |
---|
732 | oss << "{" << iendl; \ |
---|
733 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
734 | oss << " CArray<" << typeName << ",2> tmp(" << name << ", shape(extent1, extent2), neverDeleteData);" << iendl; \ |
---|
735 | oss << " tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \ |
---|
736 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
737 | oss << "}" << std::endl; \ |
---|
738 | } \ |
---|
739 | \ |
---|
740 | template <> \ |
---|
741 | void CInterface::AttributeCInterface<CArray<T,3> >(ostream& oss, const string& className, const string& name) \ |
---|
742 | { \ |
---|
743 | string typeName=getStrType<T>(); \ |
---|
744 | \ |
---|
745 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int extent1, int extent2, int extent3)" << iendl; \ |
---|
746 | oss << "{" << iendl; \ |
---|
747 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
748 | oss << " CArray<" << typeName << ",3> tmp(" << name << ", shape(extent1, extent2, extent3), neverDeleteData);" << iendl; \ |
---|
749 | oss << " " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \ |
---|
750 | /*oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \ |
---|
751 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
752 | oss << "}" << std::endl; \ |
---|
753 | oss << iendl; \ |
---|
754 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int extent1, int extent2, int extent3)" << iendl; \ |
---|
755 | oss << "{" << iendl; \ |
---|
756 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
757 | oss << " CArray<" << typeName << ",3> tmp(" << name << ", shape(extent1, extent2, extent3), neverDeleteData);" << iendl; \ |
---|
758 | oss << " tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \ |
---|
759 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
760 | oss << "}" << std::endl; \ |
---|
761 | } |
---|
762 | |
---|
763 | macro(bool) |
---|
764 | macro(double) |
---|
765 | macro(int) |
---|
766 | |
---|
767 | #undef macro |
---|
768 | |
---|
769 | // ///////////////////////////////////////////////// |
---|
770 | // // Fortran 2003 Interface // |
---|
771 | // ///////////////////////////////////////////////// |
---|
772 | |
---|
773 | #define macro(T) \ |
---|
774 | template <> \ |
---|
775 | void CInterface::AttributeFortran2003Interface<CArray<T,1> >(ostream& oss, const string& className, const string& name) \ |
---|
776 | { \ |
---|
777 | string fortranType=getStrFortranType<T>(); \ |
---|
778 | string fortranKindC=getStrFortranKindC<T>(); \ |
---|
779 | \ |
---|
780 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent1) BIND(C)" << iendl; \ |
---|
781 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
782 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
783 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
784 | oss << " INTEGER (kind = C_INT), VALUE :: extent1" << iendl; \ |
---|
785 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ |
---|
786 | oss << iendl; \ |
---|
787 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent1) BIND(C)" << iendl; \ |
---|
788 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
789 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
790 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
791 | oss << " INTEGER (kind = C_INT), VALUE :: extent1" << iendl; \ |
---|
792 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ |
---|
793 | } \ |
---|
794 | \ |
---|
795 | template <> \ |
---|
796 | void CInterface::AttributeFortran2003Interface<CArray<T,2> >(ostream& oss, const string& className, const string& name) \ |
---|
797 | { \ |
---|
798 | string fortranType=getStrFortranType<T>(); \ |
---|
799 | string fortranKindC=getStrFortranKindC<T>(); \ |
---|
800 | \ |
---|
801 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent1, extent2) BIND(C)" << iendl; \ |
---|
802 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
803 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
804 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
805 | oss << " INTEGER (kind = C_INT), VALUE :: extent1" << iendl; \ |
---|
806 | oss << " INTEGER (kind = C_INT), VALUE :: extent2" << iendl; \ |
---|
807 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ |
---|
808 | oss << iendl; \ |
---|
809 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent1, extent2) BIND(C)" << iendl; \ |
---|
810 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
811 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
812 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
813 | oss << " INTEGER (kind = C_INT), VALUE :: extent1" << iendl; \ |
---|
814 | oss << " INTEGER (kind = C_INT), VALUE :: extent2" << iendl; \ |
---|
815 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ |
---|
816 | } \ |
---|
817 | \ |
---|
818 | template <> \ |
---|
819 | void CInterface::AttributeFortran2003Interface<CArray<T,3> >(ostream& oss, const string& className, const string& name) \ |
---|
820 | { \ |
---|
821 | string fortranType=getStrFortranType<T>(); \ |
---|
822 | string fortranKindC=getStrFortranKindC<T>(); \ |
---|
823 | \ |
---|
824 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent1, extent2, extent3) BIND(C)" << iendl; \ |
---|
825 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
826 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
827 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
828 | oss << " INTEGER (kind = C_INT), VALUE :: extent1" << iendl; \ |
---|
829 | oss << " INTEGER (kind = C_INT), VALUE :: extent2" << iendl; \ |
---|
830 | oss << " INTEGER (kind = C_INT), VALUE :: extent3" << iendl; \ |
---|
831 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ |
---|
832 | oss << iendl; \ |
---|
833 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent1, extent2, extent3) BIND(C)" << iendl; \ |
---|
834 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
835 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
836 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
837 | oss << " INTEGER (kind = C_INT), VALUE :: extent1" << iendl; \ |
---|
838 | oss << " INTEGER (kind = C_INT), VALUE :: extent2" << iendl; \ |
---|
839 | oss << " INTEGER (kind = C_INT), VALUE :: extent3" << iendl; \ |
---|
840 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ |
---|
841 | } |
---|
842 | |
---|
843 | macro(bool) |
---|
844 | macro(double) |
---|
845 | macro(int) |
---|
846 | |
---|
847 | #undef macro |
---|
848 | |
---|
849 | #define macro(T) \ |
---|
850 | template <> \ |
---|
851 | void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,1> >(ostream& oss, const string& className, const string& name) \ |
---|
852 | { \ |
---|
853 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:)"; \ |
---|
854 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:)"; \ |
---|
855 | } \ |
---|
856 | template <> \ |
---|
857 | void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,1> >(ostream& oss, const string& className, const string& name) \ |
---|
858 | { \ |
---|
859 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:)"; \ |
---|
860 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:)"; \ |
---|
861 | } \ |
---|
862 | \ |
---|
863 | template <> \ |
---|
864 | void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,2> >(ostream& oss, const string& className, const string& name) \ |
---|
865 | { \ |
---|
866 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:)"; \ |
---|
867 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:)"; \ |
---|
868 | } \ |
---|
869 | \ |
---|
870 | template <> \ |
---|
871 | void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,2> >(ostream& oss, const string& className, const string& name) \ |
---|
872 | { \ |
---|
873 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:)"; \ |
---|
874 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:)"; \ |
---|
875 | } \ |
---|
876 | \ |
---|
877 | template <> \ |
---|
878 | void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,3> >(ostream& oss, const string& className, const string& name) \ |
---|
879 | { \ |
---|
880 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:)"; \ |
---|
881 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:)"; \ |
---|
882 | } \ |
---|
883 | \ |
---|
884 | template <> \ |
---|
885 | void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,3> >(ostream& oss, const string& className, const string& name) \ |
---|
886 | { \ |
---|
887 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:)"; \ |
---|
888 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:)"; \ |
---|
889 | } |
---|
890 | |
---|
891 | macro(bool) |
---|
892 | macro(double) |
---|
893 | macro(int) |
---|
894 | |
---|
895 | #undef macro |
---|
896 | |
---|
897 | #define macro(T) \ |
---|
898 | template <> \ |
---|
899 | void CInterface::AttributeFortranInterfaceBody< CArray<T,1> >(ostream& oss, const string& className, const string& name) \ |
---|
900 | { \ |
---|
901 | string name_tmp=name+"__tmp"; \ |
---|
902 | \ |
---|
903 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
904 | if (!matchingTypeCFortran<T>()) \ |
---|
905 | { \ |
---|
906 | oss << " ALLOCATE(" << name_tmp << "(size(" << name << "_,1)))" << iendl; \ |
---|
907 | oss << " " << name_tmp << " = " << name << "_" << iendl; \ |
---|
908 | oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", size(" << name << "_,1))" << iendl; \ |
---|
909 | } \ |
---|
910 | else oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, size(" << name << "_,1))" << iendl; \ |
---|
911 | oss << "ENDIF"; \ |
---|
912 | } \ |
---|
913 | \ |
---|
914 | template <> \ |
---|
915 | void CInterface::AttributeFortranInterfaceBody< CArray<T,2> >(ostream& oss, const string& className, const string& name) \ |
---|
916 | { \ |
---|
917 | string name_tmp=name+"__tmp"; \ |
---|
918 | \ |
---|
919 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
920 | if (!matchingTypeCFortran<T>()) \ |
---|
921 | { \ |
---|
922 | oss << " ALLOCATE(" << name_tmp << "(size(" << name << "_,1), size(" << name << "_,2)))" << iendl; \ |
---|
923 | oss << " " << name_tmp << " = " << name << "_" << iendl; \ |
---|
924 | oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", size(" << name << "_,1), size(" << name << "_,2))" << iendl; \ |
---|
925 | } \ |
---|
926 | else oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, size(" << name << "_,1), size(" << name << "_,2))" << iendl; \ |
---|
927 | oss << "ENDIF"; \ |
---|
928 | } \ |
---|
929 | \ |
---|
930 | template <> \ |
---|
931 | void CInterface::AttributeFortranInterfaceBody< CArray<T,3> >(ostream& oss, const string& className, const string& name) \ |
---|
932 | { \ |
---|
933 | string name_tmp=name+"__tmp"; \ |
---|
934 | \ |
---|
935 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
936 | if (!matchingTypeCFortran<T>()) \ |
---|
937 | { \ |
---|
938 | oss << " ALLOCATE(" << name_tmp << "(size(" << name << "_,1), size(" << name << "_,2), size(" << name << "_,3)))" << iendl; \ |
---|
939 | oss << " " << name_tmp << " = " << name << "_" << iendl; \ |
---|
940 | oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", size(" << name << "_,1), size(" << name << "_,2), size(" << name << "_,3))" << iendl; \ |
---|
941 | } \ |
---|
942 | else oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, size(" << name << "_,1), size(" << name << "_,2), size(" << name << "_,3))" << iendl; \ |
---|
943 | oss << "ENDIF"; \ |
---|
944 | } |
---|
945 | |
---|
946 | macro(bool) |
---|
947 | macro(double) |
---|
948 | macro(int) |
---|
949 | |
---|
950 | #undef macro |
---|
951 | |
---|
952 | #define macro(T) \ |
---|
953 | template <> \ |
---|
954 | void CInterface::AttributeFortranInterfaceGetBody< CArray<T,1> >(ostream& oss, const string& className, const string& name) \ |
---|
955 | { \ |
---|
956 | string name_tmp=name+"__tmp"; \ |
---|
957 | \ |
---|
958 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
959 | if (!matchingTypeCFortran<T>()) \ |
---|
960 | { \ |
---|
961 | oss << " ALLOCATE(" << name_tmp << "(size(" << name << "_,1)))" << iendl; \ |
---|
962 | oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", size(" << name << "_,1))" << iendl; \ |
---|
963 | oss << " " << name << "_ = " << name_tmp << iendl; \ |
---|
964 | } \ |
---|
965 | else oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, size(" << name << "_,1))" << iendl; \ |
---|
966 | oss << "ENDIF"; \ |
---|
967 | } \ |
---|
968 | \ |
---|
969 | template <> \ |
---|
970 | void CInterface::AttributeFortranInterfaceGetBody< CArray<T,2> >(ostream& oss, const string& className, const string& name) \ |
---|
971 | { \ |
---|
972 | string name_tmp=name+"__tmp"; \ |
---|
973 | \ |
---|
974 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
975 | if (!matchingTypeCFortran<T>()) \ |
---|
976 | { \ |
---|
977 | oss << " ALLOCATE(" << name_tmp << "(size(" << name << "_,1), size(" << name << "_,2)))" << iendl; \ |
---|
978 | oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", size(" << name << "_,1), size(" << name << "_,2))" << iendl; \ |
---|
979 | oss << " " << name << "_ = " << name_tmp << iendl; \ |
---|
980 | } \ |
---|
981 | else oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, size(" << name << "_,1), size(" << name << "_,2))" << iendl; \ |
---|
982 | oss << "ENDIF"; \ |
---|
983 | } \ |
---|
984 | \ |
---|
985 | template <> \ |
---|
986 | void CInterface::AttributeFortranInterfaceGetBody< CArray<T,3> >(ostream& oss, const string& className, const string& name) \ |
---|
987 | { \ |
---|
988 | string name_tmp=name+"__tmp"; \ |
---|
989 | \ |
---|
990 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
991 | if (!matchingTypeCFortran<T>()) \ |
---|
992 | { \ |
---|
993 | oss << " ALLOCATE(" << name_tmp << "(size(" << name << "_,1), size(" << name << "_,2), size(" << name << "_,3)))" << iendl; \ |
---|
994 | oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", size(" << name << "_,1), size(" << name << "_,2), size(" << name << "_,3))" << iendl; \ |
---|
995 | oss << " " << name << "_ = " << name_tmp << iendl; \ |
---|
996 | } \ |
---|
997 | else oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, size(" << name << "_,1), size(" << name << "_,2), size(" << name << "_,3))" << iendl; \ |
---|
998 | oss << "ENDIF"; \ |
---|
999 | } |
---|
1000 | |
---|
1001 | macro(bool) |
---|
1002 | macro(double) |
---|
1003 | macro(int) |
---|
1004 | |
---|
1005 | #undef macro |
---|
1006 | } |
---|
1007 | #endif |
---|