Module dc_string

module dc_string

        ! Uses
    use dcstring_base
    use dcstring_list
    use dc_types, only: TOKEN, STRING, DP

        ! Interfaces
    public interface StoI
    public interface StoD
    public interface get_array
    public interface Str_to_Logical
    public interface toChar
    public interface Concat
    public interface StoA
    public interface Split
    public interface toUpper
    public interface toLower
    public interface UChar
    public interface LChar
    public interface StriEq
    public interface StrHead
    public interface StrInclude
    public interface GTStringQuoteForDcl
    public interface Cprintf
    public interface Printf

        ! Subroutines and functions
    private logical function StrHead_CC (whole, head)
    private logical function StriEq_cc (string_a, string_b)
    private logical function StriEq_sc (string_a, string_b)
    private logical function Str_Include_ac (carray, string_b)
    private logical function str2bool (string)
    private integer function atoi_scalar (string, default)
    private integer function stoi_scalar (string)
    private real (kind=DP) function atod_scalar (string)
    private real (kind=DP) function stod_scalar (string)
    private subroutine str2ip (int_ptr, string)
    private subroutine strv2ip (int_ptr, string)
    private subroutine str2rp (real_ptr, string)
    private subroutine strv2rp (real_ptr, string)
    private subroutine str2dp (real_ptr, string)
    private subroutine strv2dp (dble_ptr, string)
    private character (len=TOKEN) function itoa_scalar (i)
    private character (len=STRING) function itoa_array (ibuf)
    private character (len=TOKEN) function rtoa_scalar (x)
    private character (len=STRING) function rtoa_array (rbuf)
    private character (len=TOKEN) function dtoa_scalar (d)
    private character (len=STRING) function dtoa_array (dbuf)
    private character (len=TOKEN) function ltoa_scalar (l)
    private character (len=STRING) function ltoa_array (lbuf)
    public character (len=STRING) function JoinChar (carray, expr)
    private subroutine concat_tail (carray, str, result)
    private function Str_to_Array1 (c1) result (result)
    private function Str_to_Array2 (c1, c2) result (result)
    private function Str_to_Array3 (c1, c2, c3) result (result)
    private function Str_to_Array4 (c1, c2, c3, c4) result (result)
    private function Str_to_Array5 (c1, c2, c3, c4, c5) result (result)
    private function Str_to_Array6 (c1, c2, c3, c4, c5, c6) result (result)
    private function Str_to_Array7 (c1, c2, c3, c4, c5, c6, c7) result (result)
    private function Str_to_Array8 (c1, c2, c3, c4, c5, c6, c7, c8) result (result)
    private function Str_to_Array9 (c1, c2, c3, c4, c5, c6, c7, c8, c9) result (result)
    private function Str_to_Array10 (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) result (result)
    private function Str_to_Array11 (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11) result (result)
    private function Str_to_Array12 (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12) result (result)
    private subroutine Split_CC (str, carray, sep, limit)
    public integer function Index_Ofs (string, start, substr)
    public function Replace (string, from, to) result (result)
    private subroutine cupper (ch)
    private subroutine clower (ch)
    public character (len=STRING) function UChar (ch)
    public character (len=STRING) function LChar (ch)

end module dc_string

Description of Interfaces

StoI

public interface StoI
    module procedure atoi_scalar
    module procedure stoi_scalar
end interface StoI

StoD

public interface StoD
    module procedure atod_scalar
    module procedure stod_scalar
end interface StoD

get_array

public interface get_array
    module procedure str2ip
    module procedure strv2ip
    module procedure str2rp
    module procedure strv2rp
    module procedure str2dp
    module procedure strv2dp
end interface get_array

Str_to_Logical

public interface Str_to_Logical
    module procedure str2bool
end interface Str_to_Logical

toChar

public interface toChar
    module procedure itoa_scalar
    module procedure itoa_array
    module procedure rtoa_scalar
    module procedure rtoa_array
    module procedure dtoa_scalar
    module procedure dtoa_array
    module procedure ltoa_scalar
    module procedure ltoa_array
end interface toChar

Concat

public interface Concat
    module procedure concat_tail
