//-*- mode: c++; indent-tabs-mode: t; coding: utf-8; show-trailing-whitespace: t -*- // file newmods.cpp #include "newmods.hpp" // namespace emtp { tVariable pVariables[] = { { "x", "c0b001", 3, JBLTYPE_DOUBLE }, { "ykm", "c0b002", 5, JBLTYPE_DOUBLE }, { "km", "c0b003", 5, JBLTYPE_DOUBLE }, { "xk", "c0b004", 72, JBLTYPE_DOUBLE }, { "xm", "c0b005", 72, JBLTYPE_DOUBLE }, { "weight", "c0b006", 14, JBLTYPE_DOUBLE }, { "iwtent", "c0b007", 52, JBLTYPE_DOUBLE }, { "con1", "c0b008", 51, JBLTYPE_DOUBLE }, { "iskip", "c0b009", 13, JBLTYPE_DOUBLE }, { "zinf", "c0b010", 13, JBLTYPE_DOUBLE }, { "eta", "c0b011", 13, JBLTYPE_DOUBLE }, // To do. { "itbtb3", "c44b25", 72, JBLTYPE_COMPLEX_DOUBLE }, { "tbtext", "c44b26", 73, JBLTYPE_COMPLEX_DOUBLE }, { "karray", "c45b01", 9, JBLTYPE_DOUBLE }, { "karray", "c47b01", 9, JBLTYPE_DOUBLE } }; // bool vardim(const std::string &sFileName, std::vector &sListNew) { long int i; long int j; long int n4, n9, n37; bool bReturnValue = false; long int n1; long int nMTot; long int pKExtra[ NUMKEX ]; long int pDefaultSizes[ NUMLST ] = { 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 }; std::fstream sSizesFile; std::vector sKExtra(NUMKEX); std::vector sDefaultSizes(&pDefaultSizes[ 0 ], &pDefaultSizes[ NUMLST ]); // if(blkcom::nIprsUp >= 1) (*reinterpret_cast (blkcom::pLFiles[ 5 ])) << " Begin of vardim." << std::endl; sListNew.resize(99); sSizesFile.open(sFileName.c_str(), std::ios::in); if(sSizesFile.good()) { for(i = 1; i <= NUMLST; i++) sSizesFile >> std::setw(8) >> sListNew[ i - 1 ]; if((sListNew[ 0 ] / 10e6) == 9) { for(i = 1; i <= NUMKEX; i++) sSizesFile >> sKExtra[ i - 1 ]; sListNew[ 0 ] -= 90e6; } sSizesFile.close(); } else { (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << " Using default data sizes." << std::endl; for(i = 1; i <= NUMLST; i++) sListNew[ i - 1 ] = sDefaultSizes[ i - 1 ]; } if(blkcom::nIprsUp >= 1) { (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << std::endl; (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << " Pseudo-listing of data cards"; (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << " which have been read by the variable"; (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << "-dimensioning program 'vardim' . Only" << std::endl; (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << " if all data fields are punched with"; (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << " 'clean' i8 integer information will"; (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << " this be a true listing. Data cards" << std::endl; (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << " are in fact read in and then printed out"; (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << " using integer variables and 10i8"; (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << " format." << std::endl; (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << " " << std::string(111, '-') << std::endl; (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << std::string(31, ' ') << "0"; for(i = 1; i <= 8; i++) (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << std::string(9, ' ') << std::setw(1) << i; (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << std::endl << std::string(31, ' ') << "0"; for(i = 1; i <= 8; i++) (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << std::string(9, ' ') << "0"; (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << std::endl << std::string(31, ' ') << std::string(81, '-') << std::endl; for(j = 0; j < 3; j++) { switch(j) { case 0: (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << " 1st card (lists 1-10)." << std::string(7, ' ') << "|"; break; case 1: (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << " 2nd card (lists 11-20)." << std::string(7, ' ') << "|"; break; case 2: (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << " 3rd card (lists 21-30)." << std::string(7, ' ') << "|"; break; } for(i = 0; i < 8; i++) if((i + 8 * j) < NUMLST) (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << std::setw(10) << std::setfill(' ') << sListNew[ i + 8 * j ]; (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << std::endl; } } if((sListNew[ 0 ] / 10e6) != 9) goto a5294; if(blkcom::nIprsUp >= 1) { (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << " Supplemental offsets." << std::string(9, ' ') << "|"; for (i = 1; i <= NUMKEX; i++) (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << pKExtra[ i - 1 ]; (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << std::endl; } sListNew[ 0 ] -= 90e6; a5294: if((sListNew[ 10 ] / 10e6) == 9) { n4 = sListNew[ 10 ] - 90e6; for(j = 1; j <= NUMLST; j++) // 5296 sListNew[ j - 1 ] = pDefaultSizes[ j - 1 ] * n4; // end 5296 } if(sListNew[ 0 ] > 0) sListNew[ 0 ] += 2; for(i = 1; i <= NUMLST; i++) { n1 = i; if(sListNew[ i - 1 ] >= 1e6) return false; if(sListNew[ i - 1 ] <= 0) sListNew[ i - 1 ] = pDefaultSizes[ i - 1 ]; } if(sListNew[ 18 ] <= 23) sListNew[ 18 ] = 23; if(sListNew[ 25 ] <= 10) sListNew[ 25 ] = 10; n1 = sListNew[ 15 ] / 2; if(2 * n1 != sListNew[ 15 ]) sListNew[ 15 ] += 1; n1 = sListNew[ 26 ] / 2; if(2 * n1 != sListNew[ 26 ]) sListNew[ 26 ] += 1; // list number 51 is a dependent list, always twice // the size of list number 13. // This is for frequency-dependence arrays // 'con1' , 'con2' , and 'con3' . sListNew[ 50 ] = 6 * sListNew[ 12 ]; // list number 52 is a dependent list, always twice // the size of list number 1, plus one. // This is for frequency-dependence array 'iwtent' . sListNew[ 51 ] += 1; // list number 7 also serves for storage as part of // list number 3. Hence list 7 must not be shorter. // if (lstnew(3) .gt. lstnew(7)) // 1 lstnew(7) = lstnew(3) // List number 53 is for terminal pairs // associated with compensation elements. sListNew[ 52 ] = sListNew[ 8 ] + 3 * sListNew[ 16 ]; // cable adds 5 list-2 extensions to 'namebr' sListNew[ 53 ] = 6 * sListNew[ 1 ]; // list 55 has one entry for each subnetwork. sListNew[ 54 ] = sListNew[ 8 ] + sListNew[ 16 ]; // list 56 is for vladimir's "cikfd" and "rmfd" // arrays for freq-depend. generator equivalent sListNew[ 55 ] = sListNew[ 1 ] * sListNew[ 26 ] / 2; // list 57 maps #phases into znonl size. sListNew[ 56 ] = sListNew[ 0 ] * sListNew[ 23 ]; // list 58 is for extrema vector "xmax" . sListNew[ 57 ] = 4 * sListNew[ 11 ]; // list 59 is extended working vector "volti" sListNew[ 58 ] = 2 * sListNew[ 25 ]; // list 60 provides double-length "kmswit" as // replacement for earlier "klow" and "khigh" sListNew[ 59 ] = 3 * sListNew[ 5 ]; // list 61 is for ontario hydro freq-dep source sListNew[ 60 ] = 1; // list 62 is for power/energy ("koutvp" which // now includes former, separate "koutie") sListNew[ 61 ] = 2 * sListNew[ 17 ]; sListNew[ 62 ] = 3 * sListNew[ 5 ]; sListNew[ 63 ] = 4 * sListNew[ 5 ]; // list 65 is for type-59 s.m. electrical data: sListNew[ 64 ] = 101 * sListNew[ 16 ]; // list 66 is for type-59 s.m. electrical variables: sListNew[ 65 ] = 24 * sListNew[ 16 ]; // list 67 is for type-59 s.m. mechanical data: sListNew[ 66 ] = 12 * sListNew[ 15 ]; // list 68 is for type-59 s.m. mechanical variables: sListNew[ 67 ] = 6 * sListNew[ 15 ]; // list 69 is for type-59 s.m. pointers: sListNew[ 68 ] = 30 * sListNew[ 16 ]; // list 70 is for type-59 s.m. output pointers: sListNew[ 69 ] = 5 * sListNew[ 10 ] + 2; // list 71 is to extend list 21 for Ljg (18 aug 1987): sListNew[ 70 ] = 2 * sListNew[ 20 ]; sListNew[ 71 ] = sListNew[ 7 ] + sListNew[ 27 ]; // list 73 is to extend list 22 for Ljg (10 mar 1988): sListNew[ 72 ] = sListNew[ 21 ] + sListNew[ 20 ]; nMTot = 0; std::vector sVariables(pVariables, pVariables + sizeof(pVariables) / sizeof(tVariable)); std::vector::iterator pI; for(pI = sVariables.begin(); pI != sVariables.end(); pI++) { n9 = pI -> m_nSize; if((n9 != 0) && (n9 != 98)) { n37 = 3; if(pI -> m_sType != 0) n37 = (long int) pI -> m_sType; nMTot += (size_t) (n37 * sListNew[ n9 - 1 ]); } } sListNew[ 28 ] = nMTot; labcom::sX.resize(sListNew[ sVariables[ 0 ].m_nSize ]); labcom::sYKM.resize(sListNew[ sVariables[ 1 ].m_nSize ]); labcom::sKM.resize(sListNew[ sVariables[ 2 ].m_nSize ]); labcom::sXK.resize(sListNew[ sVariables[ 3 ].m_nSize ]); labcom::sXM.resize(sListNew[ sVariables[ 4 ].m_nSize ]); labcom::sWeight.resize(sListNew[ sVariables[ 5 ].m_nSize ]); labcom::sIWTent.resize(sListNew[ sVariables[ 6 ].m_nSize ]); labcom::sCOn1.resize(sListNew[ sVariables[ 7 ].m_nSize ]); labcom::sISkip.resize(sListNew[ sVariables[ 8 ].m_nSize ]); labcom::sZInf.resize(sListNew[ sVariables[ 9 ].m_nSize ]); labcom::sEta.resize(sListNew[ sVariables[ 10 ].m_nSize ]); labcom::sNHist.resize(sListNew[ sVariables[ 11 ].m_nSize ]); labcom::sStailM.resize(sListNew[ sVariables[ 12 ].m_nSize ]); labcom::sStailK.resize(sListNew[ sVariables[ 13 ].m_nSize ]); labcom::sXMax.resize(sListNew[ sVariables[ 14 ].m_nSize ]); labcom::sKOutVP.resize(sListNew[ sVariables[ 15 ].m_nSize ]); labcom::sBNRG.resize(sListNew[ sVariables[ 16 ].m_nSize ]); labcom::sSCOnST.resize(sListNew[ sVariables[ 17 ].m_nSize ]); labcom::sCNVHst.resize(sListNew[ sVariables[ 18 ].m_nSize ]); labcom::sHSFD.resize(sListNew[ sVariables[ 19 ].m_nSize ]); labcom::sQFD.resize(sListNew[ sVariables[ 20 ].m_nSize ]); labcom::sSemAux.resize(sListNew[ sVariables[ 21 ].m_nSize ]); labcom::sIBSOut.resize(sListNew[ sVariables[ 22 ].m_nSize ]); labcom::sBValue.resize(sListNew[ sVariables[ 23 ].m_nSize ]); labcom::sSPTACS.resize(sListNew[ sVariables[ 24 ].m_nSize ]); labcom::sKSWTyp.resize(sListNew[ sVariables[ 25 ].m_nSize ]); labcom::sModSwt.resize(sListNew[ sVariables[ 26 ].m_nSize ]); labcom::sKBegSw.resize(sListNew[ sVariables[ 27 ].m_nSize ]); labcom::sLastSw.resize(sListNew[ sVariables[ 28 ].m_nSize ]); labcom::sKENTNB.resize(sListNew[ sVariables[ 29 ].m_nSize ]); labcom::sNBHDSw.resize(sListNew[ sVariables[ 30 ].m_nSize ]); labcom::sTOpen.resize(sListNew[ sVariables[ 31 ].m_nSize ]); labcom::sCrit.resize(sListNew[ sVariables[ 32 ].m_nSize ]); labcom::sKDEPSw.resize(sListNew[ sVariables[ 33 ].m_nSize ]); labcom::sTDNS.resize(sListNew[ sVariables[ 34 ].m_nSize ]); labcom::sISourc.resize(sListNew[ sVariables[ 35 ].m_nSize ]); labcom::sEnergy.resize(sListNew[ sVariables[ 36 ].m_nSize ]); labcom::sIARDUB.resize(sListNew[ sVariables[ 37 ].m_nSize ]); labcom::sARDUBE.resize(sListNew[ sVariables[ 38 ].m_nSize ]); labcom::sNOnLAD.resize(sListNew[ sVariables[ 39 ].m_nSize ]); labcom::sNOnLE.resize(sListNew[ sVariables[ 40 ].m_nSize ]); labcom::sVOnL.resize(sListNew[ sVariables[ 41 ].m_nSize ]); labcom::sCurr.resize(sListNew[ sVariables[ 42 ].m_nSize ]); labcom::sANOnL.resize(sListNew[ sVariables[ 43 ].m_nSize ]); labcom::sVecNL1.resize(sListNew[ sVariables[ 44 ].m_nSize ]); labcom::sVecNL2.resize(sListNew[ sVariables[ 45 ].m_nSize ]); labcom::sNameNL.resize(sListNew[ sVariables[ 46 ].m_nSize ]); labcom::sVZero.resize(sListNew[ sVariables[ 47 ].m_nSize ]); bReturnValue = true; return bReturnValue; } bool dimens(std::vector &sLSizes, \ const int &nChain, \ std::string &sBus1, \ std::string &sBus2) { long int n7; bool bReturnValue = false; // if(sLSizes.size() > 0) { if(blkcom::nChain < 29) { n7 = 29; sLSizes.push_back(0); sBus1 = "91205"; sBus2 = "123093"; bReturnValue = true; } else if(blkcom::nChain <= 29) { sLSizes[ 0 ] = 0; sLSizes[ 1 ] = 1992869; sLSizes[ 2 ] = 23; sLSizes[ 3 ] = 30000; sLSizes[ 4 ] = 1; sLSizes[ 5 ] = 3002; sLSizes[ 6 ] = 9; sLSizes[ 7 ] = 300; bReturnValue = true; } else if(blkcom::nChain <= 39) { // To do. } else if(blkcom::nChain <= 10) { // To do. } else if(blkcom::nChain <= 44) { // To do. } else if(blkcom::nChain <= 45) { // To do. } else if(blkcom::nChain <= 47) { // To do. } else { sLSizes[ 0 ] = (size_t) &sBus1 - (size_t) &sBus2; } } if(blkcom::nIprsUp >= 1) (*reinterpret_cast(blkcom::pLFiles[ 5 ])) << " Exiting vardim." << std::endl; return bReturnValue; } bool cleanup(void) { bool bReturnValue = false; // if (labcom::pSpace) { delete [] labcom::pSpace; labcom::pSpace = nullptr; bReturnValue = true; } return bReturnValue; } } // end of file newmods.cpp