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 #else 961 #define PETSC_SCALAR PETSC_DOUBLE 962 #endif 963 #endif 964 #if defined(PETSC_USE_SINGLE) 965 #define PETSC_REAL PETSC_FLOAT 966 #elif defined(PETSC_USE_LONG_DOUBLE) 967 #define PETSC_REAL PETSC_LONG_DOUBLE 968 #else 969 #define PETSC_REAL PETSC_DOUBLE 970 #endif 971 #define PETSC_FORTRANADDR PETSC_LONG 972 973 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDataTypeToMPIDataType(PetscDataType,MPI_Datatype*); 974 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDataTypeGetSize(PetscDataType,PetscInt*); 975 976 /* 977 Basic memory and string operations. These are usually simple wrappers 978 around the basic Unix system calls, but a few of them have additional 979 functionality and/or error checking. 980 */ 981 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemcpy(void*,const void *,size_t); 982 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBitMemcpy(void*,PetscInt,const void*,PetscInt,PetscInt,PetscDataType); 983 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemmove(void*,void *,size_t); 984 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemzero(void*,size_t); 985 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemcmp(const void*,const void*,size_t,PetscTruth *); 986 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrlen(const char[],size_t*); 987 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrcmp(const char[],const char[],PetscTruth *); 988 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrgrt(const char[],const char[],PetscTruth *); 989 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrcasecmp(const char[],const char[],PetscTruth*); 990 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrncmp(const char[],const char[],size_t,PetscTruth*); 991 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrcpy(char[],const char[]); 992 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrcat(char[],const char[]); 993 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrncat(char[],const char[],size_t); 994 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrncpy(char[],const char[],size_t); 995 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrchr(const char[],char,char *[]); 996 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrtolower(char[]); 997 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrrchr(const char[],char,char *[]); 998 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrstr(const char[],const char[],char *[]); 999 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrrstr(const char[],const char[],char *[]); 1000 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrallocpy(const char[],char *[]); 1001 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrreplace(MPI_Comm,const char[],char[],size_t); 1002 #define PetscStrfree(a) ((a) ? PetscFree(a) : 0) 1003 /*S 1004 PetscToken - 'Token' used for managing tokenizing strings 1005 1006 Level: intermediate 1007 1008 .seealso: PetscTokenCreate(), PetscTokenFind(), PetscTokenDestroy() 1009 S*/ 1010 typedef struct {char token;char *array;char *current;} PetscToken; 1011 1012 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscTokenCreate(const char[],const char,PetscToken**); 1013 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscTokenFind(PetscToken*,char *[]); 1014 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscTokenDestroy(PetscToken*); 1015 1016 /* 1017 These are MPI operations for MPI_Allreduce() etc 1018 */ 1019 EXTERN PETSC_DLLEXPORT MPI_Op PetscMaxSum_Op; 1020 #if defined(PETSC_USE_COMPLEX) 1021 EXTERN PETSC_DLLEXPORT MPI_Op PetscSum_Op; 1022 #else 1023 #define PetscSum_Op MPI_SUM 1024 #endif 1025 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMaxSum(MPI_Comm,const PetscInt[],PetscInt*,PetscInt*); 1026 1027 /*S 1028 PetscObject - any PETSc object, PetscViewer, Mat, Vec, KSP etc 1029 1030 Level: beginner 1031 1032 Note: This is the base class from which all objects appear. 1033 1034 .seealso: PetscObjectDestroy(), PetscObjectView(), PetscObjectGetName(), PetscObjectSetName() 1035 S*/ 1036 typedef struct _p_PetscObject* PetscObject; 1037 1038 /*S 1039 PetscFList - Linked list of functions, possibly stored in dynamic libraries, accessed 1040 by string name 1041 1042 Level: advanced 1043 1044 .seealso: PetscFListAdd(), PetscFListDestroy() 1045 S*/ 1046 typedef struct _n_PetscFList *PetscFList; 1047 1048 /*E 1049 PetscFileMode - Access mode for a file. 1050 1051 Level: beginner 1052 1053 FILE_MODE_READ - open a file at its beginning for reading 1054 1055 FILE_MODE_WRITE - open a file at its beginning for writing (will create if the file does not exist) 1056 1057 FILE_MODE_APPEND - open a file at end for writing 1058 1059 FILE_MODE_UPDATE - open a file for updating, meaning for reading and writing 1060 1061 FILE_MODE_APPEND_UPDATE - open a file for updating, meaning for reading and writing, at the end 1062 1063 .seealso: PetscViewerFileSetMode() 1064 E*/ 1065 typedef enum {FILE_MODE_READ, FILE_MODE_WRITE, FILE_MODE_APPEND, FILE_MODE_UPDATE, FILE_MODE_APPEND_UPDATE} PetscFileMode; 1066 1067 #include "petscviewer.h" 1068 #include "petscoptions.h" 1069 1070 #define PETSC_COOKIE 1211211 1071 extern PETSC_DLLEXPORT PetscCookie PETSC_LARGEST_COOKIE; 1072 extern PETSC_DLLEXPORT PetscCookie PETSC_OBJECT_COOKIE; 1073 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscCookieRegister(PetscCookie *); 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 PetscVerboseInfoAllow(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 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryCCAAppend(MPI_Comm,PetscDLLibraryList *,const char[]); 1261 1262 /* 1263 Mechanism for translating PETSc object representations between languages 1264 Not currently used. 1265 */ 1266 typedef enum {PETSC_LANGUAGE_C,PETSC_LANGUAGE_CXX} PetscLanguage; 1267 #define PETSC_LANGUAGE_F77 PETSC_LANGUAGE_C 1268 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectComposeLanguage(PetscObject,PetscLanguage,void *); 1269 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectQueryLanguage(PetscObject,PetscLanguage,void **); 1270 1271 /* 1272 Useful utility routines 1273 */ 1274 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSplitOwnership(MPI_Comm,PetscInt*,PetscInt*); 1275 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSplitOwnershipBlock(MPI_Comm,PetscInt,PetscInt*,PetscInt*); 1276 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSequentialPhaseBegin(MPI_Comm,PetscMPIInt); 1277 PetscPolymorphicSubroutine(PetscSequentialPhaseBegin,(MPI_Comm comm),(comm,1)) 1278 PetscPolymorphicSubroutine(PetscSequentialPhaseBegin,(void),(PETSC_COMM_WORLD,1)) 1279 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSequentialPhaseEnd(MPI_Comm,PetscMPIInt); 1280 PetscPolymorphicSubroutine(PetscSequentialPhaseEnd,(MPI_Comm comm),(comm,1)) 1281 PetscPolymorphicSubroutine(PetscSequentialPhaseEnd,(void),(PETSC_COMM_WORLD,1)) 1282 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBarrier(PetscObject); 1283 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMPIDump(FILE*); 1284 1285 #define PetscNot(a) ((a) ? PETSC_FALSE : PETSC_TRUE) 1286 /* 1287 Defines basic graphics available from PETSc. 1288 */ 1289 #include "petscdraw.h" 1290 1291 /* 1292 Defines the base data structures for all PETSc objects 1293 */ 1294 PETSC_EXTERN_CXX_END 1295 #include "private/petscimpl.h" 1296 PETSC_EXTERN_CXX_BEGIN 1297 /* 1298 Defines PETSc profiling. 1299 */ 1300 #include "petsclog.h" 1301 1302 /* 1303 For locking, unlocking and destroying AMS memories associated with 1304 PETSc objects. Not currently used. 1305 */ 1306 #define PetscPublishAll(v) 0 1307 #define PetscObjectTakeAccess(obj) 0 1308 #define PetscObjectGrantAccess(obj) 0 1309 #define PetscObjectDepublish(obj) 0 1310 1311 1312 1313 /* 1314 This code allows one to pass a MPI communicator between 1315 C and Fortran. MPI 2.0 defines a standard API for doing this. 1316 The code here is provided to allow PETSc to work with MPI 1.1 1317 standard MPI libraries. 1318 */ 1319 EXTERN PetscErrorCode MPICCommToFortranComm(MPI_Comm,int *); 1320 EXTERN PetscErrorCode MPIFortranCommToCComm(int,MPI_Comm*); 1321 1322 /* 1323 Simple PETSc parallel IO for ASCII printing 1324 */ 1325 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFixFilename(const char[],char[]); 1326 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFOpen(MPI_Comm,const char[],const char[],FILE**); 1327 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFClose(MPI_Comm,FILE*); 1328 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4); 1329 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPrintf(MPI_Comm,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3); 1330 1331 /* These are used internally by PETSc ASCII IO routines*/ 1332 #include <stdarg.h> 1333 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscVSNPrintf(char*,size_t,const char*,va_list); 1334 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscVFPrintf(FILE*,const char*,va_list); 1335 1336 /*MC 1337 PetscErrorPrintf - Prints error messages. 1338 1339 Not Collective 1340 1341 Synopsis: 1342 PetscErrorCode (*PetscErrorPrintf)(const char format[],...); 1343 1344 Input Parameters: 1345 . format - the usual printf() format string 1346 1347 Options Database Keys: 1348 . -error_output_stderr - cause error messages to be printed to stderr instead of the 1349 (default) stdout 1350 1351 1352 Level: developer 1353 1354 Fortran Note: 1355 This routine is not supported in Fortran. 1356 1357 Concepts: error messages^printing 1358 Concepts: printing^error messages 1359 1360 .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscHelpPrintf() 1361 M*/ 1362 EXTERN PETSC_DLLEXPORT PetscErrorCode (*PetscErrorPrintf)(const char[],...); 1363 1364 /*MC 1365 PetscHelpPrintf - Prints help messages. 1366 1367 Not Collective 1368 1369 Synopsis: 1370 PetscErrorCode (*PetscHelpPrintf)(const char format[],...); 1371 1372 Input Parameters: 1373 . format - the usual printf() format string 1374 1375 Level: developer 1376 1377 Fortran Note: 1378 This routine is not supported in Fortran. 1379 1380 Concepts: help messages^printing 1381 Concepts: printing^help messages 1382 1383 .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscErrorPrintf() 1384 M*/ 1385 EXTERN PETSC_DLLEXPORT PetscErrorCode (*PetscHelpPrintf)(MPI_Comm,const char[],...); 1386 1387 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPOpen(MPI_Comm,const char[],const char[],const char[],FILE **); 1388 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPClose(MPI_Comm,FILE*); 1389 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSynchronizedPrintf(MPI_Comm,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3); 1390 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSynchronizedFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4); 1391 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSynchronizedFlush(MPI_Comm); 1392 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSynchronizedFGets(MPI_Comm,FILE*,size_t,char[]); 1393 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStartMatlab(MPI_Comm,const char[],const char[],FILE**); 1394 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStartJava(MPI_Comm,const char[],const char[],FILE**); 1395 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetPetscDir(const char*[]); 1396 1397 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPopUpSelect(MPI_Comm,char*,char*,int,char**,int*); 1398 /*S 1399 PetscObjectContainer - Simple PETSc object that contains a pointer to any required data 1400 1401 Level: advanced 1402 1403 .seealso: PetscObject, PetscObjectContainerCreate() 1404 S*/ 1405 typedef struct _p_PetscObjectContainer* PetscObjectContainer; 1406 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectContainerGetPointer(PetscObjectContainer,void **); 1407 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectContainerSetPointer(PetscObjectContainer,void *); 1408 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectContainerDestroy(PetscObjectContainer); 1409 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectContainerCreate(MPI_Comm comm,PetscObjectContainer *); 1410 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectContainerSetUserDestroy(PetscObjectContainer, PetscErrorCode (*)(void*)); 1411 1412 /* 1413 For use in debuggers 1414 */ 1415 extern PETSC_DLLEXPORT PetscMPIInt PetscGlobalRank; 1416 extern PETSC_DLLEXPORT PetscMPIInt PetscGlobalSize; 1417 1418 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscIntView(PetscInt,PetscInt[],PetscViewer); 1419 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRealView(PetscInt,PetscReal[],PetscViewer); 1420 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscScalarView(PetscInt,PetscScalar[],PetscViewer); 1421 1422 /* 1423 Allows accessing Matlab Engine 1424 */ 1425 #include "petscmatlab.h" 1426 1427 /* 1428 Determine if some of the kernel computation routines use 1429 Fortran (rather than C) for the numerical calculations. On some machines 1430 and compilers (like complex numbers) the Fortran version of the routines 1431 is faster than the C/C++ versions. The flag PETSC_USE_FORTRAN_KERNELS 1432 would be set in the petscconf.h file 1433 */ 1434 #if defined(PETSC_USE_FORTRAN_KERNELS) 1435 1436 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTCRL) 1437 #define PETSC_USE_FORTRAN_KERNEL_MULTCRL 1438 #endif 1439 1440 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTCSRPERM) 1441 #define PETSC_USE_FORTRAN_KERNEL_MULTCSRPERM 1442 #endif 1443 1444 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTAIJ) 1445 #define PETSC_USE_FORTRAN_KERNEL_MULTAIJ 1446 #endif 1447 1448 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ) 1449 #define PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ 1450 #endif 1451 1452 #if !defined(PETSC_USE_FORTRAN_KERNEL_NORM) 1453 #define PETSC_USE_FORTRAN_KERNEL_NORM 1454 #endif 1455 1456 #if !defined(PETSC_USE_FORTRAN_KERNEL_MAXPY) 1457 #define PETSC_USE_FORTRAN_KERNEL_MAXPY 1458 #endif 1459 1460 #if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ) 1461 #define PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ 1462 #endif 1463 1464 #if !defined(PETSC_USE_FORTRAN_KERNEL_RELAXAIJ) 1465 #define PETSC_USE_FORTRAN_KERNEL_RELAXAIJ 1466 #endif 1467 1468 #if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ) 1469 #define PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ 1470 #endif 1471 1472 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ) 1473 #define PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ 1474 #endif 1475 1476 #if !defined(PETSC_USE_FORTRAN_KERNEL_MDOT) 1477 #define PETSC_USE_FORTRAN_KERNEL_MDOT 1478 #endif 1479 1480 #if !defined(PETSC_USE_FORTRAN_KERNEL_XTIMESY) 1481 #define PETSC_USE_FORTRAN_KERNEL_XTIMESY 1482 #endif 1483 1484 #if !defined(PETSC_USE_FORTRAN_KERNEL_AYPX) 1485 #define PETSC_USE_FORTRAN_KERNEL_AYPX 1486 #endif 1487 1488 #if !defined(PETSC_USE_FORTRAN_KERNEL_WAXPY) 1489 #define PETSC_USE_FORTRAN_KERNEL_WAXPY 1490 #endif 1491 1492 #endif 1493 1494 /* 1495 Macros for indicating code that should be compiled with a C interface, 1496 rather than a C++ interface. Any routines that are dynamically loaded 1497 (such as the PCCreate_XXX() routines) must be wrapped so that the name 1498 mangler does not change the functions symbol name. This just hides the 1499 ugly extern "C" {} wrappers. 1500 */ 1501 #if defined(__cplusplus) 1502 #define EXTERN_C_BEGIN extern "C" { 1503 #define EXTERN_C_END } 1504 #else 1505 #define EXTERN_C_BEGIN 1506 #define EXTERN_C_END 1507 #endif 1508 1509 /* --------------------------------------------------------------------*/ 1510 1511 /*MC 1512 size - integer variable used to contain the number of processors in 1513 the relevent MPI_Comm 1514 1515 Level: beginner 1516 1517 .seealso: rank, comm 1518 M*/ 1519 1520 /*MC 1521 rank - integer variable used to contain the number of this processor relative 1522 to all in the relevent MPI_Comm 1523 1524 Level: beginner 1525 1526 .seealso: size, comm 1527 M*/ 1528 1529 /*MC 1530 comm - MPI_Comm used in the current routine or object 1531 1532 Level: beginner 1533 1534 .seealso: size, rank 1535 M*/ 1536 1537 /*MC 1538 MPI_Comm - the basic object used by MPI to determine which processes are involved in a 1539 communication 1540 1541 Level: beginner 1542 1543 Note: This manual page is a place-holder because MPICH does not have a manual page for MPI_Comm 1544 1545 .seealso: size, rank, comm, PETSC_COMM_WORLD, PETSC_COMM_SELF 1546 M*/ 1547 1548 /*MC 1549 PetscScalar - PETSc type that represents either a double precision real number or 1550 a double precision complex number if the code is configured with --with-scalar-type=complex 1551 1552 Level: beginner 1553 1554 .seealso: PetscReal, PassiveReal, PassiveScalar 1555 M*/ 1556 1557 /*MC 1558 PetscReal - PETSc type that represents a double precision real number 1559 1560 Level: beginner 1561 1562 .seealso: PetscScalar, PassiveReal, PassiveScalar 1563 M*/ 1564 1565 /*MC 1566 PassiveScalar - PETSc type that represents either a double precision real number or 1567 a double precision complex number if the code is code is configured with --with-scalar-type=complex 1568 1569 Level: beginner 1570 1571 This is the same as a PetscScalar except in code that is automatically differentiated it is 1572 treated as a constant (not an indendent or dependent variable) 1573 1574 .seealso: PetscReal, PassiveReal, PetscScalar 1575 M*/ 1576 1577 /*MC 1578 PassiveReal - PETSc type that represents a double precision real number 1579 1580 Level: beginner 1581 1582 This is the same as a PetscReal except in code that is automatically differentiated it is 1583 treated as a constant (not an indendent or dependent variable) 1584 1585 .seealso: PetscScalar, PetscReal, PassiveScalar 1586 M*/ 1587 1588 /*MC 1589 MPIU_SCALAR - MPI datatype corresponding to PetscScalar 1590 1591 Level: beginner 1592 1593 Note: In MPI calls that require an MPI datatype that matches a PetscScalar or array of PetscScalars 1594 pass this value 1595 1596 .seealso: PetscReal, PassiveReal, PassiveScalar, PetscScalar 1597 M*/ 1598 1599 /* 1600 The IBM include files define hz, here we hide it so that it may be used 1601 as a regular user variable. 1602 */ 1603 #if defined(hz) 1604 #undef hz 1605 #endif 1606 1607 /* For arrays that contain filenames or paths */ 1608 1609 1610 #if defined(PETSC_HAVE_LIMITS_H) 1611 #include <limits.h> 1612 #endif 1613 #if defined(PETSC_HAVE_SYS_PARAM_H) 1614 #include <sys/param.h> 1615 #endif 1616 #if defined(PETSC_HAVE_SYS_TYPES_H) 1617 #include <sys/types.h> 1618 #endif 1619 #if defined(MAXPATHLEN) 1620 # define PETSC_MAX_PATH_LEN MAXPATHLEN 1621 #elif defined(MAX_PATH) 1622 # define PETSC_MAX_PATH_LEN MAX_PATH 1623 #elif defined(_MAX_PATH) 1624 # define PETSC_MAX_PATH_LEN _MAX_PATH 1625 #else 1626 # define PETSC_MAX_PATH_LEN 4096 1627 #endif 1628 1629 PETSC_EXTERN_CXX_END 1630 #endif 1631 1632 1633