Re: Read a list with undefined length
- From: "robin" <robin51@xxxxxxxxxxx>
- Date: Sun, 27 Mar 2011 00:31:01 +1100
Dick Hendrickson wrote in message <8v4bdnF5laU1@xxxxxxxxxxxxxxxxxx>...
On 3/25/11 2:25 PM, Allamarein wrote:
When I use the READ statement, I use data file of this kind:
I'm not sure I completely understand your question, but the normal way
to do things like this is
integer :: npts, x(1000), y(1000)
read (unit,*) npts
if (npts > 1000) stop
read (unit, *) (x(i), y(i), i=1,npts)
[ or even
do i = 1,npts
read (unit,*) x(i), y(i)
Where you first read in the npts value and then use this to control a
loop. You pick dimensions for x and y that you are sure should be big
That is the old-fashioned FORTRAN 77 and earlier way.
Better to allocate an array of the exact size from npts.
Then the arrays x and y are handy to pass to subroutines.