FORCES
FORtran lib for Comp. Env. Sys.
|
String utilities. More...
Data Types | |
interface | num2str |
Convert to string. More... | |
interface | numarray2str |
Convert to string. More... | |
Functions/Subroutines | |
pure logical function, public | is_blank (c) |
Check for blank characters. | |
character(len(whitespaces)) function, public | compress (whitespaces, n) |
Remove white spaces. | |
character(len(s)+100) function, public | replace_text (s, text, rep) |
character(len(s)+100) function, public | replace_word (s, word, rep, check_negative_number_arg) |
replaces words in a string | |
integer function, public | index_word (s, text, check_negative_number_arg) |
find index in word | |
subroutine, public | divide_string (string, delim, strarr) |
Divide string in substrings. | |
logical function, public | equalstrings (string1, string2) |
Checks if two string are equal. | |
logical function, public | nonull (str) |
Checks if string was already used. | |
character(len=256) function, dimension(:), allocatable, public | splitstring (string, delim) |
split string at delimiter | |
logical function, public | startswith (string, start, strip) |
Checks if string starts with character(s) | |
logical function, public | endswith (string, suffix, strip) |
Checks if (maybe trimmed) string ends with given character(s) | |
character(len=len_trim(upper)) function, public | tolower (upper) |
Convert to lower case. | |
character(len=len_trim(lower)) function, public | toupper (lower) |
Convert to upper case. | |
pure character(len=10) function | i42str (nn, form) |
pure character(len=20) function | i82str (nn, form) |
pure character(len=32) function | sp2str (rr, form) |
pure character(len=32) function | dp2str (rr, form) |
pure character(len=10) function | log2str (ll, form) |
character(len=size(arr)) function | i4array2str (arr) |
integer(i4) function, dimension(:), allocatable, public | str2num (string) |
Converts string into an array of its numerical representation. | |
Variables | |
character(len= *), parameter, public | separator = repeat('-', 70) |
separator string (line) | |
String utilities.
This module provides string conversion and checking utilities.
COPYING
and COPYING.LESSER
provided with this software. The complete GNU license text can also be found at http://www.gnu.org/licenses/. character(len(whitespaces)) function, public mo_string_utils::compress | ( | character(len=*), intent(in) | whitespaces, |
integer(i4), intent(out), optional | n | ||
) |
Remove white spaces.
Return a copy of an input string with all whitespace (spaces and tabs) removed
Example
Returns 'Hallo'
[in] | character(len=*) :: whiteSpaces | String |
[out] | integer(i4), optional :: n | Integer |
character(len = len(whiteSpaces)) :: compress | String where all all whitespace (spaces and tabs) are removed |
Definition at line 156 of file mo_string_utils.f90.
References compress(), and mo_kind::i4.
Referenced by compress(), mo_sce::sce(), and mo_utils::special_value::special_value_sp().
subroutine, public mo_string_utils::divide_string | ( | character(len=*), intent(in) | string, |
character(len=*), intent(in) | delim, | ||
character(len=*), dimension(:), intent(out), allocatable | strarr | ||
) |
Divide string in substrings.
Divides a string in several substrings (array of strings) with the help of a user specified delimiter.
Example
Divide string into 'I', 'want', 'to', ...
[in] | CHARACTER(len=*), INTENT(IN) :: string | - string to be divided |
[in] | CHARACTER(len=*), INTENT(IN) :: delim | - delimiter specifying places for division |
[out] | CHARACTER(len=*), DIMENSION(:), ALLOCATABLE, INTENT(OUT) :: strArr | Array of substrings, has to be allocateable and is handed to the routine unallocated |
Definition at line 325 of file mo_string_utils.f90.
Referenced by mo_datetime::d_from_string(), mo_datetime::dt_from_cf(), mo_datetime::dt_from_string(), and mo_datetime::t_from_string().
|
private |
Definition at line 692 of file mo_string_utils.f90.
logical function, public mo_string_utils::endswith | ( | character(len=*), intent(in) | string, |
character(len=*), intent(in) | suffix, | ||
logical, intent(in), optional | strip | ||
) |
Checks if (maybe trimmed) string ends with given character(s)
endswith | if string ends with given end |
[in] | string | string to check |
[in] | suffix | ending string |
[in] | strip | whether to strip trailing white-spaces (.true. by default) |
Definition at line 527 of file mo_string_utils.f90.
References endswith().
Referenced by endswith(), mo_os::path_join_char(), mo_os::path_join::path_join_char_opt(), and mo_os::path_splitext().
logical function, public mo_string_utils::equalstrings | ( | character(len=*), intent(in) | string1, |
character(len=*), intent(in) | string2 | ||
) |
Checks if two string are equal.
Returns true if the given string arguments are equal
Example
[in] | character(len=*) :: string1 | String |
[in] | character(len=*) :: string2 | String |
logical :: eq | Logical value if string equal |
Definition at line 389 of file mo_string_utils.f90.
References equalstrings(), and str2num().
Referenced by equalstrings().
|
private |
Definition at line 641 of file mo_string_utils.f90.
|
private |
Definition at line 725 of file mo_string_utils.f90.
|
private |
Definition at line 658 of file mo_string_utils.f90.
integer function, public mo_string_utils::index_word | ( | character(*) | s, |
character(*) | text, | ||
logical, optional | check_negative_number_arg | ||
) |
find index in word
Definition at line 236 of file mo_string_utils.f90.
Referenced by replace_word().
pure logical function, public mo_string_utils::is_blank | ( | character(len=1), intent(in) | c | ) |
Check for blank characters.
Checks whether or not c
is a blank character, namely a space and tab character.
c
is a blank. [in] | c | The character to test. |
Definition at line 125 of file mo_string_utils.f90.
References is_blank().
Referenced by is_blank(), and mo_io::number_of_columns().
|
private |
Definition at line 709 of file mo_string_utils.f90.
logical function, public mo_string_utils::nonull | ( | character(len=*), intent(in) | str | ) |
Checks if string was already used.
Checks if string was already used, i.e. does not contain NULL character anymore.
Example
Trim if string is used.
[in] | character(len=*) :: str | String |
logical :: used | .true.: string was already set; .false.: string still in initialised state |
Definition at line 432 of file mo_string_utils.f90.
References nonull().
Referenced by mo_ncwrite::create_netcdf(), and nonull().
character(len(s)+100) function, public mo_string_utils::replace_text | ( | character(*) | s, |
character(*) | text, | ||
character(*) | rep | ||
) |
Definition at line 201 of file mo_string_utils.f90.
character(len(s)+100) function, public mo_string_utils::replace_word | ( | character(*) | s, |
character(*) | word, | ||
character(*) | rep, | ||
logical, optional | check_negative_number_arg | ||
) |
replaces words in a string
replaces proper words only, e.g. replace_word('our hour', 'our', 'their') --> 'their hour'
Definition at line 218 of file mo_string_utils.f90.
References index_word().
|
private |
Definition at line 675 of file mo_string_utils.f90.
character(len=256) function, dimension(:), allocatable, public mo_string_utils::splitstring | ( | character(len=*), intent(in) | string, |
character(len=*), intent(in) | delim | ||
) |
split string at delimiter
Split string at delimiter an return an array of strings
Example
[in] | character(len=*) :: string | String |
[in] | character(len=*) :: delim | String |
character(len=245) :: out(:) | Array of splitted strings |
Definition at line 466 of file mo_string_utils.f90.
References str2num().
logical function, public mo_string_utils::startswith | ( | character(len=*), intent(in) | string, |
character(len=*), intent(in) | start, | ||
logical, intent(in), optional | strip | ||
) |
Checks if string starts with character(s)
Returns true if string starts with given characters, flase otherwise
[in] | string | string to check |
[in] | start | starting string |
[in] | strip | whether to strip trailing white-spaces (.false. by default) |
Definition at line 497 of file mo_string_utils.f90.
References startswith().
Referenced by mo_os::path_isabs(), mo_os::path_isroot(), and startswith().
integer(i4) function, dimension(:), allocatable, public mo_string_utils::str2num | ( | character(len=*), intent(in) | string | ) |
Converts string into an array of its numerical representation.
Converts string into an integer array of the numerical values of the letters
Example
Convert is string into numerical array of the letters
[in] | character(len=*) :: string | String |
integer :: out(:) | Numerical array of letters |
Definition at line 757 of file mo_string_utils.f90.
Referenced by equalstrings(), and splitstring().
character(len=len_trim(upper)) function, public mo_string_utils::tolower | ( | character(len=*), intent(in) | upper | ) |
Convert to lower case.
Convert all upper case letters in string to lower case letters.
Example
Returns 'hallo'
[in] | character(len=*) :: upper | String |
character(len=len_trim(upper)) :: low | String where all uppercase in input is converted to lowercase |
Definition at line 573 of file mo_string_utils.f90.
References tolower().
Referenced by mo_nml::position_nml(), and tolower().
character(len=len_trim(lower)) function, public mo_string_utils::toupper | ( | character(len=*), intent(in) | lower | ) |
Convert to upper case.
Convert all lower case letters in string to upper case letters.
Example
Returns 'HALLO'
[in] | character(len=*) :: lower | String |
character(len=len_trim(lower)) :: up | String where all lowercase in input is converted to uppercase |
Definition at line 614 of file mo_string_utils.f90.
References toupper().
Referenced by toupper().
character(len=*), parameter, public mo_string_utils::separator = repeat('-', 70) |
separator string (line)
Definition at line 116 of file mo_string_utils.f90.