[313] | 1 | #ifndef __XIOS_GENERATE_INTERFACE_IMPL_HPP__ |
---|
| 2 | #define __XIOS_GENERATE_INTERFACE_IMPL_HPP__ |
---|
| 3 | |
---|
[591] | 4 | #include "xios_spl.hpp" |
---|
[313] | 5 | #include "generate_interface.hpp" |
---|
| 6 | #include "type_util.hpp" |
---|
| 7 | #include "indent.hpp" |
---|
[369] | 8 | #include "enum.hpp" |
---|
| 9 | #include "array_new.hpp" |
---|
[532] | 10 | #include "date.hpp" |
---|
[313] | 11 | |
---|
[335] | 12 | namespace xios |
---|
[509] | 13 | { |
---|
[581] | 14 | template<> string CInterface::getStrFortranType<int>(void) { return string("INTEGER"); } |
---|
| 15 | template<> string CInterface::getStrFortranType<bool>(void) { return string("LOGICAL"); } |
---|
| 16 | template<> string CInterface::getStrFortranType<double>(void) { return string("REAL"); } |
---|
| 17 | template<> string CInterface::getStrFortranType<float>(void) { return string("REAL"); } |
---|
| 18 | template<> string CInterface::getStrFortranType<CDate>(void) { return string("TYPE(txios(date))"); } |
---|
| 19 | template<> string CInterface::getStrFortranType<CDuration>(void) { return string("TYPE(txios(duration))"); } |
---|
[509] | 20 | |
---|
[581] | 21 | template<> string CInterface::getStrFortranKind<int>(void) { return string(""); } |
---|
| 22 | template<> string CInterface::getStrFortranKind<bool>(void) { return string(""); } |
---|
| 23 | template<> string CInterface::getStrFortranKind<double>(void) { return string("(KIND=8)"); } |
---|
| 24 | template<> string CInterface::getStrFortranKind<float>(void) { return string("(KIND=4)"); } |
---|
| 25 | template<> string CInterface::getStrFortranKind<CDate>(void) { return string(""); } |
---|
| 26 | template<> string CInterface::getStrFortranKind<CDuration>(void) { return string(""); } |
---|
[509] | 27 | |
---|
[581] | 28 | template<> string CInterface::getStrFortranKindC<int>(void) { return string("(KIND=C_INT)"); } |
---|
| 29 | template<> string CInterface::getStrFortranKindC<bool>(void) { return string("(KIND=C_BOOL)"); } |
---|
| 30 | template<> string CInterface::getStrFortranKindC<double>(void) { return string("(KIND=C_DOUBLE)"); } |
---|
| 31 | template<> string CInterface::getStrFortranKindC<float>(void) { return string("(KIND=C_FLOAT)"); } |
---|
| 32 | template<> string CInterface::getStrFortranKindC<CDate>(void) { return string(""); } |
---|
| 33 | template<> string CInterface::getStrFortranKindC<CDuration>(void) { return string(""); } |
---|
[509] | 34 | |
---|
[581] | 35 | template<> bool CInterface::matchingTypeCFortran<int>(void) { return true; } |
---|
| 36 | template<> bool CInterface::matchingTypeCFortran<bool>(void) { return false; } |
---|
[352] | 37 | template<> bool CInterface::matchingTypeCFortran<double>(void) { return true; } |
---|
| 38 | template<> bool CInterface::matchingTypeCFortran<float>(void) { return true; } |
---|
[532] | 39 | template<> bool CInterface::matchingTypeCFortran<CDate>(void) { return true; } |
---|
[537] | 40 | template<> bool CInterface::matchingTypeCFortran<CDuration>(void) { return true; } |
---|
[313] | 41 | |
---|
| 42 | // ///////////////////////////////////////////////// |
---|
| 43 | // // C Interface // |
---|
| 44 | // ///////////////////////////////////////////////// |
---|
| 45 | |
---|
[581] | 46 | void CInterface::AttributeIsDefinedCInterface(ostream& oss, const string& className, const string& name) |
---|
[432] | 47 | { |
---|
[581] | 48 | oss << "bool cxios_is_defined_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl)" << iendl; |
---|
| 49 | oss << "{" << iendl; |
---|
| 50 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; |
---|
| 51 | oss << " bool isDefined = " << className << "_hdl->" << name << ".hasInheritedValue();" << iendl; |
---|
| 52 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; |
---|
| 53 | oss << " return isDefined;" << iendl; |
---|
| 54 | oss << "}" << std::endl; |
---|
[432] | 55 | } |
---|
[509] | 56 | |
---|
[313] | 57 | template <class T> |
---|
[581] | 58 | void CInterface::AttributeCInterface(ostream& oss, const string& className, const string& name) |
---|
[313] | 59 | { |
---|
[581] | 60 | string typeName = getStrType<T>(); |
---|
[509] | 61 | |
---|
[581] | 62 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << " " << name << ")" << iendl; |
---|
| 63 | oss << "{" << iendl; |
---|
| 64 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; |
---|
| 65 | oss << " " << className << "_hdl->" << name << ".setValue(" << name << ");" << iendl; |
---|
| 66 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; |
---|
| 67 | oss << "}" << std::endl; |
---|
[509] | 68 | |
---|
[581] | 69 | oss << iendl; |
---|
| 70 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ")" << iendl; |
---|
| 71 | oss << "{" << iendl; |
---|
| 72 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; |
---|
| 73 | oss << " *" << name << " = " << className << "_hdl->" << name << ".getInheritedValue();" << iendl; |
---|
| 74 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; |
---|
| 75 | oss << "}" << std::endl; |
---|
[313] | 76 | } |
---|
[509] | 77 | |
---|
[313] | 78 | template<> |
---|
[581] | 79 | void CInterface::AttributeCInterface<string>(ostream& oss, const string& className, const string& name) |
---|
[313] | 80 | { |
---|
[581] | 81 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, const char * " << name << ", int " << name << "_size)" << iendl; |
---|
| 82 | oss << "{" << iendl; |
---|
| 83 | oss << " std::string " << name << "_str;" << iendl; |
---|
| 84 | oss << " if (!cstr2string(" << name << ", " << name << "_size, " << name << "_str)) return;" << iendl; |
---|
| 85 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; |
---|
| 86 | oss << " " << className << "_hdl->" << name << ".setValue(" << name << "_str);" << iendl; |
---|
| 87 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; |
---|
| 88 | oss << "}" << std::endl; |
---|
[509] | 89 | |
---|
[581] | 90 | oss << iendl; |
---|
[509] | 91 | |
---|
[581] | 92 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, char * " << name << ", int " << name << "_size)" << iendl; |
---|
| 93 | oss << "{" << iendl; |
---|
| 94 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; |
---|
| 95 | oss << " if (!string_copy(" << className << "_hdl->" << name << ".getInheritedValue(), " << name << ", " << name << "_size))" << iendl; |
---|
| 96 | oss << " ERROR(\"void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, char * " << name << ", int " |
---|
[672] | 97 | << name << "_size)\", << \"Input string is too short\");" << iendl; |
---|
[581] | 98 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; |
---|
| 99 | oss << "}" << std::endl; |
---|
[313] | 100 | } |
---|
| 101 | |
---|
[369] | 102 | template<> |
---|
[581] | 103 | void CInterface::AttributeCInterface<CEnumBase>(ostream& oss, const string& className, const string& name) |
---|
[369] | 104 | { |
---|
[581] | 105 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, const char * " << name << ", int " << name << "_size)" << iendl; |
---|
| 106 | oss << "{" << iendl; |
---|
| 107 | oss << " std::string " << name << "_str;" << iendl; |
---|
| 108 | oss << " if (!cstr2string(" << name << ", " << name << "_size, " << name << "_str)) return;" << iendl; |
---|
| 109 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; |
---|
| 110 | oss << " " << className << "_hdl->" << name << ".fromString(" << name << "_str);" << iendl; |
---|
| 111 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; |
---|
| 112 | oss << "}" << std::endl; |
---|
[509] | 113 | |
---|
[581] | 114 | oss << iendl; |
---|
[509] | 115 | |
---|
[581] | 116 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, char * " << name << ", int " << name << "_size)" << iendl; |
---|
| 117 | oss << "{" << iendl; |
---|
| 118 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; |
---|
| 119 | oss << " if (!string_copy(" << className << "_hdl->" << name << ".getInheritedStringValue(), " << name << ", " << name << "_size))" << iendl; |
---|
| 120 | oss << " ERROR(\"void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, char * " << name << ", int " |
---|
[672] | 121 | << name << "_size)\", << \"Input string is too short\");" << iendl; |
---|
[581] | 122 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; |
---|
| 123 | oss << "}" << std::endl; |
---|
[369] | 124 | } |
---|
[313] | 125 | |
---|
[532] | 126 | template<> |
---|
[581] | 127 | void CInterface::AttributeCInterface<CDate>(ostream& oss, const string& className, const string& name) |
---|
[532] | 128 | { |
---|
| 129 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, cxios_date " << name << "_c)" << iendl; |
---|
| 130 | oss << "{" << iendl; |
---|
| 131 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; |
---|
| 132 | oss << " " << className << "_hdl->" << name << ".allocate();" << iendl; |
---|
[581] | 133 | oss << " CDate& " << name << " = " << className << "_hdl->" << name << ".get();" << iendl; |
---|
[532] | 134 | oss << " " << name << ".setDate(" << name << "_c.year," << iendl; |
---|
| 135 | oss << " " << name << "_c.month," << iendl; |
---|
| 136 | oss << " " << name << "_c.day," << iendl; |
---|
| 137 | oss << " " << name << "_c.hour," << iendl; |
---|
| 138 | oss << " " << name << "_c.minute," << iendl; |
---|
| 139 | oss << " " << name << "_c.second);" << iendl; |
---|
| 140 | oss << " if (" << name << ".hasRelCalendar())" << iendl; |
---|
| 141 | oss << " " << name << ".checkDate();" << iendl; |
---|
| 142 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; |
---|
[581] | 143 | oss << "}" << std::endl; |
---|
[532] | 144 | |
---|
| 145 | oss << iendl; |
---|
| 146 | |
---|
| 147 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, cxios_date* " << name << "_c)" << iendl; |
---|
| 148 | oss << "{" << iendl; |
---|
| 149 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; |
---|
[581] | 150 | oss << " CDate " << name << " = " << className << "_hdl->" << name << ".getInheritedValue();" << iendl; |
---|
[532] | 151 | oss << " " << name << "_c->year = " << name << ".getYear();" << iendl; |
---|
| 152 | oss << " " << name << "_c->month = " << name << ".getMonth();" << iendl; |
---|
| 153 | oss << " " << name << "_c->day = " << name << ".getDay();" << iendl; |
---|
| 154 | oss << " " << name << "_c->hour = " << name << ".getHour();" << iendl; |
---|
| 155 | oss << " " << name << "_c->minute = " << name << ".getMinute();" << iendl; |
---|
| 156 | oss << " " << name << "_c->second = " << name << ".getSecond();" << iendl; |
---|
| 157 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; |
---|
[581] | 158 | oss << "}" << std::endl; |
---|
[532] | 159 | } |
---|
| 160 | |
---|
[537] | 161 | template<> |
---|
[581] | 162 | void CInterface::AttributeCInterface<CDuration>(ostream& oss, const string& className, const string& name) |
---|
[537] | 163 | { |
---|
| 164 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, cxios_duration " << name << "_c)" << iendl; |
---|
| 165 | oss << "{" << iendl; |
---|
| 166 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; |
---|
| 167 | oss << " " << className << "_hdl->" << name << ".allocate();" << iendl; |
---|
[581] | 168 | oss << " CDuration& " << name << " = " << className << "_hdl->" << name << ".get();" << iendl; |
---|
[537] | 169 | oss << " " << name << ".year = " << name << "_c.year;" << iendl; |
---|
| 170 | oss << " " << name << ".month = " << name << "_c.month;" << iendl; |
---|
| 171 | oss << " " << name << ".day = " << name << "_c.day;" << iendl; |
---|
| 172 | oss << " " << name << ".hour = " << name << "_c.hour;" << iendl; |
---|
| 173 | oss << " " << name << ".minute = " << name << "_c.minute;" << iendl; |
---|
| 174 | oss << " " << name << ".second = " << name << "_c.second;" << iendl; |
---|
| 175 | oss << " " << name << ".timestep = " << name << "_c.timestep;" << iendl; |
---|
| 176 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; |
---|
[581] | 177 | oss << "}" << std::endl; |
---|
[537] | 178 | |
---|
| 179 | oss << iendl; |
---|
| 180 | |
---|
| 181 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, cxios_duration* " << name << "_c)" << iendl; |
---|
| 182 | oss << "{" << iendl; |
---|
| 183 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; |
---|
[581] | 184 | oss << " CDuration " << name << " = " << className << "_hdl->" << name << ".getInheritedValue();" << iendl; |
---|
[537] | 185 | oss << " " << name << "_c->year = " << name << ".year;" << iendl; |
---|
| 186 | oss << " " << name << "_c->month = " << name << ".month;" << iendl; |
---|
| 187 | oss << " " << name << "_c->day = " << name << ".day;" << iendl; |
---|
| 188 | oss << " " << name << "_c->hour = " << name << ".hour;" << iendl; |
---|
| 189 | oss << " " << name << "_c->minute = " << name << ".minute;" << iendl; |
---|
| 190 | oss << " " << name << "_c->second = " << name << ".second;" << iendl; |
---|
| 191 | oss << " " << name << "_c->timestep = " << name << ".timestep;" << iendl; |
---|
| 192 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; |
---|
[581] | 193 | oss << "}" << std::endl; |
---|
[537] | 194 | } |
---|
| 195 | |
---|
[509] | 196 | #undef macro |
---|
[313] | 197 | |
---|
| 198 | // ///////////////////////////////////////////////// |
---|
| 199 | // // Fortran 2003 Interface // |
---|
| 200 | // ///////////////////////////////////////////////// |
---|
[509] | 201 | |
---|
[672] | 202 | void CInterface::AttributeIsDefinedFortran2003Interface(ostream& oss, const string& className, const string& name) |
---|
| 203 | { |
---|
| 204 | oss << "FUNCTION cxios_is_defined_" << className << "_" << name << "(" << className << "_hdl) BIND(C)" << iendl; |
---|
| 205 | oss << " USE ISO_C_BINDING" << iendl; |
---|
| 206 | oss << " LOGICAL(kind=C_BOOL) :: cxios_is_defined_" << className << "_" << name << iendl; |
---|
| 207 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; |
---|
| 208 | oss << "END FUNCTION cxios_is_defined_" << className << "_" << name << std::endl; |
---|
| 209 | } |
---|
[509] | 210 | |
---|
[672] | 211 | template <class T> |
---|
| 212 | void CInterface::AttributeFortran2003Interface(ostream& oss, const string& className, const string& name) |
---|
| 213 | { |
---|
| 214 | string fortranType=getStrFortranType<T>(); |
---|
| 215 | string fortranKindC=getStrFortranKindC<T>(); |
---|
[509] | 216 | |
---|
[672] | 217 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; |
---|
| 218 | oss << " USE ISO_C_BINDING" << iendl; |
---|
| 219 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; |
---|
| 220 | oss << " " << fortranType << " " << fortranKindC << " , VALUE :: " << name << iendl; |
---|
| 221 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; |
---|
| 222 | oss << iendl; |
---|
| 223 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; |
---|
| 224 | oss << " USE ISO_C_BINDING" << iendl; |
---|
| 225 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; |
---|
| 226 | oss << " " << fortranType << " " << fortranKindC << " :: " << name << iendl; |
---|
| 227 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; |
---|
| 228 | } |
---|
[369] | 229 | |
---|
[532] | 230 | template <> |
---|
[672] | 231 | void CInterface::AttributeFortran2003Interface<string>(ostream& oss, const string& className, const string& name) |
---|
| 232 | { |
---|
| 233 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", " << name << "_size) BIND(C)" << iendl; |
---|
| 234 | oss << " USE ISO_C_BINDING" << iendl; |
---|
| 235 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; |
---|
| 236 | oss << " CHARACTER(kind = C_CHAR) , DIMENSION(*) :: " << name << iendl; |
---|
| 237 | oss << " INTEGER (kind = C_INT) , VALUE :: " << name << "_size" << iendl; |
---|
| 238 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; |
---|
| 239 | oss << iendl; |
---|
| 240 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", " << name << "_size) BIND(C)" << iendl; |
---|
| 241 | oss << " USE ISO_C_BINDING" << iendl; |
---|
| 242 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; |
---|
| 243 | oss << " CHARACTER(kind = C_CHAR) , DIMENSION(*) :: " << name << iendl; |
---|
| 244 | oss << " INTEGER (kind = C_INT) , VALUE :: " << name << "_size" << iendl; |
---|
| 245 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; |
---|
| 246 | } |
---|
| 247 | |
---|
| 248 | template <> |
---|
[532] | 249 | void CInterface::AttributeFortran2003Interface<CDate>(ostream& oss, const string& className, const string& name) |
---|
| 250 | { |
---|
| 251 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; |
---|
| 252 | oss << " USE ISO_C_BINDING" << iendl; |
---|
| 253 | oss << " USE IDATE" << iendl; |
---|
| 254 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; |
---|
[537] | 255 | oss << " TYPE(txios(date)), VALUE :: " << name << iendl; |
---|
[581] | 256 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; |
---|
[532] | 257 | oss << iendl; |
---|
| 258 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; |
---|
| 259 | oss << " USE ISO_C_BINDING" << iendl; |
---|
| 260 | oss << " USE IDATE" << iendl; |
---|
| 261 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; |
---|
| 262 | oss << " TYPE(txios(date)) :: " << name << iendl; |
---|
[581] | 263 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; |
---|
[532] | 264 | } |
---|
| 265 | |
---|
[537] | 266 | template <> |
---|
| 267 | void CInterface::AttributeFortran2003Interface<CDuration>(ostream& oss, const string& className, const string& name) |
---|
| 268 | { |
---|
| 269 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; |
---|
| 270 | oss << " USE ISO_C_BINDING" << iendl; |
---|
[545] | 271 | oss << " USE IDURATION" << iendl; |
---|
[537] | 272 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; |
---|
| 273 | oss << " TYPE(txios(duration)), VALUE :: " << name << iendl; |
---|
[581] | 274 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; |
---|
[537] | 275 | oss << iendl; |
---|
| 276 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; |
---|
| 277 | oss << " USE ISO_C_BINDING" << iendl; |
---|
[545] | 278 | oss << " USE IDURATION" << iendl; |
---|
[537] | 279 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; |
---|
| 280 | oss << " TYPE(txios(duration)) :: " << name << iendl; |
---|
[581] | 281 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; |
---|
[537] | 282 | } |
---|
| 283 | |
---|
[672] | 284 | template <class T> |
---|
| 285 | void CInterface::AttributeFortranInterfaceDeclaration(ostream& oss, const string& className, const string& name) |
---|
| 286 | { |
---|
| 287 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name; |
---|
| 288 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " :: " << name << "_tmp"; |
---|
| 289 | } |
---|
[509] | 290 | |
---|
[672] | 291 | template <class T> |
---|
| 292 | void CInterface::AttributeFortranInterfaceGetDeclaration(ostream& oss, const string& className, const string& name) |
---|
| 293 | { |
---|
| 294 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name; |
---|
| 295 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " :: " << name << "_tmp"; |
---|
| 296 | } |
---|
[369] | 297 | |
---|
[672] | 298 | void CInterface::AttributeFortranInterfaceIsDefinedDeclaration(ostream& oss, const string& className, const string& name) |
---|
| 299 | { |
---|
| 300 | oss << "LOGICAL, OPTIONAL, INTENT(OUT) :: " << name << iendl; |
---|
| 301 | oss << "LOGICAL(KIND=C_BOOL) :: " << name << "_tmp"; |
---|
| 302 | } |
---|
[313] | 303 | |
---|
[672] | 304 | template <> |
---|
| 305 | void CInterface::AttributeFortranInterfaceDeclaration<string>(ostream& oss, const string& className, const string& name) |
---|
| 306 | { |
---|
| 307 | oss << "CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: " << name; |
---|
| 308 | } |
---|
[509] | 309 | |
---|
[672] | 310 | template <> |
---|
| 311 | void CInterface::AttributeFortranInterfaceGetDeclaration<string>(ostream& oss, const string& className, const string& name) |
---|
| 312 | { |
---|
| 313 | oss << "CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: " << name; |
---|
| 314 | } |
---|
[509] | 315 | |
---|
[672] | 316 | template <class T> |
---|
| 317 | void CInterface::AttributeFortranInterfaceBody(ostream& oss, const string& className, const string& name) |
---|
| 318 | { |
---|
| 319 | string name_tmp=name+"__tmp"; |
---|
[509] | 320 | |
---|
[672] | 321 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; |
---|
| 322 | if (!matchingTypeCFortran<T>()) |
---|
| 323 | { |
---|
| 324 | oss << " " << name_tmp << " = " << name << "_" << iendl; |
---|
| 325 | oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ")" << iendl; |
---|
| 326 | } |
---|
| 327 | else oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_)" << iendl; |
---|
| 328 | oss << "ENDIF"; |
---|
| 329 | } |
---|
[313] | 330 | |
---|
[672] | 331 | template <class T> |
---|
| 332 | void CInterface::AttributeFortranInterfaceGetBody(ostream& oss, const string& className, const string& name) |
---|
| 333 | { |
---|
| 334 | string name_tmp=name+"__tmp"; |
---|
[509] | 335 | |
---|
[672] | 336 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; |
---|
| 337 | if (!matchingTypeCFortran<T>()) |
---|
| 338 | { |
---|
| 339 | oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ")" << iendl; |
---|
| 340 | oss << " " << name << "_ = " << name_tmp << iendl; |
---|
| 341 | } |
---|
| 342 | else oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_)" << iendl; |
---|
| 343 | oss << "ENDIF"; |
---|
| 344 | } |
---|
[313] | 345 | |
---|
[672] | 346 | void CInterface::AttributeFortranInterfaceIsDefinedBody(ostream& oss, const string& className, const string& name) |
---|
| 347 | { |
---|
| 348 | string name_tmp=name+"__tmp"; |
---|
[509] | 349 | |
---|
[672] | 350 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; |
---|
| 351 | oss << " " << name << "__tmp = cxios_is_defined_" << className << "_" << name << "(" << className << "_hdl%daddr)" << iendl; |
---|
| 352 | oss << " " << name << "_ = " << name_tmp << iendl; |
---|
| 353 | oss << "ENDIF"; |
---|
| 354 | } |
---|
[509] | 355 | |
---|
[672] | 356 | template <> |
---|
| 357 | void CInterface::AttributeFortranInterfaceBody<string>(ostream& oss, const string& className, const string& name) |
---|
| 358 | { |
---|
| 359 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; |
---|
| 360 | oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, len(" << name << "_))" << iendl; |
---|
| 361 | oss << "ENDIF"; |
---|
| 362 | } |
---|
[509] | 363 | |
---|
[672] | 364 | template <> |
---|
| 365 | void CInterface::AttributeFortranInterfaceGetBody<string>(ostream& oss, const string& className, const string& name) |
---|
| 366 | { |
---|
| 367 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; |
---|
| 368 | oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, len(" << name << "_))" << iendl; |
---|
| 369 | oss << "ENDIF"; |
---|
| 370 | } |
---|
[509] | 371 | |
---|
[369] | 372 | // declaration for CArray |
---|
| 373 | |
---|
| 374 | #define macro(T) \ |
---|
[581] | 375 | template <> \ |
---|
| 376 | void CInterface::AttributeCInterface<CArray<T,1> >(ostream& oss, const string& className, const string& name) \ |
---|
| 377 | { \ |
---|
| 378 | string typeName=getStrType<T>(); \ |
---|
[369] | 379 | \ |
---|
[674] | 380 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
[581] | 381 | oss << "{" << iendl; \ |
---|
| 382 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
[674] | 383 | oss << " CArray<" << typeName << ",1> tmp(" << name << ", shape(extent[0]), neverDeleteData);" << iendl; \ |
---|
[581] | 384 | oss << " " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \ |
---|
| 385 | /*oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \ |
---|
| 386 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 387 | oss << "}" << std::endl; \ |
---|
| 388 | oss << iendl; \ |
---|
[674] | 389 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
[581] | 390 | oss << "{" << iendl; \ |
---|
| 391 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
[674] | 392 | oss << " CArray<" << typeName << ",1> tmp(" << name << ", shape(extent[0]), neverDeleteData);" << iendl; \ |
---|
[581] | 393 | oss << " tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \ |
---|
| 394 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 395 | oss << "}" << std::endl; \ |
---|
| 396 | } \ |
---|
[369] | 397 | \ |
---|
| 398 | template <> \ |
---|
[581] | 399 | void CInterface::AttributeCInterface<CArray<T,2> >(ostream& oss, const string& className, const string& name) \ |
---|
| 400 | { \ |
---|
| 401 | string typeName=getStrType<T>(); \ |
---|
[369] | 402 | \ |
---|
[674] | 403 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
[581] | 404 | oss << "{" << iendl; \ |
---|
| 405 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
[674] | 406 | oss << " CArray<" << typeName << ",2> tmp(" << name << ", shape(extent[0], extent[1]), neverDeleteData);" << iendl; \ |
---|
[581] | 407 | oss << " " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \ |
---|
| 408 | /*oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \ |
---|
| 409 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 410 | oss << "}" << std::endl; \ |
---|
| 411 | oss << iendl; \ |
---|
[674] | 412 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
[581] | 413 | oss << "{" << iendl; \ |
---|
| 414 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
[674] | 415 | oss << " CArray<" << typeName << ",2> tmp(" << name << ", shape(extent[0], extent[1]), neverDeleteData);" << iendl; \ |
---|
[581] | 416 | oss << " tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \ |
---|
| 417 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 418 | oss << "}" << std::endl; \ |
---|
| 419 | } \ |
---|
[369] | 420 | \ |
---|
[581] | 421 | template <> \ |
---|
| 422 | void CInterface::AttributeCInterface<CArray<T,3> >(ostream& oss, const string& className, const string& name) \ |
---|
| 423 | { \ |
---|
| 424 | string typeName=getStrType<T>(); \ |
---|
[369] | 425 | \ |
---|
[674] | 426 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
[581] | 427 | oss << "{" << iendl; \ |
---|
| 428 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
[674] | 429 | oss << " CArray<" << typeName << ",3> tmp(" << name << ", shape(extent[0], extent[1], extent[2]), neverDeleteData);" << iendl; \ |
---|
[581] | 430 | oss << " " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \ |
---|
| 431 | /*oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \ |
---|
| 432 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 433 | oss << "}" << std::endl; \ |
---|
| 434 | oss << iendl; \ |
---|
[674] | 435 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
[581] | 436 | oss << "{" << iendl; \ |
---|
| 437 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
[674] | 438 | oss << " CArray<" << typeName << ",3> tmp(" << name << ", shape(extent[0], extent[1], extent[2]), neverDeleteData);" << iendl; \ |
---|
[581] | 439 | oss << " tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \ |
---|
| 440 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 441 | oss << "}" << std::endl; \ |
---|
[932] | 442 | } \ |
---|
| 443 | \ |
---|
| 444 | template <> \ |
---|
| 445 | void CInterface::AttributeCInterface<CArray<T,4> >(ostream& oss, const string& className, const string& name) \ |
---|
| 446 | { \ |
---|
| 447 | string typeName=getStrType<T>(); \ |
---|
| 448 | \ |
---|
| 449 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
| 450 | oss << "{" << iendl; \ |
---|
| 451 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
| 452 | oss << " CArray<" << typeName << ",4> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3]), neverDeleteData);" << iendl; \ |
---|
| 453 | oss << " " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \ |
---|
| 454 | /*oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \ |
---|
| 455 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 456 | oss << "}" << std::endl; \ |
---|
| 457 | oss << iendl; \ |
---|
| 458 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
| 459 | oss << "{" << iendl; \ |
---|
| 460 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
| 461 | oss << " CArray<" << typeName << ",4> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3]), neverDeleteData);" << iendl; \ |
---|
| 462 | oss << " tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \ |
---|
| 463 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 464 | oss << "}" << std::endl; \ |
---|
| 465 | } \ |
---|
| 466 | \ |
---|
| 467 | template <> \ |
---|
| 468 | void CInterface::AttributeCInterface<CArray<T,5> >(ostream& oss, const string& className, const string& name) \ |
---|
| 469 | { \ |
---|
| 470 | string typeName=getStrType<T>(); \ |
---|
| 471 | \ |
---|
| 472 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
| 473 | oss << "{" << iendl; \ |
---|
| 474 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
| 475 | oss << " CArray<" << typeName << ",5> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3], extent[4]), neverDeleteData);" << iendl; \ |
---|
| 476 | oss << " " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \ |
---|
| 477 | /*oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \ |
---|
| 478 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 479 | oss << "}" << std::endl; \ |
---|
| 480 | oss << iendl; \ |
---|
| 481 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
| 482 | oss << "{" << iendl; \ |
---|
| 483 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
| 484 | oss << " CArray<" << typeName << ",5> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3], extent[4]), neverDeleteData);" << iendl; \ |
---|
| 485 | oss << " tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \ |
---|
| 486 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 487 | oss << "}" << std::endl; \ |
---|
| 488 | } \ |
---|
| 489 | \ |
---|
| 490 | template <> \ |
---|
| 491 | void CInterface::AttributeCInterface<CArray<T,6> >(ostream& oss, const string& className, const string& name) \ |
---|
| 492 | { \ |
---|
| 493 | string typeName=getStrType<T>(); \ |
---|
| 494 | \ |
---|
| 495 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
| 496 | oss << "{" << iendl; \ |
---|
| 497 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
| 498 | oss << " CArray<" << typeName << ",6> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3], extent[4], extent[5]), neverDeleteData);" << iendl; \ |
---|
| 499 | oss << " " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \ |
---|
| 500 | /*oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \ |
---|
| 501 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 502 | oss << "}" << std::endl; \ |
---|
| 503 | oss << iendl; \ |
---|
| 504 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
| 505 | oss << "{" << iendl; \ |
---|
| 506 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
| 507 | oss << " CArray<" << typeName << ",6> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3], extent[4], extent[5]), neverDeleteData);" << iendl; \ |
---|
| 508 | oss << " tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \ |
---|
| 509 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 510 | oss << "}" << std::endl; \ |
---|
| 511 | } \ |
---|
| 512 | \ |
---|
| 513 | template <> \ |
---|
| 514 | void CInterface::AttributeCInterface<CArray<T,7> >(ostream& oss, const string& className, const string& name) \ |
---|
| 515 | { \ |
---|
| 516 | string typeName=getStrType<T>(); \ |
---|
| 517 | \ |
---|
| 518 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
| 519 | oss << "{" << iendl; \ |
---|
| 520 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
| 521 | oss << " CArray<" << typeName << ",7> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3], extent[4], extent[5], extent[6]), neverDeleteData);" << iendl; \ |
---|
| 522 | oss << " " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \ |
---|
| 523 | /*oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \ |
---|
| 524 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 525 | oss << "}" << std::endl; \ |
---|
| 526 | oss << iendl; \ |
---|
| 527 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
| 528 | oss << "{" << iendl; \ |
---|
| 529 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
| 530 | oss << " CArray<" << typeName << ",7> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3], extent[4], extent[5], extent[6]), neverDeleteData);" << iendl; \ |
---|
| 531 | oss << " tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \ |
---|
| 532 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 533 | oss << "}" << std::endl; \ |
---|
[369] | 534 | } |
---|
| 535 | |
---|
| 536 | macro(bool) |
---|
| 537 | macro(double) |
---|
| 538 | macro(int) |
---|
| 539 | |
---|
[509] | 540 | #undef macro |
---|
[369] | 541 | |
---|
| 542 | // ///////////////////////////////////////////////// |
---|
| 543 | // // Fortran 2003 Interface // |
---|
| 544 | // ///////////////////////////////////////////////// |
---|
| 545 | |
---|
[581] | 546 | #define macro(T) \ |
---|
[672] | 547 | template <> \ |
---|
| 548 | void CInterface::AttributeFortran2003Interface<CArray<T,1> >(ostream& oss, const string& className, const string& name) \ |
---|
| 549 | { \ |
---|
| 550 | string fortranType=getStrFortranType<T>(); \ |
---|
| 551 | string fortranKindC=getStrFortranKindC<T>(); \ |
---|
[369] | 552 | \ |
---|
[674] | 553 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
[672] | 554 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 555 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 556 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
[674] | 557 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
[672] | 558 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ |
---|
| 559 | oss << iendl; \ |
---|
[674] | 560 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
[672] | 561 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 562 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 563 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
[674] | 564 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
[672] | 565 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ |
---|
| 566 | } \ |
---|
[369] | 567 | \ |
---|
[672] | 568 | template <> \ |
---|
| 569 | void CInterface::AttributeFortran2003Interface<CArray<T,2> >(ostream& oss, const string& className, const string& name) \ |
---|
| 570 | { \ |
---|
| 571 | string fortranType=getStrFortranType<T>(); \ |
---|
| 572 | string fortranKindC=getStrFortranKindC<T>(); \ |
---|
[369] | 573 | \ |
---|
[674] | 574 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
[672] | 575 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 576 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 577 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
[674] | 578 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
[672] | 579 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ |
---|
| 580 | oss << iendl; \ |
---|
[674] | 581 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
[672] | 582 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 583 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 584 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
[674] | 585 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
[672] | 586 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ |
---|
| 587 | } \ |
---|
[932] | 588 | \ |
---|
[672] | 589 | template <> \ |
---|
| 590 | void CInterface::AttributeFortran2003Interface<CArray<T,3> >(ostream& oss, const string& className, const string& name) \ |
---|
| 591 | { \ |
---|
| 592 | string fortranType=getStrFortranType<T>(); \ |
---|
| 593 | string fortranKindC=getStrFortranKindC<T>(); \ |
---|
[369] | 594 | \ |
---|
[674] | 595 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
[672] | 596 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 597 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 598 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
[674] | 599 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
[672] | 600 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ |
---|
| 601 | oss << iendl; \ |
---|
[674] | 602 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
[672] | 603 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 604 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 605 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
[674] | 606 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
[672] | 607 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ |
---|
[932] | 608 | } \ |
---|
| 609 | \ |
---|
| 610 | template <> \ |
---|
| 611 | void CInterface::AttributeFortran2003Interface<CArray<T,4> >(ostream& oss, const string& className, const string& name) \ |
---|
| 612 | { \ |
---|
| 613 | string fortranType=getStrFortranType<T>(); \ |
---|
| 614 | string fortranKindC=getStrFortranKindC<T>(); \ |
---|
| 615 | \ |
---|
| 616 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
| 617 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 618 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 619 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
| 620 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
| 621 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ |
---|
| 622 | oss << iendl; \ |
---|
| 623 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
| 624 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 625 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 626 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
| 627 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
| 628 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ |
---|
| 629 | }\ |
---|
| 630 | \ |
---|
| 631 | template <> \ |
---|
| 632 | void CInterface::AttributeFortran2003Interface<CArray<T,5> >(ostream& oss, const string& className, const string& name) \ |
---|
| 633 | { \ |
---|
| 634 | string fortranType=getStrFortranType<T>(); \ |
---|
| 635 | string fortranKindC=getStrFortranKindC<T>(); \ |
---|
| 636 | \ |
---|
| 637 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
| 638 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 639 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 640 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
| 641 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
| 642 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ |
---|
| 643 | oss << iendl; \ |
---|
| 644 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
| 645 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 646 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 647 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
| 648 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
| 649 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ |
---|
| 650 | }\ |
---|
| 651 | \ |
---|
| 652 | template <> \ |
---|
| 653 | void CInterface::AttributeFortran2003Interface<CArray<T,6> >(ostream& oss, const string& className, const string& name) \ |
---|
| 654 | { \ |
---|
| 655 | string fortranType=getStrFortranType<T>(); \ |
---|
| 656 | string fortranKindC=getStrFortranKindC<T>(); \ |
---|
| 657 | \ |
---|
| 658 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
| 659 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 660 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 661 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
| 662 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
| 663 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ |
---|
| 664 | oss << iendl; \ |
---|
| 665 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
| 666 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 667 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 668 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
| 669 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
| 670 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ |
---|
| 671 | }\ |
---|
| 672 | \ |
---|
| 673 | template <> \ |
---|
| 674 | void CInterface::AttributeFortran2003Interface<CArray<T,7> >(ostream& oss, const string& className, const string& name) \ |
---|
| 675 | { \ |
---|
| 676 | string fortranType=getStrFortranType<T>(); \ |
---|
| 677 | string fortranKindC=getStrFortranKindC<T>(); \ |
---|
| 678 | \ |
---|
| 679 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
| 680 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 681 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 682 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
| 683 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
| 684 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ |
---|
| 685 | oss << iendl; \ |
---|
| 686 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
| 687 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 688 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 689 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
| 690 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
| 691 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ |
---|
[672] | 692 | } |
---|
[509] | 693 | |
---|
[369] | 694 | macro(bool) |
---|
| 695 | macro(double) |
---|
| 696 | macro(int) |
---|
[509] | 697 | |
---|
[369] | 698 | #undef macro |
---|
| 699 | |
---|
[581] | 700 | #define macro(T) \ |
---|
[672] | 701 | template <> \ |
---|
| 702 | void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,1> >(ostream& oss, const string& className, const string& name) \ |
---|
| 703 | { \ |
---|
| 704 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:)"; \ |
---|
| 705 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:)"; \ |
---|
| 706 | } \ |
---|
| 707 | template <> \ |
---|
| 708 | void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,1> >(ostream& oss, const string& className, const string& name) \ |
---|
| 709 | { \ |
---|
| 710 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:)"; \ |
---|
| 711 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:)"; \ |
---|
| 712 | } \ |
---|
[369] | 713 | \ |
---|
[672] | 714 | template <> \ |
---|
| 715 | void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,2> >(ostream& oss, const string& className, const string& name) \ |
---|
| 716 | { \ |
---|
| 717 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:)"; \ |
---|
| 718 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:)"; \ |
---|
| 719 | } \ |
---|
[369] | 720 | \ |
---|
[672] | 721 | template <> \ |
---|
| 722 | void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,2> >(ostream& oss, const string& className, const string& name) \ |
---|
| 723 | { \ |
---|
| 724 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:)"; \ |
---|
| 725 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:)"; \ |
---|
| 726 | } \ |
---|
[369] | 727 | \ |
---|
[672] | 728 | template <> \ |
---|
| 729 | void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,3> >(ostream& oss, const string& className, const string& name) \ |
---|
| 730 | { \ |
---|
| 731 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:)"; \ |
---|
| 732 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:)"; \ |
---|
| 733 | } \ |
---|
[369] | 734 | \ |
---|
[672] | 735 | template <> \ |
---|
| 736 | void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,3> >(ostream& oss, const string& className, const string& name) \ |
---|
| 737 | { \ |
---|
| 738 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:)"; \ |
---|
| 739 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:)"; \ |
---|
[932] | 740 | }\ |
---|
| 741 | \ |
---|
| 742 | template <> \ |
---|
| 743 | void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,4> >(ostream& oss, const string& className, const string& name) \ |
---|
| 744 | { \ |
---|
| 745 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:,:)"; \ |
---|
| 746 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:)"; \ |
---|
| 747 | } \ |
---|
| 748 | \ |
---|
| 749 | template <> \ |
---|
| 750 | void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,4> >(ostream& oss, const string& className, const string& name) \ |
---|
| 751 | { \ |
---|
| 752 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:,:)"; \ |
---|
| 753 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:)"; \ |
---|
| 754 | }\ |
---|
| 755 | \ |
---|
| 756 | template <> \ |
---|
| 757 | void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,5> >(ostream& oss, const string& className, const string& name) \ |
---|
| 758 | { \ |
---|
| 759 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:,:,:)"; \ |
---|
| 760 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:)"; \ |
---|
| 761 | } \ |
---|
| 762 | \ |
---|
| 763 | template <> \ |
---|
| 764 | void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,5> >(ostream& oss, const string& className, const string& name) \ |
---|
| 765 | { \ |
---|
| 766 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:,:,:)"; \ |
---|
| 767 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:)"; \ |
---|
| 768 | }\ |
---|
| 769 | \ |
---|
| 770 | template <> \ |
---|
| 771 | void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,6> >(ostream& oss, const string& className, const string& name) \ |
---|
| 772 | { \ |
---|
| 773 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:,:,:,:)"; \ |
---|
| 774 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:,:)"; \ |
---|
| 775 | } \ |
---|
| 776 | \ |
---|
| 777 | template <> \ |
---|
| 778 | void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,6> >(ostream& oss, const string& className, const string& name) \ |
---|
| 779 | { \ |
---|
| 780 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:,:,:,:)"; \ |
---|
| 781 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:,:)"; \ |
---|
| 782 | }\ |
---|
| 783 | \ |
---|
| 784 | template <> \ |
---|
| 785 | void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,7> >(ostream& oss, const string& className, const string& name) \ |
---|
| 786 | { \ |
---|
| 787 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:,:,:,:,:)"; \ |
---|
| 788 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:,:,:)"; \ |
---|
| 789 | } \ |
---|
| 790 | \ |
---|
| 791 | template <> \ |
---|
| 792 | void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,7> >(ostream& oss, const string& className, const string& name) \ |
---|
| 793 | { \ |
---|
| 794 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:,:,:,:,:)"; \ |
---|
| 795 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:,:,:)"; \ |
---|
[672] | 796 | } |
---|
[509] | 797 | |
---|
[369] | 798 | macro(bool) |
---|
| 799 | macro(double) |
---|
| 800 | macro(int) |
---|
| 801 | |
---|
| 802 | #undef macro |
---|
| 803 | |
---|
| 804 | #define macro(T) \ |
---|
[672] | 805 | template <> \ |
---|
| 806 | void CInterface::AttributeFortranInterfaceBody< CArray<T,1> >(ostream& oss, const string& className, const string& name) \ |
---|
| 807 | { \ |
---|
| 808 | string name_tmp=name+"__tmp"; \ |
---|
[369] | 809 | \ |
---|
[672] | 810 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 811 | if (!matchingTypeCFortran<T>()) \ |
---|
| 812 | { \ |
---|
[674] | 813 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1)))" << iendl; \ |
---|
[672] | 814 | oss << " " << name_tmp << " = " << name << "_" << iendl; \ |
---|
[674] | 815 | oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
[672] | 816 | } \ |
---|
[674] | 817 | else oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; \ |
---|
[672] | 818 | oss << "ENDIF"; \ |
---|
| 819 | } \ |
---|
[369] | 820 | \ |
---|
[672] | 821 | template <> \ |
---|
| 822 | void CInterface::AttributeFortranInterfaceBody< CArray<T,2> >(ostream& oss, const string& className, const string& name) \ |
---|
| 823 | { \ |
---|
| 824 | string name_tmp=name+"__tmp"; \ |
---|
[369] | 825 | \ |
---|
[672] | 826 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 827 | if (!matchingTypeCFortran<T>()) \ |
---|
| 828 | { \ |
---|
[674] | 829 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2)))" << iendl; \ |
---|
[672] | 830 | oss << " " << name_tmp << " = " << name << "_" << iendl; \ |
---|
[674] | 831 | oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
[672] | 832 | } \ |
---|
[674] | 833 | else oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; \ |
---|
[672] | 834 | oss << "ENDIF"; \ |
---|
| 835 | } \ |
---|
[932] | 836 | \ |
---|
[672] | 837 | template <> \ |
---|
| 838 | void CInterface::AttributeFortranInterfaceBody< CArray<T,3> >(ostream& oss, const string& className, const string& name) \ |
---|
| 839 | { \ |
---|
| 840 | string name_tmp=name+"__tmp"; \ |
---|
[369] | 841 | \ |
---|
[672] | 842 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 843 | if (!matchingTypeCFortran<T>()) \ |
---|
| 844 | { \ |
---|
[674] | 845 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3)))" << iendl; \ |
---|
[672] | 846 | oss << " " << name_tmp << " = " << name << "_" << iendl; \ |
---|
[674] | 847 | oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
[672] | 848 | } \ |
---|
[674] | 849 | else oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; \ |
---|
[672] | 850 | oss << "ENDIF"; \ |
---|
[932] | 851 | }\ |
---|
| 852 | \ |
---|
| 853 | template <> \ |
---|
| 854 | void CInterface::AttributeFortranInterfaceBody< CArray<T,4> >(ostream& oss, const string& className, const string& name) \ |
---|
| 855 | { \ |
---|
| 856 | string name_tmp=name+"__tmp"; \ |
---|
| 857 | \ |
---|
| 858 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 859 | if (!matchingTypeCFortran<T>()) \ |
---|
| 860 | { \ |
---|
| 861 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), SIZE(" << name << "_,4)))" << iendl; \ |
---|
| 862 | oss << " " << name_tmp << " = " << name << "_" << iendl; \ |
---|
| 863 | oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
| 864 | } \ |
---|
| 865 | else oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; \ |
---|
| 866 | oss << "ENDIF"; \ |
---|
| 867 | }\ |
---|
| 868 | \ |
---|
| 869 | template <> \ |
---|
| 870 | void CInterface::AttributeFortranInterfaceBody< CArray<T,5> >(ostream& oss, const string& className, const string& name) \ |
---|
| 871 | { \ |
---|
| 872 | string name_tmp=name+"__tmp"; \ |
---|
| 873 | \ |
---|
| 874 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 875 | if (!matchingTypeCFortran<T>()) \ |
---|
| 876 | { \ |
---|
| 877 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), SIZE(" << name << "_,4), SIZE(" << name << "_,5)))" << iendl; \ |
---|
| 878 | oss << " " << name_tmp << " = " << name << "_" << iendl; \ |
---|
| 879 | oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
| 880 | } \ |
---|
| 881 | else oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; \ |
---|
| 882 | oss << "ENDIF"; \ |
---|
| 883 | }\ |
---|
| 884 | \ |
---|
| 885 | template <> \ |
---|
| 886 | void CInterface::AttributeFortranInterfaceBody< CArray<T,6> >(ostream& oss, const string& className, const string& name) \ |
---|
| 887 | { \ |
---|
| 888 | string name_tmp=name+"__tmp"; \ |
---|
| 889 | \ |
---|
| 890 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 891 | if (!matchingTypeCFortran<T>()) \ |
---|
| 892 | { \ |
---|
| 893 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), SIZE(" << name << "_,4), SIZE(" << name << "_,5), SIZE(" << name << "_,6)))" << iendl; \ |
---|
| 894 | oss << " " << name_tmp << " = " << name << "_" << iendl; \ |
---|
| 895 | oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
| 896 | } \ |
---|
| 897 | else oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; \ |
---|
| 898 | oss << "ENDIF"; \ |
---|
| 899 | }\ |
---|
| 900 | \ |
---|
| 901 | template <> \ |
---|
| 902 | void CInterface::AttributeFortranInterfaceBody< CArray<T,7> >(ostream& oss, const string& className, const string& name) \ |
---|
| 903 | { \ |
---|
| 904 | string name_tmp=name+"__tmp"; \ |
---|
| 905 | \ |
---|
| 906 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 907 | if (!matchingTypeCFortran<T>()) \ |
---|
| 908 | { \ |
---|
| 909 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), SIZE(" << name << "_,4), SIZE(" << name << "_,5), SIZE(" << name << "_,6), SIZE(" << name << "_,7)))" << iendl; \ |
---|
| 910 | oss << " " << name_tmp << " = " << name << "_" << iendl; \ |
---|
| 911 | oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
| 912 | } \ |
---|
| 913 | else oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; \ |
---|
| 914 | oss << "ENDIF"; \ |
---|
[672] | 915 | } |
---|
[509] | 916 | |
---|
[369] | 917 | macro(bool) |
---|
| 918 | macro(double) |
---|
| 919 | macro(int) |
---|
| 920 | |
---|
| 921 | #undef macro |
---|
| 922 | |
---|
| 923 | #define macro(T) \ |
---|
[672] | 924 | template <> \ |
---|
| 925 | void CInterface::AttributeFortranInterfaceGetBody< CArray<T,1> >(ostream& oss, const string& className, const string& name) \ |
---|
| 926 | { \ |
---|
| 927 | string name_tmp=name+"__tmp"; \ |
---|
[369] | 928 | \ |
---|
[672] | 929 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 930 | if (!matchingTypeCFortran<T>()) \ |
---|
| 931 | { \ |
---|
[674] | 932 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1)))" << iendl; \ |
---|
| 933 | oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
[672] | 934 | oss << " " << name << "_ = " << name_tmp << iendl; \ |
---|
| 935 | } \ |
---|
[674] | 936 | else oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; \ |
---|
[672] | 937 | oss << "ENDIF"; \ |
---|
| 938 | } \ |
---|
[369] | 939 | \ |
---|
[672] | 940 | template <> \ |
---|
| 941 | void CInterface::AttributeFortranInterfaceGetBody< CArray<T,2> >(ostream& oss, const string& className, const string& name) \ |
---|
| 942 | { \ |
---|
| 943 | string name_tmp=name+"__tmp"; \ |
---|
[369] | 944 | \ |
---|
[672] | 945 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 946 | if (!matchingTypeCFortran<T>()) \ |
---|
| 947 | { \ |
---|
[674] | 948 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2)))" << iendl; \ |
---|
| 949 | oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
[672] | 950 | oss << " " << name << "_ = " << name_tmp << iendl; \ |
---|
| 951 | } \ |
---|
[674] | 952 | else oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; \ |
---|
[672] | 953 | oss << "ENDIF"; \ |
---|
| 954 | } \ |
---|
[932] | 955 | \ |
---|
[672] | 956 | template <> \ |
---|
| 957 | void CInterface::AttributeFortranInterfaceGetBody< CArray<T,3> >(ostream& oss, const string& className, const string& name) \ |
---|
| 958 | { \ |
---|
| 959 | string name_tmp=name+"__tmp"; \ |
---|
[369] | 960 | \ |
---|
[672] | 961 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 962 | if (!matchingTypeCFortran<T>()) \ |
---|
| 963 | { \ |
---|
[674] | 964 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3)))" << iendl; \ |
---|
| 965 | oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
[672] | 966 | oss << " " << name << "_ = " << name_tmp << iendl; \ |
---|
[369] | 967 | } \ |
---|
[674] | 968 | else oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; \ |
---|
[672] | 969 | oss << "ENDIF"; \ |
---|
[932] | 970 | } \ |
---|
| 971 | \ |
---|
| 972 | template <> \ |
---|
| 973 | void CInterface::AttributeFortranInterfaceGetBody< CArray<T,4> >(ostream& oss, const string& className, const string& name) \ |
---|
| 974 | { \ |
---|
| 975 | string name_tmp=name+"__tmp"; \ |
---|
| 976 | \ |
---|
| 977 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 978 | if (!matchingTypeCFortran<T>()) \ |
---|
| 979 | { \ |
---|
| 980 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), SIZE(" << name << "_,4)))" << iendl; \ |
---|
| 981 | oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
| 982 | oss << " " << name << "_ = " << name_tmp << iendl; \ |
---|
| 983 | } \ |
---|
| 984 | else oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; \ |
---|
| 985 | oss << "ENDIF"; \ |
---|
| 986 | } \ |
---|
| 987 | \ |
---|
| 988 | template <> \ |
---|
| 989 | void CInterface::AttributeFortranInterfaceGetBody< CArray<T,5> >(ostream& oss, const string& className, const string& name) \ |
---|
| 990 | { \ |
---|
| 991 | string name_tmp=name+"__tmp"; \ |
---|
| 992 | \ |
---|
| 993 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 994 | if (!matchingTypeCFortran<T>()) \ |
---|
| 995 | { \ |
---|
| 996 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), SIZE(" << name << "_,4), SIZE(" << name << "_,5)))" << iendl; \ |
---|
| 997 | oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
| 998 | oss << " " << name << "_ = " << name_tmp << iendl; \ |
---|
| 999 | } \ |
---|
| 1000 | else oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; \ |
---|
| 1001 | oss << "ENDIF"; \ |
---|
| 1002 | }\ |
---|
| 1003 | \ |
---|
| 1004 | template <> \ |
---|
| 1005 | void CInterface::AttributeFortranInterfaceGetBody< CArray<T,6> >(ostream& oss, const string& className, const string& name) \ |
---|
| 1006 | { \ |
---|
| 1007 | string name_tmp=name+"__tmp"; \ |
---|
| 1008 | \ |
---|
| 1009 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 1010 | if (!matchingTypeCFortran<T>()) \ |
---|
| 1011 | { \ |
---|
| 1012 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), SIZE(" << name << "_,4), SIZE(" << name << "_,5), SIZE(" << name << "_,6)))" << iendl; \ |
---|
| 1013 | oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
| 1014 | oss << " " << name << "_ = " << name_tmp << iendl; \ |
---|
| 1015 | } \ |
---|
| 1016 | else oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; \ |
---|
| 1017 | oss << "ENDIF"; \ |
---|
| 1018 | } \ |
---|
| 1019 | \ |
---|
| 1020 | template <> \ |
---|
| 1021 | void CInterface::AttributeFortranInterfaceGetBody< CArray<T,7> >(ostream& oss, const string& className, const string& name) \ |
---|
| 1022 | { \ |
---|
| 1023 | string name_tmp=name+"__tmp"; \ |
---|
| 1024 | \ |
---|
| 1025 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 1026 | if (!matchingTypeCFortran<T>()) \ |
---|
| 1027 | { \ |
---|
| 1028 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), SIZE(" << name << "_,4), SIZE(" << name << "_,5), SIZE(" << name << "_,6), SIZE(" << name << "_,7)))" << iendl; \ |
---|
| 1029 | oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
| 1030 | oss << " " << name << "_ = " << name_tmp << iendl; \ |
---|
| 1031 | } \ |
---|
| 1032 | else oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; \ |
---|
| 1033 | oss << "ENDIF"; \ |
---|
[672] | 1034 | } |
---|
[509] | 1035 | |
---|
[369] | 1036 | macro(bool) |
---|
| 1037 | macro(double) |
---|
| 1038 | macro(int) |
---|
| 1039 | |
---|
| 1040 | #undef macro |
---|
[313] | 1041 | } |
---|
| 1042 | #endif |
---|