Subroutine/library to read a parametric file
- From: deltaquattro <deltaquattro@xxxxxxxxx>
- Date: Wed, 20 Jun 2012 04:26:24 -0700 (PDT)
I need to read a parametric file, i.e. a text file which has a structure like this:
i.e., a series of "keys" separated by "/", then a final key which can have different forms, but it's usually something like EtX_xxxxxxx where the first X is an integer, a ":" and finally a value, which depending on the key can be a string, an integer, a float, etc. Sometimes there's a space btw the semicolon and the value, and other times there's not (blame the different hands which modified the file format during the years!!!!). I guess the Computer Science term for this kind of data structure is a dictionary, but I'm not sure at all.
The order in which the keys appear is semi-arbitrary, in the sense that all keys pertaining to the same section, i.e. "Co1", "Pr1", "Se1", etc. are listed together, but, inside each section, they could appear in an arbitrary order. Also, I don't know how many section there are for each key, i.e. how many CoX, PrX, etc.
how do I read such a file in Fortran? Inside a section, a given key may appear everywhere, so if I start scanning the file for a given key, I may have to rewind it and go back to the top. Other than this, I'm a bit stranded since I've never really handled such stuff. Could you help me? A subroutine/library suited to the need would be the best, but suggestions on ho to DIY are also welcome. Thanks,