Fortran Fortran77: Data I/O in big file

AI Thread Summary
Handling large data files in Fortran 77 can be optimized by utilizing direct access file capabilities, which allow for efficient reading of specific records without sequential access. Instead of splitting a large file into multiple smaller files, it is recommended to create a single large record with a fixed length, enabling instant access to required data points. This approach minimizes I/O overhead and simplifies file management. If the data points cannot be directly indexed by record number, external indexing may be necessary. Additionally, using unformatted files can significantly enhance read/write speed. Caution is advised when using pointers, as they can slow down operations in complex scenarios.
Bistable
Messages
1
Reaction score
0
Hi there,

I have generated a huge data file (approx 500MB large) containing a few 100k lines of formatted data (format(1X, 200ES11.4)). As I believe handling such a large file might over and over again (will be opened by an explicit FE code) might slow down the process significantely, I was thinking to split this file into many smaller files that contain certain columns of data (eg. file element1.txt contains columns 1 and 2, element2.txt contains columns 1 and 3, element3.txt contains columns 1 and 4...element150.txt contains columns 1 and 151) and call those when I need them (I only need a few data points during the calculations). I managed to create those files, but I am struggeling to pass the correct data to those files. Pointers might be good, but I do not know if and how they work with fortran 77. Is there a simple way of doing this?

Thanks a lot.
 
Technology news on Phys.org
It depends on how you use the file.
If it is a huge stiffness matrix which you have to read from A-Z, then you do not have too many options.
If it is a file from which you extract information ("I only need a few data points during the calculations"), then you may seriously consider using the direct access file capability.
You will have to index the records, and your program will be able to read the required records directly, without a sequential read. Even if you have a file of 500 Mb with 100K+ records, the read is instant, and you can read or write in any order. The only catch is you will have to decide on a fixed record length on creation of the file, and the search is by record number. If the point numbers cannot be related to the record number, then external indexing will be required.
See, for example, a description at:
http://rsusu1.rnd.runnet.ru/develop/fortran/prof77/node162.html
or an example at:
http://rainbow.ldgo.columbia.edu/data/fortranreaddata.html

Note: you do not need to dissect the file. A huge record of length 2K is reasonable, and easier for you to work with. There will be less file handles, less indexes, and less I/O overhead.
 
Last edited by a moderator:
Is there any reason you can't read/write it as an unformatted file? MUCH faster. Also, do not directly operate on pointers if you're performing a complex operation, they are very very slow as well.
 
Thread 'Star maps using Blender'
Blender just recently dropped a new version, 4.5(with 5.0 on the horizon), and within it was a new feature for which I immediately thought of a use for. The new feature was a .csv importer for Geometry nodes. Geometry nodes are a method of modelling that uses a node tree to create 3D models which offers more flexibility than straight modeling does. The .csv importer node allows you to bring in a .csv file and use the data in it to control aspects of your model. So for example, if you...
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

Replies
1
Views
3K
Replies
6
Views
2K
Replies
12
Views
3K
Replies
5
Views
2K
Replies
1
Views
2K
Back
Top