mod_profiling.f90 Source File


This file depends on

sourcefile~~mod_profiling.f90~~EfferentGraph sourcefile~mod_profiling.f90 mod_profiling.f90 sourcefile~mod_constants.f90 mod_constants.f90 sourcefile~mod_profiling.f90->sourcefile~mod_constants.f90 sourcefile~mod_io.f90 mod_io.f90 sourcefile~mod_profiling.f90->sourcefile~mod_io.f90 sourcefile~mod_memory.f90 mod_memory.f90 sourcefile~mod_profiling.f90->sourcefile~mod_memory.f90 sourcefile~mod_io.f90->sourcefile~mod_constants.f90 sourcefile~mod_memory.f90->sourcefile~mod_constants.f90 sourcefile~mod_memory.f90->sourcefile~mod_io.f90

Files dependent on this one

sourcefile~~mod_profiling.f90~~AfferentGraph sourcefile~mod_profiling.f90 mod_profiling.f90 sourcefile~mod_electrostatics.f90 mod_electrostatics.f90 sourcefile~mod_electrostatics.f90->sourcefile~mod_profiling.f90 sourcefile~mod_nonbonded.f90 mod_nonbonded.f90 sourcefile~mod_nonbonded.f90->sourcefile~mod_profiling.f90 sourcefile~mod_neighbors_list.f90 mod_neighbors_list.f90 sourcefile~mod_nonbonded.f90->sourcefile~mod_neighbors_list.f90 sourcefile~mod_neighbors_list.f90->sourcefile~mod_profiling.f90 sourcefile~mod_interface.f90 mod_interface.f90 sourcefile~mod_interface.f90->sourcefile~mod_profiling.f90 sourcefile~mod_interface.f90->sourcefile~mod_electrostatics.f90 sourcefile~mod_interface.f90->sourcefile~mod_nonbonded.f90 sourcefile~mod_mmpol.f90 mod_mmpol.f90 sourcefile~mod_interface.f90->sourcefile~mod_mmpol.f90 sourcefile~mod_polarization.f90 mod_polarization.f90 sourcefile~mod_interface.f90->sourcefile~mod_polarization.f90 sourcefile~mod_inputloader.f90 mod_inputloader.f90 sourcefile~mod_interface.f90->sourcefile~mod_inputloader.f90 sourcefile~mod_prm.f90 mod_prm.f90 sourcefile~mod_interface.f90->sourcefile~mod_prm.f90 sourcefile~mod_link_atom.f90 mod_link_atom.f90 sourcefile~mod_interface.f90->sourcefile~mod_link_atom.f90 sourcefile~mod_qm_helper.f90 mod_qm_helper.f90 sourcefile~mod_interface.f90->sourcefile~mod_qm_helper.f90 sourcefile~mod_geomgrad.f90 mod_geomgrad.f90 sourcefile~mod_interface.f90->sourcefile~mod_geomgrad.f90 sourcefile~mod_mmpol.f90->sourcefile~mod_profiling.f90 sourcefile~mod_mmpol.f90->sourcefile~mod_electrostatics.f90 sourcefile~mod_mmpol.f90->sourcefile~mod_nonbonded.f90 sourcefile~mod_mmpol.f90->sourcefile~mod_link_atom.f90 sourcefile~mod_polarization.f90->sourcefile~mod_profiling.f90 sourcefile~mod_polarization.f90->sourcefile~mod_electrostatics.f90 sourcefile~mod_polarization.f90->sourcefile~mod_mmpol.f90 sourcefile~mod_solvers.f90 mod_solvers.f90 sourcefile~mod_polarization.f90->sourcefile~mod_solvers.f90 sourcefile~mod_inputloader.f90->sourcefile~mod_profiling.f90 sourcefile~mod_inputloader.f90->sourcefile~mod_electrostatics.f90 sourcefile~mod_inputloader.f90->sourcefile~mod_mmpol.f90 sourcefile~mod_inputloader.f90->sourcefile~mod_prm.f90 sourcefile~mod_c_interface.f90 mod_c_interface.f90 sourcefile~mod_c_interface.f90->sourcefile~mod_electrostatics.f90 sourcefile~mod_c_interface.f90->sourcefile~mod_interface.f90 sourcefile~mod_c_interface.f90->sourcefile~mod_mmpol.f90 sourcefile~mod_c_interface.f90->sourcefile~mod_qm_helper.f90 sourcefile~mod_solvers.f90->sourcefile~mod_electrostatics.f90 sourcefile~mod_prm.f90->sourcefile~mod_electrostatics.f90 sourcefile~mod_prm.f90->sourcefile~mod_nonbonded.f90 sourcefile~rotate_multipoles.f90 rotate_multipoles.f90 sourcefile~rotate_multipoles.f90->sourcefile~mod_electrostatics.f90 sourcefile~mod_link_atom.f90->sourcefile~mod_electrostatics.f90 sourcefile~mod_link_atom.f90->sourcefile~mod_nonbonded.f90 sourcefile~mod_link_atom.f90->sourcefile~mod_prm.f90 sourcefile~mod_qm_helper.f90->sourcefile~mod_electrostatics.f90 sourcefile~mod_qm_helper.f90->sourcefile~mod_nonbonded.f90 sourcefile~mod_qm_helper.f90->sourcefile~mod_mmpol.f90 sourcefile~mod_qm_helper.f90->sourcefile~mod_prm.f90 sourcefile~mod_qm_helper.f90->sourcefile~mod_link_atom.f90 sourcefile~mod_geomgrad.f90->sourcefile~mod_electrostatics.f90 sourcefile~mod_geomgrad.f90->sourcefile~mod_mmpol.f90 sourcefile~mod_geomgrad.f90->sourcefile~mod_polarization.f90 sourcefile~test_si_geomgrad_num.f90 test_SI_geomgrad_num.f90 sourcefile~test_si_geomgrad_num.f90->sourcefile~mod_interface.f90 sourcefile~test_si_geomgrad_num.f90->sourcefile~mod_mmpol.f90 sourcefile~test_si_init.f90 test_SI_init.f90 sourcefile~test_si_init.f90->sourcefile~mod_interface.f90 sourcefile~test_si_geomgrad.f90 test_SI_geomgrad.f90 sourcefile~test_si_geomgrad.f90->sourcefile~mod_interface.f90 sourcefile~test_si_geomgrad.f90->sourcefile~test_si_geomgrad_num.f90 sourcefile~test_si_potential.f90 test_SI_potential.f90 sourcefile~test_si_potential.f90->sourcefile~mod_interface.f90

