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