samsami160
Technical User
- Jan 8, 2014
- 7
I have a problem, I wrote a simple code that first imports a text file (text file includes one column of numbers) after reading text file, I want to delete numbers in 2,4,6,8,10,... rows) then export it to new file, my code is below:
PROGRAM a
REAL::b
open (2,file="INPUTS.txt",action="read",status="OLD")
open (3,file="OUTPUTS.txt",action="write",status="REPLACE")
do i= 1,40,2
READ(2,*)b
WRITE(3,*)(b)
END DO
CLOSE(2)
CLOSE(3)
END PROGRAM
I write do i= 1,40,2 to delete numbers in 2,4,6,8,10,... rows but my result in new file is not so, produced numbers in new file by applying do i= 1,40,2 are twenty first row.
PROGRAM a
REAL::b
open (2,file="INPUTS.txt",action="read",status="OLD")
open (3,file="OUTPUTS.txt",action="write",status="REPLACE")
do i= 1,40,2
READ(2,*)b
WRITE(3,*)(b)
END DO
CLOSE(2)
CLOSE(3)
END PROGRAM
I write do i= 1,40,2 to delete numbers in 2,4,6,8,10,... rows but my result in new file is not so, produced numbers in new file by applying do i= 1,40,2 are twenty first row.