File: M_CLI2.3m_cli2.html

package info (click to toggle)
fortran-cli2 3.2.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 25,856 kB
  • sloc: f90: 6,172; javascript: 3,423; makefile: 189; sh: 25
file content (307 lines) | stat: -rwxr-xr-x 9,780 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<html> 
<head> 
<title> </title>
<style> 
px {font-family: "Lucida Console", Monaco, monospace }
p { font-size:100%; line-height:1.1em; }
body {xfont-style: sans-serif}
body {
color:#333; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:1em; line-height:1.3em; }
a:visited { color:#666; }
h1,h2,h3,h4,h5,h6 { color:#333; font-family:georgia, verdana, sans-serif; }
h1 { font-size:150%; page-break-before:auto;background-color: #aaaaff}
h2 { font-size:143%;color:teal; }
h3 { font-size:134%;color:blue; }
h4 { font-size:120%;color:gray; }
img { max-width: 55em}
p{ padding: 0;margin:0; }
p{ padding-right:1.4em; }
p{ padding-bottom:0.1em; }
p{ padding-top:1em; }
p{ whitespace: pre-wrap; }
h5,h6 { font-size:100% }
a.nav,a:link.nav, a:visited.nav { background-color:#FFF; color:#000; }
XXtable { border:double #000; border-collapse:collapse; }
XXtable { border-collapse:collapse; }
XXtd { border:thin solid #888; }
XXtd { border:none; }
li { margin-bottom:0.5em; }
blockquote { display:block; font-size:100%; line-height:1.1em; margin:0 0 0.5em; padding:0 2.5em; }
pre { background-color:#DDD; font-size:100%; overflow:auto; padding:1em; }
a,li span { color:#000; }
a:hover, a.nav:hover, a:hover math { background-color:#000; color:#FFF; }
#Container { margin:0 10px; text-align:center; background-color: #BBB}
#Content { border-top:none; margin:auto; padding:0.3em; text-align:left; width:100%; max-width:55em; background:#FFF}
span.webName { font-size:.5em; }
textarea#content { font-size: 1em; line-height: 1.125; }
h1#pageName { line-height:1em; margin:0.2em 0 0.2em 0; padding:0; }
.property { color:#666; font-size:100%; }
a.existingWikiWord[title]{ //border: 1px dashed #BBB; }
.byline { color:#666; font-size:1.0em; font-style:italic; margin-bottom:1em; padding-top:1px; } 
</style> 
</head>
<BODY bgcolor=#F0F0F0 text=#000000 link=#0000ff vlink=#C000C0 alink=#ff0000><A NAME=top></A>
<!--
<h5><a href="https://github.com/urbanjost/M_CLI2">[UP]</a></h5>
<button type="button" onclick="javascript:history.back()">Back</button>
-->
<div id="Container">
<div id="Content">
<CENTER>
<H1><HR><I>Manual Reference Pages &nbsp;-&nbsp;</I><NOBR>M_CLI2 (3m_cli2)</NOBR><HR></H1>
</CENTER>
<A name=0>

     <H3>NAME</H3>

</A>
<BLOCKQUOTE>
M_CLI2(3fm) - [ARGUMENTS::M_CLI2::INTRO] command line argument
parsing using a prototype command
(LICENSE:PD)
</BLOCKQUOTE>
<A name=contents></A><H3>CONTENTS</H3></A>
<BLOCKQUOTE>
<A HREF=#1>Synopsis</A><BR>
<A HREF=#2>Description</A><BR>
<A HREF=#3>Example</A><BR>
<A HREF=#4>Author</A><BR>
<A HREF=#5>License</A><BR>
<A HREF=#6>See Also</A><BR>
</BLOCKQUOTE>
<A name=7>

     <H3>SYNOPSIS</H3>

</A>
<BLOCKQUOTE>
Available procedures and variables:
<P>
<PRE>
     ! basic procedures
     use M_CLI2, only : set_args, get_args, specified, set_mode
     ! convenience functions
     use M_CLI2, only : dget, iget, lget, rget, sget, cget
     use M_CLI2, only : dgets, igets, lgets, rgets, sgets, cgets
     ! variables
     use M_CLI2, only : unnamed, remaining, args
     ! working with non-allocatable strings and arrays
     use M_CLI2, only : get_args_fixed_length, get_args_fixed_size
     ! special function for creating subcommands
     use M_CLI2, only : get_subcommand(3f)
<P>
</PRE>
</BLOCKQUOTE>
<A name=2>

     <H3>DESCRIPTION</H3>

</A>
<BLOCKQUOTE>
The M_CLI2 module cracks a Unix-style command line.
<P>
Typically one call to SET_ARGS(3f) is made to define the command
arguments, set default values and parse the command line. Then a call
is made to the convenience procedures or GET_ARGS(3f) proper for each
command keyword to obtain the argument values.
<P>
Detailed descriptions of each procedure and example programs are
included.
</BLOCKQUOTE>
<A name=3>

     <H3>EXAMPLE</H3>

</A>
<BLOCKQUOTE>
<P>
Sample minimal program which may be called in various ways:
<P>
<PRE>
    mimimal -x 100.3 -y 3.0e4
    mimimal --xvalue=300 --debug
    mimimal --yvalue 400
    mimimal -x 10 file1 file2 file3
<P>
</PRE>
Program example:
<P>
<PRE>
    program minimal
    use M_CLI2,  only : set_args, lget, rget, sgets
    implicit none
    real    :: x, y
    integer :: i
    character(len=:),allocatable :: filenames(:)
       ! define and crack command line
       call set_args(&#146; --yvalue:y 0.0 --xvalue:x 0.0 --debug F&#146;)
       ! get values
       x=rget(&#146;xvalue&#146;)
       y=rget(&#146;yvalue&#146;)
       if(lget(&#146;debug&#146;))then
          write(*,*)&#146;X=&#146;,x
          write(*,*)&#146;Y=&#146;,y
          write(*,*)&#146;ATAN2(Y,X)=&#146;,atan2(x=x,y=y)
       else
          write(*,*)atan2(x=x,y=y)
       endif
       filenames=sgets() ! sget with no name gets "unnamed" values
       if(size(filenames) &gt; 0)then
          write(*,&#146;(g0)&#146;)&#146;filenames:&#146;
          write(*,&#146;(i6.6,3a)&#146;)(i,&#146;[&#146;,filenames(i),&#146;]&#146;,i=1,size(filenames))
       endif
    end program minimal
<P>
</PRE>
Sample program using get_args() and variants
<P>
<PRE>
    program demo_M_CLI2
    use M_CLI2,  only : set_args, get_args
    use M_CLI2,  only : filenames=&gt;unnamed
    use M_CLI2,  only : get_args_fixed_length, get_args_fixed_size
    implicit none
    integer                      :: i
    integer,parameter            :: dp=kind(0.0d0)
     !
     ! Define ARGS
    real                         :: x, y, z
    logical                      :: l, lbig
    character(len=40)            :: label    ! FIXED LENGTH
    real(kind=dp),allocatable    :: point(:)
    logical,allocatable          :: logicals(:)
    character(len=:),allocatable :: title    ! VARIABLE LENGTH
    real                         :: p(3)     ! FIXED SIZE
    logical                      :: logi(3)  ! FIXED SIZE
     !
     ! DEFINE AND PARSE (TO SET INITIAL VALUES) COMMAND LINE
     !   o set a value for all keywords.
     !   o double-quote strings, strings must be at least one space
     !     because adjacent double-quotes designate a double-quote
     !     in the value.
     !   o set all logical values to F
     !   o numeric values support an "e" or "E" exponent
     !   o for lists delimit with a comma, colon, or space
    call set_args(&#146;                         &
            & -x 1 -y 2 -z 3                &
            & -p -1 -2 -3                   &
            & --point 11.11, 22.22, 33.33e0 &
            & --title "my title" -l F -L F  &
            & --logicals  F F F F F         &
            & --logi F T F                  &
            & --label " " &
            ! note space between quotes is required
            & &#146;)
     ! Assign values to elements using G_ARGS(3f).
     ! non-allocatable scalars can be done up to twenty per call
    call get_args(&#146;x&#146;,x, &#146;y&#146;,y, &#146;z&#146;,z, &#146;l&#146;,l, &#146;L&#146;,lbig)
     ! As a convenience multiple pairs of keywords and variables may be
     ! specified if and only if all the values are scalars and the CHARACTER
     ! variables are fixed-length or pre-allocated.
     !
     ! After SET_ARGS(3f) has parsed the command line
     ! GET_ARGS(3f) retrieves the value of keywords accept for
     ! two special cases. For fixed-length CHARACTER variables
     ! see GET_ARGS_FIXED_LENGTH(3f). For fixed-size arrays see
     ! GET_ARGS_FIXED_SIZE(3f).
     !
     ! allocatables should be done one at a time
    call get_args(&#146;title&#146;,title) ! allocatable string
    call get_args(&#146;point&#146;,point) ! allocatable arrays
    call get_args(&#146;logicals&#146;,logicals)
     !
     ! less commonly &#46;&#46;&#46;
<P>
     ! for fixed-length strings
    call get_args_fixed_length(&#146;label&#146;,label)
<P>
     ! for non-allocatable arrays
    call get_args_fixed_size(&#146;p&#146;,p)
    call get_args_fixed_size(&#146;logi&#146;,logi)
     !
     ! all done parsing, use values
    write(*,*)&#146;x=&#146;,x, &#146;y=&#146;,y, &#146;z=&#146;,z, x+y+z
    write(*,*)&#146;p=&#146;,p
    write(*,*)&#146;point=&#146;,point
    write(*,*)&#146;title=&#146;,title
    write(*,*)&#146;label=&#146;,label
    write(*,*)&#146;l=&#146;,l
    write(*,*)&#146;L=&#146;,lbig
    write(*,*)&#146;logicals=&#146;,logicals
    write(*,*)&#146;logi=&#146;,logi
     !
     ! unnamed strings
     !
    if(size(filenames) &gt; 0)then
       write(*,&#146;(i6.6,3a)&#146;)(i,&#146;[&#146;,filenames(i),&#146;]&#146;,i=1,size(filenames))
    endif
     !
    end program demo_M_CLI2
<P>
</PRE>
</BLOCKQUOTE>
<A name=4>

     <H3>AUTHOR</H3>

</A>
<BLOCKQUOTE>
John S. Urban, 2019
</BLOCKQUOTE>
<A name=5>

     <H3>LICENSE</H3>

</A>
<BLOCKQUOTE>
Public Domain
</BLOCKQUOTE>
<A name=6>

     <H3>SEE ALSO</H3>

</A>
<BLOCKQUOTE>
<TABLE cellpadding=3>
<TR valign=top><TD width=3%>
o
</TD><TD>
get_args(3f)
</TD></TR>
<TR valign=top><TD width=3%>
o
</TD><TD>
get_args_fixed_size(3f)
</TD></TR>
<TR valign=top><TD width=3%>
o
</TD><TD>
get_args_fixed_length(3f)
</TD></TR>
<TR valign=top><TD width=3%>
o
</TD><TD>
get_subcommand(3f)
</TD></TR>
<TR valign=top><TD width=3%>
o
</TD><TD>
set_mode(3f)
</TD></TR>
<TR valign=top><TD width=3%>
o
</TD><TD>
specified(3f)
</TD></TR>
<TR></TR></TABLE></BLOCKQUOTE>
<P>
Note that the convenience routines are described under get_args(3f):
dget(3f), iget(3f), lget(3f), rget(3f), sget(3f), cget(3f) dgets(3f),
igets(3f), lgets(3f), rgets(3f), sgets(3f), cgets(3f)
<P><HR>
<TABLE width=100%><TR> <TD width=33%><I>Nemo Release 3.1</I></TD> <TD width=33% align=center>M_CLI2 (3m_cli2)</TD> <TD align=right width=33%><I>February 10, 2023</I></TD> </TR></TABLE><FONT SIZE=-1>Generated by <A HREF="http://www.squarebox.co.uk/download/manServer.shtml">manServer 1.08</A> from 2fca3bf4-1d20-4acb-b6d2-e218413bd8bf using man macros.</FONT>
<br><br><center><img src="images/M_CLI2.gif"></center>
</div>
</div>
</body>
</HTML>