LKedward / fhash

fpm package implementing a hash table with support for generic keys and values.
https://lkedward.github.io/fhash/
MIT License
38 stars 8 forks source link

Do Concurrent compatability #19

Open chuckyvt opened 1 year ago

chuckyvt commented 1 year ago

This falls under feature request instead of issue, but the current implantation of the tbl%get function has a couple 'non pure' subroutines, which block usage in 'Do Concurrent' loops. Not sure how difficult to change, but would be nice to be able to remove that restriction.

chuckyvt commented 1 year ago

I should point out that this was tested in Ifort/Ifx as of 2023.1. I can't speak to other compilers.

chuckyvt commented 1 year ago

Was able to clean up intent declarations on a number of routines and get the 'pure' flag added to them. But wasn't able to get past line 81 in the fhash_sll.f90 file.

if (allocated(node%value%scalar_data)) deallocate(node%value%scalar_data) allocate(node%value%scalar_data, source = value)

Ifort comes back with "A statement that might result in the deallocation of a polymorphic entity is not permitted in a pure procedure."

The following link from the Intel forum discussing the same issue. https://community.intel.com/t5/Intel-Fortran-Compiler/About-the-forbidden-deallocation-of-a-polymorphic-entity-in-a/td-p/1484958

LKedward commented 1 year ago

Hi @chuckyvt, thanks for taking the time to look into this and report here. I'd not heard of that restriction before, it seems quite limiting.

One way to get this to work could be to define a separate set_pure interface which only succeeds if data does not already exist for that key. Then we can define a separate pure procedure in fhash_sll which doesn't perform the deallocation.