Re: How to Read csv Files with both Characters and Numbers?



Lars Mossberg <Lars.Mossberg@xxxxxxxxx> wrote:

! "ierror" returns an error code:
....
! 1 "majsplit" is ASSOCIATED on entry
! 2 "majsplit" cannot be allocated
! 3 "minsplit" is ASSOCIATED on entry

Hmm. I presume that you are testing for this to help avoid things like
memory leaks. I'd be concerned, however, that such a test might be more
prone to cause problems than to find them. In particular, it is
nonstandard to even do the test if the pointer association status is
undefined, which is the initial state of pointers by default. An awful
lot of pointer-related problems are related to undefined association
status.

In this particular case, it would seem fine for the association status
to be undefined on entry, but the test might well give the misleading
result associated() returning true (or it might even abort if you have a
compiler that tries to catch such errors). One could avoid this with
sufficient discipline in the calling code, but I'd personally think that
requires at least as much discipline as is needed to avoid whatever
problems thisi test is trying to guard against.

Like many uses of pointers, this one pretty clearly "wants" to be an
allocatable, which wouldn't have such problems, but allocatables were
not allowed in such contexts until quite recently (f95+TR or f2003, and
it took quite a long time for compilers to get the TR implemented
reasonably well).

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.



Relevant Pages

  • Re: how DEALLOCATE statement works in f2003
    ... As there is no other pointer to those allocatables pointed ... deallocate anything allocatable _pointed_to_ by a pointer manually. ... way for you to create a memory leak with allocatables. ... The case involved also involved pointers, though, which I think is outside that dictum -- there is a memory leak, arising when an allocatable is deallocated, which happens because the allocatable contains pointers. ...
    (comp.lang.fortran)
  • Re: Derived type - valued function with pointer member.
    ... It was my understanding that pointers were needed to accomplish this. ... unless you embrace the common extension where ALLOCATABLES can be used. ... END TYPE mytype ... When I make the %vec's allocatable arrays instead, the program segfaults on calling vplus. ...
    (comp.lang.fortran)
  • Re: DO or FORALL control ... is not declared locally ?
    ... of pointers for which there is an allocatable array equivalent". ... Many current uses of pointer components are for ... things that would more naturally be allocatables. ...
    (comp.lang.fortran)
  • Re: Features chosen for Fortran 2008
    ... J3-41/2 Interoperability of pointers, allocatables, assumed-shape ... RU-03 Obsolescent: ENTRY ... UK-07 Pointer function references as actual arguments ... That's my only use of ENTRY. ...
    (comp.lang.fortran)
  • Re: how DEALLOCATE statement works in f2003
    ... contains pointers. ... Thus I stick by my claim that you cannot leak memory with allocatables. ...
    (comp.lang.fortran)