Date: 2026-06-01T23:13:45+00:00

Actual source code: ex17f.F90

      1: ! Demonstrates PetscGetVersionNumber(): Fortran Example
      2: #include <petsc/finclude/petscsys.h>
      3: program main
      4:   use petscsys

      6:   implicit none
      7:   PetscErrorCode                    :: ierr
      8:   PetscInt                          :: major, minor, subminor, release
      9:   character(len=PETSC_MAX_PATH_LEN) :: outputString

     11:   ! Every PETSc routine should begin with the PetscInitialize() routine.

     13:   PetscCallA(PetscInitialize(ierr))
     14:   PetscCallA(PetscGetVersionNumber(major, minor, subminor, release, ierr))

     16:   if (major /= PETSC_VERSION_MAJOR) then
     17:     write (outputString, *) 'Library major', major, 'does not equal include', PETSC_VERSION_MAJOR
     18:     SETERRA(PETSC_COMM_SELF, PETSC_ERR_PLIB, trim(outputString))
     19:   end if

     21:   if (minor /= PETSC_VERSION_MINOR) then
     22:     write (outputString, *) 'Library minor', minor, 'does not equal include', PETSC_VERSION_MINOR
     23:     SETERRA(PETSC_COMM_SELF, PETSC_ERR_PLIB, trim(outputString))
     24:   end if

     26:   if (subminor /= PETSC_VERSION_SUBMINOR) then
     27:     write (outputString, *) 'Library subminor', subminor, 'does not equal include', PETSC_VERSION_SUBMINOR
     28:     SETERRA(PETSC_COMM_SELF, PETSC_ERR_PLIB, trim(outputString))
     29:   end if

     31:   PetscCallA(PetscFinalize(ierr))
     32: end program main

     34: !/*TEST
     35: !
     36: !   test:
     37: !     output_file: output/empty.out
     38: !
     39: !TEST*/