fmt(3f) - [M_strings:TYPE] convert any intrinsic to a string using specified format (LICENSE:PD)
Synopsis
Description
Options
Returns
Examples
Author
License
function fmt(value,format) result(string)
class(*),intent(in),optional :: value character(len=*),intent(in),optional :: format character(len=:),allocatable :: string
FMT(3f) converts any standard intrinsic value to a string using the specified format.
value value to print the value of. May be of type INTEGER, LOGICAL, REAL, DOUBLEPRECISION, COMPLEX, or CHARACTER. format format to use to print value. It is up to the user to use an appropriate format. The format does not require being surrounded by parenthesis. If not present a default is selected similar to what would be produced with free format, with trailing zeros removed.
string A string value
Sample program:
program demo_fmt use :: M_strings, only : fmt implicit none character(len=:),allocatable :: outputResults:output=fmt(10,"[,i0,]") write(*,*)result is ,output
output=fmt(10.0/3.0,"[,g0.5,]") write(*,*)result is ,output
output=fmt(.true.,"The final answer is [,g0,]") write(*,*)result is ,output
end program demo_fmt
result is [10] result is [3.3333] result is The final answer is [T]
John S. Urban
Public Domain
Nemo Release 3.1 | fmt (3m_strings) | January 10, 2025 |