tem_print_array Subroutine

public subroutine tem_print_array(me, nVals, itemLength, title, outUnit)

print an array to the debugunit

Arguments

Type IntentOptional Attributes Name
integer(kind=long_k), intent(in) :: me(:)

long array to write to debug file

integer, intent(in) :: nVals

number of values in array me

integer, optional :: itemLength

how many characters needs each item of the array to output

character(len=*), optional :: title

Array title in debug output for easy identification in the file

integer, intent(in) :: outUnit

output unit


Contents

Source Code


Source Code

  subroutine tem_print_array( me, nVals, itemLength, title, outUnit )
    ! ---------------------------------------------------------------------------
    !> Array title in debug output for easy identification in the file
    character( len=* ),optional :: title
    !> number of values in array me
    integer, intent(in) :: nVals
    !> long array to write to debug file
    integer(kind=long_k), intent(in) :: me(:)
    !> how many characters needs each item of the array to output
    integer,optional :: itemLength
    !> output unit
    integer, intent(in) :: outUnit
    ! ---------------------------------------------------------------------------
    integer :: iVal, iLine, nLines
    integer :: itemLength_loc
    character( len=buffer_length ) :: buffer
    ! ---------------------------------------------------------------------------

    if( present(itemlength)) then
      itemlength_loc = itemlength
    else
      itemlength_loc = 8
    endif

    write(outUnit,*) ''
    write(outUnit,*) '------------------------------------------------'

    if( present(title)) then
      write(outUnit,"(A,I0)") '   '//trim(title)//', nVals: ', nVals
      write(outUnit,*) ''
    endif

    buffer = ''

    nLines = nVals / itemLength_loc + 1

    do iLine = 1, nLines - 1
      buffer = ''
      do iVal = 1, itemLength_loc
        call append_to_buffer( buffer, me(iVal) )
      end do
      write(outUnit,*) trim(buffer)
    end do

    buffer = ''
    do iVal = 1, mod( nVals, itemLength_loc )
      call append_to_buffer( buffer, me(iVal) )
    end do
    write(outUnit,*) trim(buffer)

    write(outUnit,*) '------------------------------------------------'
    write(outUnit,*) ''

    ! do iVal = 1, nVals
    !   buffer = trim(buffer)//'  '//tem_toStr( me(iVal), logger )
    !   if( iVal == nVals .or. mod( iElem, itemLength_loc ) == 0) then
    !     write(outUnit,*) trim(buffer)
    !     buffer = ''
    !   endif
    ! enddo

    contains

      subroutine append_to_buffer(buffer, val )
        character( len=buffer_length ), intent(inout) :: buffer
        integer(kind=long_k), intent(in) :: val
        character(len=SolSpecLen) :: str

        str = tem_toStr( val, main_debug%logger )
        if ( (2 + len_trim(buffer) + len_trim(str)) > buffer_length) then
          write(logunit(1),*) "Can't append value to output in tem_print_array."
          write(logunit(1),*) "  Internal buffer too short."
        else
          buffer = trim(buffer) // '  ' // str
        endif

      end subroutine append_to_buffer

  end subroutine tem_print_array