There is a file that has,say, 1000 frames. Each frame contains different number of lines.Each line has two columns of integers.But,I do not know how many number of lines eac
One of the weaknesses of even modern versions of Fortran (IMO) is the lack of expanding arrays like std::vector
in C++ or GArray
in GLib/C. Yes, you could write such a thing yourself, but the lack of generics/templates means that you'd have to specialise for every type and kind, or mess about with class(*)
and allocatable scalars... urgh.
But I digress.
There are two options I can see. The first is to do two passes through the file, first counting the number of lines between each space, and allocating your frame arrays as you go, and the second pass to actually fill the arrays with data.
The second, possibly more "Fortran-y" way to do it is to have a temporary work array which is as large as you ever expect a single frame to be. Fill this with data, then when you reach the end of a frame, allocate an array of the right size and copy your just-read data into it.
Neither solution is particularly great though unfortunately.