如何在使用 Fortran 读取 .txt 文件时删除重复的字符串行?这是我目前的代码,我正走在一条非常错误的道路上。目前,我正在尝试保持第一行不变,然后将其与之后的行进行比较。
PROGRAM REM_DUP
IMPLICIT NONE
CHARACTER(632) :: ROW3, ROW4
INTEGER :: I
OPEN(UNIT=23, FILE="APM_FORMATTED.TXT", ACTION="READ", STATUS="OLD")
OPEN(UNIT=25, FILE="APM_DUPLICATES.TXT", ACTION="WRITE", STATUS="NEW")
DO
READ(23,'(A632)', END=199) ROW3
I=1
OPEN(UNIT=24, FILE="APM_FORMATTED1.TXT", ACTION="READWRITE", ACCESS="APPEND", STATUS="OLD")
DO
READ(24,'(A632)', END=299) ROW4
IF(ROW3(33:52).EQ.ROW4(33:52)) THEN
I=I+1
IF (I.GE.3) THEN
WRITE(25,'(A632)') ROW3
ENDIF
ELSE
WRITE(24, '(A632)') ROW3
ENDIF
ENDDO
CLOSE(24)
ENDDO
199 关闭(23) 299 关闭(24) 关闭(25)
END PROGRAM REM_DUP