end interface Concat

StoA

public interface StoA
    module procedure Str_to_Array1
    module procedure Str_to_Array2
    module procedure Str_to_Array3
    module procedure Str_to_Array4
    module procedure Str_to_Array5
    module procedure Str_to_Array6
    module procedure Str_to_Array7
    module procedure Str_to_Array8
    module procedure Str_to_Array9
    module procedure Str_to_Array10
    module procedure Str_to_Array11
    module procedure Str_to_Array12
end interface StoA

Split

public interface Split
    module procedure Split_CC
end interface Split

toUpper

public interface toUpper
    module procedure cupper
end interface toUpper

toLower

public interface toLower
    module procedure clower
end interface toLower

UChar

public interface UChar
    module procedure UChar
end interface UChar

LChar

public interface LChar
    module procedure LChar
end interface LChar

StriEq

public interface StriEq
    module procedure StriEq_sc
    module procedure StriEq_cc
end interface StriEq

StrHead

public interface StrHead
    module procedure StrHead_cc
            $    module procedure StrHead_sc
end interface StrHead

StrInclude

public interface StrInclude
    module procedure Str_Include_ac
end interface StrInclude

GTStringQuoteForDcl

public interface GTStringQuoteForDcl
    function GTStringQuoteForDcl (string) result (result)
        character (len=*), intent(in) :: string
        character (len=STRLEN) :: result
    end function GTStringQuoteForDcl
end interface GTStringQuoteForDcl

Cprintf

public interface Cprintf
    function DCStringCPrintf (fmt, i, r, d, L, s, n, c1, c2, c3, ca) result (result)
        character (len=*), intent(in) :: fmt
        integer, optional, intent(in), dimension (:) :: i
        real, optional, intent(in), dimension (:) :: r
        real (kind=DP), optional, intent(in), dimension (:) :: d
        logical, optional, intent(in), dimension (:) :: L
        type (VSTRING), optional, intent(in), dimension (:) :: s
        integer, optional, intent(in), dimension (:) :: n
        character (len=*), optional, intent(in) :: c1
        character (len=*), optional, intent(in) :: c2
        character (len=*), optional, intent(in) :: c3
        character (len=*), optional, intent(in), dimension (:) :: ca
        character (len=STRING) :: result
    end function DCStringCPrintf
end interface Cprintf

Printf

public interface Printf
    subroutine DCStringSPrintf (unit, fmt, i, r, d, L, s, n, c1, c2, c3, ca)
        character (len=*), intent(out) :: unit
        character (len=*), intent(in) :: fmt
        integer, optional, intent(in), dimension (:) :: i
        real, optional, intent(in), dimension (:) :: r
        real (kind=DP), optional, intent(in), dimension (:) :: d
        logical, optional, intent(in), dimension (:) :: L
        type (VSTRING), optional, intent(in), dimension (:) :: s
        integer, optional, intent(in), dimension (:) :: n
        character (len=*), optional, intent(in) :: c1
        character (len=*), optional, intent(in) :: c2
        character (len=*), optional, intent(in) :: c3
        character (len=*), optional, intent(in), dimension (:) :: ca
    end subroutine DCStringSPrintf
    subroutine DCStringPrintf (unit, fmt, i, r, d, L, s, n, c1, c2, c3, ca)
        type (VSTRING), intent(out) :: unit
        character (len=*), intent(in) :: fmt
        integer, optional, intent(in), dimension (:) :: i
        real, optional, intent(in), dimension (:) :: r
        real (kind=DP), optional, intent(in), dimension (:) :: d
        logical, optional, intent(in), dimension (:) :: L
        type (VSTRING), optional, intent(in), dimension (:) :: s
        integer, optional, intent(in), dimension (:) :: n
        character (len=*), optional, intent(in) :: c1
        character (len=*), optional, intent(in) :: c2
        character (len=*), optional, intent(in) :: c3
        character (len=*), optional, intent(in), dimension (:) :: ca
    end subroutine DCStringPrintf
    subroutine DCStringFPrintf (unit, fmt, i, r, d, L, s, n, c1, c2, c3, ca)
        integer, optional, intent(in) :: unit
        character (len=*), intent(in) :: fmt
        integer, optional, intent(in), dimension (:) :: i
        real, optional, intent(in), dimension (:) :: r
        real (kind=DP), optional, intent(in), dimension (:) :: d
        logical, optional, intent(in), dimension (:) :: L
        type (VSTRING), optional, intent(in), dimension (:) :: s
        integer, optional, intent(in), dimension (:) :: n
        character (len=*), optional, intent(in) :: c1
        character (len=*), optional, intent(in) :: c2
        character (len=*), optional, intent(in) :: c3
        character (len=*), optional, intent(in), dimension (:) :: ca
    end subroutine DCStringFPrintf
