1 /* $Id: petsc.h,v 1.297 2001/09/07 20:13:16 bsmith Exp $ */ 2 /* 3 This is the main PETSc include file (for C and C++). It is included by all 4 other PETSc include files, so it almost never has to be specifically included. 5 */ 6 #if !defined(__PETSC_H) 7 #define __PETSC_H 8 9 /* ========================================================================== */ 10 /* 11 Current PETSc version number and release date 12 */ 13 #include "petscversion.h" 14 15 /* ========================================================================== */ 16 /* 17 petscconf.h is contained in bmake/${PETSC_ARCH}/petscconf.h it is 18 found automatically by the compiler due to the -I${PETSC_DIR}/bmake/${PETSC_ARCH} 19 in the bmake/common_variables definition of PETSC_INCLUDE 20 */ 21 #include "petscconf.h" 22 /* 23 Fixes for configure time choices which impact our interface. Currently only 24 calling conventions and extra compiler checking falls under this category. 25 */ 26 #if !defined(PETSC_PRINTF_FORMAT_CHECK) 27 #define PETSC_PRINTF_FORMAT_CHECK(a,b) 28 #endif 29 #if !defined (PETSC_STDCALL) 30 #define PETSC_STDCALL 31 #endif 32 #if !defined (PETSC_TEMPLATE) 33 #define PETSC_TEMPLATE 34 #endif 35 36 /* ========================================================================== */ 37 38 #include <stdio.h> 39 /* 40 Defines the interface to MPI allowing the use of all MPI functions. 41 */ 42 #include "mpi.h" 43 44 /* 45 EXTERN indicates a PETSc function defined elsewhere 46 */ 47 #if !defined(EXTERN) 48 #define EXTERN extern 49 #endif 50 51 /* 52 Defines some elementary mathematics functions and constants. 53 */ 54 #include "petscmath.h" 55 56 /* 57 Basic PETSc constants 58 */ 59 60 /*E 61 PetscTruth - Logical variable. Actually an integer 62 63 Level: beginner 64 65 E*/ 66 typedef enum { PETSC_FALSE,PETSC_TRUE } PetscTruth; 67 68 /*M 69 PETSC_NULL - standard way of passing in a null or array or pointer 70 71 Level: beginner 72 73 Notes: accepted by many PETSc functions to not set a parameter and instead use 74 some default 75 76 This macro does not exist in Fortran; you must use PETSC_NULL_INTEGER, 77 PETSC_NULL_DOUBLE_PRECISION etc 78 79 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE 80 81 M*/ 82 #define PETSC_NULL 0 83 84 /*M 85 PETSC_DECIDE - standard way of passing in integer or floating point parameter 86 where you wish PETSc to use the default. 87 88 Level: beginner 89 90 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE 91 92 M*/ 93 #define PETSC_DECIDE -1 94 95 /*M 96 PETSC_DEFAULT - standard way of passing in integer or floating point parameter 97 where you wish PETSc to use the default. 98 99 Level: beginner 100 101 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE 102 103 M*/ 104 #define PETSC_DEFAULT -2 105 106 #define PETSC_YES PETSC_TRUE 107 #define PETSC_NO PETSC_FALSE 108 #define PETSC_IGNORE PETSC_NULL 109 110 /*M 111 PETSC_DETERMINE - standard way of passing in integer or floating point parameter 112 where you wish PETSc to compute the required value. 113 114 Level: beginner 115 116 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE, VecSetSizes() 117 118 M*/ 119 #define PETSC_DETERMINE PETSC_DECIDE 120 121 /*M 122 PETSC_COMM_WORLD - a duplicate of the MPI_COMM_WORLD communicator which represents 123 all the processs 124 125 Level: beginner 126 127 Notes: PETSC_COMM_WORLD and MPI_COMM_WORLD are equivalent except that passint MPI_COMM_WORLD 128 into PETSc object constructors will result in using more MPI resources since an MPI_Comm_dup() 129 will be done on it internally. We recommend always using PETSC_COMM_WORLD 130 131 .seealso: PETSC_COMM_SELF 132 133 M*/ 134 extern MPI_Comm PETSC_COMM_WORLD; 135 136 /*M 137 PETSC_COMM_SELF - a duplicate of the MPI_COMM_SELF communicator which represents 138 the current process 139 140 Level: beginner 141 142 Notes: PETSC_COMM_SELF and MPI_COMM_SELF are equivalent except that passint MPI_COMM_SELF 143 into PETSc object constructors will result in using more MPI resources since an MPI_Comm_dup() 144 will be done on it internally. We recommend always using PETSC_COMM_SELF 145 146 .seealso: PETSC_COMM_WORLD 147 148 M*/ 149 extern MPI_Comm PETSC_COMM_SELF; 150 151 extern PetscTruth PetscInitializeCalled; 152 EXTERN int PetscSetCommWorld(MPI_Comm); 153 EXTERN int PetscSetHelpVersionFunctions(int (*)(MPI_Comm),int (*)(MPI_Comm)); 154 155 /*MC 156 PetscMalloc - Allocates memory 157 158 Input Parameter: 159 . m - number of bytes to allocate 160 161 Output Parameter: 162 . result - memory allocated 163 164 Synopsis: 165 int PetscMalloc(size_t m,void **result) 166 167 Level: beginner 168 169 Notes: Memory is always allocated at least double aligned 170 171 .seealso: PetscFree(), PetscNew() 172 173 Concepts: memory allocation 174 175 M*/ 176 #define PetscMalloc(a,b) (*PetscTrMalloc)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__,(void**)(b)) 177 /*MC 178 PetscNew - Allocates memory of a particular type 179 180 Input Parameter: 181 . type - structure name of space to be allocated. Memory of size sizeof(type) is allocated 182 183 Output Parameter: 184 . result - memory allocated 185 186 Synopsis: 187 int PetscNew(struct type,((type *))result) 188 189 Level: beginner 190 191 .seealso: PetscFree(), PetscMalloc() 192 193 Concepts: memory allocation 194 195 M*/ 196 #define PetscNew(A,b) PetscMalloc(sizeof(A),(b)) 197 /*MC 198 PetscFree - Frees memory 199 200 Input Parameter: 201 . memory - memory to free 202 203 Synopsis: 204 int PetscFree(void *memory) 205 206 Level: beginner 207 208 Notes: Memory must have been obtained with PetscNew() or PetscMalloc() 209 210 .seealso: PetscNew(), PetscMalloc() 211 212 Concepts: memory allocation 213 214 M*/ 215 #define PetscFree(a) (*PetscTrFree)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__) 216 EXTERN int (*PetscTrMalloc)(size_t,int,char*,char*,char*,void**); 217 EXTERN int (*PetscTrFree)(void *,int,char*,char*,char*); 218 EXTERN int PetscSetMalloc(int (*)(size_t,int,char*,char*,char*,void**),int (*)(void *,int,char*,char*,char*)); 219 EXTERN int PetscClearMalloc(void); 220 221 /* 222 Routines for tracing memory corruption/bleeding with default PETSc 223 memory allocation 224 */ 225 EXTERN int PetscTrDump(FILE *); 226 EXTERN int PetscTrSpace(PetscLogDouble *,PetscLogDouble *,PetscLogDouble *); 227 EXTERN int PetscTrValid(int,const char[],const char[],const char[]); 228 EXTERN int PetscTrDebugLevel(int); 229 EXTERN int PetscTrLog(void); 230 EXTERN int PetscTrLogDump(FILE *); 231 EXTERN int PetscGetResidentSetSize(PetscLogDouble *); 232 233 /* 234 Variable type where we stash PETSc object pointers in Fortran. 235 Assumes that sizeof(long) == sizeof(void*)which is true on 236 all machines that we know. 237 */ 238 #define PetscFortranAddr long 239 240 /*E 241 PetscDataType - Used for handling different basic data types. 242 243 Level: beginner 244 245 .seealso: PetscBinaryRead(), PetscBinaryWrite(), PetscDataTypeToMPIDataType(), 246 PetscDataTypeGetSize(), PetscDataTypeGetName() 247 248 E*/ 249 typedef enum {PETSC_INT = 0,PETSC_DOUBLE = 1,PETSC_COMPLEX = 2, 250 PETSC_LONG =3 ,PETSC_SHORT = 4,PETSC_FLOAT = 5, 251 PETSC_CHAR = 6,PETSC_LOGICAL = 7} PetscDataType; 252 #if defined(PETSC_USE_COMPLEX) 253 #define PETSC_SCALAR PETSC_COMPLEX 254 #else 255 #if defined(PETSC_USE_SINGLE) 256 #define PETSC_SCALAR PETSC_FLOAT 257 #else 258 #define PETSC_SCALAR PETSC_DOUBLE 259 #endif 260 #endif 261 #if defined(PETSC_USE_SINGLE) 262 #define PETSC_REAL PETSC_FLOAT 263 #else 264 #define PETSC_REAL PETSC_DOUBLE 265 #endif 266 #define PETSC_FORTRANADDR PETSC_LONG 267 268 EXTERN int PetscDataTypeToMPIDataType(PetscDataType,MPI_Datatype*); 269 EXTERN int PetscDataTypeGetSize(PetscDataType,int*); 270 EXTERN int PetscDataTypeGetName(PetscDataType,char*[]); 271 272 /* 273 Basic memory and string operations. These are usually simple wrappers 274 around the basic Unix system calls, but a few of them have additional 275 functionality and/or error checking. 276 */ 277 EXTERN int PetscMemcpy(void *,const void *,int); 278 EXTERN int PetscBitMemcpy(void*,int,const void*,int,int,PetscDataType); 279 EXTERN int PetscMemmove(void *,void *,int); 280 EXTERN int PetscMemzero(void *,int); 281 EXTERN int PetscMemcmp(const void*,const void*,int,PetscTruth *); 282 EXTERN int PetscStrlen(const char[],int*); 283 EXTERN int PetscStrcmp(const char[],const char[],PetscTruth *); 284 EXTERN int PetscStrgrt(const char[],const char[],PetscTruth *); 285 EXTERN int PetscStrcasecmp(const char[],const char[],PetscTruth*); 286 EXTERN int PetscStrncmp(const char[],const char[],int,PetscTruth*); 287 EXTERN int PetscStrcpy(char[],const char[]); 288 EXTERN int PetscStrcat(char[],const char[]); 289 EXTERN int PetscStrncat(char[],const char[],int); 290 EXTERN int PetscStrncpy(char[],const char[],int); 291 EXTERN int PetscStrchr(const char[],char,char **); 292 EXTERN int PetscStrtolower(char[]); 293 EXTERN int PetscStrrchr(const char[],char,char **); 294 EXTERN int PetscStrstr(const char[],const char[],char **); 295 EXTERN int PetscStrallocpy(const char[],char **); 296 EXTERN int PetscStrreplace(MPI_Comm,const char[],char*,int); 297 #define PetscStrfree(a) ((a) ? PetscFree(a) : 0) 298 typedef struct {char token;char *array;char *current;} PetscToken; 299 EXTERN int PetscTokenCreate(const char[],const char,PetscToken**); 300 EXTERN int PetscTokenFind(PetscToken*,char **); 301 EXTERN int PetscTokenDestroy(PetscToken*); 302 303 /* 304 These are MPI operations for MPI_Allreduce() etc 305 */ 306 EXTERN MPI_Op PetscMaxSum_Op; 307 #if defined(PETSC_USE_COMPLEX) 308 EXTERN MPI_Op PetscSum_Op; 309 #else 310 #define PetscSum_Op MPI_SUM 311 #endif 312 EXTERN int PetscMaxSum(MPI_Comm,const int[],int*,int*); 313 314 /*S 315 PetscObject - any PETSc object, PetscViewer, Mat, Vec, SLES etc 316 317 Level: beginner 318 319 .seealso: PetscObjectDestroy(), PetscObjectView(), PetscObjectGetName(), PetscObjectSetName() 320 S*/ 321 typedef struct _p_PetscObject* PetscObject; 322 323 /*S 324 PetscFList - Linked list of functions, possibly stored in dynamic libraries, accessed 325 by string name 326 327 Level: advanced 328 329 .seealso: PetscFListAdd(), PetscFListDestroy() 330 S*/ 331 typedef struct _PetscFList *PetscFList; 332 333 #include "petscviewer.h" 334 #include "petscoptions.h" 335 336 EXTERN int PetscShowMemoryUsage(PetscViewer,char*); 337 EXTERN int PetscGetTime(PetscLogDouble*); 338 EXTERN int PetscGetCPUTime(PetscLogDouble*); 339 EXTERN int PetscSleep(int); 340 341 /* 342 Initialization of PETSc 343 */ 344 EXTERN int PetscInitialize(int*,char***,char[],const char[]); 345 EXTERN int PetscInitializeNoArguments(void); 346 EXTERN int PetscFinalize(void); 347 EXTERN int PetscInitializeFortran(void); 348 EXTERN int PetscGetArgs(int*,char ***); 349 EXTERN int PetscEnd(void); 350 351 /* 352 ParameterDict is an abstraction for arguments to interface mechanisms 353 */ 354 extern int DICT_COOKIE; 355 typedef struct _p_Dict *ParameterDict; 356 357 typedef void (**PetscVoidFunction)(void); 358 359 /* 360 PetscTryMethod - Queries an object for a method, if it exists then calls it. 361 Can support argument checking 362 */ 363 #if defined(PETSC_FORTRAN_STUBS) 364 #define PetscTryMethod(obj,A,B,C) \ 365 0;{ int (*f)B; \ 366 *ierr = PetscObjectQueryFunction((PetscObject)obj,#A,(PetscVoidFunction)&f);if (*ierr) return; \ 367 if (f) {*ierr = (*f)C;if (*ierr) return;}\ 368 } 369 #else 370 #define PetscTryMethod(obj,A,B,C) \ 371 0;{ int (*f)B, __ierr; \ 372 __ierr = PetscObjectQueryFunction((PetscObject)obj,#A,(PetscVoidFunction)&f);CHKERRQ(__ierr); \ 373 if (f) {__ierr = (*f)C;CHKERRQ(__ierr);}\ 374 } 375 #endif 376 377 /* 378 Functions that can act on any PETSc object. 379 */ 380 EXTERN int PetscObjectDestroy(PetscObject); 381 EXTERN int PetscObjectExists(PetscObject,PetscTruth*); 382 EXTERN int PetscObjectGetComm(PetscObject,MPI_Comm *); 383 EXTERN int PetscObjectGetCookie(PetscObject,int *); 384 EXTERN int PetscObjectGetType(PetscObject,int *); 385 EXTERN int PetscObjectSetName(PetscObject,const char[]); 386 EXTERN int PetscObjectGetName(PetscObject,char*[]); 387 EXTERN int PetscObjectReference(PetscObject); 388 EXTERN int PetscObjectGetReference(PetscObject,int*); 389 EXTERN int PetscObjectDereference(PetscObject); 390 EXTERN int PetscObjectGetNewTag(PetscObject,int *); 391 EXTERN int PetscObjectSetParameterDict(PetscObject,ParameterDict); 392 EXTERN int PetscObjectGetParameterDict(PetscObject,ParameterDict*); 393 EXTERN int PetscCommGetNewTag(MPI_Comm,int *); 394 EXTERN int PetscObjectView(PetscObject,PetscViewer); 395 EXTERN int PetscObjectCompose(PetscObject,const char[],PetscObject); 396 EXTERN int PetscObjectQuery(PetscObject,const char[],PetscObject *); 397 EXTERN int PetscObjectComposeFunction(PetscObject,const char[],const char[],void (*)(void)); 398 399 /*MC 400 PetscObjectComposeFunctionDynamic - Associates a function with a given PETSc object. 401 402 Collective on PetscObject 403 404 Input Parameters: 405 + obj - the PETSc object; this must be cast with a (PetscObject), for example, 406 PetscObjectCompose((PetscObject)mat,...); 407 . name - name associated with the child function 408 . fname - name of the function 409 - ptr - function pointer (or PETSC_NULL if using dynamic libraries) 410 411 Level: advanced 412 413 Synopsis: 414 int PetscObjectComposeFunctionDynamic(PetscObject obj,char *name,char *fname,void *ptr) 415 416 Notes: 417 PetscObjectComposeFunctionDynamic() can be used with any PETSc object (such as 418 Mat, Vec, KSP, SNES, etc.) or any user-provided object. 419 420 The composed function must be wrapped in a EXTERN_C_BEGIN/END for this to 421 work in C++/complex with dynamic link libraries (PETSC_USE_DYNAMIC_LIBRARIES) 422 enabled. 423 424 Concepts: objects^composing functions 425 Concepts: composing functions 426 Concepts: functions^querying 427 Concepts: objects^querying 428 Concepts: querying objects 429 430 .seealso: PetscObjectQueryFunction() 431 M*/ 432 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 433 #define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,0) 434 #else 435 #define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,(void (*)(void))(d)) 436 #endif 437 438 EXTERN int PetscObjectQueryFunction(PetscObject,const char[],void (**)(void)); 439 EXTERN int PetscObjectSetOptionsPrefix(PetscObject,const char[]); 440 EXTERN int PetscObjectAppendOptionsPrefix(PetscObject,const char[]); 441 EXTERN int PetscObjectPrependOptionsPrefix(PetscObject,const char[]); 442 EXTERN int PetscObjectGetOptionsPrefix(PetscObject,char*[]); 443 EXTERN int PetscObjectPublish(PetscObject); 444 EXTERN int PetscObjectChangeTypeName(PetscObject,char *); 445 EXTERN int PetscObjectChangeSerializeName(PetscObject,char *); 446 EXTERN int PetscObjectRegisterDestroy(PetscObject); 447 EXTERN int PetscObjectRegisterDestroyAll(void); 448 EXTERN int PetscObjectName(PetscObject); 449 EXTERN int PetscTypeCompare(PetscObject,char*,PetscTruth*); 450 EXTERN int PetscSerializeCompare(PetscObject,char*,PetscTruth*); 451 452 /* 453 Defines PETSc error handling. 454 */ 455 #include "petscerror.h" 456 457 /*S 458 PetscOList - Linked list of PETSc objects, accessable by string name 459 460 Level: advanced 461 462 .seealso: PetscOListAdd(), PetscOListDestroy(), PetscOListFind() 463 S*/ 464 typedef struct _PetscOList *PetscOList; 465 466 EXTERN int PetscOListDestroy(PetscOList *); 467 EXTERN int PetscOListFind(PetscOList,const char[],PetscObject*); 468 EXTERN int PetscOListReverseFind(PetscOList,PetscObject,char**); 469 EXTERN int PetscOListAdd(PetscOList *,const char[],PetscObject); 470 EXTERN int PetscOListDuplicate(PetscOList,PetscOList *); 471 472 /* 473 Dynamic library lists. Lists of names of routines in dynamic 474 link libraries that will be loaded as needed. 475 */ 476 EXTERN int PetscFListAdd(PetscFList*,const char[],const char[],void (*)(void)); 477 EXTERN int PetscFListDestroy(PetscFList*); 478 EXTERN int PetscFListFind(MPI_Comm,PetscFList,const char[],void (**)(void)); 479 EXTERN int PetscFListPrintTypes(MPI_Comm,FILE*,const char[],const char[],char *,char *,PetscFList); 480 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 481 #define PetscFListAddDynamic(a,b,p,c) PetscFListAdd(a,b,p,0) 482 #else 483 #define PetscFListAddDynamic(a,b,p,c) PetscFListAdd(a,b,p,(void (*)(void))c) 484 #endif 485 EXTERN int PetscFListDuplicate(PetscFList,PetscFList *); 486 EXTERN int PetscFListView(PetscFList,PetscViewer); 487 EXTERN int PetscFListConcat(const char [],const char [],char []); 488 EXTERN int PetscFListGet(PetscFList,char ***,int*); 489 490 /*S 491 PetscDLLibraryList - Linked list of dynamics libraries to search for functions 492 493 Level: advanced 494 495 PETSC_USE_DYNAMIC_LIBRARIES must be defined in petscconf.h to use dynamic libraries 496 497 .seealso: PetscDLLibraryOpen() 498 S*/ 499 typedef struct _PetscDLLibraryList *PetscDLLibraryList; 500 extern PetscDLLibraryList DLLibrariesLoaded; 501 EXTERN int PetscDLLibraryRetrieve(MPI_Comm,const char[],char *,int,PetscTruth *); 502 EXTERN int PetscDLLibraryOpen(MPI_Comm,const char[],void **); 503 EXTERN int PetscDLLibrarySym(MPI_Comm,PetscDLLibraryList *,const char[],const char[],void **); 504 EXTERN int PetscDLLibraryAppend(MPI_Comm,PetscDLLibraryList *,const char[]); 505 EXTERN int PetscDLLibraryPrepend(MPI_Comm,PetscDLLibraryList *,const char[]); 506 EXTERN int PetscDLLibraryClose(PetscDLLibraryList); 507 EXTERN int PetscDLLibraryPrintPath(void); 508 EXTERN int PetscDLLibraryGetInfo(void *,char *,char **); 509 510 /* 511 Mechanism for translating PETSc object representations between languages 512 Not currently used. 513 */ 514 typedef enum {PETSC_LANGUAGE_C,PETSC_LANGUAGE_CPP} PetscLanguage; 515 #define PETSC_LANGUAGE_F77 PETSC_LANGUAGE_C 516 EXTERN int PetscObjectComposeLanguage(PetscObject,PetscLanguage,void *); 517 EXTERN int PetscObjectQueryLanguage(PetscObject,PetscLanguage,void **); 518 519 /* 520 Useful utility routines 521 */ 522 EXTERN int PetscSplitOwnership(MPI_Comm,int*,int*); 523 EXTERN int PetscSplitOwnershipBlock(MPI_Comm,int,int*,int*); 524 EXTERN int PetscSequentialPhaseBegin(MPI_Comm,int); 525 EXTERN int PetscSequentialPhaseEnd(MPI_Comm,int); 526 EXTERN int PetscBarrier(PetscObject); 527 EXTERN int PetscMPIDump(FILE*); 528 529 #define PetscNot(a) ((a) ? PETSC_FALSE : PETSC_TRUE) 530 /* 531 Defines basic graphics available from PETSc. 532 */ 533 #include "petscdraw.h" 534 535 /* 536 Defines the base data structures for all PETSc objects 537 */ 538 #include "petschead.h" 539 540 /* 541 Defines PETSc profiling. 542 */ 543 #include "petsclog.h" 544 545 /* 546 For locking, unlocking and destroying AMS memories associated with 547 PETSc objects 548 */ 549 #if defined(PETSC_HAVE_AMS) 550 551 extern PetscTruth PetscAMSPublishAll; 552 #define PetscPublishAll(v) (PetscAMSPublishAll ? PetscObjectPublish((PetscObject)v) : 0) 553 #define PetscObjectTakeAccess(obj) ((((PetscObject)(obj))->amem == -1) ? 0 : AMS_Memory_take_access(((PetscObject)(obj))->amem)) 554 #define PetscObjectGrantAccess(obj) ((((PetscObject)(obj))->amem == -1) ? 0 : AMS_Memory_grant_access(((PetscObject)(obj))->amem)) 555 #define PetscObjectDepublish(obj) ((((PetscObject)(obj))->amem == -1) ? 0 : AMS_Memory_destroy(((PetscObject)(obj))->amem)); \ 556 ((PetscObject)(obj))->amem = -1; 557 558 #else 559 560 #define PetscPublishAll(v) 0 561 #define PetscObjectTakeAccess(obj) 0 562 #define PetscObjectGrantAccess(obj) 0 563 #define PetscObjectDepublish(obj) 0 564 565 #endif 566 567 568 569 /* 570 This code allows one to pass a MPI communicator between 571 C and Fortran. MPI 2.0 defines a standard API for doing this. 572 The code here is provided to allow PETSc to work with MPI 1.1 573 standard MPI libraries. 574 */ 575 EXTERN int MPICCommToFortranComm(MPI_Comm,int *); 576 EXTERN int MPIFortranCommToCComm(int,MPI_Comm*); 577 578 /* 579 Simple PETSc parallel IO for ASCII printing 580 */ 581 EXTERN int PetscFixFilename(const char[],char[]); 582 EXTERN int PetscFOpen(MPI_Comm,const char[],const char[],FILE**); 583 EXTERN int PetscFClose(MPI_Comm,FILE*); 584 EXTERN int PetscFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4); 585 EXTERN int PetscPrintf(MPI_Comm,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3); 586 587 /*MC 588 PetscErrorPrintf - Prints error messages. 589 590 Not Collective 591 592 Synopsis: 593 int (*PetscErrorPrintf)(const char format[],...); 594 595 Input Parameters: 596 . format - the usual printf() format string 597 598 Options Database Keys: 599 . -error_output_stderr - cause error messages to be printed to stderr instead of the 600 (default) stdout 601 602 603 Level: developer 604 605 Fortran Note: 606 This routine is not supported in Fortran. 607 608 Concepts: error messages^printing 609 Concepts: printing^error messages 610 611 .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscHelpPrintf() 612 M*/ 613 EXTERN int (*PetscErrorPrintf)(const char[],...); 614 615 /*MC 616 PetscHelpPrintf - Prints help messages. 617 618 Not Collective 619 620 Synopsis: 621 int (*PetscHelpPrintf)(const char format[],...); 622 623 Input Parameters: 624 . format - the usual printf() format string 625 626 Level: developer 627 628 Fortran Note: 629 This routine is not supported in Fortran. 630 631 Concepts: help messages^printing 632 Concepts: printing^help messages 633 634 .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscErrorPrintf() 635 M*/ 636 EXTERN int (*PetscHelpPrintf)(MPI_Comm,const char[],...); 637 638 EXTERN int PetscPOpen(MPI_Comm,char *,char*,const char[],FILE **); 639 EXTERN int PetscPClose(MPI_Comm,FILE*); 640 EXTERN int PetscSynchronizedPrintf(MPI_Comm,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3); 641 EXTERN int PetscSynchronizedFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4); 642 EXTERN int PetscSynchronizedFlush(MPI_Comm); 643 EXTERN int PetscSynchronizedFGets(MPI_Comm,FILE*,int,char[]); 644 EXTERN int PetscStartMatlab(MPI_Comm,char *,char*,FILE**); 645 EXTERN int PetscStartJava(MPI_Comm,char *,char*,FILE**); 646 EXTERN int PetscGetPetscDir(char**); 647 648 EXTERN int PetscPopUpSelect(MPI_Comm,char*,char*,int,char**,int*); 649 /*S 650 PetscObjectContainer - Simple PETSc object that contains a pointer to any required data 651 652 Level: advanced 653 654 .seealso: PetscObject, PetscObjectContainerCreate() 655 S*/ 656 typedef struct _p_PetscObjectContainer* PetscObjectContainer; 657 EXTERN int PetscObjectContainerGetPointer(PetscObjectContainer,void **); 658 EXTERN int PetscObjectContainerSetPointer(PetscObjectContainer,void *); 659 EXTERN int PetscObjectContainerDestroy(PetscObjectContainer); 660 EXTERN int PetscObjectContainerCreate(MPI_Comm comm,PetscObjectContainer *); 661 662 /* 663 For incremental debugging 664 */ 665 extern PetscTruth PetscCompare; 666 EXTERN int PetscCompareDouble(double); 667 EXTERN int PetscCompareScalar(PetscScalar); 668 EXTERN int PetscCompareInt(int); 669 670 /* 671 For use in debuggers 672 */ 673 extern int PetscGlobalRank,PetscGlobalSize; 674 EXTERN int PetscIntView(int,int[],PetscViewer); 675 EXTERN int PetscRealView(int,PetscReal[],PetscViewer); 676 EXTERN int PetscScalarView(int,PetscScalar[],PetscViewer); 677 678 /* 679 Allows accessing Matlab Engine 680 */ 681 #include "petscengine.h" 682 683 /* 684 C code optimization is often enhanced by telling the compiler 685 that certain pointer arguments to functions are not aliased to 686 to other arguments. This is not yet ANSI C standard so we define 687 the macro "restrict" to indicate that the variable is not aliased 688 to any other argument. 689 */ 690 #if defined(PETSC_HAVE_RESTRICT) && !defined(__cplusplus) 691 #define restrict _Restrict 692 #else 693 #if defined(restrict) 694 #undef restrict 695 #endif 696 #define restrict 697 #endif 698 699 /* 700 Determine if some of the kernel computation routines use 701 Fortran (rather than C) for the numerical calculations. On some machines 702 and compilers (like complex numbers) the Fortran version of the routines 703 is faster than the C/C++ versions. The flag PETSC_USE_FORTRAN_KERNELS 704 would be set in the petscconf.h file 705 */ 706 #if defined(PETSC_USE_FORTRAN_KERNELS) 707 708 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTAIJ) 709 #define PETSC_USE_FORTRAN_KERNEL_MULTAIJ 710 #endif 711 712 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ) 713 #define PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ 714 #endif 715 716 #if !defined(PETSC_USE_FORTRAN_KERNEL_NORM) 717 #define PETSC_USE_FORTRAN_KERNEL_NORM 718 #endif 719 720 #if !defined(PETSC_USE_FORTRAN_KERNEL_MAXPY) 721 #define PETSC_USE_FORTRAN_KERNEL_MAXPY 722 #endif 723 724 #if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ) 725 #define PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ 726 #endif 727 728 #if !defined(PETSC_USE_FORTRAN_KERNEL_RELAXAIJ) 729 #define PETSC_USE_FORTRAN_KERNEL_RELAXAIJ 730 #endif 731 732 #if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ) 733 #define PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ 734 #endif 735 736 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ) 737 #define PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ 738 #endif 739 740 #if !defined(PETSC_USE_FORTRAN_KERNEL_MDOT) 741 #define PETSC_USE_FORTRAN_KERNEL_MDOT 742 #endif 743 744 #if !defined(PETSC_USE_FORTRAN_KERNEL_XTIMESY) 745 #define PETSC_USE_FORTRAN_KERNEL_XTIMESY 746 #endif 747 748 #if !defined(PETSC_USE_FORTRAN_KERNEL_AYPX) 749 #define PETSC_USE_FORTRAN_KERNEL_AYPX 750 #endif 751 752 #if !defined(PETSC_USE_FORTRAN_KERNEL_WAXPY) 753 #define PETSC_USE_FORTRAN_KERNEL_WAXPY 754 #endif 755 756 #endif 757 758 /* 759 Macros for indicating code that should be compiled with a C interface, 760 rather than a C++ interface. Any routines that are dynamically loaded 761 (such as the PCCreate_XXX() routines) must be wrapped so that the name 762 mangler does not change the functions symbol name. This just hides the 763 ugly extern "C" {} wrappers. 764 */ 765 #if defined(__cplusplus) 766 #define EXTERN_C_BEGIN extern "C" { 767 #define EXTERN_C_END } 768 #else 769 #define EXTERN_C_BEGIN 770 #define EXTERN_C_END 771 #endif 772 773 /* --------------------------------------------------------------------*/ 774 775 /*M 776 size - integer variable used to contain the number of processors in 777 the relevent MPI_Comm 778 779 Level: beginner 780 781 .seealso: rank, comm 782 M*/ 783 784 /*M 785 rank - integer variable used to contain the number of this processor relative 786 to all in the relevent MPI_Comm 787 788 Level: beginner 789 790 .seealso: size, comm 791 M*/ 792 793 /*M 794 comm - MPI_Comm used in the current routine or object 795 796 Level: beginner 797 798 .seealso: size, rank 799 M*/ 800 801 /*M 802 MPI_Comm - the basic object used by MPI to determine which processes are involved in a 803 communication 804 805 Level: beginner 806 807 Note: This manual page is a place-holder because MPICH does not have a manual page for MPI_Comm 808 809 .seealso: size, rank, comm, PETSC_COMM_WORLD, PETSC_COMM_SELF 810 M*/ 811 812 /*M 813 PetscScalar - PETSc type that represents either a double precision real number or 814 a double precision complex number if the code is compiled with BOPT=g_complex or O_complex 815 816 Level: beginner 817 818 .seealso: PetscReal, PassiveReal, PassiveScalar 819 M*/ 820 821 /*M 822 PetscReal - PETSc type that represents a double precision real number 823 824 Level: beginner 825 826 .seealso: PetscScalar, PassiveReal, PassiveScalar 827 M*/ 828 829 /*M 830 PassiveScalar - PETSc type that represents either a double precision real number or 831 a double precision complex number if the code is compiled with BOPT=g_complex or O_complex 832 833 Level: beginner 834 835 This is the same as a PetscScalar except in code that is automatically differentiated it is 836 treated as a constant (not an indendent or dependent variable) 837 838 .seealso: PetscReal, PassiveReal, PetscScalar 839 M*/ 840 841 /*M 842 PassiveReal - PETSc type that represents a double precision real number 843 844 Level: beginner 845 846 This is the same as a PetscReal except in code that is automatically differentiated it is 847 treated as a constant (not an indendent or dependent variable) 848 849 .seealso: PetscScalar, PetscReal, PassiveScalar 850 M*/ 851 852 /* 853 The IBM include files define hz, here we hide it so that it may be used 854 as a regular user variable. 855 */ 856 #if defined(hz) 857 #undef hz 858 #endif 859 860 /* For arrays that contain filenames or paths */ 861 862 #if defined(PETSC_HAVE_LIMITS_H) 863 #include <limits.h> 864 #endif 865 #if defined(PETSC_HAVE_SYS_PARAM_H) 866 #include <sys/param.h> 867 #endif 868 869 #if defined(MAXPATHLEN) 870 # define PETSC_MAX_PATH_LEN MAXPATHLEN 871 #elif defined(MAX_PATH) 872 # define PETSC_MAX_PATH_LEN MAX_PATH 873 #elif defined(_MAX_PATH) 874 # define PETSC_MAX_PATH_LEN _MAX_PATH 875 #else 876 # define PETSC_MAX_PATH_LEN 4096 877 #endif 878 879 #endif 880 881 882