Re: Read a list with undefined length

On Mar 25, 3:25 pm, Allamarein <matteo.diplom...@xxxxxxxxx> wrote:
When I use the READ statement, I use data file of this kind:


x   y
2   5
7   9
10 13

In other words in the file the number of records is explicit (an
INTEGER variable).
I would not specify the number of records.
I am reading the CVF guide and I found this:
"err, end, eor
Are branch specifiers if an error (ERR=label), end-of-file
(END=label), or end-of-record (EOR=label) condition occurs.
EOR can only be specified for nonadvancing READ statements."

Could I use this optional input for my purpose?
I have just posed this question, but I need a more complete answer.

Another possibility for reading a file without explicitly knowing the
number of data points is to inquire about the file size. Knowing the
file size and data type you can deduce the number of variables.

Say you have 2 variables of data written as 8-byte floating=>

integer,parameter :: dp = selected_real_kind(15) !Gives double
precision 8-byte
real(db),allocatable :: x(:),y(:)
integer :: fsize,fid,npnts
character(200) :: fname


inquire(fid,size=fsize) ! find file size. Typically file size is given
in bytes but check your compiler doc

npnts = fsize/(8*2) ! Divide by 8-bytes per data point * 2 variables -
gives # points per variable


Of course you will have to get ride of the "header" part of the file
that tells how many variables you have.

Mr. Herrmannsfeld idea about reading and processing individual points
is interesting. I typically read in all the data at once. With really
large data sets I could see how this could be very useful. Is there a
performance advantage (other than memory) to doing this?


Relevant Pages

  • Re: memory allocation question
    ... > | available in book form for reasonable money now. ... do *not* specify -- it can allow for more flexibility ... > | International Standard imposes no requirements. ... > Thanks for that explicit description, ...
  • RE: Reading Audio CD Text Data
    ... You should specify 2048 bytes when reading in cooked ... Reading Audio CD Text Data ... using IOCTL_CDROM_MEDIA_REMOVAL then I read the TOC from the cd using ...
  • Re: [RFC/RFT][PATCH -mm] swsusp: userland interface
    ... > Looks mostly okay, few nits... ... >> +The device can be open either for reading or for writing. ... please refer to the source code. ... > We should specify that userland suspend/resume utilities should lock ...
  • Re: sink maps problems
    ... If you use SINK_ENTRY (where you don't specify the IID of the source ... These heuristics work for some ... I prefer to specify an explicit ...
  • Re: Strategey Reading VERY large files
    ... I found fscan to be considerably faster for reading text coded numbers than ... dlmread, especially if you read line by line. ... values R and C specify the row and column where the upper left corner ...