print_self_status Subroutine

public subroutine print_self_status(unit, info, text)

This subroutine reads out the status of the process if it is available in /proc/self/status, which is provided by the Linux operating system.

Arguments

Type IntentOptional Attributes Name
integer, intent(in), optional :: unit

A preconnected unit, to write the content of /proc/self/status to.

character(len=*), intent(in), optional :: info

optional filename prefix

character(len=*), intent(in), optional :: text

optional header text to be dumped to file


Calls

proc~~print_self_status~~CallsGraph proc~print_self_status print_self_status proc~newunit newunit proc~print_self_status->proc~newunit

Called by

proc~~print_self_status~~CalledByGraph proc~print_self_status print_self_status proc~my_status_string my_status_string proc~my_status_string->proc~print_self_status proc~my_status_string_vec my_status_string_vec proc~my_status_string_vec->proc~print_self_status proc~tem_finalize tem_finalize proc~tem_finalize->proc~print_self_status proc~my_status_int my_status_int proc~my_status_int->proc~my_status_string proc~my_status_int_vec my_status_int_vec proc~my_status_int_vec->proc~my_status_string_vec proc~tem_reportstatus tem_reportStatus proc~tem_reportstatus->proc~my_status_string proc~tem_global_vmhwm tem_global_vmhwm proc~tem_global_vmhwm->proc~my_status_int proc~tem_trackmem tem_trackmem proc~tem_trackmem->proc~my_status_int proc~tem_trackmem->proc~my_status_int_vec

Source Code

  subroutine print_self_status(unit, info, text)
    ! ---------------------------------------------------------------------------
    !> A preconnected unit, to write the content
    !! of /proc/self/status to.
    integer, optional, intent(in) :: unit
    !> optional filename prefix
    character(len=*), optional, intent(in) :: info
    !> optional header text to be dumped to file
    character(len=*), optional, intent(in) :: text
    ! ---------------------------------------------------------------------------
    character(len=128) :: cInfo
    character(len=128) :: line
    integer :: stat
    integer :: inUnit
    integer :: outUnit
    ! ---------------------------------------------------------------------------
    if( present( info )) then
      cInfo = info
    else
      cInfo = '/proc/self/status'
    end if
    if( present( unit )) then
      outUnit = unit
    else
      outUnit = output_unit
    end if
    inUnit = newUnit()
    open( file   = trim(cInfo), &
      &   action = 'read',      &
      &   iostat = stat,        &
      &   unit   = inUnit       )

    if( present( text )) then
      write(outUnit, '(a)')                                                    &
        &  '-------------------------------------------------------'
      write(outUnit, '(2a)') '        ', trim(text)
    end if
    if (stat==0) then
      read(inUnit, '(a)', iostat=stat) line
      do while (stat==0)
        if (present(unit)) then
          write(unit,'(a)') trim(line)
        else
          write(*,'(a)') trim(line)
        end if
        read(inUnit, '(a)', iostat=stat) line
      end do

      close(inUnit)
    else
      write(outUnit,*) '/proc/self/'//trim(cInfo)//' not available'
    end if
    if( present( text )) then
      write(outUnit, '(a)')                                                    &
        &  '-------------------------------------------------------'
    end if

  end subroutine print_self_status