summaryrefslogtreecommitdiffstats
path: root/sources/over51.cpp
blob: 601a25b9d20a1d093bafde9dd0bbace13b18e7b8 (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
//-*- mode: c++; indent-tabs-mode: nil; coding: utf-8; show-trailing-whitespace: t -*-

// file over51.cpp

#include "over51.hpp"

namespace over51 {

  // subroutine over51.

  void over51(void)
  {
    double nVMin;
    double nVMax;
    //
    if (blkcom::nIprsUp >= 1)
      (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " Begin \"over51\".  kill = " << blkcom::nKill << std::endl << std::flush;
    date_time::runtym(nVMin, nVMax);
    blkcom::sFLStat[ 8 ] = nVMin - blkcom::sFLStat[ 8 ];
    blkcom::sFLStat[ 9 ] = nVMax - blkcom::sFLStat[ 9 ];
    if (blkcom::nKill == 0)
      goto a4521;
    subr51 ();
    goto a4536;

  a4521:
    blkcom::nLastOV = blkcom::nChain;
    blkcom::nChain = 55;

  a4536:
    if (blkcom::nIprsUp >= 1)
      (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " Exit module \"over51\"." << std::endl << std::flush;
  }

  // subroutine subr51.

  void subr51 (void)
  {
    //
    // Note. --- As the structure of the EMTP error overlays change,
    //           the following assignments may have to be altered ...
    //           nfrfld  ---- total number of error overlays
    //           kpen(j) ---- storage for the highest kill-code
    //                        number handled by error overlay
    //                        number  50+j ,   for all but the
    //                        last error overlay.
    int i;
    int j;
    int nKSat;
    //
    double nD1;
    double nVMin;
    double nVMax;
    //
    size_t pKPen[ 5 ] = { 50, 90, 150, 200 };
    //
    try {
      blkcom::nNFrFld = 5;
      if(blkcom::nIprsUp >= 1)
        (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " Begin \"subr51\".  kill = " << blkcom::nKill << std::endl << std::flush;
      if ((blkcom::nKill == 99) && blkcom::sLStat[ 18 ] == 11111)
        emtp::stoptp ();
      pKPen[ blkcom::nNFrFld ] = std::numeric_limits<size_t>::max ();
      date_time::runtym (nVMin, nVMax);
      blkcom::sFLStat[ 8 ] = nVMin - blkcom::sFLStat[ 8 ];
      if (blkcom::pIpnTV[ 0 ] != -8888)
        goto a1643;
      if (blkcom::nKill == 38)
        blkcom::sFLStat[ 12 ] = 1.0;
      if (blkcom::nKill == 41)
        blkcom::sLStat[ 10 ] = 1;
      if (blkcom::nKill == 43)
        blkcom::sFLStat[ 12 ] = 1.0;
      if ((blkcom::nKill - 1) != blkcom::pIpnTV[ 2 ])
        goto a1643;
      blkcom::pIpnTV[ 2 ] = blkcom::nKill;
      goto a1649;

    a1643:
      if (blkcom::nLastOV >= blkcom::nChain)
        goto a1649;
      blkcom::nNOutPR = 0;
      emtp::interp ();
      (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " " << std::endl << std::flush;
      (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::string (132, '-') << std::endl << std::flush;
      for (i = 1; i <= 2; i++) {
        for (j = 1; j <= 22; j++)
          (*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::flush;
      (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::string (132, '-') << std::endl << std::flush;
      (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << "0You lose, fella.   The EMTP logic has detected an error condition, and is going to terminate your run.  The following\n";
      (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " printout message summarizes the data difficulty leading to this program decision.  By studying this message, the problem\n";
      (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " data,  and the rules delineated by the  840-page EMTP rule book,  it is hoped that the user can rectify the problem.\n";
      (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " If still in doubt after some study, come see program maintenance for assistance.\n" << std::flush;
      blkcom::sTexCol = blkcom::sABuff.str ().substr (0, 80);
      (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " Where an otherwise-unidentified card is referred to, or is called the 'last' card, this means the most-recently-\n";
      (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " read card of the input data deck.   The 80-column card image in question is the last one printed out before this\n";
      (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " termination message.   A copy follows.... " << blkcom::sTexCol << std::endl << std::flush;
      (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << std::string (14, ' ') << "kill code number" << std::string (16, ' ') << "overlay number " << std::string (10, ' ') << "nearby statement no.\n" << blkcom::nKill << " " << blkcom::sLStat[ 17 ] << " " << blkcom::sLStat[ 18 ] << std::endl << std::flush;

    a1649:
      for(j = 1; j <= blkcom::nNFrFld; j++) {
        if(blkcom::nKill > pKPen[ j - 1 ])
          goto a1658;
        if(j == 1)
          goto a1684;
        blkcom::nLastOV = blkcom::nChain;
        blkcom::nChain = 50 + j;
        if(blkcom::nIprsUp >= 1)
          (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " Error overlay found.  kill, j, kpen(j), nchain = " << blkcom::nKill << " " << j << " " << pKPen[ j - 1 ] << " " << blkcom::nChain << std::endl << std::flush;
        goto a9000;
      }

    a1658:
      ;

    a1684:
      ;

      switch (blkcom::nKill) {
      case 1:
        throw emtp::storage_exceeded_error();
        break;

      case 60:
        throw emtp::dummy_function_called_error();
        break;
      }
    }
    catch (const std::runtime_error &e) {
      (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 0 ])) << e.what () << std::endl << std::flush;
    }

    blkcom::nLastOV = blkcom::nChain;
    blkcom::nChain = blkcom::nNFrFld + 50;
    if (blkcom::nIprsUp >= 1)
      (*reinterpret_cast<std::ostream *>(blkcom::pLFiles[ 5 ])) << " Exit \"subr51\".  nchain, kill = " << blkcom::nChain << " " << blkcom::nKill << std::endl << std::flush;

  a9000:
    return;
  }

}

// end of file over51.f90