!***********************************************************************
! This file is part of OpenMolcas.                                     *
!                                                                      *
! OpenMolcas is free software; you can redistribute it and/or modify   *
! it under the terms of the GNU Lesser General Public License, v. 2.1. *
! OpenMolcas is distributed in the hope that it will be useful, but it *
! is provided "as is" and without any express or implied warranties.   *
! For more details see the full text of the license in the file        *
! LICENSE or in <http://www.gnu.org/licenses/>.                        *
!                                                                      *
! Copyright (C) 2019, Stefano Battaglia                                *
!***********************************************************************

subroutine prettyprint(A,N,M)
! This subroutine pretty prints the NxM matrix A

use caspt2_module, only: mState
use Definitions, only: wp, iwp, u6

implicit none
integer(kind=iwp), intent(in) :: N, M
real(kind=wp), intent(in) :: A(N,M)
integer(kind=iwp) :: i, j, jEnd, jStart

do jStart=1,N,5
  jEnd = min(jStart+4,N)
  write(u6,'(1x,5i16)') (mstate(j),j=jStart,jEnd)
  do i=1,N
    write(u6,'(1x,i3,2x,5f16.8)') mstate(i),(A(i,j),j=jStart,jEnd)
  end do
  write(u6,*)
end do

end subroutine prettyprint
