| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(input_t), | intent(in) | :: | me | |||
| character(len=*), | intent(in) | :: | key | |||
| character(len=*), | intent(in), | optional | :: | filter_key | ||
| character(len=*), | intent(in), | optional | :: | filter_value | ||
| logical, | intent(in), | optional | :: | empty |
function input_dict(me,key,filter_key,filter_value,empty) result(out_dict) class(input_t), intent(in) :: me character(*), intent(in) :: key character(*), optional, intent(in) :: filter_key, filter_value logical, optional, intent(in) :: empty class(input_t), allocatable :: out_dict class(type_dictionary), allocatable, target :: empty_dict type(type_dictionary) :: dict class(input_t), allocatable :: dict_array(:) allocate(out_dict) if (present(filter_key) .and. present(filter_value)) then dict_array = input_dict1d(me,key,filter_key,filter_value) if (size(dict_array) == 0) then error stop "Couldn't match key,value: "//filter_key//','//filter_value endif if (size(dict_array) > 1) then error stop "Key,value pair match multiple times: "//filter_key// & ','//filter_value endif out_dict%root => dict_array(1)%root else if(present(empty) .and. .not. me%has_key(key)) then if(empty) then allocate(empty_dict) out_dict%root => empty_dict return endif endif out_dict%root => me%node(key) if (.not.same_type_as(out_dict%root,dict)) & error stop 'Value in key: "'//key//'" is not dictionary.' endif end function input_dict