98 character(len=80) :: name
117 character function substr( str, i, j )
119 character(len=*),
intent(in):: str
120 integer,
intent(in):: i, j
122 if ( 1 <= i .and. i <= j .and. j <= len(str))
then 131 character function getopt( optstring, longopts )
133 character(len=*),
intent(in):: optstring
134 type(
option_s),
intent(in),
optional:: longopts(:)
137 character(len=80):: arg
140 if (
optind > iargc())
then 144 call getarg(
optind, arg )
145 if (
present( longopts ) .and. arg(1:2) ==
'--' )
then 147 elseif ( arg(1:1) ==
'-' )
then 158 type(
option_s),
intent(in):: longopts(:)
159 character(len=*),
intent(in):: arg
166 do i = 1,
size(longopts)
167 if ( arg(3:) == longopts(i)%name )
then 170 if ( longopts(i)%has_arg )
then 171 if (
optind <= iargc())
then 175 print
'(a,a,a)',
"Error: option '", trim(arg),
"' requires an argument" 184 print
'(a,a,a)',
"Error: unrecognized option '", trim(arg),
"'" 192 character(len=*),
intent(in):: optstring, arg
197 arglen = len( trim( arg ))
201 i = index( optstring,
optopt )
206 print
'(a,a,a)',
"Error: unrecognized option '-",
optopt,
"'" 209 if ( i > 0 .and.
substr( optstring, i+1, i+1 ) ==
':' )
then 212 if ( arglen >
grpind )
then 215 elseif (
optind <= iargc())
then 220 print
'(a,a,a)',
"Error: option '-",
optopt,
"' requires an argument" 223 elseif ( arglen >
grpind )
then character function getopt(optstring, longopts)
character function process_short(optstring, arg)
character function substr(str, i, j)
character function process_long(longopts, arg)