[OT] fortran lib which provide python like data type

Rustom Mody rustompmody at gmail.com
Thu Jan 29 20:40:03 EST 2015


On Friday, January 30, 2015 at 4:09:19 AM UTC+5:30, beli... at aol.com wrote:
> On Thursday, January 29, 2015 at 10:01:00 AM UTC-5, Liu Zhenhai wrote:
> > Hi,
> > I am not sure here is the right place to ask this question, but I want to give it a shot:)
> > are there fortran libs providing python like data type, such as set, dict, list?
> > Thanks,
> > Yours liuzhenhai
> 
> The "Fortran library" http://bigdft.org/Wiki/index.php?title=Fortran_library appears to have some of what you want. I have not tried the code.
> 
> "The flib library provides an object called dictionary which is -- strictly speaking -- more than just a dictionary. It is polymorphic and can be a list or a dictionary, as in the python language. The other difference is that it keeps the order of the elements, which is very useful if we want to dump its contents to the yaml output. It represents indeed a tree of data, and for these reasons it will most likely change name into f_tree in a future release of the module.
> 
> These dictionaries are also used in the other parts of the flib library and are thus essential for its proper use. There are many examples in the file dicts.f90."

Interesting

Note the very first minimal example

FORTRAN

 use dictionary
 type(dictionary), pointer :: d
 d=>dict_new()
 call set(d//'toto',1)
 v = d//'toto'
 call dict_free(d)

The corresponding python

 d = dict()
 d['toto'] = 1
 v = d['toto']
 del(d)

In particular note the del in the python.

Should highlight the point that languages with gc, support data structures
in a way that gc-less languages - Fortran, C, C++ - do not and cannot.



More information about the Python-list mailing list