Why, would you expect a different behaviour between mod
and modulo
for positive numbers? I’m missing something?
I will also suggest not to use float
as its result will be single precision instead of double, even though the difference will be small.
As other modernisation I wont use data statements as it is hiding which variable will be updated and which one is a parameter. I will write something like:
module rfb_mod
implicit none
integer, parameter :: dp = kind(1.0d0)
contains
real(dp) function rfb()
integer, parameter :: ix1 = 1500419
integer, parameter :: ix2 = 1400159
integer, parameter :: ix3 = 1364
integer, parameter :: ix4 = 1528
integer :: ix5 = 1
integer :: ix6 = 3
real(dp) :: rr1, rr2
rr1 = 1.0/real(ix1, dp)
rr2 = 1.0/real(ix2, dp)
ix5 = MODULO(ix5*ix3, ix1)
ix6 = MODULO(ix6*ix4, ix2)
rfb = rr1*ix5 + rr2*ix6
rfb = modulo(rfb, 1.0_dp)
! or
! if (rfb >= 1.0) rfb = rfb -1.0
! which is the fastest
end function
end module
by the way the OP is also saying that he started learning Fortran so it may be better to show him a more modern syntax.
Of course there are other possible improvements.