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

read entire binary file into memory

andrew_s
Beginner
1,058 Views
I am reading a binary file using the open command. After reading the header I know the structure of the file. The actual data in the file which I am interested in is not stored sequentially so I have to read part of the data, change the current file position using fseek, and then read some more, and so on.

My program works as intended. If I read from my local hard drive it reads very quickly. If I read from the network it is much much slower. I presume this is becasue a request needs to be made everytime I read a bit more data (which I do a lot, so it really is a very big performance hit)

Is it possible to read the entire binary file into memory first, and then access the data using the read command as i have been doing? If it is possible, then it should be much faster when accessing a binary file from the network. (I have programmed something similar in Delphi before and that resulted in the desired speed up).

Many Thanks,

Andrew
0 Kudos
2 Replies
Steven_L_Intel1
Employee
1,058 Views
There is no built-in support for memory files using Fortran I/O. You could read the file into memory as a large array and then write your own routines to access it.
0 Kudos
andrew_s
Beginner
1,058 Views
Thanks for the information. I am now reading the file into a large character array and using the transfer function to convert between data of different types. This seems to work well.

Andrew
0 Kudos
Reply