# PetscFinalize

Checks for options to be called at the conclusion of the program. MPI_Finalize() is called only if the user had not called MPI_Init() before calling PetscInitialize().

### Synopsis

    #include "petsc.h"
    PetscErrorCode PETSC_DLLEXPORT PetscFinalize(void)

Collective on PETSC_COMM_WORLD

### Options Database Keys

| -options_table | - Calls PetscOptionsPrint()
| -options_left | - Prints unused options that remain in the database
| -options_left no | - Does not print unused options that remain in the database
| -mpidump | - Calls PetscMPIDump()
| -malloc_dump | - Calls PetscMallocDump()
| -malloc_info | - Prints total memory usage
| -malloc_log | - Prints summary of memory usage

### Options Database Keys for Profiling

See the Profiling chapter of the users manual for details.

| -log_summary [filename] | - Prints summary of flop and timing information to screen. If the filename is specified the summary is written to the file. (for code compiled with PETSC_USE_LOG). See PetscLogPrintSummary().
| -log_all [filename] | - Logs extensive profiling information (for code compiled with PETSC_USE_LOG). See PetscLogDump().
| -log [filename] | - Logs basic profiline information (for code compiled with PETSC_USE_LOG). See PetscLogDump().
| -log_sync | - Log the synchronization in scatters, inner products and norms
| -log_mpe [filename] | - Creates a logfile viewable by the utility Upshot/Nupshot (in MPICH distribution)

### Note

See PetscInitialize() for more general runtime options.

### See Also

PetscInitialize(), PetscOptionsPrint(), PetscMallocDump(), PetscMPIDump(), PetscEnd()

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/viewer/examples/tutorials/ex1f90.F90.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/ex5.c.html
src/sys/examples/tutorials/ex3f.F.html
src/sys/examples/tutorials/ex5f90.F90.html
src/vec/vec/examples/tutorials/ex1.c.html
src/vec/vec/examples/tutorials/ex1e.c.html
src/vec/vec/examples/tutorials/ex2.c.html
src/vec/vec/examples/tutorials/ex3.c.html