18PROGRAM optionparser_test
29TYPE(optionparser) :: opt
30INTEGER :: optind, optstatus
33CHARACTER(len=80) :: name
36DOUBLE PRECISION :: dval
37TYPE(arrayof_integer) :: count_list
38TYPE(arrayof_real) :: value_list
39LOGICAL :: force, version
42CHARACTER(len=1024) :: exp_res
43TYPE(csv_record) :: csv_reader
44CHARACTER(len=80) :: ccheck
47DOUBLE PRECISION :: dcheck
51opt = optionparser_new(description_msg= &
52 'Test program for the optionparser class, &
53 &it just tests the arguments.', &
54 usage_msg=
'Usage: optionparser_test [options] expected_result')
58 'short and long character option with default value')
60 'long integer option with default value')
62 'short and long real option with default value')
65 'long real option without default value')
67 'short and long double precision option with default value, &
68 &this should be a positive number')
70 'integer array option, a comma-separated list of values can be provided, &
71 &the default is partially displayed, in this case it is 1,2,3')
73 'real array option, a comma-separated list of values can be provided, &
74 &the default in this case does not exist')
76 'logical option, it cannot have a default value because it is .FALSE. by design')
77CALL optionparser_add_count(opt,
'v',
'verbose', verbose, help= &
78 'count option without start value, it will be incremented at every appearence &
83CALL optionparser_add_help(opt,
'h',
'help', help=
'show an help message and exit')
84CALL optionparser_add(opt,
' ',
'version', version, help=
'show version and exit')
87CALL optionparser_parse(opt, optind, optstatus)
89IF (optstatus == optionparser_help)
THEN
91ELSE IF (optstatus == optionparser_err)
THEN
92 WRITE(*,
'(A)')
'Error in command-line arguments'
96 WRITE(*,
'(A,1X,A)')
'optionparser_test 1.0'
99IF (iargc() > optind)
THEN
100 WRITE(*,
'(A)')
'Error, zero or one non-option argument required'
114IF (iargc() < optind)
THEN
118CALL getarg(optind, exp_res)
119CALL init(csv_reader, exp_res)
122IF (ier /= 0 .OR. trim(ccheck) /= trim(name))
THEN
123 WRITE(*,
'(A)')
'Error in command-line argument --name'
128IF (ier /= 0 .OR. icheck /= nx)
THEN
129 WRITE(*,
'(A)')
'Error in command-line argument --nx'
134IF (ier /= 0 .OR. rcheck /= xval)
THEN
135 WRITE(*,
'(A)')
'Error in command-line argument --xval'
140IF (ier /= 0 .OR. rcheck /= yval)
THEN
141 WRITE(*,
'(A)')
'Error in command-line argument --yval'
146IF (ier /= 0 .OR. dcheck /= dval)
THEN
147 WRITE(*,
'(A)')
'Error in command-line argument --dval'
154IF (ier /= 0 .OR. icheck /= verbose)
THEN
155 WRITE(*,
'(A)')
'Error in command-line argument --verbose'
163END PROGRAM optionparser_test
Destructor for finalizing an array object.
Methods for successively obtaining the fields of a csv_record object.
Constructor for the class csv_record.
Add a new option of a specific type.
This module defines usefull general purpose function and subroutine.
Utilities for managing files.
Definitions of constants and functions for working with missing values.
Module for parsing command-line optons.