Do not report error if the key are not in dictionary
Closed this issue · 2 comments
jiangleads commented
Hello, I had build this cod under Intel Compile. Everything is ok except it do not report error when the keys are not in the dictionary. Can it report error when the keys are not in dictionary?
the codes are below:
program test
use fhash, only: fhash_tbl_t, key=>fhash_key
implicit none
integer :: istation
type(fhash_tbl_t) :: tbl
call tbl%set(key("key1"), value=1)
call tbl%get(key("key1"),istation)
print*,'key1',istation
call tbl%set(key("key2"), value=2)
call tbl%get(key("key2"),istation)
print*,'key2',istation
call tbl%set(key("key3"), value=3)
call tbl%get(key("key3"),istation)
print*,'key3',istation
call tbl%get(key("NONE"),istation)
print*,'NONE',istation
end program
LKedward commented
Hi, yes this is possible using the optional status variable:
program test
use fhash, only: fhash_tbl_t, key=>fhash_key
implicit none
integer :: istation, status
type(fhash_tbl_t) :: tbl
call tbl%get(key("NONE"),istation,stat=status)
if (status /= 0) then
Print*, "Key not found"
else
print*,istation
end if
end program
jiangleads commented
Hi, yes this is possible using the optional status variable:
program test use fhash, only: fhash_tbl_t, key=>fhash_key implicit none integer :: istation, status type(fhash_tbl_t) :: tbl call tbl%get(key("NONE"),istation,stat=status) if (status /= 0) then Print*, "Key not found" else print*,istation end if end program
Hello, Thank you for your reply!
That is great! Awsome :)