C Library Functions  - fmt (3)

NAME

fmt(3f) - [M_msg] convert any intrinsic to a string using specified format (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Returns
Examples
Author
License

SYNOPSIS

function fmt(value,format) result(string)

    class(*),intent(in),optional :: value
    character(len=*),intent(in),optional  :: format
    character(len=:),allocatable :: string

DESCRIPTION

FMT(3f) converts any standard intrinsic value to a string using the specified format.

OPTIONS

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.

RETURNS

string A string value

EXAMPLES

Sample program:

    program demo_fmt
    use :: M_msg, only : fmt
    implicit none
    character(len=:),allocatable :: output

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

Results:

    result is [10]
    result is [3.3333]
    result is The final answer is [T]

AUTHOR

John S. Urban

LICENSE

Public Domain


Nemo Release 3.1 fmt (3) July 22, 2023
Generated by manServer 1.08 from 976227a4-bca6-4678-bec0-e793d95586bf using man macros.