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