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
 30:       PetscEvent USER_EVENT3,USER_EVENT4
 31:       PetscEvent USER_EVENT5,USER_EVENT6
 32:       PetscEvent USER_EVENT7,USER_EVENT8
 33:       PetscEvent USER_EVENT9
 34:       integer imax
 35:       PetscErrorCode ierr
 36:       parameter (imax = 10000)
 37: !
 38: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 39: !                 Beginning of program
 40: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 42:       call PetscInitialize(PETSC_NULL_CHARACTER,ierr)

 44: !
 45: !     Create a new user-defined event.
 47: !        integer event number, which should then be used for profiling
 49: !      - The user can also optionally log floating point operations
 50: !        with the routine PetscLogFlops().
 51: !
 62:       call PetscLogFlops(imax,ierr)
 63:       call PetscSleep(1,ierr)
 66:       call PetscLogFlops(imax,ierr)
 67:       call PetscSleep(1,ierr)
 70:       call PetscLogFlops(imax,ierr)
 71:       call PetscSleep(1,ierr)
 74:       call PetscLogFlops(imax,ierr)
 75:       call PetscSleep(1,ierr)
 78:       call PetscLogFlops(imax,ierr)
 79:       call PetscSleep(1,ierr)
 82:       call PetscLogFlops(imax,ierr)
 83:       call PetscSleep(1,ierr)
 86:       call PetscLogFlops(imax,ierr)
 87:       call PetscSleep(1,ierr)
 90:       call PetscLogFlops(imax,ierr)
 91:       call PetscSleep(1,ierr)
 94:       call PetscLogFlops(imax,ierr)
 95:       call PetscSleep(1,ierr)
 97: !
 98: !    We disable the logging of an event.
 99: !      - Note that the user can activate/deactive both user-defined
100: !        events and predefined PETSc events.
101: !
104:       call PetscSleep(1,ierr)
106: !
107: !    We next enable the logging of an event
108: !
111:       call PetscSleep(1,ierr)

114:       call PetscFinalize(ierr)

116:       end