-
Notifications
You must be signed in to change notification settings - Fork 1
/
BUGFILES.PAS
630 lines (516 loc) · 18.5 KB
/
BUGFILES.PAS
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
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
Unit BUGfiles;
{ PMS 19-April-1988 13:25 }
{ ************* COPYRIGHT (C) Materials Group, **************
************* Cambridge University Engineering **************
************* Department, Cambridge, UK. **************
************* M.F.Ashby and P.M.Sargent **************
************* April 1988 **************
}
{$R-} {Range checking off}
{$B+} {Boolean complete evaluation on}
{$S+} {Stack checking on}
{$I+} {I/O checking on}
Interface
Uses
Crt,
Dos,
Printer,
BUGGlbls;
PROCEDURE MAKE_PARAMETER_FILE;
{ -- Creates a file on disk containing parameters for a chosen material -- }
PROCEDURE MAKE_VARIABLE_FILE;
{ -- Creates a file on disk containing variables for a chosen material -- }
PROCEDURE READ_PARAMETER_FILE;
{ -------- Read in the chosen parameter file -------- }
PROCEDURE READ_VARIABLE_FILE;
{ -------- Read in the chosen variable file -------- }
PROCEDURE CHECK_PARAMETERS;
{ -------- Checks input data against limits -------- }
PROCEDURE INPUT_DATA_TO_PRINTER;
PROCEDURE INPUT_DATA_TO_FILE;
{===================================================================}
Implementation
{-------------------------------------------------------------------}
PROCEDURE SaveParFile (parfilename: String);
VAR
infile : Text;
BEGIN
Assign (infile, parfilename);
Rewrite (infile);
FOR parnumber:= 1 TO numberofparameters DO
BEGIN
Labels_for_data;
WRITELN(infile, par[parnumber],' ''',d,''' ''',u,'''');
END;
close (infile);
END;
{-------------------------------------------------------------------}
PROCEDURE SaveVblFile (vblfilename: String);
VAR
infile : Text;
BEGIN
Assign (infile, vblfilename);
Rewrite (infile);
FOR vblnumber:= 1 TO numberofvariables DO
BEGIN
Labels_for_variables;
WRITELN(infile, vbl[vblnumber],' ''',d,''' ''',u,'''');
END;
close (infile);
END;
{-------------------------------------------------------------------}
PROCEDURE Prompt_Finish;
BEGIN
gotoXY(1,24); textbackground(C_back);
write(' ');
repeat gotoXY(1,24);
write (' FINISHED EDITING ? (Y/N) ');
answer:=Readkey;
until answer in ['y','Y','n','N',Esc];
IF answer=Esc THEN Finish(0);
textcolor(C_text);
END; { Prompt_Finish }
{-------------------------------------------------------------------}
PROCEDURE Prompt_Save;
BEGIN
{ -------- Save the modified file ? -------- }
gotoXY(1,24); textbackground(C_back);
write(' ');
repeat gotoXY(1,24); textcolor(C_bright);
write (' SAVE THE FILE ? (Y/N) ');
answer:=Readkey; gotoXY(1,24);
until answer in ['y','Y','n','N',Esc];
IF answer=Esc THEN Finish(0);
textcolor(C_text);
END; { Prompt_Save }
{-------------------------------------------------------------------}
PROCEDURE Prompt_Edit;
BEGIN
{ -------- Edit the modified file ? -------- }
gotoXY(1,24); textbackground(C_back);
write(' ');
repeat
gotoXY(1,24); textcolor(C_bright);
write(' EDIT THE FILE ? (Y/N) ');
answer:=Readkey;
until answer in ['y','Y','n','N',Esc];
IF answer=Esc THEN Finish(0);
textcolor(C_text);
END; { Prompt_Edit }
{-------------------------------------------------------------------}
PROCEDURE EDIT_PARAMETERS;
BEGIN
Prompt_Edit;
if answer in ['y','Y'] then
BEGIN
repeat
Textbackground(C_back);
repeat gotoXY(1,24); textcolor(C_bright);
write (' ');
gotoXY(1,24);
write (' LINE NUMBER FOR EDITING ....');
readln (parnumber);
until parnumber in [1..17]; textcolor(C_text);
LABELS_FOR_DATA;
gotoXY(1,24); textcolor(C_bright);
write (' ', parnumber:3,' ', d, u, ' = ');
textcolor(C_warn);
read (par[parnumber]);
textcolor(C_bright);
LowVideo;
gotoXY(1,4 + parnumber);
write (' ',parnumber:3,' ', d, u,' =');
writeln( par[parnumber]:12);
NormVideo;
Prompt_Finish;
until answer in ['y','Y'];
Prompt_Save;
IF answer in ['y','Y'] then SaveParFile(parfilename);
END;
textbackground(C_back); gotoXY(1,2);
END; { EDIT_Parameters }
{-------------------------------------------------------------------}
PROCEDURE EDIT_VARIABLES;
BEGIN
Prompt_Edit;
if answer in ['y','Y'] then
BEGIN
repeat
Textbackground(C_back);
repeat gotoXY(1,24); textcolor(C_bright);
write (' ');
gotoXY(1,24);
write (' LINE NUMBER FOR EDITING .... ');
readln (vblnumber);
until vblnumber in [1..17]; textcolor(C_text);
LABELS_FOR_VARIABLES;
gotoXY(1,24); textcolor(C_bright);
write (' ', vblnumber:3,' ', d, u, ' = ');
textcolor(C_warn);
read (vbl[vblnumber]);
textcolor(C_bright);
LowVideo;
gotoXY(1,4 + vblnumber);
write (' ',vblnumber:3,' ', d, u,' =');
writeln( vbl[vblnumber]:12);
NormVideo;
Prompt_Finish;
until answer in ['y','Y'];
Prompt_Save;
IF answer in ['y','Y'] then SaveVblFile(vblfilename);
END;
textbackground(C_back); gotoXY(1,2);
END; { EDIT_VARIABLES }
{-------------------------------------------------------------------}
PROCEDURE MAKE_PARAMETER_FILE;
{ -- Creates a file on disk containing parameters for a chosen material -- }
BEGIN
CLEAN_WINDOW;
DATE_AND_TIME;
textbackground(C_back);
gotoXY(1,2);
write (' ');
gotoXY(1,2);
write(' ',Version,' Creating a new file for ',filename,' ',date_string);
gotoXY(1,5);
for parnumber := 1 to numberofparameters do BEGIN
LABELS_FOR_DATA;
writeln (' ',parnumber:3,' ',d,u,'....');
END;
gotoXY(1,24);
write (' ');
gotoXY(1,24);
textcolor(C_bright);
write(' ENTER PARAMETERS '); textcolor(C_text);
for parnumber := 1 to numberofparameters do
BEGIN
gotoXY (47,4+parnumber);
TextBackground(C_bright);
write(' ');
gotoXY (47,4+parnumber);
Textcolor(C_warn);
read(par[parnumber]);
gotoXY (47,4+parnumber);
TextBackground(C_back);
write(' ');
gotoXY (47,4+parnumber);
Textcolor(C_bright);
write(par[parnumber]:12);
END;
{ -------- Create default wherever zeros entered in parameter file --------}
for parnumber := 1 to numberofparameters do
BEGIN
if par[parnumber] = 0.0 then
BEGIN
case parnumber of
1 : par[1] := 1500;
2 : par[2] := 1.3e-3;
3 : par[3] := 0.033*par[1];
4 : par[4] := 0.5;
5 : par[5] := 6.0e-3;
6 : par[6] := 6.0e-3;
7 : par[7] := 1.8e-29;
8 : par[8] := 1.0e-4;
9 : par[9] := 18*R*par[1]/1000;
10 : par[10] := exp(ln(par[7])/3)*par[8];
11 : par[11] := 11*R*par[1]/1000;
12 : par[12] := 1.0e-23;
13 : par[13] := par[11];
14 : par[14] := 3.0;
15 : par[15] := 1000*par[5]*par[3]/2;
16 : par[16] := par[9];
17 : par[17] := 3.5e-10;
END; { Case }
END;
END;
LIST_PARAMETERS;
{ -------- Save the file -------- }
Prompt_Save;
if answer in ['y','Y'] then SaveParFile(parfilename);
{ ------- List the file for inspection and Editing ------- }
EDIT_PARAMETERS;
END; {MAKE_PARAMETER_FILE. }
{-------------------------------------------------------------------}
PROCEDURE MAKE_VARIABLE_FILE;
{ -- Creates a file on disk containing variables for a chosen material -- }
BEGIN
CLEAN_WINDOW;
DATE_AND_TIME;
textbackground(C_back);
gotoXY(1,2);
write (' ');
gotoXY(1,2);
write(' ',Version,' Creating a new file for ',filename,' ',date_string);
gotoXY(1,5);
for vblnumber := 1 to numberofvariables do BEGIN
LABELS_FOR_VARIABLES;
writeln (' ',vblnumber:3,' ',d,u,'....');
END;
gotoXY(1,24);
write (' ');
gotoXY(1,24);
textcolor(C_bright);
write(' ENTER VARIABLES '); textcolor(C_text);
for vblnumber := 1 to numberofvariables do
BEGIN
gotoXY (47,4+vblnumber);
TextBackground(C_bright);
write(' ');
gotoXY (47,4+vblnumber);
Textcolor(C_warn);
read(vbl[vblnumber]);
gotoXY (47,4+vblnumber);
TextBackground(C_back);
write(' ');
gotoXY (47,4+vblnumber);
Textcolor(C_bright);
write(vbl[vblnumber]:12);
END;
{ -------- Create default wherever zeros entered in variable file --------}
for vblnumber := 1 to numberofvariables do
BEGIN
if vbl[vblnumber] = 0.0 then
BEGIN
case vblnumber of
1 : vbl[1] := 1;
2 : vbl[2] := 0.0;
3 : vbl[3] := 0.0;
4 : vbl[4] := 0.0;
5 : vbl[5] := 1.0e-4; {100 microns}
6 : vbl[6] := 0.0;
7 : vbl[7] := 0.0;
8 : vbl[8] := 1.0;
9 : vbl[9] := 1.0e-4;
10 : vbl[10] := 1.0e-1;
11 : vbl[11] := 0.0;
12 : vbl[12] := 0.0;
13 : vbl[13] := 1.0;
14 : vbl[14] := 1.0e-7;
15 : vbl[15] := 10;
16 : vbl[16] := 10;
17 : vbl[17] := 40;
END; { Case }
if (vbl[8] > 100) then vbl[8] := 100;
END;
END;
LIST_VARIABLES;
{ -------- Save the file -------- }
Prompt_Save;
if answer in ['y','Y'] then SaveVblFile(vblfilename);
{ ------- List the file for inspection and Editing ------- }
EDIT_VARIABLES;
END; {MAKE_VARIABLE_FILE. }
{-------------------------------------------------------------------}
PROCEDURE READ_PARAMETER_FILE;
{ -------- Read in the chosen parameter file -------- }
VAR
infile : TEXT;
BEGIN
Assign (infile,parfilename);
Reset (infile);
FOR parnumber:= 1 TO numberofparameters DO
READLN(infile, par[parnumber]);
Close(infile);
{ ------- Display the file for inspection and editing ------- }
IF NOT modefast THEN
BEGIN
LIST_PARAMETERS;
EDIT_PARAMETERS;
END;
END; {READ_PARAMETER_FILE. }
{-------------------------------------------------------------------}
PROCEDURE READ_VARIABLE_FILE;
{ -------- Read in the chosen variable file -------- }
VAR
infile : TEXT;
BEGIN
Assign (infile,vblfilename);
Reset (infile);
FOR vblnumber:= 1 TO numberofvariables DO
READLN(infile, vbl[vblnumber]);
Close(infile);
{ ------- Display the file for inspection and editing ------- }
IF NOT modefast THEN
BEGIN
LIST_VARIABLES;
EDIT_VARIABLES;
END;
END; {READ_VARIABLE_FILE. }
{-------------------------------------------------------------------}
PROCEDURE CHECK_PARAMETERS;
{ -------- Checks input data against limits -------- }
VAR
lf : Text;
BEGIN
CLEAN_WINDOW;
textbackground(C_back);
gotoXY(1,2);
write (' ');
gotoXY(1,2);
write(' ',Version,' CHECK ON INPUT DATA FOR ');
textcolor(C_bright);
write(filename);
gotoXY(1,5);
for parnumber := 1 to numberofparameters do
BEGIN
LABELS_FOR_DATA;
case parnumber of
1 : BEGIN L1 := 500; L2 := 4000 END;
2 : BEGIN L1 := 1.0e-4; L2 := 0.1 END;
3 : BEGIN L1 := 5; L2 := 500 END;
4 : BEGIN L1 := 0.1; L2 := 0.95 END;
5 : BEGIN L1 := 1.0e-4; L2 := 0.1 END;
6 : BEGIN L1 := 0.0; L2 := 0.2 END;
7 : BEGIN L1 := 1.0E-29; L2 := 5.0E-29 END;
8 : BEGIN L1 := 1.0E-10; L2 := 1.0 END;
9 : BEGIN L1 := 8*R*par[1]/1000; L2 := 34*R*par[1]/1000; END;
10 : BEGIN L1 := 1.0E-17; L2 := 1.0E-8 END;
11 : BEGIN L1 := 0.38*par[9]; L2 := 1.0*par[9] END;
12 : BEGIN L1 := 1.0E-26; L2 := 1.0E-20 END;
13 : BEGIN L1 := 0.38*par[9]; L2 := par[9] END;
14 : BEGIN L1 := 3.0; L2 := 15.0 END;
15 : BEGIN L1 := 1.0e3*par[3]*par[2]/8;
L2 := 5.0e3*par[3]*par[2] END;
16 : BEGIN L1 := 0.6*par[9]; L2 := 2.0*par[9] END;
17 : BEGIN L1 := 2.0e-10; L2 := 10.0e-10 END;
END;
if (par[parnumber] < L1) or (par[parnumber] > L2) then BEGIN
modeconcern:=TRUE;
writeln (' ',d,' outside expected range ');
writeln(' ',d,'=',par[parnumber]:12,' ',u);
writeln(' Anticipated Range =',L1:12,' ',u);
writeln(' to ',L2:12,' ',u);
IF modelist AND NOT modelistfile then
BEGIN
writeln(lst,' PARAMETER',parnumber:3,' OUTSIDE EXPECTED RANGE.');
writeln(lst,' ',d,'=',par[parnumber]:12,' ',u);
writeln(lst,' Anticipated Range =',L1:12,' to ',L2:12,' ',u);
writeln(lst);
END;
IF modelistfile THEN
BEGIN
Assign(lf,listfilename);
Append(lf);
writeln(lf,' PARAMETER',parnumber:3,' OUTSIDE EXPECTED RANGE.');
writeln(lf,' ',d,'=',par[parnumber]:12,' ',u);
writeln(lf,' Anticipated Range =',L1:12,' to ',L2:12,' ',u);
writeln(lf);
Close(lf);
END;
END;
END;
for vblnumber := 1 to numberofvariables do
BEGIN
LABELS_FOR_VARIABLES;
case vblnumber of
1 : BEGIN L1 := 1; L2 := 30 END;
2 : BEGIN L1 := 0.0; L2 := 0.0 END;
3 : BEGIN L1 := 0.0; L2 := 0.0 END;
4 : BEGIN L1 := 0.0; L2 := 0.0 END;
5 : BEGIN L1 := 1.0E-8; L2 := 1.0E-2;END;
6 : BEGIN L1 := 0.0; L2 := 0.0 END;
7 : BEGIN L1 := 0.0; L2 := 0.0 END;
8 : BEGIN L1 := 0; L2 := 1.0e6 END;
9 : BEGIN L1 := 1.0e-14; L2 := 0.01 END;
10 : BEGIN L1 := 0.0001; L2 := 1 END;
11 : BEGIN L1 := 0.0; L2 := 0.0 END;
12 : BEGIN L1 := 0.0; L2 := 0.9 END;
13 : BEGIN L1 := 0.1; L2 := 1.0 END;
14 : BEGIN L1 := 1.0e-16; L2 := 1.0e3 END;
15 : BEGIN L1 := 1.1; L2 := 1.0e4 END;
16 : BEGIN L1 := 1; L2 := 30 END;
17 : BEGIN L1 := 10; L2 := 300 END;
END;
if (vbl[vblnumber] < L1) or (vbl[vblnumber] > L2) then
BEGIN
writeln (' ',d,' outside expected range ');
writeln(' ',d,'=',vbl[vblnumber]:12,' ',u);
writeln(' Anticipated Range =',L1:12,' ',u);
writeln(' to ',L2:12,' ',u);
IF modelist AND NOT modelistfile then
BEGIN
writeln(lst,' VARIABLE ',vblnumber:3,' OUTSIDE EXPECTED RANGE.');
writeln(lst,' ',d,'=',vbl[vblnumber]:12,' ',u);
writeln(lst,' Anticipated Range =',L1:12,' to ',L2:12,' ',u);
writeln(lst);
END;
IF modelistfile THEN
BEGIN
Assign(lf,listfilename);
Append(lf);
writeln(lf,' VARIABLE ',vblnumber:3,' OUTSIDE EXPECTED RANGE.');
writeln(lf,' ',d,'=',vbl[vblnumber]:12,' ',u);
writeln(lf,' Anticipated Range =',L1:12,' to ',L2:12,' ',u);
writeln(lf);
Close(lf);
END;
END;
END; { for vblnumber := 1 to numberofvariables do }
textcolor(C_text); writeln;
write (' ------------ DATA CHECK COMPLETE ------------');
writeln;
END; {CHECK_PARAMETERS. }
{-------------------------------------------------------------------}
PROCEDURE INPUT_DATA_TO_PRINTER;
BEGIN
DATE_AND_TIME;
writeln(lst,' =============================================================');
writeln(lst,' ',Version,' INPUT PARAMETERS for ',filename,' ',Date_string);
writeln(lst,' =============================================================');
writeln(lst);
for parnumber := 1 to numberofparameters do BEGIN
LABELS_FOR_DATA;
writeln (lst,' ',parnumber:3,' ', d, u,' =', par[parnumber]:12);
END;
writeln(lst);
writeln(lst,' =============================================================');
writeln(lst,' Time ',time_string);
writeln(lst); writeln(lst); writeln(lst); writeln(lst);
writeln(lst,' =============================================================');
writeln(lst,' ',Version,' INPUT VARIABLES for ',filename,' ',Date_string);
writeln(lst,' =============================================================');
writeln(lst);
for vblnumber := 1 to numberofvariables do BEGIN
LABELS_FOR_VARIABLES;
writeln (lst,' ',vblnumber:3,' ', d, u,' =', vbl[vblnumber]:12);
END;
writeln(lst);
writeln(lst,' =============================================================');
writeln(lst,' Time ',time_string);
writeln(lst); writeln(lst); writeln(lst); writeln(lst);
END; {INPUT_DATA_TO_PRINTER. }
{-------------------------------------------------------------------}
PROCEDURE INPUT_DATA_TO_FILE;
VAR
lf : Text;
BEGIN
DATE_AND_TIME;
Assign(lf,listfilename);
Rewrite(lf);
writeln(lf,' =============================================================');
writeln(lf,' ',Version,' INPUT PARAMETERS for ',filename,' ',Date_string);
writeln(lf,' =============================================================');
writeln(lf);
for parnumber := 1 to numberofparameters do BEGIN
LABELS_FOR_DATA;
writeln (lf,' ',parnumber:3,' ', d, u,' =', par[parnumber]:12);
END;
writeln(lf);
writeln(lf,' =============================================================');
writeln(lf,' Time ',time_string);
writeln(lf); writeln(lf); writeln(lf); writeln(lf);
writeln(lf,' =============================================================');
writeln(lf,' ',Version,' INPUT VARIABLES for ',filename,' ',Date_string);
writeln(lf,' =============================================================');
writeln(lf);
for vblnumber := 1 to numberofvariables do BEGIN
LABELS_FOR_VARIABLES;
writeln (lf,' ',vblnumber:3,' ', d, u,' =', vbl[vblnumber]:12);
END;
writeln(lf);
writeln(lf,' =============================================================');
writeln(lf,' Time ',time_string);
writeln(lf); writeln(lf); writeln(lf); writeln(lf);
Close(lf);
END; {INPUT_DATA_TO_FILE. }
End. { Unit BUGfiles }