I am old enough to remember programming in Fortran using magnetic tapes.
The REWIND statement rewinds the tape to the start. So you will effectively be overwriting that file.
Just open a file for writing as normal, not as an append.
Stop me before I start talking about mounting ring out / ring in
The equivalent of REWIND in C stdlib and also Julia is the seek function. Without the REWIND (or seek) the writing would start wherever the tape had been left. Perhaps this is not relevant any more for modern I/O. But just in case I would translate the REWIND to seek(io, 0) .
It’s around 20k lines of code but very straightforward, as it is mainly manipulation of matrices and vectors.
I’m checking that matrices that are constructed inside subroutines are preallocated (Fortran does that in the declaration of variables section of a subroutine).
The main time-consuming task is changing the indexation of matrices from () to . It is time consuming because one has to interpret whether some parenthesis are actually grouping operations, rather than indexing or calling functions.
I’m also changing spelled-out greek letters to unicode (alpha to α), but that’s just me.
Yes, there should be still tape drives around. According to my memory the FORTRAN rewind (on VAX VMS, Norsk Data SINTRAN, etc.) would rewind the tape drive and subsequent writes would then overwrite files that were on the tape before, starting with the first one, and make the full length of the tape available for writing. To do this in Julia, one would need to use an external utility like mt. However, the file name 'pv.txt' suggests, that this is intended for ordinary files on a disk, and then the REWIND just after the OPEN has no effect. Just don’t open for appending, as already said. The equivalent of the WRITE is probably println (write would be in case of `OPEN( …, FORMAT=‘unformatted’) in FORTRAN).