Actual source code: ex3f.F

  1: !
  2: !
  3: !   Description: Demonstrates how users can augment the PETSc profiling by
  4: !                nserting their own event logging.
  5: !
  6: !/*T
  7: !   Concepts: PetscLog^user-defined event profiling (basic example);
  8: !   Concepts: PetscLog^activating/deactivating events for profiling (basic example);
  9: !   Processors: n
 10: !T*/
 11: ! -----------------------------------------------------------------------

 13:       program main
 14:       implicit none

 16: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 17: !                    Include files
 18: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 19: !
 20: !  The following include statements are required for using PetscLog Routines
 21: !
 22:  #include include/finclude/petsc.h
 23:  #include include/finclude/petsclog.h
 24: !
 25: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 26: !                   Variable declarations
 27: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 28: !
 29:       PetscEvent USER_EVENT1,USER_EVENT2,USER_EVENT3,USER_EVENT4
 30:       PetscEvent USER_EVENT8,USER_EVENT9
 31:       PetscEvent USER_EVENT5,USER_EVENT6,USER_EVENT7
 32:       integer imax
 33:       PetscErrorCode ierr
 34:       parameter (imax = 10000)
 35: !
 36: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 37: !                 Beginning of program
 38: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 40:       call PetscInitialize(PETSC_NULL_CHARACTER,ierr)

 42: !
 43: !     Create a new user-defined event.
 45: !        integer event number, which should then be used for profiling
 47: !      - The user can also optionally log floating point operations
 48: !        with the routine PetscLogFlops().
 49: !
 60:       call PetscLogFlops(imax,ierr)
 61:       call PetscSleep(1,ierr)
 64:       call PetscLogFlops(imax,ierr)
 65:       call PetscSleep(1,ierr)
 68:       call PetscLogFlops(imax,ierr)
 69:       call PetscSleep(1,ierr)
 72:       call PetscLogFlops(imax,ierr)
 73:       call PetscSleep(1,ierr)
 76:       call PetscLogFlops(imax,ierr)
 77:       call PetscSleep(1,ierr)
 80:       call PetscLogFlops(imax,ierr)
 81:       call PetscSleep(1,ierr)
 84:       call PetscLogFlops(imax,ierr)
 85:       call PetscSleep(1,ierr)
 88:       call PetscLogFlops(imax,ierr)
 89:       call PetscSleep(1,ierr)
 92:       call PetscLogFlops(imax,ierr)
 93:       call PetscSleep(1,ierr)
 95: !
 96: !    We disable the logging of an event.
 97: !      - Note that the user can activate/deactive both user-defined
 98: !        events and predefined PETSc events.
 99: !
102:       call PetscSleep(1,ierr)
104: !
105: !    We next enable the logging of an event
106: !
109:       call PetscSleep(1,ierr)

112:       call PetscFinalize(ierr)

114:       end