Fast output to ascii file

I have a large 2D array, it’s too slow to write out the data to ascii using

DO i = 1, col
    write (file_ID, *) a(:, i)
END DO

I tried using flush() , yet it’s still slow. Any suggestion please.

Tuan

Hi Tuan,

Calling flush will slow things down since this forces a write to the disk and disk I/O is the slow part. Instead, you want to use a larger system I/O buffer. I happen to be in the process of writing an example of using setvbuf for another users (See: I/O buffering behavior (2nd attempt)) which may help you as well.

Note that if the output does not need to be formatted, then it would be faster to output in binary.

  • Mat

Thanks Mat. I’ll check when an example from you is posted.

Tuan