libSUFR
a LIBrary of Some Useful Fortran Routines
All Classes Namespaces Files Functions Variables Pages
command_line.f90
Go to the documentation of this file.
1!> \file command_line.f90 Procedures to handle command-line options and arguments
2
3
4! Copyright (c) 2002-2025 Marc van der Sluys - Nikhef/Utrecht University - marc.vandersluys.nl
5!
6! This file is part of the libSUFR package,
7! see: http://libsufr.sourceforge.net/
8!
9! This is free software: you can redistribute it and/or modify it under the terms of the European Union
10! Public Licence 1.2 (EUPL 1.2). This software is distributed in the hope that it will be useful, but
11! WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12! PURPOSE. See the EU Public Licence for more details. You should have received a copy of the European
13! Union Public Licence along with this code. If not, see <https://www.eupl.eu/1.2/en/>.
14
15
16
17
18!***********************************************************************************************************************************
19!> \brief Procedures to handle command-line options and arguments
20!!
21
23 implicit none
24 save
25
26
27 !> \brief Struct to store command-line options
28 type :: cl_options
29 character :: name*(99) !< Name of the cl option
30 character :: value*(99) !< Value of the cl option
31 logical :: short !< This is a short option (-s)
32 logical :: long !< This is a long option (--long)
33 logical :: has_val !< This option has a value/argument
34 end type cl_options
35
36contains
37
38
39 !*********************************************************************************************************************************
40 !> \brief Get an integer from the command line
41 !!
42 !! \param nArg Number of command-line argument (1,2,...)
43 !! \param arg Value of the argument (output)
44 !! \param status Exit status: 0: ok, !=0: not ok (output)
45
46 subroutine get_command_argument_i(nArg,arg, status)
47 implicit none
48 integer, intent(in) :: nArg
49 integer, intent(out) :: arg
50 integer, intent(out), optional :: status
51 integer :: lstatus
52 character :: str*(199)
53
54 call get_command_argument(narg, str)
55 read(str,*, iostat=lstatus) arg
56
57 if(present(status)) status = lstatus
58
59 end subroutine get_command_argument_i
60 !*********************************************************************************************************************************
61
62
63 !*********************************************************************************************************************************
64 !> \brief Get a long integer from the command line
65 !!
66 !! \param nArg Number of command-line argument (1,2,...)
67 !! \param arg Value of the argument (output)
68 !! \param status Exit status: 0: ok, !=0: not ok (output)
69
70 subroutine get_command_argument_l(nArg,arg, status)
71 use sufr_kinds, only: long
72
73 implicit none
74 integer, intent(in) :: nArg
75 integer(long), intent(out) :: arg
76 integer, intent(out), optional :: status
77 integer :: lstatus
78 character :: str*(199)
79
80 call get_command_argument(narg, str)
81 read(str,*, iostat=lstatus) arg
82
83 if(present(status)) status = lstatus
84
85 end subroutine get_command_argument_l
86 !*********************************************************************************************************************************
87
88
89 !*********************************************************************************************************************************
90 !> \brief Get a double-precision real from the command line
91 !!
92 !! \param nArg Number of command-line argument (1,2,...)
93 !! \param arg Value of the argument (output)
94 !! \param status Exit status: 0: ok, !=0: not ok (output)
95
96 subroutine get_command_argument_d(nArg,arg, status)
97 use sufr_kinds, only: double
98
99 implicit none
100 integer, intent(in) :: nArg
101 real(double), intent(out) :: arg
102 integer, intent(out), optional :: status
103 integer :: lstatus
104 character :: str*(199)
105
106 call get_command_argument(narg, str)
107 read(str,*, iostat=lstatus) arg
108
109 if(present(status)) status = lstatus
110
111 end subroutine get_command_argument_d
112 !*********************************************************************************************************************************
113
114
115 !*********************************************************************************************************************************
116 !> \brief Get a single-precision real from the command line
117 !!
118 !! \param nArg Number of command-line argument (1,2,...)
119 !! \param arg Value of the argument (output)
120 !! \param status Exit status: 0: ok, !=0: not ok (output)
121
122 subroutine get_command_argument_r(nArg,arg, status)
123 implicit none
124 integer, intent(in) :: nArg
125 real, intent(out) :: arg
126 integer, intent(out), optional :: status
127 integer :: lstatus
128 character :: str*(199)
129
130 call get_command_argument(narg, str)
131 read(str,*, iostat=lstatus) arg
132
133 if(present(status)) status = lstatus
134
135 end subroutine get_command_argument_r
136 !*********************************************************************************************************************************
137
138
139 !*********************************************************************************************************************************
140 !> \brief Read all the command-line arguments and return them in a character array
141 !!
142 !! \param verbose Verbosity: 0-print nothing, 1-print warnings, 2-print information, 3-print debugging info
143 !! \param narg_max Maximum array size for arguments
144 !!
145 !! \param nargs Number of command-line arguments found (output)
146 !! \param arguments Array of command-line arguments found (output)
147
148 subroutine read_all_commandline_arguments(verbose,narg_max, nargs,arguments)
149 implicit none
150 integer, intent(in) :: verbose, narg_max
151 integer, intent(out) :: nargs
152 character, intent(out) :: arguments(narg_max)*(*)
153
154 integer :: ia
155 character :: arg*(len(arguments))
156
157 nargs = 0
158 arguments = ''
159
160
161 nargs = command_argument_count()
162 if(verbose.ge.1) write(*,'(/,A,I6)') ' Arguments found:',nargs
163 if(nargs.eq.0) return
164
165 if(nargs.gt.narg_max) then
166 write(0,'(A,I6,A)')' * WARNING: narg_max is too small; only the first',narg_max,' arguments will be read!'
167 nargs = narg_max
168 end if
169
170 do ia = 1,nargs
171 call get_command_argument(ia,arg)
172 arguments(ia) = trim(arg)
173 if(verbose.ge.3) write(*,'(A,I3,A)') ' argument',ia,': '//trim(arg)
174 end do
175
176 end subroutine read_all_commandline_arguments
177 !*********************************************************************************************************************************
178
179
180
181 !*********************************************************************************************************************************
182 !> \brief Determine the type of each command-line argument found:
183 !! - normal or short option (i.e., with two dashes or one)
184 !! - option with or without argument
185 !!
186 !! \param verbose Verbosity: 0-print nothing, 1-print warnings, 2-print information, 3-print debugging info
187 !! \param nargs Number of command-line arguments
188 !! \param arguments Array of command-line arguments
189 !!
190 !! \param types Array with command-line argument types: 10: normal option (no value), 20/21: short option (one dash) (output)
191 !! without/with value, 22: value for short option, 30/31: long option (two dashes) without/with value
192 !! 33: value for long option
193
194 subroutine get_commandline_argument_types(verbose, nargs,arguments, types)
195 implicit none
196 integer, intent(in) :: verbose, nargs
197 integer, intent(out) :: types(nargs)
198 character, intent(in) :: arguments(nargs)*(*)
199
200 integer :: ia,il, typ, oldtyp, ltypes(0:nargs)
201 character :: arg*(len(arguments)), abc*(52)
202 logical :: has_letters
203
204 abc = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
205
206 oldtyp = 0
207 do ia=1,nargs
208 arg = trim(arguments(ia))
209
210 has_letters = .false.
211 do il=1,52
212 if(index(arg,abc(il:il)).ne.0) then
213 has_letters = .true. ! argument contains a letter
214 exit
215 end if
216 end do
217
218 typ = 0
219 if(index(arg,'--',.false.).eq.1) then ! argument starts with two dashes: long option
220 typ = 30 ! long option
221 else if(index(arg,'-',.false.).eq.1 .and. has_letters) then ! argument starts with one dash: short option
222 typ = 20 ! short option
223 else ! argument doesn't start with a dash: normal option
224 typ = 10 ! normal option
225 if(oldtyp.eq.20 .or. oldtyp.eq.30) then ! argument is a variable (and ia>1)
226 ltypes(ia-1) = oldtyp + 1 ! previous argument is an option with a variable (21, 31)
227 typ = oldtyp + 2 ! argument is a variable for a short or long option (22, 32)
228 end if
229 end if
230
231 ltypes(ia) = typ
232 oldtyp = typ
233
234 end do ! ia
235
236 if(verbose.ge.3) then
237 do ia=1,nargs
238 write(*,'(A,I6,A15,3I6)') 'Types:',ia,trim(arguments(ia)),ltypes(ia),ltypes(ia)/10,mod(ltypes(ia),10)
239 end do
240 end if
241
242 types(1:nargs) = ltypes(1:nargs) ! ltypes(0:nargs) is needed because types(ia-1) above triggers a warning in gfortran-8
243
244 end subroutine get_commandline_argument_types
245 !*********************************************************************************************************************************
246
247
248
249 !*********************************************************************************************************************************
250 !> \brief If short command-line options are found (i.e., starting with one dash), split them, e.g. "-bar" -> "-b -a -r"
251 !!
252 !! \param verbose Verbosity: 0-print nothing, 1-print warnings, 2-print information, 3-print debugging info
253 !! \param narg_max Maximum number of command-line arguments
254 !!
255 !! \param nargs Actual number of command-line arguments (I/O) (output)
256 !! \param arguments Array of command-line arguments (I/O) (output)
257 !! \param types Array with command-line argument types: 10: normal option (no value), 20/21: short option (one dash) (output)
258 !! without/with value, 22: value for short option, 30/31: long option (two dashes) without/with value
259 !! 33: value for long option
260
261 subroutine split_short_cl_options(verbose, narg_max, nargs,arguments,types)
262 use sufr_system, only: quit_program
263
264 implicit none
265 integer, intent(in) :: verbose, narg_max
266 integer, intent(out) :: nargs
267 character, intent(inout) :: arguments(narg_max)*(*)
268 integer, intent(inout) :: types(narg_max)
269
270 integer :: ia1,ia2, typ1, dn0, ib
271 character :: arg1*(len(arguments)), arg2*(len(arguments))
272 character :: new_args(narg_max)*(len(arguments))
273 integer :: new_types(narg_max)
274 logical :: found_duplicate
275
276 ! Count the change in number of short options (e.g. -abc means -a -b -c, 1->3, hence dn0=2)
277 dn0 = 0
278 do ia1 = 1,nargs
279 arg1 = trim(arguments(ia1))
280 typ1 = types(ia1)
281 if(typ1.eq.20.or.typ1.eq.21) then ! Short option with or without argument
282 dn0 = dn0 + len_trim(arg1) - 2
283 end if
284 if(verbose.ge.3) print*, 'Extra parameters: ', arg1, typ1, dn0
285 end do
286 if(dn0+nargs.gt.narg_max) call quit_program('Command-line argument arrays too small')
287
288 ia2 = 0
289 do ia1 = 1,nargs
290 arg1 = trim(arguments(ia1))
291 typ1 = types(ia1)
292
293 if(typ1.eq.20.or.typ1.eq.21) then ! Short option
294 do ib=2,len_trim(arg1)
295 ia2 = ia2 + 1
296 new_args(ia2) = '-'//arg1(ib:ib)
297 new_types(ia2) = typ1
298 if(ib.ne.len_trim(arg1)) new_types(ia2) = 20 ! Short option without value
299 end do
300 else ! Not a short option
301 ia2 = ia2 + 1
302 new_args(ia2) = arguments(ia1)
303 new_types(ia2) = typ1
304 end if
305 end do ! ia1
306
307 arguments = new_args
308 types = new_types
309
310 nargs = ia2
311
312
313 ! Find and remove the earlier occurrence of double short options:
314 ib = 0
315 ia1 = 0
316 do while(ia1.lt.nargs)
317 ia1 = ia1 + 1
318 arg1 = trim(arguments(ia1))
319 typ1 = types(ia1)
320
321 if(typ1.eq.20.or.typ1.eq.21) then ! Short option
322
323 found_duplicate = .false.
324 do ia2=ia1+1,nargs
325 arg2 = trim(arguments(ia2))
326 !typ2 = types(ia2)
327 if(trim(arg1).eq.trim(arg2)) then
328 found_duplicate = .true.
329 if(verbose.ge.3) write(*,'(A)')'Removing duplicate short option '//trim(arg1)
330 exit
331 end if
332 end do
333
334 if(found_duplicate) then ! Don't copy arg1 (the earlier occurrence)
335 if(typ1.eq.21) ia1 = ia1 + 1 ! Don't copy variable either
336 else ! Copy
337 ib = ib + 1
338 new_args(ib) = trim(arg1)
339 new_types(ib) = typ1
340 end if
341
342 else ! Not a short option -> copy
343 ib = ib + 1
344 new_args(ib) = trim(arg1)
345 new_types(ib) = typ1
346 end if
347 end do
348
349 arguments = new_args
350 types = new_types
351 nargs = ib
352
353 end subroutine split_short_cl_options
354 !*********************************************************************************************************************************
355
356
357
358 !*********************************************************************************************************************************
359 !> \brief Obtain command-line arguments and reduce them to options, values and types
360 !!
361 !! \param verbose Verbosity: 0-print nothing, 1-print warnings, 2-print information, 3-print debugging info
362 !! \param narg_max Maximum number of command-line arguments
363 !!
364 !! \param nopts Number of options found (without counting their variables) (output)
365 !! \param options Array of command-line options found (output)
366 !! \param values Array of command-line values found (i.e., the parameters that belong to an option) (output)
367 !! \param optypes Array of option types: 10: normal option (no value), 20/21: short option (one dash) without/with value, (output)
368 !! 30/31: long option (two dashes) without/with value
369 !! \param cl_option Struct containing command-line option names, values, has_val, short and long (output)
370
371
372 subroutine get_commandline_options_values(verbose,narg_max, nopts,options,values,optypes, cl_option)
373 implicit none
374 integer, intent(in) :: verbose, narg_max
375 integer, intent(out) :: nopts, optypes(narg_max)
376 character, intent(out) :: options(narg_max)*(*),values(narg_max)*(*)
377 type(cl_options), intent(out) :: cl_option(narg_max)
378
379 character :: arg*( max(len(options),len(values)) ), arguments(narg_max)*( max(len(options),len(values)) )
380 integer :: ia, io, nargs, typ, argtypes(narg_max)
381
382
383 call read_all_commandline_arguments(verbose,narg_max, nargs,arguments)
384 call get_commandline_argument_types(verbose, nargs,arguments, argtypes)
385 call split_short_cl_options(verbose, narg_max,nargs,arguments, argtypes)
386
387 options = ''
388 values = ''
389
390 cl_option(1:narg_max)%name = ''
391 cl_option(1:narg_max)%value = ''
392 cl_option(1:narg_max)%has_val = .false.
393 cl_option(1:narg_max)%short = .false.
394 cl_option(1:narg_max)%long = .false.
395
396
397 io = 0
398 do ia=1,nargs
399 arg = trim(arguments(ia))
400 typ = mod(argtypes(ia),10)
401 if(typ.le.1) then
402 io = io + 1
403 options(io) = trim(arg)
404 optypes(io) = argtypes(ia)
405 cl_option(io)%name = trim(arg)
406 !print*,io,'name: ',arg,optypes(io),nint(dble(optypes(io)-typ)/10.d0)
407 if(nint(dble(optypes(io)-typ)/10.d0) .eq. 2) cl_option(io)%short = .true.
408 if(nint(dble(optypes(io)-typ)/10.d0) .eq. 3) cl_option(io)%long = .true.
409 else if(typ.eq.2) then
410 values(io) = trim(arg)
411 cl_option(io)%value = trim(arg)
412 cl_option(io)%has_val = .true.
413 !print*,io,'value: ',arg
414 else
415 write(0,'(A,2I3)')' * Error in argument type:',ia,argtypes(ia)
416 end if
417 end do
418
419 nopts = io
420
421
422 ! Debug output:
423 if(verbose.ge.2) then
424 write(*,*)
425 do io=1,nopts
426 write(*,'(I6,5x,2A20,I6)') io,options(io),values(io),optypes(io)
427 end do
428 end if
429
430 if(verbose.ge.1) then
431 write(*,*)
432 do io=1,nopts
433 if(mod(optypes(io),10).eq.0) then
434 write(*,'(1x,A)', advance='no') trim(options(io))
435 else
436 write(*,'(2(1x,A))', advance='no') trim(options(io)),trim(values(io))
437 end if
438 end do
439 write(*,*)
440 end if
441
442 end subroutine get_commandline_options_values
443 !*********************************************************************************************************************************
444
445
446 !*********************************************************************************************************************************
447 !> \brief Print all command-line options and values found to stdOut for debugging
448 !!
449 !! \param nopts Number of options found (without counting their variables) (output)
450 !! \param options Array of command-line options found (output)
451 !! \param values Array of command-line values found (i.e., the parameters that belong to an option) (output)
452 !! \param optypes Array of option types: 10: normal option (no value), 20/21: short option (one dash) without/with value, (output)
453 !! 30/31: long option (two dashes) without/with value
454 !! \param cl_option Struct containing command-line option names, values, has_val, short and long (output)
455
456 subroutine print_commandline_options_values(nopts,options,values,optypes, cl_option)
457 implicit none
458 integer, intent(in) :: Nopts, optypes(nOpts)
459 character, intent(in) :: options(nOpts)*(*),values(nOpts)*(*)
460 type(cl_options), intent(in) :: cl_option(nOpts)
461
462 integer :: io
463
464
465 write(*,'(/,A)') ' Options found:'
466 do io=1,nopts
467 write(*,'(2I5,9(5x,A19))') io,optypes(io),options(io),values(io)
468 write(*,'(I5,2(5x,A19),3(3x,L3))') io,cl_option(io)%name, cl_option(io)%value, cl_option(io)%short, cl_option(io)%long, &
469 cl_option(io)%has_val
470 end do
471 write(*,*)
472
474 !*********************************************************************************************************************************
475
476
477 !*********************************************************************************************************************************
478 !> \brief Check whether a command-line option is present
479 !!
480 !! \param option Option to verify the presence of
481 !! \param verbose Verbosity: 0-print nothing, 1-print warnings, 2-print information, 3-print debugging info
482 !! \retval cl_option_present The cl option is present (true/false).
483
484 function cl_option_present(option, verbose)
485 implicit none
486 character, intent(in) :: option*(*)
487 integer, intent(in), optional :: verbose
488 logical :: cl_option_present
489
490 integer, parameter :: narg_max = 99
491 type(cl_options) :: cl_option(narg_max)
492 integer :: i, lverbose, nopts, optypes(narg_max)
493 character :: options(narg_max)*(len(option)+2), values(narg_max)*(len(option)+2) ! longer string to disting. "--foo" & "--foos"
494
495 lverbose = 0
496 if(present(verbose)) lverbose = verbose
497 call get_commandline_options_values(lverbose,narg_max, nopts,options,values,optypes, cl_option)
498
499 cl_option_present = .false.
500
501 if(nopts.eq.0) return
502
503 do i=1,nopts
504 if(trim(options(i)).eq.trim(option)) cl_option_present = .true.
505 end do
506
507 if(lverbose.ge.2) then
508 if(cl_option_present) then
509 write(*,'(2x,A)') 'Command-line option '//trim(option)//' was found.'
510 else
511 write(*,'(2x,A)') 'Command-line option '//trim(option)//' was not found.'
512 end if
513 end if
514
515 end function cl_option_present
516 !*********************************************************************************************************************************
517
518
519
520 !*********************************************************************************************************************************
521 !> \brief Retrieve the string argument/variable of a command-line option, if it exists
522 !!
523 !! \param option Option to get the argument from
524 !! \param string Argument/variable string (output)
525 !!
526 !! \retval cl_option_var_string Bool that indicates whether an option argument was present.
527
528 function cl_option_var_string(option, string)
529 implicit none
530 character, intent(in) :: option*(*)
531 character, intent(out) :: string*(*)
532 logical :: cl_option_var_string
533
534 integer, parameter :: narg_max = 99
535 type(cl_options) :: cl_option(narg_max)
536 integer :: i, verbose, nopts, types(narg_max)
537 character :: options(narg_max)*(len(option)+2) ! Must be longer than option to discern e.g. "--foo" from "--foos"
538 character :: values(narg_max)*(len(string))
539
540 verbose = 0 ! 0: no, 1-yes, 2-more
541 call get_commandline_options_values(verbose,narg_max, nopts,options,values,types, cl_option)
542
543 cl_option_var_string = .false.
544 if(nopts.eq.0) return
545
546 do i=1,nopts
547 if(trim(options(i)).eq.trim(option)) then
548 if(mod(types(i),10).ne.1) then
549 cl_option_var_string = .false. ! Option exists, but doesn't have an argument
550 else
551 cl_option_var_string = .true.
552 string = trim(values(i))
553 end if
554 end if
555 end do
556
557 end function cl_option_var_string
558 !*********************************************************************************************************************************
559
560
561 !*********************************************************************************************************************************
562 !> \brief Retrieve the integer argument/variable of a command-line option, if it exists
563 !!
564 !! \param option Option to get the argument from
565 !! \param intarg Argument/variable integer (output)
566 !!
567 !! \retval cl_option_var_int Bool that indicates whether an option argument was present.
568
569 function cl_option_var_int(option, intarg)
570 implicit none
571 character, intent(in) :: option*(*)
572 integer, intent(out) :: intarg
573 logical :: cl_option_var_int
574
575 integer, parameter :: narg_max = 99
576 type(cl_options) :: cl_option(narg_max)
577 integer :: i, verbose, nopts, types(narg_max)
578 character :: options(narg_max)*(len(option)+2) ! Must be longer than option to discern e.g. "--foo" from "--foos"
579 character :: values(narg_max)*(99)
580
581 verbose = 0 ! 0: no, 1-yes, 2-more
582 call get_commandline_options_values(verbose,narg_max, nopts,options,values,types, cl_option)
583
584 cl_option_var_int = .false.
585 if(nopts.eq.0) return
586
587 do i=1,nopts
588 !print*,i,trim(options(i)),' ',types(i),' ',trim(values(i)
589 if(trim(options(i)).eq.trim(option)) then
590 if(mod(types(i),10).ne.1) then
591 cl_option_var_int = .false. ! Option exists, but doesn't have an argument
592 else
593 cl_option_var_int = .true.
594 read(values(i), '(I99)') intarg
595 end if
596 end if
597 end do
598
599 end function cl_option_var_int
600 !*********************************************************************************************************************************
601
602
603 !*********************************************************************************************************************************
604 !> \brief Retrieve the floating-point argument/variable of a command-line option, if it exists
605 !!
606 !! \param option Option to get the argument from
607 !! \param dblarg Argument/variable floating-point (output)
608 !!
609 !! \retval cl_option_var_dbl Bool that indicates whether an option argument was present.
610
611 function cl_option_var_dbl(option, dblarg)
612 use sufr_kinds, only: double
613
614 implicit none
615 character, intent(in) :: option*(*)
616 real(double), intent(out) :: dblarg
617 logical :: cl_option_var_dbl
618
619 integer, parameter :: narg_max = 99
620 type(cl_options) :: cl_option(narg_max)
621 integer :: i, verbose, nopts, types(narg_max)
622 character :: options(narg_max)*(len(option)+2) ! Must be longer than option to discern e.g. "--foo" from "--foos"
623 character :: values(narg_max)*(99)
624
625 verbose = 0 ! 0: no, 1-yes, 2-more
626 call get_commandline_options_values(verbose,narg_max, nopts,options,values,types, cl_option)
627
628 cl_option_var_dbl = .false.
629 if(nopts.eq.0) return
630
631 do i=1,nopts
632 !print*,i,trim(options(i)),' ',types(i),' ',trim(values(i)
633 if(trim(options(i)).eq.trim(option)) then
634 if(mod(types(i),10).ne.1) then
635 cl_option_var_dbl = .false. ! Option exists, but doesn't have an argument
636 else
637 cl_option_var_dbl = .true.
638 read(values(i), *) dblarg
639 end if
640 end if
641 end do
642
643 end function cl_option_var_dbl
644 !*********************************************************************************************************************************
645
646
647
648end module sufr_command_line
649!***********************************************************************************************************************************
650
Procedures to handle command-line options and arguments.
subroutine get_command_argument_r(narg, arg, status)
Get a single-precision real from the command line.
subroutine split_short_cl_options(verbose, narg_max, nargs, arguments, types)
If short command-line options are found (i.e., starting with one dash), split them,...
logical function cl_option_present(option, verbose)
Check whether a command-line option is present.
subroutine print_commandline_options_values(nopts, options, values, optypes, cl_option)
Print all command-line options and values found to stdOut for debugging.
subroutine get_commandline_argument_types(verbose, nargs, arguments, types)
Determine the type of each command-line argument found:
logical function cl_option_var_string(option, string)
Retrieve the string argument/variable of a command-line option, if it exists.
subroutine get_commandline_options_values(verbose, narg_max, nopts, options, values, optypes, cl_option)
Obtain command-line arguments and reduce them to options, values and types.
subroutine get_command_argument_d(narg, arg, status)
Get a double-precision real from the command line.
logical function cl_option_var_int(option, intarg)
Retrieve the integer argument/variable of a command-line option, if it exists.
subroutine get_command_argument_i(narg, arg, status)
Get an integer from the command line.
subroutine get_command_argument_l(narg, arg, status)
Get a long integer from the command line.
logical function cl_option_var_dbl(option, dblarg)
Retrieve the floating-point argument/variable of a command-line option, if it exists.
subroutine read_all_commandline_arguments(verbose, narg_max, nargs, arguments)
Read all the command-line arguments and return them in a character array.
Provides kinds and related constants/routines.
Definition kinds.f90:26
integer, parameter double
Double-precision float. Precision = 15, range = 307.
Definition kinds.f90:35
integer, parameter long
Long integer.
Definition kinds.f90:31
System-related procedures.
Definition system.f90:23
subroutine quit_program(message)
Print a message to StdOut and stop the execution of the current program.
Definition system.f90:35
Struct to store command-line options.