Go to the documentation of this file.00001 INTEGER FUNCTION mltmod(a,s,m)
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 INTEGER h
00025 PARAMETER (h=32768)
00026
00027
00028 INTEGER a,m,s
00029
00030
00031 INTEGER a0,a1,k,p,q,qh,rh
00032
00033
00034
00035
00036
00037
00038 IF (.NOT. (a.LE.0.OR.a.GE.m.OR.s.LE.0.OR.s.GE.m)) GO TO 10
00039 WRITE (*,*) ' A, M, S out of order in MLTMOD - ABORT!'
00040 WRITE (*,*) ' A = ',a,' S = ',s,' M = ',m
00041 WRITE (*,*) ' MLTMOD requires: 0 < A < M; 0 < S < M'
00042 CALL XSTOPX (' A, M, S out of order in MLTMOD - ABORT!')
00043
00044 10 IF (.NOT. (a.LT.h)) GO TO 20
00045 a0 = a
00046 p = 0
00047 GO TO 120
00048
00049 20 a1 = a/h
00050 a0 = a - h*a1
00051 qh = m/h
00052 rh = m - h*qh
00053 IF (.NOT. (a1.GE.h)) GO TO 50
00054 a1 = a1 - h
00055 k = s/qh
00056 p = h* (s-k*qh) - k*rh
00057 30 IF (.NOT. (p.LT.0)) GO TO 40
00058 p = p + m
00059 GO TO 30
00060
00061 40 GO TO 60
00062
00063 50 p = 0
00064
00065
00066
00067 60 IF (.NOT. (a1.NE.0)) GO TO 90
00068 q = m/a1
00069 k = s/q
00070 p = p - k* (m-a1*q)
00071 IF (p.GT.0) p = p - m
00072 p = p + a1* (s-k*q)
00073 70 IF (.NOT. (p.LT.0)) GO TO 80
00074 p = p + m
00075 GO TO 70
00076
00077 80 CONTINUE
00078 90 k = p/qh
00079
00080
00081
00082 p = h* (p-k*qh) - k*rh
00083 100 IF (.NOT. (p.LT.0)) GO TO 110
00084 p = p + m
00085 GO TO 100
00086
00087 110 CONTINUE
00088 120 IF (.NOT. (a0.NE.0)) GO TO 150
00089
00090
00091
00092 q = m/a0
00093 k = s/q
00094 p = p - k* (m-a0*q)
00095 IF (p.GT.0) p = p - m
00096 p = p + a0* (s-k*q)
00097 130 IF (.NOT. (p.LT.0)) GO TO 140
00098 p = p + m
00099 GO TO 130
00100
00101 140 CONTINUE
00102 150 mltmod = p
00103
00104 RETURN
00105
00106 END