This commit was generated by cvs2svn to compensate for changes in r2,
[u/mrichter/AliRoot.git] / MINICERN / mathlib / gen / b / prmfct.F
1 *
2 * $Id$
3 *
4 * $Log$
5 * Revision 1.2  1997/04/08 14:11:55  mclareni
6 * 909th prime should be 7079
7 *
8 * Revision 1.1.1.1  1996/04/01 15:01:49  mclareni
9 * Mathlib gen
10 *
11 *
12 #include "gen/pilot.h"
13       SUBROUTINE PRMFCT(MODE,N,NPRIME,NPOWER,M)
14  
15       PARAMETER (NPR = 1229)
16       DIMENSION NPRIME(*),NPOWER(*),IPRIME(NPR)
17  
18       CHARACTER NAME*(*)
19       CHARACTER*80 ERRTXT
20       PARAMETER (NAME = 'PRMFCT')
21  
22       DATA (IPRIME(K),K=1,100)
23      1/    2,   3,   5,   7,  11,  13,  17,  19,  23,  29,  31,  37,
24      2    41,  43,  47,  53,  59,  61,  67,  71,  73,  79,  83,  89,
25      3    97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151,
26      4   157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223,
27      5   227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281,
28      6   283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359,
29      7   367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433,
30      8   439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503,
31      9   509, 521, 523, 541/
32  
33       DATA (IPRIME(K),K=101,200)
34      1/  547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613,
35      2   617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683,
36      3   691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769,
37      4   773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857,
38      5   859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941,
39      6   947, 953, 967, 971, 977, 983, 991, 997,1009,1013,1019,1021,
40      7  1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,1097,
41      8  1103,1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,1193,
42      9  1201,1213,1217,1223/
43  
44       DATA (IPRIME(K),K=201,300)
45      1/ 1229,1231,1237,1249,1259,1277,1279,1283,1289,1291,1297,1301,
46      2  1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,1409,1423,
47      3  1427,1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,1487,
48      4  1489,1493,1499,1511,1523,1531,1543,1549,1553,1559,1567,1571,
49      5  1579,1583,1597,1601,1607,1609,1613,1619,1621,1627,1637,1657,
50      6  1663,1667,1669,1693,1697,1699,1709,1721,1723,1733,1741,1747,
51      7  1753,1759,1777,1783,1787,1789,1801,1811,1823,1831,1847,1861,
52      8  1867,1871,1873,1877,1879,1889,1901,1907,1913,1931,1933,1949,
53      9  1951,1973,1979,1987/
54  
55       DATA (IPRIME(K),K=301,400)
56      1/ 1993,1997,1999,2003,2011,2017,2027,2029,2039,2053,2063,2069,
57      2  2081,2083,2087,2089,2099,2111,2113,2129,2131,2137,2141,2143,
58      3  2153,2161,2179,2203,2207,2213,2221,2237,2239,2243,2251,2267,
59      4  2269,2273,2281,2287,2293,2297,2309,2311,2333,2339,2341,2347,
60      5  2351,2357,2371,2377,2381,2383,2389,2393,2399,2411,2417,2423,
61      6  2437,2441,2447,2459,2467,2473,2477,2503,2521,2531,2539,2543,
62      7  2549,2551,2557,2579,2591,2593,2609,2617,2621,2633,2647,2657,
63      8  2659,2663,2671,2677,2683,2687,2689,2693,2699,2707,2711,2713,
64      9  2719,2729,2731,2741/
65  
66       DATA (IPRIME(K),K=401,500)
67      1/ 2749,2753,2767,2777,2789,2791,2797,2801,2803,2819,2833,2837,
68      2  2843,2851,2857,2861,2879,2887,2897,2903,2909,2917,2927,2939,
69      3  2953,2957,2963,2969,2971,2999,3001,3011,3019,3023,3037,3041,
70      4  3049,3061,3067,3079,3083,3089,3109,3119,3121,3137,3163,3167,
71      5  3169,3181,3187,3191,3203,3209,3217,3221,3229,3251,3253,3257,
72      6  3259,3271,3299,3301,3307,3313,3319,3323,3329,3331,3343,3347,
73      7  3359,3361,3371,3373,3389,3391,3407,3413,3433,3449,3457,3461,
74      8  3463,3467,3469,3491,3499,3511,3517,3527,3529,3533,3539,3541,
75      9  3547,3557,3559,3571/
76  
77       DATA (IPRIME(K),K=501,600)
78      1/ 3581,3583,3593,3607,3613,3617,3623,3631,3637,3643,3659,3671,
79      2  3673,3677,3691,3697,3701,3709,3719,3727,3733,3739,3761,3767,
80      3  3769,3779,3793,3797,3803,3821,3823,3833,3847,3851,3853,3863,
81      4  3877,3881,3889,3907,3911,3917,3919,3923,3929,3931,3943,3947,
82      5  3967,3989,4001,4003,4007,4013,4019,4021,4027,4049,4051,4057,
83      6  4073,4079,4091,4093,4099,4111,4127,4129,4133,4139,4153,4157,
84      7  4159,4177,4201,4211,4217,4219,4229,4231,4241,4243,4253,4259,
85      8  4261,4271,4273,4283,4289,4297,4327,4337,4339,4349,4357,4363,
86      9  4373,4391,4397,4409/
87  
88       DATA (IPRIME(K),K=601,700)
89      1/ 4421,4423,4441,4447,4451,4457,4463,4481,4483,4493,4507,4513,
90      2  4517,4519,4523,4547,4549,4561,4567,4583,4591,4597,4603,4621,
91      3  4637,4639,4643,4649,4651,4657,4663,4673,4679,4691,4703,4721,
92      4  4723,4729,4733,4751,4759,4783,4787,4789,4793,4799,4801,4813,
93      5  4817,4831,4861,4871,4877,4889,4903,4909,4919,4931,4933,4937,
94      6  4943,4951,4957,4967,4969,4973,4987,4993,4999,5003,5009,5011,
95      7  5021,5023,5039,5051,5059,5077,5081,5087,5099,5101,5107,5113,
96      8  5119,5147,5153,5167,5171,5179,5189,5197,5209,5227,5231,5233,
97      9  5237,5261,5273,5279/
98  
99       DATA (IPRIME(K),K=701,800)
100      1/ 5281,5297,5303,5309,5323,5333,5347,5351,5381,5387,5393,5399,
101      2  5407,5413,5417,5419,5431,5437,5441,5443,5449,5471,5477,5479,
102      3  5483,5501,5503,5507,5519,5521,5527,5531,5557,5563,5569,5573,
103      4  5581,5591,5623,5639,5641,5647,5651,5653,5657,5659,5669,5683,
104      5  5689,5693,5701,5711,5717,5737,5741,5743,5749,5779,5783,5791,
105      6  5801,5807,5813,5821,5827,5839,5843,5849,5851,5857,5861,5867,
106      7  5869,5879,5881,5897,5903,5923,5927,5939,5953,5981,5987,6007,
107      8  6011,6029,6037,6043,6047,6053,6067,6073,6079,6089,6091,6101,
108      9  6113,6121,6131,6133/
109  
110       DATA (IPRIME(K),K=801,900)
111      1/ 6143,6151,6163,6173,6197,6199,6203,6211,6217,6221,6229,6247,
112      2  6257,6263,6269,6271,6277,6287,6299,6301,6311,6317,6323,6329,
113      3  6337,6343,6353,6359,6361,6367,6373,6379,6389,6397,6421,6427,
114      4  6449,6451,6469,6473,6481,6491,6521,6529,6547,6551,6553,6563,
115      5  6569,6571,6577,6581,6599,6607,6619,6637,6653,6659,6661,6673,
116      6  6679,6689,6691,6701,6703,6709,6719,6733,6737,6761,6763,6779,
117      7  6781,6791,6793,6803,6823,6827,6829,6833,6841,6857,6863,6869,
118      8  6871,6883,6899,6907,6911,6917,6947,6949,6959,6961,6967,6971,
119      9  6977,6983,6991,6997/
120  
121       DATA (IPRIME(K),K=901,1000)
122      1/ 7001,7013,7019,7027,7039,7043,7057,7069,7079,7103,7109,7121,
123      2  7127,7129,7151,7159,7177,7187,7193,7207,7211,7213,7219,7229,
124      3  7237,7243,7247,7253,7283,7297,7307,7309,7321,7331,7333,7349,
125      4  7351,7369,7393,7411,7417,7433,7451,7457,7459,7477,7481,7487,
126      5  7489,7499,7507,7517,7523,7529,7537,7541,7547,7549,7559,7561,
127      6  7573,7577,7583,7589,7591,7603,7607,7621,7639,7643,7649,7669,
128      7  7673,7681,7687,7691,7699,7703,7717,7723,7727,7741,7753,7757,
129      8  7759,7789,7793,7817,7823,7829,7841,7853,7867,7873,7877,7879,
130      9  7883,7901,7907,7919/
131  
132       DATA (IPRIME(K),K=1001,1100)
133      1/ 7927,7933,7937,7949,7951,7963,7993,8009,8011,8017,8039,8053,
134      2  8059,8069,8081,8087,8089,8093,8101,8111,8117,8123,8147,8161,
135      3  8167,8171,8179,8191,8209,8219,8221,8231,8233,8237,8243,8263,
136      4  8269,8273,8287,8291,8293,8297,8311,8317,8329,8353,8363,8369,
137      5  8377,8387,8389,8419,8423,8429,8431,8443,8447,8461,8467,8501,
138      6  8513,8521,8527,8537,8539,8543,8563,8573,8581,8597,8599,8609,
139      7  8623,8627,8629,8641,8647,8663,8669,8677,8681,8689,8693,8699,
140      8  8707,8713,8719,8731,8737,8741,8747,8753,8761,8779,8783,8803,
141      9  8807,8819,8821,8831/
142  
143       DATA (IPRIME(K),K=1101,1200)
144      1/ 8837,8839,8849,8861,8863,8867,8887,8893,8923,8929,8933,8941,
145      2  8951,8963,8969,8971,8999,9001,9007,9011,9013,9029,9041,9043,
146      3  9049,9059,9067,9091,9103,9109,9127,9133,9137,9151,9157,9161,
147      4  9173,9181,9187,9199,9203,9209,9221,9227,9239,9241,9257,9277,
148      5  9281,9283,9293,9311,9319,9323,9337,9341,9343,9349,9371,9377,
149      6  9391,9397,9403,9413,9419,9421,9431,9433,9437,9439,9461,9463,
150      7  9467,9473,9479,9491,9497,9511,9521,9533,9539,9547,9551,9587,
151      8  9601,9613,9619,9623,9629,9631,9643,9649,9661,9677,9679,9689,
152      9  9697,9719,9721,9733/
153  
154       DATA (IPRIME(K),K=1201,1229)
155      1/ 9739,9743,9749,9767,9769,9781,9787,9791,9803,9811,9817,9829,
156      2  9833,9839,9851,9857,9859,9871,9883,9887,9901,9907,9923,9929,
157      3  9931,9941,9949,9967,9973/
158  
159       IF(MODE .NE. 0 .AND. MODE .NE. 1 .AND. MODE .NE. 2) THEN
160        WRITE(ERRTXT,101) MODE
161        CALL MTLPRT(NAME,'B002.1',ERRTXT)
162        RETURN
163       ELSEIF(MODE .EQ. 0) THEN
164        IF(0 .LT. N .AND. N .LE. NPR) THEN
165         DO 10 J = 1,N
166         NPRIME(J)=IPRIME(J)
167    10   NPOWER(J)=1
168         M=N
169        ELSE
170         WRITE(ERRTXT,102) N
171         CALL MTLPRT(NAME,'B002.2',ERRTXT)
172        ENDIF
173        RETURN
174       ELSE
175        IF(N .LE. 1 .OR. N .GE. 10007) THEN
176         WRITE(ERRTXT,102) N
177         CALL MTLPRT(NAME,'B002.2',ERRTXT)
178         RETURN
179        ENDIF
180       ENDIF
181  
182       N0=MIN(N,NPR)
183       DO 7 J = 1,N0
184     7 NPRIME(J)=IPRIME(J)
185       IF(N .GE. NPRIME(NPR)) THEN
186        L=NPR
187        GO TO 2
188       ELSE
189        DO 1 J = 1,N0
190        IF(NPRIME(J) .GT. N) THEN
191         L=J-1
192         GO TO 2
193        ELSEIF(NPRIME(J) .EQ. N) THEN
194         L=J
195         GO TO 2
196        ENDIF
197     1  CONTINUE
198       ENDIF
199  
200     2 DO 3 J = 1,L
201     3 NPOWER(J)=0
202       K0=N
203       IF(MODE .EQ. 2) K0=2
204       DO 4 K = K0,N
205       N1=K
206       DO 5 J = 1,L
207     6 IF(MOD(N1,NPRIME(J)) .EQ. 0) THEN
208        NPOWER(J)=NPOWER(J)+1
209        N1=N1/NPRIME(J)
210        IF(N1 .EQ. 1) GO TO 4
211        GO TO 6
212       ENDIF
213     5 CONTINUE
214     4 CONTINUE
215       DO 8 J = L,1,-1
216       IF(NPOWER(J) .GT. 0) GO TO 9
217     8 CONTINUE
218     9 M=J
219       RETURN
220   101 FORMAT('MODE = ',I5,'  ILLEGAL')
221   102 FORMAT('N = ',I8,'  ILLEGAL')
222       END