init_da_label Subroutine

public subroutine init_da_label(me, length)

initialization of a dynamic array

before a dynamic array can be used, it has to be initialized with this routine. the initial length provided here, can avoid reallocations and memory copying, if approximated correctly enough. if none is specified, the provided container initially will be of size 0.

Arguments

Type IntentOptional Attributes Name
type(dyn_labelarray_type), intent(out) :: me
integer, intent(in), optional :: length

Called by

proc~~init_da_label~~CalledByGraph proc~init_da_label init_da_label interface~init~24 init interface~init~24->proc~init_da_label proc~init_possible_variable init_possible_variable proc~init_possible_variable->interface~init~24 proc~sorttruncate_da_int sorttruncate_da_int proc~sorttruncate_da_int->interface~init~24 proc~sorttruncate_da_label sorttruncate_da_label proc~sorttruncate_da_label->interface~init~24 proc~sorttruncate_da_long sorttruncate_da_long proc~sorttruncate_da_long->interface~init~24 proc~sorttruncate_da_real sorttruncate_da_real proc~sorttruncate_da_real->interface~init~24 proc~tem_create_varmap tem_create_varMap proc~tem_create_varmap->interface~init~24 proc~tem_varsys_init tem_varSys_init proc~tem_varsys_init->interface~init~24 proc~tem_varsys_load_single tem_varSys_load_single proc~tem_varsys_load_single->interface~init~24 interface~init~26 init interface~init~26->proc~init_possible_variable interface~sorttruncate~2 sorttruncate interface~sorttruncate~2->proc~sorttruncate_da_long interface~sorttruncate~3 sorttruncate interface~sorttruncate~3->proc~sorttruncate_da_int interface~sorttruncate~4 sorttruncate interface~sorttruncate~4->proc~sorttruncate_da_real interface~sorttruncate~5 sorttruncate interface~sorttruncate~5->proc~sorttruncate_da_label interface~tem_varsys_load tem_varSys_load interface~tem_varsys_load->proc~tem_varsys_load_single proc~tem_varsys_load_vector tem_varSys_load_vector interface~tem_varsys_load->proc~tem_varsys_load_vector proc~hvs_output_init hvs_output_init proc~hvs_output_init->proc~tem_create_varmap proc~tem_init_convergence tem_init_convergence proc~tem_init_convergence->proc~tem_create_varmap proc~tem_init_depend tem_init_depend proc~tem_init_depend->proc~tem_create_varmap proc~tem_init_tracker tem_init_tracker proc~tem_init_tracker->proc~tem_create_varmap proc~tem_init_tracker->proc~hvs_output_init proc~tem_opvar_reduction_transient_init tem_opVar_reduction_transient_init proc~tem_opvar_reduction_transient_init->proc~tem_create_varmap proc~tem_varsys_load_vector->proc~tem_varsys_load_single proc~tem_restart_readheader tem_restart_readHeader proc~tem_restart_readheader->interface~tem_varsys_load

Source Code

  subroutine init_da_label(me, length)
    !-----------------------------------------------------------------
    type(dyn_labelarray_type), intent(out) :: me !< dynamic array to init
    integer, intent(in), optional :: length !< initial length of the container
    !-----------------------------------------------------------------

    if (present(length)) then
      me%containersize = length
    else
      me%containersize = zerolength
    end if

    ! deallocate ...
    if( allocated( me%val ) ) deallocate(me%val)
    if( allocated( me%sorted ) ) deallocate(me%sorted)
    ! ... and reallocate
    allocate(me%val(me%containersize))
    allocate(me%sorted(me%containersize))
    me%nvals = 0

  end subroutine init_da_label