Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(arg_type), | intent(out), | allocatable | :: | args(:) |
subroutine get_arguments(args)
type(arg_type), allocatable, intent(out) :: args(:)
integer :: iarg, length
character(len=:), allocatable :: tmp
allocate(args(command_argument_count()))
do iarg = 1, size(args)
call get_command_argument(iarg, length=length)
allocate(character(len=length) :: tmp)
if (length > 0) then
call get_command_argument(iarg, tmp)
end if
call move_alloc(tmp, args(iarg)%arg)
end do
end subroutine get_arguments