Re: reading configuration files



Bart Vandewoestyne wrote:
Hello all,

In an attempt to make a certain program more flexible in its use,
I would like it to read certain parameters from a textual
configuration file.

For as far as I can see now, the program parameters are all
simple scalar values, so I was wondering what could be the best
format for my configuration file, with respect to readability,
ease of reading in the values in my program and also taking into
account that the people who are entering the values in the
text-files do not know much about Fortran programming.

Some ways of doing it could be for example:

Option 1: use one space
----------------
parameter1 value1
parameter2 value2

Option 2: use :
---------------
parameter1:value1
parameter2:value2

Option 3: use tabs
------------------
parameter1 value1
parameter2 value2

Option 4: use two lines for parameter-value pairs
-------------------------------------------------
parameter1
value1
parameter2
value2

Option 5-...: any other suggestions?
------------------------------------
???

The names 'parameter1' and 'parameter2' do not necessarily have
to be the same length, and also I do not want to make many
assumptions on the input format of the numerical values (say I have
non-fortran users that need to modify the text-files and write
numerical values in it... so they don't know anything about
format descriptors etc...)


What would be a good format for my configuration files so that
i can easily read it in my fortran code and so that it is a bit
robust against different formats for the numerical values.
(e.g. a user could enter 1.0e3 or 1000 or 1000.0.

Thanks,
Bart


If the order of the values can be fixed, a simple file format
value_1 text description
value_2 text description
....

The values are read using list directed input (one value per read statement), and the text description is simply ignored.
.



Relevant Pages

  • reading configuration files
    ... format for my configuration file, with respect to readability, ... text-files do not know much about Fortran programming. ... assumptions on the input format of the numerical values (say I have ...
    (comp.lang.fortran)
  • Re: reading configuration files
    ... format for my configuration file, with respect to readability, ... text-files do not know much about Fortran programming. ... assumptions on the input format of the numerical values (say I have ... STRING = "a string like this" ...
    (comp.lang.fortran)
  • Re: reading configuration files
    ... format for my configuration file, with respect to readability, ... text-files do not know much about Fortran programming. ... assumptions on the input format of the numerical values (say I have ...
    (comp.lang.fortran)
  • Re: Best format for configuration file?
    ... "Jimbo" wrote in message ... > What's the best format to save a configuration file? ... I recommend XML. ... Look for configuration file information in the docs. ...
    (microsoft.public.dotnet.languages.csharp)