I am translating another musical C program to Fortran. In the MIDI binary format, for each musical track I must write in the header of the track some bytes containing the size of its following data. As I don’t know that size before the end of the algorithm, I am using the C
ftell() function to memorize the position where that size must be written. And when the track is finished, I easily go back to that position using the
fseek() function, write the data size, then go back to the current end of the file to write other tracks, and so on. See:
I am really confused on how to do that in Fortran. I have not found exactly equivalent functions. Should I use
BACKSPACE as many times as needed (because it goes back only one record at a time)? But then, how to go back to the current end of the file? Making as many
READ as needed? (Note that happily, MIDI files are generally quite short: some kilobytes. Performance is not a problem.)
I could probably more easily work with an array, then transfer it to a file. But there is some elegance in the C way.
Thanks for help