stringifor_string_t Module

StringiFor, definition of string type.


Uses

  • module~~stringifor_string_t~~UsesGraph module~stringifor_string_t stringifor_string_t befor64 befor64 module~stringifor_string_t->befor64 face face module~stringifor_string_t->face iso_fortran_env iso_fortran_env module~stringifor_string_t->iso_fortran_env penf penf module~stringifor_string_t->penf

Used by

  • module~~stringifor_string_t~~UsedByGraph module~stringifor_string_t stringifor_string_t module~stringifor stringifor module~stringifor->module~stringifor_string_t program~volatile_doctest volatile_doctest program~volatile_doctest->module~stringifor_string_t program~volatile_doctest~10 volatile_doctest program~volatile_doctest~10->module~stringifor_string_t program~volatile_doctest~100 volatile_doctest program~volatile_doctest~100->module~stringifor_string_t program~volatile_doctest~101 volatile_doctest program~volatile_doctest~101->module~stringifor_string_t program~volatile_doctest~102 volatile_doctest program~volatile_doctest~102->module~stringifor_string_t program~volatile_doctest~103 volatile_doctest program~volatile_doctest~103->module~stringifor_string_t program~volatile_doctest~104 volatile_doctest program~volatile_doctest~104->module~stringifor_string_t program~volatile_doctest~105 volatile_doctest program~volatile_doctest~105->module~stringifor_string_t program~volatile_doctest~106 volatile_doctest program~volatile_doctest~106->module~stringifor_string_t program~volatile_doctest~107 volatile_doctest program~volatile_doctest~107->module~stringifor_string_t program~volatile_doctest~108 volatile_doctest program~volatile_doctest~108->module~stringifor_string_t program~volatile_doctest~109 volatile_doctest program~volatile_doctest~109->module~stringifor_string_t program~volatile_doctest~11 volatile_doctest program~volatile_doctest~11->module~stringifor_string_t program~volatile_doctest~12 volatile_doctest program~volatile_doctest~12->module~stringifor_string_t program~volatile_doctest~13 volatile_doctest program~volatile_doctest~13->module~stringifor_string_t program~volatile_doctest~14 volatile_doctest program~volatile_doctest~14->module~stringifor_string_t program~volatile_doctest~15 volatile_doctest program~volatile_doctest~15->module~stringifor_string_t program~volatile_doctest~16 volatile_doctest program~volatile_doctest~16->module~stringifor_string_t program~volatile_doctest~17 volatile_doctest program~volatile_doctest~17->module~stringifor_string_t program~volatile_doctest~18 volatile_doctest program~volatile_doctest~18->module~stringifor_string_t program~volatile_doctest~19 volatile_doctest program~volatile_doctest~19->module~stringifor_string_t program~volatile_doctest~2 volatile_doctest program~volatile_doctest~2->module~stringifor_string_t program~volatile_doctest~20 volatile_doctest program~volatile_doctest~20->module~stringifor_string_t program~volatile_doctest~21 volatile_doctest program~volatile_doctest~21->module~stringifor_string_t program~volatile_doctest~22 volatile_doctest program~volatile_doctest~22->module~stringifor_string_t program~volatile_doctest~23 volatile_doctest program~volatile_doctest~23->module~stringifor_string_t program~volatile_doctest~24 volatile_doctest program~volatile_doctest~24->module~stringifor_string_t program~volatile_doctest~25 volatile_doctest program~volatile_doctest~25->module~stringifor_string_t program~volatile_doctest~26 volatile_doctest program~volatile_doctest~26->module~stringifor_string_t program~volatile_doctest~27 volatile_doctest program~volatile_doctest~27->module~stringifor_string_t program~volatile_doctest~28 volatile_doctest program~volatile_doctest~28->module~stringifor_string_t program~volatile_doctest~29 volatile_doctest program~volatile_doctest~29->module~stringifor_string_t program~volatile_doctest~3 volatile_doctest program~volatile_doctest~3->module~stringifor_string_t program~volatile_doctest~30 volatile_doctest program~volatile_doctest~30->module~stringifor_string_t program~volatile_doctest~31 volatile_doctest program~volatile_doctest~31->module~stringifor_string_t program~volatile_doctest~32 volatile_doctest program~volatile_doctest~32->module~stringifor_string_t program~volatile_doctest~33 volatile_doctest program~volatile_doctest~33->module~stringifor_string_t program~volatile_doctest~34 volatile_doctest program~volatile_doctest~34->module~stringifor_string_t program~volatile_doctest~35 volatile_doctest program~volatile_doctest~35->module~stringifor_string_t program~volatile_doctest~36 volatile_doctest program~volatile_doctest~36->module~stringifor_string_t program~volatile_doctest~37 volatile_doctest program~volatile_doctest~37->module~stringifor_string_t program~volatile_doctest~38 volatile_doctest program~volatile_doctest~38->module~stringifor_string_t program~volatile_doctest~39 volatile_doctest program~volatile_doctest~39->module~stringifor_string_t program~volatile_doctest~4 volatile_doctest program~volatile_doctest~4->module~stringifor_string_t program~volatile_doctest~40 volatile_doctest program~volatile_doctest~40->module~stringifor_string_t program~volatile_doctest~41 volatile_doctest program~volatile_doctest~41->module~stringifor_string_t program~volatile_doctest~42 volatile_doctest program~volatile_doctest~42->module~stringifor_string_t program~volatile_doctest~43 volatile_doctest program~volatile_doctest~43->module~stringifor_string_t program~volatile_doctest~44 volatile_doctest program~volatile_doctest~44->module~stringifor_string_t program~volatile_doctest~45 volatile_doctest program~volatile_doctest~45->module~stringifor_string_t program~volatile_doctest~46 volatile_doctest program~volatile_doctest~46->module~stringifor_string_t program~volatile_doctest~47 volatile_doctest program~volatile_doctest~47->module~stringifor_string_t program~volatile_doctest~48 volatile_doctest program~volatile_doctest~48->module~stringifor_string_t program~volatile_doctest~49 volatile_doctest program~volatile_doctest~49->module~stringifor_string_t program~volatile_doctest~5 volatile_doctest program~volatile_doctest~5->module~stringifor_string_t program~volatile_doctest~50 volatile_doctest program~volatile_doctest~50->module~stringifor_string_t program~volatile_doctest~51 volatile_doctest program~volatile_doctest~51->module~stringifor_string_t program~volatile_doctest~52 volatile_doctest program~volatile_doctest~52->module~stringifor_string_t program~volatile_doctest~53 volatile_doctest program~volatile_doctest~53->module~stringifor_string_t program~volatile_doctest~54 volatile_doctest program~volatile_doctest~54->module~stringifor_string_t program~volatile_doctest~55 volatile_doctest program~volatile_doctest~55->module~stringifor_string_t program~volatile_doctest~56 volatile_doctest program~volatile_doctest~56->module~stringifor_string_t program~volatile_doctest~57 volatile_doctest program~volatile_doctest~57->module~stringifor_string_t program~volatile_doctest~58 volatile_doctest program~volatile_doctest~58->module~stringifor_string_t program~volatile_doctest~59 volatile_doctest program~volatile_doctest~59->module~stringifor_string_t program~volatile_doctest~6 volatile_doctest program~volatile_doctest~6->module~stringifor_string_t program~volatile_doctest~60 volatile_doctest program~volatile_doctest~60->module~stringifor_string_t program~volatile_doctest~61 volatile_doctest program~volatile_doctest~61->module~stringifor_string_t program~volatile_doctest~62 volatile_doctest program~volatile_doctest~62->module~stringifor_string_t program~volatile_doctest~63 volatile_doctest program~volatile_doctest~63->module~stringifor_string_t program~volatile_doctest~64 volatile_doctest program~volatile_doctest~64->module~stringifor_string_t program~volatile_doctest~65 volatile_doctest program~volatile_doctest~65->module~stringifor_string_t program~volatile_doctest~66 volatile_doctest program~volatile_doctest~66->module~stringifor_string_t program~volatile_doctest~67 volatile_doctest program~volatile_doctest~67->module~stringifor_string_t program~volatile_doctest~68 volatile_doctest program~volatile_doctest~68->module~stringifor_string_t program~volatile_doctest~69 volatile_doctest program~volatile_doctest~69->module~stringifor_string_t program~volatile_doctest~7 volatile_doctest program~volatile_doctest~7->module~stringifor_string_t program~volatile_doctest~70 volatile_doctest program~volatile_doctest~70->module~stringifor_string_t program~volatile_doctest~71 volatile_doctest program~volatile_doctest~71->module~stringifor_string_t program~volatile_doctest~72 volatile_doctest program~volatile_doctest~72->module~stringifor_string_t program~volatile_doctest~73 volatile_doctest program~volatile_doctest~73->module~stringifor_string_t program~volatile_doctest~74 volatile_doctest program~volatile_doctest~74->module~stringifor_string_t program~volatile_doctest~75 volatile_doctest program~volatile_doctest~75->module~stringifor_string_t program~volatile_doctest~76 volatile_doctest program~volatile_doctest~76->module~stringifor_string_t program~volatile_doctest~77 volatile_doctest program~volatile_doctest~77->module~stringifor_string_t program~volatile_doctest~78 volatile_doctest program~volatile_doctest~78->module~stringifor_string_t program~volatile_doctest~79 volatile_doctest program~volatile_doctest~79->module~stringifor_string_t program~volatile_doctest~8 volatile_doctest program~volatile_doctest~8->module~stringifor_string_t program~volatile_doctest~80 volatile_doctest program~volatile_doctest~80->module~stringifor_string_t program~volatile_doctest~81 volatile_doctest program~volatile_doctest~81->module~stringifor_string_t program~volatile_doctest~82 volatile_doctest program~volatile_doctest~82->module~stringifor_string_t program~volatile_doctest~83 volatile_doctest program~volatile_doctest~83->module~stringifor_string_t program~volatile_doctest~84 volatile_doctest program~volatile_doctest~84->module~stringifor_string_t program~volatile_doctest~85 volatile_doctest program~volatile_doctest~85->module~stringifor_string_t program~volatile_doctest~86 volatile_doctest program~volatile_doctest~86->module~stringifor_string_t program~volatile_doctest~87 volatile_doctest program~volatile_doctest~87->module~stringifor_string_t program~volatile_doctest~88 volatile_doctest program~volatile_doctest~88->module~stringifor_string_t program~volatile_doctest~89 volatile_doctest program~volatile_doctest~89->module~stringifor_string_t program~volatile_doctest~9 volatile_doctest program~volatile_doctest~9->module~stringifor_string_t program~volatile_doctest~90 volatile_doctest program~volatile_doctest~90->module~stringifor_string_t program~volatile_doctest~91 volatile_doctest program~volatile_doctest~91->module~stringifor_string_t program~volatile_doctest~92 volatile_doctest program~volatile_doctest~92->module~stringifor_string_t program~volatile_doctest~93 volatile_doctest program~volatile_doctest~93->module~stringifor_string_t program~volatile_doctest~94 volatile_doctest program~volatile_doctest~94->module~stringifor_string_t program~volatile_doctest~95 volatile_doctest program~volatile_doctest~95->module~stringifor_string_t program~volatile_doctest~96 volatile_doctest program~volatile_doctest~96->module~stringifor_string_t program~volatile_doctest~97 volatile_doctest program~volatile_doctest~97->module~stringifor_string_t program~volatile_doctest~98 volatile_doctest program~volatile_doctest~98->module~stringifor_string_t program~volatile_doctest~99 volatile_doctest program~volatile_doctest~99->module~stringifor_string_t program~stringifor_test_csv_naive_parser stringifor_test_csv_naive_parser program~stringifor_test_csv_naive_parser->module~stringifor program~stringifor_test_parse_large_csv stringifor_test_parse_large_csv program~stringifor_test_parse_large_csv->module~stringifor program~volatile_doctest~110 volatile_doctest program~volatile_doctest~110->module~stringifor program~volatile_doctest~111 volatile_doctest program~volatile_doctest~111->module~stringifor

