Print an array of integers in a well formatted way.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | label |
Label to print before the array |
||
integer(kind=ip), | intent(in), | dimension(:) | :: | vec |
Integer vector to be printed |
|
integer(kind=ip), | intent(in), | optional | :: | ofunit |
If present specify the unit where the array should be printed, otherwise iof_mmpol is used. |
|
integer(kind=ip), | intent(in), | optional | :: | ibeg |
Index of the first element to be printed, if 0 or absent the first element is used |
|
integer(kind=ip), | intent(in), | optional | :: | iend |
Index of the last element to be printed, if 0 or absent the last |
subroutine print_int_vec(label, vec, ofunit, ibeg, iend)
!! Print an array of integers in a well formatted way.
implicit none
character(len=*), intent(in) :: label
!! Label to print before the array
integer(ip), dimension(:), intent(in) :: vec
!! Integer vector to be printed
integer(ip), intent(in), optional :: ofunit
!! If present specify the unit where the array should be printed,
!! otherwise [[iof_mmpol]] is used.
integer(ip), intent(in), optional :: ibeg
!! Index of the first element to be printed, if 0 or absent the first
!! element is used
integer(ip), intent(in), optional :: iend
!! Index of the last element to be printed, if 0 or absent the last
integer(ip) :: ib, ie, out_unit
if(present(ibeg)) then
ib = ibeg
else
ib = 0
end if
if(present(ibeg)) then
ie = iend
else
ie = 0
end if
if(ib == 0) ib = 1
if(ie == 0) ie = size(vec)
if(present(ofunit)) then
out_unit = ofunit
else
out_unit = iof_mmpol
end if
write(out_unit, '(t3, a)') label
if(ib > ie) then
write(out_unit,'(t5)')
return
end if
write(out_unit,'(t5, 10i8)') vec(ib:ie)
end subroutine print_int_vec