Fortran -> how to delete double lines?
Fortran -> how to delete double lines?
(OP)
Hello everyone! I have trouble to deal with a text file like this:
1.21781250000000 47 0
1.21781250000000 48 0
1.21781250000000 49 0
1.21781250000000 50 0
1.21781250000000 51 0
1.21781250000000 52 0
1.21781250000000 53 0
1.21781250000000 54 0
1.21781250000000 47 0
1.21781250000000 48 0
1.21781250000000 49 0
1.21781250000000 50 0
1.21781250000000 51 0
1.21781250000000 52 0
1.21781250000000 53 0
1.21781250000000 54 0
1.21781250000000 47 0
1.21781250000000 48 0
1.21781250000000 49 0
1.21781250000000 50 0
1.21781250000000 51 0
1.21781250000000 52 0
1.21781250000000 53 0
1.21781250000000 54 0
I'd like to delete the double lines automatically. Can someone give me a tip or code how to erase them with fortran?
1.21781250000000 47 0
1.21781250000000 48 0
1.21781250000000 49 0
1.21781250000000 50 0
1.21781250000000 51 0
1.21781250000000 52 0
1.21781250000000 53 0
1.21781250000000 54 0
1.21781250000000 47 0
1.21781250000000 48 0
1.21781250000000 49 0
1.21781250000000 50 0
1.21781250000000 51 0
1.21781250000000 52 0
1.21781250000000 53 0
1.21781250000000 54 0
1.21781250000000 47 0
1.21781250000000 48 0
1.21781250000000 49 0
1.21781250000000 50 0
1.21781250000000 51 0
1.21781250000000 52 0
1.21781250000000 53 0
1.21781250000000 54 0
I'd like to delete the double lines automatically. Can someone give me a tip or code how to erase them with fortran?






RE: Fortran -> how to delete double lines?
Something like this:
http://www.unix.com/shell-programming-and-scriptin...
Mike Halloran
Pembroke Pines, FL, USA
RE: Fortran -> how to delete double lines?
You could do a sort instead, but you still need to check whether adjacent lines are identical.
Cheers
Greg Locock
New here? Try reading these, they might help FAQ731-376: Eng-Tips.com Forum Policies http://eng-tips.com/market.cfm?
RE: Fortran -> how to delete double lines?
It should be very simple to do in fortran (any version from 77 to 2008). Here's a simple pseudo-code-logic:
Allocate a character string array, a(:), at lease big enough to store all lines of the file.
Read each and every line into a character string array, a(1:???)
Now... look through each line (stored in a(:) looking for duplicate lines)
Do i = 1 to the total # of lines
Do j = i+1 to the total # of lines
If( a(i) == a(j) )Then
! you will be wanting to eliminate the jth line
End If
End Do
End Do
Now... write all of the non-eliminated lines back out to your file and re-save it.
The above is not the most efficient way to do it. However, if you don't have many thousands of lines and you don't have to do the operation over and over again... it's very simple and will execute very quickly.
Dan
RE: Fortran -> how to delete double lines?