I have a file txt with 8 lines.
<ShapeResults>
<Integrals YYYYY />
<Simplexes Rows="888" Cols="3">0,1,2;3,2663</Simplexes>
<Integrals YYYYY />
<Integrals NNNNN />
<Group ShapeType="Optum.Shapes.Face" XXXX, YYY, ShapeID="2".....>---> 10000 characters
<Simplexes Rows="888" Cols="3">0,1,2;3,2663</Simplexes>
<Integrals YYYYY />
</Group2>
</Group>
I will change a line (e.g. line 4) and I will have the same format in the rest of the file. Line 6 has 10,000 characters more or less and I do not how to copy and write in my file. I have tried creating a new file and copy all in that file, but It has a restriction of FORMAT (A999). I only copy 999 characters. See my code.
INTEGER :: RV_NUMBER, NRV, FN1, FN2, I
CHARACTER :: LINE*999, NAME*15, GEOS*50
REAL*8 :: X(1)
character :: totalstring*500 , formato*10, TAMANHOstring*3
character :: Gstring*50,Cstring*50,Fstring*50,FBstring*50,Estring*50
FN1 = 1
FN2 = 2
OPEN(UNIT=FN1,FILE=TRIM(GEOS),POSITION="REWIND",STATUS="OLD")
OPEN(UNIT=FN2,FILE="transito.txt",POSITION="REWIND",STATUS="UNKNOWN")
DO WHILE (.NOT. EOF(FN1))
READ(FN1,200) LINE
WRITE(FN2,200) LINE
END DO
CLOSE(FN2)
OPEN(UNIT=FN2,FILE="transito.txt",POSITION="REWIND",STATUS="OLD")
REWIND(FN2)
REWIND(FN1)
DO I=1,3
READ(FN2,200) LINE
WRITE(tamanhostring,'(I3)') LEN_TRIM(LINE)
formato = '(A' // adjustl(tamanhostring) // ')'
WRITE(FN1,trim(formato)) TRIM(LINE)
END DO
write(Cstring,'(F7.4)') X(1)
totalstring = ' <c>'
totalstring = trim(totalstring)//trim(Cstring)//'</c>'
READ(FN2,200) LINE
write(FN1,*) trim(totalstring)
DO WHILE (.NOT. EOF(FN2))
READ(FN2,200) LINE
WRITE(tamanhostring,'(I3)') LEN_TRIM(LINE)
formato = '(A' // adjustl(tamanhostring) // ')'
WRITE(FN1,trim(formato)) TRIM(LINE)
END DO
CLOSE(FN1)
CLOSE(FN2)
10 FORMAT(A24,G17.11,A5,ES21.15,A4)
20 FORMAT(A11,A2,F20.5)
200 FORMAT(A999)
I want to change only a line 4, and I want to have as the same format the rest of the file. The problem is in line 6 which has 10,000 characters more or less and I do not how to copy and write in my file.