PrintMemory Subroutine

public subroutine PrintMemory(PrintDeallocated, iunit)

Arguments

Type IntentOptional Attributes Name
logical, intent(in), optional :: PrintDeallocated
integer, intent(in), optional :: iunit

Contents

Source Code


Source Code

    subroutine PrintMemory(PrintDeallocated, iunit)
        ! Print out the memory log.  If using the cache memory log, then it will
        ! only print out the elements stored, *not* any which have been
        ! over-written.  By default, only the active allocations are printed out to
        ! STOUT.
        !
        ! INPUT:
        !      PrintDeallocated (optional, default=.false.) - print out objects which
        !                       have been deallocated (but are still present in the cache).
        !      iunit (optional, default=6) - unit to output to.

        logical, intent(in), optional :: PrintDeallocated
        integer, intent(in), optional :: iunit

        logical :: pd
        integer :: io, iobj
        character(len=*), parameter :: fmt1 = '(3a19)'

        if (present(PrintDeallocated)) then
            pd = PrintDeallocated
        else
            pd = .false.
        end if

        if (present(iunit)) then
            io = iunit
        else
            io = 6
        end if

        call WriteMemLogHeader(io)
        do iobj = 1, min(ipos, MaxLen)
            if (pd .or. MemLog(iobj)%DeallocRoutine == 'not deallocated') then
                write (io, fmt1, advance='no') ' '//MemLog(iobj)%ObjectName, MemLog(iobj)%AllocRoutine, MemLog(iobj)%DeallocRoutine
                call WriteMemSize(io, MemLog(iobj)%ObjectSize)
            end if
        enddo
        if (ipos > MaxLen) then
            write (io, *) '== NOTE: Length of logging arrays exceeded. Length needed is ', ipos
        endif
        write (io, *) '================================================================'
    end subroutine PrintMemory