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