petsc-3.7.1 2016-05-15
Report Typos and Errors

PetscInitialize

Initializes the PETSc database and MPI. PetscInitialize() calls MPI_Init() if that has yet to be called, so this routine should always be called near the beginning of your program -- usually the very first line!

Synopsis

#include "petscsys.h"   
PetscErrorCode  PetscInitialize(int *argc,char ***args,const char file[],const char help[])
Collective on MPI_COMM_WORLD or PETSC_COMM_WORLD if it has been set Many br

Input Parameters

argc - count of number of command line arguments Many br
args - the command line arguments Many br
file - [optional] PETSc database file, also checks ~username/.petscrc and .petscrc use NULL to not check for Many brcode specific file. Use -skip_petscrc in the code specific file to skip the .petscrc files Many br
help - [optional] Help message to print, use NULL for no message Many br

If you wish PETSc code to run ONLY on a subcommunicator of MPI_COMM_WORLD, create that Many brcommunicator first and assign it to PETSC_COMM_WORLD BEFORE calling PetscInitialize(). Thus if you are running a Many brfour process job and two processes will run PETSc and have PetscInitialize() and PetscFinalize() and two process will not, Many brthen do this. If ALL processes in the job are using PetscInitialize() and PetscFinalize() then you don't need to do this, even Many brif different subcommunicators of the job are doing different things with PETSc. Many br

Options Database Keys

-start_in_debugger [noxterm,dbx,xdb,gdb,...] - Starts program in debugger Many br
-on_error_attach_debugger [noxterm,dbx,xdb,gdb,...] - Starts debugger when error detected Many br
-on_error_emacs <machinename> causes emacsclient to jump to error file- . -on_error_abort calls abort() when error detected (no traceback) Many br
-on_error_mpiabort calls MPI_abort() when error detected- . -error_output_stderr prints error messages to stderr instead of the default stdout Many br
-error_output_none does not print the error messages (but handles errors in the same way as if this was not called)- . -debugger_nodes [node1,node2,...] - Indicates nodes to start in debugger Many br
-debugger_pause [sleeptime] (in seconds) - Pauses debugger Many br
-stop_for_debugger - Print message on how to attach debugger manually to Many brprocess and wait (-debugger_pause) seconds for attachment Many br
-malloc - Indicates use of PETSc error-checking malloc (on by default for debug version of libraries) Many br
-malloc no - Indicates not to use error-checking malloc Many br
-malloc_debug - check for memory corruption at EVERY malloc or free Many br
-malloc_dump - prints a list of all unfreed memory at the end of the run Many br
-malloc_test - like -malloc_dump -malloc_debug, but only active for debugging builds Many br
-fp_trap - Stops on floating point exceptions (Note that on the Many brIBM RS6000 this slows code by at least a factor of 10.) Many br
-no_signal_handler - Indicates not to trap error signals Many br
-shared_tmp - indicates /tmp directory is shared by all processors Many br
-not_shared_tmp - each processor has own /tmp Many br
-tmp - alternative name of /tmp directory Many br
-get_total_flops - returns total flops done by all processors Many br
-memory_view - Print memory usage at end of run Many br

Options Database Keys for Profiling

See Users-Manual: Chapter 13 Profiling for details. Many br
-info <optional filename> - Prints verbose information to the screen Many br
-info_exclude <null,vec,mat,pc,ksp,snes,ts> - Excludes some of the verbose messages Many br
-log_sync - Log the synchronization in scatters, inner products and norms Many br
-log_trace [filename] - Print traces of all PETSc calls to the screen (useful to determine where a program Many brhangs without running in the debugger). See PetscLogTraceBegin(). Many br
-log_view [:filename:format] - Prints summary of flop and timing information to screen or file, see PetscLogView(). Many br
-log_summary [filename] - (Deprecated, use -log_view) Prints summary of flop and timing information to screen. If the filename is specified the Many brsummary is written to the file. See PetscLogView(). Many br
-log_exclude: <vec,mat,pc.ksp,snes> - excludes subset of object classes from logging Many br
-log_all [filename] - Logs extensive profiling information See PetscLogDump(). Many br
-log [filename] - Logs basic profiline information See PetscLogDump(). Many br
-log_mpe [filename] - Creates a logfile viewable by the utility Jumpshot (in MPICH distribution) Many br

Only one of -log_trace, -log_view, -log_summary, -log_all, -log, or -log_mpe may be used at a time Many br

Options Database Keys for SAWs

-saws_port <portnumber> - port number to publish SAWs data, default is 8080 Many br
-saws_port_auto_select - have SAWs select a new unique port number where it publishes the data, the URL is printed to the screen Many brthis is useful when you are running many jobs that utilize SAWs at the same time Many br
-saws_log <filename> - save a log of all SAWs communication Many br
-saws_https <certificate file> - have SAWs use HTTPS instead of HTTP Many br
-saws_root <directory> - allow SAWs to have access to the given directory to search for requested resources and files Many br

Environmental Variables

PETSC_TMP - alternative tmp directory Many br
PETSC_SHARED_TMP - tmp is shared by all processes Many br
PETSC_NOT_SHARED_TMP - each process has its own private tmp Many br
PETSC_VIEWER_SOCKET_PORT - socket number to use for socket viewer Many br
PETSC_VIEWER_SOCKET_MACHINE - machine to use for socket viewer to connect to Many br

Many br

Notes

If for some reason you must call MPI_Init() separately, call Many brit before PetscInitialize(). Many br

Fortran Version

In Fortran this routine has the format Many br
      call PetscInitialize(file,ierr)

ierr - error return code Many br
file - [optional] PETSc database file, also checks ~username/.petscrc and .petscrc use PETSC_NULL_CHARACTER to not check for Many brcode specific file. Use -skip_petscrc in the code specific file to skip the .petscrc files Many br

Important Fortran Note

In Fortran, you MUST use PETSC_NULL_CHARACTER to indicate a Many brnull character string; you CANNOT just use NULL as Many brin the C version. See Users-Manual: Chapter 12 PETSc for Fortran Users for details. Many br

If your main program is C but you call Fortran code that also uses PETSc you need to call PetscInitializeFortran() soon after Many brcalling PetscInitialize(). Many br

See Also

PetscFinalize(), PetscInitializeFortran(), PetscGetArgs(), PetscInitializeNoArguments()

Level:beginner
Location:
src/sys/objects/pinit.c
Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/sys/classes/viewer/examples/tutorials/ex1.c.html
src/sys/classes/viewer/examples/tutorials/ex2.c.html
src/sys/classes/viewer/examples/tutorials/ex1f90.F90.html
src/sys/classes/random/examples/tutorials/ex1.c.html
src/sys/classes/random/examples/tutorials/ex2.c.html
src/sys/examples/tutorials/ex1.c.html
src/sys/examples/tutorials/ex2.c.html
src/sys/examples/tutorials/ex3.c.html
src/sys/examples/tutorials/ex4.c.html
src/sys/examples/tutorials/ex5.c.html
src/sys/examples/tutorials/ex6.c.html