rpad(3f) - [M_strings:LENGTH] convert to a string and pad on the right
to requested length
(LICENSE:PD)
function rpad(valuein,length) result(strout)
 class*,intent(in)       :: valuein(..)
 integer,intent(in)      :: length
rpad(3f) converts a scalar intrinsic value to a string and then pads
it on the right with spaces to at least the specified length. If the
trimmed input string is longer than the requested length the string
is returned trimmed of leading and trailing spaces.
str      The input may be scalar or a vector.
         the input value to return as a string, padded on the left to
         the specified length if shorter than length. The input may be
         any intrinsic scalar which is converted to a cropped string
         much as if written with list-directed output.
length   The minimum string length to return
strout  The input string padded to the requested length
        on the right with spaces.
Sample Program:
  program demo_rpad
   use M_strings, only : rpad
   implicit none
      write(*,'("[",a,"]")') rpad( 'my string', 20)
      write(*,'("[",a,"]")') rpad( 'my string   ', 20)
      write(*,'("[",a,"]")') rpad( '   my string', 20)
      write(*,'("[",a,"]")') rpad( '   my string   ', 20)
      write(*,'("[",a,"]")') rpad( valuein=42 , length=7)
      write(*,'("[",a,"]")') rpad( valuein=1.0/9.0 , length=20)
  end program demo_rpad
Results:
  > [my string           ]
  > [my string           ]
  > [my string           ]
  > [my string           ]
  > [42     ]
  > [0.111111112         ]
John S. Urban
Public Domain
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(*), | intent(in) | :: | valuein | |||
| integer, | intent(in), | optional | :: | length | 
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(*), | intent(in) | :: | valuein(:) | |||
| integer, | intent(in), | optional | :: | length |