## (Pseudo) Random number generator help for a beginner

## (Pseudo) Random number generator help for a beginner

(OP)

Hello, it's been quite awhile since I was last programming in fortran and it was mostly for molecular modeling in chemistry.

I would like to ask for help with writing a random number generator. I would like it to generate 8 digits in hexadecimal system, this part I think I can do myself, but the problem is that I need every digit from that 8 random digits to be just a single number so not like this: (this is just an example)

AC98D

6374999

EF16383

1.72264576E-02

etc.

But just one number e.g.

A

9

D

2

etc.

I know that members of this forum are very advanced, nice and helpful people so I hope that there will be a good soul who would help me out.

I am using gcc (gfortran on a Mac).

This is what I've written so far:

program rand_test

implicit none

real a,b,c,d,e,f,g,h

integer seed

seed=time()

call srand(seed)

a=rand(0)

b=rand(0)

c=rand(0)

d=rand(0)

e=rand(0)

f=rand(0)

g=rand(0)

h=rand(0)

print *, "first 8 numbers:", a, b, c, d, e, f, g, h

end

I would like to ask for help with writing a random number generator. I would like it to generate 8 digits in hexadecimal system, this part I think I can do myself, but the problem is that I need every digit from that 8 random digits to be just a single number so not like this: (this is just an example)

AC98D

6374999

EF16383

1.72264576E-02

etc.

But just one number e.g.

A

9

D

2

etc.

I know that members of this forum are very advanced, nice and helpful people so I hope that there will be a good soul who would help me out.

I am using gcc (gfortran on a Mac).

This is what I've written so far:

program rand_test

implicit none

real a,b,c,d,e,f,g,h

integer seed

seed=time()

call srand(seed)

a=rand(0)

b=rand(0)

c=rand(0)

d=rand(0)

e=rand(0)

f=rand(0)

g=rand(0)

h=rand(0)

print *, "first 8 numbers:", a, b, c, d, e, f, g, h

end

## RE: (Pseudo) Random number generator help for a beginner

I tried for example this:

## CODE

or this (using arrays):

## CODE

Compilation and running:

## CODE

## RE: (Pseudo) Random number generator help for a beginner