Actual source code: ex17f.F90

petsc-3.11.4 2019-09-28
Report Typos and Errors
  1: ! Demonstrates PetscGetVersionNumber(): Fortran Example


  4: program main
  5:  #include <petsc/finclude/petscsys.h>
  6:       use petscsys
  7: 
  8:       implicit none
  9:       PetscErrorCode     :: ierr
 10:       PetscInt           :: major,minor,subminor
 11:       character(len=256) :: outputString
 12: 
 13:       ! Every PETSc routine should begin with the PetscInitialize() routine.

 15:       call PetscInitialize(PETSC_NULL_CHARACTER,ierr)
 16:       if (ierr /= 0) then
 17:         write(6,*)'Unable to initialize PETSc'
 18:         stop
 19:       endif
 20: 
 21:       call PetscGetVersionNumber(major,minor,subminor,PETSC_NULL_INTEGER,ierr)
 22:       CHKERRA(ierr)

 24:       if (major /= PETSC_VERSION_MAJOR) then
 25:         write(outputString,*)'Library major',major,'does not equal include',PETSC_VERSION_MAJOR
 26:         SETERRA(PETSC_COMM_SELF,PETSC_ERR_PLIB,trim(outputString))
 27:       endif

 29:       if (minor /= PETSC_VERSION_MINOR) then
 30:         write(outputString,*)'Library minor',minor,'does not equal include',PETSC_VERSION_MINOR
 31:         SETERRA(PETSC_COMM_SELF,PETSC_ERR_PLIB,trim(outputString))
 32:       endif

 34:       if (subminor /= PETSC_VERSION_SUBMINOR) then
 35:         write(outputString,*)'Library subminor',subminor,'does not equal include',PETSC_VERSION_SUBMINOR
 36:         SETERRA(PETSC_COMM_SELF,PETSC_ERR_PLIB,trim(outputString))
 37:       endif
 38: 
 39:       call PetscFinalize(ierr)
 40: 

 42: end program main