dbcsr_printmat_matlab_z Subroutine

private subroutine dbcsr_printmat_matlab_z(matrix, rows, cols, r_offset, c_offset, iunit, tr, variable_name)

Arguments

TypeIntentOptionalAttributesName
complex(kind=real_8), intent(in), DIMENSION(:):: matrix
integer, intent(in) :: rows
integer, intent(in) :: cols
integer, intent(in) :: r_offset
integer, intent(in) :: c_offset
integer, intent(in) :: iunit
logical, intent(in), optional :: tr
character(len=*), intent(in), optional :: variable_name

Contents


Source Code

   SUBROUTINE dbcsr_printmat_matlab_z(matrix, rows, cols, r_offset, c_offset, iunit, tr, variable_name)
      COMPLEX(KIND=real_8), DIMENSION(:), INTENT(IN)     :: matrix
      INTEGER, INTENT(IN)                                :: rows, cols, r_offset, c_offset, iunit
      LOGICAL, INTENT(IN), OPTIONAL                      :: tr
      CHARACTER(len=*), INTENT(in), OPTIONAL             :: variable_name

      INTEGER                                            :: c, c_off, m, n, r, r_off
      LOGICAL                                            :: t

!   ---------------------------------------------------------------------------

      m = rows
      n = cols
      r_off = r_offset
      c_off = c_offset
      t = .FALSE.
      IF (PRESENT(tr)) THEN
         IF (tr) THEN
            t = .TRUE.
            m = cols
            n = rows
            r_off = c_offset
            c_off = r_offset
         END IF
      END IF

      DO c = 1, cols
         DO r = 1, rows
            IF (.NOT. t) THEN
               IF (PRESENT(variable_name)) THEN
                  WRITE (iunit, '(A,I3,A,I3,A,E23.16,A,E23.16,A)') variable_name//'(', r + r_offset - 1, ',', &
                     c + c_offset - 1, ')=', &
                     REAL(matrix(r + (c - 1)*rows)), '+', AIMAG(matrix(r + (c - 1)*rows)), 'i;'
               ELSE
                  WRITE (iunit, '(A,I3,A,I3,A,E23.16,A,E23.16,A)') 'a(', r + r_offset - 1, ',', c + c_offset - 1, ')=', &
                     REAL(matrix(r + (c - 1)*rows)), '+', AIMAG(matrix(r + (c - 1)*rows)), 'i;'
               END IF
            ELSE
               IF (PRESENT(variable_name)) THEN
                  WRITE (iunit, '(A,I3,A,I3,A,E23.16,A,E23.16,A)') variable_name//'(', r + r_offset - 1, ',', &
                     c + c_offset - 1, ')=', &
                     REAL(matrix((r - 1)*cols + c)), '+', AIMAG(matrix((r - 1)*cols + c)), 'i;'
               ELSE
                  WRITE (iunit, '(A,I3,A,I3,A,E23.16,A,E23.16,A)') 'a(', r + r_offset - 1, ',', c + c_offset - 1, ')=', &
                     REAL(matrix((r - 1)*cols + c)), '+', AIMAG(matrix((r - 1)*cols + c)), 'i;'
               END IF
            END IF
         END DO
      END DO
   END SUBROUTINE dbcsr_printmat_matlab_z