add_str Subroutine

private subroutine add_str(me, str)

Add a string to the buffer.

Type Bound

pyplot

Arguments

Type IntentOptional Attributes Name
class(pyplot), intent(inout) :: me

pyplot handler

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

str to be added to pyplot handler buffer


Called by

proc~~add_str~~CalledByGraph proc~add_str pyplot%add_str proc~add_3d_plot pyplot%add_3d_plot proc~add_3d_plot->proc~add_str proc~add_bar pyplot%add_bar proc~add_bar->proc~add_str proc~add_contour pyplot%add_contour proc~add_contour->proc~add_str proc~add_errorbar pyplot%add_errorbar proc~add_errorbar->proc~add_str proc~add_hist pyplot%add_hist proc~add_hist->proc~add_str proc~add_imshow pyplot%add_imshow proc~add_imshow->proc~add_str proc~add_plot pyplot%add_plot proc~add_plot->proc~add_str proc~add_sphere pyplot%add_sphere proc~add_sphere->proc~add_str proc~finish_ops pyplot%finish_ops proc~finish_ops->proc~add_str proc~initialize pyplot%initialize proc~initialize->proc~add_str proc~plot_surface pyplot%plot_surface proc~plot_surface->proc~add_str proc~plot_wireframe pyplot%plot_wireframe proc~plot_wireframe->proc~add_str proc~savefig pyplot%savefig proc~savefig->proc~add_str proc~savefig->proc~finish_ops proc~showfig pyplot%showfig proc~showfig->proc~add_str proc~showfig->proc~finish_ops

Source Code

    subroutine add_str(me,str)

    class(pyplot),    intent(inout) :: me  !! pyplot handler
    character(len=*), intent(in)    :: str !! str to be added to pyplot handler buffer

    integer :: n_old !! current `me%str` length
    integer :: n_str !! length of input `str`
    character(len=:),allocatable :: tmp !! tmp string for building the result

    ! original
    !me%str = me%str//str//new_line(' ')

    if (len(str)==0) return

    ! the above can sometimes cause a stack overflow in the
    ! intel Fortran compiler, so we replace with this:
    if (allocated(me%str)) then
        n_old = len(me%str)
        n_str = len(str)
        allocate(character(len=n_old+n_str+1) :: tmp)
        tmp(1:n_old) = me%str
        tmp(n_old+1:) = str//new_line(' ')
        call move_alloc(tmp, me%str)
    else
        allocate(me%str, source = str//new_line(' '))
    end if

    end subroutine add_str