Contents


Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: CK = selected_char_kind('DEFAULT')

Default character kind.

character(kind=CK, len=26), private, parameter :: UPPER_ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

Upper case alphabet.

character(kind=CK, len=26), private, parameter :: LOWER_ALPHABET = 'abcdefghijklmnopqrstuvwxyz'

Lower case alphabet.

character(kind=CK, len=1), private, parameter :: SPACE = ' '

Space character.

character(kind=CK, len=1), private, parameter :: TAB = achar(9)

Tab character.

character(kind=CK, len=1), private, parameter :: UIX_DIR_SEP = char(47)

Unix/Linux directories separator (/).

character(kind=CK, len=1), private, parameter :: BACKSLASH = char(92)

Backslash character.


Interfaces

public interface glob

Overloading glob procedure.

 type(string)                  :: astring
 character(len=:), allocatable :: alist_chr(:)
 type(string),     allocatable :: alist_str(:)
 integer, parameter            :: Nf=5
 character(14)                 :: files(1:Nf)
 integer                       :: file_unit
 integer                       :: f
 integer                       :: ff
 logical                       :: test_passed
 do f=1, Nf
    files(f) = astring%tempname(prefix='foo-')
    open(newunit=file_unit, file=files(f))
    write(file_unit, *)f
    close(unit=file_unit)
 enddo
 call glob(self=astring, pattern='foo-*', list=alist_chr)
 call glob(self=astring, pattern='foo-*', list=alist_str)
 do f=1, Nf
    open(newunit=file_unit, file=files(f))
    close(unit=file_unit, status='delete')
 enddo
 test_passed = .false.
 outer_chr: do f=1, size(alist_chr, dim=1)
    do ff=1, Nf
       test_passed = alist_chr(f) == files(ff)
       if (test_passed) cycle outer_chr
    enddo
 enddo outer_chr
 if (test_passed) then
    test_passed = .false.
    outer_str: do f=1, size(alist_str, dim=1)
       do ff=1, Nf
          test_passed = alist_str(f) == files(ff)
          if (test_passed) cycle outer_str
       enddo
    enddo outer_str
 endif
 print '(L1)', test_passed
  • private subroutine glob_character(self, pattern, list)

    Glob search (character output), finds all the pathnames matching a given pattern according to the rules used by the Unix shell.

     type(string)                  :: astring
     character(len=:), allocatable :: alist_chr(:)
     integer, parameter            :: Nf=5
     character(14)                 :: files(1:Nf)
     integer                       :: file_unit
     integer                       :: f
     integer                       :: ff
     logical                       :: test_passed
     do f=1, Nf
        files(f) = astring%tempname(prefix='foo-')
        open(newunit=file_unit, file=files(f))
        write(file_unit, *)f
        close(unit=file_unit)
     enddo
     call astring%glob(pattern='foo-*', list=alist_chr)
     do f=1, Nf
        open(newunit=file_unit, file=files(f))
        close(unit=file_unit, status='delete')
     enddo
     test_passed = .false.
     outer_chr: do f=1, size(alist_chr, dim=1)
        do ff=1, Nf
           test_passed = alist_chr(f) == files(ff)
           if (test_passed) cycle outer_chr
        enddo
     enddo outer_chr
     print '(L1)', test_passed
    

    Arguments

    Type IntentOptional Attributes Name
    class(string), intent(in) :: self

    The string.

    character(len=*), intent(in) :: pattern

    Given pattern.

    character(len=:), intent(out), allocatable :: list(:)

    List of matching pathnames.

  • private subroutine glob_string(self, pattern, list)

    Glob search (string output), finds all the pathnames matching a given pattern according to the rules used by the Unix shell.

     type(string)                  :: astring
     type(string),     allocatable :: alist_str(:)
     integer, parameter            :: Nf=5
     character(14)                 :: files(1:Nf)
     integer                       :: file_unit
     integer                       :: f
     integer                       :: ff
     logical                       :: test_passed
    
     do f=1, Nf
        files(f) = astring%tempname(prefix='foo-')
        open(newunit=file_unit, file=files(f))
        write(file_unit, *)f
        close(unit=file_unit)
     enddo
     call astring%glob(pattern='foo-*', list=alist_str)
     do f=1, Nf
        open(newunit=file_unit, file=files(f))
        close(unit=file_unit, status='delete')
     enddo
     test_passed = .false.
     outer_str: do f=1, size(alist_str, dim=1)
        do ff=1, Nf
           test_passed = alist_str(f) == files(ff)
           if (test_passed) cycle outer_str
        enddo
     enddo outer_str
     print '(L1)', test_passed
    

    Arguments

    Type IntentOptional Attributes Name
    class(string), intent(in) :: self

    The string.

    character(len=*), intent(in) :: pattern

    Given pattern.

    type(string), intent(out), allocatable :: list(:)

    List of matching pathnames.

