Ignore:
Timestamp:
12/11/14 14:32:37 (9 years ago)
Author:
rlacroix
Message:

Add a new attribute type for durations and use it for the context's timestep.

Note that the "xios_time" type and the "xios_set_timestep" procedure have been removed from the Fortran interface. Instead, the "xios_duration" type and the "xios_get_context_attr"/"xios_set_context_attr" procedures should now be used to get/set the timestep.

File:
1 edited

Legend:

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

    r532 r537  
    1717  template<> string CInterface::getStrFortranType<float>(void) {return string("REAL") ;} 
    1818  template<> string CInterface::getStrFortranType<CDate>(void) {return string("TYPE(txios(date))") ;} 
     19  template<> string CInterface::getStrFortranType<CDuration>(void) {return string("TYPE(txios(duration))") ;} 
    1920 
    2021  template<> string CInterface::getStrFortranKind<int>(void) {return string("") ;} 
     
    2324  template<> string CInterface::getStrFortranKind<float>(void) {return string("(KIND=4)") ;} 
    2425  template<> string CInterface::getStrFortranKind<CDate>(void) {return string("") ;} 
     26  template<> string CInterface::getStrFortranKind<CDuration>(void) {return string("") ;} 
    2527 
    2628  template<> string CInterface::getStrFortranKindC<int>(void) {return string("(KIND=C_INT)") ;} 
     
    2931  template<> string CInterface::getStrFortranKindC<float>(void) {return string("(KIND=C_FLOAT)") ;} 
    3032  template<> string CInterface::getStrFortranKindC<CDate>(void) {return string("") ;} 
     33  template<> string CInterface::getStrFortranKindC<CDuration>(void) {return string("") ;} 
    3134 
    3235  template<> bool CInterface::matchingTypeCFortran<int>(void) { return true ; } 
     
    3538  template<> bool CInterface::matchingTypeCFortran<float>(void) { return true; } 
    3639  template<> bool CInterface::matchingTypeCFortran<CDate>(void) { return true; } 
     40  template<> bool CInterface::matchingTypeCFortran<CDuration>(void) { return true; } 
    3741 
    3842 
     
    167171  } 
    168172 
     173  template<> 
     174  void CInterface::AttributeCInterface<CDuration>(ostream& oss, const string& className,const string& name) 
     175  { 
     176    oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, cxios_duration " << name << "_c)" << iendl; 
     177    oss << "{" << iendl; 
     178    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; 
     179    oss << "  " << className << "_hdl->" << name << ".allocate();" << iendl; 
     180    oss << "  CDuration& " << name <<" = " << className << "_hdl->" << name << ".get();" << iendl; 
     181    oss << "  " << name << ".year = " << name << "_c.year;" << iendl; 
     182    oss << "  " << name << ".month = " << name << "_c.month;" << iendl; 
     183    oss << "  " << name << ".day = " << name << "_c.day;" << iendl; 
     184    oss << "  " << name << ".hour = " << name << "_c.hour;" << iendl; 
     185    oss << "  " << name << ".minute = " << name << "_c.minute;" << iendl; 
     186    oss << "  " << name << ".second = " << name << "_c.second;" << iendl; 
     187    oss << "  " << name << ".timestep = " << name << "_c.timestep;" << iendl; 
     188    oss << "  CTimer::get(\"XIOS\").suspend();" << iendl; 
     189    oss << "}" << iendl; 
     190 
     191    oss << iendl; 
     192 
     193    oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, cxios_duration* " << name << "_c)" << iendl; 
     194    oss << "{" << iendl; 
     195    oss << "  CTimer::get(\"XIOS\").resume();" << iendl; 
     196    oss << "  CDuration " << name <<" = " << className << "_hdl->" << name << ".getInheritedValue();" << iendl; 
     197    oss << "  " << name << "_c->year = " << name << ".year;" << iendl; 
     198    oss << "  " << name << "_c->month = " << name << ".month;" << iendl; 
     199    oss << "  " << name << "_c->day = " << name << ".day;" << iendl; 
     200    oss << "  " << name << "_c->hour = " << name << ".hour;" << iendl; 
     201    oss << "  " << name << "_c->minute = " << name << ".minute;" << iendl; 
     202    oss << "  " << name << "_c->second = " << name << ".second;" << iendl; 
     203    oss << "  " << name << "_c->timestep = " << name << ".timestep;" << iendl; 
     204    oss << "  CTimer::get(\"XIOS\").suspend();" << iendl; 
     205    oss << "}" << iendl; 
     206    oss << iendl; 
     207  } 
     208 
    169209/* 
    170210#define macro(T) \ 
     
    305345    oss << "  USE IDATE" << iendl; 
    306346    oss << "  INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; 
    307     oss << "  TYPE(xios_date), VALUE :: " << name << iendl; 
     347    oss << "  TYPE(txios(date)), VALUE :: " << name << iendl; 
    308348    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << iendl; 
    309349    oss << iendl; 
     
    313353    oss << "  INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; 
    314354    oss << "  TYPE(txios(date)) :: " << name << iendl; 
     355    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << iendl; 
     356    oss << iendl; 
     357  } 
     358 
     359  template <> 
     360  void CInterface::AttributeFortran2003Interface<CDuration>(ostream& oss, const string& className, const string& name) 
     361  { 
     362    oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; 
     363    oss << "  USE ISO_C_BINDING" << iendl; 
     364    oss << "  USE IDATE" << iendl; 
     365    oss << "  INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; 
     366    oss << "  TYPE(txios(duration)), VALUE :: " << name << iendl; 
     367    oss << "END SUBROUTINE cxios_set_" << className << "_" << name << iendl; 
     368    oss << iendl; 
     369    oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; 
     370    oss << "  USE ISO_C_BINDING" << iendl; 
     371    oss << "  USE IDATE" << iendl; 
     372    oss << "  INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; 
     373    oss << "  TYPE(txios(duration)) :: " << name << iendl; 
    315374    oss << "END SUBROUTINE cxios_get_" << className << "_" << name << iendl; 
    316375    oss << iendl; 
Note: See TracChangeset for help on using the changeset viewer.