[UP]


Manual Reference Pages  - msg (3)

NAME

msg(3f) - [M_strings] converts any standard scalar type to a string (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Returns
Examples
Author
License

SYNOPSIS

function msg(g1,g2g3,g4,g5,g6,g7,g8,g9,nospace)

     class(*),intent(in),optional  :: g1,g2,g3,g4,g5,g6,g7,g8,g9
     logical,intent(in),optional   :: nospace
     character,len=(:),allocatable :: msg

DESCRIPTION

msg(3f) builds a space-separated string from up to nine scalar values.

OPTIONS

g[1-9] optional value to print the value of after the message. May be of type INTEGER, LOGICAL, REAL, DOUBLEPRECISION, COMPLEX, or CHARACTER.
nospace
  if nospace=.true., then no spaces are added between values

RETURNS

msg description to print

EXAMPLES

Sample program:

       program demo_msg
       use M_strings, only : msg
       implicit none
       character(len=:),allocatable :: pr
       character(len=:),allocatable :: frmt
       integer                      :: biggest

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

! create a format on the fly biggest=huge(0) frmt=msg(’(*(i’,int(log10(real(biggest))),’:,1x))’,nospace=.true.) write(*,*)’format=’,frmt

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

end program demo_msg

Output

      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))
       program will now stop

AUTHOR

John S. Urban

LICENSE

Public Domain


msg (3) March 11, 2021
Generated by manServer 1.08 from 3beb01b7-db43-48e9-8912-d8cdc3685a7d using man macros.