source: XIOS/trunk/src/generate_interface_impl.hpp @ 537

Last change on this file since 537 was 537, checked in by rlacroix, 8 years ago

Add a new attribute type for durations and use it for the context's timestep.

Note that the "xios_time" type and the "xios_set_timestep" procedure have been removed from the Fortran interface. Instead, the "xios_duration" type and the "xios_get_context_attr"/"xios_set_context_attr" procedures should now be used to get/set the timestep.

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