dict_i4tuple_callstat_get Function

private function dict_i4tuple_callstat_get(dict, key, default_value) result(value)

Gets a value for a given key from the dictionary. If the key is not found the default_value will be returned. If the key is not found and default_value was not provided the program stops.

Arguments

Type IntentOptional Attributes Name
type(dict_i4tuple_callstat_type), intent(inout) :: dict
integer(kind=int_4), dimension(2) :: key
type(call_stat_type), intent(in), optional, POINTER :: default_value

Return Value type(call_stat_type), POINTER


Source Code

      FUNCTION dict_i4tuple_callstat_get(dict, key, default_value) RESULT(value)
      !! Gets a value for a given key from the dictionary.
      !! If the key is not found the default_value will be returned.
      !! If the key is not found and default_value was not provided the program stops.
         TYPE(dict_i4tuple_callstat_type), intent(inout)  :: dict
         INTEGER(kind=int_4), dimension(2)                                        :: key
         TYPE(call_stat_type), POINTER, intent(in), optional                :: default_value
         TYPE(call_stat_type), POINTER                                      :: value
         TYPE(private_item_type_i4tuple_callstat), POINTER                      :: item
         INTEGER(KIND=int_8)                                   :: hash, idx

# 268 "/__w/dbcsr/dbcsr/src/core/dbcsr_dict.F"
            NULLIFY (value)
# 270 "/__w/dbcsr/dbcsr/src/core/dbcsr_dict.F"

         IF (.not. ASSOCIATED(dict%buckets)) &
            DBCSR_ABORT("dict_i4tuple_callstat_get: dictionary is not initialized.")

         hash = hash_i4tuple (key)
         idx = MOD(hash, INT(size(dict%buckets), KIND=int_8)) + 1

         item => dict%buckets(idx)%p
         do while (ASSOCIATED(item))
            IF (item%hash == hash) THEN
               IF (ALL(item%key==key)) THEN
                  value =>item%value
                  return
               END IF
            END IF
            item => item%next
         end do

         IF (PRESENT(default_value)) THEN
            value =>default_value
            return
         END IF

         DBCSR_ABORT("dict_i4tuple_callstat_get: Key not found in dictionary.")
      END FUNCTION dict_i4tuple_callstat_get