module quickdirty

  private
  integer, parameter      :: mr=714025, ia=1366, ic=150889
  real(8), parameter      :: qnorm=1.d0/mr
  integer, save           :: irand=0

  public :: qdirty, setdirty

contains

  real(8) function qdirty()

    ! quick-and-dirty random numbers
    ! cf. Numerical Recipes, eq.(7.1.1) and Table, p.198
    ! irand = mod(ia*irand+ic, mr)

    irand = mod(ia*irand+ic, mr)
    qdirty = qnorm*irand;

  end function qdirty


  subroutine setdirty(iseed)

    irand = mod(abs(iseed), mr)

  end subroutine setdirty

end module quickdirty
