help_version Subroutine

subroutine help_version(l_version)

NAME

rand - [M_random] generate pseudo-random permutations of file lines, whole
numbers, or strings
(LICENSE:PD)

SYNOPSIS

syntax:

rand FILES(s)   [ -n]
rand STRINGS -e [ -n]
rand -i LO-HI   [ -n]

DESCRIPTION

Generates pseudorandom permutations, similar to the shuf(1) command.
Writes pseudo-random permutations of:

o the lines in a file
o a range of whole numbers
o a list of strings

OPTIONS

FILES(s)   files to use as input
-e         treat each ARG as an input line
-i LO HI   treat each number LO through HI as an input line
-n         output at most COUNT lines (per file)
--help     display this help and exit
--version  output version information and exit

EXAMPLES

Sample usage:

# generate a random number from 0 to 100
rand -i 0 100 -n 1

# randomly pick a line from a file
rand -n 1 MYFILE.TXT

# randomly select xterm(1) color
xterm -bg `rand green black gray blue -e -n 1`

# randomly sleep 10 to 30 seconds
sleep `rand 10 30 -n 1`

AUTHOR

John S. Urban

LICENSE

Public Domain

Arguments

Type IntentOptional Attributes Name
logical, intent(in) :: l_version

Variables

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: help_text(:)
integer, public :: i
character(len=*), public, parameter :: ident = "@(#)help_version(3f): prints version information"
logical, public :: stopit = .false.

Source Code

subroutine help_version(l_version)
implicit none
character(len=*),parameter     :: ident="@(#)help_version(3f): prints version information"
logical,intent(in)             :: l_version
character(len=:),allocatable   :: help_text(:)
integer                        :: i
logical                        :: stopit=.false.
stopit=.false.
if(l_version)then
help_text=[ CHARACTER(LEN=128) :: &
'@(#)PRODUCT:        GPF (General Purpose Fortran) utilities and examples>',&
'@(#)PROGRAM:        rand(1)>',&
'@(#)DESCRIPTION:    random shuffle of lines in a file or strings or a range of whole numbers>',&
'@(#)VERSION:        2.0, 2022-01-08>',&
'@(#)AUTHOR:         John S. Urban>',&
'@(#)LICENSE:        Public Domain. This is free software: you are free to change and redistribute it.>',&
'@(#)                There is NO WARRANTY, to the extent permitted by law.>',&
'@(#)COMPILED:       2023-04-12 02:29:17 UTC-240>',&
'']
   WRITE(*,'(a)')(trim(help_text(i)(5:len_trim(help_text(i))-1)),i=1,size(help_text))
   stop ! if --version was specified, stop
endif
end subroutine help_version