end interface Printf

Description of Subroutines and Functions

StrHead_CC

private function StrHead_CC (whole, head) result (result)
    character (len=*), intent(in) :: whole
    character (len=*), intent(in) :: head
    logical :: result
end function StrHead_CC
$  logical function StrHead_SC(whole, head) result(result)
$    type(VSTRING)     , intent(in) :: whole
$    character(len = *), intent(in) :: head
$  continue
$    result = (extract(whole, 1, len(head)) == head)
$  end function

StriEq_cc

private function StriEq_cc (string_a, string_b) result (result)
    character (len=*), intent(in) :: string_a
    character (len=*), intent(in) :: string_b
    logical :: result
    ! Calls: toUpper
end function StriEq_cc

StriEq_sc

private function StriEq_sc (string_a, string_b) result (result)
    type (VSTRING), intent(in) :: string_a
    character (len=*), intent(in) :: string_b
    logical :: result
end function StriEq_sc

Str_Include_ac

private function Str_Include_ac (carray, string_b) result (result)
    character (len=*), intent(in), dimension (:) :: carray
    character (len=*), intent(in) :: string_b
    logical :: result
end function Str_Include_ac

str2bool

private function str2bool (string) result (result)
    character (len=*), intent(in) :: string
    logical :: result
end function str2bool

atoi_scalar

private function atoi_scalar (string, default) result (result)
    character (len=*), intent(in) :: string
    integer, optional, intent(in) :: default
    integer :: result
end function atoi_scalar

stoi_scalar

private function stoi_scalar (string) result (result)
    type (VSTRING), intent(in) :: string
    integer :: result
end function stoi_scalar

atod_scalar

private function atod_scalar (string) result (result)
    character (len=*), intent(in) :: string
    real (kind=DP) :: result
end function atod_scalar

stod_scalar

private function stod_scalar (string) result (result)
    type (VSTRING), intent(in) :: string
    real (kind=DP) :: result
end function stod_scalar

str2ip

private subroutine str2ip (int_ptr, string)
    integer, pointer, dimension (:) :: int_ptr
    character (len=*), intent(in) :: string
end subroutine str2ip

strv2ip

private subroutine strv2ip (int_ptr, string)
    integer, pointer, dimension (:) :: int_ptr
    type (VSTRING), intent(in) :: string
    ! Calls: Split, dispose
end subroutine strv2ip

str2rp

private subroutine str2rp (real_ptr, string)
    real, pointer, dimension (:) :: real_ptr
    character (len=*), intent(in) :: string
end subroutine str2rp

strv2rp

private subroutine strv2rp (real_ptr, string)
    real, pointer, dimension (:) :: real_ptr
    type (VSTRING), intent(in) :: string
    ! Calls: Split, dispose
end subroutine strv2rp

str2dp

private subroutine str2dp (real_ptr, string)
    real (kind=DP), pointer, dimension (:) :: real_ptr
    character (len=*), intent(in) :: string
end subroutine str2dp

strv2dp

private subroutine strv2dp (dble_ptr, string)
    real (kind=DP), pointer, dimension (:) :: dble_ptr
    type (VSTRING), intent(in) :: string
    ! Calls: Split, dispose
end subroutine strv2dp

itoa_scalar

private function itoa_scalar (i) result (result)
    integer, intent(in) :: i
    character (len=TOKEN) :: result
end function itoa_scalar

itoa_array

private function itoa_array (ibuf) result (result)
    integer, intent(in), dimension (:) :: ibuf
    character (len=STRING) :: result
