| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(input_t), | intent(in) | :: | me | |||
| character(len=*), | intent(in) | :: | key | |||
| real(kind=dp), | intent(in), | optional | :: | default_value(:) |
default value in case of missing key |
|
| integer, | intent(in), | optional | :: | n |
function input_dbl1d(me,key,default_value,n) result(val) class(input_t), intent(in) :: me character(*), intent(in) :: key real(dp), optional, intent(in) :: default_value(:) !! default value in case of missing key integer, optional, intent(in) :: n real(dp), allocatable :: val(:) type(type_list_item), pointer :: item type(type_scalar), pointer :: element integer :: i logical :: ok type(input_t) :: tmp 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_dbl1d: scalar node requires "n" for key: '//key if (allocated(val)) deallocate(val) allocate(val(n)) val = node%to_real(0.0_dp, 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_real(0.0_dp,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 class is(type_dictionary) tmp%root => node if(get1d_hdf5(tmp,val)) return end select if(present(default_value)) return error stop 'Can not convert to 1d array of "double" for key: '//key end function input_dbl1d