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