开发者

Dynamic Hash-like data-structure in Fortran [closed]

Closed. This question is seeking recommendations for books, tools, software libraries, and more开发者_C百科. It does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 3 years ago.

Improve this question

Is there a library usable in Fortran, which allows the usage of sparse dynamic arrays (hash/dictionary like) besides the Judy arrays?


I have created an abstracted dictionary in fortran which might suit your needs.

See: https://github.com/zerothi/fdict

Basically it lets you do

type(dict) :: dic, dic2
dic = ('KEY'.kv.1)
dic = dic //('next'.kv. (/3.,5.,6./))
dic = dic //('string'.kv.'Hello world')
dic2 = ('string2'.kv.'Test')
dic = dic // ('dic2'.kvp.dic2)

Where you can save all intrinsic types and it can easily be extended to contain other data-types, it defaults to initially contain itself as another value. (the last line retains a dictionary as a pointer)

It does .kv. == key : value designation which is a deep copy, and .kvp. == key : pointer which is a reference copy. In this way you can store huge data without having to duplicate data and retrieve the pointer at some later point.

To elaborate on the idea, all data is stored as address pointers using a transfer call from a derived type containing the data pointer. In this way you trick the compiler to hand you the address of the fortran derived type, but forces you to retrieve it in the exact same manner.
By .kv. a pointer of the data-type is allocated and subsequently pointed to by the data-container, then afterwards the allocated pointer is nullifyied and lost thus forcing the user to know what they are doing (there is no garbage-collector in it ;) ). By .kvp. the pointer is directly saved without duplicating any memory.

The nice thing is that it is fortran90 compliant.


Haven't seen one built-in, but google returns a few:

FLibs: http://flibs.sourceforge.net/

Hash Tables: http://burtleburtle.net/bob/hash/evahash.html and http://www.cris.com/~Ttwang/tech/inthash.htm.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