1 /* 2 This is the main PETSc include file (for C and C++). It is included by all 3 other PETSc include files, so it almost never has to be specifically included. 4 */ 5 #if !defined(__PETSC_H) 6 #define __PETSC_H 7 /* ========================================================================== */ 8 /* 9 petscconf.h is contained in ${PETSC_ARCH}/conf/petscconf.h it is 10 found automatically by the compiler due to the -I${PETSC_DIR}/${PETSC_ARCH}/include 11 in the bmake/common/variables definition of PETSC_INCLUDE 12 */ 13 #include "petscconf.h" 14 15 /* ========================================================================== */ 16 /* 17 This facilitates using C version of PETSc from C++ and 18 C++ version from C. Use --with-c-support --with-clanguage=c++ with config/configure.py for the latter) 19 */ 20 #if defined(PETSC_CLANGUAGE_CXX) && !defined(PETSC_USE_EXTERN_CXX) && !defined(__cplusplus) 21 #error "PETSc configured with --with-clanguage=c++ and NOT --with-c-support - it can be used only with a C++ compiler" 22 #endif 23 24 #if defined(PETSC_USE_EXTERN_CXX) && defined(__cplusplus) 25 #define PETSC_EXTERN_CXX_BEGIN extern "C" { 26 #define PETSC_EXTERN_CXX_END } 27 #else 28 #define PETSC_EXTERN_CXX_BEGIN 29 #define PETSC_EXTERN_CXX_END 30 #endif 31 /* ========================================================================== */ 32 /* 33 Current PETSc version number and release date. Also listed in 34 Web page 35 src/docs/tex/manual/intro.tex, 36 src/docs/tex/manual/manual.tex. 37 src/docs/website/index.html. 38 */ 39 #include "petscversion.h" 40 #define PETSC_AUTHOR_INFO "\ 41 The PETSc Team\n\ 42 petsc-maint@mcs.anl.gov\n\ 43 http://www.mcs.anl.gov/petsc/\n" 44 #if (PETSC_VERSION_RELEASE == 1) 45 #define PetscGetVersion(version,len) (PetscSNPrintf(*(version),len,"Petsc Release Version %d.%d.%d, Patch %d, ", \ 46 PETSC_VERSION_MAJOR,PETSC_VERSION_MINOR, PETSC_VERSION_SUBMINOR, \ 47 PETSC_VERSION_PATCH),PetscStrcat(*(version),PETSC_VERSION_PATCH_DATE), \ 48 PetscStrcat(*(version)," HG revision: "),PetscStrcat(*(version),PETSC_VERSION_HG),0) 49 #else 50 #define PetscGetVersion(version,len) (PetscSNPrintf(*(version),len,"Petsc Development Version %d.%d.%d, Patch %d, ", \ 51 PETSC_VERSION_MAJOR,PETSC_VERSION_MINOR, PETSC_VERSION_SUBMINOR, \ 52 PETSC_VERSION_PATCH),PetscStrcat(*(version),PETSC_VERSION_PATCH_DATE), \ 53 PetscStrcat(*(version)," HG revision: "),PetscStrcat(*(version),PETSC_VERSION_HG),0) 54 #endif 55 56 /*MC 57 PetscGetVersion - Gets the Petsc Version information in a string. 58 59 Output Parameter: 60 . version - version string 61 62 Input Parameter: 63 . len - length of the string 64 65 Level: developer 66 67 Usage: 68 char version[256]; 69 PetscGetVersion(&version,256); 70 71 Fortran Note: 72 This routine is not supported in Fortran. 73 74 .seealso: PetscGetProgramName() 75 76 M*/ 77 78 /* ========================================================================== */ 79 80 /* 81 Currently cannot check formatting for PETSc print statements because we have our 82 own format %D and %G 83 */ 84 #undef PETSC_PRINTF_FORMAT_CHECK 85 #define PETSC_PRINTF_FORMAT_CHECK(a,b) 86 #undef PETSC_FPRINTF_FORMAT_CHECK 87 #define PETSC_FPRINTF_FORMAT_CHECK(a,b) 88 89 /* 90 Fixes for configure time choices which impact our interface. Currently only 91 calling conventions and extra compiler checking falls under this category. 92 */ 93 #if !defined(PETSC_STDCALL) 94 #define PETSC_STDCALL 95 #endif 96 #if !defined(PETSC_TEMPLATE) 97 #define PETSC_TEMPLATE 98 #endif 99 #if !defined(PETSC_HAVE_DLL_EXPORT) 100 #define PETSC_DLL_EXPORT 101 #define PETSC_DLL_IMPORT 102 #endif 103 #if !defined(PETSC_DLLEXPORT) 104 #define PETSC_DLLEXPORT 105 #endif 106 #if !defined(PETSCVEC_DLLEXPORT) 107 #define PETSCVEC_DLLEXPORT 108 #endif 109 #if !defined(PETSCMAT_DLLEXPORT) 110 #define PETSCMAT_DLLEXPORT 111 #endif 112 #if !defined(PETSCDM_DLLEXPORT) 113 #define PETSCDM_DLLEXPORT 114 #endif 115 #if !defined(PETSCKSP_DLLEXPORT) 116 #define PETSCKSP_DLLEXPORT 117 #endif 118 #if !defined(PETSCSNES_DLLEXPORT) 119 #define PETSCSNES_DLLEXPORT 120 #endif 121 #if !defined(PETSCTS_DLLEXPORT) 122 #define PETSCTS_DLLEXPORT 123 #endif 124 #if !defined(PETSCFORTRAN_DLLEXPORT) 125 #define PETSCFORTRAN_DLLEXPORT 126 #endif 127 /* ========================================================================== */ 128 129 /* 130 Defines the interface to MPI allowing the use of all MPI functions. 131 132 PETSc does not use the C++ binding of MPI at ALL. The following flag 133 makes sure the C++ bindings are not included. The C++ bindings REQUIRE 134 putting mpi.h before ANY C++ include files, we cannot control this 135 with all PETSc users. 136 */ 137 #define MPICH_SKIP_MPICXX 1 138 #include "mpi.h" 139 /* 140 Yuck, we need to put stdio.h AFTER mpi.h for MPICH2 with C++ compiler 141 see the top of mpicxx.h 142 143 The MPI STANDARD HAS TO BE CHANGED to prevent this nonsense. 144 */ 145 #include <stdio.h> 146 147 /*MC 148 PetscErrorCode - datatype used for return error code from all PETSc functions 149 150 Level: beginner 151 152 .seealso: CHKERRQ, SETERRQ 153 M*/ 154 typedef int PetscErrorCode; 155 156 /*MC 157 158 PetscCookie - A unique id used to identify each PETSc object. 159 (internal integer in the data structure used for error 160 checking). These are all defined by an offset from the lowest 161 one, PETSC_SMALLEST_COOKIE. 162 163 Level: advanced 164 165 .seealso: PetscLogClassRegister(), PetscLogEventRegister(), PetscHeaderCreate() 166 M*/ 167 typedef int PetscCookie; 168 169 /*MC 170 PetscEvent - id used to identify PETSc or user events - primarily for logging 171 172 Level: intermediate 173 174 .seealso: PetscLogEventRegister(), PetscLogEventBegin() PetscLogEventEnd() 175 M*/ 176 typedef int PetscEvent; 177 178 /*MC 179 PetscBLASInt - datatype used to represent 'int' parameters to blas functions. 180 181 Level: intermediate 182 M*/ 183 typedef int PetscBLASInt; 184 185 /*MC 186 PetscMPIInt - datatype used to represent 'int' parameters to MPI functions. 187 188 Level: intermediate 189 M*/ 190 typedef int PetscMPIInt; 191 192 /*MC 193 PetscEnum - datatype used to pass enum types within PETSc functions. 194 195 Level: intermediate 196 197 .seealso: PetscOptionsGetEnum(), PetscOptionsEnum(), PetscBagRegisterEnum() 198 M*/ 199 typedef enum { ENUM_DUMMY } PetscEnum; 200 201 /*MC 202 PetscInt - PETSc type that represents integer - used primarily to 203 represent size of objects. Its size can be configured with the option 204 --with-64-bit-indices - to be either 32bit or 64bit [default 32 bit ints] 205 206 Level: intermediate 207 208 .seealso: PetscScalar 209 M*/ 210 #if defined(PETSC_USE_64BIT_INDICES) 211 typedef long long PetscInt; 212 #define MPIU_INT MPI_LONG_LONG_INT 213 #else 214 typedef int PetscInt; 215 #define MPIU_INT MPI_INT 216 #endif 217 218 /* 219 You can use PETSC_STDOUT as a replacement of stdout. You can also change 220 the value of PETSC_STDOUT to redirect all standard output elsewhere 221 */ 222 FILE* PETSC_ZOPEFD; 223 extern FILE* PETSC_STDOUT; 224 225 /* 226 You can use PETSC_STDERR as a replacement of stderr. You can also change 227 the value of PETSC_STDERR to redirect all standard error elsewhere 228 */ 229 extern FILE* PETSC_STDERR; 230 231 #if !defined(PETSC_USE_EXTERN_CXX) && defined(__cplusplus) 232 /*MC 233 PetscPolymorphicSubroutine - allows defining a C++ polymorphic version of 234 a PETSc function that remove certain optional arguments for a simplier user interface 235 236 Not collective 237 238 Synopsis: 239 PetscPolymorphicSubroutine(Functionname,(arguments of C++ function),(arguments of C function)) 240 241 Level: developer 242 243 Example: 244 PetscPolymorphicSubroutine(VecNorm,(Vec x,PetscReal *r),(x,NORM_2,r)) generates the new routine 245 PetscErrorCode VecNorm(Vec x,PetscReal *r) = VecNorm(x,NORM_2,r) 246 247 .seealso: PetscPolymorphicFunction() 248 249 M*/ 250 #define PetscPolymorphicSubroutine(A,B,C) PETSC_STATIC_INLINE PetscErrorCode A B {return A C;} 251 252 /*MC 253 PetscPolymorphicScalar - allows defining a C++ polymorphic version of 254 a PETSc function that replaces a PetscScalar * argument with a PetscScalar argument 255 256 Not collective 257 258 Synopsis: 259 PetscPolymorphicScalar(Functionname,(arguments of C++ function),(arguments of C function)) 260 261 Level: developer 262 263 Example: 264 PetscPolymorphicScalar(VecAXPY,(PetscScalar _val,Vec x,Vec y),(&_Val,x,y)) generates the new routine 265 PetscErrorCode VecAXPY(PetscScalar _val,Vec x,Vec y) = {PetscScalar _Val = _val; return VecAXPY(&_Val,x,y);} 266 267 .seealso: PetscPolymorphicFunction(),PetscPolymorphicSubroutine() 268 269 M*/ 270 #define PetscPolymorphicScalar(A,B,C) PETSC_STATIC_INLINE PetscErrorCode A B {PetscScalar _Val = _val; return A C;} 271 272 /*MC 273 PetscPolymorphicFunction - allows defining a C++ polymorphic version of 274 a PETSc function that remove certain optional arguments for a simplier user interface 275 and returns the computed value (istead of an error code) 276 277 Not collective 278 279 Synopsis: 280 PetscPolymorphicFunction(Functionname,(arguments of C++ function),(arguments of C function),return type,return variable name) 281 282 Level: developer 283 284 Example: 285 PetscPolymorphicFunction(VecNorm,(Vec x,NormType t),(x,t,&r),PetscReal,r) generates the new routine 286 PetscReal VecNorm(Vec x,NormType t) = {PetscReal r; VecNorm(x,t,&r); return r;} 287 288 .seealso: PetscPolymorphicSubroutine() 289 290 M*/ 291 #define PetscPolymorphicFunction(A,B,C,D,E) PETSC_STATIC_INLINE D A B {D E; A C;return E;} 292 293 #else 294 #define PetscPolymorphicSubroutine(A,B,C) 295 #define PetscPolymorphicScalar(A,B,C) 296 #define PetscPolymorphicFunction(A,B,C,D,E) 297 #endif 298 299 /* 300 Extern indicates a PETSc function defined elsewhere 301 */ 302 #if !defined(EXTERN) 303 #define EXTERN extern 304 #endif 305 306 /* 307 Defines some elementary mathematics functions and constants. 308 */ 309 #include "petscmath.h" 310 311 /* 312 Declare extern C stuff after including external header files 313 */ 314 315 PETSC_EXTERN_CXX_BEGIN 316 317 /* 318 Basic PETSc constants 319 */ 320 321 /*E 322 PetscTruth - Logical variable. Actually an integer 323 324 Level: beginner 325 326 E*/ 327 typedef enum { PETSC_FALSE,PETSC_TRUE } PetscTruth; 328 extern const char *PetscTruths[]; 329 330 /*MC 331 PETSC_FALSE - False value of PetscTruth 332 333 Level: beginner 334 335 Note: Zero integer 336 337 .seealso: PetscTruth, PETSC_TRUE 338 M*/ 339 340 /*MC 341 PETSC_TRUE - True value of PetscTruth 342 343 Level: beginner 344 345 Note: Nonzero integer 346 347 .seealso: PetscTruth, PETSC_FALSE 348 M*/ 349 350 /*MC 351 PETSC_YES - Alias for PETSC_TRUE 352 353 Level: beginner 354 355 Note: Zero integer 356 357 .seealso: PetscTruth, PETSC_TRUE, PETSC_FALSE, PETSC_NO 358 M*/ 359 #define PETSC_YES PETSC_TRUE 360 361 /*MC 362 PETSC_NO - Alias for PETSC_FALSE 363 364 Level: beginner 365 366 Note: Nonzero integer 367 368 .seealso: PetscTruth, PETSC_TRUE, PETSC_FALSE, PETSC_YES 369 M*/ 370 #define PETSC_NO PETSC_FALSE 371 372 /*MC 373 PETSC_NULL - standard way of passing in a null or array or pointer 374 375 Level: beginner 376 377 Notes: accepted by many PETSc functions to not set a parameter and instead use 378 some default 379 380 This macro does not exist in Fortran; you must use PETSC_NULL_INTEGER, 381 PETSC_NULL_DOUBLE_PRECISION etc 382 383 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE 384 385 M*/ 386 #define PETSC_NULL 0 387 388 /*MC 389 PETSC_DECIDE - standard way of passing in integer or floating point parameter 390 where you wish PETSc to use the default. 391 392 Level: beginner 393 394 .seealso: PETSC_NULL, PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE 395 396 M*/ 397 #define PETSC_DECIDE -1 398 399 /*MC 400 PETSC_DEFAULT - standard way of passing in integer or floating point parameter 401 where you wish PETSc to use the default. 402 403 Level: beginner 404 405 .seealso: PETSC_DECIDE, PETSC_NULL, PETSC_IGNORE, PETSC_DETERMINE 406 407 M*/ 408 #define PETSC_DEFAULT -2 409 410 411 /*MC 412 PETSC_IGNORE - same as PETSC_NULL, means PETSc will ignore this argument 413 414 Level: beginner 415 416 Notes: accepted by many PETSc functions to not set a parameter and instead use 417 some default 418 419 This macro does not exist in Fortran; you must use PETSC_NULL_INTEGER, 420 PETSC_NULL_DOUBLE_PRECISION etc 421 422 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_NULL, PETSC_DETERMINE 423 424 M*/ 425 #define PETSC_IGNORE PETSC_NULL 426 427 /*MC 428 PETSC_DETERMINE - standard way of passing in integer or floating point parameter 429 where you wish PETSc to compute the required value. 430 431 Level: beginner 432 433 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, PETSC_NULL, VecSetSizes() 434 435 M*/ 436 #define PETSC_DETERMINE PETSC_DECIDE 437 438 /*MC 439 PETSC_COMM_WORLD - the equivalent of the MPI_COMM_WORLD communicator which represents 440 all the processs that PETSc knows about. 441 442 Level: beginner 443 444 Notes: By default PETSC_COMM_WORLD and MPI_COMM_WORLD are identical unless you wish to 445 run PETSc on ONLY a subset of MPI_COMM_WORLD. In that case create your new (smaller) 446 communicator, call it, say comm, and set PETSC_COMM_WORLD = comm BEFORE calling 447 PetscInitialize() 448 449 .seealso: PETSC_COMM_SELF 450 451 M*/ 452 extern MPI_Comm PETSC_COMM_WORLD; 453 454 /*MC 455 PETSC_COMM_SELF - a duplicate of the MPI_COMM_SELF communicator which represents 456 the current process 457 458 Level: beginner 459 460 Notes: PETSC_COMM_SELF and MPI_COMM_SELF are equivalent. 461 462 .seealso: PETSC_COMM_WORLD 463 464 M*/ 465 #define PETSC_COMM_SELF MPI_COMM_SELF 466 467 extern PETSC_DLLEXPORT PetscTruth PetscInitializeCalled; 468 extern PETSC_DLLEXPORT PetscTruth PetscFinalizeCalled; 469 470 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSetHelpVersionFunctions(PetscErrorCode (*)(MPI_Comm),PetscErrorCode (*)(MPI_Comm)); 471 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscCommDuplicate(MPI_Comm,MPI_Comm*,int*); 472 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscCommDestroy(MPI_Comm*); 473 474 /*MC 475 PetscMalloc - Allocates memory 476 477 Input Parameter: 478 . m - number of bytes to allocate 479 480 Output Parameter: 481 . result - memory allocated 482 483 Synopsis: 484 PetscErrorCode PetscMalloc(size_t m,void **result) 485 486 Level: beginner 487 488 Notes: Memory is always allocated at least double aligned 489 490 If you request memory of zero size it will allocate no space and assign the pointer to 0; PetscFree() will 491 properly handle not freeing the null pointer. 492 493 .seealso: PetscFree(), PetscNew() 494 495 Concepts: memory allocation 496 497 M*/ 498 #define PetscMalloc(a,b) ((a != 0) ? (*PetscTrMalloc)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__,(void**)(b)) : (*(b) = 0,0) ) 499 500 /*MC 501 PetscMalloc2 - Allocates 2 chunks of memory 502 503 Input Parameter: 504 + m1 - number of elements to allocate in 1st chunk (may be zero) 505 . t1 - type of first memory elements 506 . m2 - number of elements to allocate in 2nd chunk (may be zero) 507 - t2 - type of second memory elements 508 509 Output Parameter: 510 + r1 - memory allocated in first chunk 511 - r2 - memory allocated in second chunk 512 513 Synopsis: 514 PetscErrorCode PetscMalloc2(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2) 515 516 Level: developer 517 518 Notes: Memory of first chunk is always allocated at least double aligned 519 520 .seealso: PetscFree(), PetscNew(), PetscMalloc() 521 522 Concepts: memory allocation 523 524 M*/ 525 #if defined(PETSC_USE_DEBUG) 526 #define PetscMalloc2(m1,t1,r1,m2,t2,r2) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2)) 527 #else 528 #define PetscMalloc2(m1,t1,r1,m2,t2,r2) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2),r1) || (*(r2) = (t2*)(*(r1)+m1),0)) 529 #endif 530 531 /*MC 532 PetscMalloc3 - Allocates 3 chunks of memory 533 534 Input Parameter: 535 + m1 - number of elements to allocate in 1st chunk (may be zero) 536 . t1 - type of first memory elements 537 . m2 - number of elements to allocate in 2nd chunk (may be zero) 538 . t2 - type of second memory elements 539 . m3 - number of elements to allocate in 3rd chunk (may be zero) 540 - t3 - type of third memory elements 541 542 Output Parameter: 543 + r1 - memory allocated in first chunk 544 . r2 - memory allocated in second chunk 545 - r3 - memory allocated in third chunk 546 547 Synopsis: 548 PetscErrorCode PetscMalloc3(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2,size_t m3,type t3,void **r3) 549 550 Level: developer 551 552 Notes: Memory of first chunk is always allocated at least double aligned 553 554 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3() 555 556 Concepts: memory allocation 557 558 M*/ 559 #if defined(PETSC_USE_DEBUG) 560 #define PetscMalloc3(m1,t1,r1,m2,t2,r2,m3,t3,r3) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2) || PetscMalloc((m3)*sizeof(t3),r3)) 561 #else 562 #define PetscMalloc3(m1,t1,r1,m2,t2,r2,m3,t3,r3) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3),r1) || (*(r2) = (t2*)(*(r1)+m1),*(r3) = (t3*)(*(r2)+m2),0)) 563 #endif 564 565 /*MC 566 PetscMalloc4 - Allocates 4 chunks of memory 567 568 Input Parameter: 569 + m1 - number of elements to allocate in 1st chunk (may be zero) 570 . t1 - type of first memory elements 571 . m2 - number of elements to allocate in 2nd chunk (may be zero) 572 . t2 - type of second memory elements 573 . m3 - number of elements to allocate in 3rd chunk (may be zero) 574 . t3 - type of third memory elements 575 . m4 - number of elements to allocate in 4th chunk (may be zero) 576 - t4 - type of fourth memory elements 577 578 Output Parameter: 579 + r1 - memory allocated in first chunk 580 . r2 - memory allocated in second chunk 581 . r3 - memory allocated in third chunk 582 - r4 - memory allocated in fourth chunk 583 584 Synopsis: 585 PetscErrorCode PetscMalloc4(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2,size_t m3,type t3,void **r3,size_t m4,type t4,void **r4) 586 587 Level: developer 588 589 Notes: Memory of first chunk is always allocated at least double aligned 590 591 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4() 592 593 Concepts: memory allocation 594 595 M*/ 596 #if defined(PETSC_USE_DEBUG) 597 #define PetscMalloc4(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2) || PetscMalloc((m3)*sizeof(t3),r3) || PetscMalloc((m4)*sizeof(t4),r4)) 598 #else 599 #define PetscMalloc4(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3)+(m4)*sizeof(t4),r1) || (*(r2) = (t2*)(*(r1)+m1),*(r3) = (t3*)(*(r2)+m2),*(r4) = (t4*)(*(r3)+m3),0)) 600 #endif 601 602 /*MC 603 PetscMalloc5 - Allocates 5 chunks of memory 604 605 Input Parameter: 606 + m1 - number of elements to allocate in 1st chunk (may be zero) 607 . t1 - type of first memory elements 608 . m2 - number of elements to allocate in 2nd chunk (may be zero) 609 . t2 - type of second memory elements 610 . m3 - number of elements to allocate in 3rd chunk (may be zero) 611 . t3 - type of third memory elements 612 . m4 - number of elements to allocate in 4th chunk (may be zero) 613 . t4 - type of fourth memory elements 614 . m5 - number of elements to allocate in 5th chunk (may be zero) 615 - t5 - type of fifth memory elements 616 617 Output Parameter: 618 + r1 - memory allocated in first chunk 619 . r2 - memory allocated in second chunk 620 . r3 - memory allocated in third chunk 621 . r4 - memory allocated in fourth chunk 622 - r5 - memory allocated in fifth chunk 623 624 Synopsis: 625 PetscErrorCode PetscMalloc5(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2,size_t m3,type t3,void **r3,size_t m4,type t4,void **r4,size_t m5,type t5,void **r5) 626 627 Level: developer 628 629 Notes: Memory of first chunk is always allocated at least double aligned 630 631 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4(), PetscFree5() 632 633 Concepts: memory allocation 634 635 M*/ 636 #if defined(PETSC_USE_DEBUG) 637 #define PetscMalloc5(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4,m5,t5,r5) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2) || PetscMalloc((m3)*sizeof(t3),r3) || PetscMalloc((m4)*sizeof(t4),r4) || PetscMalloc((m5)*sizeof(t5),r5)) 638 #else 639 #define PetscMalloc5(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4,m5,t5,r5) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3)+(m4)*sizeof(t4)+(m5)*sizeof(t5),r1) || (*(r2) = (t2*)(*(r1)+m1),*(r3) = (t3*)(*(r2)+m2),*(r4) = (t4*)(*(r3)+m3),*(r5) = (t5*)(*(r4)+m4),0)) 640 #endif 641 642 643 /*MC 644 PetscMalloc6 - Allocates 6 chunks of memory 645 646 Input Parameter: 647 + m1 - number of elements to allocate in 1st chunk (may be zero) 648 . t1 - type of first memory elements 649 . m2 - number of elements to allocate in 2nd chunk (may be zero) 650 . t2 - type of second memory elements 651 . m3 - number of elements to allocate in 3rd chunk (may be zero) 652 . t3 - type of third memory elements 653 . m4 - number of elements to allocate in 4th chunk (may be zero) 654 . t4 - type of fourth memory elements 655 . m5 - number of elements to allocate in 5th chunk (may be zero) 656 . t5 - type of fifth memory elements 657 . m6 - number of elements to allocate in 6th chunk (may be zero) 658 - t6 - type of sixth memory elements 659 660 Output Parameter: 661 + r1 - memory allocated in first chunk 662 . r2 - memory allocated in second chunk 663 . r3 - memory allocated in third chunk 664 . r4 - memory allocated in fourth chunk 665 . r5 - memory allocated in fifth chunk 666 - r6 - memory allocated in sixth chunk 667 668 Synopsis: 669 PetscErrorCode PetscMalloc6(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2,size_t m3,type t3,void **r3,size_t m4,type t4,void **r4,size_t m5,type t5,void **r5,size_t m6,type t6,void **r6) 670 671 Level: developer 672 673 Notes: Memory of first chunk is always allocated at least double aligned 674 675 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4(), PetscFree5(), PetscFree6() 676 677 Concepts: memory allocation 678 679 M*/ 680 #if defined(PETSC_USE_DEBUG) 681 #define PetscMalloc6(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4,m5,t5,r5,m6,t6,r6) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2) || PetscMalloc((m3)*sizeof(t3),r3) || PetscMalloc((m4)*sizeof(t4),r4) || PetscMalloc((m5)*sizeof(t5),r5) || PetscMalloc((m6)*sizeof(t6),r6)) 682 #else 683 #define PetscMalloc6(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4,m5,t5,r5,m6,t6,r6) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3)+(m4)*sizeof(t4)+(m5)*sizeof(t5)+(m6)*sizeof(t6),r1) || (*(r2) = (t2*)(*(r1)+m1),*(r3) = (t3*)(*(r2)+m2),*(r4) = (t4*)(*(r3)+m3),*(r5) = (t5*)(*(r4)+m4),*(r6) = (t6*)(*(r5)+m5),0)) 684 #endif 685 686 /*MC 687 PetscMalloc7 - Allocates 7 chunks of memory 688 689 Input Parameter: 690 + m1 - number of elements to allocate in 1st chunk (may be zero) 691 . t1 - type of first memory elements 692 . m2 - number of elements to allocate in 2nd chunk (may be zero) 693 . t2 - type of second memory elements 694 . m3 - number of elements to allocate in 3rd chunk (may be zero) 695 . t3 - type of third memory elements 696 . m4 - number of elements to allocate in 4th chunk (may be zero) 697 . t4 - type of fourth memory elements 698 . m5 - number of elements to allocate in 5th chunk (may be zero) 699 . t5 - type of fifth memory elements 700 . m6 - number of elements to allocate in 6th chunk (may be zero) 701 . t6 - type of sixth memory elements 702 . m7 - number of elements to allocate in 7th chunk (may be zero) 703 - t7 - type of sixth memory elements 704 705 Output Parameter: 706 + r1 - memory allocated in first chunk 707 . r2 - memory allocated in second chunk 708 . r3 - memory allocated in third chunk 709 . r4 - memory allocated in fourth chunk 710 . r5 - memory allocated in fifth chunk 711 . r6 - memory allocated in sixth chunk 712 - r7 - memory allocated in sixth chunk 713 714 Synopsis: 715 PetscErrorCode PetscMalloc7(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2,size_t m3,type t3,void **r3,size_t m4,type t4,void **r4,size_t m5,type t5,void **r5,size_t m6,type t6,void **r6,size_t m7,type t7,void **r7) 716 717 Level: developer 718 719 Notes: Memory of first chunk is always allocated at least double aligned 720 721 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4(), PetscFree5(), PetscFree6(), PetscFree7() 722 723 Concepts: memory allocation 724 725 M*/ 726 #if defined(PETSC_USE_DEBUG) 727 #define PetscMalloc7(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4,m5,t5,r5,m6,t6,r6,m7,t7,r7) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2) || PetscMalloc((m3)*sizeof(t3),r3) || PetscMalloc((m4)*sizeof(t4),r4) || PetscMalloc((m5)*sizeof(t5),r5) || PetscMalloc((m6)*sizeof(t6),r6) || PetscMalloc((m7)*sizeof(t7),r7)) 728 #else 729 #define PetscMalloc7(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4,m5,t5,r5,m6,t6,r6,m7,t7,r7) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3)+(m4)*sizeof(t4)+(m5)*sizeof(t5)+(m6)*sizeof(t6)+(m7)*sizeof(t7),r1) || (*(r2) = (t2*)(*(r1)+m1),*(r3) = (t3*)(*(r2)+m2),*(r4) = (t4*)(*(r3)+m3),*(r5) = (t5*)(*(r4)+m4),*(r6) = (t6*)(*(r5)+m5),*(r7) = (t7*)(*(r6)+m6),0)) 730 #endif 731 732 /*MC 733 PetscNew - Allocates memory of a particular type, zeros the memory! 734 735 Input Parameter: 736 . type - structure name of space to be allocated. Memory of size sizeof(type) is allocated 737 738 Output Parameter: 739 . result - memory allocated 740 741 Synopsis: 742 PetscErrorCode PetscNew(struct type,((type *))result) 743 744 Level: beginner 745 746 .seealso: PetscFree(), PetscMalloc() 747 748 Concepts: memory allocation 749 750 M*/ 751 #define PetscNew(A,b) (PetscMalloc(sizeof(A),(b)) || PetscMemzero(*(b),sizeof(A))) 752 #define PetscNewLog(o,A,b) (PetscNew(A,b) || ((o) ? PetscLogObjectMemory(o,sizeof(A)) : 0)) 753 754 /*MC 755 PetscFree - Frees memory 756 757 Input Parameter: 758 . memory - memory to free (the pointer is ALWAYS set to 0 upon sucess) 759 760 Synopsis: 761 PetscErrorCode PetscFree(void *memory) 762 763 Level: beginner 764 765 Notes: Memory must have been obtained with PetscNew() or PetscMalloc() 766 767 .seealso: PetscNew(), PetscMalloc(), PetscFreeVoid() 768 769 Concepts: memory allocation 770 771 M*/ 772 #define PetscFree(a) ((a) ? ((*PetscTrFree)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__) || ((a = 0),0)) : 0) 773 774 /*MC 775 PetscFreeVoid - Frees memory 776 777 Input Parameter: 778 . memory - memory to free 779 780 Synopsis: 781 void PetscFreeVoid(void *memory) 782 783 Level: beginner 784 785 Notes: This is different from PetscFree() in that no error code is returned 786 787 .seealso: PetscFree(), PetscNew(), PetscMalloc() 788 789 Concepts: memory allocation 790 791 M*/ 792 #define PetscFreeVoid(a) ((*PetscTrFree)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__),(a) = 0) 793 794 795 /*MC 796 PetscFree2 - Frees 2 chunks of memory obtained with PetscMalloc2() 797 798 Input Parameter: 799 + memory1 - memory to free 800 - memory2 - 2nd memory to free 801 802 803 Synopsis: 804 PetscErrorCode PetscFree2(void *memory1,void *memory2) 805 806 Level: developer 807 808 Notes: Memory must have been obtained with PetscMalloc2() 809 810 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree() 811 812 Concepts: memory allocation 813 814 M*/ 815 #if defined(PETSC_USE_DEBUG) 816 #define PetscFree2(m1,m2) (PetscFree(m2) || PetscFree(m1)) 817 #else 818 #define PetscFree2(m1,m2) (PetscFree(m1)) 819 #endif 820 821 /*MC 822 PetscFree3 - Frees 3 chunks of memory obtained with PetscMalloc3() 823 824 Input Parameter: 825 + memory1 - memory to free 826 . memory2 - 2nd memory to free 827 - memory3 - 3rd memory to free 828 829 830 Synopsis: 831 PetscErrorCode PetscFree3(void *memory1,void *memory2,void *memory3) 832 833 Level: developer 834 835 Notes: Memory must have been obtained with PetscMalloc3() 836 837 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3() 838 839 Concepts: memory allocation 840 841 M*/ 842 #if defined(PETSC_USE_DEBUG) 843 #define PetscFree3(m1,m2,m3) (PetscFree(m3) || PetscFree(m2) || PetscFree(m1)) 844 #else 845 #define PetscFree3(m1,m2,m3) (PetscFree(m1)) 846 #endif 847 848 /*MC 849 PetscFree4 - Frees 4 chunks of memory obtained with PetscMalloc4() 850 851 Input Parameter: 852 + m1 - memory to free 853 . m2 - 2nd memory to free 854 . m3 - 3rd memory to free 855 - m4 - 4th memory to free 856 857 858 Synopsis: 859 PetscErrorCode PetscFree4(void *m1,void *m2,void *m3,void *m4) 860 861 Level: developer 862 863 Notes: Memory must have been obtained with PetscMalloc4() 864 865 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4() 866 867 Concepts: memory allocation 868 869 M*/ 870 #if defined(PETSC_USE_DEBUG) 871 #define PetscFree4(m1,m2,m3,m4) (PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1)) 872 #else 873 #define PetscFree4(m1,m2,m3,m4) (PetscFree(m1)) 874 #endif 875 876 /*MC 877 PetscFree5 - Frees 5 chunks of memory obtained with PetscMalloc5() 878 879 Input Parameter: 880 + m1 - memory to free 881 . m2 - 2nd memory to free 882 . m3 - 3rd memory to free 883 . m4 - 4th memory to free 884 - m5 - 5th memory to free 885 886 887 Synopsis: 888 PetscErrorCode PetscFree5(void *m1,void *m2,void *m3,void *m4,void *m5) 889 890 Level: developer 891 892 Notes: Memory must have been obtained with PetscMalloc5() 893 894 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4(), PetscMalloc5() 895 896 Concepts: memory allocation 897 898 M*/ 899 #if defined(PETSC_USE_DEBUG) 900 #define PetscFree5(m1,m2,m3,m4,m5) (PetscFree(m5) || PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1)) 901 #else 902 #define PetscFree5(m1,m2,m3,m4,m5) (PetscFree(m1)) 903 #endif 904 905 906 /*MC 907 PetscFree6 - Frees 6 chunks of memory obtained with PetscMalloc6() 908 909 Input Parameter: 910 + m1 - memory to free 911 . m2 - 2nd memory to free 912 . m3 - 3rd memory to free 913 . m4 - 4th memory to free 914 . m5 - 5th memory to free 915 - m6 - 6th memory to free 916 917 918 Synopsis: 919 PetscErrorCode PetscFree6(void *m1,void *m2,void *m3,void *m4,void *m5,void *m6) 920 921 Level: developer 922 923 Notes: Memory must have been obtained with PetscMalloc6() 924 925 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4(), PetscMalloc5(), PetscMalloc6() 926 927 Concepts: memory allocation 928 929 M*/ 930 #if defined(PETSC_USE_DEBUG) 931 #define PetscFree6(m1,m2,m3,m4,m5,m6) (PetscFree(m6) || PetscFree(m5) || PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1)) 932 #else 933 #define PetscFree6(m1,m2,m3,m4,m5,m6) (PetscFree(m1)) 934 #endif 935 936 /*MC 937 PetscFree7 - Frees 7 chunks of memory obtained with PetscMalloc7() 938 939 Input Parameter: 940 + m1 - memory to free 941 . m2 - 2nd memory to free 942 . m3 - 3rd memory to free 943 . m4 - 4th memory to free 944 . m5 - 5th memory to free 945 . m6 - 6th memory to free 946 - m7 - 7th memory to free 947 948 949 Synopsis: 950 PetscErrorCode PetscFree7(void *m1,void *m2,void *m3,void *m4,void *m5,void *m6,void *m7) 951 952 Level: developer 953 954 Notes: Memory must have been obtained with PetscMalloc7() 955 956 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4(), PetscMalloc5(), PetscMalloc6(), 957 PetscMalloc7() 958 959 Concepts: memory allocation 960 961 M*/ 962 #if defined(PETSC_USE_DEBUG) 963 #define PetscFree7(m1,m2,m3,m4,m5,m6,m7) (PetscFree(m7) || PetscFree(m6) || PetscFree(m5) || PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1)) 964 #else 965 #define PetscFree7(m1,m2,m3,m4,m5,m6,m7) (PetscFree(m1)) 966 #endif 967 968 EXTERN PETSC_DLLEXPORT PetscErrorCode (*PetscTrMalloc)(size_t,int,const char[],const char[],const char[],void**); 969 EXTERN PETSC_DLLEXPORT PetscErrorCode (*PetscTrFree)(void*,int,const char[],const char[],const char[]); 970 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSetMalloc(PetscErrorCode (*)(size_t,int,const char[],const char[],const char[],void**),PetscErrorCode (*)(void*,int,const char[],const char[],const char[])); 971 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscClearMalloc(void); 972 973 /* 974 Routines for tracing memory corruption/bleeding with default PETSc 975 memory allocation 976 */ 977 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMallocDump(FILE *); 978 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMallocDumpLog(FILE *); 979 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMallocGetCurrentUsage(PetscLogDouble *); 980 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMallocGetMaximumUsage(PetscLogDouble *); 981 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMallocDebug(PetscTruth); 982 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMallocValidate(int,const char[],const char[],const char[]); 983 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMallocSetDumpLog(void); 984 985 986 /* 987 Variable type where we stash PETSc object pointers in Fortran. 988 On most machines size(pointer) == sizeof(long) - except windows 989 where its sizeof(long long) 990 */ 991 992 #if (PETSC_SIZEOF_VOID_P) == (PETSC_SIZEOF_LONG) 993 #define PetscFortranAddr long 994 #elif (PETSC_SIZEOF_VOID_P) == (PETSC_SIZEOF_LONG_LONG) 995 #define PetscFortranAddr long long 996 #else 997 #error "Unknown size for PetscFortranAddr! Send us a bugreport at petsc-maint@mcs.anl.gov" 998 #endif 999 1000 /*E 1001 PetscDataType - Used for handling different basic data types. 1002 1003 Level: beginner 1004 1005 .seealso: PetscBinaryRead(), PetscBinaryWrite(), PetscDataTypeToMPIDataType(), 1006 PetscDataTypeGetSize() 1007 1008 E*/ 1009 typedef enum {PETSC_INT = 0,PETSC_DOUBLE = 1,PETSC_COMPLEX = 2, PETSC_LONG = 3 ,PETSC_SHORT = 4,PETSC_FLOAT = 5, 1010 PETSC_CHAR = 6,PETSC_LOGICAL = 7,PETSC_ENUM = 8,PETSC_TRUTH=9, PETSC_LONG_DOUBLE = 10} PetscDataType; 1011 extern const char *PetscDataTypes[]; 1012 1013 #if defined(PETSC_USE_COMPLEX) 1014 #define PETSC_SCALAR PETSC_COMPLEX 1015 #else 1016 #if defined(PETSC_USE_SINGLE) 1017 #define PETSC_SCALAR PETSC_FLOAT 1018 #elif defined(PETSC_USE_LONG_DOUBLE) 1019 #define PETSC_SCALAR PETSC_LONG_DOUBLE 1020 #elif defined(PETSC_USE_INT) 1021 #define PETSC_SCALAR PETSC_INT 1022 #else 1023 #define PETSC_SCALAR PETSC_DOUBLE 1024 #endif 1025 #endif 1026 #if defined(PETSC_USE_SINGLE) 1027 #define PETSC_REAL PETSC_FLOAT 1028 #elif defined(PETSC_USE_LONG_DOUBLE) 1029 #define PETSC_REAL PETSC_LONG_DOUBLE 1030 #elif defined(PETSC_USE_INT) 1031 #define PETSC_REAL PETSC_INT 1032 #else 1033 #define PETSC_REAL PETSC_DOUBLE 1034 #endif 1035 #define PETSC_FORTRANADDR PETSC_LONG 1036 1037 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDataTypeToMPIDataType(PetscDataType,MPI_Datatype*); 1038 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDataTypeGetSize(PetscDataType,PetscInt*); 1039 1040 /* 1041 Basic memory and string operations. These are usually simple wrappers 1042 around the basic Unix system calls, but a few of them have additional 1043 functionality and/or error checking. 1044 */ 1045 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemcpy(void*,const void *,size_t); 1046 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBitMemcpy(void*,PetscInt,const void*,PetscInt,PetscInt,PetscDataType); 1047 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemmove(void*,void *,size_t); 1048 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemzero(void*,size_t); 1049 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemcmp(const void*,const void*,size_t,PetscTruth *); 1050 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrlen(const char[],size_t*); 1051 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrcmp(const char[],const char[],PetscTruth *); 1052 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrgrt(const char[],const char[],PetscTruth *); 1053 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrcasecmp(const char[],const char[],PetscTruth*); 1054 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrncmp(const char[],const char[],size_t,PetscTruth*); 1055 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrcpy(char[],const char[]); 1056 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrcat(char[],const char[]); 1057 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrncat(char[],const char[],size_t); 1058 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrncpy(char[],const char[],size_t); 1059 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrchr(const char[],char,char *[]); 1060 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrtolower(char[]); 1061 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrrchr(const char[],char,char *[]); 1062 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrstr(const char[],const char[],char *[]); 1063 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrrstr(const char[],const char[],char *[]); 1064 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrallocpy(const char[],char *[]); 1065 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrreplace(MPI_Comm,const char[],char[],size_t); 1066 #define PetscStrfree(a) ((a) ? PetscFree(a) : 0) 1067 1068 /*S 1069 PetscToken - 'Token' used for managing tokenizing strings 1070 1071 Level: intermediate 1072 1073 .seealso: PetscTokenCreate(), PetscTokenFind(), PetscTokenDestroy() 1074 S*/ 1075 typedef struct {char token;char *array;char *current;} PetscToken; 1076 1077 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscTokenCreate(const char[],const char,PetscToken**); 1078 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscTokenFind(PetscToken*,char *[]); 1079 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscTokenDestroy(PetscToken*); 1080 1081 /* 1082 These are MPI operations for MPI_Allreduce() etc 1083 */ 1084 EXTERN PETSC_DLLEXPORT MPI_Op PetscMaxSum_Op; 1085 #if defined(PETSC_USE_COMPLEX) 1086 EXTERN PETSC_DLLEXPORT MPI_Op PetscSum_Op; 1087 #else 1088 #define PetscSum_Op MPI_SUM 1089 #endif 1090 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMaxSum(MPI_Comm,const PetscInt[],PetscInt*,PetscInt*); 1091 1092 /*S 1093 PetscObject - any PETSc object, PetscViewer, Mat, Vec, KSP etc 1094 1095 Level: beginner 1096 1097 Note: This is the base class from which all objects appear. 1098 1099 .seealso: PetscObjectDestroy(), PetscObjectView(), PetscObjectGetName(), PetscObjectSetName() 1100 S*/ 1101 typedef struct _p_PetscObject* PetscObject; 1102 1103 /*S 1104 PetscFList - Linked list of functions, possibly stored in dynamic libraries, accessed 1105 by string name 1106 1107 Level: advanced 1108 1109 .seealso: PetscFListAdd(), PetscFListDestroy() 1110 S*/ 1111 typedef struct _n_PetscFList *PetscFList; 1112 1113 /*E 1114 PetscFileMode - Access mode for a file. 1115 1116 Level: beginner 1117 1118 FILE_MODE_READ - open a file at its beginning for reading 1119 1120 FILE_MODE_WRITE - open a file at its beginning for writing (will create if the file does not exist) 1121 1122 FILE_MODE_APPEND - open a file at end for writing 1123 1124 FILE_MODE_UPDATE - open a file for updating, meaning for reading and writing 1125 1126 FILE_MODE_APPEND_UPDATE - open a file for updating, meaning for reading and writing, at the end 1127 1128 .seealso: PetscViewerFileSetMode() 1129 E*/ 1130 typedef enum {FILE_MODE_READ, FILE_MODE_WRITE, FILE_MODE_APPEND, FILE_MODE_UPDATE, FILE_MODE_APPEND_UPDATE} PetscFileMode; 1131 1132 #include "petscviewer.h" 1133 #include "petscoptions.h" 1134 1135 #define PETSC_SMALLEST_COOKIE 1211211 1136 extern PETSC_DLLEXPORT PetscCookie PETSC_LARGEST_COOKIE; 1137 extern PETSC_DLLEXPORT PetscCookie PETSC_OBJECT_COOKIE; 1138 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscCookieRegister(PetscCookie *); 1139 1140 /* 1141 Routines that get memory usage information from the OS 1142 */ 1143 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemoryGetCurrentUsage(PetscLogDouble *); 1144 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemoryGetMaximumUsage(PetscLogDouble *); 1145 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemorySetGetMaximumUsage(void); 1146 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemoryShowUsage(PetscViewer,const char[]); 1147 1148 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscInfoAllow(PetscTruth,const char []); 1149 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetTime(PetscLogDouble*); 1150 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetCPUTime(PetscLogDouble*); 1151 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSleep(int); 1152 1153 /* 1154 Initialization of PETSc 1155 */ 1156 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscInitialize(int*,char***,const char[],const char[]); 1157 PetscPolymorphicSubroutine(PetscInitialize,(int *argc,char ***args),(argc,args,PETSC_NULL,PETSC_NULL)) 1158 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscInitializeNoArguments(void); 1159 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscInitialized(PetscTruth *); 1160 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFinalized(PetscTruth *); 1161 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFinalize(void); 1162 EXTERN PetscErrorCode PetscInitializeFortran(void); 1163 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetArgs(int*,char ***); 1164 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetArguments(char ***args); 1165 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFreeArguments(char **args); 1166 1167 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscEnd(void); 1168 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscInitializePackage(const char[]); 1169 1170 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPMerge(PetscMPIInt); 1171 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPSpawn(PetscMPIInt); 1172 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPFinalize(void); 1173 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPRun(MPI_Comm,PetscErrorCode (*)(MPI_Comm,void *),void*); 1174 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPFree(MPI_Comm,void*); 1175 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPNew(MPI_Comm,PetscInt,void**); 1176 1177 /* 1178 These are so that in extern C code we can caste function pointers to non-extern C 1179 function pointers. Since the regular C++ code expects its function pointers to be 1180 C++. 1181 */ 1182 typedef void (**PetscVoidStarFunction)(void); 1183 typedef void (*PetscVoidFunction)(void); 1184 typedef PetscErrorCode (*PetscErrorCodeFunction)(void); 1185 1186 /* 1187 PetscTryMethod - Queries an object for a method, if it exists then calls it. 1188 These are intended to be used only inside PETSc functions. 1189 */ 1190 #define PetscTryMethod(obj,A,B,C) \ 1191 0;{ PetscErrorCode (*f)B, __ierr; \ 1192 __ierr = PetscObjectQueryFunction((PetscObject)obj,#A,(PetscVoidStarFunction)&f);CHKERRQ(__ierr); \ 1193 if (f) {__ierr = (*f)C;CHKERRQ(__ierr);}\ 1194 } 1195 #define PetscUseMethod(obj,A,B,C) \ 1196 0;{ PetscErrorCode (*f)B, __ierr; \ 1197 __ierr = PetscObjectQueryFunction((PetscObject)obj,A,(PetscVoidStarFunction)&f);CHKERRQ(__ierr); \ 1198 if (f) {__ierr = (*f)C;CHKERRQ(__ierr);}\ 1199 else {SETERRQ1(PETSC_ERR_SUP,"Cannot locate function %s in object",A);} \ 1200 } 1201 /* 1202 Functions that can act on any PETSc object. 1203 */ 1204 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectCreate(MPI_Comm,PetscObject*); 1205 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectCreateGeneric(MPI_Comm, PetscCookie, const char [], PetscObject *); 1206 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectDestroy(PetscObject); 1207 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectExists(PetscObject,PetscTruth*); 1208 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetComm(PetscObject,MPI_Comm *); 1209 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetCookie(PetscObject,PetscCookie *); 1210 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectSetType(PetscObject,const char []); 1211 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetType(PetscObject,const char *[]); 1212 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectSetName(PetscObject,const char[]); 1213 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetName(PetscObject,const char*[]); 1214 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectReference(PetscObject); 1215 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetReference(PetscObject,PetscInt*); 1216 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectDereference(PetscObject); 1217 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetNewTag(PetscObject,PetscMPIInt *); 1218 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectView(PetscObject,PetscViewer); 1219 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectCompose(PetscObject,const char[],PetscObject); 1220 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectQuery(PetscObject,const char[],PetscObject *); 1221 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectComposeFunction(PetscObject,const char[],const char[],void (*)(void)); 1222 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectSetFromOptions(PetscObject); 1223 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectSetUp(PetscObject); 1224 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscCommGetNewTag(MPI_Comm,PetscMPIInt *); 1225 1226 /*MC 1227 PetscObjectComposeFunctionDynamic - Associates a function with a given PETSc object. 1228 1229 Collective on PetscObject 1230 1231 Input Parameters: 1232 + obj - the PETSc object; this must be cast with a (PetscObject), for example, 1233 PetscObjectCompose((PetscObject)mat,...); 1234 . name - name associated with the child function 1235 . fname - name of the function 1236 - ptr - function pointer (or PETSC_NULL if using dynamic libraries) 1237 1238 Level: advanced 1239 1240 Synopsis: 1241 PetscErrorCode PetscObjectComposeFunctionDynamic(PetscObject obj,const char name[],const char fname[],void *ptr) 1242 1243 Notes: 1244 To remove a registered routine, pass in a PETSC_NULL rname and fnc(). 1245 1246 PetscObjectComposeFunctionDynamic() can be used with any PETSc object (such as 1247 Mat, Vec, KSP, SNES, etc.) or any user-provided object. 1248 1249 The composed function must be wrapped in a EXTERN_C_BEGIN/END for this to 1250 work in C++/complex with dynamic link libraries (config/configure.py options --with-shared --with-dynamic) 1251 enabled. 1252 1253 Concepts: objects^composing functions 1254 Concepts: composing functions 1255 Concepts: functions^querying 1256 Concepts: objects^querying 1257 Concepts: querying objects 1258 1259 .seealso: PetscObjectQueryFunction() 1260 M*/ 1261 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 1262 #define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,0) 1263 #else 1264 #define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,(PetscVoidFunction)(d)) 1265 #endif 1266 1267 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectQueryFunction(PetscObject,const char[],void (**)(void)); 1268 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectSetOptionsPrefix(PetscObject,const char[]); 1269 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectAppendOptionsPrefix(PetscObject,const char[]); 1270 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectPrependOptionsPrefix(PetscObject,const char[]); 1271 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetOptionsPrefix(PetscObject,const char*[]); 1272 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectPublish(PetscObject); 1273 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectChangeTypeName(PetscObject,const char[]); 1274 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectRegisterDestroy(PetscObject); 1275 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectRegisterDestroyAll(void); 1276 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectName(PetscObject); 1277 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscTypeCompare(PetscObject,const char[],PetscTruth*); 1278 1279 /* 1280 Defines PETSc error handling. 1281 */ 1282 #include "petscerror.h" 1283 1284 /*S 1285 PetscOList - Linked list of PETSc objects, accessable by string name 1286 1287 Level: advanced 1288 1289 .seealso: PetscOListAdd(), PetscOListDestroy(), PetscOListFind() 1290 S*/ 1291 typedef struct _n_PetscOList *PetscOList; 1292 1293 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOListDestroy(PetscOList); 1294 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOListFind(PetscOList,const char[],PetscObject*); 1295 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOListReverseFind(PetscOList,PetscObject,char**); 1296 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOListAdd(PetscOList *,const char[],PetscObject); 1297 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOListDuplicate(PetscOList,PetscOList *); 1298 1299 /* 1300 Dynamic library lists. Lists of names of routines in dynamic 1301 link libraries that will be loaded as needed. 1302 */ 1303 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListAdd(PetscFList*,const char[],const char[],void (*)(void)); 1304 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListDestroy(PetscFList*); 1305 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListFind(PetscFList,MPI_Comm,const char[],void (**)(void)); 1306 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListPrintTypes(PetscFList,MPI_Comm,FILE*,const char[],const char[],const char[],const char[]); 1307 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 1308 #define PetscFListAddDynamic(a,b,p,c) PetscFListAdd(a,b,p,0) 1309 #else 1310 #define PetscFListAddDynamic(a,b,p,c) PetscFListAdd(a,b,p,(void (*)(void))c) 1311 #endif 1312 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListDuplicate(PetscFList,PetscFList *); 1313 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListView(PetscFList,PetscViewer); 1314 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListConcat(const char [],const char [],char []); 1315 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListGet(PetscFList,char ***,int*); 1316 1317 /*S 1318 PetscDLLibrary - Linked list of dynamics libraries to search for functions 1319 1320 Level: advanced 1321 1322 --with-shared --with-dynamic must be used with config/configure.py to use dynamic libraries 1323 1324 .seealso: PetscDLLibraryOpen() 1325 S*/ 1326 typedef struct _n_PetscDLLibrary *PetscDLLibrary; 1327 extern PetscDLLibrary DLLibrariesLoaded; 1328 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryRetrieve(MPI_Comm,const char[],char *,int,PetscTruth *); 1329 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryOpen(MPI_Comm,const char[],void **); 1330 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibrarySym(MPI_Comm,PetscDLLibrary *,const char[],const char[],void **); 1331 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryAppend(MPI_Comm,PetscDLLibrary *,const char[]); 1332 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryPrepend(MPI_Comm,PetscDLLibrary *,const char[]); 1333 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryClose(PetscDLLibrary); 1334 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryPrintPath(void); 1335 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryGetInfo(void*,const char[],const char *[]); 1336 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryCCAAppend(MPI_Comm,PetscDLLibrary *,const char[]); 1337 1338 /* 1339 Useful utility routines 1340 */ 1341 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSplitOwnership(MPI_Comm,PetscInt*,PetscInt*); 1342 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSplitOwnershipBlock(MPI_Comm,PetscInt,PetscInt*,PetscInt*); 1343 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSequentialPhaseBegin(MPI_Comm,PetscMPIInt); 1344 PetscPolymorphicSubroutine(PetscSequentialPhaseBegin,(MPI_Comm comm),(comm,1)) 1345 PetscPolymorphicSubroutine(PetscSequentialPhaseBegin,(void),(PETSC_COMM_WORLD,1)) 1346 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSequentialPhaseEnd(MPI_Comm,PetscMPIInt); 1347 PetscPolymorphicSubroutine(PetscSequentialPhaseEnd,(MPI_Comm comm),(comm,1)) 1348 PetscPolymorphicSubroutine(PetscSequentialPhaseEnd,(void),(PETSC_COMM_WORLD,1)) 1349 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBarrier(PetscObject); 1350 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMPIDump(FILE*); 1351 1352 #define PetscNot(a) ((a) ? PETSC_FALSE : PETSC_TRUE) 1353 /* 1354 Defines basic graphics available from PETSc. 1355 */ 1356 #include "petscdraw.h" 1357 1358 /* 1359 Defines the base data structures for all PETSc objects 1360 */ 1361 #include "private/petscimpl.h" 1362 /* 1363 Defines PETSc profiling. 1364 */ 1365 #include "petsclog.h" 1366 1367 /* 1368 For locking, unlocking and destroying AMS memories associated with 1369 PETSc objects. Not currently used. 1370 */ 1371 #define PetscPublishAll(v) 0 1372 #define PetscObjectTakeAccess(obj) 0 1373 #define PetscObjectGrantAccess(obj) 0 1374 #define PetscObjectDepublish(obj) 0 1375 1376 1377 1378 /* 1379 This code allows one to pass a MPI communicator between 1380 C and Fortran. MPI 2.0 defines a standard API for doing this. 1381 The code here is provided to allow PETSc to work with MPI 1.1 1382 standard MPI libraries. 1383 */ 1384 EXTERN PetscErrorCode MPICCommToFortranComm(MPI_Comm,int *); 1385 EXTERN PetscErrorCode MPIFortranCommToCComm(int,MPI_Comm*); 1386 1387 /* 1388 Simple PETSc parallel IO for ASCII printing 1389 */ 1390 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFixFilename(const char[],char[]); 1391 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFOpen(MPI_Comm,const char[],const char[],FILE**); 1392 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFClose(MPI_Comm,FILE*); 1393 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4); 1394 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPrintf(MPI_Comm,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3); 1395 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSNPrintf(char*,size_t,const char [],...); 1396 1397 /* These are used internally by PETSc ASCII IO routines*/ 1398 #include <stdarg.h> 1399 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscVSNPrintf(char*,size_t,const char[],va_list); 1400 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscVFPrintf(FILE*,const char[],va_list); 1401 1402 /*MC 1403 PetscErrorPrintf - Prints error messages. 1404 1405 Not Collective 1406 1407 Synopsis: 1408 PetscErrorCode (*PetscErrorPrintf)(const char format[],...); 1409 1410 Input Parameters: 1411 . format - the usual printf() format string 1412 1413 Options Database Keys: 1414 + -error_output_stderr - cause error messages to be printed to stderr instead of the 1415 (default) stdout 1416 - -error_output_none to turn off all printing of error messages (does not change the way the 1417 error is handled.) 1418 1419 Notes: Use 1420 PetscErrorPrintf = PetscErrorPrintfNone; to turn off all printing of error messages (does not change the way the 1421 error is handled.) and 1422 PetscErrorPrintf = PetscErrorPrintfDefault; to turn it back on 1423 1424 1425 1426 1427 Level: developer 1428 1429 Fortran Note: 1430 This routine is not supported in Fortran. 1431 1432 Concepts: error messages^printing 1433 Concepts: printing^error messages 1434 1435 .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscHelpPrintf() 1436 M*/ 1437 EXTERN PETSC_DLLEXPORT PetscErrorCode (*PetscErrorPrintf)(const char[],...); 1438 1439 /*MC 1440 PetscHelpPrintf - Prints help messages. 1441 1442 Not Collective 1443 1444 Synopsis: 1445 PetscErrorCode (*PetscHelpPrintf)(const char format[],...); 1446 1447 Input Parameters: 1448 . format - the usual printf() format string 1449 1450 Level: developer 1451 1452 Fortran Note: 1453 This routine is not supported in Fortran. 1454 1455 Concepts: help messages^printing 1456 Concepts: printing^help messages 1457 1458 .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscErrorPrintf() 1459 M*/ 1460 EXTERN PETSC_DLLEXPORT PetscErrorCode (*PetscHelpPrintf)(MPI_Comm,const char[],...); 1461 1462 EXTERN PetscErrorCode PetscErrorPrintfDefault(const char [],...); 1463 EXTERN PetscErrorCode PetscErrorPrintfNone(const char [],...); 1464 EXTERN PetscErrorCode PetscHelpPrintfDefault(MPI_Comm,const char [],...); 1465 1466 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPOpen(MPI_Comm,const char[],const char[],const char[],FILE **); 1467 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPClose(MPI_Comm,FILE*); 1468 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSynchronizedPrintf(MPI_Comm,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3); 1469 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSynchronizedFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4); 1470 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSynchronizedFlush(MPI_Comm); 1471 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSynchronizedFGets(MPI_Comm,FILE*,size_t,char[]); 1472 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStartMatlab(MPI_Comm,const char[],const char[],FILE**); 1473 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStartJava(MPI_Comm,const char[],const char[],FILE**); 1474 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetPetscDir(const char*[]); 1475 1476 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPopUpSelect(MPI_Comm,char*,char*,int,char**,int*); 1477 1478 /*S 1479 PetscContainer - Simple PETSc object that contains a pointer to any required data 1480 1481 Level: advanced 1482 1483 .seealso: PetscObject, PetscContainerCreate() 1484 S*/ 1485 extern PetscCookie PETSC_DLLEXPORT PETSC_CONTAINER_COOKIE; 1486 typedef struct _p_PetscContainer* PetscContainer; 1487 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscContainerGetPointer(PetscContainer,void **); 1488 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscContainerSetPointer(PetscContainer,void *); 1489 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscContainerDestroy(PetscContainer); 1490 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscContainerCreate(MPI_Comm,PetscContainer *); 1491 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscContainerSetUserDestroy(PetscContainer, PetscErrorCode (*)(void*)); 1492 1493 /* 1494 For use in debuggers 1495 */ 1496 extern PETSC_DLLEXPORT PetscMPIInt PetscGlobalRank; 1497 extern PETSC_DLLEXPORT PetscMPIInt PetscGlobalSize; 1498 1499 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscIntView(PetscInt,PetscInt[],PetscViewer); 1500 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRealView(PetscInt,PetscReal[],PetscViewer); 1501 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscScalarView(PetscInt,PetscScalar[],PetscViewer); 1502 1503 /* 1504 Allows accessing Matlab Engine 1505 */ 1506 #include "petscmatlab.h" 1507 1508 /* 1509 Determine if some of the kernel computation routines use 1510 Fortran (rather than C) for the numerical calculations. On some machines 1511 and compilers (like complex numbers) the Fortran version of the routines 1512 is faster than the C/C++ versions. The flag --with-fortran-kernels 1513 should be used with config/configure.py to turn these on. 1514 */ 1515 #if defined(PETSC_USE_FORTRAN_KERNELS) 1516 1517 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTCRL) 1518 #define PETSC_USE_FORTRAN_KERNEL_MULTCRL 1519 #endif 1520 1521 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTCSRPERM) 1522 #define PETSC_USE_FORTRAN_KERNEL_MULTCSRPERM 1523 #endif 1524 1525 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTAIJ) 1526 #define PETSC_USE_FORTRAN_KERNEL_MULTAIJ 1527 #endif 1528 1529 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ) 1530 #define PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ 1531 #endif 1532 1533 #if !defined(PETSC_USE_FORTRAN_KERNEL_NORM) 1534 #define PETSC_USE_FORTRAN_KERNEL_NORM 1535 #endif 1536 1537 #if !defined(PETSC_USE_FORTRAN_KERNEL_MAXPY) 1538 #define PETSC_USE_FORTRAN_KERNEL_MAXPY 1539 #endif 1540 1541 #if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ) 1542 #define PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ 1543 #endif 1544 1545 #if !defined(PETSC_USE_FORTRAN_KERNEL_RELAXAIJ) 1546 #define PETSC_USE_FORTRAN_KERNEL_RELAXAIJ 1547 #endif 1548 1549 #if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ) 1550 #define PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ 1551 #endif 1552 1553 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ) 1554 #define PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ 1555 #endif 1556 1557 #if !defined(PETSC_USE_FORTRAN_KERNEL_MDOT) 1558 #define PETSC_USE_FORTRAN_KERNEL_MDOT 1559 #endif 1560 1561 #if !defined(PETSC_USE_FORTRAN_KERNEL_XTIMESY) 1562 #define PETSC_USE_FORTRAN_KERNEL_XTIMESY 1563 #endif 1564 1565 #if !defined(PETSC_USE_FORTRAN_KERNEL_AYPX) 1566 #define PETSC_USE_FORTRAN_KERNEL_AYPX 1567 #endif 1568 1569 #if !defined(PETSC_USE_FORTRAN_KERNEL_WAXPY) 1570 #define PETSC_USE_FORTRAN_KERNEL_WAXPY 1571 #endif 1572 1573 #endif 1574 1575 /* 1576 Macros for indicating code that should be compiled with a C interface, 1577 rather than a C++ interface. Any routines that are dynamically loaded 1578 (such as the PCCreate_XXX() routines) must be wrapped so that the name 1579 mangler does not change the functions symbol name. This just hides the 1580 ugly extern "C" {} wrappers. 1581 */ 1582 #if defined(__cplusplus) 1583 #define EXTERN_C_BEGIN extern "C" { 1584 #define EXTERN_C_END } 1585 #else 1586 #define EXTERN_C_BEGIN 1587 #define EXTERN_C_END 1588 #endif 1589 1590 /* --------------------------------------------------------------------*/ 1591 1592 /*MC 1593 size - integer variable used to contain the number of processors in 1594 the relevent MPI_Comm 1595 1596 Level: beginner 1597 1598 .seealso: rank, comm 1599 M*/ 1600 1601 /*MC 1602 rank - integer variable used to contain the number of this processor relative 1603 to all in the relevent MPI_Comm 1604 1605 Level: beginner 1606 1607 .seealso: size, comm 1608 M*/ 1609 1610 /*MC 1611 comm - MPI_Comm used in the current routine or object 1612 1613 Level: beginner 1614 1615 .seealso: size, rank 1616 M*/ 1617 1618 /*MC 1619 MPI_Comm - the basic object used by MPI to determine which processes are involved in a 1620 communication 1621 1622 Level: beginner 1623 1624 Note: This manual page is a place-holder because MPICH does not have a manual page for MPI_Comm 1625 1626 .seealso: size, rank, comm, PETSC_COMM_WORLD, PETSC_COMM_SELF 1627 M*/ 1628 1629 /*MC 1630 PetscScalar - PETSc type that represents either a double precision real number, 1631 a double precision complex number, a single precision real number, a long double or an int 1632 if the code is configured with --with-scalar-type=complex,float,longdouble,int 1633 1634 Level: beginner 1635 1636 .seealso: PetscReal, PassiveReal, PassiveScalar 1637 M*/ 1638 1639 /*MC 1640 PetscReal - PETSc type that represents a real number version of PetscScalar 1641 1642 Level: beginner 1643 1644 .seealso: PetscScalar, PassiveReal, PassiveScalar 1645 M*/ 1646 1647 /*MC 1648 PassiveScalar - PETSc type that represents a PetscScalar 1649 Level: beginner 1650 1651 This is the same as a PetscScalar except in code that is automatically differentiated it is 1652 treated as a constant (not an indendent or dependent variable) 1653 1654 .seealso: PetscReal, PassiveReal, PetscScalar 1655 M*/ 1656 1657 /*MC 1658 PassiveReal - PETSc type that represents a PetscReal 1659 1660 Level: beginner 1661 1662 This is the same as a PetscReal except in code that is automatically differentiated it is 1663 treated as a constant (not an indendent or dependent variable) 1664 1665 .seealso: PetscScalar, PetscReal, PassiveScalar 1666 M*/ 1667 1668 /*MC 1669 MPIU_SCALAR - MPI datatype corresponding to PetscScalar 1670 1671 Level: beginner 1672 1673 Note: In MPI calls that require an MPI datatype that matches a PetscScalar or array of PetscScalars 1674 pass this value 1675 1676 .seealso: PetscReal, PassiveReal, PassiveScalar, PetscScalar 1677 M*/ 1678 1679 /* 1680 The IBM include files define hz, here we hide it so that it may be used 1681 as a regular user variable. 1682 */ 1683 #if defined(hz) 1684 #undef hz 1685 #endif 1686 1687 /* For arrays that contain filenames or paths */ 1688 1689 1690 #if defined(PETSC_HAVE_LIMITS_H) 1691 #include <limits.h> 1692 #endif 1693 #if defined(PETSC_HAVE_SYS_PARAM_H) 1694 #include <sys/param.h> 1695 #endif 1696 #if defined(PETSC_HAVE_SYS_TYPES_H) 1697 #include <sys/types.h> 1698 #endif 1699 #if defined(MAXPATHLEN) 1700 # define PETSC_MAX_PATH_LEN MAXPATHLEN 1701 #elif defined(MAX_PATH) 1702 # define PETSC_MAX_PATH_LEN MAX_PATH 1703 #elif defined(_MAX_PATH) 1704 # define PETSC_MAX_PATH_LEN _MAX_PATH 1705 #else 1706 # define PETSC_MAX_PATH_LEN 4096 1707 #endif 1708 1709 PETSC_EXTERN_CXX_END 1710 #endif 1711