Re: g77 and DVF works fine but ifc causes a run-time error! Any ideas?

From: Richard Maine (nospam_at_see.signature)
Date: 12/19/03


Date: Fri, 19 Dec 2003 09:37:10 -0800


"Charles Russell" <STOPworworSPAM@bellsouth.net> writes:

> Why would one ever use a final dimension of 1 for any reason but assumed
> size?

Innumerable reasons. I assure you that in the "why would anything
ever do anything so strange" list, this one is pretty mundane.
Fundmentally, it is a valid, natural, and sensible thing to do for
quite a few situations. The fact that some of them could also be
written as scalars doesn't automatically mean that everyone necessarily
wants to in all cases.

Rank matters. Just because an array of size 1 has only one element,
that does not make it the sam ething as a scalar. It might logically
still be an array of size 1. Some people might find it more natural
to write it that way...and there are places where the standard
*REQUIRES* you to write it that way.

For example, suppose you have a subroutine with an array dummy
argument. The standard does not allow you to pass a named scalar
variable to it as an actual argument (except for an array element,
which is a special case). It will often, perhaps even usually, work
anyway, but it has never been standard-conforming. Quite a few
current compilers will bitch about it if you don't manage to "hide"
the problem from them. And it won't work at all with generics in
any compiler.

Also, automatic code writing software isn't likely to special-case
a size of 1. Why should it? If something is logically an array,
but the application in question needs only a single element, it
would be a lot of mostly pointless complication for the software
to change it to a scalar (even more so if multiple cases needed
to work together - some size 1 and some larger).

Or human written software can have the same issues of why do the
special case differently. Writing specific application modules to go
in a general program. The program handles arrays of arbitrary size
for something. I have only one of them for the current application.
Just give the program the natural size 1 array. That will sure make
it easier if I later add a second one. Besides that way I'll just
need to follow exactly how the program documentation shows to set up
things. I might even have a template of declarations and interface to
copy from. Why go out of my way to change it?

There are also a bunch of reasons that are a bit on the strage side
and mostly nonstandard, but the ones above are pretty mundane and
standard-conforming (and even required for standard conformance
in some cases).

Occasionally there can be reason to write the special case differently.
Perhaps you'll get better performance or something. The same
answer isn't best for all cases.

Next you are going to ask why anyone would write an array of size
zero. Yes, I've seen that one also. Done it even, for multiple
reasons. Most common is when my particular application doesn't
use one feature of a general program. Also occasionally done it
for more obscure reasons.

-- 
Richard Maine
email: my last name at domain
domain: sumertriangle dot net


Relevant Pages

  • Re: Derived Types, Allocatable Elements and Vectorization
    ... is an array". ... The reasons for that restriction have been discussed here before, ... answer is that the standard doesn't allow that. ... restriction is reasonably accurately desribed by the error message, ...
    (comp.lang.fortran)
  • Re: Cohens paper on byte order
    ... Nothing in the whole standard appears to me to try to talk ... > are external to the FIPS but which are used to test the validity of AES ... valid although obscure reasons, ...
    (sci.crypt)
  • Re: A new paradigm
    ... First I use a 3rd party btree handler for several reasons - cross platform ... Therefore all our programs use a standard common area ... but no one in the rest of the market seemed interested. ... people just shifting where they're buying their features and support ...
    (comp.databases.pick)
  • Re: A new paradigm
    ... One driver with a standard interface to ... standardised subroutines - everything in my suites is a subroutine ... First I use a 3rd party btree handler for several reasons - cross ... but no one in the rest of the market seemed interested. ...
    (comp.databases.pick)
  • Re: Why C Is Not My Favourite Programming Language
    ... And the number of modules in Python 2.4's Global Module Index is 362. ... The PDP architecture ideals ... fflushcan't be used to flush the contents of standard ... But it's not foolish that in ksh if you refer to an array name ...
    (comp.lang.c)