vec_to_string Subroutine

private subroutine vec_to_string(v, fmt, str, use_numpy, is_tuple)

Real vector 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

logical, intent(in), optional :: is_tuple

if true [default], use '()', if false use '[]'


Called by

proc~~vec_to_string~~CalledByGraph proc~vec_to_string vec_to_string proc~add_3d_plot pyplot%add_3d_plot proc~add_3d_plot->proc~vec_to_string proc~add_bar pyplot%add_bar proc~add_bar->proc~vec_to_string proc~add_contour pyplot%add_contour proc~add_contour->proc~vec_to_string proc~matrix_to_string matrix_to_string proc~add_contour->proc~matrix_to_string proc~add_errorbar pyplot%add_errorbar proc~add_errorbar->proc~vec_to_string proc~add_hist pyplot%add_hist proc~add_hist->proc~vec_to_string proc~add_imshow pyplot%add_imshow proc~add_imshow->proc~vec_to_string proc~add_imshow->proc~matrix_to_string proc~add_plot pyplot%add_plot proc~add_plot->proc~vec_to_string proc~matrix_to_string->proc~vec_to_string proc~plot_surface pyplot%plot_surface proc~plot_surface->proc~vec_to_string proc~plot_surface->proc~matrix_to_string proc~plot_wireframe pyplot%plot_wireframe proc~plot_wireframe->proc~vec_to_string proc~plot_wireframe->proc~matrix_to_string

Source Code

    subroutine vec_to_string(v, fmt, str, use_numpy, is_tuple)

    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
    logical,intent(in),optional                :: is_tuple  !! if true [default], use '()', if false use '[]'

    integer                     :: i         !! counter
    integer                     :: istat     !! IO status
    character(len=max_real_len) :: tmp       !! dummy string
    logical                     :: tuple

    if (present(is_tuple)) then
        tuple = is_tuple
    else
        tuple = .false.
    end if

    if (tuple) then
        str = '('
    else
        str = '['
    end if

    do i=1, size(v)
        if (fmt=='*') then
            write(tmp, *, iostat=istat) v(i)
        else
            write(tmp, fmt, iostat=istat) v(i)
        end if
        if (istat/=0) then
            write(error_unit,'(A)') 'Error in vec_to_string'
            str = '****'
            return
        end if
        str = str//trim(adjustl(tmp))
        if (i<size(v)) str = str // ','
    end do

    if (tuple) then
        str = str // ')'
    else
        str = str // ']'
    end if

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

    end subroutine vec_to_string