Contents

Source Code


Source Code

#include "version.h"
#define OMMP_TIMING

module mod_profiling
    !! Unified Input/Output handling across the code.
    
    use mod_constants, only: OMMP_VERBOSE_DEBUG, &
                             OMMP_VERBOSE_HIGH, &
                             OMMP_VERBOSE_LOW, &
                             OMMP_VERBOSE_NONE, &
                             OMMP_VERBOSE_DEFAULT, &
                             OMMP_STR_CHAR_MAX, &
                             ip, rp
    use mod_io, only: fatal_error, ommp_message
    use mod_memory, only: mem_stat

    implicit none
    private

#ifdef OMMP_TIMING
    integer(ip), parameter :: ntimes = 128
    integer(ip) :: tcnt = 1
    real(rp) :: times(ntimes)
    real(rp) :: maxmem(ntimes)
#endif

    public :: time_pull, time_push

    contains
    
    subroutine time_push()
        implicit none
#ifdef OMMP_TIMING
        real(rp) :: omp_get_wtime
        
        if(tcnt <= ntimes) then
            times(tcnt) = omp_get_wtime()
            ! Reset the memory counter, and save current value.
            maxmem(tcnt) = mem_stat()
            tcnt = tcnt + 1
        else
            call fatal_error('time_push Cannot push another time in the buffer.')
        end if
#endif
    end subroutine

    subroutine time_pull(s)
        implicit none

        character(len=*), intent(in) :: s
#ifdef OMMP_TIMING
        real(rp) :: elap, mm
        character(len=OMMP_STR_CHAR_MAX) :: msg

        real(rp) :: omp_get_wtime

        if(tcnt > 1) then
            elap = omp_get_wtime() - times(tcnt-1)
            !! Get maximum memory usage since last time push in
            !! GB, also make it ready for the next push/pull
            mm = mem_stat(maxmem(tcnt-1))
            tcnt = tcnt - 1
            write(msg, "(3a, ': ', e14.6E2, ' s')") repeat('-', tcnt), '> ', s, elap
            call ommp_message(msg, OMMP_VERBOSE_HIGH, 'time')
            write(msg, "(3a, ': ', e14.6E2, ' GB')") repeat('-', tcnt), '> ', s, mm
            call ommp_message(msg, OMMP_VERBOSE_HIGH, 'memory')
        else
            call fatal_error('time_pull Cannot pull any value.')
        end if
#endif
    end subroutine

end module mod_profiling