I have a large array (hundreds of MB), and using this is too slow
OPEN(file_ID, 'filename', action='write')
DO i = 1, N
write(file_ID, *) a(:,i)
ENDDO
call FLUSH()
even with using formatted output. There is no need to read the data
back in a session. So, could someone tell me the better way to flush
out all the data to the file quickly.
Tuan
|
|
0
|
|
|
|
Reply
|
bio_amateur
|
11/8/2010 9:28:04 PM |
|
bio_amateur <hoangtrongminhtuan@gmail.com> wrote:
> I have a large array (hundreds of MB), and using this is too slow
> OPEN(file_ID, 'filename', action='write')
> DO i = 1, N
> write(file_ID, *) a(:,i)
> ENDDO
> call FLUSH()
>
> even with using formatted output. There is no need to read the data
> back in a session. So, could someone tell me the better way to flush
> out all the data to the file quickly.
1. What you show above *IS* formatted output. I would guess that you are
making the common mistake of thinking that "formatted" means that a
format statement is involved. It doesn't. Formatting is the process of
converting the data to text form.
2. Formatted output is slow - pretty much always. Fast and formatted is
pretty much a contradiction; you aren't going to be able to change that.
So the obvious question is why you are using formatted output at all. If
you want speed, unformatted is the place to start. If you have
requirements that rule out unformatted, then you are petty much stuck.
3. Your mention of flushing, and the use of CALL FLUSH is confusing. Are
you actually talking about the time to physically flush the buffers to
disk or the time for the rest of the I/O? Those are two *VERY* different
questions. If you are talking about the rest of the I/O, that has little
to do with FLUSH. If you are actually talking about the time to flush
buffers to disk, that has little to do with Fortran, and you can't
trivially do much about it in Fortran code. It is true that lowering the
amount of data will lower the amount of time it takes to flush it to
disk; doing formatted I/O hurts there as well because in most cases,
formatted data takes significantly more space than the unformatted form.
--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain
|
|
0
|
|
|
|
Reply
|
nospam
|
11/8/2010 9:48:54 PM
|
|
What is the reason you want ASCII for?
Writing binary files would speed up the process.
For post-processing/reading the output you can write separate routines/
utilities.
You can write your array in 1 go, i.e. without looping over elements,
and use a large record-length to allow for large chuncks to be
written.
Arjan
|
|
0
|
|
|
|
Reply
|
Arjan
|
11/8/2010 9:52:49 PM
|
|
what about
open(file_id,file='filename',form='unformatted',access='sequential')
write(file_id) a
close(file_id)
?
Might not work if the size of "a" is too big for some system thing to handle.
bio_amateur wrote:
> I have a large array (hundreds of MB), and using this is too slow
> OPEN(file_ID, 'filename', action='write')
> DO i = 1, N
> write(file_ID, *) a(:,i)
> ENDDO
> call FLUSH()
>
> even with using formatted output. There is no need to read the data
> back in a session. So, could someone tell me the better way to flush
> out all the data to the file quickly.
>
> Tuan
|
|
1
|
|
|
|
Reply
|
Paul
|
11/8/2010 10:10:36 PM
|
|
|
3 Replies
1296 Views
(page loaded in 0.129 seconds)
|