[UP]


Manual Reference Pages  - rd (3)

NAME

rd(3f) - [M_io] ask for string from standard input with user-definable prompt (LICENSE:PD)

  function rd(prompt,default) result(strout)

character(len=*),intent(in) :: prompt

character(len=*),intent(in) :: default or integer,intent(in) :: default or real,intent(in) :: default or doubleprecision,intent(in) :: default

character(len=:),allocatable,intent(out) :: strout

CONTENTS

Description
Options
Returns
Example
Author
License

DESCRIPTION

Ask for string or value from standard input with user-definable prompt up to 20 times.

Do not use the function in an I/O statement as not all versions of Fortran support this form of recursion. Numeric values may be input in standard INTEGER, REAL, and DOUBLEPRECISION formats or as whole numbers in base 2 to 36 in the format BASE#VALUE.

OPTIONS

prompt Prompt string; displayed on same line as input is read from
default
  default answer on carriage-return. The type of the default determines the type of the output.

RETURNS

strout returned string or value. If an end-of-file or system error is encountered the string "EOF" is returned, or a "Nan" numeric value.

EXAMPLE

Sample program:

   program demo_rd
   use M_io, only : rd
   implicit none
   character(len=:),allocatable :: mystring
   doubleprecision              :: d
   real                         :: r
   integer                      :: i

INFINITE: do mystring=rd(’Enter string or "STOP":’,default=’Today’) if(mystring.eq.’STOP’)stop i=rd(’Enter integer:’,default=huge(0)) r=rd(’Enter real:’,default=huge(0.0)) d=rd(’Enter double:’,default=huge(0.0d0))

write(*,*)’I=’, i, ’R=’, r, ’D=’,d, ’MYSTRING=’, mystring enddo INFINITE

end program demo_rd

AUTHOR

John S. Urban, 1993

LICENSE

Public Domain


rd (3) March 11, 2021
Generated by manServer 1.08 from 4a1414e8-4f17-439b-8485-5a243d2d8926 using man macros.