Manual Reference Pages  - str (3m_strings)

NAME

str(3f) - [M_strings:TYPE] converts multiple values to a (CSV) string (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Returns
Examples
Author
License

SYNOPSIS

function str( g1,g2,g3,g4,g5,g6,g7,g8,g9,g10, & & g11,g12,g13,g14,g15,g16,g17,g18,g19,g20,sep,csv)

class(*),intent(in),optional
  :: g1,g2,g3,g4,g5,g6,g7,g8,g9,g10
class(*),intent(in),optional
  :: g11,g12,g13,g14,g15,g16,g17,g18,g19,g20 character(len=*),intent(in),optional :: sep logical,intent(in),optional :: csv character(len=:),allocatable :: str

DESCRIPTION

str(3f) builds a string from up to twenty scalar values.

OPTIONS

g[1-20]
  optional value to print the value of after the message. May be of type INTEGER, LOGICAL, REAL, DOUBLEPRECISION, COMPLEX, or CHARACTER.
sep separator between values. Defaults to a space
csv write output conforming to RFC 1080 for CSV (Comma-Separated Values) files

RETURNS

str description to print

EXAMPLES

Sample program:

       program demo_str
       use M_strings, only : str, quote
       implicit none
       character(len=:),allocatable :: pr
       character(len=:),allocatable :: frmt
       integer                      :: biggest

pr=str(’HUGE(3f) integers’,huge(0),& & ’and real’,huge(0.0),’and double’,huge(0.0d0)) write(*,’(a)’)pr pr=str(’real :’,& & huge(0.0),0.0,12345.6789,tiny(0.0) ) write(*,’(a)’)pr pr=str(’doubleprecision :’,& & huge(0.0d0),0.0d0,12345.6789d0,tiny(0.0d0) ) write(*,’(a)’)pr pr=str(’complex :’,& & cmplx(huge(0.0),tiny(0.0)) ) write(*,’(a)’)pr

! create a format on the fly biggest=huge(0) ! +0 for gfortran-11 bug frmt=str(’(*(i’,int(log10(real(biggest)))+0,’:,1x))’,sep=’’) write(*,*)’format=’,frmt

! compound output pr=str(10,100.0,"string",(11.0,22.0),.false.) write(*,’(a)’)pr ! a separator and also use of quote(3f) pr=str(10,100.0,quote("string"),(11.0,22.0),.false.,sep=’;’) write(*,’(a)’)pr ! CSV mode pr=str(10,100.0,"string",(11.0,22.0),.false.,csv=.true.) write(*,’(a)’)pr ! everything a vector instead of a scalar pr=str([10,20,30],["string"],[(11.0,22.0)],[.false.,.true.]) write(*,’(a)’)pr pr=str([10,20,30],["string"],[(11.0,22.0)],[.false.,.true.],sep=’|’) write(*,’(a)’)pr pr=str([10,20,30],["string"],[(11.0,22.0)],[.false.,.true.],csv=.true.) write(*,’(a)’)pr

! although it will often work, using str(3f) in an I/O statement ! is not recommended write(*,*)str(’program will now attempt to stop’)

end program demo_str

Results:

 > HUGE(3f) integers 2147483647 and real 3.40282347E+38 and ...
 > ... double 1.7976931348623157E+308
 > real            : 3.40282347E+38 0.00000000 12345.6787 1.17549435E-38
 > doubleprecision : 1.7976931348623157E+308 0.0000000000000000 ...
 > ... 12345.678900000001 2.2250738585072014E-308
 > complex         : (3.40282347E+38,1.17549435E-38)
 >  format=(*(i9:,1x))
 > 10 100.000000 string (11.0000000,22.0000000) F
 > 10;100.000000;"string";(11.0000000,22.0000000);F
 > 10,100.000000,"string",11.0000000,22.0000000,F
 >  program will now attempt to stop

AUTHOR

John S. Urban

LICENSE

Public Domain


Nemo Release 3.1 str (3m_strings) July 20, 2024
Generated by manServer 1.08 from 63c9b5dc-fc6c-4c3f-814e-b8d641ce983b using man macros.