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
|
//-*- mode: c++; indent-tabs-mode: t; coding: utf-8; show-trailing-whitespace: t -*-
// file main.cpp
#include "main.hpp"
//**********************************************************************
// *
// --------------- Electromagnetic Transients Program ------------ *
// methods development branch, route eogb *
// division of system engineering *
// Bonneville Power Administration *
// P. O. Box 3621 *
// Portland, Oregon 97208 *
// U.S.A. phone: (503) 230-4404 *
// *
// The fortran comment-card text now being read represents a *
// summary introduction and explanation which applies to a very *
// large program development referred to by the title of *
// 'electromagnetic transients program' (abbreviated 'EMTP' , *
// or 't.p.' in the older notation). *
// *
// In general terms, the purpose of this work is to simulate *
// transient phenomena in power system networks, taking into *
// account traveling waves (electromagnetic transients) on *
// transmission lines, saturation of transformers, nonlinearities *
// of surge arresters, etc. While not so restricted in theory, *
// the most common program application is for the simulation of *
// switching surges which propagate on power network transmission *
// lines. for a more detailed explantion of the modeling *
// techniques which are used, the reader is referred to the *
// manual for this program (840 pages for the version dated *
// march, 1983). ). while older issues were titled *
// "EMTP user's manual", beginning in september of 1980 *
// this work is now called the "EMTP rule book" . *
// *
// The utpf is a large 80-column bcd card-image file, to be used *
// as input to e/t programs. E/t programs machine translate this *
// utpf code into legal fortran for most computer systems of *
// interest (ibm, cdc, univac, honeywell, dec pdp-10, dec vax-11, *
// prime, sel, apollo, hitachi, facom, harris, etc.). *
// *
// In conformity with long-standing bpa policy, as well as the *
// more recent (february 19, 1975) federal freedom of information *
// act, dissemination of these program materials is freely made *
// to any and all interested parties. a fee to cover reproduction,*
// handling, and mailing costs may be assessed against the *
// organization receiving the material, however. No claim or *
// warranty as to the usefulness, accuracy, fidelity, or *
// completeness of these materials is (or ever has been) in any *
// way expressed or implied. *
// *
//**********************************************************************
//
// The present module main00 is always in memory. It is the
// highest level module of a program which has two levels of
// overlaying. It calls primary level overlays only (directly),
// based on the value of variable 'nchain' . The following
// legitimate values, and the meaning of the associated overlay
// calls, exist .....
// 1-20. For overlays 1, 2, ..., 20, which are secondary-level
// overlays, a call must be first made to the controlling
// primary-level overlay. Thus for such 'nchain' values,
// control is transfered first to module main10 . This
// is the only case where calls to overlays are not made
// directly.
//
// 29. Completion of statistics (Monte Carlo) study, where variable
// maxima of the different case solutions are read off the
// disk, and are processed statistically to produce
// cumulative distribution functions, etc.
//
// 31. Plot routine, for graphical output of transients.
// The program also terminates execution here, usually,
// after writing an end-of-information mark on the
// plot tape (whether or not the user has plotted anything).
//
// 39. Supporting routine which generates EMTP branch
// cards for the frequency-dependent representation of
// an untransposed transmission line. this is the
// "marti setup" code, named after dr. jose marti of
// vancouver and caracas (see 1981 ieee pica paper).
//
// 41. Supporting routine which calculates transformer matrices (R)
// and (L) from short-circuit and open-circuit data.
//
// 42. Supporting routine which converts an rms voltage vs. current
// saturation characteristic into an instantaneous flux vs.
// current characteristic.
//
// 43. Supporting routine which calculates weighting functions
// a1(t) and a2(2) for the zero-sequence mode of a
// distributed line which has frequency-dependent line
// constants r and l .
//
// 44. Supporting routine which calculates line constants for
// overhead transmission lines by means of carson's formula.
// this is a modified version of what was originally (until
// january 1975) the completely-separate bpa line-constants
// program.
//
// 45. Supporting routine of 'Semlyen setup' code. the output
// is a group of punched cards, as are required for the EMTP
// simulation of a transmission circuit using semlyen
// recursive convolution modeling.
//
// 47. Supporting routine of 'cable constants' code. the
// primary function is to calculate (r), (l), % (c)
// matrices for a multi-phase system of single-core coaxial
// cables.
//
// 51. Printing of introductory paragraph of error-message
// termination ('you lose, fella, ... '), plus error-message
// texts for 'kill' codes numbered 1 through 50 .
// the exiting linkage is to the last error overlay.
//
// 52. Error message texts for 'kill' codes numbered 51
// the exiting linkage is to the last error overlay.
//
// 53. Error message texts for 'kill' codes numbered 91
// through 150. the exiting linkage is to the last
// error overlay.
//
// 54. Error message texts for 'kill' codes numbered 151
// through 200. the exiting linkage is to the
// last error overlay.
//
// 55. Final error overlay. Messages for kill = 201
// onward are contained, as well as summary statistics
// --- table sizes and timing figures for the run.
// The exiting linkage is generally to module over1 (to read
// a new data case), but may be to module over31 (for final
// case termination).
//**********************************************************************
int main(int argc, char *argv[])
{
char c;
char optopt;
int n1;
long int nReturnValue = EXIT_FAILURE;
static struct option long_options[] = {
{ "dimensioning-file", optional_argument, nullptr, 'd' },
{ "case-file", optional_argument, nullptr, 'f' },
{ "help", optional_argument, nullptr, 'h' },
{ "output-file", optional_argument, nullptr, 'o' },
{ "verbose", optional_argument, nullptr, 'v' },
{ "version", optional_argument, nullptr, 'V' },
{ nullptr, 0, nullptr, 0 }
};
struct winsize sWindow;
//
auto a2010 = [&](void)
{
if(blkcom::nM4Plot == 1)
;//emtspy();
switch(blkcom::nChain) {
case 29:
#ifdef WITH_OVER29
over29();
#else
emtp::dummy();
#endif
break;
case 31:
#ifdef WITH_OVER31
over31();
#else
emtp::dummy();
#endif
break;
case 39:
#ifdef WITH_OVER39
over39();
#else
emtp::dummy();
#endif
break;
case 41:
#ifdef WITH_OVER41
over41();
#else
emtp::dummy();
#endif
break;
case 42:
#ifdef WITH_OVER42
over42();
#else
emtp::dummy();
#endif
break;
case 44:
#ifdef WITH_OVER44
over44();
#else
emtp::dummy();
#endif
break;
case 45:
#ifdef WITH_OVER45
over45();
#else
emtp::dummy();
#endif
break;
case 47:
#ifdef WITH_OVER47
over47();
#else
emtp::dummy();
#endif
break;
case 51:
#ifdef WITH_OVER51
over51::over51();
#else
emtp::dummy();
#endif
break;
case 52:
#ifdef WITH_OVER52
over52();
#else
emtp::dummy();
#endif
break;
case 53:
#ifdef WITH_OVER53
over53();
#else
emtp::dummy();
#endif
break;
case 54:
#ifdef WITH_OVER54
over54();
#else
emtp::dummy();
#endif
break;
case 55:
#ifdef WITH_OVER55
over55();
#else
emtp::dummy();
#endif
break;
default:
(*reinterpret_cast<std::ostream *> (blkcom::pLFiles[ 5 ])) << std::endl << " Illegal NCHAIN in MAIN00." << blkcom::nChain << std::endl << std::flush;
break;
}
};
auto a2001 = [&](void)
{
//
n1 = blkcom::nChain;
if(n1 > 30)
n1 -= 30;
if(n1 <= 0)
n1 = 1;
if(blkcom::nIprsUp == 0)
blkcom::nIprsUp = blkcom::pIprsOV[ n1 - 1 ];
if(blkcom::nChain > 20)
a2010();
else {
if((blkcom::nChain == 12) || (blkcom::nChain == 2))
emtp::main10();
else {
if(blkcom::nChain == -1)
;//movecopy::move0(&blkcom::pIprsOv[ 0 ], nLL34);
emtp::vardim(emtp::sSizesFileName, blkcom::sLStat);
emtp::erexit();
blkcom::nChain = 0;
if (blkcom::nChain <= 20)
emtp::main10();
}
}
};
//
opterr = 0;
optind = 0;
blkcom::nLLBuff = -3333;
blkcom::nChain = -1;
blkcom::nLastOV = 0;
blkcom::nKill = 0;
blkcom::pLFiles[ 0 ] = reinterpret_cast<void *>(&std::cerr);
blkcom::pLFiles[ 4 ] = reinterpret_cast<void *>(&std::cin);
blkcom::pLFiles[ 5 ] = reinterpret_cast<void *>(&std::cout);
sWindow = utilities::getTerminalSize();
if(sWindow.ws_col >= 132)
blkcom::nKol132 = 132;
else if(sWindow.ws_col >= 80)
blkcom::nKol132 = 80;
else
blkcom::nKol132 = sWindow.ws_col;
while((c = getopt_long(argc, argv, "d:f:ho:vV", long_options, &optind)) != -1) {
switch(c) {
case 0:
// If this option set a flag, do nothing else now.
if(long_options[ optind ].flag != 0)
break;
std::cout << "Option " << long_options[ optind ].name;
if(optarg)
std::cout << " with arg " << optarg;
std::cout << std::endl;
break;
case 'd':
{
std::stringstream sTemp(optarg);
if(sTemp.str().empty()) {
blkcom::nChain = 51;
blkcom::nKill = 100;
emtp::sSizesFileName = "";
} else {
emtp::sSizesFileName = sTemp.str();
}
}
break;
case 'f':
// To do.
break;
case 'h':
std::cout << "Usage: gemtp++ [-d|--dimensioning-file dimfile] [-f|--case-file infile] [-h|--help] [-o|--output-file outfile] [-v|--verbose] [-V|--Version] [< infile]" << std::endl;
emtp::stoptp();
exit(EXIT_SUCCESS);
break;
case 'o':
// To do.
break;
case 'v':
++blkcom::nIprsUp;
break;
case 'V':
// To do.
break;
}
}
FOREVER {
switch(blkcom::nKill) {
case 0:
case 9999:
a2001();
break;
case 7733:
(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " \"main\" intercept of \"begin\" request." << std::endl << std::flush;
blkcom::nKill = 0;
blkcom::nNumDCD = 0;
blkcom::nChain = 1;
emtp::main10();
break;
default:
if(blkcom::nChain > 51)
a2001();
else {
blkcom::nChain = 51;
a2001();
}
break;
}
}
;;
return nReturnValue;
}
// end of file main.cpp
|