end function itoa_array

rtoa_scalar

private function rtoa_scalar (x) result (result)
    real, intent(in) :: x
    character (len=TOKEN) :: result
end function rtoa_scalar

rtoa_array

private function rtoa_array (rbuf) result (result)
    real, intent(in), dimension (:) :: rbuf
    character (len=STRING) :: result
end function rtoa_array

dtoa_scalar

private function dtoa_scalar (d) result (result)
    real (kind=DP), intent(in) :: d
    character (len=TOKEN) :: result
end function dtoa_scalar

dtoa_array

private function dtoa_array (dbuf) result (result)
    real (kind=DP), intent(in), dimension (:) :: dbuf
    character (len=STRING) :: result
end function dtoa_array

ltoa_scalar

private function ltoa_scalar (l) result (result)
    logical, intent(in) :: l
    character (len=TOKEN) :: result
end function ltoa_scalar

ltoa_array

private function ltoa_array (lbuf) result (result)
    logical, intent(in), dimension (:) :: lbuf
    character (len=STRING) :: result
end function ltoa_array

JoinChar

public function JoinChar (carray, expr) result (result)
    character (len=*), intent(in), dimension (:) :: carray
    character (len=*), optional, intent(in) :: expr
    character (len=STRING) :: result
end function JoinChar

concat_tail

private subroutine concat_tail (carray, str, result)
    character (len=*), intent(in), dimension (:) :: carray
    character (len=*), intent(in) :: str
    character (len=STRING), pointer, dimension (:) :: result
end subroutine concat_tail

Str_to_Array1

private function Str_to_Array1 (c1) result (result)
    character (len=*), intent(in) :: c1
    character (len=STRING), dimension (1) :: result
end function Str_to_Array1

Str_to_Array2

private function Str_to_Array2 (c1, c2) result (result)
    character (len=*), intent(in) :: c1
    character (len=*), intent(in) :: c2
    character (len=STRING), dimension (2) :: result
end function Str_to_Array2

Str_to_Array3

private function Str_to_Array3 (c1, c2, c3) result (result)
    character (len=*), intent(in) :: c1
    character (len=*), intent(in) :: c2
    character (len=*), intent(in) :: c3
    character (len=STRING), dimension (3) :: result
end function Str_to_Array3

Str_to_Array4

private function Str_to_Array4 (c1, c2, c3, c4) result (result)
    character (len=*), intent(in) :: c1
    character (len=*), intent(in) :: c2
    character (len=*), intent(in) :: c3
    character (len=*), intent(in) :: c4
    character (len=STRING), dimension (4) :: result
end function Str_to_Array4

Str_to_Array5

private function Str_to_Array5 (c1, c2, c3, c4, c5) result (result)
    character (len=*), intent(in) :: c1
    character (len=*), intent(in) :: c2
    character (len=*), intent(in) :: c3
    character (len=*), intent(in) :: c4
    character (len=*), intent(in) :: c5
    character (len=STRING), dimension (5) :: result
end function Str_to_Array5

Str_to_Array6

private function Str_to_Array6 (c1, c2, c3, c4, c5, c6) result (result)
    character (len=*), intent(in) :: c1
    character (len=*), intent(in) :: c2
    character (len=*), intent(in) :: c3
    character (len=*), intent(in) :: c4
    character (len=*), intent(in) :: c5
    character (len=*), intent(in) :: c6
    character (len=STRING), dimension (6) :: result
end function Str_to_Array6

Str_to_Array7

private function Str_to_Array7 (c1, c2, c3, c4, c5, c6, c7) result (result)
    character (len=*), intent(in) :: c1
    character (len=*), intent(in) :: c2
    character (len=*), intent(in) :: c3
    character (len=*), intent(in) :: c4
    character (len=*), intent(in) :: c5
    character (len=*), intent(in) :: c6
    character (len=*), intent(in) :: c7
    character (len=STRING), dimension (7) :: result
end function Str_to_Array7

Str_to_Array8

