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