rgets(3f) - [ARGUMENTS:M_kracken] given keyword fetch real array from command arguments (LICENSE:PD)
Synopsis
Description
Options
Returns
Examples
See Also
Author
License
function rgets(keyword,ier) result(rarray)
character(len=*),intent(in) :: keyword real,allocatable :: rarray(:) integer,optional,intent(iout) :: ier
The rgets(3f) function returns a dynamically allocated array of real values from a string that is the value for a command line option. It is part of the M_kracken(3fm) module.Values that cannot be read as a numeric value are returned as a NaN.
KEYWORD the dictionary keyword (in form VERB_KEYWORD) to retrieve. The VERB name comes from the first argument of the KRACKEN(3f) call. The KEYWORD is a keyword from the KRACKEN(3f) call that should be interpreted as a list of REAL values.
RARRAY real array returned by function. The array will have zero size if the parsed dictionary entry is blank. IER If present and non-zero an error occurred in converting strings to a value
Sample program converts between Celcius and Fahrenheit
program demo_rgets use M_kracken, only: kracken, rgets implicit none real,allocatable :: val(:) integer :: i ! define command arguments and parse user command call kracken(fc,-F -C )Example program runs:! get any values specified on -C option val=rgets(fc_C) ! test if have something to print in C ==> F table if(size(val).gt.0)then ! print the requested values write(*,(a,t14,a))celsius,fahrenheit write(*,(f5.1,t14,f5.1))( val(i),(val(i)+40.0)*9.0/5.0 - 40.0,i=1,size(val)) endif
val=rgets(fc_F) ! check for values on -F if(size(val).gt.0)then write(*,(a,t14,a)) fahrenheit, celsius write(*,(f5.1,t14,f5.1))(val(i),(val(i)+40.0)*5.0/9.0 - 40.0,i=1,size(val)) endif end program demo_rgets
% demo_rgets -C -273.15 0 100 -40 37 celsius fahrenheit -273.15 -459.67 0.0 32.0 100.0 212.0 -40.0 -40.0 37.0 98.6% demo_rgets -F -459.67 32 212 -40 98.6 fahrenheit celsius -459.67 -273.15 32.00 0.00 212.00 100.00 -40.00 -40.00 98.60 37.00
dget(3f), dgets(3f), iget(3f), igets(3f), lget(3f), lgets(3f), rget(3f), rgets(3f), sget(3f), sgets(3f), retrev(3f)
M_kracken(3f), kracken(3f) parse(3f), dissect(3f), store(3f), setprompts(3f), show(3f)
John S. Urban
Public Domain
Nemo Release 3.1 | rgets (3) | February 23, 2025 |