Random Numbers



Hello! Let me start this off by saying I am very new to Fortran. I
started learning it about a week and a half ago.

I have a program that has character strings (quotes) in an array, and
upon starting the program, the idea was that a random number generator
would then be used to produce a number within my array boundaries, and
that number would be used to specify the quote pulled up. I want the
quotes to vary each time you start the program. I was looking at random
seed, but I would rather that the user doesn't need to interact with
the program to vary the seed and get a new quote. Is there a different
method to accomplish this goal without user input? Like I said, I'm new
to this, so the simpler the solution, the more likely I am to
understand it. :)

Program Friendly
Implicit None
Character(LEN=50),Dimension(1:1500)::quotes
Real::x,lBound=1,uBound=1500
Integer::y

....I assign the quotes to the array here...

Call random_number(x)
x=(x*(uBound-lBound))+lBound
y=x
Print*, quotes(y)

End Program Friendly

Thank you!

Cat

.


Quantcast