The mod function operates on both REAL and INTEGER arguments.
The mod function will return the remainder of division of the two arguments passed to it.
mod( NUM, DENOM )
NUM can either be an INTEGER or a REAL value. NUM is the number that will be divided (the NUMerator). It is also worth noting that the results of the mod function will be of the same type as NUM.
DENOM must be of the same type as NUM. NUM will be divided by DENOM (the DENOMinator). Also, if DENOM is equal to zero then the results of this operation will be undefined.
There are no optional arguments to the mod function.
The following four references are made to the mod function:
x1 = mod(187.0,9.0) x2 = mod(-87,9) x3 = mod(4.0,4.0) x4 = mod(54,-7)
The results are then:
x1 = 7.0 x2 = -6 x3 = 0.0 x4 = 5
In general the Fortran expression:
z = mod (x , y)
is equivalent to the expression
z = x - int(x/y)*y
Lecture
Examples: plot1.f
Written by Jason Wehr : jcw142@psu.edu and Maintained by John Mahaffy : jhm@cac.psu.edu