#ifndef __XIOS_GENERATE_INTERFACE_IMPL_HPP__ #define __XIOS_GENERATE_INTERFACE_IMPL_HPP__ #include "xmlioserver_spl.hpp" #include "generate_interface.hpp" #include "type_util.hpp" #include "indent.hpp" #include "enum.hpp" #include "array_new.hpp" #include "date.hpp" namespace xios { template<> string CInterface::getStrFortranType(void) {return string("INTEGER") ;} template<> string CInterface::getStrFortranType(void) {return string("LOGICAL") ;} template<> string CInterface::getStrFortranType(void) {return string("REAL") ;} template<> string CInterface::getStrFortranType(void) {return string("REAL") ;} template<> string CInterface::getStrFortranType(void) {return string("TYPE(txios(date))") ;} template<> string CInterface::getStrFortranType(void) {return string("TYPE(txios(duration))") ;} template<> string CInterface::getStrFortranKind(void) {return string("") ;} template<> string CInterface::getStrFortranKind(void) {return string("") ;} template<> string CInterface::getStrFortranKind(void) {return string("(KIND=8)") ;} template<> string CInterface::getStrFortranKind(void) {return string("(KIND=4)") ;} template<> string CInterface::getStrFortranKind(void) {return string("") ;} template<> string CInterface::getStrFortranKind(void) {return string("") ;} template<> string CInterface::getStrFortranKindC(void) {return string("(KIND=C_INT)") ;} template<> string CInterface::getStrFortranKindC(void) {return string("(KIND=C_BOOL)") ;} template<> string CInterface::getStrFortranKindC(void) {return string("(KIND=C_DOUBLE)") ;} template<> string CInterface::getStrFortranKindC(void) {return string("(KIND=C_FLOAT)") ;} template<> string CInterface::getStrFortranKindC(void) {return string("") ;} template<> string CInterface::getStrFortranKindC(void) {return string("") ;} template<> bool CInterface::matchingTypeCFortran(void) { return true ; } template<> bool CInterface::matchingTypeCFortran(void) { return false ;} template<> bool CInterface::matchingTypeCFortran(void) { return true; } template<> bool CInterface::matchingTypeCFortran(void) { return true; } template<> bool CInterface::matchingTypeCFortran(void) { return true; } template<> bool CInterface::matchingTypeCFortran(void) { return true; } // ///////////////////////////////////////////////// // // C Interface // // ///////////////////////////////////////////////// void CInterface::AttributeIsDefinedCInterface(ostream& oss, const string& className,const string& name) { oss<<"bool cxios_is_defined_"<"< void CInterface::AttributeCInterface(ostream& oss, const string& className,const string& name) { string typeName=getStrType() ; oss<<"void cxios_set_"<"<sendAttributToServer("<"<"< void CInterface::AttributeCInterface(ostream& oss, const string& className,const string& name) { oss<<"void cxios_set_"<"<sendAttributToServer("<"<"< void CInterface::AttributeCInterface(ostream& oss, const string& className,const string& name) { oss<<"void cxios_set_"<"<sendAttributToServer("<"<"<mask.getValue(), mask, extent1, extent2)) // ERROR("cxios_get_domain_mask(XDomainPtr domain_hdl, bool * mask, int extent1, int extent2)",<<"Output array size is not conform to array size attribut") ; template<> void CInterface::AttributeCInterface(ostream& oss, const string& className,const string& name) { oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, cxios_date " << name << "_c)" << iendl; oss << "{" << iendl; oss << " CTimer::get(\"XIOS\").resume();" << iendl; oss << " " << className << "_hdl->" << name << ".allocate();" << iendl; oss << " CDate& " << name <<" = " << className << "_hdl->" << name << ".get();" << iendl; oss << " " << name << ".setDate(" << name << "_c.year," << iendl; oss << " " << name << "_c.month," << iendl; oss << " " << name << "_c.day," << iendl; oss << " " << name << "_c.hour," << iendl; oss << " " << name << "_c.minute," << iendl; oss << " " << name << "_c.second);" << iendl; oss << " if (" << name << ".hasRelCalendar())" << iendl; oss << " " << name << ".checkDate();" << iendl; oss << " CTimer::get(\"XIOS\").suspend();" << iendl; oss << "}" << iendl; oss << iendl; oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, cxios_date* " << name << "_c)" << iendl; oss << "{" << iendl; oss << " CTimer::get(\"XIOS\").resume();" << iendl; oss << " CDate " << name <<" = " << className << "_hdl->" << name << ".getInheritedValue();" << iendl; oss << " " << name << "_c->year = " << name << ".getYear();" << iendl; oss << " " << name << "_c->month = " << name << ".getMonth();" << iendl; oss << " " << name << "_c->day = " << name << ".getDay();" << iendl; oss << " " << name << "_c->hour = " << name << ".getHour();" << iendl; oss << " " << name << "_c->minute = " << name << ".getMinute();" << iendl; oss << " " << name << "_c->second = " << name << ".getSecond();" << iendl; oss << " CTimer::get(\"XIOS\").suspend();" << iendl; oss << "}" << iendl; oss << iendl; } template<> void CInterface::AttributeCInterface(ostream& oss, const string& className,const string& name) { oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, cxios_duration " << name << "_c)" << iendl; oss << "{" << iendl; oss << " CTimer::get(\"XIOS\").resume();" << iendl; oss << " " << className << "_hdl->" << name << ".allocate();" << iendl; oss << " CDuration& " << name <<" = " << className << "_hdl->" << name << ".get();" << iendl; oss << " " << name << ".year = " << name << "_c.year;" << iendl; oss << " " << name << ".month = " << name << "_c.month;" << iendl; oss << " " << name << ".day = " << name << "_c.day;" << iendl; oss << " " << name << ".hour = " << name << "_c.hour;" << iendl; oss << " " << name << ".minute = " << name << "_c.minute;" << iendl; oss << " " << name << ".second = " << name << "_c.second;" << iendl; oss << " " << name << ".timestep = " << name << "_c.timestep;" << iendl; oss << " CTimer::get(\"XIOS\").suspend();" << iendl; oss << "}" << iendl; oss << iendl; oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, cxios_duration* " << name << "_c)" << iendl; oss << "{" << iendl; oss << " CTimer::get(\"XIOS\").resume();" << iendl; oss << " CDuration " << name <<" = " << className << "_hdl->" << name << ".getInheritedValue();" << iendl; oss << " " << name << "_c->year = " << name << ".year;" << iendl; oss << " " << name << "_c->month = " << name << ".month;" << iendl; oss << " " << name << "_c->day = " << name << ".day;" << iendl; oss << " " << name << "_c->hour = " << name << ".hour;" << iendl; oss << " " << name << "_c->minute = " << name << ".minute;" << iendl; oss << " " << name << "_c->second = " << name << ".second;" << iendl; oss << " " << name << "_c->timestep = " << name << ".timestep;" << iendl; oss << " CTimer::get(\"XIOS\").suspend();" << iendl; oss << "}" << iendl; oss << iendl; } /* #define macro(T) \ template <>\ void CInterface::AttributeCInterface(ostream& oss, const string& className,const string& name)\ {\ string typeName=getStrType() ;\ \ oss<<"void cxios_set_"<(boost::extents[extent1]));"<num_elements()]), array_tmp->data());"<"<sendAttributToServer("<"<"< \ void CInterface::AttributeCInterface(ostream& oss, const string& className,const string& name)\ {\ string typeName=getStrType() ;\ \ oss<<"void cxios_set_"<(boost::extents[extent1][extent2]));"<num_elements()]), array_tmp->data());"<"<sendAttributToServer("<"<"<\ void CInterface::AttributeCInterface(ostream& oss, const string& className,const string& name)\ {\ string typeName=getStrType() ;\ \ oss<<"void cxios_set_"<(boost::extents[extent1][extent2][extent3]));"<num_elements()]), array_tmp->data());"<"<sendAttributToServer("<"<"< void CInterface::AttributeFortran2003Interface(ostream& oss,const string& className,const string& name) { string fortranType=getStrFortranType() ; string fortranKindC=getStrFortranKindC() ; oss<<"SUBROUTINE cxios_set_"< void CInterface::AttributeFortran2003Interface(ostream& oss,const string& className,const string& name) { oss<<"SUBROUTINE cxios_set_"< void CInterface::AttributeFortran2003Interface(ostream& oss, const string& className, const string& name) { oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; oss << " USE ISO_C_BINDING" << iendl; oss << " USE IDATE" << iendl; oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; oss << " TYPE(txios(date)), VALUE :: " << name << iendl; oss << "END SUBROUTINE cxios_set_" << className << "_" << name << iendl; oss << iendl; oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; oss << " USE ISO_C_BINDING" << iendl; oss << " USE IDATE" << iendl; oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; oss << " TYPE(txios(date)) :: " << name << iendl; oss << "END SUBROUTINE cxios_get_" << className << "_" << name << iendl; oss << iendl; } template <> void CInterface::AttributeFortran2003Interface(ostream& oss, const string& className, const string& name) { oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; oss << " USE ISO_C_BINDING" << iendl; oss << " USE IDATE" << iendl; oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; oss << " TYPE(txios(duration)), VALUE :: " << name << iendl; oss << "END SUBROUTINE cxios_set_" << className << "_" << name << iendl; oss << iendl; oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; oss << " USE ISO_C_BINDING" << iendl; oss << " USE IDATE" << iendl; oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; oss << " TYPE(txios(duration)) :: " << name << iendl; oss << "END SUBROUTINE cxios_get_" << className << "_" << name << iendl; oss << iendl; } /* #define macro(T)\ template <>\ void CInterface::AttributeFortran2003Interface(ostream& oss,const string& className,const string& name) \ { \ string fortranType=getStrFortranType() ; \ string fortranKindC=getStrFortranKindC() ; \ \ oss<<"SUBROUTINE cxios_set_"< \ void CInterface::AttributeFortran2003Interface(ostream& oss,const string& className,const string& name) \ { \ string fortranType=getStrFortranType() ; \ string fortranKindC=getStrFortranKindC() ; \ \ oss<<"SUBROUTINE cxios_set_"< \ void CInterface::AttributeFortran2003Interface(ostream& oss,const string& className,const string& name) \ { \ string fortranType=getStrFortranType() ; \ string fortranKindC=getStrFortranKindC() ; \ \ oss<<"SUBROUTINE cxios_set_"< void CInterface::AttributeFortranInterfaceDeclaration(ostream& oss,const string& className,const string& name) { oss<()<<" "<< getStrFortranKind() <<" , OPTIONAL, INTENT(IN) :: "<()) oss<()<<" "<()<<" :: "< void CInterface::AttributeFortranInterfaceGetDeclaration(ostream& oss,const string& className,const string& name) { oss<()<<" "<< getStrFortranKind() <<" , OPTIONAL, INTENT(OUT) :: "<()) oss<()<<" "<()<<" :: "< void CInterface::AttributeFortranInterfaceDeclaration(ostream& oss,const string& className,const string& name) { oss<<"CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: "< void CInterface::AttributeFortranInterfaceGetDeclaration(ostream& oss,const string& className,const string& name) { oss<<"CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: "< \ void CInterface::AttributeFortranInterfaceDeclaration(ostream& oss,const string& className,const string& name) \ { \ oss<()<<" "<() <<" , OPTIONAL, INTENT(IN) :: "<()) oss<()<<" "<() <<" , ALLOCATABLE :: "< \ void CInterface::AttributeFortranInterfaceGetDeclaration(ostream& oss,const string& className,const string& name) \ { \ oss<()<<" "<() <<" , OPTIONAL, INTENT(OUT) :: "<()) oss<()<<" "<() <<" , ALLOCATABLE :: "< \ void CInterface::AttributeFortranInterfaceDeclaration(ostream& oss,const string& className,const string& name) \ { \ oss<()<<" "<() <<" , OPTIONAL, INTENT(IN) :: "<()) oss<()<<" "<() <<" , ALLOCATABLE :: "< \ void CInterface::AttributeFortranInterfaceGetDeclaration(ostream& oss,const string& className,const string& name) \ { \ oss<()<<" "<() <<" , OPTIONAL, INTENT(OUT) :: "<()) oss<()<<" "<() <<" , ALLOCATABLE :: "< \ void CInterface::AttributeFortranInterfaceDeclaration(ostream& oss,const string& className,const string& name) \ { \ oss<()<<" "<() <<" , OPTIONAL, INTENT(IN) :: "<()) oss<()<<" "<() <<" , ALLOCATABLE :: "< \ void CInterface::AttributeFortranInterfaceGetDeclaration(ostream& oss,const string& className,const string& name) \ { \ oss<()<<" "<() <<" , OPTIONAL, INTENT(OUT) :: "<()) oss<()<<" "<() <<" , ALLOCATABLE :: "< void CInterface::AttributeFortranInterfaceBody(ostream& oss,const string& className,const string& name) { string name_tmp=name+"__tmp" ; oss<<"IF (PRESENT("<()) { oss<<" "< void CInterface::AttributeFortranInterfaceGetBody(ostream& oss,const string& className,const string& name) { string name_tmp=name+"__tmp" ; oss<<"IF (PRESENT("<()) { oss<<" CALL cxios_get_"< void CInterface::AttributeFortranInterfaceBody(ostream& oss,const string& className,const string& name) { oss<<"IF (PRESENT("< void CInterface::AttributeFortranInterfaceGetBody(ostream& oss,const string& className,const string& name) { oss<<"IF (PRESENT("< \ void CInterface::AttributeFortranInterfaceBody< ARRAY(T,1) >(ostream& oss,const string& className,const string& name) \ { \ string name_tmp=name+"__tmp" ; \ \ oss<<"IF (PRESENT("<()) \ { \ oss<<" ALLOCATE("< \ void CInterface::AttributeFortranInterfaceBody< ARRAY(T,2) >(ostream& oss,const string& className,const string& name) \ { \ string name_tmp=name+"__tmp" ; \ \ oss<<"IF (PRESENT("<()) \ { \ oss<<" ALLOCATE("< \ void CInterface::AttributeFortranInterfaceBody< ARRAY(T,3) >(ostream& oss,const string& className,const string& name) \ { \ string name_tmp=name+"__tmp" ; \ \ oss<<"IF (PRESENT("<()) \ { \ oss<<" ALLOCATE("< \ void CInterface::AttributeFortranInterfaceGetBody< ARRAY(T,1) >(ostream& oss,const string& className,const string& name) \ { \ string name_tmp=name+"__tmp" ; \ \ oss<<"IF (PRESENT("<()) \ { \ oss<<" ALLOCATE("< \ void CInterface::AttributeFortranInterfaceGetBody< ARRAY(T,2) >(ostream& oss,const string& className,const string& name) \ { \ string name_tmp=name+"__tmp" ; \ \ oss<<"IF (PRESENT("<()) \ { \ oss<<" ALLOCATE("< \ void CInterface::AttributeFortranInterfaceGetBody< ARRAY(T,3) >(ostream& oss,const string& className,const string& name) \ { \ string name_tmp=name+"__tmp" ; \ \ oss<<"IF (PRESENT("<()) \ { \ oss<<" ALLOCATE("<\ void CInterface::AttributeCInterface >(ostream& oss, const string& className,const string& name)\ {\ string typeName=getStrType() ;\ \ oss<<"void cxios_set_"< tmp("<"<sendAttributToServer("<"< tmp("<"< \ void CInterface::AttributeCInterface >(ostream& oss, const string& className,const string& name)\ {\ string typeName=getStrType() ;\ \ oss<<"void cxios_set_"< tmp("<"<sendAttributToServer("<"< tmp("<"<\ void CInterface::AttributeCInterface >(ostream& oss, const string& className,const string& name)\ {\ string typeName=getStrType() ;\ \ oss<<"void cxios_set_"< tmp("<"<sendAttributToServer("<"< tmp("<"<\ void CInterface::AttributeFortran2003Interface >(ostream& oss,const string& className,const string& name) \ { \ string fortranType=getStrFortranType() ; \ string fortranKindC=getStrFortranKindC() ; \ \ oss<<"SUBROUTINE cxios_set_"< \ void CInterface::AttributeFortran2003Interface >(ostream& oss,const string& className,const string& name) \ { \ string fortranType=getStrFortranType() ; \ string fortranKindC=getStrFortranKindC() ; \ \ oss<<"SUBROUTINE cxios_set_"< \ void CInterface::AttributeFortran2003Interface >(ostream& oss,const string& className,const string& name) \ { \ string fortranType=getStrFortranType() ; \ string fortranKindC=getStrFortranKindC() ; \ \ oss<<"SUBROUTINE cxios_set_"< \ void CInterface::AttributeFortranInterfaceDeclaration >(ostream& oss,const string& className,const string& name) \ { \ oss<()<<" "<() <<" , OPTIONAL, INTENT(IN) :: "<()) oss<()<<" "<() <<" , ALLOCATABLE :: "< \ void CInterface::AttributeFortranInterfaceGetDeclaration >(ostream& oss,const string& className,const string& name) \ { \ oss<()<<" "<() <<" , OPTIONAL, INTENT(OUT) :: "<()) oss<()<<" "<() <<" , ALLOCATABLE :: "< \ void CInterface::AttributeFortranInterfaceDeclaration >(ostream& oss,const string& className,const string& name) \ { \ oss<()<<" "<() <<" , OPTIONAL, INTENT(IN) :: "<()) oss<()<<" "<() <<" , ALLOCATABLE :: "< \ void CInterface::AttributeFortranInterfaceGetDeclaration >(ostream& oss,const string& className,const string& name) \ { \ oss<()<<" "<() <<" , OPTIONAL, INTENT(OUT) :: "<()) oss<()<<" "<() <<" , ALLOCATABLE :: "< \ void CInterface::AttributeFortranInterfaceDeclaration >(ostream& oss,const string& className,const string& name) \ { \ oss<()<<" "<() <<" , OPTIONAL, INTENT(IN) :: "<()) oss<()<<" "<() <<" , ALLOCATABLE :: "< \ void CInterface::AttributeFortranInterfaceGetDeclaration >(ostream& oss,const string& className,const string& name) \ { \ oss<()<<" "<() <<" , OPTIONAL, INTENT(OUT) :: "<()) oss<()<<" "<() <<" , ALLOCATABLE :: "< \ void CInterface::AttributeFortranInterfaceBody< CArray >(ostream& oss,const string& className,const string& name) \ { \ string name_tmp=name+"__tmp" ; \ \ oss<<"IF (PRESENT("<()) \ { \ oss<<" ALLOCATE("< \ void CInterface::AttributeFortranInterfaceBody< CArray >(ostream& oss,const string& className,const string& name) \ { \ string name_tmp=name+"__tmp" ; \ \ oss<<"IF (PRESENT("<()) \ { \ oss<<" ALLOCATE("< \ void CInterface::AttributeFortranInterfaceBody< CArray >(ostream& oss,const string& className,const string& name) \ { \ string name_tmp=name+"__tmp" ; \ \ oss<<"IF (PRESENT("<()) \ { \ oss<<" ALLOCATE("< \ void CInterface::AttributeFortranInterfaceGetBody< CArray >(ostream& oss,const string& className,const string& name) \ { \ string name_tmp=name+"__tmp" ; \ \ oss<<"IF (PRESENT("<()) \ { \ oss<<" ALLOCATE("< \ void CInterface::AttributeFortranInterfaceGetBody< CArray >(ostream& oss,const string& className,const string& name) \ { \ string name_tmp=name+"__tmp" ; \ \ oss<<"IF (PRESENT("<()) \ { \ oss<<" ALLOCATE("< \ void CInterface::AttributeFortranInterfaceGetBody< CArray >(ostream& oss,const string& className,const string& name) \ { \ string name_tmp=name+"__tmp" ; \ \ oss<<"IF (PRESENT("<()) \ { \ oss<<" ALLOCATE("<