Re: fortran program reading an external text (and numbers) file and writing with edits




Sharad_Regmi@xxxxxxxxxxx wrote:
Tobias wrote:
Sharad_Regmi@xxxxxxxxxxx wrote:
I am looking for some guidence in writing a fortran program which reads
an external file (one page consisting of text and numbers) and
printing the same file (with different name) with some edits.

Can this be done in fortran 90/95? Help appriciated,

....
Could you give an example (or explain in more details) how a line in
your file looks like and how you want to modify it? ...
....
My file looks like this; I will have to change some numbers (not text)
and write the file with a different name.
-------------------------------------------------------------------------------------------------------------------------------
#The rock macro assigns values of rock density, specific heat, and
#porosity.
rock
1 22491 1 2300. 1010. 1.0
22492 67473 1 2300. 1010. 0.12

#***********************************************************
perm
1 22491 1 6.793e-12 6.793e-12 6.793e-13
22492 67473 1 1.019e-12 1.019e-12 1.019e-13

....

You're really not giving much to work on here--if you want help, you
have to help. too...

How are you deciding which numbers (which _are_ text, too, btw) to
change and what to change them to?

How many of these files are there to change and are the changes
consistent across files?

Unless you have a great number of files to process with an algorithm
that can be codified relatively easily it would seem that what you
really need is a text editor rather than writing a Fortran program.
If, otoh, there is such an algorithm and there are a lot of these files
or you foresee doing this for a long time in the future, it might be
reasonable to write a routine to do so. Whether Fortran is the most
appropriate tool even then is somewhat debatable, at best.

.