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