This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: read file from asci file


M. Kilani wrote:
I have data in ascii file like this

name           value          description
x                  2.3            var1
y                  3.1            var...
e                  2.5            ...

I want to write a function that reads data and affects values to variables.
notice that the function should guess the name of the variable, and then
affect the value, ie. the order of the variables may change.

is there a function in fortran that do this?
is it easy to write?

Something similar can be done automatically with namelists. This would require you to reformat your input file to follow the standard namelist format.


Otherwise this kind of code is not hard to write in Fortran (or any programming language for that matter). Just read the first element from the line, then use SELECT ... CASE to decide which variable to drop the value from the second column in.

NB this is not a forum for general programming questions.

Cheers,
- Tobi


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]