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