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