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
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
|
//-*- mode: c++; indent-tabs-mode: t; coding: utf-8; show-trailing-whitespace: t -*-
// file emtp.cpp
#include "emtp.hpp"
// The EMTP solution process proper consists of numerous secondary-
// level overlays, each called from module main10 using
// module number 'nchain' as the indicator of where control is to
// pass next. The following is a tabulation of valid 'nchain'
// values, along with the function of the corresponding code. With
// the possible exception of the time-step loop, 'nchain' is the
// utpf overlay number of the code to which control is to be
// transfered next. The overlay number of the time-step loop
// is given by 'nchain' corresponding to the first quarter of
// the time-step-loop segmentation, on machines not using ecs
// overlaying.
//
// 1. Input of miscellaneous data cards.
// 2. Input branch data.
// 3. Code associated with the cascading of pi-circuits for
// steady-state phasor solutions only.
// 4. Input and processing of frequency-dependence data for
// distributed-parameter line mode.
// 5. Input of switch and source data cards.
// 6. Network connectivity output. Setup of transient-network
// renumbering tables.
// 7. Network node renumbering routine (John Walker's old
// subroutine number).
// 8. Convert tables to new node numbers. Find steady-state
// phasor equivalents for distributed branches.
// 9. Set up steady-state phasor network renumbering tables.
// 10. Form the steady-state admittance matrix (y). Solve for
// steady-state phasor voltages.
// 11. Output steady-state phasor solution (if requested).
// 12. Branch-table and switch-table processing, as preparation
// for the integration in time-step loop.
// 13. Setup initial conditions on lumped elements, and past
// history for distributed lines.
// 14. Form (Y) for the transients network. Triangularize the
// first partition (nonswitch/source nodes).
// 15. Final setup operations before time-step loop.
// 16. First quarter of time-step loop (checking for changes of
// switches and pseudo-nonlinear elements, retriangularization
// of Ybb and calculation of thevenin impedance vectors).
// 17. Second quarter of time-step loop (branch-table history
// updating, addition of branch contributions to nodal
// injected current vector i ).
// 18. Third quarter of time-step loop (source update, repeat
// solution of (Y)v = i for node voltage vector v ).
// 19. Fourth quarter of time-step loop (solution of 3-phase
// nonlinearities and compensation-based rotating
// machinery [type-50 s.m., u.m.], superposition to
// give the total solution including compensation).
// 20. Punch and print terminal conditions (if requested).
// Catalog plot-data points on the disk as a permanent file, if
// misc. data parameter 'icat' is positive.
namespace emtp {
const long int nLL34 = 34;
std::string sSizesFileName;
tWords pWords[ 24 ] = {
{ "a", "attach", 1 },
{ "p", "punch", 2 },
{ "out", "output", 3 },
{ "s", "save", 4 },
{ "spy", "spydata", 5 },
{ "d", "disable", 7 },
{ "r", "return", 10 },
{ "n", "newfile", 11 },
{ "ne", "new epsln", 13 },
{ "de", "delete", 15 },
{ "m", "monitor", 16 },
{ "lf", "listoff", 18 },
{ "ln", "liston", 20 },
{ "v", "vintage", 21 },
{ "old", "oldfile", 23 },
{ "st", "stop", 25 },
{ "w", "watch5", 26 },
{ "com", "comment", 27 },
{ "wi", "width", 29 },
{ "u", "units", 30 },
{ "", "", 31 },
{ "", "", 0 }
};
// subroutine ioerr.
void ioerr(const long int &nAddr)
{
;
}
// subroutine caterr.
void caterr(const long int &nAddr, const long int &nKodErr)
{
;
}
void stoptp(void)
{
// Temporary stop statements of EMTP have been converted to
// "CALL STOPTP", allowing installation-dependent clean up.
blkcom::sTexCol = blkcom::sABuff.str().substr(0, 80);
if((blkcom::nChain == 31) && (blkcom::nLastOV == 1) && (blkcom::nKill == 9999))
exit(EXIT_FAILURE);
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " Temporary error stop in \"stoptp\"., nchain, lastov =";
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << blkcom::nChain << blkcom::nLastOV;
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " Last-read card image ABUFF follows ...." << std::endl;
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << blkcom::sABuff.str() << std::endl << std::flush;
exit(EXIT_FAILURE);
}
// subroutine nextcard.
void nextcard(void)
{
long int n7;
// This entry is used only for interactive EMTP. It gets
// next card image from memory rather than unit 5.
n7 = blkcom::nNumDCD + 1;
a1472:
if(spycom::nIprSpy < 5)
goto a1486;
(*reinterpret_cast<std::stringstream *>(spycom::pMFiles[ 5 ])) << " in \"nextcard\":";
(*reinterpret_cast<std::stringstream *>(spycom::pMFiles[ 5 ])) << std::setfill(' ') << std::setw(5) << std::dec << n7;
(*reinterpret_cast<std::stringstream *>(spycom::pMFiles[ 5 ])) << " ";
(*reinterpret_cast<std::stringstream *>(spycom::pMFiles[ 5 ])) << std::setfill(' ') << std::setw(80) << spyf77::sFile6[ n7 - 1 ] << std::endl;
utilities::window(*reinterpret_cast<std::ostream*>(blkcom::pLFiles[ 5 ]), \
*reinterpret_cast<std::stringstream *>(spycom::pMFiles[ 5 ]));
a1486:
if(n7 <= spycom::nNumCRD)
goto a1488;
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " **** **** Data crisis. Last card has been read. numcrd =";
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::setfill(' ') << std::setw(6) << std::dec << spycom::nNumCRD << std::endl;
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " Use \"data\" command of spy to read in next block of data." << std::endl;
if(blkcom::nM4Plot != 1)
goto a9000;
over20::emtspy();
goto a1472;
a1488:
blkcom::sABuff.str(spyf77::sFile6[ n7 - 1 ]);
goto a9200;
a9000:
blkcom::nKill = 7654;
a9200:
return;
}
// subroutine cimage.
void cimage(void)
{
// VAX-11 installation-dependent EMTP module which serves
// to return the next input card. All systems will substitute.
//
//char pBuff10[ 80 ];
//
long int i;
long int j;
long int k;
long int l;
long int n1, n2, n3, n8 = 0, n11 = 0, n12 = 99999, n13 = 99999;
//
double d1;
double d11 = 0.0;
//
std::string sBuff10;
std::string sFileName;
std::string sText1;
std::string sText2;
std::string sText4("9");
std::string sText5("blank");
std::string sCharC("c");
std::string sChTACS("tacs");
//
std::fstream *pTempFile1 = nullptr, *pTempFile2 = nullptr, *pTempFile7 = nullptr;
//
auto a4209 = [ & ](void)
{
//
blkcom::nNFrFld = 1;
free((void *) &d11);
a4225:
if(d11 < 0.0)
pTempFile1 = pTempFile2;
else
pTempFile1 = reinterpret_cast<std::fstream *>(blkcom::pLFiles[ (int) d11 ]);
if(n8 == 8) {
utilities::closeFile(reinterpret_cast<std::fstream *>(pTempFile1));
if(blkcom::nNOutPR == 0)
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "+Close file on unit 0x" << std::setfill('0') << std::setw(8) << std::hex << pTempFile1 << " ." << std::endl;
if(pTempFile1 == blkcom::pLFiles[ 4 ])
blkcom::nNOutPR = 1;
} else {
if(blkcom::nNOutPR == 0) {
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "+Copy file";
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "0x" << std::setfill('0') << std::setw(8) << std::hex << pTempFile1;
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " to" << sText1 << " ." << std::endl;
}
utilities::copyFile(pTempFile1, \
pTempFile7, \
sFileName);
}
};
auto a4206 = [ & ](void)
{
pTempFile2 = reinterpret_cast<std::fstream *>(blkcom::pLFiles[ 6 ]);
a4209();
};
auto a4506 = [ & ](void)
{
long int i;
long int k;
long int n4;
//
std::fstream *pTempFile6 = nullptr;
std::fstream *pTempFile7 = nullptr;
//
n4 = 0;
sFileName = std::string(25, ' ');
for(k = blkcom::nKolBeg; k <= 80; k++) {
if(blkcom::sTexCol[ k - 1 ] != ' ') {
if((blkcom::sTexCol[ k - 1 ] == blkcom::cCSepar) || \
(blkcom::sTexCol[ k - 1 ] == '('))
goto a4536;
++n4;
sFileName[ n4 - 1 ] = blkcom::sTexCol[ k - 1 ];
}
}
k = 80;
a4536:
blkcom::nKolBeg = k + 1;
blkcom::nNFrFld = 1;
free((void *) &d11);
pTempFile7 = reinterpret_cast<std::fstream *>(blkcom::pLFiles[ (int) d11 - 1 ]);
if(n8 == 4) {
free((void *) &d11);
pTempFile6 = reinterpret_cast<std::fstream *>(blkcom::pLFiles[ (int) d11 - 1 ]);
} else {
if(!pTempFile6)
pTempFile6 = reinterpret_cast<std::fstream *>(blkcom::pLFiles[ 6 ]);
if(n8 == 5)
pTempFile7 = reinterpret_cast<std::fstream *>(spycom::pMFiles[ 4 ]);
if(!pTempFile7) {
for(k = 1; k <= 15; k++)
if(blkcom::pLFilesSave[ k - 1 ] == nullptr)
goto a4568;
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::endl;
for(i = 1; i <= 10; i++)
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " Error, ";
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::endl;
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::string(5, ' ') << " All I/O channels occupied. Kill run at s.n. 4566 of \"cimage\" ." << std::endl;
for(i = 1; i <= 20; i++)
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::setfill(' ') << std::setw(5) << std::dec << blkcom::pLFilesSave[ i - 1 ];
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::endl;
stoptp();
a4568:
pTempFile7 = reinterpret_cast<std::fstream *>(blkcom::pLFiles[ k - 1 ]);
} else {
if(blkcom::nNOutPR == 0)
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "+" << sText1.substr(0, 6) << " file:" << sFileName.substr(0, 25) << " unit = 0x" << std::setfill('0') << std::setw(8) << std::hex << pTempFile7 << std::endl;
switch(n8) {
case 4:
utilities::copyFile(pTempFile6, pTempFile7, sFileName); // label 4423
break;
case 9:
utilities::openFile(pTempFile7, sFileName, std::ios::out); // label 4907
break;
case 11:
utilities::deleteFile(sFileName); // label 5106
break;
case 16:
utilities::closeFile(pTempFile7); // label 5608
utilities::openFile(pTempFile7, sFileName, std::ios::out);
break;
default:
utilities::closeFile(pTempFile7);
utilities::openFile(pTempFile7, sFileName, std::ios::out);
pTempFile7 -> seekp(0, std::ios::beg);
if(n8 == 5)
over20::spying();
break;
}
}
}
};
auto cattach = [ & ](void)
{
sText1 = "attach";
a4506();
};
auto cpunch = [ & ](void)
{
long int n1;
//
sText1 = "punch";
a4206();
};
auto coutput = [ & ](void)
{
sText1 = "output";
a4206();
};
auto csave = [ & ](void)
{
sText1 = "saved";
a4506();
};
auto cspydata = [ & ](void)
{
sText1 = "spying";
blkcom::pMFilesSave[ 1 ] = nullptr; // remember $spy for eof time in "spying (2288)"
blkcom::pMFilesSave[ 0 ] = spycom::pMFiles[ 4 ]; // remember spy input channel till now
spycom::pMFiles[ 4 ] = blkcom::pLFiles[ 16 ]; // special I/O unit used for $spy connection
spycom::nKFile5 = 1; // flag so "spying" knows munit5 opened to disk
a4506();
};
auto cdisable = [ & ](void)
{
if(blkcom::nNOutPR == 0)
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "+Begin data to be ignored." << std::endl;
};
auto cenable = [ & ](void)
{
if(blkcom::nNOutPR == 0)
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "+End of data to be ignored." << std::endl;
};
auto creturn = [ & ](void)
{
pTempFile2 = reinterpret_cast<std::fstream *>(blkcom::pLFiles[ 3 ]);
a4209();
};
auto cnewfile = [ & ](void)
{
sText1 = "newfil";
pTempFile2 = reinterpret_cast<std::fstream *>(blkcom::pLFiles[ 3 ]);
a4506();
};
auto cnew_epsilon = [ & ](void)
{
double d1;
//
blkcom::nNFrFld = 1;
d1 = blkcom::nEpsilon;
freedom::freeOne(blkcom::nEpsilon);
if(blkcom::nNOutPR == 0)
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "+ Epsiln change. old, new =" << std::setfill(' ') << std::setw(13) << d1 << blkcom::nEpsilon << std::endl;
};
auto cdelete = [ & ](void)
{
sText1 = "delete";
a4506();
utilities::deleteFile(sFileName);
};
auto cmonitor = [ & ](void)
{
if(blkcom::nNOutPR != 0) {
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << sBuff10 << std::endl;
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "+CRT Monitor. Card number = " << std::setfill(' ') << std::setw(5) << std::dec << blkcom::nNumDCD << std::endl;
}
};
auto clistoff = [ & ](void)
{
if(blkcom::nNOutPR == 0) {
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "+Turn off input listing at card" << std::setfill(' ') << std::setw(5) << std::dec << blkcom::nNumDCD << std::endl;
blkcom::nNOutPR = 1;
}
};
auto cliston = [ & ](void)
{
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::string(51, ' ') << "|$liston"<< std::endl;
blkcom::nNOutPR = 0;
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "+Turn on input listing at card" << std::setfill(' ') << std::setw(5) << std::dec << blkcom::nNumDCD << std::endl;
};
auto cvintage = [ & ](void)
{
;
};
auto coldfile = [ & ](void)
{
;
};
auto cstop = [ & ](void)
{
;
};
auto cwatch5 = [ & ](void)
{
;
};
auto ccomment = [ & ](void)
{
;
};
auto cwidth = [ & ](void)
{
;
};
auto cunits = [ & ](void)
{
;
};
tRequest pRequests[] = {
{ "a", "attach", 1, cattach },
{ "p", "punch", 2, cpunch },
{ "out", "output", 3, coutput },
{ "s", "save", 4, csave },
{ "spy", "spydata", 5, cspydata },
{ "d", "disable", 7, cdisable },
{ "e", "enable", 9, cenable },
{ "r", "return", 10, creturn },
{ "n", "newfile", 11, cnewfile },
{ "ne", "new epsiln", 13, cnew_epsilon },
{ "de", "delete", 15, cdelete },
{ "m", "monitor", 16, cmonitor },
{ "lf", "listoff", 18, clistoff },
{ "ln", "liston", 20, cliston },
{ "v", "vintage", 21, cvintage },
{ "old", "oldfile", 23, coldfile },
{ "st", "stop", 25, cstop },
{ "w", "watch5", 26, cwatch5 },
{ "com", "comment", 27, ccomment },
{ "wi", "width", 29, cwidth },
{ "u", "units", 30, cunits }
};
std::list<tRequest> sRequests(pRequests, pRequests + sizeof(pRequests) / sizeof(tRequest));
auto cecho = [ & ](void)
{
if(blkcom::nChain <= 15)
++blkcom::pIpnTV[ 10 ] + 1;
reinterpret_cast<std::fstream *>(blkcom::pInEcho) -> write(blkcom::sABuff.str().c_str(), 80);
};
auto ibrinc = [ & ](void)
{
++blkcom::nIBr;
labcom::sXOptBR[ blkcom::nIBr - 1 ] = blkcom::nXOpt;
labcom::sCOptBR[ blkcom::nIBr - 1 ] = blkcom::nCOpt;
};
//
// The main body of cimage subroutine.
//
if(blkcom::nIprsUp >= 10) {
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " Begin cimage. lunit5, lunit6, noutpr, numdcd =";
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "0x" << std::setfill('0') << std::setw(8) << std::hex << blkcom::pLFiles[ 4 ];
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "0x" << std::setfill('0') << std::setw(8) << std::hex << blkcom::pLFiles[ 5 ];
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::setfill(' ') << std::setw(5) << std::dec << blkcom::nNOutPR;
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::setfill(' ') << std::setw(5) << std::dec << blkcom::nNumDCD << std::endl << std::flush;
}
a1000:
if(blkcom::nM4Plot == 1)
over20::emtspy();
if(blkcom::pLFiles[ 4 ] != nullptr) {
if(reinterpret_cast<std::ifstream *>(blkcom::pLFiles[ 4 ]) -> is_open()) {
std::getline(*reinterpret_cast<std::istream *>(blkcom::pLFiles[ 4 ]), sBuff10, '\n');
if(reinterpret_cast<std::ifstream *>(blkcom::pLFiles[ 4 ]) -> eof())
goto a4000;
}
}
if(blkcom::pLFiles[ 4 ]) {
if(!reinterpret_cast<std::ifstream *>(blkcom::pLFiles[ 4 ]) -> is_open())
nextcard();
} else
nextcard();
if(blkcom::nKill > 0)
goto a4000;
if(!blkcom::pLFilesSave[ 4 ])
++blkcom::nNumDCD;
sBuff10 = blkcom::sABuff.str();
sText1 = sBuff10[ 0 ];
sText2 = sBuff10[ 1 ];
if(sText1 != CHARC)
goto a3034;
if(sText2 != BLANK)
goto a3034;
a1036:
if(blkcom::nNOutPR != 0)
goto a1000;
if(n11 != 0)
goto a1000;
if(blkcom::nKol132 == 132)
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " Comment card. " << std::string(37, ' ') << "|" << sBuff10.substr(0, 80) << std::endl;
else
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " Comment card. " << std::string(37, ' ') << "|" << sBuff10.substr(0, 29) << std::endl;
goto a1000;
a3034:
if(blkcom::nNOutPR != 0)
goto a3035;
if(blkcom::nKol132 == 132)
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::string(52, ' ') << "|" << sBuff10.substr(0, 80) << std::endl;
else
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::string(52, ' ') << "|" << sBuff10.substr(0, 29) << std::endl;
a3035:
if(n13 > 0)
goto a3011;
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " " << std::setfill(' ') << std::setw(5) << std::dec << blkcom::nNumDCD << " :" << blkcom::sABuff.str().substr(0, 72) << std::endl;
n13 = n12;
a3011:
--n13;
blkcom::sABuff >> sText2;
if(strcom::toLower(sText2) != sText5)
goto a3040;
if(n8 == 6)
goto a3044;
a3039:
blkcom::sABuff.str("");
goto a3233;
a3040:
if(blkcom::sChCont == strcom::toLower(sText4))
goto a3233;
blkcom::sTexCol = blkcom::sABuff.str().substr(0, 80);
if((strcom::toLower(blkcom::sABuff.str()) != "$listoff") && \
(strcom::toLower(blkcom::sABuff.str()) != "$liston"))
goto a3042;
goto a3246;
a3042:
if(blkcom::sChCont == sChTACS)
goto a3233;
if(blkcom::sTexCol == blkcom::sChCont)
goto a3246;
if(n8 != 6)
goto a1144;
a3044:
if(blkcom::nNOutPR == 0)
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "+Comment card (impicit)." << std::endl;
goto a1000;
a1144:
for(k = 1; k <= 80; k++) {
if(blkcom::sTexCol[ k - 1 ] == blkcom::cCSepar)
goto a3237;
if(blkcom::sTexCol.substr(k - 1, blkcom::sChCont.size()) == blkcom::sChCont)
goto a3237;
}
a3233:
blkcom::nKolBeg = -std::numeric_limits<long int>::infinity();
goto a7014;
a3237:
blkcom::nKolBeg = 1;
goto a7014;
a3246:
blkcom::nKolBeg = 2;
a3251:
blkcom::nNRight = -2;
freedom::freeOne(d1);
if(blkcom::nIprsUp >= 1)
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::endl << " nfrfld = " << std::setfill(' ') << std::setw(8) << blkcom::nNFrFld << std::string(5, ' ') << "texta6 = " << blkcom::pTextA6[ 0 ].substr(0, 7) << blkcom::pTextA6[ 1 ].substr(0, 7) << std::endl;
blkcom::nNRight = 0;
for(i = 1; i <= 200; i++) {
n1 = pRequests[ i - 1 ].m_nPointer;
n2 = pRequests[ i ].m_nPointer - 1;
if(n2 < 0)
goto a3319;
if(blkcom::nIprsUp >= 35) {
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " Special-request word" << std::setfill(' ') << std::setw(4) << i << " .";
for(j = n1; j <= n2; j++)
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << pRequests[ j - 1 ].m_sLongName;
}
if(strcom::toLower(pRequests[ n1 - 1 ].m_sLongName) == BLANK)
goto a3306;
l = 0;
n2 = n2 - n1 + 1;
if(n3 != blkcom::nNFrFld)
goto a3306;
for(j = n1; j <= n2; j++) {
++l;
if(strcom::toLower(blkcom::pTextA6[ l - 1 ]) != pRequests[ j - 1 ].m_sLongName)
goto a3306;
}
if(blkcom::nIprsUp >= 2) {
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::endl << " key-word found. i, n8 =" << std::setfill(' ') << std::setw(5) << i << n8;
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::string(5, ' ') << "texta6, textay = " << blkcom::pTextA6[ 0 ] << pRequests[ i - 1 ].m_sLongName << std::endl;
}
a3294:
if(n8 != 6)
goto a3301;
if(i != 7)
goto a1036;
a3301:
n8 = i;
switch(n8) {
case 1: // ***** Request no. 1. "$attach" *****
cattach();
break;
case 2: // ***** Request no. 2. "$punch" *****
cpunch();
break;
case 3: // ***** Request no. 3. "$output" *****
coutput();
break;
case 4: // ***** Request no. 4. "$save" *****
csave();
break;
case 5: // ***** Request no. 5. "$spy" *****
cspydata();
break;
case 6: // ***** Request no. 6. "$disable" *****
cdisable();
break;
case 7: // ***** Request no. 7. "$enable" *****
cenable();
break;
case 8: // ***** Request no. 8. "$return" *****
creturn();
break;
case 9: // ***** Request no. 9. "$newfile" *****
cnewfile();
break;
case 10: // ***** Request no. 10. "new epsiln" *****
cnew_epsilon();
break;
case 11: // ***** Request no. 11. "delete" *****
cdelete();
break;
case 12: // ***** Request no. 12. "monitor" *****
cmonitor();
break;
case 13: // ***** Request no. 13. "listoff" *****
clistoff();
break;
case 14: // ***** Request no. 14. "liston" *****
cliston();
break;
case 15: // ***** Request no. 15. "vintage" *****
cvintage();
break;
case 16: // ***** Request no. 16. "oldfile" *****
coldfile();
break;
case 17: // ***** Request no. 17. "stop" *****
cstop();
break;
case 18: // ***** Request no. 18. "watch5" *****
cwatch5();
break;
case 19: // ***** Request no. 19. "comment" *****
ccomment();
break;
case 21: // ***** Request no. 21. "units" *****
cunits();
break;
}
if((n8 >= 1) && (n8 <= 21))
goto a1000;
a3306:
if(strcom::toLower(blkcom::pTextA6[ 0 ]) == pRequests[ i - 1 ].m_sLongName)
goto a3294;
}
a3319:
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " Illegal $-card. Stop at s.n. 3319 of \"cimage\" ." << std::endl;
stoptp();
cattach();
goto a1000;
a4000:
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::endl << " " << std::string(85, '=') << std::endl;
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " End of file encounted in \"cimage\" while, attempting to read another data card. Stop." << std::endl << " " << std::string(85, '=') << std::endl;
stoptp();
a7014:
if(blkcom::pInEcho == nullptr)
return;
cecho();
}
void erexit(void)
{
// VAX-11 installation-dependent EMTP module. This is
// called by the top of "MAIN00", before any EMTP data input.
//int idum[ 3 ];
//nKWTVAX = 0;
datain::datain();
}
void dummy(void)
{
std::stringstream sTemp;
//
//(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " Dummy overlay function called. nchain = " << blkcom::nChain << ". Exiting." << std::endl << std::flush;
sTemp << " Dummy overlay function called. nchain = " << blkcom::nChain << ". Exiting." << std::endl << std::flush;
throw(std::runtime_error(sTemp.str().c_str()));
blkcom::nKill = 60;
}
// subroutine tapsav.
void tapsav(char *narray, std::fstream &n1, const long int &n2, const long int &n3)
{
// Near-universal module for dumping or restoring (central memory
// vs. disk) of /label/ . This does not work for those
// computers like Prime and Burroughs where common blocks
// are not ordered regularly in memory. Switch "KBURRO"
// selects between disk or virtual memory (/C29B01/).
int i;
int j;
int k;
int nKVecSv, n13;
//
long int n4, n9;
//
std::vector<long int> sKPen(5);
//
auto a5448 = [&](void)
{
if(n3 <= 1)
n1.write(&narray[ 0 ], n2);
else
n1.read(&narray[ 0 ], n2);
};
auto a6327 = [&](void)
{
if((blkcom::nChain == 20) && (blkcom::nMemSav == 1))
a5448 ();
else {
if(blkcom::nChain == 1)
a5448 ();
else {
if(!((blkcom::nChain == 6) || (blkcom::nChain == 8))) {
n13 = 29;
emtp::dimens(sKPen, n13, blkcom::sTrash, blkcom::sTrash);
nKVecSv = 2 * (blkcom::nIt + blkcom::nIt + blkcom::nIBr + blkcom::nTot + blkcom::nIoffd) + blkcom::nKSwtch + blkcom::nLHist;
n9 = blkcom::sSStat.m_nTLabl + nKVecSv * blkcom::pNByte[ 2 ] / blkcom::pNByte[ 3 ];
if(n9 >= sKPen[ 1 ] + 50) {
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " Error stop in \"tapsav\". Overflow of /c29b01/ storage. n2, kpen(2) =";
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::setw (8) << n2 << sKPen[ 1 ];
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " needed storage n9 =";
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::setw (8) << n9;
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "\n memory requirement in integer words for virtual computer implementation of tapsav. Storage must\n";
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "provide for all of --/label/--( deck \"labcom\" ), the several usages \"vecrsv\" and \"vecisv\" (over6-11), plus 50 extra cells.\n";
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "nchain =" << std::setw (5) << blkcom::nChain << std::endl << std::flush;
emtp::stoptp();
} else {
j = 50;
if(n3 <= 1) {
for(k = 1; k <= n2; k++) {
++j;
labcom::pKArray[ j - 1 ] = narray[ k - 1 ];
}
} else {
for(k = 1; k <= n2; k++) {
++j;
narray[ k - 1 ] = labcom::pKArray[ j - 1 ];
}
}
}
}
}
}
};
//
if(narray) {
if(blkcom::nIprsUp >= 1) {
n9 = 0;
sKPen[ 1 ] = 0;
n4 = (size_t) narray;
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "\n Top of \"tapsav\". n1 n2 n3 kburro n4" << std::endl << std::flush;
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "0x" << std::setw(8) << std::setfill('0') << std::hex << &n1 << " " << n2;
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " " << n3 << " " << blkcom::nKBurro << std::setw(8) << " " << n4 << std::endl << std::flush;
} else {
if(blkcom::nKBurro != 1)
a5448();
else
a6327();
}
if (blkcom::nIprsUp >= 1)
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " Exit \"tapsav\". n9, kpen(2) = " << n9 << " " << sKPen[ 1 ] << std:: endl << std::flush;
}
}
/* subroutine main10. */
void main10(void)
{
subr10();
}
/* subroutine subr10. */
void subr10(void)
{
int nIprCBL;
int n24;
//
try {
blkcom::nKTab = 0;
FOREVER {
if(blkcom::nChain <= 20) {
if(blkcom::nKill != 0)
blkcom::nChain = 51;
else {
n24 = blkcom::nChain;
if(n24 < 1)
n24 = 1;
blkcom::nIprsUp = blkcom::pIprsOV[ n24 - 1 ];
nIprCBL = blkcom::nIprsUp;
if(blkcom::nM4Plot == 1)
over20::emtspy ();
if(blkcom::nChain == 0)
blkcom::nChain = 1;
switch (blkcom::nChain) {
case 1:
#ifdef WITH_OVER1
over1::over1();
#else
dummy();
#endif
break;
case 2:
#ifdef WITH_OVER2
over2();
#else
dummy();
#endif
break;
case 3:
case 4:
emtp::stoptp();
break;
#ifdef WITH_OVER5
over5();
#else
dummy();
#endif
break;
#ifdef WITH_OVER6
over6();
#else
dummy();
#endif
break;
#ifdef WITH_OVER7
over7();
#else
dummy();
#endif
break;
#ifdef WITH_OVER8
over8();
#else
dummy();
#endif
break;
#ifdef WITH_OVER9
over9();
#else
dummy();
#endif
break;
#ifdef WITH_OVER10
over10();
#else
dummy();
#endif
break;
#ifdef WITH_OVER11
over11();
#else
dummy();
#endif
break;
case 12:
#ifdef WITH_OVER12
over12();
#else
dummy();
#endif
break;
case 13:
#ifdef WITH_OVER13
over13();
#else
dummy();
#endif
break;
case 14:
#ifdef WITH_OVER14
over14();
#else
dummy ();
#endif
break;
case 15:
#ifdef WITH_OVER15
over15();
#else
dummy();
#endif
break;
case 16:
case 17:
case 18:
case 19:
#ifdef WITH_OVER16
over16();
#else
dummy();
#endif
break;
case 20:
#ifdef WITH_OVER20
over20::over20();
#else
dummy();
#endif
break;
}
}
} else
break;
}
}
catch(std::exception &e) {
std::cerr << e.what() << std::endl;
exit(EXIT_FAILURE);
}
}
void setmar(int *n)
{
if (*n)
*n = 0;
}
void chrsiz(int *n)
{
if (*n)
*n = 0;
}
void setplt(void)
{
;
}
void setstd (void)
{
;
}
void interp(void)
{
;
}
void namea6(const std::string &sText1, long int *n24)
{
// module for maintainance of alphanumeric vector texvec of
// "labcom". maxbus of "blkcom" is last used cell. n24 chooses
// mode of use: 0 will add text1, positive will locate it,
// and negative will destroy (remove) it.
int j;
int n17 = 0;
//
std::string sText2("unused");
//
if(blkcom::nMaxBus <= 0)
goto a3423;
for(j = 1; j <= blkcom::nMaxBus; j++)
if(strcom::toLower(sText1) == strcom::toLower(labcom::sTexVec[ j - 1 ]))
goto a3446;
a3423:
if(*n24 != 0)
goto a3438;
if (n17 == 0)
goto a3434;
labcom::sTexVec[ n17 - 1 ] = strcom::toLower (sText1);
*n24 = n17;
for(j = 1; j <= blkcom::nMaxBus; j++)
if(strcom::toLower(labcom::sTexVec[ j - 1 ]) != strcom::toLower(sText2)) {
;
} else {
n17 = j;
goto a9000;
}
n17 = 0;
goto a9000;
a3434:
++blkcom::nMaxBus;
if (blkcom::nMaxBus > blkcom::sSStat.m_nSize7)
exit(EXIT_FAILURE);
labcom::sTexVec[ blkcom::nMaxBus - 1 ] = strcom::toLower(sText1);
*n24 = blkcom::nMaxBus;
goto a9000;
a3438:
if(blkcom::nIprsUp >= 1) {
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " +++++ Search of EMTP name vector bus through cell";
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::setw (5) << blkcom::nMaxBus;
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " in \"namea6\" shows no match for\n";
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " . \"";
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::setw (6) << sText1;
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "\". Return -intinf.";
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::setw (10) << *n24 << std::endl << std::flush;
}
*n24 = std::numeric_limits<int>::min();
goto a9000;
a3446:
if (*n24 < 0)
goto a3455;
*n24 = j;
goto a9000;
a3455:
labcom::sTexVec[ j - 1 ] = strcom::toLower (sText2);
n17 = j;
a9000:
if(blkcom::nIprsUp >= 6) {
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " Exit \"namea6\". text1, maxbus, n24, j =";
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " ";
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::setw (6) << sText1;
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::setw (10) << blkcom::nMaxBus << *n24 << j << std::endl << std::flush;
}
}
void tables(void)
{
// Utility which is used to both dump and restore EMTP
// tables (central memory vs. disk). Usage is for both
// "statistics" (over12, over15, over20) and "start again"
// (over1, over20). Call to "tapsav" dumps /label/ .
// Also used by $restart request of "cimage" (called
// from "lookie" which is called by "subts3" of ov16).
// Also used by "restore" request of rtm, where table
// restoration is in "katalg" of overlay 20.
// Note about deck "synmac". If EMTP s.m. modeling
// Brandwajn (type-59), is to be deleted,
// then all s.m. subroutines ( smdat, smout, smpfit,
// smint, uncor, premec, elec, past,
// update, increm ) are to be destroyed, and
// deck "synmac" is to be removed from the present module.
// but then "dimension z(1)" should be added in its
// place, and the "n4 =" calculation involving "locint"
// should be replaced by the simple statements "n4 = 1" .
// comment card immediately preceding "synmac" -------------
// comment card immediately following "synmac" -------------
long int i, iprsav[] = { 0, 0, 0, 0 };
long int j;
long int ll0, ll1, ll2, ll4;
long int n1, n2, n3, n4, n5, n9, n24;
//
char *pBusOne = &blkcom::sBus1[ 0 ];
long int *pIDistX = &blkcom::nEnerg;
long int *pKBase = &blkcom::sMonCar.m_nKBase;
std::vector<long int> sIntegX;
std::vector<long int> sITemp;
std::vector<long int> sJTemp;
std::vector<long int> sKTemp;
std::vector<long int> sKPen;
//
ll1 = 1;
ll2 = 2;
ll4 = 4;
blkcom::nNWord1 = (size_t) blkcom::pVoltBC - (size_t) &sKPen;
blkcom::nNWord2 = (size_t) blkcom::pIDistX - (size_t) &blkcom::pLFilesSave[ 14 ];
// ... to complete.
}
// subroutine csup.
void csup(const long int &l)
{
;
}
}
// end of file emtp.hpp
|