Dear Noemi,
I apologize. You were right and I was wrong.
My coding would never work, because XI (the random number) is
larger than CUMUL(I) already at the first cumulative interval
when I = 0.
This is what happens when writing out of memory without checking!
What I had in mind was that it was not necessary to check both
extremes of each interval, as you did. But I did it the wrong way.
What I should have written is the following:
XI = FLRNDM(DUMMY)
DO 1 I = 0, NPOINT - 1
IF ( XI.LT.CUMUL(I+1) ) THEN ! <===
* come here when cumul(i) =< xi < cumul(i+1). Interpolate
SAMPLE = ENERGY(I) + (ENERGY(I+1) - ENERGY(I))
& * (XI - CUMUL(I)) / (CUMUL(I+1) - CUMUL(I))
GO TO 2
END IF
1 CONTINUE
2 CONTINUE
There is no need to check that XI.GE.CUMUL(I) because that check
has already been made in the previous step.
But of course you played safe, without special tricks, and you
were right.
I am sorry for my stupid mistake. Please forgive me
Alberto
-- Alberto Fasso` SLAC-RP, MS 48, 2575 Sand Hill Road, Menlo Park CA 94025 Phone: (1 650) 926 4762 Fax: (1 650) 926 3569 fasso@slac.stanford.eduReceived on Fri Apr 18 09:26:19 2008
This archive was generated by hypermail 2.1.8 : Fri Apr 18 2008 - 09:26:20 CEST