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

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

Add a new attribute type for dates and use it for the context's start_date and time_origin.

The "xios_date" type should now be used to get/set date attributes through the Fortran interface. This avoids using strings to manipulate dates.

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