reserve Subroutine

private pure subroutine reserve(me, nchars)

Make sure the buffer has room for nchars more characters.

Type Bound

text_buffer

Arguments

Type IntentOptional Attributes Name
class(text_buffer), intent(inout) :: me
integer, intent(in) :: nchars

Called by

proc~~reserve~~CalledByGraph proc~reserve text_buffer%reserve proc~add_real text_buffer%add_real proc~add_real->proc~reserve proc~add_str text_buffer%add_str proc~add_real->proc~add_str proc~add_digits add_digits proc~add_real->proc~add_digits proc~add_real_array text_buffer%add_real_array proc~add_real_array->proc~reserve proc~add_real_list text_buffer%add_real_list proc~add_real_array->proc~add_real_list proc~add_real_array->proc~add_str proc~add_real_list->proc~reserve proc~add_real_list->proc~add_real proc~add_real_list->proc~add_str proc~add_str->proc~reserve proc~add_digits->proc~add_str proc~segment_trajectory_json segment_trajectory_json proc~segment_trajectory_json->proc~add_real_array proc~segment_trajectory_json->proc~add_str proc~add_int text_buffer%add_int proc~segment_trajectory_json->proc~add_int proc~write_json_real_array write_json_real_array proc~write_json_real_array->proc~add_real_list proc~write_json_real_array->proc~add_str proc~add_int->proc~add_digits proc~export_trajectory_json_file mission_type%export_trajectory_json_file proc~export_trajectory_json_file->proc~segment_trajectory_json proc~generate_eclipse_data mission_type%generate_eclipse_data proc~generate_eclipse_data->proc~write_json_real_array proc~halo_solver_main halo_solver_main proc~halo_solver_main->proc~export_trajectory_json_file proc~halo_solver_main->proc~generate_eclipse_data

Source Code

    pure subroutine reserve(me, nchars)

    class(text_buffer),intent(inout) :: me
    integer,intent(in) :: nchars

    character(len=:),allocatable :: tmp
    integer :: new_size

    if (.not. allocated(me%s)) then
        allocate(character(len=max(nchars, 1024)) :: me%s)
        me%n = 0
    else if (me%n + nchars > len(me%s)) then
        new_size = max(2*len(me%s), me%n + nchars)
        allocate(character(len=new_size) :: tmp)
        tmp(1:me%n) = me%s(1:me%n)
        call move_alloc(tmp, me%s)
    end if

    end subroutine reserve