bundle(3f) - [M_strings:ARRAY] return up to twenty strings of arbitrary length as an array (LICENSE:PD)
Synopsis
Description
Options
Examples
Author
License
function bundle(str1,str2,...str20,len) result (vec)
character(len=*),intent(in),optional :: str1, str2 ... str20 integer,intent(in),optional :: len
Given a list of up to twenty strings create a string array. The length of the variables will be the same as the maximum length of the input strings unless explicitly specified via LEN.This is an alternative to the syntax
[ CHARACTER(LEN=NN) :: str1, str2, ... ]that by default additionally calculates the minimum length required to prevent truncation.
str1,str2, ... str20 input strings to combine into a vector len length of returned array variables
Sample Program:
program demo_bundle use M_strings, only: bundle implicit none character(len=*),parameter :: fmt= "(*("",a,"":,,,1x))" character(len=:),allocatable :: array(:) print fmt, bundle("one") print fmt, bundle("one","two") print fmt, bundle("one","two","three") array=bundle("one","two","three","four","five","six","seven") write(*,(*(g0)))size=,size(array),,len=,len(array) write(*,("[",a,"]"))array end program demo_bundleResults:
> "one" > "one", "two" > "one ", "two ", "three" > size=7,len=5 > [one ] > [two ] > [three] > [four ] > [five ] > [six ] > [seven]
John S. Urban
Public Domain
Nemo Release 3.1 | bundle (3m_strings) | January 10, 2025 |