Skip to content

Commit

Permalink
More error messages, aid in fixing #200,#237
Browse files Browse the repository at this point in the history
  • Loading branch information
njansson committed Feb 19, 2022
1 parent 52616fa commit 2eda49c
Showing 1 changed file with 36 additions and 8 deletions.
44 changes: 36 additions & 8 deletions src/adt/htable.f90
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@ recursive subroutine htable_set(this, key, data)
integer index, i

index = this%hash(key)
if (index .lt. 0) then
call neko_error("Invalid hash generated")
end if

i = this%size - 1

do while (i .ge. 0)
Expand Down Expand Up @@ -339,6 +343,8 @@ recursive subroutine htable_set(this, key, data)
allocate(htable_i4t4_t::tmp)
type is (h_cptr_t)
allocate(htable_cptr_t::tmp)
class default
call neko_error('Invalid htable key')
end select

call htable_init(tmp, ishft(this%size, 1), key, data)
Expand Down Expand Up @@ -456,7 +462,9 @@ subroutine htable_set_data(this, idx, data)
select type(hdp)
type is (h_cptr_t)
hdp = data
end select
end select
class default
call neko_error('Invalid htable data (set)')
end select
end subroutine htable_set_data

Expand Down Expand Up @@ -502,6 +510,8 @@ subroutine htable_get_data(this, idx, data)
type is (h_cptr_t)
data = hdp
end select
class default
call neko_error('Invalid htable data (get)')
end select
end subroutine htable_get_data

Expand Down Expand Up @@ -596,6 +606,8 @@ subroutine htable_set_key(this, idx, key)
type is (h_cptr_t)
kp = key
end select
class default
call neko_error('Invalid htable key (set)')
end select
end subroutine htable_set_key

Expand Down Expand Up @@ -666,6 +678,8 @@ subroutine htable_iter_data(this, data)
type is (h_cptr_t)
data = hdp
end select
class default
call neko_error('Invalid htable data (iter)')
end select

end subroutine htable_iter_data
Expand Down Expand Up @@ -763,7 +777,7 @@ function htable_iter_i4_value(this) result(value)
type is (integer)
value => hdp
class default
call neko_error('Key and data of different kind')
call neko_error('Key and data of different kind (i4)')
end select

end function htable_iter_i4_value
Expand All @@ -776,6 +790,8 @@ function htable_iter_i4_key(this) result(key)
select type (kp => this%t%t(this%n)%key)
type is (integer)
key => kp
class default
call neko_error('Invalid key (i4)')
end select

end function htable_iter_i4_key
Expand Down Expand Up @@ -877,7 +893,7 @@ function htable_iter_i8_value(this) result(value)
type is (integer(8))
value => hdp
class default
call neko_error('Key and data of different kind')
call neko_error('Key and data of different kind (i8)')
end select

end function htable_iter_i8_value
Expand All @@ -890,6 +906,8 @@ function htable_iter_i8_key(this) result(key)
select type (kp => this%t%t(this%n)%key)
type is (integer(8))
key => kp
class default
call neko_error('Invalid key (i8)')
end select

end function htable_iter_i8_key
Expand Down Expand Up @@ -976,7 +994,7 @@ function htable_iter_r8_value(this) result(value)
type is (double precision)
value => hdp
class default
call neko_error('Key and data of different kind')
call neko_error('Key and data of different kind (r8)')
end select

end function htable_iter_r8_value
Expand All @@ -989,6 +1007,8 @@ function htable_iter_r8_key(this) result(key)
select type (kp => this%t%t(this%n)%key)
type is (double precision)
key => kp
class default
call neko_error('Invalid key (r8)')
end select

end function htable_iter_r8_key
Expand Down Expand Up @@ -1077,7 +1097,7 @@ function htable_iter_pt_value(this) result(value)
type is (point_t)
value => hdp
class default
call neko_error('Key and data of different kind')
call neko_error('Key and data of different kind (pt)')
end select

end function htable_iter_pt_value
Expand All @@ -1090,6 +1110,8 @@ function htable_iter_pt_key(this) result(key)
select type (kp => this%t%t(this%n)%key)
type is (point_t)
key => kp
class default
call neko_error('Invalid key (pt)')
end select

end function htable_iter_pt_key
Expand Down Expand Up @@ -1195,7 +1217,7 @@ function htable_iter_i4t2_value(this) result(value)
type is (tuple_i4_t)
value => hdp
class default
call neko_error('Key and data of different kind')
call neko_error('Key and data of different kind (i4t2)')
end select

end function htable_iter_i4t2_value
Expand All @@ -1208,6 +1230,8 @@ function htable_iter_i4t2_key(this) result(key)
select type (kp => this%t%t(this%n)%key)
type is (tuple_i4_t)
key => kp
class default
call neko_error('Invalid key (i4t2)')
end select

end function htable_iter_i4t2_key
Expand Down Expand Up @@ -1313,7 +1337,7 @@ function htable_iter_i4t4_value(this) result(value)
type is (tuple4_i4_t)
value => hdp
class default
call neko_error('Key and data of different kind')
call neko_error('Key and data of different kind (i4t4)')
end select

end function htable_iter_i4t4_value
Expand All @@ -1326,6 +1350,8 @@ function htable_iter_i4t4_key(this) result(key)
select type (kp => this%t%t(this%n)%key)
type is (tuple4_i4_t)
key => kp
class default
call neko_error('Invalid key (i4t4)')
end select

end function htable_iter_i4t4_key
Expand Down Expand Up @@ -1415,7 +1441,7 @@ function htable_iter_cptr_value(this) result(value)
type is (h_cptr_t)
value => hdp
class default
call neko_error('Key and data of different kind')
call neko_error('Key and data of different kind (cptr)')
end select

end function htable_iter_cptr_value
Expand All @@ -1430,6 +1456,8 @@ function htable_iter_cptr_key(this) result(key)
select type (kp)
type is (h_cptr_t)
key => kp
class default
call neko_error('Invalid key (cptr)')
end select

end function htable_iter_cptr_key
Expand Down

0 comments on commit 2eda49c

Please sign in to comment.