!>
!> @file rvec_print.f90
!>
!> @brief
!>
!> @copyright
!> Copyright (©) 2021 EPFL (Ecole Polytechnique Fédérale de Lausanne)
!> SPC (Swiss Plasma Center)
!>
!> SPClibs is free software: you can redistribute it and/or modify it under
!> the terms of the GNU Lesser General Public License as published by the Free
!> Software Foundation, either version 3 of the License, or (at your option)
!> any later version.
!>
!> SPClibs is distributed in the hope that it will be useful, but WITHOUT ANY
!> WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
!> FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
!>
!> You should have received a copy of the GNU Lesser General Public License
!> along with this program. If not, see .
!>
!> @author
!> (in alphabetical order)
!> @author Trach-Minh Tran
!>
subroutine rvec_print ( n, a, title )
!*******************************************************************************
!
!! RVEC_PRINT prints a real vector.
!
! Discussion:
!
! If all the entries are integers, the data is printed
! in integer format.
!
! Modified:
!
! 19 November 2002
!
! Author:
!
! John Burkardt
!
! Parameters:
!
! Input, integer N, the number of components of the vector.
!
! Input, real ( kind = 8 ) A(N), the vector to be printed.
!
! Input, character ( len = * ) TITLE, a title to be printed.
!
implicit none
integer n
real ( kind = 8 ) a(n)
integer i
character ( len = * ) title
if ( 0 < len_trim ( title ) ) then
write ( *, '(a)' ) ' '
write ( *, '(a)' ) trim ( title )
end if
write ( *, '(a)' ) ' '
if ( all ( a(1:n) == aint ( a(1:n) ) ) ) then
do i = 1, n
write ( *, '(i6,i6)' ) i, int ( a(i) )
end do
else if ( all ( abs ( a(1:n) ) < 1000000.0D+00 ) ) then
do i = 1, n
write ( *, '(i6,f14.6)' ) i, a(i)
end do
else
do i = 1, n
write ( *, '(i6,g14.6)' ) i, a(i)
end do
end if
return
end