Re: Read a list with undefined length

Allamarein <matteo.diplomacy@xxxxxxxxx> wrote:
When I use the READ statement, I use data file of this kind:


x y
2 5
7 9
10 13

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?

This has resulted in long discussions in the past.
There is no easy answer.

Well, in the days of static allocation it was easy. One allocated
the arrays as large as possible (on the single task machine) and
read in as much as one could.

With dynamic allocation, one has to know how big to allocate
the array to read in the data, but one doesn't know how big
until the data has been read. There are ways around that, but
not so easy to describe in one post.

My least favorite is to read the whole file counting records
but not storing data, REWIND, allocate, and read again. I am
not recommending it, but that is what some do.

-- glen

Relevant Pages

  • dgemm subroutine in BLAS - I think Ive cracked the difference, please confirm
    ... see what I'm talking about), so in the current state of memory allocation, ... but I have a problem when it comes to applying the dimensions. ... > In the Fortran 66 days it was because dynamic allocation didn't exist, ... > you allocate arrays big enough for the largest problem you might run into. ...
  • Re: Copying allocatable member
    ... obvious that allocation was happening by forcing the user to write it ... vendors being overly defensive about criticisms from clueless users who ... time imagining it being significant unless the arrays in question are ... reminded of some of the nasty cases that Henry Zongaro used to construct ...
  • Re: Fortran memory allocation (stack/heap) issues
    ... > rather than Fortran, ... dynamic allocation, and relatively little stack allocation. ... value return and arrays by reference. ...
  • Re: Save attribute for 3d arrays
    ... not deallocate and reallocate the arrays or anything like that. ... of logic that would connect the segfault to SAVE somehow not working. ... Odds are that there is an unrelated error somewhere else that is causing ... allocation. ...
  • Re: INTERFACE problem
    ... I have an integer at Fortran side, pass it by reference to C function, treat here as pointer, allocate memory and this C-pointer at Fortran side now is an integer which has represents address allocated at C side. ... I did something like this many years ago to allow dynamic allocation ... Then it was converted into a subroutine with the arrays and ... it called the sub by way of Pascal with those "pointers". ...