Skip to content

Latest commit

 

History

History
executable file
·
176 lines (139 loc) · 12.1 KB

README.md

File metadata and controls

executable file
·
176 lines (139 loc) · 12.1 KB

string

Name

M_strings and M_strings__oop - Fortran modules for processing strings

Description

The M_strings(3fm) module is a collection of Fortran procedures that supplement the built-in intrinsic string routines. Routines for parsing, tokenizing, changing case, substituting new strings for substrings, locating strings with simple wildcard expressions, removing tabs and line terminators as well as other string manipulations are included.

M_strings_oop(3fm) is a companion module that provides an OOP interface to the M_strings module.

Note there are some procedures with overlapping function that were all initially gathered here that have varying performance and robustness that may be consolidated at some point.

Synopsis

public entities:

use M_strings, only : split, sep, delim, chomp, strtok
use M_strings, only : split2020, find_field
use M_strings, only : substitute, change, modif, transliterate, reverse, squeeze
use M_strings, only : replace, join
use M_strings, only : upper, lower, upper_quoted
use M_strings, only : rotate13, percent_encode
use M_strings, only : adjustc, compact, nospace, indent
use M_strings, only : crop, clip, unquote, quote, matching_delimiter
use M_strings, only : len_white, pad, lpad, cpad, rpad, zpad, stretch, lenset, merge_str
use M_strings, only : switch, s2c, c2s
use M_strings, only : noesc, notabs, dilate, expand, visible
use M_strings, only : longest_common_substring
use M_strings, only : string_to_value, string_to_values, s2v, s2vs
use M_strings, only : value_to_string, v2s, msg
use M_strings, only : listout, getvals
use M_strings, only : glob, ends_with
use M_strings, only : paragraph
use M_strings, only : base, decodebase, codebase, base2
use M_strings, only : isalnum, isalpha, iscntrl, isdigit
use M_strings, only : isgraph, islower, isprint, ispunct
use M_strings, only : isspace, isupper, isascii, isblank, isxdigit
use M_strings, only : isnumber
use M_strings, only : fortran_name
use M_strings, only : describe
use M_strings, only : edit_distance
use M_strings, only : cc
use M_strings, only : int, dble, nint
use M_strings, only : atoi, atol, dble

Intrinsics

The M_strings(3fm) module supplements and works in combination with the Fortran built-in intrinsics. Standard Fortran lets you access the characters in a string using ranges much like they are character arrays assignment, comparisons with standard operators, supports dynamically allocatable strings and supports concatenation using the // operator:

 adjustl             Left adjust a string
 adjustr             Right adjust a string
 index               Position of a substring within a string
 repeat              Repeated string concatenation
 scan                Scan a string for the presence of a set of characters
 trim                Remove trailing blank characters of a string
 verify              Scan a string for the absence of a set of characters
 len                 It returns the length of a character string
 achar               converts an integer into a character
 iachar              converts a character into an integer
 len_trim            finds length of string with trailing spaces ignored
 new_line            Newline character
 selected_char_kind  Choose character kind
 lge                 Lexical greater than or equal
 lgt                 Lexical greater than
 lle                 Lexical less than or equal
 llt                 Lexical less than

gmake

Download and Build with make(1)

Just download the github repository, enter the src/ directory and run make:

 git clone https://github.com/urbanjost/M_strings.git
 cd M_strings/src
 # change Makefile if not using one of the listed compilers

 # for gfortran
 make clean
 make F90=gfortran gfortran

 # for ifort
 make clean
 make F90=ifort ifort

 # for nvfortran
 make clean
 make F90=nvfortran nvfortran

 # optionally
 make test # run the unit tests
 make run  # run all the demo programs from the man-pages
 make help # see other developer options

This will compile the M_strings(3f) module and optionally build all the example programs from the document pages in the example/ sub-directory and run the unit tests.


fpm

Download and Build with fpm(1)

Alternatively, download the github repository and build it with fpm ( as described at Fortran Package Manager )

     git clone https://github.com/urbanjost/M_strings.git
     cd M_strings
     fpm build
     fpm test  # run unit tests

or just list it as a dependency in your fpm.toml project file.

     [dependencies]
     M_strings        = { git = "https://github.com/urbanjost/M_strings.git" ,tag="v1.0.1"}

Note that M_strings.f90 is registered at the fpm(1) registry


docs

Documentation

User

There are descriptions of each procedures in the style of man-pages in three formats:

  • An index to the HTML versions of the man-pages.

  • A single page (that uses javascript) combining all the HTML descriptions of the man-pages for easy searching and printing: BOOK_M_strings.

  • man-pages man-page archives for installation on GNU/Linux, Unix and CygWin platforms:

  • CHANGELOG provides a history of significant changes

Developer


demos

Demo Programs

Each man-page includes a working example program. These and additional examples are included in the example/ directory.

See Also

  • M_match Fortran module for Basic Regular Expressions (LICENSE:PD)
  • M_regex Fortran interface to POSIX 1003.2 regular expression library using ISO_C_BINDING.