From: Richard Maine on
Richard Maine <nospam(a)see.signature> wrote:

> Alexandros Droseltis <usenet-1(a)alex-droseltis.com> wrote:
>
> > On 2009-11-05, Alexandros Droseltis <usenet-1(a)alex-droseltis.com> wrote:
> > >
> > > Thus, if HPR <= 0 (which always is for the 1st time of the loop), then X
> > > has no value assigned, and the assigment of HX after 3 lines
> > > (HX=HINF+HM*X) becomes deterministic; therefore X has no meaning to be
> > > used there.
> >
> > Here I assume that a variable with no assigned value has the value
> > 0. Is this so for Fortran IV?
>
> No. It can happen to be so for some compilers, but it is not and has not
> been part of the language specification....

On rereading what I wrote, I think that, while it was accurate, it
wasn't the most appropriate tone or message for the specific audience
(the OP). I was writing more as though to a programmer (much of the
audience here) instead of to someone trying to understand an existing
program. So to take the same message, but rephrase it for a different
audience, I'd say...

1. No, this isn't so for the language. (I have to stick with that part).
But it might well have been something that the author of the original
code assumed anyway. If you need to make an assumption like that for the
code to make sense, then that might be what was originally intended. If
that is the case, you want to fix the code by making the initial 0 value
explicit.

2. I'd alternatively guess there to be significant chance that the
author of the original code simply failed to notice that it used an
undefined value. It does take a certain level of discipline to watch for
such things. I know that my own younger self was less careful about such
things than my older, more experienced self (see signature).

--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain
From: glen herrmannsfeldt on
Richard Maine <nospam(a)see.signature> wrote:
(snip, someone wrote)

>> > Here I assume that a variable with no assigned value has the value
>> > 0. Is this so for Fortran IV?
(snip)

> On rereading what I wrote, I think that, while it was accurate, it
> wasn't the most appropriate tone or message for the specific audience
> (the OP). I was writing more as though to a programmer (much of the
> audience here) instead of to someone trying to understand an existing
> program. So to take the same message, but rephrase it for a different
> audience, I'd say...

> 1. No, this isn't so for the language. (I have to stick with that part).
> But it might well have been something that the author of the original
> code assumed anyway. If you need to make an assumption like that for the
> code to make sense, then that might be what was originally intended. If
> that is the case, you want to fix the code by making the initial 0 value
> explicit.

At this point, it looks like a mistake in the original code.

> 2. I'd alternatively guess there to be significant chance that the
> author of the original code simply failed to notice that it used an
> undefined value. It does take a certain level of discipline to watch for
> such things. I know that my own younger self was less careful about such
> things than my older, more experienced self (see signature).

In the case of programs using random numbers, it can be difficult to
detect 'wrong' results from the program output. It might be slightly
less random than it should be, or maybe slightly more. For some
programs, you can supply specific input data and check that the
output agrees with the input. That is very difficult for programs
using random numbers.

Though IBM compilers used to be pretty good about printing out
a table of all the variables and their location in memory.
(Especially useful when debugging from memory dumps.) A quick
look through that table can identify unexpected variable names.

-- glen
From: dpb on
glen herrmannsfeldt wrote:
....
> Though IBM compilers used to be pretty good about printing out
> a table of all the variables and their location in memory.
> (Especially useful when debugging from memory dumps.) A quick
> look through that table can identify unexpected variable names.
....

Particularly useful for this kind of problem was the CDC listing
cross-reference that also identified the first use of each variable that
went a long way towards being able to find uninitialized. Couldn't
catch everything, of course (COMMON being most obvious), but better than
most compilers for PC I've seen yet (not that I have a very large sample).

--
From: dpb on
Richard Maine wrote:
....

> 1. No, this isn't so for the language. (I have to stick with that part).
> But it might well have been something that the author of the original
> code assumed anyway. If you need to make an assumption like that for the
> code to make sense, then that might be what was originally intended. If
> that is the case, you want to fix the code by making the initial 0 value
> explicit.
....

I suppose it wouldn't be too far off base here to point out that many
compilers have an option that will do that so that one can as a shortcut
bypass having to find/fix all occurrences.

While certainly not the best solution in the long run nor my
recommendation as a final fix, it might help in getting somewhere more
or less quickly.

The other thing one can do that way is to start the rng w/ same sequence
and compare results with and without the "zero-memory" flag. If is a
difference, it'll identify there is a problem that needs addressed.

--
From: robin on
"Alexandros Droseltis" <usenet-1(a)alex-droseltis.com> wrote in message news:7lgd58F3ec3koU1(a)mid.individual.net...
| On 2009-11-05, Alexandros Droseltis <usenet-1(a)alex-droseltis.com> wrote:
| >
| > Thus, if HPR <= 0 (which always is for the 1st time of the loop), then X
| > has no value assigned, and the assigment of HX after 3 lines
| > (HX=HINF+HM*X) becomes deterministic; therefore X has no meaning to be
| > used there.
|
| Here I assume that a variable with no assigned value has the value
| 0. Is this so for Fortran IV?

No. That was so in the days of FORTRAN IV,
and is sstill so for virtually all implementations of Fortran now.