tokenize_into_first_last Subroutine

private pure subroutine tokenize_into_first_last(string, set, first, last)

Parse a string into tokens. This subroutine implements the tokenize intrinsic procedure as defined in the Fortran 2023 language standard (Section 16.9.210).

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: string
character(len=*), intent(in) :: set
integer, intent(out), allocatable :: first(:)
integer, intent(out), allocatable :: last(:)

Calls

proc~~tokenize_into_first_last~~CallsGraph proc~tokenize_into_first_last tokenize_into_first_last proc~split split proc~tokenize_into_first_last->proc~split interface~clamp clamp proc~split->interface~clamp proc~clamp_int32 clamp_int32 interface~clamp->proc~clamp_int32 proc~clamp_int64 clamp_int64 interface~clamp->proc~clamp_int64 proc~clamp_real32 clamp_real32 interface~clamp->proc~clamp_real32 proc~clamp_real64 clamp_real64 interface~clamp->proc~clamp_real64

Called by

proc~~tokenize_into_first_last~~CalledByGraph proc~tokenize_into_first_last tokenize_into_first_last interface~tokenize tokenize interface~tokenize->proc~tokenize_into_first_last proc~tokenize_into_tokens_separator tokenize_into_tokens_separator interface~tokenize->proc~tokenize_into_tokens_separator proc~parse_stream_name parse_stream_name proc~parse_stream_name->interface~tokenize proc~tokenize_into_tokens_separator->interface~tokenize proc~dyn_mpas_init_stream_with_pool mpas_dynamical_core_type%dyn_mpas_init_stream_with_pool proc~dyn_mpas_init_stream_with_pool->proc~parse_stream_name proc~dyn_mpas_read_write_stream mpas_dynamical_core_type%dyn_mpas_read_write_stream proc~dyn_mpas_read_write_stream->proc~parse_stream_name proc~dyn_mpas_read_write_stream->proc~dyn_mpas_init_stream_with_pool proc~dyn_init dyn_init proc~dyn_init->proc~dyn_mpas_read_write_stream proc~dyn_variable_dump dyn_variable_dump proc~dyn_variable_dump->proc~dyn_mpas_read_write_stream proc~model_grid_init model_grid_init proc~model_grid_init->proc~dyn_mpas_read_write_stream interface~dyn_init dyn_init interface~dyn_init->proc~dyn_init interface~model_grid_init model_grid_init interface~model_grid_init->proc~model_grid_init proc~dyn_final dyn_final proc~dyn_final->proc~dyn_variable_dump interface~dyn_final dyn_final interface~dyn_final->proc~dyn_final proc~stepon_final stepon_final proc~stepon_final->interface~dyn_final

Variables

Type Visibility Attributes Name Initial
integer, private :: l
integer, private :: n
integer, private :: pos
integer, private :: pos_end(len(string)+1)
integer, private :: pos_start(len(string)+1)

Source Code

    pure subroutine tokenize_into_first_last(string, set, first, last)
        character(*), intent(in) :: string, set
        integer, allocatable, intent(out) :: first(:), last(:)

        integer :: pos_start(len(string) + 1), pos_end(len(string) + 1)
        integer :: l, n, pos

        l = len(string)
        n = 0
        pos = 0

        do while (pos < l + 1)
            n = n + 1
            pos_start(n) = pos + 1

            call split(string, set, pos)

            pos_end(n) = pos - 1
        end do

        allocate(first(n), last(n))

        first(:) = pos_start(1:n)
        last(:) = pos_end(1:n)
    end subroutine tokenize_into_first_last