Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a new line in a direct access file. (FORTRAN77) 1

Status
Not open for further replies.

fguser

Technical User
Mar 29, 2009
4
US
Hello,

How do I create a new line in a direct access file?

I have this code right below. Instead of writing the records all on the same line I'd like to write each record in a different line.

PROGRAM TEST
OPEN (UNIT=10, FILE='TEST.TXT', FORM='FORMATTED', ACCESS='DIRECT',
+STATUS='OLD', RECL=1)
DO N=0, 9, 1
WRITE (10,1, REC=N+1) N
END DO
CLOSE(10)
1 FORMAT (/,I1)
END

Thanks!
 
Change the record length to 3 for windows, 2 for linux. Change the format to (I1/)

 
After changing the format and the record lenght as sugested. My output was the following.

0 1 2 3 4 5 6 7 8 9

I'm using g95 to compile my program.

Do you have any other suggestions to my problem?

Here is my code:

PROGRAM TEST
OPEN (UNIT=10, FILE='TEST.TXT', FORM='FORMATTED', ACCESS='DIRECT',
+STATUS='OLD', RECL=3)
DO N=0, 9, 1
WRITE (10,1, REC=N+1) N
END DO
CLOSE(10)
1 FORMAT (I1/)
END
 
Try
Code:
      WRITE (10,1, REC=N+1) N, CHAR(13), CHAR(10)
...
10    FORMAT(I1,2A1)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top