Get CLA multiple values from a buffer.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
character(len=*), | intent(in) | :: | buffer |
Buffer containing values (parsed or default CLA value). |
||
class(*), | intent(inout) | :: | val(1:) |
CLA value. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
subroutine get_cla_list_from_buffer(self, buffer, val, pref) !< Get CLA multiple values from a buffer. implicit none class(command_line_argument), intent(inout) :: self !< CLA data. character(*), intent(in) :: buffer !< Buffer containing values (parsed or default CLA value). class(*), intent(inout) :: val(1:) !< CLA value. character(*), optional, intent(in) :: pref !< Prefixing string. integer(I4P) :: Nv !< Number of values. character(len=len(buffer)), allocatable :: vals(:) !< String array of values based on buffer value. integer(I4P) :: v !< Values counter. call tokenize(strin=buffer, delimiter=args_sep, toks=vals, Nt=Nv) select type(val) #if defined _R16P type is(real(R16P)) do v=1, Nv val(v) = cton(pref=pref,error=self%error,str=trim(adjustl(vals(v))),knd=1._R16P) if (allocated(self%choices).and.self%error==0) call self%check_choices(val=val(v),pref=pref) if (self%error/=0) exit enddo #endif type is(real(R8P)) do v=1, Nv val(v) = cton(pref=pref,error=self%error,str=trim(adjustl(vals(v))),knd=1._R8P) if (allocated(self%choices).and.self%error==0) call self%check_choices(val=val(v),pref=pref) if (self%error/=0) exit enddo type is(real(R4P)) do v=1, Nv val(v) = cton(pref=pref,error=self%error,str=trim(adjustl(vals(v))),knd=1._R4P) if (allocated(self%choices).and.self%error==0) call self%check_choices(val=val(v),pref=pref) if (self%error/=0) exit enddo type is(integer(I8P)) do v=1, Nv val(v) = cton(pref=pref,error=self%error,str=trim(adjustl(vals(v))),knd=1_I8P) if (allocated(self%choices).and.self%error==0) call self%check_choices(val=val(v),pref=pref) if (self%error/=0) exit enddo type is(integer(I4P)) do v=1, Nv val(v) = cton(pref=pref,error=self%error,str=trim(adjustl(vals(v))),knd=1_I4P) if (allocated(self%choices).and.self%error==0) call self%check_choices(val=val(v),pref=pref) if (self%error/=0) exit enddo type is(integer(I2P)) do v=1, Nv val(v) = cton(pref=pref,error=self%error,str=trim(adjustl(vals(v))),knd=1_I2P) if (allocated(self%choices).and.self%error==0) call self%check_choices(val=val(v),pref=pref) if (self%error/=0) exit enddo type is(integer(I1P)) do v=1, Nv val(v) = cton(pref=pref,error=self%error,str=trim(adjustl(vals(v))),knd=1_I1P) if (allocated(self%choices).and.self%error==0) call self%check_choices(val=val(v),pref=pref) if (self%error/=0) exit enddo type is(logical) do v=1, Nv read(vals(v),*,iostat=self%error)val(v) if (self%error/=0) then call self%errored(pref=pref,error=ERROR_CASTING_LOGICAL,log_value=vals(v)) exit endif enddo type is(character(*)) do v=1, Nv val(v)=vals(v) if (allocated(self%choices).and.self%error==0) call self%check_choices(val=val(v),pref=pref) if (self%error/=0) exit enddo endselect endsubroutine get_cla_list_from_buffer