source: XIOS3/trunk/src/generate_interface_impl.hpp

Last change on this file was 2620, checked in by jderouillat, 3 months ago

Modify fortran-C interfaces to manage logical-bool conversion, the optimizations of OneAPI could produce bugs regarding the logical-bool encodings.

  • 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: 66.9 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 xios_logical_to_bool_0d(" << name_tmp << ")" << iendl; \
359      oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl;
360      oss << "(" << className << "_hdl%daddr, " << name_tmp << ")" << iendl;
361    }
362    else { oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl;
363           oss << "(" << className << "_hdl%daddr, " << name << "_)" << iendl; }
364    oss << "ENDIF";
365  }
366
367  template <class T>
368  void CInterface::AttributeFortranInterfaceGetBody(ostream& oss, const string& className, const string& name)
369  {
370    string name_tmp=name+"__tmp";
371
372    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl;
373    if (!matchingTypeCFortran<T>())
374    {
375      oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl;
376      oss << "(" << className << "_hdl%daddr, " << name_tmp << ")" << iendl;
377      oss << "  CALL xios_bool_to_logical_0d(" << name_tmp << ")" << iendl; \
378      oss << "  " << name << "_ = " << name_tmp << iendl;
379    }
380    else { oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl;
381           oss << "(" << className << "_hdl%daddr, " << name << "_)" << iendl; }
382    oss << "ENDIF";
383  }
384
385  void CInterface::AttributeFortranInterfaceIsDefinedBody(ostream& oss, const string& className, const string& name)
386  {
387    string name_tmp=name+"__tmp";
388
389    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl;
390    oss << "  " << name << "__tmp = cxios_is_defined_" << className << "_" << name << " &" << iendl;
391    oss << "(" << className << "_hdl%daddr)" << iendl;
392    oss << "  " << name << "_ = " << name_tmp << iendl;
393    oss << "ENDIF";
394  }
395
396  template <>
397  void CInterface::AttributeFortranInterfaceBody<string>(ostream& oss, const string& className, const string& name)
398  {
399    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl;
400    oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl;
401    oss << "(" << className << "_hdl%daddr, " << name << "_, len(" << name << "_))" << iendl;
402    oss << "ENDIF";
403  }
404
405  template <>
406  void CInterface::AttributeFortranInterfaceGetBody<string>(ostream& oss, const string& className, const string& name)
407  {
408    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl;
409    oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl;
410    oss << "(" << className << "_hdl%daddr, " << name << "_, len(" << name << "_))" << iendl;
411    oss << "ENDIF";
412  }
413
414// declaration for CArray
415
416#define macro(T) \
417  template <> \
418  void CInterface::AttributeCInterface<CArray<T,1> >(ostream& oss, const string& className, const string& name) \
419  { \
420    string typeName=getStrType<T>(); \
421\
422    oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
423    oss << "{" << iendl; \
424    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
425    oss << "  CArray<" << typeName << ",1> tmp(" << name << ", shape(extent[0]), neverDeleteData);" << iendl; \
426    oss << "  " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \
427    /*oss << "  " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \
428    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
429    oss << "}" << std::endl; \
430    oss << iendl; \
431    oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
432    oss << "{" << iendl; \
433    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
434    oss << "  CArray<" << typeName << ",1> tmp(" << name << ", shape(extent[0]), neverDeleteData);" << iendl; \
435    oss << "  tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \
436    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
437    oss << "}" << std::endl; \
438  } \
439\
440  template <> \
441  void CInterface::AttributeCInterface<CArray<T,2> >(ostream& oss, const string& className, const string& name) \
442  { \
443    string typeName=getStrType<T>(); \
444\
445    oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
446    oss << "{" << iendl; \
447    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
448    oss << "  CArray<" << typeName << ",2> tmp(" << name << ", shape(extent[0], extent[1]), neverDeleteData);" << iendl; \
449    oss << "  " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \
450    /*oss << "  " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \
451    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
452    oss << "}" << std::endl; \
453    oss << iendl; \
454    oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
455    oss << "{" << iendl; \
456    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
457    oss << "  CArray<" << typeName << ",2> tmp(" << name << ", shape(extent[0], extent[1]), neverDeleteData);" << iendl; \
458    oss << "  tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \
459    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
460    oss << "}" << std::endl; \
461  } \
462\
463  template <> \
464  void CInterface::AttributeCInterface<CArray<T,3> >(ostream& oss, const string& className, const string& name) \
465  { \
466    string typeName=getStrType<T>(); \
467\
468    oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
469    oss << "{" << iendl; \
470    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
471    oss << "  CArray<" << typeName << ",3> tmp(" << name << ", shape(extent[0], extent[1], extent[2]), neverDeleteData);" << iendl; \
472    oss << "  " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \
473    /*oss << "  " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \
474    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
475    oss << "}" << std::endl; \
476    oss << iendl; \
477    oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
478    oss << "{" << iendl; \
479    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
480    oss << "  CArray<" << typeName << ",3> tmp(" << name << ", shape(extent[0], extent[1], extent[2]), neverDeleteData);" << iendl; \
481    oss << "  tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \
482    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
483    oss << "}" << std::endl; \
484  } \
485\
486  template <> \
487  void CInterface::AttributeCInterface<CArray<T,4> >(ostream& oss, const string& className, const string& name) \
488  { \
489    string typeName=getStrType<T>(); \
490\
491    oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
492    oss << "{" << iendl; \
493    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
494    oss << "  CArray<" << typeName << ",4> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3]), neverDeleteData);" << iendl; \
495    oss << "  " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \
496    /*oss << "  " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \
497    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
498    oss << "}" << std::endl; \
499    oss << iendl; \
500    oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
501    oss << "{" << iendl; \
502    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
503    oss << "  CArray<" << typeName << ",4> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3]), neverDeleteData);" << iendl; \
504    oss << "  tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \
505    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
506    oss << "}" << std::endl; \
507  } \
508\
509  template <> \
510  void CInterface::AttributeCInterface<CArray<T,5> >(ostream& oss, const string& className, const string& name) \
511  { \
512    string typeName=getStrType<T>(); \
513\
514    oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
515    oss << "{" << iendl; \
516    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
517    oss << "  CArray<" << typeName << ",5> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3], extent[4]), neverDeleteData);" << iendl; \
518    oss << "  " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \
519    /*oss << "  " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \
520    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
521    oss << "}" << std::endl; \
522    oss << iendl; \
523    oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
524    oss << "{" << iendl; \
525    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
526    oss << "  CArray<" << typeName << ",5> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3], extent[4]), neverDeleteData);" << iendl; \
527    oss << "  tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \
528    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
529    oss << "}" << std::endl; \
530  } \
531\
532  template <> \
533  void CInterface::AttributeCInterface<CArray<T,6> >(ostream& oss, const string& className, const string& name) \
534  { \
535    string typeName=getStrType<T>(); \
536\
537    oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
538    oss << "{" << iendl; \
539    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
540    oss << "  CArray<" << typeName << ",6> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3], extent[4], extent[5]), neverDeleteData);" << iendl; \
541    oss << "  " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \
542    /*oss << "  " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \
543    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
544    oss << "}" << std::endl; \
545    oss << iendl; \
546    oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
547    oss << "{" << iendl; \
548    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
549    oss << "  CArray<" << typeName << ",6> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3], extent[4], extent[5]), neverDeleteData);" << iendl; \
550    oss << "  tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \
551    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
552    oss << "}" << std::endl; \
553  }  \
554\
555  template <> \
556  void CInterface::AttributeCInterface<CArray<T,7> >(ostream& oss, const string& className, const string& name) \
557  { \
558    string typeName=getStrType<T>(); \
559\
560    oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
561    oss << "{" << iendl; \
562    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
563    oss << "  CArray<" << typeName << ",7> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3], extent[4], extent[5], extent[6]), neverDeleteData);" << iendl; \
564    oss << "  " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \
565    /*oss << "  " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \
566    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
567    oss << "}" << std::endl; \
568    oss << iendl; \
569    oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \
570    oss << "{" << iendl; \
571    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
572    oss << "  CArray<" << typeName << ",7> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3], extent[4], extent[5], extent[6]), neverDeleteData);" << iendl; \
573    oss << "  tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \
574    oss << "   CTimer::get(\"XIOS\").suspend();" << iendl; \
575    oss << "}" << std::endl; \
576  }
577
578macro(bool)
579macro(double)
580macro(int)
581
582#undef macro
583
584#define macro(N,EXTENT)\
585  template <>\
586  void CInterface::AttributeCInterface<CArray<StdString,N> >(ostream& oss, const string& className, const string& name)\
587  { \
588    oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << "char* " << name <<", int str_len, int* str_size, int* extent)" << iendl; \
589    oss << "{" << iendl; \
590    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
591    oss << "  "<<className<<"_hdl->"<<name<<".resize(shape("<<EXTENT<<"));"<<iendl;\
592    oss << "  Array<StdString,"<<#N<<">::iterator it, itb="<<className<<"_hdl->"<<name<<".begin(), ite="<<className<<"_hdl->"<<name<<".end() ;"<<iendl ;\
593    oss << "  int i, n ;"<< iendl; \
594    oss << "  for(it=itb, i=0, n=0 ; it!=ite ; ++it,n+=str_len,++i) *it=StdString(&"<<name<<"[n],str_size[i]) ;"<<iendl ;\
595    oss << "  CTimer::get(\"XIOS\").suspend();" << iendl; \
596    oss << "}" << std::endl; \
597    oss << iendl; \
598    oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << "char* " << name << ", int str_size, int* extent)" << iendl; \
599    oss << "{" << iendl; \
600    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \
601    oss << "  Array<StdString,"<<#N<<">::const_iterator it, itb="<<className<<"_hdl->"<<name<<".getInheritedValue().begin(), ite="<<className<<"_hdl->"<<name<<".getInheritedValue().end() ;" << iendl; \
602    oss << "  int n ;"<< iendl; \
603    oss << "  for(it=itb, n=0 ; it!=ite ; ++it, n+=str_size) it->copy(&"<<name<<"[n],it->size()) ; "<< iendl; \
604    oss << "  CTimer::get(\"XIOS\").suspend();" << iendl; \
605    oss << "}" << std::endl; \
606  }
607
608macro(1,"extent[0]")
609macro(2,"extent[0],extent[1]")
610macro(3,"extent[0],extent[1],extent[2]")
611macro(4,"extent[0],extent[1],extent[2],extent[3]")
612macro(5,"extent[0],extent[1],extent[2],extent[3],extent[4]")
613macro(6,"extent[0],extent[1],extent[2],extent[3],extent[4],extent[5]")
614macro(7,"extent[0],extent[1],extent[2],extent[3],extent[4],extent[5],extent[6]")
615#undef macro
616// /////////////////////////////////////////////////
617// //          Fortran 2003 Interface             //
618// /////////////////////////////////////////////////
619
620#define macro(T) \
621  template <> \
622  void CInterface::AttributeFortran2003Interface<CArray<T,1> >(ostream& oss, const string& className, const string& name) \
623  { \
624    string fortranType=getStrFortranType<T>(); \
625    string fortranKindC=getStrFortranKindC<T>(); \
626      \
627    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
628    oss << "  USE ISO_C_BINDING" << iendl; \
629    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
630    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
631    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
632    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \
633    oss << iendl; \
634    oss << "SUBROUTINE cxios_get_" << 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_get_" << className << "_" << name << std::endl; \
640  } \
641 \
642  template <> \
643  void CInterface::AttributeFortran2003Interface<CArray<T,2> >(ostream& oss, const string& className, const string& name) \
644  { \
645    string fortranType=getStrFortranType<T>(); \
646    string fortranKindC=getStrFortranKindC<T>(); \
647      \
648    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
649    oss << "  USE ISO_C_BINDING" << iendl; \
650    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
651    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
652    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
653    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \
654    oss << iendl; \
655    oss << "SUBROUTINE cxios_get_" << 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_get_" << className << "_" << name << std::endl; \
661  } \
662 \
663  template <> \
664  void CInterface::AttributeFortran2003Interface<CArray<T,3> >(ostream& oss, const string& className, const string& name) \
665  { \
666    string fortranType=getStrFortranType<T>(); \
667    string fortranKindC=getStrFortranKindC<T>(); \
668      \
669    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
670    oss << "  USE ISO_C_BINDING" << iendl; \
671    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
672    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
673    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
674    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \
675    oss << iendl; \
676    oss << "SUBROUTINE cxios_get_" << 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_get_" << className << "_" << name << std::endl; \
682  }  \
683 \
684  template <> \
685  void CInterface::AttributeFortran2003Interface<CArray<T,4> >(ostream& oss, const string& className, const string& name) \
686  { \
687    string fortranType=getStrFortranType<T>(); \
688    string fortranKindC=getStrFortranKindC<T>(); \
689      \
690    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
691    oss << "  USE ISO_C_BINDING" << iendl; \
692    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
693    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
694    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
695    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \
696    oss << iendl; \
697    oss << "SUBROUTINE cxios_get_" << 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_get_" << className << "_" << name << std::endl; \
703  }\
704 \
705  template <> \
706  void CInterface::AttributeFortran2003Interface<CArray<T,5> >(ostream& oss, const string& className, const string& name) \
707  { \
708    string fortranType=getStrFortranType<T>(); \
709    string fortranKindC=getStrFortranKindC<T>(); \
710      \
711    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
712    oss << "  USE ISO_C_BINDING" << iendl; \
713    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
714    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
715    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
716    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \
717    oss << iendl; \
718    oss << "SUBROUTINE cxios_get_" << 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_get_" << className << "_" << name << std::endl; \
724  }\
725 \
726  template <> \
727  void CInterface::AttributeFortran2003Interface<CArray<T,6> >(ostream& oss, const string& className, const string& name) \
728  { \
729    string fortranType=getStrFortranType<T>(); \
730    string fortranKindC=getStrFortranKindC<T>(); \
731      \
732    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
733    oss << "  USE ISO_C_BINDING" << iendl; \
734    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
735    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
736    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
737    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \
738    oss << iendl; \
739    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
740    oss << "  USE ISO_C_BINDING" << iendl; \
741    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
742    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
743    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
744    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \
745  }\
746 \
747  template <> \
748  void CInterface::AttributeFortran2003Interface<CArray<T,7> >(ostream& oss, const string& className, const string& name) \
749  { \
750    string fortranType=getStrFortranType<T>(); \
751    string fortranKindC=getStrFortranKindC<T>(); \
752      \
753    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
754    oss << "  USE ISO_C_BINDING" << iendl; \
755    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
756    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
757    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
758    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \
759    oss << iendl; \
760    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \
761    oss << "  USE ISO_C_BINDING" << iendl; \
762    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
763    oss << "  " << fortranType << " " << fortranKindC << "     , DIMENSION(*) :: " << name << iendl; \
764    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
765    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \
766  }
767
768  macro(bool)
769  macro(double)
770  macro(int)
771
772  #undef macro
773
774#define macro(T)\
775  template <>\
776  void CInterface::AttributeFortran2003Interface<CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\
777  {\
778    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", str_len, str_size, extent) BIND(C)" << iendl; \
779    oss << "  USE ISO_C_BINDING" << iendl; \
780    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
781    oss << "  CHARACTER (KIND=C_CHAR), DIMENSION(*)    :: " << name << iendl; \
782    oss << "  INTEGER (kind = C_INT), VALUE            :: str_len" << iendl; \
783    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: str_size" << iendl; \
784    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
785    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \
786    oss << iendl; \
787    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", str_size, extent) BIND(C)" << iendl; \
788    oss << "  USE ISO_C_BINDING" << iendl; \
789    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \
790    oss << "  CHARACTER (KIND=C_CHAR), DIMENSION(*)    :: " << name << iendl; \
791    oss << "  INTEGER (kind = C_INT), VALUE            :: str_size" << iendl; \
792    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \
793    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \
794  }
795  macro(1)
796  macro(2)
797  macro(3)
798  macro(4)
799  macro(5)
800  macro(6)
801  macro(7)
802
803#undef macro
804
805#define macro(T) \
806  template <> \
807  void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,1> >(ostream& oss, const string& className, const string& name) \
808  { \
809    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:)"; \
810    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:)"; \
811  } \
812  template <> \
813  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,1> >(ostream& oss, const string& className, const string& name) \
814  { \
815    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:)"; \
816    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:)"; \
817  } \
818 \
819  template <> \
820  void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,2> >(ostream& oss, const string& className, const string& name) \
821  { \
822    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:)"; \
823    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:)"; \
824  } \
825 \
826  template <> \
827  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,2> >(ostream& oss, const string& className, const string& name) \
828  { \
829    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:)"; \
830    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:)"; \
831  } \
832 \
833  template <> \
834  void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,3> >(ostream& oss, const string& className, const string& name) \
835  { \
836    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:)"; \
837    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:)"; \
838  } \
839 \
840  template <> \
841  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,3> >(ostream& oss, const string& className, const string& name) \
842  { \
843    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:)"; \
844    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:)"; \
845  }\
846 \
847  template <> \
848  void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,4> >(ostream& oss, const string& className, const string& name) \
849  { \
850    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:,:)"; \
851    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:)"; \
852  } \
853 \
854  template <> \
855  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,4> >(ostream& oss, const string& className, const string& name) \
856  { \
857    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:,:)"; \
858    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:)"; \
859  }\
860 \
861  template <> \
862  void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,5> >(ostream& oss, const string& className, const string& name) \
863  { \
864    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:,:,:)"; \
865    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:)"; \
866  } \
867 \
868  template <> \
869  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,5> >(ostream& oss, const string& className, const string& name) \
870  { \
871    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:,:,:)"; \
872    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:)"; \
873  }\
874 \
875  template <> \
876  void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,6> >(ostream& oss, const string& className, const string& name) \
877  { \
878    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:,:,:,:)"; \
879    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:,:)"; \
880  } \
881 \
882  template <> \
883  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,6> >(ostream& oss, const string& className, const string& name) \
884  { \
885    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:,:,:,:)"; \
886    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:,:)"; \
887  }\
888 \
889  template <> \
890  void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,7> >(ostream& oss, const string& className, const string& name) \
891  { \
892    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:,:,:,:,:)"; \
893    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:,:,:)"; \
894  } \
895 \
896  template <> \
897  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,7> >(ostream& oss, const string& className, const string& name) \
898  { \
899    oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:,:,:,:,:)"; \
900    if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:,:,:)"; \
901  }
902
903  macro(bool)
904  macro(double)
905  macro(int)
906
907#undef macro
908
909#define macro(T,EXTENT)\
910  template <> \
911  void CInterface::AttributeFortranInterfaceDeclaration<CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\
912  {\
913    oss << "CHARACTER(len=*) , OPTIONAL, INTENT(IN) :: " << name << "("<<EXTENT<<")"; \
914  }\
915\
916  template <>\
917  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\
918  {\
919    oss << "CHARACTER(len=*) , OPTIONAL, INTENT(OUT) :: " << name << "("<<EXTENT<<")"; \
920  }
921  macro(1,":")
922  macro(2,":,:")
923  macro(3,":,:,:")
924  macro(4,":,:,:,:")
925  macro(5,":,:,:,:,:")
926  macro(6,":,:,:,:,:,:")
927  macro(7,":,:,:,:,:,:,:")
928
929#undef macro
930
931
932
933
934 
935
936#define macro(T) \
937  template <>  \
938  void CInterface::AttributeFortranInterfaceBody< CArray<T,1> >(ostream& oss, const string& className, const string& name) \
939  {  \
940    string name_tmp=name+"__tmp"; \
941      \
942    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
943    if (!matchingTypeCFortran<T>())  \
944    { \
945      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1)))" << iendl; \
946      oss << "  " << name_tmp << " = " << name << "_" << iendl; \
947      oss << "  CALL xios_logical_to_bool_1d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << 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,2> >(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)))" << iendl; \
965      oss << "  " << name_tmp << " = " << name << "_" << iendl; \
966      oss << "  CALL xios_logical_to_bool_2d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << 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,3> >(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 << "  " << name_tmp << " = " << name << "_" << iendl; \
985      oss << "  CALL xios_logical_to_bool_3d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << 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,4> >(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)))" << iendl; \
1004      oss << "  " << name_tmp << " = " << name << "_" << iendl; \
1005      oss << "  CALL xios_logical_to_bool_4d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \
1006      oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
1007      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1008    } \
1009    else { oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
1010           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1011    oss << "ENDIF"; \
1012  }\
1013  \
1014  template <>  \
1015  void CInterface::AttributeFortranInterfaceBody< CArray<T,5> >(ostream& oss, const string& className, const string& name) \
1016  {  \
1017    string name_tmp=name+"__tmp"; \
1018      \
1019    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1020    if (!matchingTypeCFortran<T>())  \
1021    { \
1022      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \
1023      oss << " SIZE(" << name << "_,4), SIZE(" << name << "_,5)))" << iendl; \
1024      oss << "  " << name_tmp << " = " << name << "_" << iendl; \
1025      oss << "  CALL xios_logical_to_bool_5d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \
1026      oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
1027      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1028    } \
1029    else { oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
1030           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1031    oss << "ENDIF"; \
1032  }\
1033  \
1034  template <>  \
1035  void CInterface::AttributeFortranInterfaceBody< CArray<T,6> >(ostream& oss, const string& className, const string& name) \
1036  {  \
1037    string name_tmp=name+"__tmp"; \
1038      \
1039    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1040    if (!matchingTypeCFortran<T>())  \
1041    { \
1042      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \
1043      oss << " SIZE(" << name << "_,4), SIZE(" << name << "_,5), SIZE(" << name << "_,6)))" << iendl; \
1044      oss << "  " << name_tmp << " = " << name << "_" << iendl; \
1045      oss << "  CALL xios_logical_to_bool_6d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \
1046      oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
1047      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1048    } \
1049    else { oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
1050           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1051    oss << "ENDIF"; \
1052  }\
1053  \
1054  template <>  \
1055  void CInterface::AttributeFortranInterfaceBody< CArray<T,7> >(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), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \
1063      oss << " SIZE(" << name << "_,4), SIZE(" << name << "_,5), SIZE(" << name << "_,6), &" << iendl; \
1064      oss << " SIZE(" << name << "_,7)))" << iendl; \
1065      oss << "  " << name_tmp << " = " << name << "_" << iendl; \
1066      oss << "  CALL xios_logical_to_bool_7d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \
1067      oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
1068      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1069    } \
1070    else { oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
1071           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1072    oss << "ENDIF"; \
1073  }
1074
1075  macro(bool)
1076  macro(double)
1077  macro(int)
1078
1079#undef macro
1080
1081#define macro(T)\
1082  template <>\
1083  void CInterface::AttributeFortranInterfaceBody< CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\
1084  {\
1085     oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1086     oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \
1087     oss << "(" << className << "_hdl%daddr, " << name <<"_, LEN("<<name<<"_), LEN_TRIM("<<name<< "_), SHAPE(" << name << "_))" << iendl; \
1088     oss << "ENDIF"; \
1089  }
1090
1091  macro(1)
1092  macro(2)
1093#undef macro
1094
1095#define macro(T) \
1096  template <>  \
1097  void CInterface::AttributeFortranInterfaceGetBody< CArray<T,1> >(ostream& oss, const string& className, const string& name) \
1098  {  \
1099    string name_tmp=name+"__tmp"; \
1100      \
1101    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1102    if (!matchingTypeCFortran<T>())  \
1103    { \
1104      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1)))" << iendl; \
1105      oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1106      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1107      oss << "  CALL xios_bool_to_logical_1d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \
1108      oss << "  " << name << "_ = " << name_tmp << iendl; \
1109    } \
1110    else { oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1111           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1112    oss << "ENDIF"; \
1113  } \
1114 \
1115  template <>  \
1116  void CInterface::AttributeFortranInterfaceGetBody< CArray<T,2> >(ostream& oss, const string& className, const string& name) \
1117  {  \
1118    string name_tmp=name+"__tmp"; \
1119      \
1120    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1121    if (!matchingTypeCFortran<T>())  \
1122    { \
1123      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2)))" << iendl; \
1124      oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1125      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1126      oss << "  CALL xios_bool_to_logical_2d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \
1127      oss << "  " << name << "_ = " << name_tmp << iendl; \
1128    } \
1129    else { oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1130           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1131    oss << "ENDIF"; \
1132  } \
1133 \
1134  template <>  \
1135  void CInterface::AttributeFortranInterfaceGetBody< CArray<T,3> >(ostream& oss, const string& className, const string& name) \
1136  {  \
1137    string name_tmp=name+"__tmp"; \
1138      \
1139    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1140    if (!matchingTypeCFortran<T>())  \
1141    { \
1142      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3)))" << iendl; \
1143      oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1144      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1145      oss << "  CALL xios_bool_to_logical_3d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \
1146      oss << "  " << name << "_ = " << name_tmp << iendl; \
1147      } \
1148    else { oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1149           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1150    oss << "ENDIF"; \
1151  } \
1152 \
1153  template <>  \
1154  void CInterface::AttributeFortranInterfaceGetBody< CArray<T,4> >(ostream& oss, const string& className, const string& name) \
1155  {  \
1156    string name_tmp=name+"__tmp"; \
1157      \
1158    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1159    if (!matchingTypeCFortran<T>())  \
1160    { \
1161      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \
1162      oss << " SIZE(" << name << "_,4)))" << iendl; \
1163      oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1164      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1165      oss << "  CALL xios_bool_to_logical_4d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \
1166      oss << "  " << name << "_ = " << name_tmp << iendl; \
1167      } \
1168    else { oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1169           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; }\
1170    oss << "ENDIF"; \
1171  } \
1172 \
1173  template <>  \
1174  void CInterface::AttributeFortranInterfaceGetBody< CArray<T,5> >(ostream& oss, const string& className, const string& name) \
1175  {  \
1176    string name_tmp=name+"__tmp"; \
1177      \
1178    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1179    if (!matchingTypeCFortran<T>())  \
1180    { \
1181      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \
1182      oss << " SIZE(" << name << "_,4), SIZE(" << name << "_,5)))" << iendl; \
1183      oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1184      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1185      oss << "  CALL xios_bool_to_logical_5d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \
1186      oss << "  " << name << "_ = " << name_tmp << iendl; \
1187      } \
1188    else { oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1189           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1190    oss << "ENDIF"; \
1191  }\
1192 \
1193  template <>  \
1194  void CInterface::AttributeFortranInterfaceGetBody< CArray<T,6> >(ostream& oss, const string& className, const string& name) \
1195  {  \
1196    string name_tmp=name+"__tmp"; \
1197      \
1198    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1199    if (!matchingTypeCFortran<T>())  \
1200    { \
1201      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \
1202      oss << " SIZE(" << name << "_,4), SIZE(" << name << "_,5), SIZE(" << name << "_,6)))" << iendl; \
1203      oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1204      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1205      oss << "  CALL xios_bool_to_logical_6d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \
1206      oss << "  " << name << "_ = " << name_tmp << iendl; \
1207      } \
1208    else { oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1209           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1210    oss << "ENDIF"; \
1211  } \
1212 \
1213  template <>  \
1214  void CInterface::AttributeFortranInterfaceGetBody< CArray<T,7> >(ostream& oss, const string& className, const string& name) \
1215  {  \
1216    string name_tmp=name+"__tmp"; \
1217      \
1218    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1219    if (!matchingTypeCFortran<T>())  \
1220    { \
1221      oss << "  ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \
1222      oss << " SIZE(" << name << "_,4), SIZE(" << name << "_,5), SIZE(" << name << "_,6), &" << iendl; \
1223      oss << " SIZE(" << name << "_,7)))" << iendl; \
1224      oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1225      oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \
1226      oss << "  CALL xios_bool_to_logical_7d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \
1227      oss << "  " << name << "_ = " << name_tmp << iendl; \
1228      } \
1229    else { oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1230           oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \
1231    oss << "ENDIF"; \
1232  }
1233
1234  macro(bool)
1235  macro(double)
1236  macro(int)
1237
1238#undef macro
1239
1240#define macro(T)\
1241  template <> \
1242  void CInterface::AttributeFortranInterfaceGetBody< CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\
1243  {\
1244    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \
1245    oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \
1246    oss << "(" << className << "_hdl%daddr, " << name << "_, LEN("<<name<<"_), SHAPE(" << name << "_))" << iendl; \
1247    oss << "ENDIF"; \
1248  }
1249  macro(1)
1250  macro(2)
1251  macro(3)
1252  macro(4)
1253  macro(5)
1254  macro(6)
1255  macro(7)
1256
1257#undef macro
1258 
1259}
1260#endif
Note: See TracBrowser for help on using the repository browser.