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