Re: fortran program reading an external text (and numbers) file and writing with edits
- From: "Les" <l.neilson@xxxxxxxxxxxxxxxxxxx>
- Date: Mon, 30 Oct 2006 17:14:49 -0000
<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
.
- References:
- Prev by Date: Re: F77 IO, multiple outputs per line
- Next by Date: Re: Help needed
- Previous by thread: Re: fortran program reading an external text (and numbers) file and writing with edits
- Next by thread: FORALL STATEMENT
- Index(es):
Relevant Pages
|