get_args_fixed_size(3m_cli2)
β¨ get_args_fixed_size β¨
okay bestie, gather round, because this one lives in the 3m_cli2 manual and it is lowkey the moment your fixed-size arrays get their values handed to them π
π NAME π
get_args_fixed_size(3f) β [ARGUMENTS:M_CLI2] return keyword values for fixed-size array when parsing command line arguments (LICENSE:PD)
like, that's the whole job. that's the assignment. and she ate. π
πΈ SYNOPSIS πΈ
subroutine get_args_fixed_size(name,value)
character(len=*),intent(in) :: name
[real|doubleprecision|integer|logical|complex] :: value(NNN)
or
character(len=MMM) :: value(NNN)
character(len=*),intent(in),optional :: delimiters
no cap, that's the shape of it π¦
π DESCRIPTION π
so get_args_fixed_size(3f) returns the value of keywords for fixed-size arrays, and it does this after set_args(3f) has already been called. think of set_args as the one who set the whole thing up and this one as the one who shows up to collect.
and here's the tea: on input on the command line, all values of the array must be specified. every single one. no skipping, no leaving a spot empty, periodt π
β¨ OPTIONS β¨
NAMEβ the name of the commandline argument you want to obtain the value of. just the name, bestie.VALUEβ the variable that holds the returned values. the kind of the value is what determines the type of the returned value. it must be a fixed-size array. and if the type isCHARACTER, then the length must be fixed too. fixed fixed fixed, she said what she said πDELIMITERSβ by default the delimiter for array values are comma, colon, and whitespace. but you can supply a string containing an alternate list of delimiter characters if the default vibe isn't your vibe π
π EXAMPLE π
sample program, bestie, here she is in all her glory:
program demo_get_args_fixed_size
use M_CLI2, only : set_args, get_args_fixed_size
implicit none
integer,parameter :: dp=kind(0.0d0)
! DEFINE ARGS
real :: x(2)
real(kind=dp) :: y(2)
integer :: p(3)
character(len=80) :: title(1)
logical :: l(4), lbig(4)
complex :: cmp(2)
! DEFINE AND PARSE (TO SET INITIAL VALUES) COMMAND LINE
! o only quote strings
! o set all logical values to F or T.
call set_args(' &
& -x 10.0,20.0 &
& -y 11.0,22.0 &
& -p -1,-2,-3 &
& --title "my title" &
& -l F,T,F,T -L T,F,T,F &
& --cmp 111,222.0,333.0e0,4444 &
& ')
! ASSIGN VALUES TO ELEMENTS
call get_args_fixed_size('x',x)
call get_args_fixed_size('y',y)
call get_args_fixed_size('p',p)
call get_args_fixed_size('title',title)
call get_args_fixed_size('l',l)
call get_args_fixed_size('L',lbig)
call get_args_fixed_size('cmp',cmp)
! USE VALUES
write(*,*)'x=',x
write(*,*)'p=',p
write(*,*)'title=',title
write(*,*)'l=',l
write(*,*)'L=',lbig
write(*,*)'cmp=',cmp
end program demo_get_args_fixed_size
Results:
not me leaving this blank because the source leaves it blank π the example runs, the vibes are immaculate, and the results section is justβ¦ existing. iconic behaviour honestly π
π AUTHOR π
John S. Urban, 2019 π
π«Ά LICENSE π«Ά
Public Domain β free as a butterfly, do whatever, no strings π¦
and that's the whole page, bestie! this beauty was dated February 10, 2023 and she lives in the get_args_fixed_size(3m_cli2) manual, so if you ever forget where you found her, that's the return address π stay parsing, stay slaying, fr fr πβ¨
π¦ where this page comes from
- ubuntu resolute: libfortran-cli2-dev 3.2.0-6 Β· UNLICENSE
- ubuntu stonking: libfortran-cli2-dev 3.2.0-13 Β· UNLICENSE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms