Simple PRNG derived from gfortran documentation Intended to be used to seed a better PRNG. Probably shouldn't be used directly (hence why this is not public).

(?) the sign of the output will be the same as the input and hence has a restricted range, perhaps we should consider subtracting sign(s)*huge(s)/2 ?

Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|

integer(kind=kind_id), | intent(inout) | :: | s |

```
function lcg(s)
use constants, only: kind_id, kind_is
implicit none
integer :: lcg
integer (kind=kind_id), intent(in out) :: s
if (kind_id > 0) then
if (s == 0) then
s = 104729
else
s = mod(s, 4294967296_kind_id)
end if
s = mod(s * 279470273_kind_id, 4294967291_kind_id)
lcg = int(mod(s, int(huge(0), kind_id)), kind(0))
else
lcg = mod(16807*int(s,kind_is), 2147483647)
end if
end function lcg
```