Actual source code: ex17f.F90

petsc-master 2021-02-25
Report Typos and Errors
  1: ! Demonstrates PetscGetVersionNumber(): Fortran Example


  4: program main
  5: #include <petsc/finclude/petscsys.h>
  6:       use petscsys

  8:       implicit none
  9:       PetscErrorCode                    :: ierr
 10:       PetscInt                          :: major,minor,subminor
 11:       character(len=PETSC_MAX_PATH_LEN) :: outputString

 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

 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

 39:       call PetscFinalize(ierr)


 42: end program main

 44: !/*TEST
 45: !
 46: !   test:
 47: !
 48: !TEST*/