v2s(3f) - [M_strings:TYPE] return numeric string from a numeric value (LICENSE:PD)
Synopsis
Description
Options
Returns
Examples
Author
License
function v2s(value) result(outstr)
integer|real|doubleprecision|logical,intent(in ) :: value character(len=:),allocatable :: outstr character(len=*),optional,intent(in) :: fmt
v2s(3f) returns a representation of a numeric value as a string when given a numeric value of type REAL, DOUBLEPRECISION, INTEGER or LOGICAL. It creates the strings using internal WRITE() statements. Trailing zeros are removed from non-zero values, and the string is left-justified.
VALUE input value to be converted to a string FMT format can be explicitly given, but is limited to generating a string of eighty or less characters.
OUTSTR returned string representing input value,
Sample Program:
program demo_v2s use M_strings, only: v2s write(*,*) The value of 3.0/4.0 is [//v2s(3.0/4.0)//] write(*,*) The value of 1234 is [//v2s(1234)//] write(*,*) The value of 0d0 is [//v2s(0d0)//] write(*,*) The value of .false. is [//v2s(.false.)//] write(*,*) The value of .true. is [//v2s(.true.)//] end program demo_v2sExpected output
The value of 3.0/4.0 is [0.75] The value of 1234 is [1234] The value of 0d0 is [0] The value of .false. is [F] The value of .true. is [T]
John S. Urban
Public Domain
Nemo Release 3.1 | v2s (3m_strings) | January 10, 2025 |