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