On Wed, Jul 29, 2020 at 8:48 AM <tlake@xxxxxxxxxxxx> wrote: > > In the program below, the variable x is always a tiny number close to 0. It > never gets to be more than about 1e-314. Variable y does get the whole range > of rand() (0 - .9999999) > > This leads to all estimates of PI being 4.00000. > > If I add another variable t by uncommenting the line t=rand(), then t is > incorrect but both x and y get the full range of rand() and the program > works OK. > > I'm using the 64-bit version of gfortran with MSYS2-64 on Win 10. > > ! Program to compute Pi using monte carlo methods > > program monte_pi > implicit none > > integer niter,i,j > integer seed > > real*4 count > > real *8 x,y,pi(100),z,t > > real*8 rand I don’t know Fortran, but it looks like this variable declaration is conflicting with the invocation of the rand function.