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:
npts
25
x y
2 5
7 9
10 13
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)
enddo ]
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
enough.
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.
.
- References:
- Read a list with undefined length
- From: Allamarein
- Re: Read a list with undefined length
- From: Dick Hendrickson
- Read a list with undefined length
- Prev by Date: Re: how to reference module variable without the use of USE, but explicit?
- Next by Date: Re: Read a list with undefined length
- Previous by thread: Re: Read a list with undefined length
- Next by thread: Re: Read a list with undefined length
- Index(es):