Ignore:
Timestamp:
11/13/14 15:09:14 (9 years ago)
Author:
mhnguyen
Message:

Implementing buffer size auto-detection for mode client -server

+) Process xml tree in client side then send all the information to server
+) Only information enabled fields in enabled files are sent to server
+) Some important change in structure of code which must be refactored

Test
+) On Curie
+) Only mode client-server
+) Passed for all tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/generate_interface_impl.hpp

    r501 r509  
    1010 
    1111namespace xios 
    12 {  
     12{ 
    1313  template<> string CInterface::getStrFortranType<int>(void) {return string("INTEGER") ;} 
    1414  template<> string CInterface::getStrFortranType<bool>(void) {return string("LOGICAL") ;} 
    1515  template<> string CInterface::getStrFortranType<double>(void) {return string("REAL") ;} 
    1616  template<> string CInterface::getStrFortranType<float>(void) {return string("REAL") ;} 
    17    
     17 
    1818  template<> string CInterface::getStrFortranKind<int>(void) {return string("") ;} 
    1919  template<> string CInterface::getStrFortranKind<bool>(void) {return string("") ;} 
    2020  template<> string CInterface::getStrFortranKind<double>(void) {return string("(KIND=8)") ;} 
    2121  template<> string CInterface::getStrFortranKind<float>(void) {return string("(KIND=4)") ;} 
    22    
     22 
    2323  template<> string CInterface::getStrFortranKindC<int>(void) {return string("(KIND=C_INT)") ;} 
    2424  template<> string CInterface::getStrFortranKindC<bool>(void) {return string("(KIND=C_BOOL)") ;} 
    2525  template<> string CInterface::getStrFortranKindC<double>(void) {return string("(KIND=C_DOUBLE)") ;} 
    2626  template<> string CInterface::getStrFortranKindC<float>(void) {return string("(KIND=C_FLOAT)") ;} 
    27    
    28   template<> bool CInterface::matchingTypeCFortran<int>(void) { return true ; }  
    29   template<> bool CInterface::matchingTypeCFortran<bool>(void) { return false ;}  
     27 
     28  template<> bool CInterface::matchingTypeCFortran<int>(void) { return true ; } 
     29  template<> bool CInterface::matchingTypeCFortran<bool>(void) { return false ;} 
    3030  template<> bool CInterface::matchingTypeCFortran<double>(void) { return true; } 
    3131  template<> bool CInterface::matchingTypeCFortran<float>(void) { return true; } 
    32    
     32 
    3333 
    3434// ///////////////////////////////////////////////// 
     
    3636// ///////////////////////////////////////////////// 
    3737 
    38    
     38 
    3939  void CInterface::AttributeIsDefinedCInterface(ostream& oss, const string& className,const string& name) 
    4040  { 
     
    4747    oss<<iendl ; 
    4848  } 
    49    
     49 
    5050  template <class T> 
    5151  void CInterface::AttributeCInterface(ostream& oss, const string& className,const string& name) 
    5252  { 
    5353    string typeName=getStrType<T>() ; 
    54   
     54 
    5555    oss<<"void cxios_set_"<<className<<"_"<<name<<"("<<className<<"_Ptr "<<className<<"_hdl, "<< typeName<<" "<<name<<")"<<iendl ; 
    5656    oss<<"{"<<iendl ; 
    5757    oss<<"   CTimer::get(\"XIOS\").resume();"<<iendl ; 
    5858    oss<<"  "<<className<<"_hdl->"<<name<<".setValue("<<name<<");"<<iendl ; 
    59     oss<<"  "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ; 
     59//    oss<<"  "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ; 
    6060    oss<<"   CTimer::get(\"XIOS\").suspend();"<<iendl ; 
    6161    oss<<"}"<<iendl ; 
    62      
     62 
    6363    oss<<iendl ; 
    6464    oss<<"void cxios_get_"<<className<<"_"<<name<<"("<<className<<"_Ptr "<<className<<"_hdl, "<< typeName<<"* "<<name<<")"<<iendl ; 
     
    6868    oss<<iendl ; 
    6969  } 
    70      
    71    
     70 
     71 
    7272  template<> 
    73   void CInterface::AttributeCInterface<string>(ostream& oss, const string& className,const string& name)   
     73  void CInterface::AttributeCInterface<string>(ostream& oss, const string& className,const string& name) 
    7474  { 
    7575    oss<<"void cxios_set_"<<className<<"_"<<name<<"("<<className<<"_Ptr "<<className<<"_hdl, const char * "<<name<<", int "<<name<<"_size)"<<iendl ; 
     
    7979    oss<<"   CTimer::get(\"XIOS\").resume();"<<iendl ; 
    8080    oss<<"  "<<className<<"_hdl->"<<name<<".setValue("<<name<<"_str);"<<iendl ; 
    81     oss<<"  "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ; 
     81//    oss<<"  "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ; 
    8282    oss<<"   CTimer::get(\"XIOS\").suspend();"<<iendl ; 
    8383    oss<<"}"<<iendl ; 
    84      
     84 
    8585    oss<<iendl ; 
    86      
     86 
    8787    oss<<"void cxios_get_"<<className<<"_"<<name<<"("<<className<<"_Ptr "<<className<<"_hdl, char * "<<name<<", int "<<name<<"_size)"<<iendl ; 
    8888    oss<<"{"<<iendl ; 
     
    9494    oss<<"}"<<iendl ; 
    9595    oss<<iendl ; 
    96     
     96 
    9797  } 
    9898 
    9999  template<> 
    100   void CInterface::AttributeCInterface<CEnumBase>(ostream& oss, const string& className,const string& name)   
     100  void CInterface::AttributeCInterface<CEnumBase>(ostream& oss, const string& className,const string& name) 
    101101  { 
    102102    oss<<"void cxios_set_"<<className<<"_"<<name<<"("<<className<<"_Ptr "<<className<<"_hdl, const char * "<<name<<", int "<<name<<"_size)"<<iendl ; 
     
    106106    oss<<"   CTimer::get(\"XIOS\").resume();"<<iendl ; 
    107107    oss<<"  "<<className<<"_hdl->"<<name<<".fromString("<<name<<"_str);"<<iendl ; 
    108     oss<<"  "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ; 
     108//    oss<<"  "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ; 
    109109    oss<<"   CTimer::get(\"XIOS\").suspend();"<<iendl ; 
    110110    oss<<"}"<<iendl ; 
    111      
     111 
    112112    oss<<iendl ; 
    113      
     113 
    114114    oss<<"void cxios_get_"<<className<<"_"<<name<<"("<<className<<"_Ptr "<<className<<"_hdl, char * "<<name<<", int "<<name<<"_size)"<<iendl ; 
    115115    oss<<"{"<<iendl ; 
     
    121121    oss<<"}"<<iendl ; 
    122122    oss<<iendl ; 
    123    
     123 
    124124  } 
    125125//     if (!array_copy(domain_hdl->mask.getValue(), mask, extent1, extent2)) 
     
    139139    oss<<"  std::copy("<<name<<", &("<<name<<"[array_tmp->num_elements()]), array_tmp->data());"<<iendl ;\ 
    140140    oss<<"  "<<className<<"_hdl->"<<name<<".setValue(array_tmp);"<<iendl ;\ 
    141     oss<<"  "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;\ 
     141//    oss<<"  "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;\ 
    142142    oss<<"}"<<iendl ;\ 
    143143    oss<<iendl; \ 
     
    162162    oss<<"  std::copy("<<name<<", &("<<name<<"[array_tmp->num_elements()]), array_tmp->data());"<<iendl ;\ 
    163163    oss<<"  "<<className<<"_hdl->"<<name<<".setValue(array_tmp);"<<iendl ;\ 
    164     oss<<"  "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;\ 
     164//    oss<<"  "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;\ 
    165165    oss<<"}"<<iendl ;\ 
    166166    oss<<iendl; \ 
     
    185185    oss<<"  std::copy("<<name<<", &("<<name<<"[array_tmp->num_elements()]), array_tmp->data());"<<iendl ;\ 
    186186    oss<<"  "<<className<<"_hdl->"<<name<<".setValue(array_tmp);"<<iendl ;\ 
    187     oss<<"  "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;\ 
     187//    oss<<"  "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;\ 
    188188    oss<<"}"<<iendl ;\ 
    189189    oss<<iendl; \ 
     
    202202*/ 
    203203 
    204 #undef macro   
     204#undef macro 
    205205 
    206206// ///////////////////////////////////////////////// 
     
    213213     oss<<"  LOGICAL(kind=C_BOOL) :: cxios_is_defined_"<<className<<"_"<<name<<iendl; 
    214214     oss<<"  INTEGER (kind = C_INTPTR_T), VALUE :: "<<className<<"_hdl"<<iendl ; 
    215      oss<<"END FUNCTION cxios_is_defined_"<<className<<"_"<<name<<iendl ;    
    216    } 
    217     
     215     oss<<"END FUNCTION cxios_is_defined_"<<className<<"_"<<name<<iendl ; 
     216   } 
     217 
    218218   template <class T> 
    219219   void CInterface::AttributeFortran2003Interface(ostream& oss,const string& className,const string& name) 
     
    221221     string fortranType=getStrFortranType<T>() ; 
    222222     string fortranKindC=getStrFortranKindC<T>() ; 
    223       
     223 
    224224     oss<<"SUBROUTINE cxios_set_"<<className<<"_"<<name<<"("<<className<<"_hdl, "<<name<<") BIND(C)"<<iendl ; 
    225225     oss<<"  USE ISO_C_BINDING"<<iendl ; 
     
    227227     oss<<"  "<<fortranType<<" "<<fortranKindC<<"      , VALUE :: "<<name<<iendl ; 
    228228     oss<<"END SUBROUTINE cxios_set_"<<className<<"_"<<name<<iendl ; 
    229      oss<<iendl ;  
     229     oss<<iendl ; 
    230230     oss<<"SUBROUTINE cxios_get_"<<className<<"_"<<name<<"("<<className<<"_hdl, "<<name<<") BIND(C)"<<iendl ; 
    231231     oss<<"  USE ISO_C_BINDING"<<iendl ; 
     
    235235     oss<<iendl ; 
    236236   } 
    237     
    238     
     237 
     238 
    239239   template <> 
    240240   void CInterface::AttributeFortran2003Interface<string>(ostream& oss,const string& className,const string& name) 
    241241   { 
    242            
     242 
    243243     oss<<"SUBROUTINE cxios_set_"<<className<<"_"<<name<<"("<<className<<"_hdl, "<<name<<", "<<name<<"_size) BIND(C)"<<iendl ; 
    244244     oss<<"  USE ISO_C_BINDING"<<iendl ; 
     
    247247     oss<<"  INTEGER  (kind = C_INT)     , VALUE        :: "<<name<<"_size"<<iendl ; 
    248248     oss<<"END SUBROUTINE cxios_set_"<<className<<"_"<<name<<iendl ; 
    249      oss<<iendl ;  
     249     oss<<iendl ; 
    250250     oss<<"SUBROUTINE cxios_get_"<<className<<"_"<<name<<"("<<className<<"_hdl, "<<name<<", "<<name<<"_size) BIND(C)"<<iendl ; 
    251251     oss<<"  USE ISO_C_BINDING"<<iendl ; 
     
    327327     oss<<"END SUBROUTINE cxios_get_"<<className<<"_"<<name<<iendl ; \ 
    328328   } 
    329    
     329 
    330330  macro(bool) 
    331331  macro(double) 
     
    333333 
    334334  #undef macro 
    335 */   
     335*/ 
    336336   template <class T> 
    337337   void CInterface::AttributeFortranInterfaceDeclaration(ostream& oss,const string& className,const string& name) 
     
    347347     if (!matchingTypeCFortran<T>()) oss<<getStrFortranType<T>()<<" "<<getStrFortranKindC<T>()<<" :: "<<name<<"_tmp"<<iendl ; 
    348348   } 
    349     
     349 
    350350   void CInterface::AttributeFortranInterfaceIsDefinedDeclaration(ostream& oss,const string& className,const string& name) 
    351351   { 
     
    353353     oss<<"LOGICAL(KIND=C_BOOL) :: "<<name<<"_tmp"<<iendl ; 
    354354   } 
    355      
     355 
    356356   template <> 
    357357   void CInterface::AttributeFortranInterfaceDeclaration<string>(ostream& oss,const string& className,const string& name) 
     
    359359     oss<<"CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: "<<name<<iendl ; 
    360360   } 
    361     
     361 
    362362   template <> 
    363363   void CInterface::AttributeFortranInterfaceGetDeclaration<string>(ostream& oss,const string& className,const string& name) 
     
    407407     oss<<getStrFortranType<T>()<<" "<<getStrFortranKind<T>() <<" , OPTIONAL, INTENT(OUT) :: "<<name<<"(:,:,:)"<<iendl ; \ 
    408408     if (!matchingTypeCFortran<T>()) oss<<getStrFortranType<T>()<<" "<<getStrFortranKindC<T>() <<" , ALLOCATABLE :: "<<name<<"_tmp(:,:,:)"<<iendl ; \ 
    409    }      
    410     
     409   } 
     410 
    411411  macro(bool) 
    412412  macro(double) 
     
    415415#undef macro 
    416416*/ 
    417     
     417 
    418418   template <class T> 
    419419   void CInterface::AttributeFortranInterfaceBody(ostream& oss,const string& className,const string& name) 
    420420   { 
    421421     string name_tmp=name+"__tmp" ; 
    422       
     422 
    423423     oss<<"IF (PRESENT("<<name<<"_)) THEN"<<iendl ; 
    424      if (!matchingTypeCFortran<T>())  
     424     if (!matchingTypeCFortran<T>()) 
    425425     { 
    426426       oss<<"  "<<name_tmp<<"="<<name<<"_"<<iendl ; 
     
    430430     oss<<"ENDIF"<<iendl ; 
    431431   } 
    432     
     432 
    433433   template <class T> 
    434434   void CInterface::AttributeFortranInterfaceGetBody(ostream& oss,const string& className,const string& name) 
    435435   { 
    436436     string name_tmp=name+"__tmp" ; 
    437       
     437 
    438438     oss<<"IF (PRESENT("<<name<<"_)) THEN"<<iendl ; 
    439      if (!matchingTypeCFortran<T>())  
     439     if (!matchingTypeCFortran<T>()) 
    440440     { 
    441441       oss<<"  CALL cxios_get_"<<className<<"_"<<name<<"("<<className<<"_hdl%daddr, "<<name_tmp<<")"<<iendl ; 
     
    449449   { 
    450450     string name_tmp=name+"__tmp" ; 
    451       
     451 
    452452     oss<<"IF (PRESENT("<<name<<"_)) THEN"<<iendl ; 
    453453     oss<<"  "<<name<<"__tmp=cxios_is_defined_"<<className<<"_"<<name<<"("<<className<<"_hdl%daddr)"<<iendl ; 
     
    455455     oss<<"ENDIF"<<iendl ; 
    456456   } 
    457       
     457 
    458458   template <> 
    459459   void CInterface::AttributeFortranInterfaceBody<string>(ostream& oss,const string& className,const string& name) 
     
    521521     oss<<"ENDIF"<<iendl ; \ 
    522522   } 
    523    
     523 
    524524  macro(bool) 
    525525  macro(double) 
     
    578578     oss<<"ENDIF"<<iendl ; \ 
    579579   } 
    580       
     580 
    581581  macro(bool) 
    582582  macro(double) 
     
    602602    oss<<"  CArray<"<<typeName<<",1> tmp("<<name<<",shape(extent1),neverDeleteData) ;"<<iendl ;\ 
    603603    oss<<"  "<<className<<"_hdl->"<<name<<".reference(tmp.copy());"<<iendl ;\ 
    604     oss<<"  "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;\ 
     604/*    oss<<"  "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;*/\ 
    605605    oss<<"   CTimer::get(\"XIOS\").suspend();"<<iendl ;\ 
    606606    oss<<"}"<<iendl ;\ 
     
    626626    oss<<"  CArray<"<<typeName<<",2> tmp("<<name<<",shape(extent1,extent2),neverDeleteData) ;"<<iendl ;\ 
    627627    oss<<"  "<<className<<"_hdl->"<<name<<".reference(tmp.copy());"<<iendl ;\ 
    628     oss<<"  "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;\ 
     628    /*oss<<"  "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;*/\ 
    629629    oss<<"   CTimer::get(\"XIOS\").suspend();"<<iendl ;\ 
    630630    oss<<"}"<<iendl ;\ 
     
    650650    oss<<"  CArray<"<<typeName<<",3> tmp("<<name<<",shape(extent1,extent2,extent3),neverDeleteData) ;"<<iendl ;\ 
    651651    oss<<"  "<<className<<"_hdl->"<<name<<".reference(tmp.copy());"<<iendl ;\ 
    652     oss<<"  "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;\ 
     652    /*oss<<"  "<<className<<"_hdl->sendAttributToServer("<<className<<"_hdl->"<<name<<");"<<iendl ;*/\ 
    653653    oss<<"   CTimer::get(\"XIOS\").suspend();"<<iendl ;\ 
    654654    oss<<"}"<<iendl ;\ 
     
    668668macro(int) 
    669669 
    670 #undef macro   
     670#undef macro 
    671671 
    672672// ///////////////////////////////////////////////// 
     
    675675 
    676676 
    677      
     677 
    678678#define macro(T)\ 
    679679   template <>\ 
     
    748748     oss<<iendl ;\ 
    749749   } 
    750    
     750 
    751751  macro(bool) 
    752752  macro(double) 
    753753  macro(int) 
    754    
     754 
    755755  #undef macro 
    756    
     756 
    757757 
    758758#define macro(T)\ 
     
    796796     oss<<getStrFortranType<T>()<<" "<<getStrFortranKind<T>() <<" , OPTIONAL, INTENT(OUT) :: "<<name<<"(:,:,:)"<<iendl ; \ 
    797797     if (!matchingTypeCFortran<T>()) oss<<getStrFortranType<T>()<<" "<<getStrFortranKindC<T>() <<" , ALLOCATABLE :: "<<name<<"_tmp(:,:,:)"<<iendl ; \ 
    798    }      
    799     
     798   } 
     799 
    800800  macro(bool) 
    801801  macro(double) 
     
    804804#undef macro 
    805805 
    806     
     806 
    807807 
    808808#define macro(T) \ 
     
    854854     oss<<"ENDIF"<<iendl ; \ 
    855855   } 
    856    
     856 
    857857  macro(bool) 
    858858  macro(double) 
     
    909909     oss<<"ENDIF"<<iendl ; \ 
    910910   } 
    911       
     911 
    912912  macro(bool) 
    913913  macro(double) 
Note: See TracChangeset for help on using the changeset viewer.