tokenize_into_tokens_separator Subroutine

private pure subroutine tokenize_into_tokens_separator(string, set, tokens, separator)

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
character(len=:), intent(out), allocatable :: tokens(:)
character(len=:), intent(out), optional, allocatable :: separator(:)

Calls

proc~~tokenize_into_tokens_separator~~CallsGraph proc~tokenize_into_tokens_separator tokenize_into_tokens_separator interface~tokenize tokenize proc~tokenize_into_tokens_separator->interface~tokenize interface~tokenize->proc~tokenize_into_tokens_separator proc~tokenize_into_first_last tokenize_into_first_last interface~tokenize->proc~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_tokens_separator~~CalledByGraph proc~tokenize_into_tokens_separator tokenize_into_tokens_separator interface~tokenize tokenize proc~tokenize_into_tokens_separator->interface~tokenize interface~tokenize->proc~tokenize_into_tokens_separator proc~parse_stream_name parse_stream_name proc~parse_stream_name->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, allocatable :: first(:)
integer, private :: i
integer, private, allocatable :: last(:)
integer, private :: n

Source Code

    pure subroutine tokenize_into_tokens_separator(string, set, tokens, separator)
        character(*), intent(in) :: string, set
        character(:), allocatable, intent(out) :: tokens(:)
        character(:), allocatable, optional, intent(out) :: separator(:)

        integer, allocatable :: first(:), last(:)
        integer :: i, n

        call tokenize(string, set, first, last)

        n = size(first)

        allocate(character(maxval(last - first) + 1) :: tokens(n))

        do i = 1, n
            tokens(i) = string(first(i):last(i))
        end do

        if (present(separator)) then
            allocate(character(1) :: separator(n - 1))

            do i = 1, n - 1
                separator(i) = string(last(i) + 1:last(i) + 1)
            end do
        end if
    end subroutine tokenize_into_tokens_separator