Could anyone help me to understand why the call of the intrinsic RANDOM_NUMBER within a PARALLEL DO directive in some cases it returns values larger than 1?
Here it follows the test code I made to show the problem.
program test implicit none real*8 e_r integer*4 nps,i,j write(*,*) 'Number of tests' read(*,*) nps i=0 c$OMP parallel do private(e_r) reduction(+:i) do j=1,nps call random_number(e_r) if(e_r.gt.1.0d0)then write(*,*) e_r i=i+1 endif end do c$OMP end parallel do write(*,*) i end
the above code was compiled as follows
pgfortran test.f -mp -o test
Here below you can find the output
valerio@giusti-145 ~/Documents $ ./test Number of tests 1000 1.539883970671497 1.476670404429072 1.412861223654971 3
Thanks in advance for any suggestion (…and forgive me if I did something stupid :-) ).