| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(input_t), | intent(in) | :: | me | |||
| character(len=*), | intent(in) | :: | key | |||
| logical, | intent(in), | optional | :: | default_value(:) |
default value in case of missing key |
|
| integer, | intent(in), | optional | :: | n |
function input_bin1d(me,key,default_value,n) result(val) class(input_t), intent(in) :: me character(*), intent(in) :: key logical, optional, intent(in) :: default_value(:) !! default value in case of missing key integer, optional, intent(in) :: n logical, allocatable :: val(:) type(type_list_item), pointer :: item type(type_scalar), pointer :: element logical :: ok integer :: i if(present(default_value)) val = default_value if(.not.me%has_key(key) .and. present(default_value)) return select type(node=>me%node(key)) class is(type_scalar) if (.not. present(n)) & error stop 'input_bin1d: scalar node requires "n" for key: '//key if (allocated(val)) deallocate(val) allocate(val(n)) val = node%to_logical(.true., ok) call continue_if(node, ok) return class is(type_list) if (allocated(val)) deallocate(val) allocate(val(node%size())) item => node%first i = 1 do while(associated(item)) element => select_scalar(item%node); val(i) = element%to_logical(.true.,ok) call continue_if(element, ok) item => item%next i = i + 1 enddo if (present(n)) then if (size(val) /= n) then print*, 'Expected '//to_str(n)//' elements for "'//key//'" but YAML has '//to_str(size(val)) error stop 'Array size mismatch in YAML input.' endif endif return end select if(present(default_value)) return error stop 'Can not convert to 1d array of "logical" for key: '//key end function input_bin1d