Hi, I want to be able to read numbers inputed from a user into an array (Neutrons), and then add a count to an appropriate bin. The code is below.
I want to make sure that the array I am using (Neutrons(1000)) which stores the inputed numbers is used correctly in the code.
Thanks so much for your help!
I want to make sure that the array I am using (Neutrons(1000)) which stores the inputed numbers is used correctly in the code.
Code:
PROGRAM Binning
IMPLICIT NONE
INTEGER :: a, i, nrandoms
INTEGER :: bin(20) !** change according to # of bins
REAL :: Neutrons
DIMENSION [b]Neutrons(1000)[/b]
DO i=1, 20 !** change according to # of bins/ set bins initially to 0
bin(i) = 0
END DO
WRITE(*,*) 'Enter number of randoms'
READ(*,*) nrandoms
WRITE(*,*) 'Enter randoms'
DO a=1, nrandoms
READ(*,*) [b]Neutrons(a) [/b] !** read the 1000 random numbers and store in an array
IF [b](Neutrons(a)[/b] > .0288 .AND. [b]Neutrons(a)[/b] <= .0411) THEN
bin(1) = bin(1) + 1
ELSEIF (Neutrons(a) > .0411 .AND. Neutrons(a) <= .0538) THEN
bin(2) = bin(2) + 1
....
END IF
END DO
WRITE(*,) (bin(i), i=1, 20) !** change according to # of bins
END PROGRAM Binning
Thanks so much for your help!