From: Dave Allured on 1 Feb 2010 12:41 Fortran_follower wrote: > > Hi, > > Can anyone please tell me is there any chance/way to find out the size > of a file/no.of rows in a file....without actually opening it and > running a loop till the end of file...? I have frequently found it most useful to run a dummy loop to count the number of lines in a text file, like you said, before allocating arrays and reading the actual data. This is a simple, standard fortran solution that does not use any processor dependent methods, so I encourage this method even though it seems inefficient. On modern computers, this method is fast and effective for all but the most enormous of data files. It seems that in modern operating systems, the second pass reads from an in-memory cache rather than from disk, thus making the time penalty almost imperceptible. --Dave |