msg(3f) - [M_debug] converts any standard scalar type to a string (LICENSE:PD)
Synopsis
Description
Options
Returns
Examples
Author
License
function msg(g1,g2g3,g4,g5,g6,g7,g8,g9)class(*),intent(in),optional :: g1,g2,g3,g4,g5,g6,g7,g8,g9 character(len=:),allocatable :: msg
msg(3f) builds a string from up to nine scalar values. Since the routine uses internal WRITE statements to build the returned string it should not be used in a WRITE or PRINT statement, as Fortran does not yet support recursive I/O.
g[1-9] optional value to print the value of after the message. May be of type INTEGER, LOGICAL, REAL, DOUBLEPRECISION, COMPLEX, or CHARACTER.
msg description to print
Sample program:
program demo_msg use M_debug, only : msg implicit none character(len=:),allocatable :: prpr=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
! 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
John S. Urban
Public Domain
msg (3) | November 13, 2019 |