summaryrefslogtreecommitdiffstats
path: root/sources/vardim.cpp
blob: 24c485fa89c9560fa27685b98ffa202a73ceffda (plain)
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
//-*- mode: c++; indent-tabs-mode: t; coding: utf-8; show-trailing-whitespace: t -*-
// file vardim.cpp

#include "vardim.hpp"

namespace vardim {
  
  int pLstDef[] = {
    250, 300, 500, 100,
    2500, 40, 550, 1750,
    75, 160, 50, 50,
    5, 460, 50, 40,
    4, 5, 1600, 650,
    100, 150, 4000, 3,
    400, 50, 50, 1080
  };

  tVariables pVariables[] = {
    { "x", 3, "c0b001", 0 },
    { "ykm", 5, "c0b002", 0 },
  };

  // Functions.
  bool vardim(int *pLstNew)
  {
    bool bReturnValue = false;
    long int j;
    long int n1, n4, n9, n37;
    long int nMTot;
    long int nNumLst = 28;
    long int nNumKEx;
    long int pKExtra[ 29 ];
    long int pNCBarr[ 300 ];
    long int pCBlock[ 300 ];
    long int pJBLTyp[ 300 ];
    long int pMulVar[ 4 ];
    std::string sBus1, sBus2;
    //
    try {
      if(pLstNew) {
	for(int i = 1; i <= nNumLst; i++)
	  (*reinterpret_cast<std::istream *>(blkcom::pLFiles[ 4 ])) >> std::setw(8) >> pLstNew[ i - 1 ];
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "\n Pseudo-listing of data cards";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " which have been read by the variable-";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "dimensioning program 'vardim' .   Only\n";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " if all data fields are punched with";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " 'clean' I8 integer information will";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " this be a true listing.   Data cards\n";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " Are in fact read in and then printed out";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " using integer variables and  10I8";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "  format." << std::endl;
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " " << std::string(111, '-') << std::endl;
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::string(31, ' ') << "0";
	for(int i = 1; i <= 8; i++)
	  (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::string(9, ' ') << std::setw(1) << i;
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::endl;
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::string(31, ' ') << "0";
	for(int i = 1; i <= 8; i++)
	  (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::string(9, ' ') << "0";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::endl;
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::string(31, ' ') << std::string(80, '-') << std::endl;
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " 1st card (lists  1-10)." << std::string(7, ' ') << "1";
	for(int i = 1; i <= 10; i++)
	  (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::setw(8) << pLstNew[ i - 1 ];
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::endl;
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " 2nd card (lists 11-20)." << std::string(7, ' ') << "1";
	for(int i = 11; i <= 20; i++)
	  (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::setw(8) << pLstNew[ i - 1 ];
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::endl;

	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " 3rd card (lists 21-30)." << std::string(7, ' ') << "1";
	for(int i = 21; i <= nNumLst; i++)
	  (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::setw(8) << pLstNew[ i - 1 ];
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::endl;
	if(pLstNew[ 0 ] / 10000000 != 9)
	  goto a5294;
	for(size_t i = 1; i <= nNumKEx; i++)
	  (*reinterpret_cast<std::istream *>(blkcom::pLFiles[ 4 ])) >> std::setw(8) >> pKExtra[ i - 1 ];
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " Supplemental offsets." << std::string(9, ' ') << "1";
	for(size_t i = 1; i <= nNumKEx; i++)
	  (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::setw(8) << pKExtra[ i - 1 ];
	pLstNew[ 0 ] -= 90000000;

      a5294:
	if(pLstNew[ 10 ] / 10000000 != 9)
	  goto a5297;
	n4 = pLstNew[ 10 ] - 90000000;
	for(size_t j = 1; j <= nNumLst; j++)
	  pLstNew[ j - 1 ] = pLstDef[ j - 1 ] * n4;

      a5297:
	if(pLstNew[ 0 ] > 0)
	  pLstNew[ 0 ] += 2;
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " " << std::string(111, '-') << std::endl;
	for(size_t i = 1; i < nNumLst; i++) {
	  n1 = i;
	  if(pLstNew[ i - 1 ] >= 1000000)
	    goto a9000;
	  if(pLstNew[ i - 1 ] <= 0)
	    pLstNew[ i - 1 ] = pLstDef[ i - 1 ];
	}
	if(pLstNew[ 18 ] <= 23)
	  pLstNew[ 18 ] = 23;
	if(pLstNew[ 25 ] <= 10)
	  pLstNew[ 25 ] = 10;
	n1 = pLstNew[ 15 ] / 2;
	if((2 * n1) != pLstNew[ 15 ])
	  ++pLstNew[ 15 ];
	n1 = pLstNew[ 26 ] / 2;
	if(2 * n1 != pLstNew[ 26 ])
	  ++pLstNew[ 26 ];
	pLstNew[ 50 ] = 6 * pLstNew[ 12 ];
	pLstNew[ 51 ] = pLstNew[ 50 ] + 1;
	pLstNew[ 52 ] = pLstNew[ 8 ] + 3 * pLstNew[ 16 ];
	pLstNew[ 53 ] = 6 * pLstNew[ 1 ];
	pLstNew[ 54 ] = pLstNew[ 8 ] + pLstNew[ 16 ];
	pLstNew[ 55 ] = pLstNew[ 1 ] + pLstNew[ 26 ] / 2;
	pLstNew[ 56 ] = pLstNew[ 0 ] * pLstNew[ 23 ];
	pLstNew[ 57 ] = 4 * pLstNew[ 11 ];
	pLstNew[ 58 ] = 2 * pLstNew[ 25 ];
	pLstNew[ 59 ] = 3 * pLstNew[ 5 ];
	pLstNew[ 60 ] = 1;
	pLstNew[ 61 ] = 2 * pLstNew[ 17 ];
	pLstNew[ 62 ] = 3 * pLstNew[ 5 ];
	pLstNew[ 63 ] = 4 * pLstNew[ 5 ];
	pLstNew[ 64 ] = 101 * pLstNew[ 16 ];
	pLstNew[ 65 ] = 24 * pLstNew[ 16 ];
	pLstNew[ 66 ] = 12 * pLstNew[ 15 ];
	pLstNew[ 67 ] = 6 * pLstNew[ 15 ];
	pLstNew[ 68 ] = 30 * pLstNew[ 16 ];
	pLstNew[ 69 ] = 5 * pLstNew[ 10 ] + 2;
	pLstNew[ 70 ] = 2 * pLstNew[ 20 ];
	pLstNew[ 71 ] = pLstNew[ 7 ] + pLstNew[ 27 ];
	pLstNew[ 72 ] = pLstNew[ 21 ] + pLstNew[ 20 ];
	nMTot = 0;
	for(size_t i = 1; i <= 126; i++) {
	  n9 = pVariables[ i - 1 ].m_nNCB;
	  if((n9 == 0) || (n9 == 98))
	    goto a4301;
	  n37 = 3;
	  sBus1[ 0 ] = pCBlock[ i - 1 ];
	  sBus2 = sBus1[ 0 ];
	  for(j = 1; j <= 6; j++)
	    if(sBus2[ 0 ] == (char) (j - 1))
	      n37 = 4;
	  if(pJBLTyp[ i - 1 ] != 0)
	    n37 = pVariables[ i - 1 ].m_nJBLType;
	  nMTot += pMulVar[ n37 - 1 ] * pLstNew[ n9 - 1 ];

	a4301:
	  ;
	}
	bReturnValue = true;

      a9000:
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::endl << std::endl << " ";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " " << std::string(131, '-') << std::endl;
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " ";
	for(int i = 1; i <= 22; i++)
	  (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ]));
	for(int i = 1; i << 22; i++)
	  (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::string("      Error");
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::endl;
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " " << std::string(131, '-') << std::endl;
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::endl << "     " << "The user is in trouble,";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " unless he has made a data-punching error.";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "    Variable-dimensioning of the EMTP has\n";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "     " << "broken down within the separate variable";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "-dimensioning program  'vardim' .    In";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " particular, one or more of the\n";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "     " << "user-inputted list sizes must be";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " rejected as being illegally large.    User-";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "supplied limits (or default limits,";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "     " << "for any non-positive data";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " fields) are as follows ....\n ";
	for(size_t i = 1; i < nNumLst; i++)
	  (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::setw(10) << pLstNew[ i - 1 ];
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::endl;
	if(blkcom::pLStat -> m_nTLabl > 0)
	  goto a9061;
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "     " << "Specifically, the user-";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "supplied value which was read for list";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " number " << n1 << "  exceeds  999999 ,\n";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "     " << "which is unreal.   A value of " << pLstNew[ n1 - 1 ];
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "    was read from the user's data card";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " for this list.\n";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " " << std::string(131, '-') << std::endl;
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " ";
	for(int i = 1; i <= 22; i++)
	  (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::string("      Error");
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::endl;
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " " << std::string(131, '-') << std::endl;
	goto a9900;

      a9061:
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "     " << "Specifically the user-supplied";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " dimensions have collectively produced a";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " total labeled-common allocation\n";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "     " << "of " << blkcom::pLStat -> m_nTLabl << "  words, which is unreal.";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "    A limit of 9999999 has arbitrarily";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " been imposed by the better judgment";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "     " << "of the program.   A machine this";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " big (with this much real central memory)";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " is not known to be in existence anywhere\n";
	(*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "     in the world.\n";

      a9900:
	bReturnValue = true;
      }
    }
    catch(std::exception &e) {
      std::cerr << e.what() << std::endl;
    }
    return bReturnValue;
  }

}

// end of file vardim.cpp