Changeset 672
- Timestamp:
- 08/25/15 10:50:20 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/generate_interface_impl.hpp
r591 r672 64 64 oss << " CTimer::get(\"XIOS\").resume();" << iendl; 65 65 oss << " " << className << "_hdl->" << name << ".setValue(" << name << ");" << iendl; 66 // oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;67 66 oss << " CTimer::get(\"XIOS\").suspend();" << iendl; 68 67 oss << "}" << std::endl; … … 86 85 oss << " CTimer::get(\"XIOS\").resume();" << iendl; 87 86 oss << " " << className << "_hdl->" << name << ".setValue(" << name << "_str);" << iendl; 88 // oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;89 87 oss << " CTimer::get(\"XIOS\").suspend();" << iendl; 90 88 oss << "}" << std::endl; … … 97 95 oss << " if (!string_copy(" << className << "_hdl->" << name << ".getInheritedValue(), " << name << ", " << name << "_size))" << iendl; 98 96 oss << " ERROR(\"void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, char * " << name << ", int " 99 << name << "_size)\", << \"Input string is too short\");" << iendl;97 << name << "_size)\", << \"Input string is too short\");" << iendl; 100 98 oss << " CTimer::get(\"XIOS\").suspend();" << iendl; 101 99 oss << "}" << std::endl; … … 111 109 oss << " CTimer::get(\"XIOS\").resume();" << iendl; 112 110 oss << " " << className << "_hdl->" << name << ".fromString(" << name << "_str);" << iendl; 113 // oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl;114 111 oss << " CTimer::get(\"XIOS\").suspend();" << iendl; 115 112 oss << "}" << std::endl; … … 122 119 oss << " if (!string_copy(" << className << "_hdl->" << name << ".getInheritedStringValue(), " << name << ", " << name << "_size))" << iendl; 123 120 oss << " ERROR(\"void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, char * " << name << ", int " 124 << name << "_size)\", << \"Input string is too short\");" << iendl;121 << name << "_size)\", << \"Input string is too short\");" << iendl; 125 122 oss << " CTimer::get(\"XIOS\").suspend();" << iendl; 126 123 oss << "}" << std::endl; … … 197 194 } 198 195 199 /*200 #define macro(T) \201 template <> \202 void CInterface::AttributeCInterface<ARRAY(T,1)>(ostream& oss, const string& className, const string& name) \203 { \204 string typeName=getStrType<T>(); \205 \206 oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int extent1)" << iendl; \207 oss << "{" << iendl; \208 oss << " CTimer::get(\"XIOS\").resume();" << iendl; \209 oss << " ARRAY(" << typeName << ",1) array_tmp(new CArray<" << typeName << ",1>(boost::extents[extent1]));" << iendl; \210 oss << " std::copy(" << name << ", &(" << name << "[array_tmp->num_elements()]), array_tmp->data());" << iendl; \211 oss << " " << className << "_hdl->" << name << ".setValue(array_tmp);" << iendl; \212 // oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl; \213 oss << "}" << std::endl; \214 oss << iendl; \215 oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int extent1)" << iendl; \216 oss << "{" << iendl; \217 oss << " if (!array_copy(" << className << "_hdl->" << name << ".getValue(), " << name << ", extent1))" << iendl; \218 oss << " ERROR(\"void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int extent1)\", << " \219 << "\"Output array size is not conform to array size attribute\");" << iendl; \220 oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \221 oss << "}" << std::endl; \222 } \223 \224 template <> \225 void CInterface::AttributeCInterface<ARRAY(T,2)>(ostream& oss, const string& className, const string& name) \226 { \227 string typeName=getStrType<T>(); \228 \229 oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int extent1, int extent2)" << iendl; \230 oss << "{" << iendl; \231 oss << " CTimer::get(\"XIOS\").resume();" << iendl; \232 oss << " ARRAY(" << typeName << ",2) array_tmp(new CArray<" << typeName << ",2>(boost::extents[extent1][extent2]));" << iendl; \233 oss << " std::copy(" << name << ", &(" << name << "[array_tmp->num_elements()]), array_tmp->data());" << iendl; \234 oss << " " << className << "_hdl->" << name << ".setValue(array_tmp);" << iendl; \235 // oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl; \236 oss << "}" << std::endl; \237 oss << iendl; \238 oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int extent1, int extent2)" << iendl; \239 oss << "{" << iendl; \240 oss << " if (!array_copy(" << className << "_hdl->" << name << ".getValue(), " << name << ", extent1, extent2))" << iendl; \241 oss << " ERROR(\"void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int extent1, int extent2)\", << " \242 << "\"Output array size is not conform to array size attribute\");" << iendl; \243 oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \244 oss << "}" << std::endl; \245 } \246 \247 template <> \248 void CInterface::AttributeCInterface<ARRAY(T,3)>(ostream& oss, const string& className, const string& name) \249 { \250 string typeName=getStrType<T>(); \251 \252 oss << "void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int extent1, int extent2, int extent3)" << iendl; \253 oss << "{" << iendl; \254 oss << " CTimer::get(\"XIOS\").resume();" << iendl; \255 oss << " ARRAY(" << typeName << ",3) array_tmp(new CArray<" << typeName << ",3>(boost::extents[extent1][extent2][extent3]));" << iendl; \256 oss << " std::copy(" << name << ", &(" << name << "[array_tmp->num_elements()]), array_tmp->data());" << iendl; \257 oss << " " << className << "_hdl->" << name << ".setValue(array_tmp);" << iendl; \258 // oss << " " << className << "_hdl->sendAttributToServer(" << className << "_hdl->" << name << ");" << iendl; \259 oss << "}" << std::endl; \260 oss << iendl; \261 oss << "void cxios_get_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int extent1, int extent2, int extent3)" << iendl; \262 oss << "{" << iendl; \263 oss << " if (!array_copy(" << className << "_hdl->" << name << ".getValue(), " << name << ", extent1))" << iendl; \264 oss << " ERROR(\"void cxios_set_" << className << "_" << name << "(" << className << "_Ptr " << className << "_hdl, " << typeName << "* " << name << ", int extent1, int extent2, int extent3)\", << " \265 << "\"Output array size is not conform to array size attribute\");" << iendl; \266 oss << " CTimer::get(\"XIOS\").suspend();" << iendl; \267 oss << "}" << std::endl; \268 }269 270 macro(bool)271 macro(double)272 macro(int)273 */274 275 196 #undef macro 276 197 … … 278 199 // // Fortran 2003 Interface // 279 200 // ///////////////////////////////////////////////// 280 void CInterface::AttributeIsDefinedFortran2003Interface(ostream& oss, const string& className, const string& name) 281 { 282 oss << "FUNCTION cxios_is_defined_" << className << "_" << name << "(" << className << "_hdl) BIND(C)" << iendl; 283 oss << " USE ISO_C_BINDING" << iendl; 284 oss << " LOGICAL(kind=C_BOOL) :: cxios_is_defined_" << className << "_" << name << iendl; 285 oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; 286 oss << "END FUNCTION cxios_is_defined_" << className << "_" << name << std::endl; 287 } 288 289 template <class T> 290 void CInterface::AttributeFortran2003Interface(ostream& oss, const string& className, const string& name) 291 { 292 string fortranType=getStrFortranType<T>(); 293 string fortranKindC=getStrFortranKindC<T>(); 294 295 oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; 296 oss << " USE ISO_C_BINDING" << iendl; 297 oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; 298 oss << " " << fortranType << " " << fortranKindC << " , VALUE :: " << name << iendl; 299 oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; 300 oss << iendl; 301 oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ") BIND(C)" << iendl; 302 oss << " USE ISO_C_BINDING" << iendl; 303 oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; 304 oss << " " << fortranType << " " << fortranKindC << " :: " << name << iendl; 305 oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; 306 } 307 308 template <> 309 void CInterface::AttributeFortran2003Interface<string>(ostream& oss, const string& className, const string& name) 310 { 311 oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", " << name << "_size) BIND(C)" << iendl; 312 oss << " USE ISO_C_BINDING" << iendl; 313 oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; 314 oss << " CHARACTER(kind = C_CHAR) , DIMENSION(*) :: " << name << iendl; 315 oss << " INTEGER (kind = C_INT) , VALUE :: " << name << "_size" << iendl; 316 oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; 317 oss << iendl; 318 oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", " << name << "_size) BIND(C)" << iendl; 319 oss << " USE ISO_C_BINDING" << iendl; 320 oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; 321 oss << " CHARACTER(kind = C_CHAR) , DIMENSION(*) :: " << name << iendl; 322 oss << " INTEGER (kind = C_INT) , VALUE :: " << name << "_size" << iendl; 323 oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; 324 } 201 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 } 210 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>(); 216 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 } 229 230 template <> 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 } 325 247 326 248 template <> … … 360 282 } 361 283 362 /* 363 #define macro(T) \ 364 template <> \ 365 void CInterface::AttributeFortran2003Interface<ARRAY(T,1)>(ostream& oss, const string& className, const string& name) \ 366 { \ 367 string fortranType=getStrFortranType<T>(); \ 368 string fortranKindC=getStrFortranKindC<T>(); \ 369 \ 370 oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent1) BIND(C)" << iendl; \ 371 oss << " USE ISO_C_BINDING" << iendl; \ 372 oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ 373 oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ 374 oss << " INTEGER (kind = C_INT), VALUE :: extent1" << iendl; \ 375 oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ 376 oss << iendl; \ 377 oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent1) BIND(C)" << iendl; \ 378 oss << " USE ISO_C_BINDING" << iendl; \ 379 oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ 380 oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ 381 oss << " INTEGER (kind = C_INT), VALUE :: extent1" << iendl; \ 382 oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ 383 } \ 384 \ 385 template <> \ 386 void CInterface::AttributeFortran2003Interface<ARRAY(T,2)>(ostream& oss, const string& className, const string& name) \ 387 { \ 388 string fortranType=getStrFortranType<T>(); \ 389 string fortranKindC=getStrFortranKindC<T>(); \ 390 \ 391 oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent1, extent2) BIND(C)" << iendl; \ 392 oss << " USE ISO_C_BINDING" << iendl; \ 393 oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ 394 oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ 395 oss << " INTEGER (kind = C_INT), VALUE :: extent1" << iendl; \ 396 oss << " INTEGER (kind = C_INT), VALUE :: extent2" << iendl; \ 397 oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ 398 oss << iendl; \ 399 oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent1, extent2) BIND(C)" << iendl; \ 400 oss << " USE ISO_C_BINDING" << iendl; \ 401 oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ 402 oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ 403 oss << " INTEGER (kind = C_INT), VALUE :: extent1" << iendl; \ 404 oss << " INTEGER (kind = C_INT), VALUE :: extent2" << iendl; \ 405 oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ 406 } \ 407 \ 408 template <> \ 409 void CInterface::AttributeFortran2003Interface<ARRAY(T,3)>(ostream& oss, const string& className, const string& name) \ 410 { \ 411 string fortranType=getStrFortranType<T>(); \ 412 string fortranKindC=getStrFortranKindC<T>(); \ 413 \ 414 oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent1, extent2, extent3) BIND(C)" << iendl; \ 415 oss << " USE ISO_C_BINDING" << iendl; \ 416 oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ 417 oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ 418 oss << " INTEGER (kind = C_INT), VALUE :: extent1" << iendl; \ 419 oss << " INTEGER (kind = C_INT), VALUE :: extent2" << iendl; \ 420 oss << " INTEGER (kind = C_INT), VALUE :: extent3" << iendl; \ 421 oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ 422 oss << iendl; \ 423 oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent1, extent2, extent3) BIND(C)" << iendl; \ 424 oss << " USE ISO_C_BINDING" << iendl; \ 425 oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ 426 oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ 427 oss << " INTEGER (kind = C_INT), VALUE :: extent1" << iendl; \ 428 oss << " INTEGER (kind = C_INT), VALUE :: extent2" << iendl; \ 429 oss << " INTEGER (kind = C_INT), VALUE :: extent3" << iendl; \ 430 oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ 431 } 432 433 macro(bool) 434 macro(double) 435 macro(int) 436 437 #undef macro 438 */ 439 template <class T> 440 void CInterface::AttributeFortranInterfaceDeclaration(ostream& oss, const string& className, const string& name) 441 { 442 oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name; 443 if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " :: " << name << "_tmp"; 444 } 445 446 template <class T> 447 void CInterface::AttributeFortranInterfaceGetDeclaration(ostream& oss, const string& className, const string& name) 448 { 449 oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name; 450 if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " :: " << name << "_tmp"; 451 } 452 453 void CInterface::AttributeFortranInterfaceIsDefinedDeclaration(ostream& oss, const string& className, const string& name) 454 { 455 oss << "LOGICAL, OPTIONAL, INTENT(OUT) :: " << name << iendl; 456 oss << "LOGICAL(KIND=C_BOOL) :: " << name << "_tmp"; 457 } 458 459 template <> 460 void CInterface::AttributeFortranInterfaceDeclaration<string>(ostream& oss, const string& className, const string& name) 461 { 462 oss << "CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: " << name; 463 } 464 465 template <> 466 void CInterface::AttributeFortranInterfaceGetDeclaration<string>(ostream& oss, const string& className, const string& name) 467 { 468 oss << "CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: " << name; 469 } 470 471 /* 472 #define macro(T) \ 473 template <> \ 474 void CInterface::AttributeFortranInterfaceDeclaration<ARRAY(T,1)>(ostream& oss, const string& className, const string& name) \ 475 { \ 476 oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:)"; \ 477 if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:)"; \ 478 } \ 479 template <> \ 480 void CInterface::AttributeFortranInterfaceGetDeclaration<ARRAY(T,1)>(ostream& oss, const string& className, const string& name) \ 481 { \ 482 oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:)"; \ 483 if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:)"; \ 484 } \ 485 \ 486 template <> \ 487 void CInterface::AttributeFortranInterfaceDeclaration<ARRAY(T,2)>(ostream& oss, const string& className, const string& name) \ 488 { \ 489 oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:)"; \ 490 if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:)"; \ 491 } \ 492 \ 493 template <> \ 494 void CInterface::AttributeFortranInterfaceGetDeclaration<ARRAY(T,2)>(ostream& oss, const string& className, const string& name) \ 495 { \ 496 oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:)"; \ 497 if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:)"; \ 498 } \ 499 \ 500 template <> \ 501 void CInterface::AttributeFortranInterfaceDeclaration<ARRAY(T,3)>(ostream& oss, const string& className, const string& name) \ 502 { \ 503 oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:)"; \ 504 if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:)"; \ 505 } \ 506 \ 507 template <> \ 508 void CInterface::AttributeFortranInterfaceGetDeclaration<ARRAY(T,3)>(ostream& oss, const string& className, const string& name) \ 509 { \ 510 oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:)"; \ 511 if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:)"; \ 512 } 513 514 macro(bool) 515 macro(double) 516 macro(int) 517 518 #undef macro 519 */ 520 521 template <class T> 522 void CInterface::AttributeFortranInterfaceBody(ostream& oss, const string& className, const string& name) 523 { 524 string name_tmp=name+"__tmp"; 525 526 oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; 527 if (!matchingTypeCFortran<T>()) 528 { 529 oss << " " << name_tmp << " = " << name << "_" << iendl; 530 oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ")" << iendl; 531 } 532 else oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_)" << iendl; 533 oss << "ENDIF"; 534 } 535 536 template <class T> 537 void CInterface::AttributeFortranInterfaceGetBody(ostream& oss, const string& className, const string& name) 538 { 539 string name_tmp=name+"__tmp"; 540 541 oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; 542 if (!matchingTypeCFortran<T>()) 543 { 544 oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ")" << iendl; 545 oss << " " << name << "_ = " << name_tmp << iendl; 546 } 547 else oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_)" << iendl; 548 oss << "ENDIF"; 549 } 550 551 void CInterface::AttributeFortranInterfaceIsDefinedBody(ostream& oss, const string& className, const string& name) 552 { 553 string name_tmp=name+"__tmp"; 554 555 oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; 556 oss << " " << name << "__tmp = cxios_is_defined_" << className << "_" << name << "(" << className << "_hdl%daddr)" << iendl; 557 oss << " " << name << "_ = " << name_tmp << iendl; 558 oss << "ENDIF"; 559 } 560 561 template <> 562 void CInterface::AttributeFortranInterfaceBody<string>(ostream& oss, const string& className, const string& name) 563 { 564 oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; 565 oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, len(" << name << "_))" << iendl; 566 oss << "ENDIF"; 567 } 568 569 template <> 570 void CInterface::AttributeFortranInterfaceGetBody<string>(ostream& oss, const string& className, const string& name) 571 { 572 oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; 573 oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, len(" << name << "_))" << iendl; 574 oss << "ENDIF"; 575 } 576 577 /* 578 #define macro(T) \ 579 template <> \ 580 void CInterface::AttributeFortranInterfaceBody< ARRAY(T,1) >(ostream& oss, const string& className, const string& name) \ 581 { \ 582 string name_tmp=name+"__tmp"; \ 583 \ 584 oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ 585 if (!matchingTypeCFortran<T>()) \ 586 { \ 587 oss << " ALLOCATE(" << name_tmp << "(size(" << name << "_,1)))" << iendl; \ 588 oss << " " << name_tmp << " = " << name << "_" << iendl; \ 589 oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", size(" << name << "_,1))" << iendl; \ 590 } \ 591 else oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, size(" << name << "_,1))" << iendl; \ 592 oss << "ENDIF"; \ 593 } \ 594 \ 595 template <> \ 596 void CInterface::AttributeFortranInterfaceBody< ARRAY(T,2) >(ostream& oss, const string& className, const string& name) \ 597 { \ 598 string name_tmp=name+"__tmp"; \ 599 \ 600 oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ 601 if (!matchingTypeCFortran<T>()) \ 602 { \ 603 oss << " ALLOCATE(" << name_tmp << "(size(" << name << "_,1), size(" << name << "_,2)))" << iendl; \ 604 oss << " " << name_tmp << " = " << name << "_" << iendl; \ 605 oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", size(" << name << "_,1), size(" << name << "_,2))" << iendl; \ 606 } \ 607 else oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, size(" << name << "_,1), size(" << name << "_,2))" << iendl; \ 608 oss << "ENDIF"; \ 609 } \ 610 \ 611 template <> \ 612 void CInterface::AttributeFortranInterfaceBody< ARRAY(T,3) >(ostream& oss, const string& className, const string& name) \ 613 { \ 614 string name_tmp=name+"__tmp"; \ 615 \ 616 oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ 617 if (!matchingTypeCFortran<T>()) \ 618 { \ 619 oss << " ALLOCATE(" << name_tmp << "(size(" << name << "_,1), size(" << name << "_,2), size(" << name << "_,3)))" << iendl; \ 620 oss << " " << name_tmp << " = " << name << "_" << iendl; \ 621 oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", size(" << name << "_,1), size(" << name << "_,2), size(" << name << "_,3))" << iendl; \ 622 } \ 623 else oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, size(" << name << "_,1), size(" << name << "_,2), size(" << name << "_,3))" << iendl; \ 624 oss << "ENDIF"; \ 625 } 626 627 macro(bool) 628 macro(double) 629 macro(int) 630 631 #undef macro 632 */ 633 634 /* 635 #define macro(T) \ 636 template <> \ 637 void CInterface::AttributeFortranInterfaceGetBody< ARRAY(T,1) >(ostream& oss, const string& className, const string& name) \ 638 { \ 639 string name_tmp=name+"__tmp"; \ 640 \ 641 oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ 642 if (!matchingTypeCFortran<T>()) \ 643 { \ 644 oss << " ALLOCATE(" << name_tmp << "(size(" << name << "_,1)))" << iendl; \ 645 oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", size(" << name << "_,1))" << iendl; \ 646 oss << " " << name << "_ = " << name_tmp << iendl; \ 647 } \ 648 else oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, size(" << name << "_,1))" << iendl; \ 649 oss << "ENDIF"; \ 650 } \ 651 \ 652 template <> \ 653 void CInterface::AttributeFortranInterfaceGetBody< ARRAY(T,2) >(ostream& oss, const string& className, const string& name) \ 654 { \ 655 string name_tmp=name+"__tmp"; \ 656 \ 657 oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ 658 if (!matchingTypeCFortran<T>()) \ 659 { \ 660 oss << " ALLOCATE(" << name_tmp << "(size(" << name << "_,1), size(" << name << "_,2)))" << iendl; \ 661 oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", size(" << name << "_,1), size(" << name << "_,2))" << iendl; \ 662 oss << " " << name << "_ = " << name_tmp << iendl; \ 663 } \ 664 else oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, size(" << name << "_,1), size(" << name << "_,2))" << iendl; \ 665 oss << "ENDIF"; \ 666 } \ 667 \ 668 template <> \ 669 void CInterface::AttributeFortranInterfaceGetBody< ARRAY(T,3) >(ostream& oss, const string& className, const string& name) \ 670 { \ 671 string name_tmp=name+"__tmp"; \ 672 \ 673 oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ 674 if (!matchingTypeCFortran<T>()) \ 675 { \ 676 oss << " ALLOCATE(" << name_tmp << "(size(" << name << "_,1), size(" << name << "_,2), size(" << name << "_,3)))" << iendl; \ 677 oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", size(" << name << "_,1), size(" << name << "_,2), size(" << name << "_,3))" << iendl; \ 678 oss << " " << name << "_ = " << name_tmp << iendl; \ 679 } \ 680 else oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, size(" << name << "_,1), size(" << name << "_,2), size(" << name << "_,3))" << iendl; \ 681 oss << "ENDIF"; \ 682 } 683 684 macro(bool) 685 macro(double) 686 macro(int) 687 688 #undef macro 689 */ 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 } 290 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 } 297 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 } 303 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 } 309 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 } 315 316 template <class T> 317 void CInterface::AttributeFortranInterfaceBody(ostream& oss, const string& className, const string& name) 318 { 319 string name_tmp=name+"__tmp"; 320 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 } 330 331 template <class T> 332 void CInterface::AttributeFortranInterfaceGetBody(ostream& oss, const string& className, const string& name) 333 { 334 string name_tmp=name+"__tmp"; 335 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 } 345 346 void CInterface::AttributeFortranInterfaceIsDefinedBody(ostream& oss, const string& className, const string& name) 347 { 348 string name_tmp=name+"__tmp"; 349 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 } 355 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 } 363 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 } 690 371 691 372 // declaration for CArray … … 772 453 773 454 #define macro(T) \ 774 775 776 777 778 779 \ 780 781 782 783 784 785 786 787 788 789 790 791 792 793 455 template <> \ 456 void CInterface::AttributeFortran2003Interface<CArray<T,1> >(ostream& oss, const string& className, const string& name) \ 457 { \ 458 string fortranType=getStrFortranType<T>(); \ 459 string fortranKindC=getStrFortranKindC<T>(); \ 460 \ 461 oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent1) BIND(C)" << iendl; \ 462 oss << " USE ISO_C_BINDING" << iendl; \ 463 oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ 464 oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ 465 oss << " INTEGER (kind = C_INT), VALUE :: extent1" << iendl; \ 466 oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ 467 oss << iendl; \ 468 oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent1) BIND(C)" << iendl; \ 469 oss << " USE ISO_C_BINDING" << iendl; \ 470 oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ 471 oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ 472 oss << " INTEGER (kind = C_INT), VALUE :: extent1" << iendl; \ 473 oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ 474 } \ 794 475 \ 795 796 797 798 799 800 \ 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 \ 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 476 template <> \ 477 void CInterface::AttributeFortran2003Interface<CArray<T,2> >(ostream& oss, const string& className, const string& name) \ 478 { \ 479 string fortranType=getStrFortranType<T>(); \ 480 string fortranKindC=getStrFortranKindC<T>(); \ 481 \ 482 oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent1, extent2) BIND(C)" << iendl; \ 483 oss << " USE ISO_C_BINDING" << iendl; \ 484 oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ 485 oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ 486 oss << " INTEGER (kind = C_INT), VALUE :: extent1" << iendl; \ 487 oss << " INTEGER (kind = C_INT), VALUE :: extent2" << iendl; \ 488 oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ 489 oss << iendl; \ 490 oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent1, extent2) BIND(C)" << iendl; \ 491 oss << " USE ISO_C_BINDING" << iendl; \ 492 oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ 493 oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ 494 oss << " INTEGER (kind = C_INT), VALUE :: extent1" << iendl; \ 495 oss << " INTEGER (kind = C_INT), VALUE :: extent2" << iendl; \ 496 oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ 497 } \ 498 \ 499 template <> \ 500 void CInterface::AttributeFortran2003Interface<CArray<T,3> >(ostream& oss, const string& className, const string& name) \ 501 { \ 502 string fortranType=getStrFortranType<T>(); \ 503 string fortranKindC=getStrFortranKindC<T>(); \ 504 \ 505 oss << "SUBROUTINE cxios_set_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent1, extent2, extent3) BIND(C)" << iendl; \ 506 oss << " USE ISO_C_BINDING" << iendl; \ 507 oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ 508 oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ 509 oss << " INTEGER (kind = C_INT), VALUE :: extent1" << iendl; \ 510 oss << " INTEGER (kind = C_INT), VALUE :: extent2" << iendl; \ 511 oss << " INTEGER (kind = C_INT), VALUE :: extent3" << iendl; \ 512 oss << "END SUBROUTINE cxios_set_" << className << "_" << name << std::endl; \ 513 oss << iendl; \ 514 oss << "SUBROUTINE cxios_get_" << className << "_" << name << "(" << className << "_hdl, " << name << ", extent1, extent2, extent3) BIND(C)" << iendl; \ 515 oss << " USE ISO_C_BINDING" << iendl; \ 516 oss << " INTEGER (kind = C_INTPTR_T), VALUE :: " << className << "_hdl" << iendl; \ 517 oss << " " << fortranType << " " << fortranKindC << " , DIMENSION(*) :: " << name << iendl; \ 518 oss << " INTEGER (kind = C_INT), VALUE :: extent1" << iendl; \ 519 oss << " INTEGER (kind = C_INT), VALUE :: extent2" << iendl; \ 520 oss << " INTEGER (kind = C_INT), VALUE :: extent3" << iendl; \ 521 oss << "END SUBROUTINE cxios_get_" << className << "_" << name << std::endl; \ 522 } 842 523 843 524 macro(bool) … … 848 529 849 530 #define macro(T) \ 850 851 852 853 854 855 856 857 858 859 860 861 531 template <> \ 532 void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,1> >(ostream& oss, const string& className, const string& name) \ 533 { \ 534 oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:)"; \ 535 if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:)"; \ 536 } \ 537 template <> \ 538 void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,1> >(ostream& oss, const string& className, const string& name) \ 539 { \ 540 oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:)"; \ 541 if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:)"; \ 542 } \ 862 543 \ 863 864 865 866 867 868 544 template <> \ 545 void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,2> >(ostream& oss, const string& className, const string& name) \ 546 { \ 547 oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:)"; \ 548 if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:)"; \ 549 } \ 869 550 \ 870 871 872 873 874 875 551 template <> \ 552 void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,2> >(ostream& oss, const string& className, const string& name) \ 553 { \ 554 oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:)"; \ 555 if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:)"; \ 556 } \ 876 557 \ 877 878 879 880 881 882 558 template <> \ 559 void CInterface::AttributeFortranInterfaceDeclaration<CArray<T,3> >(ostream& oss, const string& className, const string& name) \ 560 { \ 561 oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(IN) :: " << name << "(:,:,:)"; \ 562 if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:)"; \ 563 } \ 883 564 \ 884 885 886 887 888 889 565 template <> \ 566 void CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T,3> >(ostream& oss, const string& className, const string& name) \ 567 { \ 568 oss << getStrFortranType<T>() << " " << getStrFortranKind<T>() << " , OPTIONAL, INTENT(OUT) :: " << name << "(:,:,:)"; \ 569 if (!matchingTypeCFortran<T>()) oss << iendl << getStrFortranType<T>() << " " << getStrFortranKindC<T>() << " , ALLOCATABLE :: " << name << "_tmp(:,:,:)"; \ 570 } 890 571 891 572 macro(bool) … … 896 577 897 578 #define macro(T) \ 898 899 900 901 902 \ 903 904 905 906 907 908 909 910 911 912 579 template <> \ 580 void CInterface::AttributeFortranInterfaceBody< CArray<T,1> >(ostream& oss, const string& className, const string& name) \ 581 { \ 582 string name_tmp=name+"__tmp"; \ 583 \ 584 oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ 585 if (!matchingTypeCFortran<T>()) \ 586 { \ 587 oss << " ALLOCATE(" << name_tmp << "(size(" << name << "_,1)))" << iendl; \ 588 oss << " " << name_tmp << " = " << name << "_" << iendl; \ 589 oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", size(" << name << "_,1))" << iendl; \ 590 } \ 591 else oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, size(" << name << "_,1))" << iendl; \ 592 oss << "ENDIF"; \ 593 } \ 913 594 \ 914 915 916 917 918 \ 919 920 921 922 923 924 925 926 927 928 595 template <> \ 596 void CInterface::AttributeFortranInterfaceBody< CArray<T,2> >(ostream& oss, const string& className, const string& name) \ 597 { \ 598 string name_tmp=name+"__tmp"; \ 599 \ 600 oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ 601 if (!matchingTypeCFortran<T>()) \ 602 { \ 603 oss << " ALLOCATE(" << name_tmp << "(size(" << name << "_,1), size(" << name << "_,2)))" << iendl; \ 604 oss << " " << name_tmp << " = " << name << "_" << iendl; \ 605 oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", size(" << name << "_,1), size(" << name << "_,2))" << iendl; \ 606 } \ 607 else oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, size(" << name << "_,1), size(" << name << "_,2))" << iendl; \ 608 oss << "ENDIF"; \ 609 } \ 929 610 \ 930 931 932 933 934 \ 935 936 937 938 939 940 941 942 943 944 611 template <> \ 612 void CInterface::AttributeFortranInterfaceBody< CArray<T,3> >(ostream& oss, const string& className, const string& name) \ 613 { \ 614 string name_tmp=name+"__tmp"; \ 615 \ 616 oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ 617 if (!matchingTypeCFortran<T>()) \ 618 { \ 619 oss << " ALLOCATE(" << name_tmp << "(size(" << name << "_,1), size(" << name << "_,2), size(" << name << "_,3)))" << iendl; \ 620 oss << " " << name_tmp << " = " << name << "_" << iendl; \ 621 oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", size(" << name << "_,1), size(" << name << "_,2), size(" << name << "_,3))" << iendl; \ 622 } \ 623 else oss << " CALL cxios_set_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, size(" << name << "_,1), size(" << name << "_,2), size(" << name << "_,3))" << iendl; \ 624 oss << "ENDIF"; \ 625 } 945 626 946 627 macro(bool) … … 951 632 952 633 #define macro(T) \ 953 954 955 956 957 \ 958 959 960 961 962 963 964 965 966 967 634 template <> \ 635 void CInterface::AttributeFortranInterfaceGetBody< CArray<T,1> >(ostream& oss, const string& className, const string& name) \ 636 { \ 637 string name_tmp=name+"__tmp"; \ 638 \ 639 oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ 640 if (!matchingTypeCFortran<T>()) \ 641 { \ 642 oss << " ALLOCATE(" << name_tmp << "(size(" << name << "_,1)))" << iendl; \ 643 oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", size(" << name << "_,1))" << iendl; \ 644 oss << " " << name << "_ = " << name_tmp << iendl; \ 645 } \ 646 else oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, size(" << name << "_,1))" << iendl; \ 647 oss << "ENDIF"; \ 648 } \ 968 649 \ 969 970 971 972 973 \ 974 975 976 977 978 979 980 981 982 983 650 template <> \ 651 void CInterface::AttributeFortranInterfaceGetBody< CArray<T,2> >(ostream& oss, const string& className, const string& name) \ 652 { \ 653 string name_tmp=name+"__tmp"; \ 654 \ 655 oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ 656 if (!matchingTypeCFortran<T>()) \ 657 { \ 658 oss << " ALLOCATE(" << name_tmp << "(size(" << name << "_,1), size(" << name << "_,2)))" << iendl; \ 659 oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", size(" << name << "_,1), size(" << name << "_,2))" << iendl; \ 660 oss << " " << name << "_ = " << name_tmp << iendl; \ 661 } \ 662 else oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, size(" << name << "_,1), size(" << name << "_,2))" << iendl; \ 663 oss << "ENDIF"; \ 664 } \ 984 665 \ 985 986 987 988 989 \ 990 991 992 993 994 995 666 template <> \ 667 void CInterface::AttributeFortranInterfaceGetBody< CArray<T,3> >(ostream& oss, const string& className, const string& name) \ 668 { \ 669 string name_tmp=name+"__tmp"; \ 670 \ 671 oss << "IF (PRESENT(" << name << "_)) THEN" << iendl; \ 672 if (!matchingTypeCFortran<T>()) \ 673 { \ 674 oss << " ALLOCATE(" << name_tmp << "(size(" << name << "_,1), size(" << name << "_,2), size(" << name << "_,3)))" << iendl; \ 675 oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name_tmp << ", size(" << name << "_,1), size(" << name << "_,2), size(" << name << "_,3))" << iendl; \ 676 oss << " " << name << "_ = " << name_tmp << iendl; \ 996 677 } \ 997 998 999 678 else oss << " CALL cxios_get_" << className << "_" << name << "(" << className << "_hdl%daddr, " << name << "_, size(" << name << "_,1), size(" << name << "_,2), size(" << name << "_,3))" << iendl; \ 679 oss << "ENDIF"; \ 680 } 1000 681 1001 682 macro(bool)
Note: See TracChangeset
for help on using the changeset viewer.