Changeset 509 for XIOS/trunk/src/generate_interface_impl.hpp
- Timestamp:
- 11/13/14 15:09:14 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/generate_interface_impl.hpp
r501 r509 10 10 11 11 namespace xios 12 { 12 { 13 13 template<> string CInterface::getStrFortranType<int>(void) {return string("INTEGER") ;} 14 14 template<> string CInterface::getStrFortranType<bool>(void) {return string("LOGICAL") ;} 15 15 template<> string CInterface::getStrFortranType<double>(void) {return string("REAL") ;} 16 16 template<> string CInterface::getStrFortranType<float>(void) {return string("REAL") ;} 17 17 18 18 template<> string CInterface::getStrFortranKind<int>(void) {return string("") ;} 19 19 template<> string CInterface::getStrFortranKind<bool>(void) {return string("") ;} 20 20 template<> string CInterface::getStrFortranKind<double>(void) {return string("(KIND=8)") ;} 21 21 template<> string CInterface::getStrFortranKind<float>(void) {return string("(KIND=4)") ;} 22 22 23 23 template<> string CInterface::getStrFortranKindC<int>(void) {return string("(KIND=C_INT)") ;} 24 24 template<> string CInterface::getStrFortranKindC<bool>(void) {return string("(KIND=C_BOOL)") ;} 25 25 template<> string CInterface::getStrFortranKindC<double>(void) {return string("(KIND=C_DOUBLE)") ;} 26 26 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 ;} 30 30 template<> bool CInterface::matchingTypeCFortran<double>(void) { return true; } 31 31 template<> bool CInterface::matchingTypeCFortran<float>(void) { return true; } 32 32 33 33 34 34 // ///////////////////////////////////////////////// … … 36 36 // ///////////////////////////////////////////////// 37 37 38 38 39 39 void CInterface::AttributeIsDefinedCInterface(ostream& oss, const string& className,const string& name) 40 40 { … … 47 47 oss<<iendl ; 48 48 } 49 49 50 50 template <class T> 51 51 void CInterface::AttributeCInterface(ostream& oss, const string& className,const string& name) 52 52 { 53 53 string typeName=getStrType<T>() ; 54 54 55 55 oss<<"void cxios_set_"<<className<<"_"<<name<<"("<<className<<"_Ptr "<<className<<"_hdl, "<< typeName<<" "<<name<<")"<<iendl ; 56 56 oss<<"{"<<iendl ; 57 57 oss<<" CTimer::get(\"XIOS\").resume();"<<iendl ; 58 58 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 ; 60 60 oss<<" CTimer::get(\"XIOS\").suspend();"<<iendl ; 61 61 oss<<"}"<<iendl ; 62 62 63 63 oss<<iendl ; 64 64 oss<<"void cxios_get_"<<className<<"_"<<name<<"("<<className<<"_Ptr "<<className<<"_hdl, "<< typeName<<"* "<<name<<")"<<iendl ; … … 68 68 oss<<iendl ; 69 69 } 70 71 70 71 72 72 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) 74 74 { 75 75 oss<<"void cxios_set_"<<className<<"_"<<name<<"("<<className<<"_Ptr "<<className<<"_hdl, const char * "<<name<<", int "<<name<<"_size)"<<iendl ; … … 79 79 oss<<" CTimer::get(\"XIOS\").resume();"<<iendl ; 80 80 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 ; 82 82 oss<<" CTimer::get(\"XIOS\").suspend();"<<iendl ; 83 83 oss<<"}"<<iendl ; 84 84 85 85 oss<<iendl ; 86 86 87 87 oss<<"void cxios_get_"<<className<<"_"<<name<<"("<<className<<"_Ptr "<<className<<"_hdl, char * "<<name<<", int "<<name<<"_size)"<<iendl ; 88 88 oss<<"{"<<iendl ; … … 94 94 oss<<"}"<<iendl ; 95 95 oss<<iendl ; 96 96 97 97 } 98 98 99 99 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) 101 101 { 102 102 oss<<"void cxios_set_"<<className<<"_"<<name<<"("<<className<<"_Ptr "<<className<<"_hdl, const char * "<<name<<", int "<<name<<"_size)"<<iendl ; … … 106 106 oss<<" CTimer::get(\"XIOS\").resume();"<<iendl ; 107 107 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 ; 109 109 oss<<" CTimer::get(\"XIOS\").suspend();"<<iendl ; 110 110 oss<<"}"<<iendl ; 111 111 112 112 oss<<iendl ; 113 113 114 114 oss<<"void cxios_get_"<<className<<"_"<<name<<"("<<className<<"_Ptr "<<className<<"_hdl, char * "<<name<<", int "<<name<<"_size)"<<iendl ; 115 115 oss<<"{"<<iendl ; … … 121 121 oss<<"}"<<iendl ; 122 122 oss<<iendl ; 123 123 124 124 } 125 125 // if (!array_copy(domain_hdl->mask.getValue(), mask, extent1, extent2)) … … 139 139 oss<<" std::copy("<<name<<", &("<<name<<"[array_tmp->num_elements()]), array_tmp->data());"<<iendl ;\ 140 140 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 ;\ 142 142 oss<<"}"<<iendl ;\ 143 143 oss<<iendl; \ … … 162 162 oss<<" std::copy("<<name<<", &("<<name<<"[array_tmp->num_elements()]), array_tmp->data());"<<iendl ;\ 163 163 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 ;\ 165 165 oss<<"}"<<iendl ;\ 166 166 oss<<iendl; \ … … 185 185 oss<<" std::copy("<<name<<", &("<<name<<"[array_tmp->num_elements()]), array_tmp->data());"<<iendl ;\ 186 186 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 ;\ 188 188 oss<<"}"<<iendl ;\ 189 189 oss<<iendl; \ … … 202 202 */ 203 203 204 #undef macro 204 #undef macro 205 205 206 206 // ///////////////////////////////////////////////// … … 213 213 oss<<" LOGICAL(kind=C_BOOL) :: cxios_is_defined_"<<className<<"_"<<name<<iendl; 214 214 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 218 218 template <class T> 219 219 void CInterface::AttributeFortran2003Interface(ostream& oss,const string& className,const string& name) … … 221 221 string fortranType=getStrFortranType<T>() ; 222 222 string fortranKindC=getStrFortranKindC<T>() ; 223 223 224 224 oss<<"SUBROUTINE cxios_set_"<<className<<"_"<<name<<"("<<className<<"_hdl, "<<name<<") BIND(C)"<<iendl ; 225 225 oss<<" USE ISO_C_BINDING"<<iendl ; … … 227 227 oss<<" "<<fortranType<<" "<<fortranKindC<<" , VALUE :: "<<name<<iendl ; 228 228 oss<<"END SUBROUTINE cxios_set_"<<className<<"_"<<name<<iendl ; 229 oss<<iendl ; 229 oss<<iendl ; 230 230 oss<<"SUBROUTINE cxios_get_"<<className<<"_"<<name<<"("<<className<<"_hdl, "<<name<<") BIND(C)"<<iendl ; 231 231 oss<<" USE ISO_C_BINDING"<<iendl ; … … 235 235 oss<<iendl ; 236 236 } 237 238 237 238 239 239 template <> 240 240 void CInterface::AttributeFortran2003Interface<string>(ostream& oss,const string& className,const string& name) 241 241 { 242 242 243 243 oss<<"SUBROUTINE cxios_set_"<<className<<"_"<<name<<"("<<className<<"_hdl, "<<name<<", "<<name<<"_size) BIND(C)"<<iendl ; 244 244 oss<<" USE ISO_C_BINDING"<<iendl ; … … 247 247 oss<<" INTEGER (kind = C_INT) , VALUE :: "<<name<<"_size"<<iendl ; 248 248 oss<<"END SUBROUTINE cxios_set_"<<className<<"_"<<name<<iendl ; 249 oss<<iendl ; 249 oss<<iendl ; 250 250 oss<<"SUBROUTINE cxios_get_"<<className<<"_"<<name<<"("<<className<<"_hdl, "<<name<<", "<<name<<"_size) BIND(C)"<<iendl ; 251 251 oss<<" USE ISO_C_BINDING"<<iendl ; … … 327 327 oss<<"END SUBROUTINE cxios_get_"<<className<<"_"<<name<<iendl ; \ 328 328 } 329 329 330 330 macro(bool) 331 331 macro(double) … … 333 333 334 334 #undef macro 335 */ 335 */ 336 336 template <class T> 337 337 void CInterface::AttributeFortranInterfaceDeclaration(ostream& oss,const string& className,const string& name) … … 347 347 if (!matchingTypeCFortran<T>()) oss<<getStrFortranType<T>()<<" "<<getStrFortranKindC<T>()<<" :: "<<name<<"_tmp"<<iendl ; 348 348 } 349 349 350 350 void CInterface::AttributeFortranInterfaceIsDefinedDeclaration(ostream& oss,const string& className,const string& name) 351 351 { … … 353 353 oss<<"LOGICAL(KIND=C_BOOL) :: "<<name<<"_tmp"<<iendl ; 354 354 } 355 355 356 356 template <> 357 357 void CInterface::AttributeFortranInterfaceDeclaration<string>(ostream& oss,const string& className,const string& name) … … 359 359 oss<<"CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: "<<name<<iendl ; 360 360 } 361 361 362 362 template <> 363 363 void CInterface::AttributeFortranInterfaceGetDeclaration<string>(ostream& oss,const string& className,const string& name) … … 407 407 oss<<getStrFortranType<T>()<<" "<<getStrFortranKind<T>() <<" , OPTIONAL, INTENT(OUT) :: "<<name<<"(:,:,:)"<<iendl ; \ 408 408 if (!matchingTypeCFortran<T>()) oss<<getStrFortranType<T>()<<" "<<getStrFortranKindC<T>() <<" , ALLOCATABLE :: "<<name<<"_tmp(:,:,:)"<<iendl ; \ 409 } 410 409 } 410 411 411 macro(bool) 412 412 macro(double) … … 415 415 #undef macro 416 416 */ 417 417 418 418 template <class T> 419 419 void CInterface::AttributeFortranInterfaceBody(ostream& oss,const string& className,const string& name) 420 420 { 421 421 string name_tmp=name+"__tmp" ; 422 422 423 423 oss<<"IF (PRESENT("<<name<<"_)) THEN"<<iendl ; 424 if (!matchingTypeCFortran<T>()) 424 if (!matchingTypeCFortran<T>()) 425 425 { 426 426 oss<<" "<<name_tmp<<"="<<name<<"_"<<iendl ; … … 430 430 oss<<"ENDIF"<<iendl ; 431 431 } 432 432 433 433 template <class T> 434 434 void CInterface::AttributeFortranInterfaceGetBody(ostream& oss,const string& className,const string& name) 435 435 { 436 436 string name_tmp=name+"__tmp" ; 437 437 438 438 oss<<"IF (PRESENT("<<name<<"_)) THEN"<<iendl ; 439 if (!matchingTypeCFortran<T>()) 439 if (!matchingTypeCFortran<T>()) 440 440 { 441 441 oss<<" CALL cxios_get_"<<className<<"_"<<name<<"("<<className<<"_hdl%daddr, "<<name_tmp<<")"<<iendl ; … … 449 449 { 450 450 string name_tmp=name+"__tmp" ; 451 451 452 452 oss<<"IF (PRESENT("<<name<<"_)) THEN"<<iendl ; 453 453 oss<<" "<<name<<"__tmp=cxios_is_defined_"<<className<<"_"<<name<<"("<<className<<"_hdl%daddr)"<<iendl ; … … 455 455 oss<<"ENDIF"<<iendl ; 456 456 } 457 457 458 458 template <> 459 459 void CInterface::AttributeFortranInterfaceBody<string>(ostream& oss,const string& className,const string& name) … … 521 521 oss<<"ENDIF"<<iendl ; \ 522 522 } 523 523 524 524 macro(bool) 525 525 macro(double) … … 578 578 oss<<"ENDIF"<<iendl ; \ 579 579 } 580 580 581 581 macro(bool) 582 582 macro(double) … … 602 602 oss<<" CArray<"<<typeName<<",1> tmp("<<name<<",shape(extent1),neverDeleteData) ;"<<iendl ;\ 603 603 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 ;*/\ 605 605 oss<<" CTimer::get(\"XIOS\").suspend();"<<iendl ;\ 606 606 oss<<"}"<<iendl ;\ … … 626 626 oss<<" CArray<"<<typeName<<",2> tmp("<<name<<",shape(extent1,extent2),neverDeleteData) ;"<<iendl ;\ 627 627 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 ;*/\ 629 629 oss<<" CTimer::get(\"XIOS\").suspend();"<<iendl ;\ 630 630 oss<<"}"<<iendl ;\ … … 650 650 oss<<" CArray<"<<typeName<<",3> tmp("<<name<<",shape(extent1,extent2,extent3),neverDeleteData) ;"<<iendl ;\ 651 651 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 ;*/\ 653 653 oss<<" CTimer::get(\"XIOS\").suspend();"<<iendl ;\ 654 654 oss<<"}"<<iendl ;\ … … 668 668 macro(int) 669 669 670 #undef macro 670 #undef macro 671 671 672 672 // ///////////////////////////////////////////////// … … 675 675 676 676 677 677 678 678 #define macro(T)\ 679 679 template <>\ … … 748 748 oss<<iendl ;\ 749 749 } 750 750 751 751 macro(bool) 752 752 macro(double) 753 753 macro(int) 754 754 755 755 #undef macro 756 756 757 757 758 758 #define macro(T)\ … … 796 796 oss<<getStrFortranType<T>()<<" "<<getStrFortranKind<T>() <<" , OPTIONAL, INTENT(OUT) :: "<<name<<"(:,:,:)"<<iendl ; \ 797 797 if (!matchingTypeCFortran<T>()) oss<<getStrFortranType<T>()<<" "<<getStrFortranKindC<T>() <<" , ALLOCATABLE :: "<<name<<"_tmp(:,:,:)"<<iendl ; \ 798 } 799 798 } 799 800 800 macro(bool) 801 801 macro(double) … … 804 804 #undef macro 805 805 806 806 807 807 808 808 #define macro(T) \ … … 854 854 oss<<"ENDIF"<<iendl ; \ 855 855 } 856 856 857 857 macro(bool) 858 858 macro(double) … … 909 909 oss<<"ENDIF"<<iendl ; \ 910 910 } 911 911 912 912 macro(bool) 913 913 macro(double)
Note: See TracChangeset
for help on using the changeset viewer.