public interface strjoin

  • private pure function strjoin_strings(array, sep) result(join)

    Return a string that is a join of an array of strings.

    The join-separator is set equals to a null string ‘’ if custom separator isn’t specified.

     type(string)     :: strings(3)
     logical          :: test_passed(5)
     strings(1) = 'one'
     strings(2) = 'two'
     strings(3) = 'three'
     test_passed(1) = (strjoin(array=strings)//''==strings(1)//strings(2)//strings(3))
     test_passed(2) = (strjoin(array=strings, sep='-')//''==strings(1)//'-'//strings(2)//'-'//strings(3))
     call strings(1)%free
     strings(2) = 'two'
     strings(3) = 'three'
     test_passed(3) = (strjoin(array=strings, sep='-')//''==strings(2)//'-'//strings(3))
     strings(1) = 'one'
     strings(2) = 'two'
     call strings(3)%free
     test_passed(4) = (strjoin(array=strings, sep='-')//''==strings(1)//'-'//strings(2))
     strings(1) = 'one'
     call strings(2)%free
     strings(3) = 'three'
     test_passed(5) = (strjoin(array=strings, sep='-')//''==strings(1)//'-'//strings(3))
     print '(L1)', all(test_passed)
    

    Arguments

    Type IntentOptional Attributes Name
    class(string), intent(in) :: array(1:)

    Array to be joined.

    character(kind=CK, len=*), intent(in), optional :: sep

    Separator.

    Return Value type(string)

    The join of array.

  • private pure function strjoin_characters(array, sep, is_trim) result(join)

    Return a string that is a join of an array of characters.

    The join-separator is set equals to a null string ‘’ if custom separator isn’t specified. The trim function is applied to array items if optional logical is_trim variable isn’t set to .false.

     character(5) :: characters(3)
     logical      :: test_passed(13)
     characters(1) = 'one'
     characters(2) = 'two'
     characters(3) = 'three'
     test_passed(1) = (strjoin(array=characters)//''==trim(characters(1))//trim(characters(2))//trim(characters(3)))
     test_passed(2) = (strjoin(array=characters, sep='-')//''==trim(characters(1))//'-'//trim(characters(2))//'-'//trim(characters(3)))
     test_passed(3) = ( strjoin(array=characters, is_trim=.false.)//''==characters(1)//characters(2)//characters(3))
     test_passed(4) = ( strjoin(array=characters, sep='-', is_trim=.false.)//''==characters(1)//'-'//characters(2)//'-'//characters(3))
     characters(1) = ''
     characters(2) = 'two'
     characters(3) = 'three'
     test_passed(5) = (strjoin(array=characters)//''==trim(characters(2))//trim(characters(3)))
     characters(1) = 'one'
     characters(2) = 'two'
     characters(3) = ''
     test_passed(6) = (strjoin(array=characters)//''==trim(characters(1))//trim(characters(2)))
     characters(1) = 'one'
     characters(2) = ''
     characters(3) = 'three'
     test_passed(7) = (strjoin(array=characters)//''==trim(characters(1))//trim(characters(3)))
     characters(1) = ''
     characters(2) = 'two'
     characters(3) = 'three'
     test_passed(8) = (strjoin(array=characters, sep='-')//''==trim(characters(2))//'-'//trim(characters(3)))
     characters(1) = 'one'
     characters(2) = 'two'
     characters(3) = ''
     test_passed(9) = (strjoin(array=characters, sep='-')//''==trim(characters(1))//'-'//trim(characters(2)))
     characters(1) = 'one'
     characters(2) = ''
     characters(3) = 'three'
     test_passed(10) = (strjoin(array=characters, sep='-')//''==trim(characters(1))//'-'//trim(characters(3)))
     characters(1) = ''
     characters(2) = 'two'
     characters(3) = 'three'
     test_passed(11) = (strjoin(array=characters, sep='-', is_trim=.false.)//''==characters(2)//'-'//characters(3))
     characters(1) = 'one'
     characters(2) = 'two'
     characters(3) = ''
     test_passed(12) = (strjoin(array=characters, sep='-', is_trim=.false.)//''==characters(1)//'-'//characters(2))
     characters(1) = 'one'
     characters(2) = ''
     characters(3) = 'three'
     test_passed(13) = (strjoin(array=characters, sep='-', is_trim=.false.)//''==characters(1)//'-'//characters(3))
     print '(L1)', all(test_passed)
    

    Arguments

    Type IntentOptional Attributes Name
    character(kind=CK, len=*), intent(in) :: array(1:)

    Array to be joined.

    character(kind=CK, len=*), intent(in), optional :: sep

    Separator.

    logical, intent(in), optional :: is_trim

    Flag to setup trim character or not

    Return Value type(string)

    The join of array.

  • private pure function strjoin_strings_array(array, sep, is_col) result(join)

    Return a string that is a join of columns or rows of an array of strings.

    The join-separator is set equals to a null string ‘’ if custom separator isn’t specified. The is_col is setup the direction of join: within default columns (.true.) or rows(.false.).

     type(string), allocatable :: strings_arr(:, :)
     logical                   :: test_passed(5)
    
     strings_arr = reshape( source = &
                            [string('one'), string('two'), string('three'),  &
                             string('ONE'), string('TWO'), string('THREE')], &
                            shape = [3, 2] )
    
     test_passed(1) = all( strjoin(array=strings_arr) == &
                           reshape([string('onetwothree'), string('ONETWOTHREE')], &
                           shape = [2]) )
    
     test_passed(2) = all( strjoin(array=strings_arr, sep='_') == &
                           reshape([string('one_two_three'), string('ONE_TWO_THREE')], &
                           shape = [2]) )
    
      test_passed(3) = all( strjoin(array=strings_arr, is_col=.false.) == &
                            reshape([string('oneONE'), string('twoTWO'), string('threeTHREE')], &
                            shape = [3]) )
    
      test_passed(4) = all( strjoin(array=strings_arr, sep='_', is_col=.false.) == &
                            reshape([string('one_ONE'), string('two_TWO'), string('three_THREE')], &
                            shape = [3]) )
    
     call strings_arr(2, 1)%free
     test_passed(5) = all( strjoin(array=strings_arr, sep='_', is_col=.false.) == &
                      reshape([string('one_ONE'), string('TWO'), string('three_THREE')], &
                      shape = [3]) )
    
     print '(L1)', all(test_passed)
    

    Arguments

    Type IntentOptional Attributes Name
    class(string), intent(in) :: array(1:,1:)

    Array to be joined.

    character(kind=CK, len=*), intent(in), optional :: sep

    Separator.

    logical, intent(in), optional :: is_col

    Direction: ‘columns’ if .true. or ‘rows’ if .false.

    Return Value type(string), allocatable, (:)

    The join of array.

  • private pure function strjoin_characters_array(array, sep, is_trim, is_col) result(join)

    Return a string that is a join of columns or rows of an array of characters.

    The join-separator is set equals to a null string ‘’ if custom separator isn’t specified. The trim function is applied to array items if optional logical is_trim variable isn’t set to .false. The is_col is setup the direction of join: within default columns (.true.) or rows(.false.).

     character(len=10)         :: chars_arr(3, 2)
     logical                   :: test_passed(9)
     chars_arr(:, 1) = ['one       ', 'two       ', 'three     ']
     chars_arr(:, 2) = ['ONE       ', 'TWO       ', 'THREE     ']
    
     test_passed(1) = all( strjoin(array=chars_arr) == &
                           reshape([string('onetwothree'), string('ONETWOTHREE')], &
                           shape = [2]) )
    
     test_passed(2) = all( strjoin(array=chars_arr, is_trim=.false.) ==  &
                           reshape([string('one       two       three     '),  &
                                    string('ONE       TWO       THREE     ')], &
                           shape = [2]) )
    
     test_passed(3) = all( strjoin(array=chars_arr, sep='_') == &
                           reshape([string('one_two_three'), string('ONE_TWO_THREE')], &
                           shape = [2]) )
    
     test_passed(4) = all( strjoin(array=chars_arr, sep='_', is_trim=.false.) ==  &
                           reshape([string('one       _two       _three     '),  &
                                    string('ONE       _TWO       _THREE     ')], &
                           shape = [2]) )
    
     test_passed(5) = all( strjoin(array=chars_arr, is_col=.false.) == &
                           reshape([string('oneONE'), string('twoTWO'), string('threeTHREE')], &
                           shape = [3]) )
    
     test_passed(6) = all( strjoin(array=chars_arr, is_trim=.false., is_col=.false.) ==  &
                           reshape([string('one       ONE       '),  &
                                    string('two       TWO       '),  &
                                    string('three     THREE     ')], &
                           shape = [3]) )
    
     test_passed(7) = all( strjoin(array=chars_arr, sep='_', is_col=.false.) == &
                           reshape([string('one_ONE'), string('two_TWO'), string('three_THREE')], &
                           shape = [3]) )
    
     test_passed(8) = all( strjoin(array=chars_arr, sep='_', is_trim=.false., is_col=.false.) ==  &
                           reshape([string('one       _ONE       '),  &
                                    string('two       _TWO       '),  &
                                    string('three     _THREE     ')], &
                           shape = [3]) )
    
     chars_arr(2,1) = ''
     test_passed(9) = all( strjoin(array=chars_arr, sep='_', is_col=.false.) ==  &
                           reshape([string('one_ONE'),  &
                                    string('TWO'),  &
                                    string('three_THREE')], &
                           shape = [3]) )
    
     print '(L1)', all(test_passed)
    

    all items of character array have equal lengths

    Arguments

    Type IntentOptional Attributes Name
    character(kind=CK, len=*), intent(in) :: array(1:,1:)

    Array to be joined.

    character(kind=CK, len=*), intent(in), optional :: sep

    Separator.

    logical, intent(in), optional :: is_trim

    Flag to setup trim character or not

    logical, intent(in), optional :: is_col

    Direction: ‘columns’ if .true. or ‘rows’ if .false.

    Return Value type(string), allocatable, (:)

    The join of array.

public interface adjustl

Builtin adjustl overloading.

  • private pure function sadjustl_character(s) result(adjusted)

    Left adjust a string by removing leading spaces (character output).

     type(string) :: astring
     astring = '   Hello World!'
     print "(L1)", adjustl(astring)=='Hello World!   '
    

    Arguments

    Type IntentOptional Attributes Name
    class(string), intent(in) :: s

    String.

    Return Value character(kind=CK, len=:), allocatable

    Adjusted string.

public interface adjustr

Builtin adjustr overloading.

  • private pure function sadjustr_character(s) result(adjusted)

    Right adjust a string by removing leading spaces (character output).

     type(string) :: astring
     astring = 'Hello World!   '
     print "(L1)", adjustr(astring)=='   Hello World!'
    

    Arguments

    Type IntentOptional Attributes Name
    class(string), intent(in) :: s

    String.

    Return Value character(kind=CK, len=:), allocatable

    Adjusted string.

public interface count

Builtin count overloading.

  • private elemental function count_substring(s, substring) result(No)

    Count the number of occurences of a substring into a string.

     print "(L1)", count('hello', substring='ll')==1
    

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: s

    String.

    character(len=*), intent(in) :: substring

    Substring.

    Return Value integer(kind=I4P)

    Number of occurrences.

public interface index

Builtin index overloading.

  • private elemental function sindex_string_string(self, substring, back) result(i)

    Return the position of the start of the first occurrence of string substring as a substring in string, counting from one. If substring is not present in string, zero is returned. If the back argument is present and true, the return value is the start of the last occurrence rather than the first.

     type(string) :: string1
     type(string) :: string2
     logical      :: test_passed(2)
     string1 = 'Hello World Hello!'
     string2 = 'llo'
     test_passed(1) = string1%index(substring=string2)==index(string='Hello World Hello!', substring='llo')
     test_passed(2) = string1%index(substring=string2, back=.true.)==index(string='Hello World Hello!', substring='llo', &
                                                                           back=.true.)
     print '(L1)', all(test_passed)
    

    Arguments

    Type IntentOptional Attributes Name
    class(string), intent(in) :: self

    The string.

    type(string), intent(in) :: substring

    Searched substring.

    logical, intent(in), optional :: back

    Start of the last occurrence rather than the first.

    Return Value integer

    Result of the search.

  • private elemental function sindex_string_character(self, substring, back) result(i)

    Return the position of the start of the first occurrence of string substring as a substring in string, counting from one. If substring is not present in string, zero is returned. If the back argument is present and true, the return value is the start of the last occurrence rather than the first.

     type(string) :: string1
     logical      :: test_passed(2)
     string1 = 'Hello World Hello!'
     test_passed(1) = string1%index(substring='llo')==index(string='Hello World Hello!', substring='llo')
     test_passed(2) = string1%index(substring='llo', back=.true.)==index(string='Hello World Hello!', substring='llo', back=.true.)
     print '(L1)', all(test_passed)
    

    Arguments

    Type IntentOptional Attributes Name
    class(string), intent(in) :: self

    The string.

    character(kind=CK, len=*), intent(in) :: substring

    Searched substring.

    logical, intent(in), optional :: back

    Start of the last occurrence rather than the first.

    Return Value integer

    Result of the search.

  • private elemental function sindex_character_string(s, substring, back) result(i)

    Return the position of the start of the first occurrence of string substring as a substring in string, counting from one. If substring is not present in string, zero is returned. If the back argument is present and true, the return value is the start of the last occurrence rather than the first.

     type(string) :: string1
     logical      :: test_passed(2)
     string1 = 'llo'
     test_passed(1) = index(s='Hello World Hello!', substring=string1)==index(string='Hello World Hello!', substring='llo')
     test_passed(2) = index(s='Hello World Hello!', substring=string1, back=.true.)==index(string='Hello World Hello!', &
                                                                                           substring='llo', back=.true.)
     print '(L1)', all(test_passed)
    

    Arguments

    Type IntentOptional Attributes Name
    character(kind=CK, len=*), intent(in) :: s

    String.

    type(string), intent(in) :: substring

    Searched substring.

    logical, intent(in), optional :: back

    Start of the last occurrence rather than the first.

    Return Value integer

    Result of the search.

public interface len_trim

Builtin len_trim overloading.

  • private elemental function slen_trim(self) result(l)

    Return the length of a string, ignoring any trailing blanks.

     type(string) :: astring
     astring = 'Hello World!   '
     print "(L1)", astring%len_trim()==len_trim('Hello World!   ')
    

    Arguments

    Type IntentOptional Attributes Name
    class(string), intent(in) :: self

    The string.

    Return Value integer

    String length.

public interface repeat

Builtin repeat overloading.

  • private elemental function srepeat_string_string(self, ncopies) result(repeated)

    Concatenates several copies of an input string.

     type(string) :: astring
     astring = 'x'
     print "(L1)", astring%repeat(5)//''=='xxxxx'
    

    Arguments

    Type IntentOptional Attributes Name
    class(string), intent(in) :: self

    String to be repeated.

    integer, intent(in) :: ncopies

    Number of string copies.

    Return Value type(string)

    Repeated string.

public interface scan

Builtin scan overloading.

  • private elemental function sscan_string_string(self, set, back) result(i)

    Return the leftmost (if back is either absent or equals false, otherwise the rightmost) character of string that is in set.

     type(string) :: string1
     type(string) :: string2
     logical      :: test_passed(2)
     string1 = 'Hello World Hello!'
     string2 = 'llo'
     test_passed(1) = string1%scan(set=string2)==scan(string='Hello World Hello!', set='llo')
     test_passed(2) = string1%scan(set=string2, back=.true.)==scan(string='Hello World Hello!', set='llo', back=.true.)
     print '(L1)', all(test_passed)
    

    Arguments

    Type IntentOptional Attributes Name
    class(string), intent(in) :: self

    The string.

    type(string), intent(in) :: set

    Searched set.

    logical, intent(in), optional :: back

    Start of the last occurrence rather than the first.

    Return Value integer

    Result of the search.

  • private elemental function sscan_string_character(self, set, back) result(i)

    Return the leftmost (if back is either absent or equals false, otherwise the rightmost) character of string that is in set.

     type(string) :: string1
     logical      :: test_passed(2)
     string1 = 'Hello World Hello!'
     test_passed(1) = string1%scan(set='llo')==scan(string='Hello World Hello!', set='llo')
     test_passed(2) = string1%scan(set='llo', back=.true.)==scan(string='Hello World Hello!', set='llo', back=.true.)
     print '(L1)', all(test_passed)
    

    Arguments

    Type IntentOptional Attributes Name
    class(string), intent(in) :: self

    The string.

    character(kind=CK, len=*), intent(in) :: set

    Searched set.

    logical, intent(in), optional :: back

    Start of the last occurrence rather than the first.

    Return Value integer

    Result of the search.

  • private elemental function sscan_character_string(s, set, back) result(i)

    Return the leftmost (if back is either absent or equals false, otherwise the rightmost) character of string that is in set.

     type(string) :: string1
     logical      :: test_passed(2)
     string1 = 'llo'
     test_passed(1) = scan(s='Hello World Hello!', set=string1)==scan(string='Hello World Hello!', set='llo')
     test_passed(2) = scan(s='Hello World Hello!', set=string1, back=.true.)==scan(string='Hello World Hello!', &
                                                                                   set='llo', back=.true.)
     print '(L1)', all(test_passed)
    

    Arguments

    Type IntentOptional Attributes Name
    character(kind=CK, len=*), intent(in) :: s

    String.

    type(string), intent(in) :: set

    Searched set.

    logical, intent(in), optional :: back

    Start of the last occurrence rather than the first.

    Return Value integer

    Result of the search.

public interface trim

Builtin trim overloading.

  • private elemental function strim(self) result(trimmed)

    Remove trailing spaces.

     type(string) :: astring
     astring = 'Hello World!   '
     print "(L1)", astring%trim()==trim('Hello World!   ')
    

    Arguments

    Type IntentOptional Attributes Name
    class(string), intent(in) :: self

    The string.

    Return Value type(string)

    Trimmed string.

public interface verify

Builtin verify overloading.

  • private elemental function sverify_string_string(self, set, back) result(i)

    Return the leftmost (if back is either absent or equals false, otherwise the rightmost) character of string that is not in set. If all characters of string are found in set, the result is zero.

     type(string) :: string1
     type(string) :: string2
     logical      :: test_passed(2)
     string1 = 'Hello World Hello!'
     string2 = 'llo'
     test_passed(1) = string1%verify(set=string2)==verify(string='Hello World Hello!', set='llo')
     test_passed(2) = string1%verify(set=string2, back=.true.)==verify(string='Hello World Hello!', set='llo', back=.true.)
     print '(L1)', all(test_passed)
    

    Arguments

    Type IntentOptional Attributes Name
    class(string), intent(in) :: self

    The string.

    type(string), intent(in) :: set

    Searched set.

    logical, intent(in), optional :: back

    Start of the last occurrence rather than the first.

    Return Value integer

    Result of the search.

  • private elemental function sverify_string_character(self, set, back) result(i)

    Return the leftmost (if back is either absent or equals false, otherwise the rightmost) character of string that is not in set. If all characters of string are found in set, the result is zero.

     type(string) :: string1
     logical      :: test_passed(2)
     string1 = 'Hello World Hello!'
     test_passed(1) = string1%verify(set='llo')==verify(string='Hello World Hello!', set='llo')
     test_passed(2) = string1%verify(set='llo', back=.true.)==verify(string='Hello World Hello!', set='llo', back=.true.)
     print '(L1)', all(test_passed)
    

    Arguments

    Type IntentOptional Attributes Name
    class(string), intent(in) :: self

    The string.

    character(kind=CK, len=*), intent(in) :: set

    Searched set.

    logical, intent(in), optional :: back

    Start of the last occurrence rather than the first.

    Return Value integer

    Result of the search.

  • private elemental function sverify_character_string(s, set, back) result(i)

    Return the leftmost (if back is either absent or equals false, otherwise the rightmost) character of string that is not in set. If all characters of string are found in set, the result is zero.

     type(string) :: string1
     logical      :: test_passed(2)
     string1 = 'ell'
     test_passed(1) = verify(s='Hello World Hello!', set=string1)==verify(string='Hello World Hello!', set='llo')
     test_passed(2) = verify(s='Hello World Hello!', set=string1, back=.true.)==verify(string='Hello World Hello!', set='llo', &
                                                                                       back=.true.)
     print '(L1)', all(test_passed)
    

    Arguments

    Type IntentOptional Attributes Name
    character(kind=CK, len=*), intent(in) :: s

    String.

    type(string), intent(in) :: set

    Searched set.

    logical, intent(in), optional :: back

    Start of the last occurrence rather than the first.

    Return Value integer

    Result of the search.


Derived Types

type, public ::  string

OOP designed string class.

Components

Type Visibility Attributes Name Initial
character(kind=CK, len=:), public, allocatable :: raw

Raw data.

Type-Bound Procedures

procedure , public , pass(self) :: adjustl => sadjustl Function

Adjustl replacement.

procedure , public , pass(self) :: adjustr => sadjustr Function

Adjustr replacement.

procedure , public , pass(self) :: count => scount Function

Count replacement.

generic, public , :: index => sindex_string_string, sindex_string_character

Index replacement.

procedure , public , pass(self) :: len => slen Function

Len replacement.

procedure , public , pass(self) :: len_trim => slen_trim Function

Len_trim replacement.

generic, public , :: repeat => srepeat_string_string, srepeat_character_string

Repeat replacement.

generic, public , :: scan => sscan_string_string, sscan_string_character

Scan replacement.

procedure , public , pass(self) :: trim => strim Function

Trim replacement.

generic, public , :: verify => sverify_string_string, sverify_string_character

Verify replacement.

procedure , public , pass(self) :: basedir Function

Return the base directory name of a string containing a file name.

procedure , public , pass(self) :: basename Function

Return the base file name of a string containing a file name.

procedure , public , pass(self) :: camelcase Function

Return a string with all words capitalized without spaces.

procedure , public , pass(self) :: capitalize Function

Return a string with its first character capitalized and the rest lowercased.

procedure , public , pass(self) :: chars Function

Return the raw characters data.

generic, public , :: colorize => colorize_str

Colorize and stylize strings.

procedure , public , pass(self) :: decode Function

Decode string.

procedure , public , pass(self) :: encode Function

Encode string.

procedure , public , pass(self) :: escape Function

Escape backslashes (or custom escape character).

procedure , public , pass(self) :: extension Function

Return the extension of a string containing a file name.

procedure , public , pass(self) :: fill Function

Pad string on the left (or right) with zeros (or other char) to fill width.

procedure , public , pass(self) :: free Subroutine

Free dynamic memory.

generic, public , :: glob => glob_character, glob_string

Glob search, finds all the pathnames matching a given pattern.

generic, public , :: insert => insert_string, insert_character

Insert substring into string at a specified position.

generic, public , :: join => join_strings, join_characters

Return a string that is a join of an array of strings or characters.

generic, public , :: strjoin => strjoin_strings, strjoin_characters, strjoin_strings_array, strjoin_characters_array

Return a string that is a join of an array of strings or characters; Return join 1D string array of an 2D array of strings or characters in columns or rows.

procedure , public , pass(self) :: lower Function

Return a string with all lowercase characters.

procedure , public , pass(self) :: partition Function

Split string at separator and return the 3 parts (before, the separator and after).

procedure , public , pass(self) :: read_file Subroutine

Read a file a single string stream.

procedure , public , pass(self) :: read_line Subroutine

Read line (record) from a connected unit.

procedure , public , pass(self) :: read_lines Subroutine

Read (all) lines (records) from a connected unit as a single ascii stream.

procedure , public , pass(self) :: replace Function

Return a string with all occurrences of substring old replaced by new.

procedure , public , pass(self) :: reverse Function

Return a reversed string.

procedure , public , pass(self) :: search Function

Search for tagged record into string.

procedure , public , pass(self) :: slice Function

Return the raw characters data sliced.

procedure , public , pass(self) :: snakecase Function

Return a string with all words lowercase separated by “_”.

procedure , public , pass(self) :: split Subroutine

Return a list of substring in the string, using sep as the delimiter string.

procedure , public , pass(self) :: split_chunked Subroutine

Return a list of substring in the string, using sep as the delimiter string.

procedure , public , pass(self) :: startcase Function

Return a string with all words capitalized, e.g. title case.

procedure , public , pass(self) :: strip Function

Return a string with the leading and trailing characters removed.

procedure , public , pass(self) :: swapcase Function

Return a string with uppercase chars converted to lowercase and vice versa.

procedure , public , pass(self) :: tempname Function

Return a safe temporary name suitable for temporary file or directories.

generic, public , :: to_number => to_integer_I1P, to_integer_I2P, to_integer_I4P, to_integer_I8P, to_real_R8P, to_real_R4P

Cast string to number.

procedure , public , pass(self) :: unescape Function

Unescape double backslashes (or custom escaped character).

procedure , public , pass(self) :: unique Function

Reduce to one (unique) multiple occurrences of a substring into a string.

procedure , public , pass(self) :: upper Function

Return a string with all uppercase characters.

procedure , public , pass(self) :: write_file Subroutine

Write a single string stream into file.

procedure , public , pass(self) :: write_line Subroutine

Write line (record) to a connected unit.

procedure , public , pass(self) :: write_lines Subroutine

Write lines (records) to a connected unit.

procedure , public , pass(self) :: end_with Function

Return true if a string ends with a specified suffix.

procedure , public , pass(self) :: is_allocated Function

Return true if the string is allocated.

procedure , public , pass(self) :: is_digit Function

Return true if all characters in the string are digits.

procedure , public , pass(self) :: is_integer Function

Return true if the string contains an integer.

procedure , public , pass(self) :: is_lower Function

Return true if all characters in the string are lowercase.

procedure , public , pass(self) :: is_number Function

Return true if the string contains a number (real or integer).

procedure , public , pass(self) :: is_real Function

Return true if the string contains an real.

procedure , public , pass(self) :: is_upper Function

Return true if all characters in the string are uppercase.

procedure , public , pass(self) :: start_with Function

Return true if a string starts with a specified prefix.

generic, public , :: assignment(=) => string_assign_string, string_assign_character, string_assign_integer_I1P, string_assign_integer_I2P, string_assign_integer_I4P, string_assign_integer_I8P, string_assign_real_R8P, string_assign_real_R4P

Assignment operator overloading.

generic, public , :: operator(//) => string_concat_string, string_concat_character, character_concat_string

Concatenation operator overloading.

generic, public , :: operator(.cat.) => string_concat_string_string, string_concat_character_string, character_concat_string_string

Concatenation operator (string output) overloading.

generic, public , :: operator(==) => string_eq_string, string_eq_character, character_eq_string

Equal operator overloading.

generic, public , :: operator(/=) => string_ne_string, string_ne_character, character_ne_string

Not equal operator overloading.

generic, public , :: operator(<) => string_lt_string, string_lt_character, character_lt_string

Lower than operator overloading.

generic, public , :: operator(<=) => string_le_string, string_le_character, character_le_string

Lower equal than operator overloading.

generic, public , :: operator(>=) => string_ge_string, string_ge_character, character_ge_string

Greater equal than operator overloading.

generic, public , :: operator(>) => string_gt_string, string_gt_character, character_gt_string

Greater than operator overloading.

generic, public , :: read(formatted) => read_formatted

Formatted input.

generic, public , :: write(formatted) => write_formatted

Formatted output.

generic, public , :: read(unformatted) => read_unformatted

Unformatted input.

generic, public , :: write(unformatted) => write_unformatted

Unformatted output.

procedure , private , pass(self) :: sindex_string_string Function

Index replacement.

procedure , private , pass(self) :: sindex_string_character Function

Index replacement.

procedure , private , pass(self) :: srepeat_string_string Function

Repeat replacement.

procedure , private , nopass :: srepeat_character_string Function

Repeat replacement.

procedure , private , pass(self) :: sscan_string_string Function

Scan replacement.

procedure , private , pass(self) :: sscan_string_character Function

Scan replacement.

procedure , private , pass(self) :: sverify_string_string Function

Verify replacement.

procedure , private , pass(self) :: sverify_string_character Function

Verify replacement.

procedure , private , pass(self) :: colorize_str Function

Colorize and stylize strings.

procedure , private , pass(self) :: glob_character Subroutine

Glob search (character output).

procedure , private , pass(self) :: glob_string Subroutine

Glob search (string output).

procedure , private , pass(self) :: insert_string Function

Insert substring into string at a specified position.

procedure , private , pass(self) :: insert_character Function

Insert substring into string at a specified position.

procedure , private , pass(self) :: join_strings Function

Return join string of an array of strings.

procedure , private , pass(self) :: join_characters Function

Return join string of an array of characters.

procedure , private , nopass :: strjoin_strings Function

Return join string of an array of strings.

procedure , private , nopass :: strjoin_characters Function

Return join string of an array of strings.

procedure , private , nopass :: strjoin_strings_array Function

Return join 1D string array of an 2D array of strings in columns or rows.

procedure , private , nopass :: strjoin_characters_array Function

Return join 1D string array of an 2D array of characters in columns or rows.

procedure , private , pass(self) :: to_integer_I1P Function

Cast string to integer.

procedure , private , pass(self) :: to_integer_I2P Function

Cast string to integer.

procedure , private , pass(self) :: to_integer_I4P Function

Cast string to integer.

procedure , private , pass(self) :: to_integer_I8P Function

Cast string to integer.

procedure , private , pass(self) :: to_real_R4P Function

Cast string to real.

procedure , private , pass(self) :: to_real_R8P Function

Cast string to real.

procedure , private , pass(self) :: to_real_R16P Function

Cast string to real.

procedure , private , pass(lhs) :: string_assign_string Subroutine

Assignment operator from string input.

procedure , private , pass(lhs) :: string_assign_character Subroutine

Assignment operator from character input.

procedure , private , pass(lhs) :: string_assign_integer_I1P Subroutine

Assignment operator from integer input.

procedure , private , pass(lhs) :: string_assign_integer_I2P Subroutine

Assignment operator from integer input.

procedure , private , pass(lhs) :: string_assign_integer_I4P Subroutine

Assignment operator from integer input.

procedure , private , pass(lhs) :: string_assign_integer_I8P Subroutine

Assignment operator from integer input.

procedure , private , pass(lhs) :: string_assign_real_R4P Subroutine

Assignment operator from real input.

procedure , private , pass(lhs) :: string_assign_real_R8P Subroutine

Assignment operator from real input.

procedure , private , pass(lhs) :: string_assign_real_R16P Subroutine

Assignment operator from real input.

procedure , private , pass(lhs) :: string_concat_string Function

Concatenation with string.

procedure , private , pass(lhs) :: string_concat_character Function

Concatenation with character.

procedure , private , pass(rhs) :: character_concat_string Function

Concatenation with character (inverted).

procedure , private , pass(lhs) :: string_concat_string_string Function

Concatenation with string (string output).

procedure , private , pass(lhs) :: string_concat_character_string Function

Concatenation with character (string output).

procedure , private , pass(rhs) :: character_concat_string_string Function

Concatenation with character (inverted, string output).

procedure , private , pass(lhs) :: string_eq_string Function

Equal to string logical operator.

procedure , private , pass(lhs) :: string_eq_character Function

Equal to character logical operator.

procedure , private , pass(rhs) :: character_eq_string Function

Equal to character (inverted) logical operator.

procedure , private , pass(lhs) :: string_ne_string Function

Not equal to string logical operator.

procedure , private , pass(lhs) :: string_ne_character Function

Not equal to character logical operator.

procedure , private , pass(rhs) :: character_ne_string Function

Not equal to character (inverted) logical operator.

procedure , private , pass(lhs) :: string_lt_string Function

Lower than to string logical operator.

procedure , private , pass(lhs) :: string_lt_character Function

Lower than to character logical operator.

procedure , private , pass(rhs) :: character_lt_string Function

Lower than to character (inverted) logical operator.

procedure , private , pass(lhs) :: string_le_string Function

Lower equal than to string logical operator.

procedure , private , pass(lhs) :: string_le_character Function

Lower equal than to character logical operator.

procedure , private , pass(rhs) :: character_le_string Function

Lower equal than to character (inverted) logical operator.

procedure , private , pass(lhs) :: string_ge_string Function

Greater equal than to string logical operator.

procedure , private , pass(lhs) :: string_ge_character Function

Greater equal than to character logical operator.

procedure , private , pass(rhs) :: character_ge_string Function

Greater equal than to character (inverted) logical operator.

procedure , private , pass(lhs) :: string_gt_string Function

Greater than to string logical operator.

procedure , private , pass(lhs) :: string_gt_character Function

Greater than to character logical operator.

procedure , private , pass(rhs) :: character_gt_string Function

Greater than to character (inverted) logical operator.

procedure , private , pass(dtv) :: read_formatted Subroutine

Formatted input.

procedure , private , pass(dtv) :: read_delimited Subroutine

Read a delimited input.

procedure , private , pass(dtv) :: read_undelimited Subroutine

Read an undelimited input.

procedure , private , pass(dtv) :: read_undelimited_listdirected Subroutine

Read an undelimited list directed input.

procedure , private , pass(dtv) :: write_formatted Subroutine

Formatted output.

procedure , private , pass(dtv) :: read_unformatted Subroutine

Unformatted input.

procedure , private , pass(dtv) :: write_unformatted Subroutine

Unformatted output.

procedure , private , pass(self) :: replace_one_occurrence Function

Replace the first occurrence of substring old by new.


Functions

private pure function string_(c)

Return a string given a character input.

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: c

Character.

Return Value type(string)

String.

private pure function sadjustl_character(s) result(adjusted)

Left adjust a string by removing leading spaces (character output).

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: s

String.

Return Value character(kind=CK, len=:), allocatable

Adjusted string.

private pure function sadjustr_character(s) result(adjusted)

Right adjust a string by removing leading spaces (character output).

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: s

String.

Return Value character(kind=CK, len=:), allocatable

Adjusted string.

private elemental function count_substring(s, substring) result(No)

Count the number of occurences of a substring into a string.

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: s

String.

character(len=*), intent(in) :: substring

Substring.

Return Value integer(kind=I4P)

Number of occurrences.

private elemental function sindex_character_string(s, substring, back) result(i)

Return the position of the start of the first occurrence of string substring as a substring in string, counting from one. If substring is not present in string, zero is returned. If the back argument is present and true, the return value is the start of the last occurrence rather than the first.

Read more…

Arguments

Type IntentOptional Attributes Name
character(kind=CK, len=*), intent(in) :: s

String.

type(string), intent(in) :: substring

Searched substring.

logical, intent(in), optional :: back

Start of the last occurrence rather than the first.

Return Value integer

Result of the search.

private elemental function sscan_character_string(s, set, back) result(i)

Return the leftmost (if back is either absent or equals false, otherwise the rightmost) character of string that is in set.

Read more…

Arguments

Type IntentOptional Attributes Name
character(kind=CK, len=*), intent(in) :: s

String.

type(string), intent(in) :: set

Searched set.

logical, intent(in), optional :: back

Start of the last occurrence rather than the first.

Return Value integer

Result of the search.

private elemental function sverify_character_string(s, set, back) result(i)

Return the leftmost (if back is either absent or equals false, otherwise the rightmost) character of string that is not in set. If all characters of string are found in set, the result is zero.

Read more…

Arguments

Type IntentOptional Attributes Name
character(kind=CK, len=*), intent(in) :: s

String.

type(string), intent(in) :: set

Searched set.

logical, intent(in), optional :: back

Start of the last occurrence rather than the first.

Return Value integer

Result of the search.

private elemental function sadjustl(self) result(adjusted)

Left adjust a string by removing leading spaces.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

Return Value type(string)

Adjusted string.

private elemental function sadjustr(self) result(adjusted)

Right adjust a string by removing leading spaces.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

Return Value type(string)

Adjusted string.

private elemental function scount(self, substring, ignore_isolated) result(No)

Count the number of occurences of a substring into a string.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(len=*), intent(in) :: substring

Substring.

logical, intent(in), optional :: ignore_isolated

Ignore “isolated” occurrences.

Return Value integer

Number of occurrences.

private elemental function sindex_string_string(self, substring, back) result(i)

Return the position of the start of the first occurrence of string substring as a substring in string, counting from one. If substring is not present in string, zero is returned. If the back argument is present and true, the return value is the start of the last occurrence rather than the first.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

type(string), intent(in) :: substring

Searched substring.

logical, intent(in), optional :: back

Start of the last occurrence rather than the first.

Return Value integer

Result of the search.

private elemental function sindex_string_character(self, substring, back) result(i)

Return the position of the start of the first occurrence of string substring as a substring in string, counting from one. If substring is not present in string, zero is returned. If the back argument is present and true, the return value is the start of the last occurrence rather than the first.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(kind=CK, len=*), intent(in) :: substring

Searched substring.

logical, intent(in), optional :: back

Start of the last occurrence rather than the first.

Return Value integer

Result of the search.

private elemental function slen(self) result(l)

Return the length of a string.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

Return Value integer

String length.

private elemental function slen_trim(self) result(l)

Return the length of a string, ignoring any trailing blanks.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

Return Value integer

String length.

private elemental function srepeat_string_string(self, ncopies) result(repeated)

Concatenates several copies of an input string.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

String to be repeated.

integer, intent(in) :: ncopies

Number of string copies.

Return Value type(string)

Repeated string.

private elemental function srepeat_character_string(rstring, ncopies) result(repeated)

Concatenates several copies of an input string.

Read more…

Arguments

Type IntentOptional Attributes Name
character(kind=CK, len=*), intent(in) :: rstring

String to be repeated.

integer, intent(in) :: ncopies

Number of string copies.

Return Value type(string)

Repeated string.

private elemental function sscan_string_string(self, set, back) result(i)

Return the leftmost (if back is either absent or equals false, otherwise the rightmost) character of string that is in set.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

type(string), intent(in) :: set

Searched set.

logical, intent(in), optional :: back

Start of the last occurrence rather than the first.

Return Value integer

Result of the search.

private elemental function sscan_string_character(self, set, back) result(i)

Return the leftmost (if back is either absent or equals false, otherwise the rightmost) character of string that is in set.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(kind=CK, len=*), intent(in) :: set

Searched set.

logical, intent(in), optional :: back

Start of the last occurrence rather than the first.

Return Value integer

Result of the search.

private elemental function strim(self) result(trimmed)

Remove trailing spaces.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

Return Value type(string)

Trimmed string.

private elemental function sverify_string_string(self, set, back) result(i)

Return the leftmost (if back is either absent or equals false, otherwise the rightmost) character of string that is not in set. If all characters of string are found in set, the result is zero.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

type(string), intent(in) :: set

Searched set.

logical, intent(in), optional :: back

Start of the last occurrence rather than the first.

Return Value integer

Result of the search.

private elemental function sverify_string_character(self, set, back) result(i)

Return the leftmost (if back is either absent or equals false, otherwise the rightmost) character of string that is not in set. If all characters of string are found in set, the result is zero.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(kind=CK, len=*), intent(in) :: set

Searched set.

logical, intent(in), optional :: back

Start of the last occurrence rather than the first.

Return Value integer

Result of the search.

private elemental function basedir(self, sep)

Return the base directory name of a string containing a file name.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(kind=CK, len=*), intent(in), optional :: sep

Directory separator.

Return Value type(string)

Base directory name.

private elemental function basename(self, sep, extension, strip_last_extension)

Return the base file name of a string containing a file name.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(kind=CK, len=*), intent(in), optional :: sep

Directory separator.

character(kind=CK, len=*), intent(in), optional :: extension

File extension.

logical, intent(in), optional :: strip_last_extension

Flag to enable the stripping of last extension.

Return Value type(string)

Base file name.

private elemental function camelcase(self, sep)

Return a string with all words capitalized without spaces.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(kind=CK, len=*), intent(in), optional :: sep

Separator.

Return Value type(string)

Camel case string.

private elemental function capitalize(self) result(capitalized)

Return a string with its first character capitalized and the rest lowercased.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

Return Value type(string)

Upper case string.

private pure function chars(self) result(raw)

Return the raw characters data.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

Return Value character(kind=CK, len=:), allocatable

Raw characters data.

private pure function colorize_str(self, color_fg, color_bg, style) result(colorized)

Colorize and stylize strings, DEFAULT kind.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(len=*), intent(in), optional :: color_fg

Foreground color definition.

character(len=*), intent(in), optional :: color_bg

Background color definition.

character(len=*), intent(in), optional :: style

Style definition.

Return Value character(len=:), allocatable

Colorized string.

private elemental function decode(self, codec) result(decoded)

Return a string decoded accordingly the codec.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(kind=CK, len=*), intent(in) :: codec

Encoding codec.

Return Value type(string)

Decoded string.

private elemental function encode(self, codec) result(encoded)

Return a string encoded accordingly the codec.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(kind=CK, len=*), intent(in) :: codec

Encoding codec.

Return Value type(string)

Encoded string.

private elemental function escape(self, to_escape, esc) result(escaped)

Escape backslashes (or custom escape character).

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(kind=CK, len=1), intent(in) :: to_escape

Character to be escaped.

character(kind=CK, len=*), intent(in), optional :: esc

Character used to escape.

Return Value type(string)

Escaped string.

private elemental function extension(self)

Return the extension of a string containing a file name.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

Return Value type(string)

Extension file name.

private elemental function fill(self, width, right, filling_char) result(filled)

Pad string on the left (or right) with zeros (or other char) to fill width.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

integer, intent(in) :: width

Final width of filled string.

logical, intent(in), optional :: right

Fill on the right instead of left.

character(kind=CK, len=1), intent(in), optional :: filling_char

Filling character (default “0”).

Return Value type(string)

Filled string.

private elemental function insert_character(self, substring, pos) result(inserted)

Insert substring into string at a specified position.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(len=*), intent(in) :: substring

Substring.

integer, intent(in) :: pos

Position from which insert substring.

Return Value type(string)

Inserted string.

private elemental function insert_string(self, substring, pos) result(inserted)

Insert substring into string at a specified position.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

type(string), intent(in) :: substring

Substring.

integer, intent(in) :: pos

Position from which insert substring.

Return Value type(string)

Inserted string.

private pure function join_strings(self, array, sep) result(join)

Return a string that is a join of an array of strings.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

type(string), intent(in) :: array(1:)

Array to be joined.

character(kind=CK, len=*), intent(in), optional :: sep

Separator.

Return Value type(string)

The join of array.

private pure function join_characters(self, array, sep) result(join)

Return a string that is a join of an array of characters.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(kind=CK, len=*), intent(in) :: array(1:)

Array to be joined.

character(kind=CK, len=*), intent(in), optional :: sep

Separator.

Return Value type(string)

The join of array.

private pure function strjoin_strings(array, sep) result(join)

Return a string that is a join of an array of strings.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: array(1:)

Array to be joined.

character(kind=CK, len=*), intent(in), optional :: sep

Separator.

Return Value type(string)

The join of array.

private pure function strjoin_characters(array, sep, is_trim) result(join)

Return a string that is a join of an array of characters.

Read more…

Arguments

Type IntentOptional Attributes Name
character(kind=CK, len=*), intent(in) :: array(1:)

Array to be joined.

character(kind=CK, len=*), intent(in), optional :: sep

Separator.

logical, intent(in), optional :: is_trim

Flag to setup trim character or not

Return Value type(string)

The join of array.

private pure function strjoin_strings_array(array, sep, is_col) result(join)

Return a string that is a join of columns or rows of an array of strings.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: array(1:,1:)

Array to be joined.

character(kind=CK, len=*), intent(in), optional :: sep

Separator.

logical, intent(in), optional :: is_col

Direction: ‘columns’ if .true. or ‘rows’ if .false.

Return Value type(string), allocatable, (:)

The join of array.

private pure function strjoin_characters_array(array, sep, is_trim, is_col) result(join)

Return a string that is a join of columns or rows of an array of characters.

Read more…

Arguments

Type IntentOptional Attributes Name
character(kind=CK, len=*), intent(in) :: array(1:,1:)

Array to be joined.

character(kind=CK, len=*), intent(in), optional :: sep

Separator.

logical, intent(in), optional :: is_trim

Flag to setup trim character or not

logical, intent(in), optional :: is_col

Direction: ‘columns’ if .true. or ‘rows’ if .false.

Return Value type(string), allocatable, (:)

The join of array.

private elemental function lower(self)

Return a string with all lowercase characters.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

Return Value type(string)

Upper case string.

private pure function partition(self, sep) result(partitions)

Split string at separator and return the 3 parts (before, the separator and after).

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(kind=CK, len=*), intent(in), optional :: sep

Separator.

Return Value type(string), (1:3)

after the separator.

private elemental function replace(self, old, new, count) result(replaced)

Return a string with all occurrences of substring old replaced by new.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(kind=CK, len=*), intent(in) :: old

Old substring.

character(kind=CK, len=*), intent(in) :: new

New substring.

integer, intent(in), optional :: count

Number of old occurences to be replaced.

Return Value type(string)

The string with old replaced by new.

private elemental function reverse(self) result(reversed)

Return a reversed string.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

Return Value type(string)

The reversed string.

private function search(self, tag_start, tag_end, in_string, in_character, istart, iend) result(tag)

Search for tagged record into string, return the first record found (if any) matching the tags.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(kind=CK, len=*), intent(in) :: tag_start

Start tag.

character(kind=CK, len=*), intent(in) :: tag_end

End tag.

type(string), intent(in), optional :: in_string

Search into this string.

character(kind=CK, len=*), intent(in), optional :: in_character

Search into this character string.

integer, intent(out), optional :: istart

Starting index of tag inside the string.

integer, intent(out), optional :: iend

Ending index of tag inside the string.

Return Value type(string)

First tag found.

private pure function slice(self, istart, iend) result(raw)

Return the raw characters data sliced.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

integer, intent(in) :: istart

Slice start index.

integer, intent(in) :: iend

Slice end index.

Return Value character(kind=CK, len=:), allocatable

Raw characters data.

private elemental function snakecase(self, sep)

Return a string with all words lowercase separated by “_”.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(kind=CK, len=*), intent(in), optional :: sep

Separator.

Return Value type(string)

Snake case string.

private elemental function startcase(self, sep)

Return a string with all words capitalized, e.g. title case.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(kind=CK, len=*), intent(in), optional :: sep

Separator.

Return Value type(string)

Start case string.

private elemental function strip(self, remove_nulls)

Return a copy of the string with the leading and trailing characters removed.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

logical, intent(in), optional :: remove_nulls

Remove null characters at the end.

Return Value type(string)

The stripped string.

private elemental function swapcase(self)

Return a copy of the string with uppercase characters converted to lowercase and vice versa.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

Return Value type(string)

Upper case string.

private function tempname(self, is_file, prefix, path)

Return a safe temporary name suitable for temporary file or directories.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

logical, intent(in), optional :: is_file

True if tempname should be used for file (the default).

character(len=*), intent(in), optional :: prefix

Name prefix, otherwise self is used (if allocated).

character(len=*), intent(in), optional :: path

Path where file/directory should be used, default ./.

Return Value character(len=:), allocatable

Safe (unique) temporary name.

private elemental function to_integer_I1P(self, kind) result(to_number)

Cast string to integer (I1P).

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

integer(kind=I1P), intent(in) :: kind

Mold parameter for kind detection.

Return Value integer(kind=I1P)

The number into the string.

private elemental function to_integer_I2P(self, kind) result(to_number)

Cast string to integer (I2P).

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

integer(kind=I2P), intent(in) :: kind

Mold parameter for kind detection.

Return Value integer(kind=I2P)

The number into the string.

private elemental function to_integer_I4P(self, kind) result(to_number)

Cast string to integer (I4P).

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

integer(kind=I4P), intent(in) :: kind

Mold parameter for kind detection.

Return Value integer(kind=I4P)

The number into the string.

private elemental function to_integer_I8P(self, kind) result(to_number)

Cast string to integer (I8P).

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

integer(kind=I8P), intent(in) :: kind

Mold parameter for kind detection.

Return Value integer(kind=I8P)

The number into the string.

private elemental function to_real_R4P(self, kind) result(to_number)

Cast string to real (R4P).

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

real(kind=R4P), intent(in) :: kind

Mold parameter for kind detection.

Return Value real(kind=R4P)

The number into the string.

private elemental function to_real_R8P(self, kind) result(to_number)

Cast string to real (R8P).

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

real(kind=R8P), intent(in) :: kind

Mold parameter for kind detection.

Return Value real(kind=R8P)

The number into the string.

private elemental function to_real_R16P(self, kind) result(to_number)

Cast string to real (R16P).

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

real(kind=R16P), intent(in) :: kind

Mold parameter for kind detection.

Return Value real(kind=R16P)

The number into the string.

private elemental function unescape(self, to_unescape, unesc) result(unescaped)

Unescape double backslashes (or custom escaped character).

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(kind=CK, len=1), intent(in) :: to_unescape

Character to be unescaped.

character(kind=CK, len=*), intent(in), optional :: unesc

Character used to unescape.

Return Value type(string)

Escaped string.

private elemental function unique(self, substring) result(uniq)

Reduce to one (unique) multiple (sequential) occurrences of a substring into a string.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(kind=CK, len=*), intent(in), optional :: substring

Substring which multiple occurences must be reduced to one.

Return Value type(string)

String parsed.

private elemental function upper(self)

Return a string with all uppercase characters.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

Return Value type(string)

Upper case string.

private elemental function end_with(self, suffix, start, end, ignore_null_eof)

Return true if a string ends with a specified suffix.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(kind=CK, len=*), intent(in) :: suffix

Searched suffix.

integer, intent(in), optional :: start

Start position into the string.

integer, intent(in), optional :: end

End position into the string.

logical, intent(in), optional :: ignore_null_eof

Ignore null character at the end of file.

Return Value logical

Result of the test.

private elemental function is_allocated(self)

Return true if the string is allocated.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

Return Value logical

Result of the test.

private elemental function is_digit(self)

Return true if all characters in the string are digits.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

Return Value logical

Result of the test.

private elemental function is_integer(self, allow_spaces)

Return true if the string contains an integer.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

logical, intent(in), optional :: allow_spaces

Allow leading-trailing spaces.

Return Value logical

Result of the test.

private elemental function is_lower(self)

Return true if all characters in the string are lowercase.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

Return Value logical

Result of the test.

private elemental function is_number(self, allow_spaces)

Return true if the string contains a number (real or integer).

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

logical, intent(in), optional :: allow_spaces

Allow leading-trailing spaces.

Return Value logical

Result of the test.

private elemental function is_real(self, allow_spaces)

Return true if the string contains a real.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

logical, intent(in), optional :: allow_spaces

Allow leading-trailing spaces.

Return Value logical

Result of the test.

private elemental function is_upper(self)

Return true if all characters in the string are uppercase.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

Return Value logical

Result of the test.

private elemental function start_with(self, prefix, start, end)

Return true if a string starts with a specified prefix.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(kind=CK, len=*), intent(in) :: prefix

Searched prefix.

integer, intent(in), optional :: start

Start position into the string.

integer, intent(in), optional :: end

End position into the string.

Return Value logical

Result of the test.

private pure function string_concat_string(lhs, rhs) result(concat)

Concatenation with string.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: lhs

Left hand side.

type(string), intent(in) :: rhs

Right hand side.

Return Value character(kind=CK, len=:), allocatable

Concatenated string.

private pure function string_concat_character(lhs, rhs) result(concat)

Concatenation with character.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: lhs

Left hand side.

character(kind=CK, len=*), intent(in) :: rhs

Right hand side.

Return Value character(kind=CK, len=:), allocatable

Concatenated string.

private pure function character_concat_string(lhs, rhs) result(concat)

Concatenation with character (inverted).

Read more…

Arguments

Type IntentOptional Attributes Name
character(kind=CK, len=*), intent(in) :: lhs

Left hand side.

class(string), intent(in) :: rhs

Right hand side.

Return Value character(kind=CK, len=:), allocatable

Concatenated string.

private elemental function string_concat_string_string(lhs, rhs) result(concat)

Concatenation with string.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: lhs

Left hand side.

type(string), intent(in) :: rhs

Right hand side.

Return Value type(string)

Concatenated string.

private elemental function string_concat_character_string(lhs, rhs) result(concat)

Concatenation with character.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: lhs

Left hand side.

character(kind=CK, len=*), intent(in) :: rhs

Right hand side.

Return Value type(string)

Concatenated string.

private elemental function character_concat_string_string(lhs, rhs) result(concat)

Concatenation with character (inverted).

Read more…

Arguments

Type IntentOptional Attributes Name
character(kind=CK, len=*), intent(in) :: lhs

Left hand side.

class(string), intent(in) :: rhs

Right hand side.

Return Value type(string)

Concatenated string.

private elemental function string_eq_string(lhs, rhs) result(is_it)

Equal to string logical operator.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: lhs

Left hand side.

type(string), intent(in) :: rhs

Right hand side.

Return Value logical

Opreator test result.

private elemental function string_eq_character(lhs, rhs) result(is_it)

Equal to character logical operator.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: lhs

Left hand side.

character(kind=CK, len=*), intent(in) :: rhs

Right hand side.

Return Value logical

Opreator test result.

private elemental function character_eq_string(lhs, rhs) result(is_it)

Equal to character (inverted) logical operator.

Read more…

Arguments

Type IntentOptional Attributes Name
character(kind=CK, len=*), intent(in) :: lhs

Left hand side.

class(string), intent(in) :: rhs

Right hand side.

Return Value logical

Opreator test result.

private elemental function string_ne_string(lhs, rhs) result(is_it)

Not equal to string logical operator.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: lhs

Left hand side.

type(string), intent(in) :: rhs

Right hand side.

Return Value logical

Opreator test result.

private elemental function string_ne_character(lhs, rhs) result(is_it)

Not equal to character logical operator.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: lhs

Left hand side.

character(kind=CK, len=*), intent(in) :: rhs

Right hand side.

Return Value logical

Opreator test result.

private elemental function character_ne_string(lhs, rhs) result(is_it)

Not equal to character (inverted) logical operator.

Read more…

Arguments

Type IntentOptional Attributes Name
character(kind=CK, len=*), intent(in) :: lhs

Left hand side.

class(string), intent(in) :: rhs

Right hand side.

Return Value logical

Opreator test result.

private elemental function string_lt_string(lhs, rhs) result(is_it)

Lower than to string logical operator.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: lhs

Left hand side.

type(string), intent(in) :: rhs

Right hand side.

Return Value logical

Opreator test result.

private elemental function string_lt_character(lhs, rhs) result(is_it)

Lower than to character logical operator.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: lhs

Left hand side.

character(kind=CK, len=*), intent(in) :: rhs

Right hand side.

Return Value logical

Opreator test result.

private elemental function character_lt_string(lhs, rhs) result(is_it)

Lower than to character (inverted) logical operator.

Read more…

Arguments

Type IntentOptional Attributes Name
character(kind=CK, len=*), intent(in) :: lhs

Left hand side.

class(string), intent(in) :: rhs

Right hand side.

Return Value logical

Opreator test result.

private elemental function string_le_string(lhs, rhs) result(is_it)

Lower equal than to string logical operator.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: lhs

Left hand side.

type(string), intent(in) :: rhs

Right hand side.

Return Value logical

Opreator test result.

private elemental function string_le_character(lhs, rhs) result(is_it)

Lower equal than to character logical operator.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: lhs

Left hand side.

character(kind=CK, len=*), intent(in) :: rhs

Right hand side.

Return Value logical

Opreator test result.

private elemental function character_le_string(lhs, rhs) result(is_it)

Lower equal than to character (inverted) logical operator.

Read more…

Arguments

Type IntentOptional Attributes Name
character(kind=CK, len=*), intent(in) :: lhs

Left hand side.

class(string), intent(in) :: rhs

Right hand side.

Return Value logical

Opreator test result.

private elemental function string_ge_string(lhs, rhs) result(is_it)

Greater equal than to string logical operator.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: lhs

Left hand side.

type(string), intent(in) :: rhs

Right hand side.

Return Value logical

Opreator test result.

private elemental function string_ge_character(lhs, rhs) result(is_it)

Greater equal than to character logical operator.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: lhs

Left hand side.

character(kind=CK, len=*), intent(in) :: rhs

Right hand side.

Return Value logical

Opreator test result.

private elemental function character_ge_string(lhs, rhs) result(is_it)

Greater equal than to character (inverted) logical operator.

Read more…

Arguments

Type IntentOptional Attributes Name
character(kind=CK, len=*), intent(in) :: lhs

Left hand side.

class(string), intent(in) :: rhs

Right hand side.

Return Value logical

Opreator test result.

private elemental function string_gt_string(lhs, rhs) result(is_it)

Greater than to string logical operator.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: lhs

Left hand side.

type(string), intent(in) :: rhs

Right hand side.

Return Value logical

Opreator test result.

private elemental function string_gt_character(lhs, rhs) result(is_it)

Greater than to character logical operator.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: lhs

Left hand side.

character(kind=CK, len=*), intent(in) :: rhs

Right hand side.

Return Value logical

Opreator test result.

private elemental function character_gt_string(lhs, rhs) result(is_it)

Greater than to character (inverted) logical operator.

Read more…

Arguments

Type IntentOptional Attributes Name
character(kind=CK, len=*), intent(in) :: lhs

Left hand side.

class(string), intent(in) :: rhs

Right hand side.

Return Value logical

Opreator test result.

private elemental function replace_one_occurrence(self, old, new) result(replaced)

Return a string with the first occurrence of substring old replaced by new.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(kind=CK, len=*), intent(in) :: old

Old substring.

character(kind=CK, len=*), intent(in) :: new

New substring.

Return Value type(string)

The string with old replaced by new.


Subroutines

private elemental subroutine free(self)

Free dynamic memory.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(inout) :: self

The string.

private subroutine glob_character(self, pattern, list)

Glob search (character output), finds all the pathnames matching a given pattern according to the rules used by the Unix shell.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(len=*), intent(in) :: pattern

Given pattern.

character(len=:), intent(out), allocatable :: list(:)

List of matching pathnames.

private subroutine glob_string(self, pattern, list)

Glob search (string output), finds all the pathnames matching a given pattern according to the rules used by the Unix shell.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(len=*), intent(in) :: pattern

Given pattern.

type(string), intent(out), allocatable :: list(:)

List of matching pathnames.

private subroutine read_file(self, file, is_fast, form, iostat, iomsg)

Read a file as a single string stream.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(inout) :: self

The string.

character(len=*), intent(in) :: file

File name.

logical, intent(in), optional :: is_fast

Flag to enable (super) fast file reading.

character(len=*), intent(in), optional :: form

Format of unit.

integer, intent(out), optional :: iostat

IO status code.

character(len=*), intent(inout), optional :: iomsg

IO status message.

private subroutine read_line(self, unit, form, iostat, iomsg)

Read line (record) from a connected unit.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(inout) :: self

The string.

integer, intent(in) :: unit

Logical unit.

character(len=*), intent(in), optional :: form

Format of unit.

integer, intent(out), optional :: iostat

IO status code.

character(len=*), intent(inout), optional :: iomsg

IO status message.

private subroutine read_lines(self, unit, form, iostat, iomsg)

Read (all) lines (records) from a connected unit as a single ascii stream.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(inout) :: self

The string.

integer, intent(in) :: unit

Logical unit.

character(len=*), intent(in), optional :: form

Format of unit.

integer, intent(out), optional :: iostat

IO status code.

character(len=*), intent(inout), optional :: iomsg

IO status message.

private pure subroutine split(self, tokens, sep, max_tokens)

Return a list of substring in the string, using sep as the delimiter string.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

type(string), intent(out), allocatable :: tokens(:)

Tokens substring.

character(kind=CK, len=*), intent(in), optional :: sep

Separator.

integer, intent(in), optional :: max_tokens

Fix the maximum number of returned tokens.

private pure subroutine split_chunked(self, tokens, chunks, sep)

Return a list of substring in the string, using sep as the delimiter string, chunked (memory-efficient) algorithm.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

type(string), intent(out), allocatable :: tokens(:)

Tokens substring.

integer, intent(in) :: chunks

Number of chunks.

character(kind=CK, len=*), intent(in), optional :: sep

Separator.

private subroutine write_file(self, file, form, iostat, iomsg)

Write a single string stream into file.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(len=*), intent(in) :: file

File name.

character(len=*), intent(in), optional :: form

Format of unit.

integer, intent(out), optional :: iostat

IO status code.

character(len=*), intent(inout), optional :: iomsg

IO status message.

private subroutine write_line(self, unit, form, iostat, iomsg)

Write line (record) to a connected unit.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

integer, intent(in) :: unit

Logical unit.

character(len=*), intent(in), optional :: form

Format of unit.

integer, intent(out), optional :: iostat

IO status code.

character(len=*), intent(inout), optional :: iomsg

IO status message.

private subroutine write_lines(self, unit, form, iostat, iomsg)

Write lines (records) to a connected unit.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

integer, intent(in) :: unit

Logical unit.

character(len=*), intent(in), optional :: form

Format of unit.

integer, intent(out), optional :: iostat

IO status code.

character(len=*), intent(inout), optional :: iomsg

IO status message.

private pure subroutine string_assign_string(lhs, rhs)

Assignment operator from string input.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(inout) :: lhs

Left hand side.

type(string), intent(in) :: rhs

Right hand side.

private pure subroutine string_assign_character(lhs, rhs)

Assignment operator from character input.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(inout) :: lhs

Left hand side.

character(kind=CK, len=*), intent(in) :: rhs

Right hand side.

private pure subroutine string_assign_integer_I1P(lhs, rhs)

Assignment operator from integer input.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(inout) :: lhs

Left hand side.

integer(kind=I1P), intent(in) :: rhs

Right hand side.

private pure subroutine string_assign_integer_I2P(lhs, rhs)

Assignment operator from integer input.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(inout) :: lhs

Left hand side.

integer(kind=I2P), intent(in) :: rhs

Right hand side.

private pure subroutine string_assign_integer_I4P(lhs, rhs)

Assignment operator from integer input.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(inout) :: lhs

Left hand side.

integer(kind=I4P), intent(in) :: rhs

Right hand side.

private pure subroutine string_assign_integer_I8P(lhs, rhs)

Assignment operator from integer input.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(inout) :: lhs

Left hand side.

integer(kind=I8P), intent(in) :: rhs

Right hand side.

private pure subroutine string_assign_real_R4P(lhs, rhs)

Assignment operator from real input.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(inout) :: lhs

Left hand side.

real(kind=R4P), intent(in) :: rhs

Right hand side.

private pure subroutine string_assign_real_R8P(lhs, rhs)

Assignment operator from real input.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(inout) :: lhs

Left hand side.

real(kind=R8P), intent(in) :: rhs

Right hand side.

private pure subroutine string_assign_real_R16P(lhs, rhs)

Assignment operator from real input.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(inout) :: lhs

Left hand side.

real(kind=R16P), intent(in) :: rhs

Right hand side.

private subroutine read_formatted(dtv, unit, iotype, v_list, iostat, iomsg)

Formatted input.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(inout) :: dtv

The string.

integer, intent(in) :: unit

Logical unit.

character(len=*), intent(in) :: iotype

Edit descriptor.

integer, intent(in) :: v_list(:)

Edit descriptor list.

integer, intent(out) :: iostat

IO status code.

character(len=*), intent(inout) :: iomsg

IO status message.

private subroutine read_delimited(dtv, unit, delim, iostat, iomsg)

Read a delimited string from a unit connected for formatted input.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(out) :: dtv

The string.

integer, intent(in) :: unit

Logical unit.

character(kind=CK, len=1), intent(in) :: delim

String delimiter.

integer, intent(out) :: iostat

IO status code.

character(kind=CK, len=*), intent(inout) :: iomsg

IO status message.

private subroutine read_undelimited_listdirected(dtv, unit, iostat, iomsg)

Read an undelimited (no leading apostrophe or double quote) character value according to the rules for list directed input.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(inout) :: dtv

The string.

integer, intent(in) :: unit

Logical unit.

integer, intent(out) :: iostat

IO status code.

character(len=*), intent(inout) :: iomsg

IO status message.

private subroutine read_undelimited(dtv, unit, terminators, iostat, iomsg)

Read an undelimited string up until end of record or a character from a set of terminators is encountered.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(inout) :: dtv

The string.

integer, intent(in) :: unit

Logical unit.

character(kind=CK, len=*), intent(in) :: terminators

Characters that are considered to terminate the string. Blanks in this string are meaningful.

integer, intent(out) :: iostat

IO status code.

character(len=*), intent(inout) :: iomsg

IO status message.

private subroutine write_formatted(dtv, unit, iotype, v_list, iostat, iomsg)

Formatted output.

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: dtv

The string.

integer, intent(in) :: unit

Logical unit.

character(kind=CK, len=*), intent(in) :: iotype

Edit descriptor.

integer, intent(in) :: v_list(:)

Edit descriptor list.

integer, intent(out) :: iostat

IO status code.

character(kind=CK, len=*), intent(inout) :: iomsg

IO status message.

private subroutine read_unformatted(dtv, unit, iostat, iomsg)

Unformatted input.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string), intent(inout) :: dtv

The string.

integer, intent(in) :: unit

Logical unit.

integer, intent(out) :: iostat

IO status code.

character(kind=CK, len=*), intent(inout) :: iomsg

IO status message.

private subroutine write_unformatted(dtv, unit, iostat, iomsg)

Unformatted output.

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: dtv

The string.

integer, intent(in) :: unit

Logical unit.

integer, intent(out) :: iostat

IO status code.

character(kind=CK, len=*), intent(inout) :: iomsg

IO status message.

private subroutine get_delimiter_mode(unit, delim, iostat, iomsg)

Get the DELIM changeable connection mode for the given unit.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: unit

The unit for the connection.

character(kind=CK, len=1), intent(out) :: delim

Represents the value of the DELIM mode.

integer, intent(out) :: iostat

IOSTAT error code, non-zero on error.

character(len=*), intent(inout) :: iomsg

IOMSG explanatory message - only defined if iostat is non-zero.

private subroutine get_next_non_blank_character_this_record(unit, ch, iostat, iomsg)

Get the next non-blank character in the current record.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: unit

Logical unit.

character(kind=CK, len=1), intent(out) :: ch

The non-blank character read. Not valid if IOSTAT is non-zero.

integer, intent(out) :: iostat

IO status code.

character(kind=CK, len=*), intent(inout) :: iomsg

IO status message.

private subroutine get_next_non_blank_character_any_record(unit, ch, iostat, iomsg)

Get the next non-blank character, advancing records if necessary.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: unit

Logical unit.

character(kind=CK, len=1), intent(out) :: ch

The non-blank character read. Not valid if IOSTAT is non-zero.

integer, intent(out) :: iostat

IO status code.

character(kind=CK, len=*), intent(inout) :: iomsg

IO status message.

private subroutine get_decimal_mode(unit, decimal_point, iostat, iomsg)

Get the DECIMAL changeable connection mode for the given unit.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: unit

Logical unit.

logical, intent(out) :: decimal_point

True if the decimal mode is POINT, false otherwise.

integer, intent(out) :: iostat

IO status code.

character(kind=CK, len=*), intent(inout) :: iomsg

IO status message.