s2vs(3f) - [M_strings:TYPE] given a string representing numbers return a numeric array (LICENSE:PD)
Synopsis
Description
Options
Returns
Examples
Author
License
function s2vs(line[,delim])
character(len=*) :: line doubleprecision,allocatable :: s2vs(:)
The function S2VS(3f) takes a string representing a series of numbers and converts it to a numeric doubleprecision array. The string values may be delimited by spaces, semi-colons, and commas by default.
LINE Input string containing numbers DELIM optional list of delimiter characters. If a space is included, it should appear as the left-most character in the list. The default is " ;," (spaces, semi-colons, and commas).
S2VS doubleprecision array
Sample Program:
program demo_s2vs use M_strings, only : s2vs implicit none character(len=80) :: s= 10 20e3;3.45 -400.3e-2;1234; 5678 real,allocatable :: values(:) integer,allocatable :: ivalues(:) integer :: iiExpected outputvalues=s2vs(s) ivalues=int(s2vs(s)) call reportit()
contains subroutine reportit() write(*,*)S2VS: write(*,*)input string.............,& & trim(s) write(*,*)number of values found...,& & size(values) write(*,*)values...................,& & (values(ii),ii=1,size(values)) write(*,(*(g0,1x)))ivalues..................,& & (ivalues(ii),ii=1,size(values)) end subroutine reportit end program demo_s2vs
S2VS: input string............. 10 20e3;3.45 -400.3e-2;1234; 5678 number of values found... 6 values................... 10.0000000 20000.0000 3.45000005 -4.00299978 1234.00000 5678.00000ivalues.................. 10 20000 3 -4 1234 5678
John S. Urban
Public Domain
Nemo Release 3.1 | s2vs (3m_strings) | January 10, 2025 |