matrix_to_string Subroutine

private subroutine matrix_to_string(v, fmt, str, use_numpy)

Real matrix (rank 2) to string.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in), dimension(:,:) :: v

real values

character(len=*), intent(in) :: fmt

real format string

character(len=:), intent(out), allocatable :: str

real values stringified

logical, intent(in) :: use_numpy

activate numpy python module usage


Calls

proc~~matrix_to_string~~CallsGraph proc~matrix_to_string matrix_to_string proc~vec_to_string vec_to_string proc~matrix_to_string->proc~vec_to_string

Called by

proc~~matrix_to_string~~CalledByGraph proc~matrix_to_string matrix_to_string proc~add_contour pyplot%add_contour proc~add_contour->proc~matrix_to_string proc~add_imshow pyplot%add_imshow proc~add_imshow->proc~matrix_to_string proc~plot_surface pyplot%plot_surface proc~plot_surface->proc~matrix_to_string proc~plot_wireframe pyplot%plot_wireframe proc~plot_wireframe->proc~matrix_to_string

Source Code

    subroutine matrix_to_string(v, fmt, str, use_numpy)

    real(wp), dimension(:,:),      intent(in)  :: v         !! real values
    character(len=*),              intent(in)  :: fmt       !! real format string
    character(len=:), allocatable, intent(out) :: str       !! real values stringified
    logical,                       intent(in)  :: use_numpy !! activate numpy python module usage

    integer                      :: i         !! counter
    character(len=:),allocatable :: tmp       !! dummy string

    str = '['
    do i=1, size(v,1)  !rows
        call vec_to_string(v(i,:), fmt, tmp, use_numpy)  !one row at a time
        str = str//trim(adjustl(tmp))
        if (i<size(v,1)) str = str // ','
    end do
    str = str // ']'

    !convert to numpy array if necessary:
    if (use_numpy) str = 'np.array('//str//')'

    end subroutine matrix_to_string