[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 | |
---|
[1626] | 217 | // oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; |
---|
| 218 | int indent = oss.iword(iendl.index); |
---|
| 219 | string str = "SUBROUTINE cxios_set_" + className + "_" + name + "(" + className + "_hdl, " + name + ") BIND(C)"; |
---|
| 220 | if ((str.length() + indent) >132) |
---|
| 221 | { |
---|
| 222 | oss << str.substr(0,130-indent) ; |
---|
| 223 | oss << "&" << endl; |
---|
| 224 | oss << "&" << str.substr(130-indent,str.length()) ; |
---|
| 225 | } |
---|
| 226 | else |
---|
| 227 | { |
---|
| 228 | oss << str; |
---|
| 229 | } |
---|
| 230 | oss << iendl; |
---|
[672] | 231 | oss << " USE ISO_C_BINDING" << iendl; |
---|
| 232 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; |
---|
| 233 | oss << " " << fortranType << " " << fortranKindC << " , VALUE :: " << name << iendl; |
---|
| 234 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; |
---|
| 235 | oss << iendl; |
---|
| 236 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; |
---|
| 237 | oss << " USE ISO_C_BINDING" << iendl; |
---|
| 238 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; |
---|
| 239 | oss << " " << fortranType << " " << fortranKindC << " :: " << name << iendl; |
---|
| 240 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; |
---|
| 241 | } |
---|
[369] | 242 | |
---|
[532] | 243 | template <> |
---|
[672] | 244 | void CInterface::AttributeFortran2003Interface<string>(ostream& oss, const string& className, const string& name) |
---|
| 245 | { |
---|
[1626] | 246 | // oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", " << name << "_size) BIND(C)" << iendl; |
---|
| 247 | int indent = oss.iword(iendl.index); |
---|
| 248 | string str ="SUBROUTINE cxios_set_" + className + "_" + name + "(" + className + "_hdl, " + name + ", " + name + "_size) BIND(C)"; |
---|
| 249 | if ((str.length() + indent) >132) |
---|
| 250 | { |
---|
| 251 | oss << str.substr(0,130-indent) ; |
---|
| 252 | oss << "&" << endl; |
---|
| 253 | oss << "&" << str.substr(130-indent,str.length()) ; |
---|
| 254 | } |
---|
| 255 | else |
---|
| 256 | { |
---|
| 257 | oss << str; |
---|
| 258 | } |
---|
| 259 | oss << iendl; |
---|
[672] | 260 | oss << " USE ISO_C_BINDING" << iendl; |
---|
| 261 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; |
---|
| 262 | oss << " CHARACTER(kind = C_CHAR) , DIMENSION(*) :: " << name << iendl; |
---|
| 263 | oss << " INTEGER (kind = C_INT) , VALUE :: " << name << "_size" << iendl; |
---|
| 264 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; |
---|
| 265 | oss << iendl; |
---|
[1626] | 266 | // oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", " << name << "_size) BIND(C)" << iendl; |
---|
| 267 | str = "SUBROUTINE cxios_get_" + className + "_" + name + "(" + className + "_hdl, " + name + ", " + name + "_size) BIND(C)"; |
---|
| 268 | if ((str.length() + indent) >132) |
---|
| 269 | { |
---|
| 270 | oss << str.substr(0,130-indent) ; |
---|
| 271 | oss << "&" << endl; |
---|
| 272 | oss << "&" << str.substr(130-indent,str.length()) ; |
---|
| 273 | } |
---|
| 274 | else |
---|
| 275 | { |
---|
| 276 | oss << str; |
---|
| 277 | } |
---|
| 278 | oss << iendl; |
---|
[672] | 279 | oss << " USE ISO_C_BINDING" << iendl; |
---|
| 280 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; |
---|
| 281 | oss << " CHARACTER(kind = C_CHAR) , DIMENSION(*) :: " << name << iendl; |
---|
| 282 | oss << " INTEGER (kind = C_INT) , VALUE :: " << name << "_size" << iendl; |
---|
| 283 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; |
---|
| 284 | } |
---|
| 285 | |
---|
| 286 | template <> |
---|
[1626] | 287 | void CInterface::AttributeFortran2003Interface<CDuration>(ostream& oss, const string& className, const string& name) |
---|
[532] | 288 | { |
---|
[1626] | 289 | // oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; |
---|
| 290 | string str = "SUBROUTINE cxios_set_" + className + "_" + name + "(" + className + "_hdl, " + name + ") BIND(C)"; |
---|
| 291 | int indent = oss.iword(iendl.index); |
---|
| 292 | if ((str.length() + indent) >132) |
---|
| 293 | { |
---|
| 294 | oss << str.substr(0,130-indent) ; |
---|
| 295 | oss << "&" << endl; |
---|
| 296 | oss << "&" << str.substr(130-indent,str.length()) ; |
---|
| 297 | } |
---|
| 298 | else |
---|
| 299 | { |
---|
| 300 | oss << str; |
---|
| 301 | } |
---|
[532] | 302 | oss << iendl; |
---|
| 303 | oss << " USE ISO_C_BINDING" << iendl; |
---|
[545] | 304 | oss << " USE IDURATION" << iendl; |
---|
[537] | 305 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; |
---|
| 306 | oss << " TYPE(txios(duration)), VALUE :: " << name << iendl; |
---|
[581] | 307 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; |
---|
[537] | 308 | oss << iendl; |
---|
| 309 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; |
---|
| 310 | oss << " USE ISO_C_BINDING" << iendl; |
---|
[545] | 311 | oss << " USE IDURATION" << iendl; |
---|
[537] | 312 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; |
---|
| 313 | oss << " TYPE(txios(duration)) :: " << name << iendl; |
---|
[581] | 314 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; |
---|
[537] | 315 | } |
---|
| 316 | |
---|
[672] | 317 | template <class T> |
---|
| 318 | void CInterface::AttributeFortranInterfaceDeclaration(ostream& oss, const string& className, const string& name) |
---|
| 319 | { |
---|
| 320 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name; |
---|
| 321 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " :: " << name << "_tmp"; |
---|
| 322 | } |
---|
[509] | 323 | |
---|
[672] | 324 | template <class T> |
---|
| 325 | void CInterface::AttributeFortranInterfaceGetDeclaration(ostream& oss, const string& className, const string& name) |
---|
| 326 | { |
---|
| 327 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name; |
---|
| 328 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " :: " << name << "_tmp"; |
---|
| 329 | } |
---|
[369] | 330 | |
---|
[672] | 331 | void CInterface::AttributeFortranInterfaceIsDefinedDeclaration(ostream& oss, const string& className, const string& name) |
---|
| 332 | { |
---|
| 333 | oss << "LOGICAL, OPTIONAL, INTENT(OUT) :: " << name << iendl; |
---|
| 334 | oss << "LOGICAL(KIND=C_BOOL) :: " << name << "_tmp"; |
---|
| 335 | } |
---|
[313] | 336 | |
---|
[672] | 337 | template <> |
---|
| 338 | void CInterface::AttributeFortranInterfaceDeclaration<string>(ostream& oss, const string& className, const string& name) |
---|
| 339 | { |
---|
| 340 | oss << "CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: " << name; |
---|
| 341 | } |
---|
[509] | 342 | |
---|
[672] | 343 | template <> |
---|
| 344 | void CInterface::AttributeFortranInterfaceGetDeclaration<string>(ostream& oss, const string& className, const string& name) |
---|
| 345 | { |
---|
| 346 | oss << "CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: " << name; |
---|
| 347 | } |
---|
[509] | 348 | |
---|
[672] | 349 | template <class T> |
---|
| 350 | void CInterface::AttributeFortranInterfaceBody(ostream& oss, const string& className, const string& name) |
---|
| 351 | { |
---|
| 352 | string name_tmp=name+"__tmp"; |
---|
[509] | 353 | |
---|
[672] | 354 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; |
---|
| 355 | if (!matchingTypeCFortran<T>()) |
---|
| 356 | { |
---|
| 357 | oss << " " << name_tmp << " = " << name << "_" << iendl; |
---|
[2620] | 358 | oss << " CALL xios_logical_to_bool_0d(" << name_tmp << ")" << iendl; \ |
---|
[966] | 359 | oss << " CALL cxios_set_" << className << "_" << name << " &" << iendl; |
---|
| 360 | oss << "(" << className << "_hdl%daddr, " << name_tmp << ")" << iendl; |
---|
[672] | 361 | } |
---|
[966] | 362 | else { oss << " CALL cxios_set_" << className << "_" << name << " &" << iendl; |
---|
| 363 | oss << "(" << className << "_hdl%daddr, " << name << "_)" << iendl; } |
---|
[672] | 364 | oss << "ENDIF"; |
---|
| 365 | } |
---|
[313] | 366 | |
---|
[672] | 367 | template <class T> |
---|
| 368 | void CInterface::AttributeFortranInterfaceGetBody(ostream& oss, const string& className, const string& name) |
---|
| 369 | { |
---|
| 370 | string name_tmp=name+"__tmp"; |
---|
[509] | 371 | |
---|
[672] | 372 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; |
---|
| 373 | if (!matchingTypeCFortran<T>()) |
---|
| 374 | { |
---|
[966] | 375 | oss << " CALL cxios_get_" << className << "_" << name << " &" << iendl; |
---|
| 376 | oss << "(" << className << "_hdl%daddr, " << name_tmp << ")" << iendl; |
---|
[2620] | 377 | oss << " CALL xios_bool_to_logical_0d(" << name_tmp << ")" << iendl; \ |
---|
[672] | 378 | oss << " " << name << "_ = " << name_tmp << iendl; |
---|
| 379 | } |
---|
[966] | 380 | else { oss << " CALL cxios_get_" << className << "_" << name << " &" << iendl; |
---|
| 381 | oss << "(" << className << "_hdl%daddr, " << name << "_)" << iendl; } |
---|
[672] | 382 | oss << "ENDIF"; |
---|
| 383 | } |
---|
[313] | 384 | |
---|
[672] | 385 | void CInterface::AttributeFortranInterfaceIsDefinedBody(ostream& oss, const string& className, const string& name) |
---|
| 386 | { |
---|
| 387 | string name_tmp=name+"__tmp"; |
---|
[509] | 388 | |
---|
[672] | 389 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; |
---|
[966] | 390 | oss << " " << name << "__tmp = cxios_is_defined_" << className << "_" << name << " &" << iendl; |
---|
| 391 | oss << "(" << className << "_hdl%daddr)" << iendl; |
---|
[672] | 392 | oss << " " << name << "_ = " << name_tmp << iendl; |
---|
| 393 | oss << "ENDIF"; |
---|
| 394 | } |
---|
[509] | 395 | |
---|
[672] | 396 | template <> |
---|
| 397 | void CInterface::AttributeFortranInterfaceBody<string>(ostream& oss, const string& className, const string& name) |
---|
| 398 | { |
---|
| 399 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; |
---|
[966] | 400 | oss << " CALL cxios_set_" << className << "_" << name << " &" << iendl; |
---|
| 401 | oss << "(" << className << "_hdl%daddr, " << name << "_, len(" << name << "_))" << iendl; |
---|
[672] | 402 | oss << "ENDIF"; |
---|
| 403 | } |
---|
[509] | 404 | |
---|
[672] | 405 | template <> |
---|
| 406 | void CInterface::AttributeFortranInterfaceGetBody<string>(ostream& oss, const string& className, const string& name) |
---|
| 407 | { |
---|
| 408 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; |
---|
[966] | 409 | oss << " CALL cxios_get_" << className << "_" << name << " &" << iendl; |
---|
| 410 | oss << "(" << className << "_hdl%daddr, " << name << "_, len(" << name << "_))" << iendl; |
---|
[672] | 411 | oss << "ENDIF"; |
---|
| 412 | } |
---|
[509] | 413 | |
---|
[369] | 414 | // declaration for CArray |
---|
| 415 | |
---|
| 416 | #define macro(T) \ |
---|
[581] | 417 | template <> \ |
---|
| 418 | void CInterface::AttributeCInterface<CArray<T,1> >(ostream& oss, const string& className, const string& name) \ |
---|
| 419 | { \ |
---|
| 420 | string typeName=getStrType<T>(); \ |
---|
[369] | 421 | \ |
---|
[674] | 422 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
[581] | 423 | oss << "{" << iendl; \ |
---|
| 424 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
[674] | 425 | oss << " CArray<" << typeName << ",1> tmp(" << name << ", shape(extent[0]), neverDeleteData);" << iendl; \ |
---|
[581] | 426 | oss << " " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \ |
---|
| 427 | /*oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \ |
---|
| 428 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 429 | oss << "}" << std::endl; \ |
---|
| 430 | oss << iendl; \ |
---|
[674] | 431 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
[581] | 432 | oss << "{" << iendl; \ |
---|
| 433 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
[674] | 434 | oss << " CArray<" << typeName << ",1> tmp(" << name << ", shape(extent[0]), neverDeleteData);" << iendl; \ |
---|
[581] | 435 | oss << " tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \ |
---|
| 436 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 437 | oss << "}" << std::endl; \ |
---|
| 438 | } \ |
---|
[369] | 439 | \ |
---|
| 440 | template <> \ |
---|
[581] | 441 | void CInterface::AttributeCInterface<CArray<T,2> >(ostream& oss, const string& className, const string& name) \ |
---|
| 442 | { \ |
---|
| 443 | string typeName=getStrType<T>(); \ |
---|
[369] | 444 | \ |
---|
[674] | 445 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
[581] | 446 | oss << "{" << iendl; \ |
---|
| 447 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
[674] | 448 | oss << " CArray<" << typeName << ",2> tmp(" << name << ", shape(extent[0], extent[1]), neverDeleteData);" << iendl; \ |
---|
[581] | 449 | oss << " " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \ |
---|
| 450 | /*oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \ |
---|
| 451 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 452 | oss << "}" << std::endl; \ |
---|
| 453 | oss << iendl; \ |
---|
[674] | 454 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
[581] | 455 | oss << "{" << iendl; \ |
---|
| 456 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
[674] | 457 | oss << " CArray<" << typeName << ",2> tmp(" << name << ", shape(extent[0], extent[1]), neverDeleteData);" << iendl; \ |
---|
[581] | 458 | oss << " tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \ |
---|
| 459 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 460 | oss << "}" << std::endl; \ |
---|
| 461 | } \ |
---|
[369] | 462 | \ |
---|
[581] | 463 | template <> \ |
---|
| 464 | void CInterface::AttributeCInterface<CArray<T,3> >(ostream& oss, const string& className, const string& name) \ |
---|
| 465 | { \ |
---|
| 466 | string typeName=getStrType<T>(); \ |
---|
[369] | 467 | \ |
---|
[674] | 468 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
[581] | 469 | oss << "{" << iendl; \ |
---|
| 470 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
[674] | 471 | oss << " CArray<" << typeName << ",3> tmp(" << name << ", shape(extent[0], extent[1], extent[2]), neverDeleteData);" << iendl; \ |
---|
[581] | 472 | oss << " " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \ |
---|
| 473 | /*oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \ |
---|
| 474 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 475 | oss << "}" << std::endl; \ |
---|
| 476 | oss << iendl; \ |
---|
[674] | 477 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
[581] | 478 | oss << "{" << iendl; \ |
---|
| 479 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
[674] | 480 | oss << " CArray<" << typeName << ",3> tmp(" << name << ", shape(extent[0], extent[1], extent[2]), neverDeleteData);" << iendl; \ |
---|
[581] | 481 | oss << " tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \ |
---|
| 482 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 483 | oss << "}" << std::endl; \ |
---|
[932] | 484 | } \ |
---|
| 485 | \ |
---|
| 486 | template <> \ |
---|
| 487 | void CInterface::AttributeCInterface<CArray<T,4> >(ostream& oss, const string& className, const string& name) \ |
---|
| 488 | { \ |
---|
| 489 | string typeName=getStrType<T>(); \ |
---|
| 490 | \ |
---|
| 491 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
| 492 | oss << "{" << iendl; \ |
---|
| 493 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
| 494 | oss << " CArray<" << typeName << ",4> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3]), neverDeleteData);" << iendl; \ |
---|
| 495 | oss << " " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \ |
---|
| 496 | /*oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \ |
---|
| 497 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 498 | oss << "}" << std::endl; \ |
---|
| 499 | oss << iendl; \ |
---|
| 500 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
| 501 | oss << "{" << iendl; \ |
---|
| 502 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
| 503 | oss << " CArray<" << typeName << ",4> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3]), neverDeleteData);" << iendl; \ |
---|
| 504 | oss << " tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \ |
---|
| 505 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 506 | oss << "}" << std::endl; \ |
---|
| 507 | } \ |
---|
| 508 | \ |
---|
| 509 | template <> \ |
---|
| 510 | void CInterface::AttributeCInterface<CArray<T,5> >(ostream& oss, const string& className, const string& name) \ |
---|
| 511 | { \ |
---|
| 512 | string typeName=getStrType<T>(); \ |
---|
| 513 | \ |
---|
| 514 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
| 515 | oss << "{" << iendl; \ |
---|
| 516 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
| 517 | oss << " CArray<" << typeName << ",5> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3], extent[4]), neverDeleteData);" << iendl; \ |
---|
| 518 | oss << " " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \ |
---|
| 519 | /*oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \ |
---|
| 520 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 521 | oss << "}" << std::endl; \ |
---|
| 522 | oss << iendl; \ |
---|
| 523 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
| 524 | oss << "{" << iendl; \ |
---|
| 525 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
| 526 | oss << " CArray<" << typeName << ",5> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3], extent[4]), neverDeleteData);" << iendl; \ |
---|
| 527 | oss << " tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \ |
---|
| 528 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 529 | oss << "}" << std::endl; \ |
---|
| 530 | } \ |
---|
| 531 | \ |
---|
| 532 | template <> \ |
---|
| 533 | void CInterface::AttributeCInterface<CArray<T,6> >(ostream& oss, const string& className, const string& name) \ |
---|
| 534 | { \ |
---|
| 535 | string typeName=getStrType<T>(); \ |
---|
| 536 | \ |
---|
| 537 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
| 538 | oss << "{" << iendl; \ |
---|
| 539 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
| 540 | oss << " CArray<" << typeName << ",6> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3], extent[4], extent[5]), neverDeleteData);" << iendl; \ |
---|
| 541 | oss << " " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \ |
---|
| 542 | /*oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \ |
---|
| 543 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 544 | oss << "}" << std::endl; \ |
---|
| 545 | oss << iendl; \ |
---|
| 546 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
| 547 | oss << "{" << iendl; \ |
---|
| 548 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
| 549 | oss << " CArray<" << typeName << ",6> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3], extent[4], extent[5]), neverDeleteData);" << iendl; \ |
---|
| 550 | oss << " tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \ |
---|
| 551 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 552 | oss << "}" << std::endl; \ |
---|
| 553 | } \ |
---|
| 554 | \ |
---|
| 555 | template <> \ |
---|
| 556 | void CInterface::AttributeCInterface<CArray<T,7> >(ostream& oss, const string& className, const string& name) \ |
---|
| 557 | { \ |
---|
| 558 | string typeName=getStrType<T>(); \ |
---|
| 559 | \ |
---|
| 560 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
| 561 | oss << "{" << iendl; \ |
---|
| 562 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
| 563 | oss << " CArray<" << typeName << ",7> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3], extent[4], extent[5], extent[6]), neverDeleteData);" << iendl; \ |
---|
| 564 | oss << " " << className << "_hdl->" << name << ".reference(tmp.copy());" << iendl; \ |
---|
| 565 | /*oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;*/ \ |
---|
| 566 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 567 | oss << "}" << std::endl; \ |
---|
| 568 | oss << iendl; \ |
---|
| 569 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int* extent)" << iendl; \ |
---|
| 570 | oss << "{" << iendl; \ |
---|
| 571 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
| 572 | oss << " CArray<" << typeName << ",7> tmp(" << name << ", shape(extent[0], extent[1], extent[2], extent[3], extent[4], extent[5], extent[6]), neverDeleteData);" << iendl; \ |
---|
| 573 | oss << " tmp=" << className << "_hdl->" << name << ".getInheritedValue();" << iendl; \ |
---|
| 574 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 575 | oss << "}" << std::endl; \ |
---|
[369] | 576 | } |
---|
| 577 | |
---|
| 578 | macro(bool) |
---|
| 579 | macro(double) |
---|
| 580 | macro(int) |
---|
| 581 | |
---|
[509] | 582 | #undef macro |
---|
[369] | 583 | |
---|
[1158] | 584 | #define macro(N,EXTENT)\ |
---|
| 585 | template <>\ |
---|
| 586 | void CInterface::AttributeCInterface<CArray<StdString,N> >(ostream& oss, const string& className, const string& name)\ |
---|
| 587 | { \ |
---|
| 588 | oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << "char* " << name <<", int str_len, int* str_size, int* extent)" << iendl; \ |
---|
| 589 | oss << "{" << iendl; \ |
---|
| 590 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
| 591 | oss << " "<<className<<"_hdl->"<<name<<".resize(shape("<<EXTENT<<"));"<<iendl;\ |
---|
| 592 | oss << " Array<StdString,"<<#N<<">::iterator it, itb="<<className<<"_hdl->"<<name<<".begin(), ite="<<className<<"_hdl->"<<name<<".end() ;"<<iendl ;\ |
---|
| 593 | oss << " int i, n ;"<< iendl; \ |
---|
| 594 | oss << " for(it=itb, i=0, n=0 ; it!=ite ; ++it,n+=str_len,++i) *it=StdString(&"<<name<<"[n],str_size[i]) ;"<<iendl ;\ |
---|
| 595 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 596 | oss << "}" << std::endl; \ |
---|
| 597 | oss << iendl; \ |
---|
| 598 | oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << "char* " << name << ", int str_size, int* extent)" << iendl; \ |
---|
| 599 | oss << "{" << iendl; \ |
---|
| 600 | oss << " CTimer::get(\"XIOS\").resume();" << iendl; \ |
---|
| 601 | oss << " Array<StdString,"<<#N<<">::const_iterator it, itb="<<className<<"_hdl->"<<name<<".getInheritedValue().begin(), ite="<<className<<"_hdl->"<<name<<".getInheritedValue().end() ;" << iendl; \ |
---|
| 602 | oss << " int n ;"<< iendl; \ |
---|
| 603 | oss << " for(it=itb, n=0 ; it!=ite ; ++it, n+=str_size) it->copy(&"<<name<<"[n],it->size()) ; "<< iendl; \ |
---|
| 604 | oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \ |
---|
| 605 | oss << "}" << std::endl; \ |
---|
| 606 | } |
---|
| 607 | |
---|
| 608 | macro(1,"extent[0]") |
---|
| 609 | macro(2,"extent[0],extent[1]") |
---|
| 610 | macro(3,"extent[0],extent[1],extent[2]") |
---|
| 611 | macro(4,"extent[0],extent[1],extent[2],extent[3]") |
---|
| 612 | macro(5,"extent[0],extent[1],extent[2],extent[3],extent[4]") |
---|
| 613 | macro(6,"extent[0],extent[1],extent[2],extent[3],extent[4],extent[5]") |
---|
| 614 | macro(7,"extent[0],extent[1],extent[2],extent[3],extent[4],extent[5],extent[6]") |
---|
| 615 | #undef macro |
---|
[369] | 616 | // ///////////////////////////////////////////////// |
---|
| 617 | // // Fortran 2003 Interface // |
---|
| 618 | // ///////////////////////////////////////////////// |
---|
| 619 | |
---|
[581] | 620 | #define macro(T) \ |
---|
[672] | 621 | template <> \ |
---|
| 622 | void CInterface::AttributeFortran2003Interface<CArray<T,1> >(ostream& oss, const string& className, const string& name) \ |
---|
| 623 | { \ |
---|
| 624 | string fortranType=getStrFortranType<T>(); \ |
---|
| 625 | string fortranKindC=getStrFortranKindC<T>(); \ |
---|
[369] | 626 | \ |
---|
[674] | 627 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
[672] | 628 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 629 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 630 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
[674] | 631 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
[672] | 632 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ |
---|
| 633 | oss << iendl; \ |
---|
[674] | 634 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
[672] | 635 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 636 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 637 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
[674] | 638 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
[672] | 639 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ |
---|
| 640 | } \ |
---|
[369] | 641 | \ |
---|
[672] | 642 | template <> \ |
---|
| 643 | void CInterface::AttributeFortran2003Interface<CArray<T,2> >(ostream& oss, const string& className, const string& name) \ |
---|
| 644 | { \ |
---|
| 645 | string fortranType=getStrFortranType<T>(); \ |
---|
| 646 | string fortranKindC=getStrFortranKindC<T>(); \ |
---|
[369] | 647 | \ |
---|
[674] | 648 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
[672] | 649 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 650 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 651 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
[674] | 652 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
[672] | 653 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ |
---|
| 654 | oss << iendl; \ |
---|
[674] | 655 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
[672] | 656 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 657 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 658 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
[674] | 659 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
[672] | 660 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ |
---|
| 661 | } \ |
---|
[932] | 662 | \ |
---|
[672] | 663 | template <> \ |
---|
| 664 | void CInterface::AttributeFortran2003Interface<CArray<T,3> >(ostream& oss, const string& className, const string& name) \ |
---|
| 665 | { \ |
---|
| 666 | string fortranType=getStrFortranType<T>(); \ |
---|
| 667 | string fortranKindC=getStrFortranKindC<T>(); \ |
---|
[369] | 668 | \ |
---|
[674] | 669 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
[672] | 670 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 671 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 672 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
[674] | 673 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
[672] | 674 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ |
---|
| 675 | oss << iendl; \ |
---|
[674] | 676 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
[672] | 677 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 678 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 679 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
[674] | 680 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
[672] | 681 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ |
---|
[932] | 682 | } \ |
---|
| 683 | \ |
---|
| 684 | template <> \ |
---|
| 685 | void CInterface::AttributeFortran2003Interface<CArray<T,4> >(ostream& oss, const string& className, const string& name) \ |
---|
| 686 | { \ |
---|
| 687 | string fortranType=getStrFortranType<T>(); \ |
---|
| 688 | string fortranKindC=getStrFortranKindC<T>(); \ |
---|
| 689 | \ |
---|
| 690 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
| 691 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 692 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 693 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
| 694 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
| 695 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ |
---|
| 696 | oss << iendl; \ |
---|
| 697 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
| 698 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 699 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 700 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
| 701 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
| 702 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ |
---|
| 703 | }\ |
---|
| 704 | \ |
---|
| 705 | template <> \ |
---|
| 706 | void CInterface::AttributeFortran2003Interface<CArray<T,5> >(ostream& oss, const string& className, const string& name) \ |
---|
| 707 | { \ |
---|
| 708 | string fortranType=getStrFortranType<T>(); \ |
---|
| 709 | string fortranKindC=getStrFortranKindC<T>(); \ |
---|
| 710 | \ |
---|
| 711 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
| 712 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 713 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 714 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
| 715 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
| 716 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ |
---|
| 717 | oss << iendl; \ |
---|
| 718 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
| 719 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 720 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 721 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
| 722 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
| 723 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ |
---|
| 724 | }\ |
---|
| 725 | \ |
---|
| 726 | template <> \ |
---|
| 727 | void CInterface::AttributeFortran2003Interface<CArray<T,6> >(ostream& oss, const string& className, const string& name) \ |
---|
| 728 | { \ |
---|
| 729 | string fortranType=getStrFortranType<T>(); \ |
---|
| 730 | string fortranKindC=getStrFortranKindC<T>(); \ |
---|
| 731 | \ |
---|
| 732 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
| 733 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 734 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 735 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
| 736 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
| 737 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ |
---|
| 738 | oss << iendl; \ |
---|
| 739 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
| 740 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 741 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 742 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
| 743 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
| 744 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ |
---|
| 745 | }\ |
---|
| 746 | \ |
---|
| 747 | template <> \ |
---|
| 748 | void CInterface::AttributeFortran2003Interface<CArray<T,7> >(ostream& oss, const string& className, const string& name) \ |
---|
| 749 | { \ |
---|
| 750 | string fortranType=getStrFortranType<T>(); \ |
---|
| 751 | string fortranKindC=getStrFortranKindC<T>(); \ |
---|
| 752 | \ |
---|
| 753 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
| 754 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 755 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 756 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
| 757 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
| 758 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ |
---|
| 759 | oss << iendl; \ |
---|
| 760 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent) BIND(C)" << iendl; \ |
---|
| 761 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 762 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 763 | oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ |
---|
| 764 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
| 765 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ |
---|
[672] | 766 | } |
---|
[509] | 767 | |
---|
[369] | 768 | macro(bool) |
---|
| 769 | macro(double) |
---|
| 770 | macro(int) |
---|
[509] | 771 | |
---|
[369] | 772 | #undef macro |
---|
| 773 | |
---|
[1158] | 774 | #define macro(T)\ |
---|
| 775 | template <>\ |
---|
| 776 | void CInterface::AttributeFortran2003Interface<CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\ |
---|
| 777 | {\ |
---|
| 778 | oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", str_len, str_size, extent) BIND(C)" << iendl; \ |
---|
| 779 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 780 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 781 | oss << " CHARACTER (KIND=C_CHAR), DIMENSION(*) :: " << name << iendl; \ |
---|
| 782 | oss << " INTEGER (kind = C_INT), VALUE :: str_len" << iendl; \ |
---|
| 783 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: str_size" << iendl; \ |
---|
| 784 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
| 785 | oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ |
---|
| 786 | oss << iendl; \ |
---|
| 787 | oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", str_size, extent) BIND(C)" << iendl; \ |
---|
| 788 | oss << " USE ISO_C_BINDING" << iendl; \ |
---|
| 789 | oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ |
---|
| 790 | oss << " CHARACTER (KIND=C_CHAR), DIMENSION(*) :: " << name << iendl; \ |
---|
| 791 | oss << " INTEGER (kind = C_INT), VALUE :: str_size" << iendl; \ |
---|
| 792 | oss << " INTEGER (kind = C_INT), DIMENSION(*) :: extent" << iendl; \ |
---|
| 793 | oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ |
---|
| 794 | } |
---|
| 795 | macro(1) |
---|
| 796 | macro(2) |
---|
| 797 | macro(3) |
---|
| 798 | macro(4) |
---|
| 799 | macro(5) |
---|
| 800 | macro(6) |
---|
| 801 | macro(7) |
---|
| 802 | |
---|
| 803 | #undef macro |
---|
| 804 | |
---|
[581] | 805 | #define macro(T) \ |
---|
[672] | 806 | template <> \ |
---|
| 807 | void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,1> >(ostream& oss, const string& className, const string& name) \ |
---|
| 808 | { \ |
---|
| 809 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:)"; \ |
---|
| 810 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:)"; \ |
---|
| 811 | } \ |
---|
| 812 | template <> \ |
---|
| 813 | void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,1> >(ostream& oss, const string& className, const string& name) \ |
---|
| 814 | { \ |
---|
| 815 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:)"; \ |
---|
| 816 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:)"; \ |
---|
| 817 | } \ |
---|
[369] | 818 | \ |
---|
[672] | 819 | template <> \ |
---|
| 820 | void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,2> >(ostream& oss, const string& className, const string& name) \ |
---|
| 821 | { \ |
---|
| 822 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:)"; \ |
---|
| 823 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:)"; \ |
---|
| 824 | } \ |
---|
[369] | 825 | \ |
---|
[672] | 826 | template <> \ |
---|
| 827 | void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,2> >(ostream& oss, const string& className, const string& name) \ |
---|
| 828 | { \ |
---|
| 829 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:)"; \ |
---|
| 830 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:)"; \ |
---|
| 831 | } \ |
---|
[369] | 832 | \ |
---|
[672] | 833 | template <> \ |
---|
| 834 | void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,3> >(ostream& oss, const string& className, const string& name) \ |
---|
| 835 | { \ |
---|
| 836 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:)"; \ |
---|
| 837 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:)"; \ |
---|
| 838 | } \ |
---|
[369] | 839 | \ |
---|
[672] | 840 | template <> \ |
---|
| 841 | void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,3> >(ostream& oss, const string& className, const string& name) \ |
---|
| 842 | { \ |
---|
| 843 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:)"; \ |
---|
| 844 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:)"; \ |
---|
[932] | 845 | }\ |
---|
| 846 | \ |
---|
| 847 | template <> \ |
---|
| 848 | void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,4> >(ostream& oss, const string& className, const string& name) \ |
---|
| 849 | { \ |
---|
| 850 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:,:)"; \ |
---|
| 851 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:)"; \ |
---|
| 852 | } \ |
---|
| 853 | \ |
---|
| 854 | template <> \ |
---|
| 855 | void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,4> >(ostream& oss, const string& className, const string& name) \ |
---|
| 856 | { \ |
---|
| 857 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:,:)"; \ |
---|
| 858 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:)"; \ |
---|
| 859 | }\ |
---|
| 860 | \ |
---|
| 861 | template <> \ |
---|
| 862 | void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,5> >(ostream& oss, const string& className, const string& name) \ |
---|
| 863 | { \ |
---|
| 864 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:,:,:)"; \ |
---|
| 865 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:)"; \ |
---|
| 866 | } \ |
---|
| 867 | \ |
---|
| 868 | template <> \ |
---|
| 869 | void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,5> >(ostream& oss, const string& className, const string& name) \ |
---|
| 870 | { \ |
---|
| 871 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:,:,:)"; \ |
---|
| 872 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:)"; \ |
---|
| 873 | }\ |
---|
| 874 | \ |
---|
| 875 | template <> \ |
---|
| 876 | void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,6> >(ostream& oss, const string& className, const string& name) \ |
---|
| 877 | { \ |
---|
| 878 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:,:,:,:)"; \ |
---|
| 879 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:,:)"; \ |
---|
| 880 | } \ |
---|
| 881 | \ |
---|
| 882 | template <> \ |
---|
| 883 | void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,6> >(ostream& oss, const string& className, const string& name) \ |
---|
| 884 | { \ |
---|
| 885 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:,:,:,:)"; \ |
---|
| 886 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:,:)"; \ |
---|
| 887 | }\ |
---|
| 888 | \ |
---|
| 889 | template <> \ |
---|
| 890 | void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,7> >(ostream& oss, const string& className, const string& name) \ |
---|
| 891 | { \ |
---|
| 892 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:,:,:,:,:)"; \ |
---|
| 893 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:,:,:)"; \ |
---|
| 894 | } \ |
---|
| 895 | \ |
---|
| 896 | template <> \ |
---|
| 897 | void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,7> >(ostream& oss, const string& className, const string& name) \ |
---|
| 898 | { \ |
---|
| 899 | oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:,:,:,:,:)"; \ |
---|
| 900 | if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:,:,:,:,:)"; \ |
---|
[672] | 901 | } |
---|
[509] | 902 | |
---|
[369] | 903 | macro(bool) |
---|
| 904 | macro(double) |
---|
| 905 | macro(int) |
---|
| 906 | |
---|
| 907 | #undef macro |
---|
| 908 | |
---|
[1158] | 909 | #define macro(T,EXTENT)\ |
---|
| 910 | template <> \ |
---|
| 911 | void CInterface::AttributeFortranInterfaceDeclaration<CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\ |
---|
| 912 | {\ |
---|
| 913 | oss << "CHARACTER(len=*) , OPTIONAL, INTENT(IN) :: " << name << "("<<EXTENT<<")"; \ |
---|
| 914 | }\ |
---|
| 915 | \ |
---|
| 916 | template <>\ |
---|
| 917 | void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\ |
---|
| 918 | {\ |
---|
| 919 | oss << "CHARACTER(len=*) , OPTIONAL, INTENT(OUT) :: " << name << "("<<EXTENT<<")"; \ |
---|
| 920 | } |
---|
| 921 | macro(1,":") |
---|
| 922 | macro(2,":,:") |
---|
| 923 | macro(3,":,:,:") |
---|
| 924 | macro(4,":,:,:,:") |
---|
| 925 | macro(5,":,:,:,:,:") |
---|
| 926 | macro(6,":,:,:,:,:,:") |
---|
| 927 | macro(7,":,:,:,:,:,:,:") |
---|
| 928 | |
---|
| 929 | #undef macro |
---|
| 930 | |
---|
| 931 | |
---|
| 932 | |
---|
| 933 | |
---|
| 934 | |
---|
| 935 | |
---|
[369] | 936 | #define macro(T) \ |
---|
[672] | 937 | template <> \ |
---|
| 938 | void CInterface::AttributeFortranInterfaceBody< CArray<T,1> >(ostream& oss, const string& className, const string& name) \ |
---|
| 939 | { \ |
---|
| 940 | string name_tmp=name+"__tmp"; \ |
---|
[369] | 941 | \ |
---|
[672] | 942 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 943 | if (!matchingTypeCFortran<T>()) \ |
---|
| 944 | { \ |
---|
[674] | 945 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1)))" << iendl; \ |
---|
[672] | 946 | oss << " " << name_tmp << " = " << name << "_" << iendl; \ |
---|
[2620] | 947 | oss << " CALL xios_logical_to_bool_1d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \ |
---|
[966] | 948 | oss << " CALL cxios_set_" << className << "_" << name << " &" << iendl; \ |
---|
| 949 | oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
[672] | 950 | } \ |
---|
[966] | 951 | else { oss << " CALL cxios_set_" << className << "_" << name << " &" << iendl; \ |
---|
| 952 | oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \ |
---|
[672] | 953 | oss << "ENDIF"; \ |
---|
| 954 | } \ |
---|
[369] | 955 | \ |
---|
[672] | 956 | template <> \ |
---|
| 957 | void CInterface::AttributeFortranInterfaceBody< CArray<T,2> >(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)))" << iendl; \ |
---|
[672] | 965 | oss << " " << name_tmp << " = " << name << "_" << iendl; \ |
---|
[2620] | 966 | oss << " CALL xios_logical_to_bool_2d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \ |
---|
[966] | 967 | oss << " CALL cxios_set_" << className << "_" << name << " &" << iendl; \ |
---|
| 968 | oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
[672] | 969 | } \ |
---|
[966] | 970 | else { oss << " CALL cxios_set_" << className << "_" << name << " &" << iendl; \ |
---|
| 971 | oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \ |
---|
[672] | 972 | oss << "ENDIF"; \ |
---|
| 973 | } \ |
---|
[932] | 974 | \ |
---|
[672] | 975 | template <> \ |
---|
| 976 | void CInterface::AttributeFortranInterfaceBody< CArray<T,3> >(ostream& oss, const string& className, const string& name) \ |
---|
| 977 | { \ |
---|
| 978 | string name_tmp=name+"__tmp"; \ |
---|
[369] | 979 | \ |
---|
[672] | 980 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 981 | if (!matchingTypeCFortran<T>()) \ |
---|
| 982 | { \ |
---|
[674] | 983 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3)))" << iendl; \ |
---|
[672] | 984 | oss << " " << name_tmp << " = " << name << "_" << iendl; \ |
---|
[2620] | 985 | oss << " CALL xios_logical_to_bool_3d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \ |
---|
[966] | 986 | oss << " CALL cxios_set_" << className << "_" << name << " &" << iendl; \ |
---|
| 987 | oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
[672] | 988 | } \ |
---|
[966] | 989 | else { oss << " CALL cxios_set_" << className << "_" << name << " &" << iendl; \ |
---|
| 990 | oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \ |
---|
[672] | 991 | oss << "ENDIF"; \ |
---|
[932] | 992 | }\ |
---|
| 993 | \ |
---|
| 994 | template <> \ |
---|
| 995 | void CInterface::AttributeFortranInterfaceBody< CArray<T,4> >(ostream& oss, const string& className, const string& name) \ |
---|
| 996 | { \ |
---|
| 997 | string name_tmp=name+"__tmp"; \ |
---|
| 998 | \ |
---|
| 999 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 1000 | if (!matchingTypeCFortran<T>()) \ |
---|
| 1001 | { \ |
---|
[966] | 1002 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \ |
---|
| 1003 | oss << " SIZE(" << name << "_,4)))" << iendl; \ |
---|
[932] | 1004 | oss << " " << name_tmp << " = " << name << "_" << iendl; \ |
---|
[2620] | 1005 | oss << " CALL xios_logical_to_bool_4d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \ |
---|
[966] | 1006 | oss << " CALL cxios_set_" << className << "_" << name << " &" << iendl; \ |
---|
| 1007 | oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
[932] | 1008 | } \ |
---|
[966] | 1009 | else { oss << " CALL cxios_set_" << className << "_" << name << " &" << iendl; \ |
---|
| 1010 | oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \ |
---|
[932] | 1011 | oss << "ENDIF"; \ |
---|
| 1012 | }\ |
---|
| 1013 | \ |
---|
| 1014 | template <> \ |
---|
| 1015 | void CInterface::AttributeFortranInterfaceBody< CArray<T,5> >(ostream& oss, const string& className, const string& name) \ |
---|
| 1016 | { \ |
---|
| 1017 | string name_tmp=name+"__tmp"; \ |
---|
| 1018 | \ |
---|
| 1019 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 1020 | if (!matchingTypeCFortran<T>()) \ |
---|
| 1021 | { \ |
---|
[966] | 1022 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \ |
---|
| 1023 | oss << " SIZE(" << name << "_,4), SIZE(" << name << "_,5)))" << iendl; \ |
---|
[932] | 1024 | oss << " " << name_tmp << " = " << name << "_" << iendl; \ |
---|
[2620] | 1025 | oss << " CALL xios_logical_to_bool_5d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \ |
---|
[966] | 1026 | oss << " CALL cxios_set_" << className << "_" << name << " &" << iendl; \ |
---|
| 1027 | oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
[932] | 1028 | } \ |
---|
[966] | 1029 | else { oss << " CALL cxios_set_" << className << "_" << name << " &" << iendl; \ |
---|
| 1030 | oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \ |
---|
[932] | 1031 | oss << "ENDIF"; \ |
---|
| 1032 | }\ |
---|
| 1033 | \ |
---|
| 1034 | template <> \ |
---|
| 1035 | void CInterface::AttributeFortranInterfaceBody< CArray<T,6> >(ostream& oss, const string& className, const string& name) \ |
---|
| 1036 | { \ |
---|
| 1037 | string name_tmp=name+"__tmp"; \ |
---|
| 1038 | \ |
---|
| 1039 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 1040 | if (!matchingTypeCFortran<T>()) \ |
---|
| 1041 | { \ |
---|
[966] | 1042 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \ |
---|
| 1043 | oss << " SIZE(" << name << "_,4), SIZE(" << name << "_,5), SIZE(" << name << "_,6)))" << iendl; \ |
---|
[932] | 1044 | oss << " " << name_tmp << " = " << name << "_" << iendl; \ |
---|
[2620] | 1045 | oss << " CALL xios_logical_to_bool_6d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \ |
---|
[966] | 1046 | oss << " CALL cxios_set_" << className << "_" << name << " &" << iendl; \ |
---|
| 1047 | oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
[932] | 1048 | } \ |
---|
[966] | 1049 | else { oss << " CALL cxios_set_" << className << "_" << name << " &" << iendl; \ |
---|
| 1050 | oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \ |
---|
[932] | 1051 | oss << "ENDIF"; \ |
---|
| 1052 | }\ |
---|
| 1053 | \ |
---|
| 1054 | template <> \ |
---|
| 1055 | void CInterface::AttributeFortranInterfaceBody< CArray<T,7> >(ostream& oss, const string& className, const string& name) \ |
---|
| 1056 | { \ |
---|
| 1057 | string name_tmp=name+"__tmp"; \ |
---|
| 1058 | \ |
---|
| 1059 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 1060 | if (!matchingTypeCFortran<T>()) \ |
---|
| 1061 | { \ |
---|
[966] | 1062 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \ |
---|
| 1063 | oss << " SIZE(" << name << "_,4), SIZE(" << name << "_,5), SIZE(" << name << "_,6), &" << iendl; \ |
---|
| 1064 | oss << " SIZE(" << name << "_,7)))" << iendl; \ |
---|
[932] | 1065 | oss << " " << name_tmp << " = " << name << "_" << iendl; \ |
---|
[2620] | 1066 | oss << " CALL xios_logical_to_bool_7d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \ |
---|
[966] | 1067 | oss << " CALL cxios_set_" << className << "_" << name << " &" << iendl; \ |
---|
| 1068 | oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
[932] | 1069 | } \ |
---|
[966] | 1070 | else { oss << " CALL cxios_set_" << className << "_" << name << " &" << iendl; \ |
---|
| 1071 | oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \ |
---|
[932] | 1072 | oss << "ENDIF"; \ |
---|
[672] | 1073 | } |
---|
[509] | 1074 | |
---|
[369] | 1075 | macro(bool) |
---|
| 1076 | macro(double) |
---|
| 1077 | macro(int) |
---|
| 1078 | |
---|
| 1079 | #undef macro |
---|
| 1080 | |
---|
[1158] | 1081 | #define macro(T)\ |
---|
| 1082 | template <>\ |
---|
| 1083 | void CInterface::AttributeFortranInterfaceBody< CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\ |
---|
| 1084 | {\ |
---|
| 1085 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 1086 | oss << " CALL cxios_set_" << className << "_" << name << " &" << iendl; \ |
---|
| 1087 | oss << "(" << className << "_hdl%daddr, " << name <<"_, LEN("<<name<<"_), LEN_TRIM("<<name<< "_), SHAPE(" << name << "_))" << iendl; \ |
---|
| 1088 | oss << "ENDIF"; \ |
---|
| 1089 | } |
---|
| 1090 | |
---|
| 1091 | macro(1) |
---|
| 1092 | macro(2) |
---|
| 1093 | #undef macro |
---|
| 1094 | |
---|
[369] | 1095 | #define macro(T) \ |
---|
[672] | 1096 | template <> \ |
---|
| 1097 | void CInterface::AttributeFortranInterfaceGetBody< CArray<T,1> >(ostream& oss, const string& className, const string& name) \ |
---|
| 1098 | { \ |
---|
| 1099 | string name_tmp=name+"__tmp"; \ |
---|
[369] | 1100 | \ |
---|
[672] | 1101 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 1102 | if (!matchingTypeCFortran<T>()) \ |
---|
| 1103 | { \ |
---|
[674] | 1104 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1)))" << iendl; \ |
---|
[966] | 1105 | oss << " CALL cxios_get_" << className << "_" << name << " &" << iendl; \ |
---|
| 1106 | oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
[2620] | 1107 | oss << " CALL xios_bool_to_logical_1d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \ |
---|
[672] | 1108 | oss << " " << name << "_ = " << name_tmp << iendl; \ |
---|
| 1109 | } \ |
---|
[966] | 1110 | else { oss << " CALL cxios_get_" << className << "_" << name << " &" << iendl; \ |
---|
| 1111 | oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \ |
---|
[672] | 1112 | oss << "ENDIF"; \ |
---|
| 1113 | } \ |
---|
[369] | 1114 | \ |
---|
[672] | 1115 | template <> \ |
---|
| 1116 | void CInterface::AttributeFortranInterfaceGetBody< CArray<T,2> >(ostream& oss, const string& className, const string& name) \ |
---|
| 1117 | { \ |
---|
| 1118 | string name_tmp=name+"__tmp"; \ |
---|
[369] | 1119 | \ |
---|
[672] | 1120 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 1121 | if (!matchingTypeCFortran<T>()) \ |
---|
| 1122 | { \ |
---|
[674] | 1123 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2)))" << iendl; \ |
---|
[966] | 1124 | oss << " CALL cxios_get_" << className << "_" << name << " &" << iendl; \ |
---|
| 1125 | oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
[2620] | 1126 | oss << " CALL xios_bool_to_logical_2d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \ |
---|
[672] | 1127 | oss << " " << name << "_ = " << name_tmp << iendl; \ |
---|
| 1128 | } \ |
---|
[966] | 1129 | else { oss << " CALL cxios_get_" << className << "_" << name << " &" << iendl; \ |
---|
| 1130 | oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \ |
---|
[672] | 1131 | oss << "ENDIF"; \ |
---|
| 1132 | } \ |
---|
[932] | 1133 | \ |
---|
[672] | 1134 | template <> \ |
---|
| 1135 | void CInterface::AttributeFortranInterfaceGetBody< CArray<T,3> >(ostream& oss, const string& className, const string& name) \ |
---|
| 1136 | { \ |
---|
| 1137 | string name_tmp=name+"__tmp"; \ |
---|
[369] | 1138 | \ |
---|
[672] | 1139 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 1140 | if (!matchingTypeCFortran<T>()) \ |
---|
| 1141 | { \ |
---|
[674] | 1142 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3)))" << iendl; \ |
---|
[966] | 1143 | oss << " CALL cxios_get_" << className << "_" << name << " &" << iendl; \ |
---|
| 1144 | oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
[2620] | 1145 | oss << " CALL xios_bool_to_logical_3d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \ |
---|
[672] | 1146 | oss << " " << name << "_ = " << name_tmp << iendl; \ |
---|
[369] | 1147 | } \ |
---|
[966] | 1148 | else { oss << " CALL cxios_get_" << className << "_" << name << " &" << iendl; \ |
---|
| 1149 | oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \ |
---|
[672] | 1150 | oss << "ENDIF"; \ |
---|
[932] | 1151 | } \ |
---|
| 1152 | \ |
---|
| 1153 | template <> \ |
---|
| 1154 | void CInterface::AttributeFortranInterfaceGetBody< CArray<T,4> >(ostream& oss, const string& className, const string& name) \ |
---|
| 1155 | { \ |
---|
| 1156 | string name_tmp=name+"__tmp"; \ |
---|
| 1157 | \ |
---|
| 1158 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 1159 | if (!matchingTypeCFortran<T>()) \ |
---|
| 1160 | { \ |
---|
[966] | 1161 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \ |
---|
| 1162 | oss << " SIZE(" << name << "_,4)))" << iendl; \ |
---|
| 1163 | oss << " CALL cxios_get_" << className << "_" << name << " &" << iendl; \ |
---|
| 1164 | oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
[2620] | 1165 | oss << " CALL xios_bool_to_logical_4d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \ |
---|
[932] | 1166 | oss << " " << name << "_ = " << name_tmp << iendl; \ |
---|
| 1167 | } \ |
---|
[966] | 1168 | else { oss << " CALL cxios_get_" << className << "_" << name << " &" << iendl; \ |
---|
| 1169 | oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; }\ |
---|
[932] | 1170 | oss << "ENDIF"; \ |
---|
| 1171 | } \ |
---|
| 1172 | \ |
---|
| 1173 | template <> \ |
---|
| 1174 | void CInterface::AttributeFortranInterfaceGetBody< CArray<T,5> >(ostream& oss, const string& className, const string& name) \ |
---|
| 1175 | { \ |
---|
| 1176 | string name_tmp=name+"__tmp"; \ |
---|
| 1177 | \ |
---|
| 1178 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 1179 | if (!matchingTypeCFortran<T>()) \ |
---|
| 1180 | { \ |
---|
[966] | 1181 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \ |
---|
| 1182 | oss << " SIZE(" << name << "_,4), SIZE(" << name << "_,5)))" << iendl; \ |
---|
| 1183 | oss << " CALL cxios_get_" << className << "_" << name << " &" << iendl; \ |
---|
| 1184 | oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
[2620] | 1185 | oss << " CALL xios_bool_to_logical_5d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \ |
---|
[932] | 1186 | oss << " " << name << "_ = " << name_tmp << iendl; \ |
---|
| 1187 | } \ |
---|
[966] | 1188 | else { oss << " CALL cxios_get_" << className << "_" << name << " &" << iendl; \ |
---|
| 1189 | oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \ |
---|
[932] | 1190 | oss << "ENDIF"; \ |
---|
| 1191 | }\ |
---|
| 1192 | \ |
---|
| 1193 | template <> \ |
---|
| 1194 | void CInterface::AttributeFortranInterfaceGetBody< CArray<T,6> >(ostream& oss, const string& className, const string& name) \ |
---|
| 1195 | { \ |
---|
| 1196 | string name_tmp=name+"__tmp"; \ |
---|
| 1197 | \ |
---|
| 1198 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 1199 | if (!matchingTypeCFortran<T>()) \ |
---|
| 1200 | { \ |
---|
[966] | 1201 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \ |
---|
| 1202 | oss << " SIZE(" << name << "_,4), SIZE(" << name << "_,5), SIZE(" << name << "_,6)))" << iendl; \ |
---|
| 1203 | oss << " CALL cxios_get_" << className << "_" << name << " &" << iendl; \ |
---|
| 1204 | oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
[2620] | 1205 | oss << " CALL xios_bool_to_logical_6d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \ |
---|
[932] | 1206 | oss << " " << name << "_ = " << name_tmp << iendl; \ |
---|
| 1207 | } \ |
---|
[966] | 1208 | else { oss << " CALL cxios_get_" << className << "_" << name << " &" << iendl; \ |
---|
| 1209 | oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \ |
---|
[932] | 1210 | oss << "ENDIF"; \ |
---|
| 1211 | } \ |
---|
| 1212 | \ |
---|
| 1213 | template <> \ |
---|
| 1214 | void CInterface::AttributeFortranInterfaceGetBody< CArray<T,7> >(ostream& oss, const string& className, const string& name) \ |
---|
| 1215 | { \ |
---|
| 1216 | string name_tmp=name+"__tmp"; \ |
---|
| 1217 | \ |
---|
| 1218 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 1219 | if (!matchingTypeCFortran<T>()) \ |
---|
| 1220 | { \ |
---|
[966] | 1221 | oss << " ALLOCATE(" << name_tmp << "(SIZE(" << name << "_,1), SIZE(" << name << "_,2), SIZE(" << name << "_,3), &" << iendl; \ |
---|
| 1222 | oss << " SIZE(" << name << "_,4), SIZE(" << name << "_,5), SIZE(" << name << "_,6), &" << iendl; \ |
---|
| 1223 | oss << " SIZE(" << name << "_,7)))" << iendl; \ |
---|
| 1224 | oss << " CALL cxios_get_" << className << "_" << name << " &" << iendl; \ |
---|
| 1225 | oss << "(" << className << "_hdl%daddr, " << name_tmp << ", SHAPE(" << name << "_))" << iendl; \ |
---|
[2620] | 1226 | oss << " CALL xios_bool_to_logical_7d(" << name_tmp << ", SHAPE("<< name_tmp << "))" << iendl; \ |
---|
[932] | 1227 | oss << " " << name << "_ = " << name_tmp << iendl; \ |
---|
| 1228 | } \ |
---|
[966] | 1229 | else { oss << " CALL cxios_get_" << className << "_" << name << " &" << iendl; \ |
---|
| 1230 | oss << "(" << className << "_hdl%daddr, " << name << "_, SHAPE(" << name << "_))" << iendl; } \ |
---|
[932] | 1231 | oss << "ENDIF"; \ |
---|
[672] | 1232 | } |
---|
[509] | 1233 | |
---|
[369] | 1234 | macro(bool) |
---|
| 1235 | macro(double) |
---|
| 1236 | macro(int) |
---|
| 1237 | |
---|
| 1238 | #undef macro |
---|
[1158] | 1239 | |
---|
| 1240 | #define macro(T)\ |
---|
| 1241 | template <> \ |
---|
| 1242 | void CInterface::AttributeFortranInterfaceGetBody< CArray<StdString,T> >(ostream& oss, const string& className, const string& name)\ |
---|
| 1243 | {\ |
---|
| 1244 | oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ |
---|
| 1245 | oss << " CALL cxios_get_" << className << "_" << name << " &" << iendl; \ |
---|
| 1246 | oss << "(" << className << "_hdl%daddr, " << name << "_, LEN("<<name<<"_), SHAPE(" << name << "_))" << iendl; \ |
---|
| 1247 | oss << "ENDIF"; \ |
---|
| 1248 | } |
---|
| 1249 | macro(1) |
---|
| 1250 | macro(2) |
---|
| 1251 | macro(3) |
---|
| 1252 | macro(4) |
---|
| 1253 | macro(5) |
---|
| 1254 | macro(6) |
---|
| 1255 | macro(7) |
---|
| 1256 | |
---|
| 1257 | #undef macro |
---|
| 1258 | |
---|
[313] | 1259 | } |
---|
| 1260 | #endif |
---|