private function Str_to_Array8 (c1, c2, c3, c4, c5, c6, c7, c8) result (result)
    character (len=*), intent(in) :: c1
    character (len=*), intent(in) :: c2
    character (len=*), intent(in) :: c3
    character (len=*), intent(in) :: c4
    character (len=*), intent(in) :: c5
    character (len=*), intent(in) :: c6
    character (len=*), intent(in) :: c7
    character (len=*), intent(in) :: c8
    character (len=STRING), dimension (8) :: result
end function Str_to_Array8

Str_to_Array9

private function Str_to_Array9 (c1, c2, c3, c4, c5, c6, c7, c8, c9) result (result)
    character (len=*), intent(in) :: c1
    character (len=*), intent(in) :: c2
    character (len=*), intent(in) :: c3
    character (len=*), intent(in) :: c4
    character (len=*), intent(in) :: c5
    character (len=*), intent(in) :: c6
    character (len=*), intent(in) :: c7
    character (len=*), intent(in) :: c8
    character (len=*), intent(in) :: c9
    character (len=STRING), dimension (9) :: result
end function Str_to_Array9

Str_to_Array10

private function Str_to_Array10 (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) result (result)
    character (len=*), intent(in) :: c1
    character (len=*), intent(in) :: c2
    character (len=*), intent(in) :: c3
    character (len=*), intent(in) :: c4
    character (len=*), intent(in) :: c5
    character (len=*), intent(in) :: c6
    character (len=*), intent(in) :: c7
    character (len=*), intent(in) :: c8
    character (len=*), intent(in) :: c9
    character (len=*), intent(in) :: c10
    character (len=STRING), dimension (10) :: result
end function Str_to_Array10

Str_to_Array11

private function Str_to_Array11 (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11) result (result)
    character (len=*), intent(in) :: c1
    character (len=*), intent(in) :: c2
    character (len=*), intent(in) :: c3
    character (len=*), intent(in) :: c4
    character (len=*), intent(in) :: c5
    character (len=*), intent(in) :: c6
    character (len=*), intent(in) :: c7
    character (len=*), intent(in) :: c8
    character (len=*), intent(in) :: c9
    character (len=*), intent(in) :: c10
    character (len=*), intent(in) :: c11
    character (len=STRING), dimension (11) :: result
end function Str_to_Array11

Str_to_Array12

private function Str_to_Array12 (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12) result (result)
    character (len=*), intent(in) :: c1
    character (len=*), intent(in) :: c2
    character (len=*), intent(in) :: c3
    character (len=*), intent(in) :: c4
    character (len=*), intent(in) :: c5
    character (len=*), intent(in) :: c6
    character (len=*), intent(in) :: c7
    character (len=*), intent(in) :: c8
    character (len=*), intent(in) :: c9
    character (len=*), intent(in) :: c10
    character (len=*), intent(in) :: c11
    character (len=*), intent(in) :: c12
    character (len=STRING), dimension (12) :: result
end function Str_to_Array12

Split_CC

private subroutine Split_CC (str, carray, sep, limit)
    character (len=*), intent(in) :: str
    character (len=*), pointer, dimension (:) :: carray
    character (len=*), intent(in) :: sep
    integer, optional, intent(in) :: limit
end subroutine Split_CC

Index_Ofs

public function Index_Ofs (string, start, substr) result (result)
    character (len=*), intent(in) :: string
    integer, intent(in) :: start
    character (len=*), intent(in) :: substr
    integer :: result
end function Index_Ofs

Replace

public function Replace (string, from, to) result (result)
    character (len=*), intent(in) :: string
    character (len=*), intent(in) :: from
    character (len=*), intent(in) :: to
    character (len=STRLEN) :: result
end function Replace

cupper

private subroutine cupper (ch)
    character (len=*), intent(inout) :: ch
end subroutine cupper

clower

private subroutine clower (ch)
    character (len=*), intent(inout) :: ch
end subroutine clower

UChar

public function UChar (ch) result (result)
    character (len=*), intent(in) :: ch
    character (len=STRING) :: result
    ! Calls: toUpper
end function UChar

LChar

public function LChar (ch) result (result)
    character (len=*), intent(in) :: ch
    character (len=STRING) :: result
    ! Calls: toLower
end function LChar