source: XIOS/branchs/xios-2.0/src/generate_interface_impl.hpp @ 1627

Last change on this file since 1627 was 1050, checked in by ymipsl, 7 years ago
  • Add label attribute for axis
  • if label attribute is present, then only only string label for each level will be output in netcdf file, ie value and bounds will not be output.

YM

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
File size: 64.8 KB
Line 
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
12namespace 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
543macro(bool)
544macro(double)
545macro(int)
546
547#undef macro
548
549#define macro(N,EXTENT)\
550  template <>\
551  void CInterface::AttributeCInterface<CArray<StdString,N> >(ostream& oss, const string& className, const string& name)\
552  { \
553    oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << "char* " << name <<", int str_len, int* str_size, int* extent)" << iendl; \
554    oss << "{" << iendl; \
555    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
556    oss << "  "<<className<<"_hdl->"<<name<<".resize(shape("<<EXTENT<<"));"<<iendl;\
557    oss << "  Array<StdString,"<<#N<<">::iterator it, itb="<<className<<"_hdl->"<<name<<".begin(), ite="<<className<<"_hdl->"<<name<<".end() ;"<<iendl ;\
558    oss << "  int i, n ;"<< iendl; \
559    oss << "  for(it=itb, i=0, n=0 ; it!=ite ; ++it,n+=str_len,++i) *it=StdString(&"<<name<<"[n],str_size[i]) ;"<<iendl ;\
560    oss << "  CTimer::get(\"XIOS\").suspend();" << iendl; \
561    oss << "}" << std::endl; \
562    oss << iendl; \
563    oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << "char* " << name << ", int str_size, int* extent)" << iendl; \
564    oss << "{" << iendl; \
565    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
566    oss << "  Array<StdString,"<<#N<<">::const_iterator it, itb="<<className<<"_hdl->"<<name<<".getInheritedValue().begin(), ite="<<className<<"_hdl->"<<name<<".getInheritedValue().end() ;" << iendl; \
567    oss << "  int n ;"<< iendl; \
568    oss << "  for(it=itb, n=0 ; it!=ite ; ++it, n+=str_size) it->copy(&"<<name<<"[n],it->size()) ; "<< iendl; \
569    oss << "  CTimer::get(\"XIOS\").suspend();" << iendl; \
570    oss << "}" << std::endl; \
571  }
572
573macro(1,"extent[0]")
574macro(2,"extent[0],extent[1]")
575macro(3,"extent[0],extent[1],extent[2]")
576macro(4,"extent[0],extent[1],extent[2],extent[3]")
577macro(5,"extent[0],extent[1],extent[2],extent[3],extent[4]")
578macro(6,"extent[0],extent[1],extent[2],extent[3],extent[4],extent[5]")
579macro(7,"extent[0],extent[1],extent[2],extent[3],extent[4],extent[5],extent[6]")
580#undef macro
581// /////////////////////////////////////////////////
582// //          Fortran 2003 Interface             //
583// /////////////////////////////////////////////////
584
585#define macro(T) \
586  template <> \
587  void CInterface::AttributeFortran2003Interface<CArray<T,1> >(ostream& oss, const string& className, const string& name) \
588  { \
589    string fortranType=getStrFortranType<T>(); \
590    string fortranKindC=getStrFortranKindC<T>(); \
591      \
592    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
593    oss << "  USE ISO_C_BINDING" << iendl; \
594    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
595    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
596    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
597    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \
598    oss << iendl; \
599    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
600    oss << "  USE ISO_C_BINDING" << iendl; \
601    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
602    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
603    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
604    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \
605  } \
606 \
607  template <> \
608  void CInterface::AttributeFortran2003Interface<CArray<T,2> >(ostream& oss, const string& className, const string& name) \
609  { \
610    string fortranType=getStrFortranType<T>(); \
611    string fortranKindC=getStrFortranKindC<T>(); \
612      \
613    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
614    oss << "  USE ISO_C_BINDING" << iendl; \
615    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
616    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
617    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
618    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \
619    oss << iendl; \
620    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
621    oss << "  USE ISO_C_BINDING" << iendl; \
622    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
623    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
624    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
625    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \
626  } \
627 \
628  template <> \
629  void CInterface::AttributeFortran2003Interface<CArray<T,3> >(ostream& oss, const string& className, const string& name) \
630  { \
631    string fortranType=getStrFortranType<T>(); \
632    string fortranKindC=getStrFortranKindC<T>(); \
633      \
634    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
635    oss << "  USE ISO_C_BINDING" << iendl; \
636    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
637    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
638    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
639    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \
640    oss << iendl; \
641    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
642    oss << "  USE ISO_C_BINDING" << iendl; \
643    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
644    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
645    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
646    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \
647  }  \
648 \
649  template <> \
650  void CInterface::AttributeFortran2003Interface<CArray<T,4> >(ostream& oss, const string& className, const string& name) \
651  { \
652    string fortranType=getStrFortranType<T>(); \
653    string fortranKindC=getStrFortranKindC<T>(); \
654      \
655    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
656    oss << "  USE ISO_C_BINDING" << iendl; \
657    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
658    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
659    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
660    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \
661    oss << iendl; \
662    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
663    oss << "  USE ISO_C_BINDING" << iendl; \
664    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
665    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
666    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
667    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \
668  }\
669 \
670  template <> \
671  void CInterface::AttributeFortran2003Interface<CArray<T,5> >(ostream& oss, const string& className, const string& name) \
672  { \
673    string fortranType=getStrFortranType<T>(); \
674    string fortranKindC=getStrFortranKindC<T>(); \
675      \
676    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
677    oss << "  USE ISO_C_BINDING" << iendl; \
678    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
679    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
680    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
681    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \
682    oss << iendl; \
683    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
684    oss << "  USE ISO_C_BINDING" << iendl; \
685    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
686    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
687    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
688    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \
689  }\
690 \
691  template <> \
692  void CInterface::AttributeFortran2003Interface<CArray<T,6> >(ostream& oss, const string& className, const string& name) \
693  { \
694    string fortranType=getStrFortranType<T>(); \
695    string fortranKindC=getStrFortranKindC<T>(); \
696      \
697    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
698    oss << "  USE ISO_C_BINDING" << iendl; \
699    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
700    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
701    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
702    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \
703    oss << iendl; \
704    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
705    oss << "  USE ISO_C_BINDING" << iendl; \
706    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
707    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
708    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
709    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \
710  }\
711 \
712  template <> \
713  void CInterface::AttributeFortran2003Interface<CArray<T,7> >(ostream& oss, const string& className, const string& name) \
714  { \
715    string fortranType=getStrFortranType<T>(); \
716    string fortranKindC=getStrFortranKindC<T>(); \
717      \
718    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
719    oss << "  USE ISO_C_BINDING" << iendl; \
720    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
721    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
722    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
723    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \
724    oss << iendl; \
725    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
726    oss << "  USE ISO_C_BINDING" << iendl; \
727    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
728    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
729    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
730    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \
731  }
732
733  macro(bool)
734  macro(double)
735  macro(int)
736
737  #undef macro
738
739#define macro(T)\
740  template <>\
741  void CInterface::AttributeFortran2003Interface<CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\
742  {\
743    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", str_len, str_size, extent) BIND(C)" << iendl; \
744    oss << "  USE ISO_C_BINDING" << iendl; \
745    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
746    oss << "  CHARACTER (KIND=C_CHAR), DIMENSION(*)    :: " << name << iendl; \
747    oss << "  INTEGER (kind = C_INT), VALUE            :: str_len" << iendl; \
748    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: str_size" << iendl; \
749    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
750    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \
751    oss << iendl; \
752    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", str_size, extent) BIND(C)" << iendl; \
753    oss << "  USE ISO_C_BINDING" << iendl; \
754    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
755    oss << "  CHARACTER (KIND=C_CHAR), DIMENSION(*)    :: " << name << iendl; \
756    oss << "  INTEGER (kind = C_INT), VALUE            :: str_size" << iendl; \
757    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
758    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \
759  }
760  macro(1)
761  macro(2)
762  macro(3)
763  macro(4)
764  macro(5)
765  macro(6)
766  macro(7)
767
768#undef macro
769
770#define macro(T) \
771  template <> \
772  void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,1> >(ostream& oss, const string& className, const string& name) \
773  { \
774    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:)"; \
775    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:)"; \
776  } \
777  template <> \
778  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,1> >(ostream& oss, const string& className, const string& name) \
779  { \
780    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:)"; \
781    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:)"; \
782  } \
783 \
784  template <> \
785  void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,2> >(ostream& oss, const string& className, const string& name) \
786  { \
787    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:)"; \
788    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:)"; \
789  } \
790 \
791  template <> \
792  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,2> >(ostream& oss, const string& className, const string& name) \
793  { \
794    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:)"; \
795    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:)"; \
796  } \
797 \
798  template <> \
799  void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,3> >(ostream& oss, const string& className, const string& name) \
800  { \
801    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:)"; \
802    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:)"; \
803  } \
804 \
805  template <> \
806  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,3> >(ostream& oss, const string& className, const string& name) \
807  { \
808    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:)"; \
809    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:)"; \
810  }\
811 \
812  template <> \
813  void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,4> >(ostream& oss, const string& className, const string& name) \
814  { \
815    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:,:)"; \
816    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:)"; \
817  } \
818 \
819  template <> \
820  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,4> >(ostream& oss, const string& className, const string& name) \
821  { \
822    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:,:)"; \
823    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:)"; \
824  }\
825 \
826  template <> \
827  void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,5> >(ostream& oss, const string& className, const string& name) \
828  { \
829    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:,:,:)"; \
830    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:)"; \
831  } \
832 \
833  template <> \
834  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,5> >(ostream& oss, const string& className, const string& name) \
835  { \
836    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:,:,:)"; \
837    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:)"; \
838  }\
839 \
840  template <> \
841  void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,6> >(ostream& oss, const string& className, const string& name) \
842  { \
843    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:,:,:,:)"; \
844    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:,:)"; \
845  } \
846 \
847  template <> \
848  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,6> >(ostream& oss, const string& className, const string& name) \
849  { \
850    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:,:,:,:)"; \
851    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:,:)"; \
852  }\
853 \
854  template <> \
855  void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,7> >(ostream& oss, const string& className, const string& name) \
856  { \
857    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:,:,:,:,:)"; \
858    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:,:,:)"; \
859  } \
860 \
861  template <> \
862  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,7> >(ostream& oss, const string& className, const string& name) \
863  { \
864    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:,:,:,:,:)"; \
865    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:,:,:)"; \
866  }
867
868  macro(bool)
869  macro(double)
870  macro(int)
871
872#undef macro
873
874#define macro(T,EXTENT)\
875  template <> \
876  void CInterface::AttributeFortranInterfaceDeclaration<CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\
877  {\
878    oss << "CHARACTER(len=*) , OPTIONAL, INTENT(IN) :: " << name << "("<<EXTENT<<")"; \
879  }\
880\
881  template <>\
882  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\
883  {\
884    oss << "CHARACTER(len=*) , OPTIONAL, INTENT(OUT) :: " << name << "("<<EXTENT<<")"; \
885  }
886  macro(1,":")
887  macro(2,":,:")
888  macro(3,":,:,:")
889  macro(4,":,:,:,:")
890  macro(5,":,:,:,:,:")
891  macro(6,":,:,:,:,:,:")
892  macro(7,":,:,:,:,:,:,:")
893
894#undef macro
895
896
897
898
899 
900
901#define macro(T) \
902  template <>  \
903  void CInterface::AttributeFortranInterfaceBody< CArray<T,1> >(ostream& oss, const string& className, const string& name) \
904  {  \
905    string name_tmp=name+"__tmp"; \
906      \
907    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
908    if (!matchingTypeCFortran<T>())  \
909    { \
910      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1)))" << iendl; \
911      oss << "  " << name_tmp << " = " << name << "_" << iendl; \
912      oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
913      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
914    } \
915    else { oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
916           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
917    oss << "ENDIF"; \
918  } \
919 \
920  template <>  \
921  void CInterface::AttributeFortranInterfaceBody< CArray<T,2> >(ostream& oss, const string& className, const string& name) \
922  {  \
923    string name_tmp=name+"__tmp"; \
924      \
925    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
926    if (!matchingTypeCFortran<T>())  \
927    { \
928      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2)))" << iendl; \
929      oss << "  " << name_tmp << " = " << name << "_" << iendl; \
930      oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
931      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
932    } \
933    else { oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
934           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
935    oss << "ENDIF"; \
936  } \
937  \
938  template <>  \
939  void CInterface::AttributeFortranInterfaceBody< CArray<T,3> >(ostream& oss, const string& className, const string& name) \
940  {  \
941    string name_tmp=name+"__tmp"; \
942      \
943    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
944    if (!matchingTypeCFortran<T>())  \
945    { \
946      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3)))" << iendl; \
947      oss << "  " << name_tmp << " = " << name << "_" << iendl; \
948      oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
949      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
950    } \
951    else { oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
952           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
953    oss << "ENDIF"; \
954  }\
955  \
956  template <>  \
957  void CInterface::AttributeFortranInterfaceBody< CArray<T,4> >(ostream& oss, const string& className, const string& name) \
958  {  \
959    string name_tmp=name+"__tmp"; \
960      \
961    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
962    if (!matchingTypeCFortran<T>())  \
963    { \
964      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \
965      oss << " SIZE(" << name << "_,4)))" << iendl; \
966      oss << "  " << name_tmp << " = " << name << "_" << iendl; \
967      oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
968      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
969    } \
970    else { oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
971           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
972    oss << "ENDIF"; \
973  }\
974  \
975  template <>  \
976  void CInterface::AttributeFortranInterfaceBody< CArray<T,5> >(ostream& oss, const string& className, const string& name) \
977  {  \
978    string name_tmp=name+"__tmp"; \
979      \
980    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
981    if (!matchingTypeCFortran<T>())  \
982    { \
983      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \
984      oss << " SIZE(" << name << "_,4), SIZE(" << name << "_,5)))" << iendl; \
985      oss << "  " << name_tmp << " = " << name << "_" << iendl; \
986      oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
987      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
988    } \
989    else { oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
990           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
991    oss << "ENDIF"; \
992  }\
993  \
994  template <>  \
995  void CInterface::AttributeFortranInterfaceBody< CArray<T,6> >(ostream& oss, const string& className, const string& name) \
996  {  \
997    string name_tmp=name+"__tmp"; \
998      \
999    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1000    if (!matchingTypeCFortran<T>())  \
1001    { \
1002      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \
1003      oss << " SIZE(" << name << "_,4), SIZE(" << name << "_,5), SIZE(" << name << "_,6)))" << iendl; \
1004      oss << "  " << name_tmp << " = " << name << "_" << iendl; \
1005      oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
1006      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1007    } \
1008    else { oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
1009           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1010    oss << "ENDIF"; \
1011  }\
1012  \
1013  template <>  \
1014  void CInterface::AttributeFortranInterfaceBody< CArray<T,7> >(ostream& oss, const string& className, const string& name) \
1015  {  \
1016    string name_tmp=name+"__tmp"; \
1017      \
1018    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1019    if (!matchingTypeCFortran<T>())  \
1020    { \
1021      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \
1022      oss << " SIZE(" << name << "_,4), SIZE(" << name << "_,5), SIZE(" << name << "_,6), &" << iendl; \
1023      oss << " SIZE(" << name << "_,7)))" << iendl; \
1024      oss << "  " << name_tmp << " = " << name << "_" << iendl; \
1025      oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
1026      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1027    } \
1028    else { oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
1029           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1030    oss << "ENDIF"; \
1031  }
1032
1033  macro(bool)
1034  macro(double)
1035  macro(int)
1036
1037#undef macro
1038
1039#define macro(T)\
1040  template <>\
1041  void CInterface::AttributeFortranInterfaceBody< CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\
1042  {\
1043     oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1044     oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
1045     oss << "(" << className << "_hdl%daddr, " << name <<"_, LEN("<<name<<"_), LEN_TRIM("<<name<< "_), SHAPE(" << name << "_))" << iendl; \
1046     oss << "ENDIF"; \
1047  }
1048
1049  macro(1)
1050  macro(2)
1051#undef macro
1052
1053#define macro(T) \
1054  template <>  \
1055  void CInterface::AttributeFortranInterfaceGetBody< CArray<T,1> >(ostream& oss, const string& className, const string& name) \
1056  {  \
1057    string name_tmp=name+"__tmp"; \
1058      \
1059    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1060    if (!matchingTypeCFortran<T>())  \
1061    { \
1062      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1)))" << iendl; \
1063      oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1064      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1065      oss << "  " << name << "_ = " << name_tmp << iendl; \
1066    } \
1067    else { oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1068           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1069    oss << "ENDIF"; \
1070  } \
1071 \
1072  template <>  \
1073  void CInterface::AttributeFortranInterfaceGetBody< CArray<T,2> >(ostream& oss, const string& className, const string& name) \
1074  {  \
1075    string name_tmp=name+"__tmp"; \
1076      \
1077    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1078    if (!matchingTypeCFortran<T>())  \
1079    { \
1080      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2)))" << iendl; \
1081      oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1082      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1083      oss << "  " << name << "_ = " << name_tmp << iendl; \
1084    } \
1085    else { oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1086           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1087    oss << "ENDIF"; \
1088  } \
1089 \
1090  template <>  \
1091  void CInterface::AttributeFortranInterfaceGetBody< CArray<T,3> >(ostream& oss, const string& className, const string& name) \
1092  {  \
1093    string name_tmp=name+"__tmp"; \
1094      \
1095    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1096    if (!matchingTypeCFortran<T>())  \
1097    { \
1098      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3)))" << iendl; \
1099      oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1100      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1101      oss << "  " << name << "_ = " << name_tmp << iendl; \
1102      } \
1103    else { oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1104           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1105    oss << "ENDIF"; \
1106  } \
1107 \
1108  template <>  \
1109  void CInterface::AttributeFortranInterfaceGetBody< CArray<T,4> >(ostream& oss, const string& className, const string& name) \
1110  {  \
1111    string name_tmp=name+"__tmp"; \
1112      \
1113    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1114    if (!matchingTypeCFortran<T>())  \
1115    { \
1116      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \
1117      oss << " SIZE(" << name << "_,4)))" << iendl; \
1118      oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1119      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1120      oss << "  " << name << "_ = " << name_tmp << iendl; \
1121      } \
1122    else { oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1123           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; }\
1124    oss << "ENDIF"; \
1125  } \
1126 \
1127  template <>  \
1128  void CInterface::AttributeFortranInterfaceGetBody< CArray<T,5> >(ostream& oss, const string& className, const string& name) \
1129  {  \
1130    string name_tmp=name+"__tmp"; \
1131      \
1132    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1133    if (!matchingTypeCFortran<T>())  \
1134    { \
1135      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \
1136      oss << " SIZE(" << name << "_,4), SIZE(" << name << "_,5)))" << iendl; \
1137      oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1138      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1139      oss << "  " << name << "_ = " << name_tmp << iendl; \
1140      } \
1141    else { oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1142           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1143    oss << "ENDIF"; \
1144  }\
1145 \
1146  template <>  \
1147  void CInterface::AttributeFortranInterfaceGetBody< CArray<T,6> >(ostream& oss, const string& className, const string& name) \
1148  {  \
1149    string name_tmp=name+"__tmp"; \
1150      \
1151    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1152    if (!matchingTypeCFortran<T>())  \
1153    { \
1154      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \
1155      oss << " SIZE(" << name << "_,4), SIZE(" << name << "_,5), SIZE(" << name << "_,6)))" << iendl; \
1156      oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1157      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1158      oss << "  " << name << "_ = " << name_tmp << iendl; \
1159      } \
1160    else { oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1161           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1162    oss << "ENDIF"; \
1163  } \
1164 \
1165  template <>  \
1166  void CInterface::AttributeFortranInterfaceGetBody< CArray<T,7> >(ostream& oss, const string& className, const string& name) \
1167  {  \
1168    string name_tmp=name+"__tmp"; \
1169      \
1170    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1171    if (!matchingTypeCFortran<T>())  \
1172    { \
1173      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \
1174      oss << " SIZE(" << name << "_,4), SIZE(" << name << "_,5), SIZE(" << name << "_,6), &" << iendl; \
1175      oss << " SIZE(" << name << "_,7)))" << iendl; \
1176      oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1177      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1178      oss << "  " << name << "_ = " << name_tmp << iendl; \
1179      } \
1180    else { oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1181           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1182    oss << "ENDIF"; \
1183  }
1184
1185  macro(bool)
1186  macro(double)
1187  macro(int)
1188
1189#undef macro
1190
1191#define macro(T)\
1192  template <> \
1193  void CInterface::AttributeFortranInterfaceGetBody< CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\
1194  {\
1195    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1196    oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1197    oss << "(" << className << "_hdl%daddr, " << name << "_, LEN("<<name<<"_), SHAPE(" << name << "_))" << iendl; \
1198    oss << "ENDIF"; \
1199  }
1200  macro(1)
1201  macro(2)
1202  macro(3)
1203  macro(4)
1204  macro(5)
1205  macro(6)
1206  macro(7)
1207
1208#undef macro
1209 
1210}
1211#endif
Note: See TracBrowser for help on using the repository browser.