source: XIOS/dev/dev_trunk_omp/src/generate_interface_impl.hpp @ 1792

Last change on this file since 1792 was 1792, checked in by yushan, 2 years ago

dev_trunk_omp : update and cleanup of unit tests

  • 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: 65.3 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    int indent = oss.iword(iendl.index);
219    string str = "SUBROUTINE cxios_set_" + className + "_" + name + "(" + className + "_hdl, " + name + ") BIND(C)";
220    if ((str.length() + indent) >132)
221    {
222      oss << str.substr(0,130-indent) ;
223      oss << "&" << endl;
224      oss << "&" << str.substr(130-indent,str.length()) ;
225    }
226    else
227    {
228      oss << str;
229    }
230    oss << iendl;
231    oss << "  USE ISO_C_BINDING" << iendl;
232    oss << "  INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl;
233    oss << "  " << fortranType << " " << fortranKindC << "      , VALUE :: " << name << iendl;
234    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl;
235    oss << iendl;
236    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl;
237    oss << "  USE ISO_C_BINDING" << iendl;
238    oss << "  INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl;
239    oss << "  " << fortranType << " " << fortranKindC << "             :: " << name << iendl;
240    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl;
241  }
242
243  template <>
244  void CInterface::AttributeFortran2003Interface<string>(ostream& oss, const string& className, const string& name)
245  {
246//    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", " << name << "_size) BIND(C)" << iendl;
247    int indent = oss.iword(iendl.index);
248    string str ="SUBROUTINE cxios_set_" + className + "_" + name + "(" + className + "_hdl, " + name + ", " + name + "_size) BIND(C)";
249    if ((str.length() + indent) >132)
250    {
251      oss << str.substr(0,130-indent) ;
252      oss << "&" << endl;
253      oss << "&" << str.substr(130-indent,str.length()) ;
254    }
255    else
256    {
257      oss << str;
258    }
259    oss << iendl;
260    oss << "  USE ISO_C_BINDING" << iendl;
261    oss << "  INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl;
262    oss << "  CHARACTER(kind = C_CHAR)    , DIMENSION(*) :: " << name << iendl;
263    oss << "  INTEGER  (kind = C_INT)     , VALUE        :: " << name << "_size" << iendl;
264    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl;
265    oss << iendl;
266//    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", " << name << "_size) BIND(C)" << iendl;
267    str = "SUBROUTINE cxios_get_" + className + "_" + name + "(" + className + "_hdl, " + name + ", " + name + "_size) BIND(C)";
268    if ((str.length() + indent) >132)
269    {
270      oss << str.substr(0,130-indent) ;
271      oss << "&" << endl;
272      oss << "&" << str.substr(130-indent,str.length()) ;
273    }
274    else
275    {
276      oss << str;
277    }
278    oss << iendl;
279    oss << "  USE ISO_C_BINDING" << iendl;
280    oss << "  INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl;
281    oss << "  CHARACTER(kind = C_CHAR)    , DIMENSION(*) :: " << name << iendl;
282    oss << "  INTEGER  (kind = C_INT)     , VALUE        :: " << name << "_size" << iendl;
283    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl;
284  }
285
286  template <>
287  void CInterface::AttributeFortran2003Interface<CDuration>(ostream& oss, const string& className, const string& name)
288  {
289//    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl;
290    string str = "SUBROUTINE cxios_set_" + className + "_" + name + "(" + className + "_hdl, " + name + ") BIND(C)";
291    int indent = oss.iword(iendl.index);
292    if ((str.length() + indent) >132)
293    {
294      oss << str.substr(0,130-indent) ;
295      oss << "&" << endl;
296      oss << "&" << str.substr(130-indent,str.length()) ;
297    }
298    else
299    {
300      oss << str;
301    }
302    oss << iendl;
303    oss << "  USE ISO_C_BINDING" << iendl;
304    oss << "  USE IDURATION" << iendl;
305    oss << "  INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl;
306    oss << "  TYPE(txios(duration)), VALUE :: " << name << iendl;
307    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl;
308    oss << iendl;
309    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl;
310    oss << "  USE ISO_C_BINDING" << iendl;
311    oss << "  USE IDURATION" << iendl;
312    oss << "  INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl;
313    oss << "  TYPE(txios(duration)) :: " << name << iendl;
314    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl;
315  }
316
317  template <class T>
318  void CInterface::AttributeFortranInterfaceDeclaration(ostream& oss, const string& className, const string& name)
319  {
320    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name;
321    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " :: " << name << "_tmp";
322  }
323
324  template <class T>
325  void CInterface::AttributeFortranInterfaceGetDeclaration(ostream& oss, const string& className, const string& name)
326  {
327    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name;
328    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " :: " << name << "_tmp";
329  }
330
331  void CInterface::AttributeFortranInterfaceIsDefinedDeclaration(ostream& oss, const string& className, const string& name)
332  {
333    oss << "LOGICAL, OPTIONAL, INTENT(OUT) :: " << name << iendl;
334    oss << "LOGICAL(KIND=C_BOOL) :: " << name << "_tmp";
335  }
336
337  template <>
338  void CInterface::AttributeFortranInterfaceDeclaration<string>(ostream& oss, const string& className, const string& name)
339  {
340    oss << "CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: " << name;
341  }
342
343  template <>
344  void CInterface::AttributeFortranInterfaceGetDeclaration<string>(ostream& oss, const string& className, const string& name)
345  {
346    oss << "CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: " << name;
347  }
348
349  template <class T>
350  void CInterface::AttributeFortranInterfaceBody(ostream& oss, const string& className, const string& name)
351  {
352    string name_tmp=name+"__tmp";
353
354    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl;
355    if (!matchingTypeCFortran<T>())
356    {
357      oss << "  " << name_tmp << " = " << name << "_" << iendl;
358      oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl;
359      oss << "(" << className << "_hdl%daddr, " << name_tmp << ")" << iendl;
360    }
361    else { oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl;
362           oss << "(" << className << "_hdl%daddr, " << name << "_)" << iendl; }
363    oss << "ENDIF";
364  }
365
366  template <class T>
367  void CInterface::AttributeFortranInterfaceGetBody(ostream& oss, const string& className, const string& name)
368  {
369    string name_tmp=name+"__tmp";
370
371    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl;
372    if (!matchingTypeCFortran<T>())
373    {
374      oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl;
375      oss << "(" << className << "_hdl%daddr, " << name_tmp << ")" << iendl;
376      oss << "  " << name << "_ = " << name_tmp << iendl;
377    }
378    else { oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl;
379           oss << "(" << className << "_hdl%daddr, " << name << "_)" << iendl; }
380    oss << "ENDIF";
381  }
382
383  void CInterface::AttributeFortranInterfaceIsDefinedBody(ostream& oss, const string& className, const string& name)
384  {
385    string name_tmp=name+"__tmp";
386
387    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl;
388    oss << "  " << name << "__tmp = cxios_is_defined_" << className << "_" << name << " &" << iendl;
389    oss << "(" << className << "_hdl%daddr)" << iendl;
390    oss << "  " << name << "_ = " << name_tmp << iendl;
391    oss << "ENDIF";
392  }
393
394  template <>
395  void CInterface::AttributeFortranInterfaceBody<string>(ostream& oss, const string& className, const string& name)
396  {
397    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl;
398    oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl;
399    oss << "(" << className << "_hdl%daddr, " << name << "_, len(" << name << "_))" << iendl;
400    oss << "ENDIF";
401  }
402
403  template <>
404  void CInterface::AttributeFortranInterfaceGetBody<string>(ostream& oss, const string& className, const string& name)
405  {
406    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl;
407    oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl;
408    oss << "(" << className << "_hdl%daddr, " << name << "_, len(" << name << "_))" << iendl;
409    oss << "ENDIF";
410  }
411
412// declaration for CArray
413
414#define macro(T) \
415  template <> \
416  void CInterface::AttributeCInterface<CArray<T,1> >(ostream& oss, const string& className, const string& name) \
417  { \
418    string typeName=getStrType<T>(); \
419\
420    oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
421    oss << "{" << iendl; \
422    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
423    oss << "  CArray<" << typeName << ",1> tmp(" << name << ", shape(extent[0]), neverDeleteData);" << iendl; \
424    oss << "  " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \
425    /*oss << "  " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \
426    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
427    oss << "}" << std::endl; \
428    oss << iendl; \
429    oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
430    oss << "{" << iendl; \
431    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
432    oss << "  CArray<" << typeName << ",1> tmp(" << name << ", shape(extent[0]), neverDeleteData);" << iendl; \
433    oss << "  tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \
434    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
435    oss << "}" << std::endl; \
436  } \
437\
438  template <> \
439  void CInterface::AttributeCInterface<CArray<T,2> >(ostream& oss, const string& className, const string& name) \
440  { \
441    string typeName=getStrType<T>(); \
442\
443    oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
444    oss << "{" << iendl; \
445    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
446    oss << "  CArray<" << typeName << ",2> tmp(" << name << ", shape(extent[0], extent[1]), neverDeleteData);" << iendl; \
447    oss << "  " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \
448    /*oss << "  " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \
449    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
450    oss << "}" << std::endl; \
451    oss << iendl; \
452    oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
453    oss << "{" << iendl; \
454    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
455    oss << "  CArray<" << typeName << ",2> tmp(" << name << ", shape(extent[0], extent[1]), neverDeleteData);" << iendl; \
456    oss << "  tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \
457    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
458    oss << "}" << std::endl; \
459  } \
460\
461  template <> \
462  void CInterface::AttributeCInterface<CArray<T,3> >(ostream& oss, const string& className, const string& name) \
463  { \
464    string typeName=getStrType<T>(); \
465\
466    oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
467    oss << "{" << iendl; \
468    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
469    oss << "  CArray<" << typeName << ",3> tmp(" << name << ", shape(extent[0], extent[1], extent[2]), neverDeleteData);" << iendl; \
470    oss << "  " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \
471    /*oss << "  " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \
472    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
473    oss << "}" << std::endl; \
474    oss << iendl; \
475    oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
476    oss << "{" << iendl; \
477    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
478    oss << "  CArray<" << typeName << ",3> tmp(" << name << ", shape(extent[0], extent[1], extent[2]), neverDeleteData);" << iendl; \
479    oss << "  tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \
480    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
481    oss << "}" << std::endl; \
482  } \
483\
484  template <> \
485  void CInterface::AttributeCInterface<CArray<T,4> >(ostream& oss, const string& className, const string& name) \
486  { \
487    string typeName=getStrType<T>(); \
488\
489    oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
490    oss << "{" << iendl; \
491    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
492    oss << "  CArray<" << typeName << ",4> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3]), neverDeleteData);" << iendl; \
493    oss << "  " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \
494    /*oss << "  " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \
495    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
496    oss << "}" << std::endl; \
497    oss << iendl; \
498    oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
499    oss << "{" << iendl; \
500    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
501    oss << "  CArray<" << typeName << ",4> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3]), neverDeleteData);" << iendl; \
502    oss << "  tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \
503    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
504    oss << "}" << std::endl; \
505  } \
506\
507  template <> \
508  void CInterface::AttributeCInterface<CArray<T,5> >(ostream& oss, const string& className, const string& name) \
509  { \
510    string typeName=getStrType<T>(); \
511\
512    oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
513    oss << "{" << iendl; \
514    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
515    oss << "  CArray<" << typeName << ",5> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3], extent[4]), neverDeleteData);" << iendl; \
516    oss << "  " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \
517    /*oss << "  " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \
518    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
519    oss << "}" << std::endl; \
520    oss << iendl; \
521    oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
522    oss << "{" << iendl; \
523    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
524    oss << "  CArray<" << typeName << ",5> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3], extent[4]), neverDeleteData);" << iendl; \
525    oss << "  tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \
526    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
527    oss << "}" << std::endl; \
528  } \
529\
530  template <> \
531  void CInterface::AttributeCInterface<CArray<T,6> >(ostream& oss, const string& className, const string& name) \
532  { \
533    string typeName=getStrType<T>(); \
534\
535    oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
536    oss << "{" << iendl; \
537    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
538    oss << "  CArray<" << typeName << ",6> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3], extent[4], extent[5]), neverDeleteData);" << iendl; \
539    oss << "  " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \
540    /*oss << "  " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \
541    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
542    oss << "}" << std::endl; \
543    oss << iendl; \
544    oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
545    oss << "{" << iendl; \
546    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
547    oss << "  CArray<" << typeName << ",6> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3], extent[4], extent[5]), neverDeleteData);" << iendl; \
548    oss << "  tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \
549    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
550    oss << "}" << std::endl; \
551  }  \
552\
553  template <> \
554  void CInterface::AttributeCInterface<CArray<T,7> >(ostream& oss, const string& className, const string& name) \
555  { \
556    string typeName=getStrType<T>(); \
557\
558    oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
559    oss << "{" << iendl; \
560    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
561    oss << "  CArray<" << typeName << ",7> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3], extent[4], extent[5], extent[6]), neverDeleteData);" << iendl; \
562    oss << "  " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \
563    /*oss << "  " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \
564    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
565    oss << "}" << std::endl; \
566    oss << iendl; \
567    oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
568    oss << "{" << iendl; \
569    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
570    oss << "  CArray<" << typeName << ",7> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3], extent[4], extent[5], extent[6]), neverDeleteData);" << iendl; \
571    oss << "  tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \
572    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
573    oss << "}" << std::endl; \
574  }
575
576macro(bool)
577macro(double)
578macro(int)
579
580#undef macro
581
582#define macro(N,EXTENT)\
583  template <>\
584  void CInterface::AttributeCInterface<CArray<StdString,N> >(ostream& oss, const string& className, const string& name)\
585  { \
586    oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << "char* " << name <<", int str_len, int* str_size, int* extent)" << iendl; \
587    oss << "{" << iendl; \
588    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
589    oss << "  "<<className<<"_hdl->"<<name<<".resize(shape("<<EXTENT<<"));"<<iendl;\
590    oss << "  Array<StdString,"<<#N<<">::iterator it, itb="<<className<<"_hdl->"<<name<<".begin(), ite="<<className<<"_hdl->"<<name<<".end() ;"<<iendl ;\
591    oss << "  int i, n ;"<< iendl; \
592    oss << "  for(it=itb, i=0, n=0 ; it!=ite ; ++it,n+=str_len,++i) *it=StdString(&"<<name<<"[n],str_size[i]) ;"<<iendl ;\
593    oss << "  CTimer::get(\"XIOS\").suspend();" << iendl; \
594    oss << "}" << std::endl; \
595    oss << iendl; \
596    oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << "char* " << name << ", int str_size, int* extent)" << iendl; \
597    oss << "{" << iendl; \
598    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
599    oss << "  Array<StdString,"<<#N<<">::const_iterator it, itb="<<className<<"_hdl->"<<name<<".getInheritedValue().begin(), ite="<<className<<"_hdl->"<<name<<".getInheritedValue().end() ;" << iendl; \
600    oss << "  int n ;"<< iendl; \
601    oss << "  for(it=itb, n=0 ; it!=ite ; ++it, n+=str_size) it->copy(&"<<name<<"[n],it->size()) ; "<< iendl; \
602    oss << "  CTimer::get(\"XIOS\").suspend();" << iendl; \
603    oss << "}" << std::endl; \
604  }
605
606macro(1,"extent[0]")
607macro(2,"extent[0],extent[1]")
608macro(3,"extent[0],extent[1],extent[2]")
609macro(4,"extent[0],extent[1],extent[2],extent[3]")
610macro(5,"extent[0],extent[1],extent[2],extent[3],extent[4]")
611macro(6,"extent[0],extent[1],extent[2],extent[3],extent[4],extent[5]")
612macro(7,"extent[0],extent[1],extent[2],extent[3],extent[4],extent[5],extent[6]")
613#undef macro
614// /////////////////////////////////////////////////
615// //          Fortran 2003 Interface             //
616// /////////////////////////////////////////////////
617
618#define macro(T) \
619  template <> \
620  void CInterface::AttributeFortran2003Interface<CArray<T,1> >(ostream& oss, const string& className, const string& name) \
621  { \
622    string fortranType=getStrFortranType<T>(); \
623    string fortranKindC=getStrFortranKindC<T>(); \
624      \
625    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
626    oss << "  USE ISO_C_BINDING" << iendl; \
627    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
628    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
629    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
630    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \
631    oss << iendl; \
632    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
633    oss << "  USE ISO_C_BINDING" << iendl; \
634    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
635    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
636    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
637    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \
638  } \
639 \
640  template <> \
641  void CInterface::AttributeFortran2003Interface<CArray<T,2> >(ostream& oss, const string& className, const string& name) \
642  { \
643    string fortranType=getStrFortranType<T>(); \
644    string fortranKindC=getStrFortranKindC<T>(); \
645      \
646    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
647    oss << "  USE ISO_C_BINDING" << iendl; \
648    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
649    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
650    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
651    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \
652    oss << iendl; \
653    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
654    oss << "  USE ISO_C_BINDING" << iendl; \
655    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
656    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
657    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
658    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \
659  } \
660 \
661  template <> \
662  void CInterface::AttributeFortran2003Interface<CArray<T,3> >(ostream& oss, const string& className, const string& name) \
663  { \
664    string fortranType=getStrFortranType<T>(); \
665    string fortranKindC=getStrFortranKindC<T>(); \
666      \
667    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
668    oss << "  USE ISO_C_BINDING" << iendl; \
669    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
670    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
671    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
672    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \
673    oss << iendl; \
674    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
675    oss << "  USE ISO_C_BINDING" << iendl; \
676    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
677    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
678    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
679    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \
680  }  \
681 \
682  template <> \
683  void CInterface::AttributeFortran2003Interface<CArray<T,4> >(ostream& oss, const string& className, const string& name) \
684  { \
685    string fortranType=getStrFortranType<T>(); \
686    string fortranKindC=getStrFortranKindC<T>(); \
687      \
688    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
689    oss << "  USE ISO_C_BINDING" << iendl; \
690    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
691    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
692    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
693    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \
694    oss << iendl; \
695    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
696    oss << "  USE ISO_C_BINDING" << iendl; \
697    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
698    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
699    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
700    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \
701  }\
702 \
703  template <> \
704  void CInterface::AttributeFortran2003Interface<CArray<T,5> >(ostream& oss, const string& className, const string& name) \
705  { \
706    string fortranType=getStrFortranType<T>(); \
707    string fortranKindC=getStrFortranKindC<T>(); \
708      \
709    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
710    oss << "  USE ISO_C_BINDING" << iendl; \
711    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
712    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
713    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
714    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \
715    oss << iendl; \
716    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
717    oss << "  USE ISO_C_BINDING" << iendl; \
718    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
719    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
720    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
721    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \
722  }\
723 \
724  template <> \
725  void CInterface::AttributeFortran2003Interface<CArray<T,6> >(ostream& oss, const string& className, const string& name) \
726  { \
727    string fortranType=getStrFortranType<T>(); \
728    string fortranKindC=getStrFortranKindC<T>(); \
729      \
730    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
731    oss << "  USE ISO_C_BINDING" << iendl; \
732    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
733    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
734    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
735    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \
736    oss << iendl; \
737    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
738    oss << "  USE ISO_C_BINDING" << iendl; \
739    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
740    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
741    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
742    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \
743  }\
744 \
745  template <> \
746  void CInterface::AttributeFortran2003Interface<CArray<T,7> >(ostream& oss, const string& className, const string& name) \
747  { \
748    string fortranType=getStrFortranType<T>(); \
749    string fortranKindC=getStrFortranKindC<T>(); \
750      \
751    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
752    oss << "  USE ISO_C_BINDING" << iendl; \
753    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
754    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
755    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
756    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \
757    oss << iendl; \
758    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
759    oss << "  USE ISO_C_BINDING" << iendl; \
760    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
761    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
762    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
763    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \
764  }
765
766  macro(bool)
767  macro(double)
768  macro(int)
769
770  #undef macro
771
772#define macro(T)\
773  template <>\
774  void CInterface::AttributeFortran2003Interface<CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\
775  {\
776    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", str_len, str_size, extent) BIND(C)" << iendl; \
777    oss << "  USE ISO_C_BINDING" << iendl; \
778    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
779    oss << "  CHARACTER (KIND=C_CHAR), DIMENSION(*)    :: " << name << iendl; \
780    oss << "  INTEGER (kind = C_INT), VALUE            :: str_len" << iendl; \
781    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: str_size" << iendl; \
782    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
783    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \
784    oss << iendl; \
785    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", str_size, extent) BIND(C)" << iendl; \
786    oss << "  USE ISO_C_BINDING" << iendl; \
787    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
788    oss << "  CHARACTER (KIND=C_CHAR), DIMENSION(*)    :: " << name << iendl; \
789    oss << "  INTEGER (kind = C_INT), VALUE            :: str_size" << iendl; \
790    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
791    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \
792  }
793  macro(1)
794  macro(2)
795  macro(3)
796  macro(4)
797  macro(5)
798  macro(6)
799  macro(7)
800
801#undef macro
802
803#define macro(T) \
804  template <> \
805  void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,1> >(ostream& oss, const string& className, const string& name) \
806  { \
807    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:)"; \
808    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:)"; \
809  } \
810  template <> \
811  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,1> >(ostream& oss, const string& className, const string& name) \
812  { \
813    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:)"; \
814    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:)"; \
815  } \
816 \
817  template <> \
818  void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,2> >(ostream& oss, const string& className, const string& name) \
819  { \
820    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:)"; \
821    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:)"; \
822  } \
823 \
824  template <> \
825  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,2> >(ostream& oss, const string& className, const string& name) \
826  { \
827    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:)"; \
828    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:)"; \
829  } \
830 \
831  template <> \
832  void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,3> >(ostream& oss, const string& className, const string& name) \
833  { \
834    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:)"; \
835    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:)"; \
836  } \
837 \
838  template <> \
839  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,3> >(ostream& oss, const string& className, const string& name) \
840  { \
841    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:)"; \
842    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:)"; \
843  }\
844 \
845  template <> \
846  void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,4> >(ostream& oss, const string& className, const string& name) \
847  { \
848    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:,:)"; \
849    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:)"; \
850  } \
851 \
852  template <> \
853  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,4> >(ostream& oss, const string& className, const string& name) \
854  { \
855    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:,:)"; \
856    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:)"; \
857  }\
858 \
859  template <> \
860  void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,5> >(ostream& oss, const string& className, const string& name) \
861  { \
862    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:,:,:)"; \
863    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:)"; \
864  } \
865 \
866  template <> \
867  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,5> >(ostream& oss, const string& className, const string& name) \
868  { \
869    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:,:,:)"; \
870    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:)"; \
871  }\
872 \
873  template <> \
874  void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,6> >(ostream& oss, const string& className, const string& name) \
875  { \
876    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:,:,:,:)"; \
877    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:,:)"; \
878  } \
879 \
880  template <> \
881  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,6> >(ostream& oss, const string& className, const string& name) \
882  { \
883    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:,:,:,:)"; \
884    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:,:)"; \
885  }\
886 \
887  template <> \
888  void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,7> >(ostream& oss, const string& className, const string& name) \
889  { \
890    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:,:,:,:,:)"; \
891    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:,:,:)"; \
892  } \
893 \
894  template <> \
895  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,7> >(ostream& oss, const string& className, const string& name) \
896  { \
897    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:,:,:,:,:)"; \
898    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:,:,:)"; \
899  }
900
901  macro(bool)
902  macro(double)
903  macro(int)
904
905#undef macro
906
907#define macro(T,EXTENT)\
908  template <> \
909  void CInterface::AttributeFortranInterfaceDeclaration<CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\
910  {\
911    oss << "CHARACTER(len=*) , OPTIONAL, INTENT(IN) :: " << name << "("<<EXTENT<<")"; \
912  }\
913\
914  template <> \
915  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\
916  {\
917    oss << "CHARACTER(len=*) , OPTIONAL, INTENT(OUT) :: " << name << "("<<EXTENT<<")"; \
918  }
919  macro(1,":")
920  macro(2,":,:")
921  macro(3,":,:,:")
922  macro(4,":,:,:,:")
923  macro(5,":,:,:,:,:")
924  macro(6,":,:,:,:,:,:")
925  macro(7,":,:,:,:,:,:,:")
926
927#undef macro
928
929
930
931
932 
933
934#define macro(T) \
935  template <>  \
936  void CInterface::AttributeFortranInterfaceBody< CArray<T,1> >(ostream& oss, const string& className, const string& name) \
937  {  \
938    string name_tmp=name+"__tmp"; \
939      \
940    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
941    if (!matchingTypeCFortran<T>())  \
942    { \
943      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1)))" << iendl; \
944      oss << "  " << name_tmp << " = " << name << "_" << iendl; \
945      oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
946      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
947    } \
948    else { oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
949           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
950    oss << "ENDIF"; \
951  } \
952 \
953  template <>  \
954  void CInterface::AttributeFortranInterfaceBody< CArray<T,2> >(ostream& oss, const string& className, const string& name) \
955  {  \
956    string name_tmp=name+"__tmp"; \
957      \
958    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
959    if (!matchingTypeCFortran<T>())  \
960    { \
961      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2)))" << iendl; \
962      oss << "  " << name_tmp << " = " << name << "_" << iendl; \
963      oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
964      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
965    } \
966    else { oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
967           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
968    oss << "ENDIF"; \
969  } \
970  \
971  template <>  \
972  void CInterface::AttributeFortranInterfaceBody< CArray<T,3> >(ostream& oss, const string& className, const string& name) \
973  {  \
974    string name_tmp=name+"__tmp"; \
975      \
976    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
977    if (!matchingTypeCFortran<T>())  \
978    { \
979      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3)))" << iendl; \
980      oss << "  " << name_tmp << " = " << name << "_" << iendl; \
981      oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
982      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
983    } \
984    else { oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
985           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
986    oss << "ENDIF"; \
987  }\
988  \
989  template <>  \
990  void CInterface::AttributeFortranInterfaceBody< CArray<T,4> >(ostream& oss, const string& className, const string& name) \
991  {  \
992    string name_tmp=name+"__tmp"; \
993      \
994    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
995    if (!matchingTypeCFortran<T>())  \
996    { \
997      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \
998      oss << " SIZE(" << name << "_,4)))" << iendl; \
999      oss << "  " << name_tmp << " = " << name << "_" << iendl; \
1000      oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
1001      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1002    } \
1003    else { oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
1004           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1005    oss << "ENDIF"; \
1006  }\
1007  \
1008  template <>  \
1009  void CInterface::AttributeFortranInterfaceBody< CArray<T,5> >(ostream& oss, const string& className, const string& name) \
1010  {  \
1011    string name_tmp=name+"__tmp"; \
1012      \
1013    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1014    if (!matchingTypeCFortran<T>())  \
1015    { \
1016      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \
1017      oss << " SIZE(" << name << "_,4), SIZE(" << name << "_,5)))" << iendl; \
1018      oss << "  " << name_tmp << " = " << name << "_" << iendl; \
1019      oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
1020      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1021    } \
1022    else { oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
1023           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1024    oss << "ENDIF"; \
1025  }\
1026  \
1027  template <>  \
1028  void CInterface::AttributeFortranInterfaceBody< CArray<T,6> >(ostream& oss, const string& className, const string& name) \
1029  {  \
1030    string name_tmp=name+"__tmp"; \
1031      \
1032    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1033    if (!matchingTypeCFortran<T>())  \
1034    { \
1035      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \
1036      oss << " SIZE(" << name << "_,4), SIZE(" << name << "_,5), SIZE(" << name << "_,6)))" << iendl; \
1037      oss << "  " << name_tmp << " = " << name << "_" << iendl; \
1038      oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
1039      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1040    } \
1041    else { oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
1042           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1043    oss << "ENDIF"; \
1044  }\
1045  \
1046  template <>  \
1047  void CInterface::AttributeFortranInterfaceBody< CArray<T,7> >(ostream& oss, const string& className, const string& name) \
1048  {  \
1049    string name_tmp=name+"__tmp"; \
1050      \
1051    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1052    if (!matchingTypeCFortran<T>())  \
1053    { \
1054      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \
1055      oss << " SIZE(" << name << "_,4), SIZE(" << name << "_,5), SIZE(" << name << "_,6), &" << iendl; \
1056      oss << " SIZE(" << name << "_,7)))" << iendl; \
1057      oss << "  " << name_tmp << " = " << name << "_" << iendl; \
1058      oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
1059      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1060    } \
1061    else { oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
1062           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1063    oss << "ENDIF"; \
1064  }
1065
1066  macro(bool)
1067  macro(double)
1068  macro(int)
1069
1070#undef macro
1071
1072#define macro(T)\
1073  template <>\
1074  void CInterface::AttributeFortranInterfaceBody< CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\
1075  {\
1076     oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1077     oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
1078     oss << "(" << className << "_hdl%daddr, " << name <<"_, LEN("<<name<<"_), LEN_TRIM("<<name<< "_), SHAPE(" << name << "_))" << iendl; \
1079     oss << "ENDIF"; \
1080  }
1081
1082  macro(1)
1083  macro(2)
1084#undef macro
1085
1086#define macro(T) \
1087  template <>  \
1088  void CInterface::AttributeFortranInterfaceGetBody< CArray<T,1> >(ostream& oss, const string& className, const string& name) \
1089  {  \
1090    string name_tmp=name+"__tmp"; \
1091      \
1092    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1093    if (!matchingTypeCFortran<T>())  \
1094    { \
1095      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1)))" << iendl; \
1096      oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1097      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1098      oss << "  " << name << "_ = " << name_tmp << iendl; \
1099    } \
1100    else { oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1101           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1102    oss << "ENDIF"; \
1103  } \
1104 \
1105  template <>  \
1106  void CInterface::AttributeFortranInterfaceGetBody< CArray<T,2> >(ostream& oss, const string& className, const string& name) \
1107  {  \
1108    string name_tmp=name+"__tmp"; \
1109      \
1110    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1111    if (!matchingTypeCFortran<T>())  \
1112    { \
1113      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2)))" << iendl; \
1114      oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1115      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1116      oss << "  " << name << "_ = " << name_tmp << iendl; \
1117    } \
1118    else { oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1119           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1120    oss << "ENDIF"; \
1121  } \
1122 \
1123  template <>  \
1124  void CInterface::AttributeFortranInterfaceGetBody< CArray<T,3> >(ostream& oss, const string& className, const string& name) \
1125  {  \
1126    string name_tmp=name+"__tmp"; \
1127      \
1128    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1129    if (!matchingTypeCFortran<T>())  \
1130    { \
1131      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3)))" << iendl; \
1132      oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1133      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1134      oss << "  " << name << "_ = " << name_tmp << iendl; \
1135      } \
1136    else { oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1137           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1138    oss << "ENDIF"; \
1139  } \
1140 \
1141  template <>  \
1142  void CInterface::AttributeFortranInterfaceGetBody< CArray<T,4> >(ostream& oss, const string& className, const string& name) \
1143  {  \
1144    string name_tmp=name+"__tmp"; \
1145      \
1146    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1147    if (!matchingTypeCFortran<T>())  \
1148    { \
1149      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \
1150      oss << " SIZE(" << name << "_,4)))" << iendl; \
1151      oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1152      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1153      oss << "  " << name << "_ = " << name_tmp << iendl; \
1154      } \
1155    else { oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1156           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; }\
1157    oss << "ENDIF"; \
1158  } \
1159 \
1160  template <>  \
1161  void CInterface::AttributeFortranInterfaceGetBody< CArray<T,5> >(ostream& oss, const string& className, const string& name) \
1162  {  \
1163    string name_tmp=name+"__tmp"; \
1164      \
1165    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1166    if (!matchingTypeCFortran<T>())  \
1167    { \
1168      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \
1169      oss << " SIZE(" << name << "_,4), SIZE(" << name << "_,5)))" << iendl; \
1170      oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1171      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1172      oss << "  " << name << "_ = " << name_tmp << iendl; \
1173      } \
1174    else { oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1175           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1176    oss << "ENDIF"; \
1177  }\
1178 \
1179  template <>  \
1180  void CInterface::AttributeFortranInterfaceGetBody< CArray<T,6> >(ostream& oss, const string& className, const string& name) \
1181  {  \
1182    string name_tmp=name+"__tmp"; \
1183      \
1184    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1185    if (!matchingTypeCFortran<T>())  \
1186    { \
1187      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \
1188      oss << " SIZE(" << name << "_,4), SIZE(" << name << "_,5), SIZE(" << name << "_,6)))" << iendl; \
1189      oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1190      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1191      oss << "  " << name << "_ = " << name_tmp << iendl; \
1192      } \
1193    else { oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1194           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1195    oss << "ENDIF"; \
1196  } \
1197 \
1198  template <>  \
1199  void CInterface::AttributeFortranInterfaceGetBody< CArray<T,7> >(ostream& oss, const string& className, const string& name) \
1200  {  \
1201    string name_tmp=name+"__tmp"; \
1202      \
1203    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1204    if (!matchingTypeCFortran<T>())  \
1205    { \
1206      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \
1207      oss << " SIZE(" << name << "_,4), SIZE(" << name << "_,5), SIZE(" << name << "_,6), &" << iendl; \
1208      oss << " SIZE(" << name << "_,7)))" << iendl; \
1209      oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1210      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1211      oss << "  " << name << "_ = " << name_tmp << iendl; \
1212      } \
1213    else { oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1214           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1215    oss << "ENDIF"; \
1216  }
1217
1218  macro(bool)
1219  macro(double)
1220  macro(int)
1221
1222#undef macro
1223
1224#define macro(T)\
1225  template <> \
1226  void CInterface::AttributeFortranInterfaceGetBody< CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\
1227  {\
1228    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1229    oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1230    oss << "(" << className << "_hdl%daddr, " << name << "_, LEN("<<name<<"_), SHAPE(" << name << "_))" << iendl; \
1231    oss << "ENDIF"; \
1232  }
1233  macro(1)
1234  macro(2)
1235  macro(3)
1236  macro(4)
1237  macro(5)
1238  macro(6)
1239  macro(7)
1240
1241#undef macro
1242 
1243}
1244#endif
Note: See TracBrowser for help on using the repository browser.