Ignore:
Timestamp:
06/06/17 17:58:16 (7 years ago)
Author:
oabramkina
Message:

Two server levels: merging with trunk r1137.
There are bugs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_olga/src/generate_interface_impl.hpp

    r966 r1158  
    547547#undef macro 
    548548 
     549#define macro(N,EXTENT)\ 
     550  template <>\ 
     551  void CInterface::AttributeCInterface<CArray<StdString,N> >(ostream& oss, const string& className, const string& name)\ 
     552  { \ 
     553    oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << "char* " << name <<", int str_len, int* str_size, int* extent)" << iendl; \ 
     554    oss << "{" << iendl; \ 
     555    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \ 
     556    oss << "  "<<className<<"_hdl->"<<name<<".resize(shape("<<EXTENT<<"));"<<iendl;\ 
     557    oss << "  Array<StdString,"<<#N<<">::iterator it, itb="<<className<<"_hdl->"<<name<<".begin(), ite="<<className<<"_hdl->"<<name<<".end() ;"<<iendl ;\ 
     558    oss << "  int i, n ;"<< iendl; \ 
     559    oss << "  for(it=itb, i=0, n=0 ; it!=ite ; ++it,n+=str_len,++i) *it=StdString(&"<<name<<"[n],str_size[i]) ;"<<iendl ;\ 
     560    oss << "  CTimer::get(\"XIOS\").suspend();" << iendl; \ 
     561    oss << "}" << std::endl; \ 
     562    oss << iendl; \ 
     563    oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << "char* " << name << ", int str_size, int* extent)" << iendl; \ 
     564    oss << "{" << iendl; \ 
     565    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; \ 
     566    oss << "  Array<StdString,"<<#N<<">::const_iterator it, itb="<<className<<"_hdl->"<<name<<".getInheritedValue().begin(), ite="<<className<<"_hdl->"<<name<<".getInheritedValue().end() ;" << iendl; \ 
     567    oss << "  int n ;"<< iendl; \ 
     568    oss << "  for(it=itb, n=0 ; it!=ite ; ++it, n+=str_size) it->copy(&"<<name<<"[n],it->size()) ; "<< iendl; \ 
     569    oss << "  CTimer::get(\"XIOS\").suspend();" << iendl; \ 
     570    oss << "}" << std::endl; \ 
     571  } 
     572 
     573macro(1,"extent[0]") 
     574macro(2,"extent[0],extent[1]") 
     575macro(3,"extent[0],extent[1],extent[2]") 
     576macro(4,"extent[0],extent[1],extent[2],extent[3]") 
     577macro(5,"extent[0],extent[1],extent[2],extent[3],extent[4]") 
     578macro(6,"extent[0],extent[1],extent[2],extent[3],extent[4],extent[5]") 
     579macro(7,"extent[0],extent[1],extent[2],extent[3],extent[4],extent[5],extent[6]") 
     580#undef macro 
    549581// ///////////////////////////////////////////////// 
    550582// //          Fortran 2003 Interface             // 
     
    705737  #undef macro 
    706738 
     739#define macro(T)\ 
     740  template <>\ 
     741  void CInterface::AttributeFortran2003Interface<CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\ 
     742  {\ 
     743    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", str_len, str_size, extent) BIND(C)" << iendl; \ 
     744    oss << "  USE ISO_C_BINDING" << iendl; \ 
     745    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \ 
     746    oss << "  CHARACTER (KIND=C_CHAR), DIMENSION(*)    :: " << name << iendl; \ 
     747    oss << "  INTEGER (kind = C_INT), VALUE            :: str_len" << iendl; \ 
     748    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: str_size" << iendl; \ 
     749    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \ 
     750    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ 
     751    oss << iendl; \ 
     752    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", str_size, extent) BIND(C)" << iendl; \ 
     753    oss << "  USE ISO_C_BINDING" << iendl; \ 
     754    oss << "  INTEGER (kind = C_INTPTR_T), VALUE       :: " << className << "_hdl" << iendl; \ 
     755    oss << "  CHARACTER (KIND=C_CHAR), DIMENSION(*)    :: " << name << iendl; \ 
     756    oss << "  INTEGER (kind = C_INT), VALUE            :: str_size" << iendl; \ 
     757    oss << "  INTEGER (kind = C_INT), DIMENSION(*)     :: extent" << iendl; \ 
     758    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ 
     759  } 
     760  macro(1) 
     761  macro(2) 
     762  macro(3) 
     763  macro(4) 
     764  macro(5) 
     765  macro(6) 
     766  macro(7) 
     767 
     768#undef macro 
     769 
    707770#define macro(T) \ 
    708771  template <> \ 
     
    808871 
    809872#undef macro 
     873 
     874#define macro(T,EXTENT)\ 
     875  template <> \ 
     876  void CInterface::AttributeFortranInterfaceDeclaration<CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\ 
     877  {\ 
     878    oss << "CHARACTER(len=*) , OPTIONAL, INTENT(IN) :: " << name << "("<<EXTENT<<")"; \ 
     879  }\ 
     880\ 
     881  template <>\  
     882  void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\ 
     883  {\ 
     884    oss << "CHARACTER(len=*) , OPTIONAL, INTENT(OUT) :: " << name << "("<<EXTENT<<")"; \ 
     885  } 
     886  macro(1,":") 
     887  macro(2,":,:") 
     888  macro(3,":,:,:") 
     889  macro(4,":,:,:,:") 
     890  macro(5,":,:,:,:,:") 
     891  macro(6,":,:,:,:,:,:") 
     892  macro(7,":,:,:,:,:,:,:") 
     893 
     894#undef macro 
     895 
     896 
     897 
     898 
     899   
    810900 
    811901#define macro(T) \ 
     
    9471037#undef macro 
    9481038 
     1039#define macro(T)\ 
     1040  template <>\ 
     1041  void CInterface::AttributeFortranInterfaceBody< CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\ 
     1042  {\ 
     1043     oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ 
     1044     oss << "  CALL cxios_set_" << className << "_" << name << " &" << iendl; \ 
     1045     oss << "(" << className << "_hdl%daddr, " << name <<"_, LEN("<<name<<"_), LEN_TRIM("<<name<< "_), SHAPE(" << name << "_))" << iendl; \ 
     1046     oss << "ENDIF"; \ 
     1047  } 
     1048 
     1049  macro(1) 
     1050  macro(2) 
     1051#undef macro 
     1052 
    9491053#define macro(T) \ 
    9501054  template <>  \ 
     
    10841188 
    10851189#undef macro 
     1190 
     1191#define macro(T)\ 
     1192  template <> \ 
     1193  void CInterface::AttributeFortranInterfaceGetBody< CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\ 
     1194  {\ 
     1195    oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ 
     1196    oss << "  CALL cxios_get_" << className << "_" << name << " &" << iendl; \ 
     1197    oss << "(" << className << "_hdl%daddr, " << name << "_, LEN("<<name<<"_), SHAPE(" << name << "_))" << iendl; \ 
     1198    oss << "ENDIF"; \ 
     1199  } 
     1200  macro(1) 
     1201  macro(2) 
     1202  macro(3) 
     1203  macro(4) 
     1204  macro(5) 
     1205  macro(6) 
     1206  macro(7) 
     1207 
     1208#undef macro 
     1209   
    10861210} 
    10871211#endif 
Note: See TracChangeset for help on using the changeset viewer.