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




<Sharad_Regmi@xxxxxxxxxxx> wrote in message
news:1162221202.610897.160440@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,

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,


Sharad Regmi


Well the writing of the file with a different name is straightforward :

character(len=12) :: inputfile ! Use a suitable number for the
length of *your* file names
character(len=12) :: outputfile !

inputfile = "myfile.txt" ! This is the name of your input
file
outputfile = "newfile.txt" ! the output file with a different
name

! See your compiler manual on the "open" statement for the various
specifiers
! for example ACTION= , FORM =, STATUS=, and ERR = etc.
! Use suitable unit numbers for your own program in place of "10" and "20"
below.

! Open the first file for input
open (10, file=inputfile, access="sequential",form="formatted",
status="old",err=999)

! Open the second file for output
open (20, file=outputfile, access="sequential",form="formatted",
status="replace", err=999)

Then for every read of the input file see if you need to change any data. If
so make the changes.
Write to the output file, whether the data has changed or not.


Les


.



Relevant Pages

  • XP Pro - CVF permission problem
    ... I'm having trouble with a Fortran program running under XP Professional ... input file because it doesn't have permission to do so. ... I'm afraid I have a profound ignorance of XP Pro and how it determines ... be cured by some compilation switch or other. ...
    (comp.lang.fortran)
  • Re: Optimizing product by 2
    ... | nospam@xxxxxxxxxxxxx (Richard Maine) wrote: ... you should be more concerned about writing clear (and ... | This reminds me of a fortran program I saw once about 30 years ago. ... Ahh, the old days! ...
    (comp.lang.fortran)
  • Re: sorting records in a binary file
    ... Open a new output file. ... Read your input file up to the point where the record to be ... Continue reading past the unwanted ... skipping 'deleted' records while writing ...
    (alt.comp.lang.learn.c-cpp)
  • Re: [OT] Changing the case of filenames
    ... > I am running a fortran program which requires all input file names to be ... > uppercase. ... As things were originally done in Windo$e all the filenames ...
    (Fedora)
  • Re: [OT] Changing the case of filenames
    ... On Fri, 2005-04-29 at 19:23 +0530, Rahul Sundaram wrote: ... > David Niemi wrote: ... >>I am running a fortran program which requires all input file names to be ...
    (Fedora)