Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

The best/efficient way of writing a huge 3D array into a binary file

dyun
Beginner
1,102 Views

Hi Everyone,

I am working on saving and reading a huge 3D array to and from a binary file. Using intel fortran compiler, the size of the array varies from 128x128x128 to 1024x1024x1024.

As far as I know, this array can be saved:

1.) elements by elements;

2.) row by row (or column by column, if see this 3D array is composed by a sequence of 2D arraies), or

3.) be saved as a single record.

But I am confused with which one of those three methods is the best, or in other words the most efficient, considering the consuming time (spend on saving and reading), accuracy and size of stored file (if different way will bring differences).

Thanks for your answers, comments and discussions.

0 Kudos
1 Solution
Steve_Lionel
Honored Contributor III
1,102 Views

For file size and "accuracy", a file opened with FORM="UNFORMATTED" is the only reasonable choice.

I would suggest that writing the whole array would be the most efficient in terms of time and resources. You may want to play with the BLOCKSIZE= value in OPEN to see if larger or smaller values make a difference. The default is 128KB and larger writes might end up more efficient. I assume you aren't interested in interweaving I/O and application work.

View solution in original post

0 Kudos
2 Replies
Steve_Lionel
Honored Contributor III
1,103 Views

For file size and "accuracy", a file opened with FORM="UNFORMATTED" is the only reasonable choice.

I would suggest that writing the whole array would be the most efficient in terms of time and resources. You may want to play with the BLOCKSIZE= value in OPEN to see if larger or smaller values make a difference. The default is 128KB and larger writes might end up more efficient. I assume you aren't interested in interweaving I/O and application work.

0 Kudos
dyun
Beginner
1,102 Views

Thanks for Steve's answer. I agree with you. I did a simple test, saving and reading data in three ways and then output their cpu time respectively.

0 Kudos
Reply