print an array to the debugunit
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=long_k), | intent(in) | :: | me(:) |
long array to write to debug file |
||
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, | optional | :: | lineLength |
how long should the line be |
||
integer | :: | nUnit |
to which unit to output |
subroutine tem_printArray( me, itemLength, title, lineLength, nUnit )
! ---------------------------------------------------------------------------
!> Array title in debug output for easy identification in the file
character( len=* ),optional :: title
!> 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
!> how long should the line be
integer,optional :: lineLength
!> to which unit to output
integer :: nUnit
! ---------------------------------------------------------------------------
integer :: iElem
integer :: elemLength, meLength
integer :: itemLength_loc, lineLength_loc
character( len=128 ) :: buffer
character( len=128 ) :: spacer
! ---------------------------------------------------------------------------
if( present(linelength)) then
linelength_loc = min( abs(linelength), 128 )
else
linelength_loc = 120
endif
if( present(itemlength)) then
itemlength_loc = max( itemlength, 8 )
else
itemlength_loc = 8
endif
meLength = size( me(:) )
if ( meLength > 0 ) then
! build spacer
spacer = ''
do iElem = 1, lineLength_loc -2
write(spacer,'(2a)') trim(spacer),'-'
enddo
if( present(title)) then
write(nUnit,*) trim(spacer)
write(nUnit,'(2a,i0)') trim(title), ', size: ', size(me)
! write(nUnit,*) trim(spacer)
endif
buffer = ''
elemLength = itemLength_loc + 3
do iElem = 1, meLength
write(buffer,'(2a,i8)') trim(buffer),' ',me( iElem )
if( iElem == meLength .or. mod( iElem, elemLength ) == 0) then
write(nUnit,*) trim(buffer)
buffer = ''
endif
enddo
write(nUnit,*) trim(spacer)
end if ! meLength > 0
end subroutine tem_printArray