-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathINITN.F
387 lines (325 loc) · 9.3 KB
/
INITN.F
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
SUBROUTINE INITN(IN, VEN)
COMMON /INIT/ NR, NW, ND, NT7, NT8, NDAT, NS1, NS2
COMMON /RAN/ IRN(54), KRANUM, RLIMIT, NRNOPT, ITAPE
COMMON /STAT/ SUM(5, 20), SUM2(5, 10), SUM3(5, 10), SUM4(5, 10)
COMMON /GEN/ITOT, ISIZE, NOWT, NOWY, NDAYS, NRUNS, IATRIB(18), ATRIB(4)
COMMON /HOUSE/ NH(6), N1, N2, N3, N4, N5, N6, NXTFAR, MX1, MX2, MX3, MX4, X1, X2, X4
COMMON /SALES/ MDSELL, WTS, NXTSAL, NSLD(4), WTSLD(4), VSLD(4), PRIH, PRIS
COMMON /BRED/ LBREED, NBREED, IFAR(6, 5), IDB(30), KAGEW, LGTHW, NAGEM
COMMON /BRED2/ ABNORG, GESM, GESS, GMIN, GMAX, ESTM, ESTS, EMIN, EMAX
COMMON /BRED3/ PTRM1, PTRM2, PTRM16, PCON1, PCON2, ADJ1, ADJ2
COMMON /SKIP/ ISTOP4, ISTOP5, ISTOP6, ISTOP7, MAXSKP
COMMON /SURVIV/ PW1, PW23, PSRT, PSFIN, PSOWS, PBORS, PBORS1, MDEAD(8), PSRT2
COMMON /GAIN/ GW1, GW23, GSRT, GFIN1, GFIN2, GSOWM, GSOWL, SDP, SSOWM, SSOWL
COMMON /BIRTH/ BRNM, BRNS, BMIN, BMAX, BWTM, BWTS, BWMIN, BWMAX, NOBRN
COMMON /CLEAN/ NDPREV, NH4CLN, LOSSL, SWTLP, SSLP
COMMON /CULL/ NGLTS, MXSRV, MXAGS, PCULG, PCULS, PSSR, PRGT, MXBOR, LDP
COMMON /COST/ FCS, FCB, CLAB, TFAR, TNUR, TSOW, TFIN
COMMON /BOAR/ MXSDY, MXSWY, MXSDM, MXSWM, NPUR, IPDAT, KAGE, WTPB, IBS
COMMON /RPT1/ ISMYP, ISMB, ISMBG, ISMF, ISMW, ISMS, ISMM
COMMON /RPT2/ ISMYC, ISMCS, ISMCH, ISML, ISMSS, ISMSH, ISMGR
COMMON /RPT3/ MJEV, ISALS, IFARS, IBRDS
COMMON /RPT4/ IDCS, IDCE, IDCN, IDCF, IDCM, IDCB, IDCFS, IDCFP, IOFLW
COMMON /RPT5/ IAAS, IAAE, IAAN, IAAFN, IAAM, IAAB, IAAFR
COMMON /SALE2/ DUMMY(12), DIS
COMMON /KRS/ KRS1, KRS2, KRS3, KRS4, KRS5, KRS6, KRS7, KRPT
DIMENSION RR(10)
INTEGER DATE
DIMENSION DATE(8)
CHARACTER(10) :: DAY
INTEGER XMINUS
DATA XMINUS/000000000000000007777/
OPEN(NEWUNIT=NR, FILE="NR.txt", STATUS="OLD", ACTION="READ", FORM="FORMATTED")
OPEN(NEWUNIT=NDAT,FILE="NDAT.txt",STATUS="OLD",ACTION="READ",FORM="FORMATTED")
C ASSIGN TAPES
C READ=NR= WRITE=NW, DIAGNOSTIC=ND, BASE HERD DATA TAPE=NDAT,
C RANDOM NOS. = ITAPE
C NR = 2
C NW = 6
C MTP: CHANGED FROM 6 SO IT ISN'T STDOUT
NW = 60
ND = 13
C MAY SET TO 8 FOR JUNKING VIA CARD 56.
NT7 = 130
C NDAT = 15
ITAPE = 50
MR = 0
C INITIATE VARIABLES OUTSIDE SUBROUTINES
KRANUM = 0
RLIMIT = 2.0 ** 48.0 - 1.0
ITOT = 0
DO 90 II = 1,6
90 NH(II) = 0
NOWY = 0
C PRESET STATISTICAL COLLECTION ARRAYS
DO 100 JVARBL = 1,20
100 CALL ZROSUM(SUM, JVARBL)
DO 200 IVARBL = 1,10
CALL ZROSUM(SUM2, IVARBL)
CALL ZROSUM(SUM3, IVARBL)
200 CALL ZROSUM(SUM4, IVARBL)
C PRESET FARROWING DATES FOR FIRST YEAR
IFAR(1, 1) = 15
IFAR(2, 1) = 60
IFAR(3, 1) = 152
IFAR(4, 1) = 198
IFAR(5, 1) = 244
IFAR(6, 1) = 355
C MARK BEGINNING OF PRINTED OUTPUT
WRITE(ND, 606) ND
WRITE(NT7, 606) NT7
WRITE(NW, 606) NW
606 FORMAT('8 BEGIN PRINT TAPE'I4' REPORTS')
C READ NR=TAPE5 DATA AND LIST THEM.
READ(NR, 705) RR
705 FORMAT(10A8)
706 FORMAT(//' FREE FORM IDENT CARD FOLLOWED BY DEFAULT DATA, USER OPTION CARDS '/' APPEAR AFTER CORRESPONDING DEFAULT CARD'//5X,10A8)
WRITE(ND, 706) RR
C READ STANDARD 10F7.0, FIRST CELL IS CARD NO., OTHERS
C REPLACE WITH NON-BLANK CELLS IF FIND USER OPTION CARD NO.
30 READ(NR, 50) RR
WRITE(ND, 60) RR
IR = RR(1)
IF(IR .EQ. 8888) GO TO 999
50 FORMAT(10F7.0)
60 FORMAT(5X,10F9.3)
IF(IR .GT. 20) GO TO 500
GO TO(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20) IR
C ISIZE OF OPENING INVENTORY HERDS
1 ISIZE = RR(2)
GO TO 30
C FARROWING CONTROL
2 LBREED = RR(2)
NBREED = RR(3)
KAGEW = RR(4)
LGTHW = RR(5)
NAGEM = RR(6)
GO TO 30
C SURVIVAL PROBABILITIES, CONVERT TO DAILY, PUT INTO /SURVIV/.
3 PW1 = (1.0 - RR(2)) ** (1.0 / 7.0)
PW23 = (1.0 - RR(3)) ** (1.0 / 14.0)
PSRT = (1.0 - RR(4)) ** (1.0 / 35.0)
PSRT2 = (1.0 - RR(5)) ** (1.0 / 35.0)
PSFIN = (1.0 - RR(6)) ** (1.0 / 124.0)
PSOWS = (1.0 - RR(7)) ** (1.0 / 365.0)
PBORS = (1.0 - RR(8)) ** (1.0 / 365.0)
PBORS1 = (1.0 - RR(9)) ** (1.0 / 365.0)
GO TO 30
C FILL /BRED2/ AND /BRED3/
C ABNORMAL GILTS, ESTRUS LENGTH, PROBABILITY OF CONCEPT, ADJ. NO BORN
4 ABNORG = RR(2)
ESTM = RR(3)
ESTS = RR(4)
EMIN = RR(5)
EMAX = RR(6)
PCON1 = RR(7)
PCON2 = RR(8)
ADJ1 = RR(9)
ADJ2 = RR(10)
GO TO 30
C GESTATION LENGTH AND PREMATURE TERMINATION.
5 GESM = RR(2)
GESS = RR(3)
GMIN = RR(4)
GMAX = RR(5)
PTRM1 = 1.0 - ((1.0 - RR(6)) ** (1.0 / 7.0))
PTRM2 = 1.0 - ((1.0 - RR(7)) ** (1.0 / 100.0))
PTRM16 = 1.0 - ((1.0 - RR(8)) ** (1.0 / 7.0))
GO TO 30
C FILL /BIRTH/
6 BRNM = RR(2)
BRNS = RR(3)
BMIN = RR(4)
BMAX = RR(5)
C WEIGHTS FILLED INTO /BIRTH/
BWTM = RR(6)
BWTS = RR(7)
BWMIN = RR(8)
BWMAX = RR(9)
GO TO 30
C WEIGHT INTO /GAIN/
7 GW1 = RR(2)
GW23 = RR(3)
GSRT = RR(4)
GFIN1 = RR(5)
GFIN2 = RR(6)
SDP = RR(7) / 100.0
GO TO 30
C SALES CONTROL INTO /SALES/
8 MDSELL = RR(2)
WTS = RR(3)
PRIH = RR(4)
PRIS = RR(5)
DIS = RR(6) / 100.0
GO TO 30
C SOW GAINS
9 GSOWM = RR(2)
SSOWM = RR(3)
GSOWL = RR(4)
SSOWL = RR(5)
C ADD TO /CLEAN/
SWTLP = RR(6)
SSLP = RR(7)
GO TO 30
C OPENING INVENTORY, BOARS - NEW, YOUNG, THEN MATURE.
10 NB1 = RR(2)
IF(NB1 .LT. 1) GO TO 6200
DO 6101 K = 1,NB1
IATRIB(1) = RR(3)
IATRIB(2) = 1
IATRIB(3) = 1
IATRIB(4) = 1
IATRIB(5) = 88 * 1000 + K
ATRIB(1) = RR(4)
ATRIB(2) = RNORM(GSOWM, SSOWM, -5.0, 10.0)
CALL FILEM(IN, VEN, 8)
6101 CONTINUE
6200 NB2 = RR(5)
IF(NB2 .LT. 1) GO TO 6300
DO 6201 K = 1,NB2
IATRIB(1) = RR(6)
IATRIB(2) = 1
IATRIB(3) = 2
IATRIB(4) = 1
IATRIB(5) = 88 * 1000 + NB1 + K
ATRIB(1) = RR(7)
ATRIB(2) = RNORM(GSOWM, SSOWM, -5.0, 10.0)
CALL FILEM(IN, VEN, 8)
6201 CONTINUE
6300 NB3 = RR(8)
IF(NB3 .LT. 1) GO TO 30
DO 6301 K = 1,NB3
IATRIB(1) = RR(9)
IATRIB(2) = 1
IATRIB(3) = 3
IATRIB(4) = 1
IATRIB(5) = 88 * 1000 + NB2 + NB1 + K
ATRIB(I) = RR(10)
CALL FILEM(IN, VEN, 8)
6301 CONTINUE
GO TO 30
C CULLING OF GILTS AND SOWS IN /CULL/
11 NGLTS = RR(2)
MXSRV = RR(3)
MXAGS = RR(4)
PCULG = RR(5) / 100.0
PCULS = RR(6) / 100.0
MXBOR = RR(7)
LDP = RR(8)
GO TO 30
C CONCEPTION ADJUSTMENT, ADDED TO /CULL/
12 PSSR = RR(2)
PRGT = RR(3)
GO TO 30
C COST CARD
13 FCS = RR(2)
FCB = RR(3)
CLAB = RR(4)
TFAR = RR(5)
TNUR = RR(6)
TSOW = RR(7)
TFIN = RR(8)
GO TO 30
C BUILDING OPTIONS, BUILDINGS ARE NOT IN FILES AS ARE ANIMALS.
14 MX1 = RR(2)
NDPREV = RR(3)
X1 = RR(4)
GO TO 30
15 MX2 = RR(2)
X2 = RR(3)
GO TO 30
16 MX3 = RR(2)
GO TO 30
17 MX4 = RR(2)
X4 = RR(3)
GO TO 30
C NO SUCH CARDS
18 GO TO 1350
19 GO TO 1350
C BOAR MANAGEMENT OPTIONS
20 MXSDY = RR(2)
MXSWY = RR(3)
MXSDM = RR(4)
MXSWM = RR(5)
NPUR = RR(6)
IPDAT = RR(7)
KAGE = RR(8)
WTPB = RR(9)
GO TO 30
C CARDS 51. AND GREATER
500 IF(IR-51) 1350, 51, 502
502 IF(IR-53) 52, 53, 504
504 IF(IR-55) 54, 55, 506
506 IF(IR-57) 56, 57, 508
508 IF(IR-59) 58, 1350, 1350
C SIMULATION CONTROL -NDAYS,NRUNS
51 NDAYS = RR(2)
C MTP: REPLACED THE CDC BUILT-IN RANF FUNCTION WITH RAND
C AND CHANGED SEED = RR(3) NSEED SO IT IS AN INTEGER
NSEED = RR(3)
SEED = RAND(NSEED)
MAXSKP = RR(4)
NRNOPT = RR(5)
KRS4 = RR(6)
GO TO 30
C NO CARD 52.
52 GO TO 1350
C PRODUCTION SUMMARY REPORT CONTROL
53 ISMYP = RR(2)
ISMB = RR(3)
ISMBG = RR(4)
ISMF = RR(5)
ISMW = RR(6)
ISMM = RR(7)
ISMM = RR(8)
GO TO 30
C COSTS AND RETURNS SUMMARY REPORT CONTROL
54 ISMYC = RR(2)
ISMCS = RR(3)
ISMCH = RR(4)
ISML = RR(5)
ISMSS = RR(6)
ISMSH = RR(7)
ISMGR = RR(8)
GO TO 30
C EVENTS AS THEY OCCUR REPORT CONTROL
55 MJEV = RR(2)
ISALS = RR(3)
IFARS = RR(4)
IBRDS = RR(5)
GO TO 30
C DAILY INVENTORY REPORT CONTROL
56 IDCS = RR(2)
IDCE = RR(3)
IDCN = RR(4)
IDCF = RR(5)
IDCM = RR(6)
IDCB = RR(7)
IDCFS = RR(8)
IDCFP = RR(9)
IOFLW = RR(10)
GO TO 30
C INDIVIDUAL DAILY ANIMAL ATTRIBUTES CONTROL
57 IAAS = RR(2)
IAAE = RR(3)
IAAN = RR(4)
IAAFN = RR(5)
IAAM = RR(6)
IAAB = RR(7)
IAAFR = RR(8)
GO TO 30
C NS1,NS2 DIAGNOSTIC SWITCHES
58 NS1 = RR(2)
NS2 = RR(3)
GO TO 30
1350 WRITE(ND, 1351) RR(1)
1351 FORMAT(' ERROR SUB. INITN, DATA CARD .GT. PERMITTED='F8.2)
GO TO 30
C MTP: RETROFITTED TODAY'S DATE FROM CDC'S BUILT-IN DATE FUNCTION
999 CALL DATE_AND_TIME(values=DATE)
WRITE(DAY,'(I4.4, "-", I2.2, "-", I2.2)') INT(DATE(1)), INT(DATE(2)), INT(DATE(3))
WRITE(NW, 998) NDAYS, DAY
998 FORMAT(//18X,'SWINE BREEDING HERD SIMULATOR'//7X,'REQUEST IS FOR',I4,' DAYS,',10X,'TODAYS DATE IS ',A10/7X///17X)
CLOSE(NR)
RETURN
END