f71stream.i.hh 3.72 KB
Newer Older
LEFEBVREJP email's avatar
LEFEBVREJP email committed
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

#ifndef RADIX_RADIXIO_F71STREAM_I_HH_
#define RADIX_RADIXIO_F71STREAM_I_HH_

#include "radixio/f71stream.hh"

#include "radixbug/bug.hh"
#include "radixcore/stringfunctions.hh"
#include "radixio/eafstream.hh"

namespace radix
{
template <typename f71case_type>
bool F71Stream::load_next(f71case_type& inventory)
{
  // check if the file is open
  if (!mStream.is_open())
  {
    mStream.open(mFile.c_str(), std::ios::binary);
  }
  if (!mStream.is_open())
  {
    throw std::runtime_error("Failed to open file: '" + mFile + "'");
  }
  if (!mStream.good()) return false;

  // header
  mStream.readHeader();
  // read record content
  int num_nuclides = mStream.readInt();                // ITXX
  mStream.readInt();                                   // ILITE
  mStream.readInt();                                   // IACT   =
  mStream.readInt();                                   // IFP    =
  mStream.readInt();                                   // NRFLAG =
  mStream.readInt();                                   // MSUB1  =
  mStream.readInt();                                   // NSTEPO =
  mStream.readInt();                                   // KASEPO =
  mStream.readInt();                                   // JOBPOS =
  mStream.readInt();                                   // NOCS   =
  mStream.readInt();                                   // NOBLND =
  mStream.readInt();                                   // NDSET  =
  mStream.readInt();                                   // NTYPE  =
  mStream.readInt();                                   // NGRP   =
  mStream.readInt();                                   // NELEM  =
  mStream.readInt();                                   // NVERT  =
  mStream.readInt();                                   // NG     =
  mStream.readInt();                                   // MMN    =
  mStream.readInt();                                   // MOUT   =
  mStream.readInt();                                   // INDEX  =
  mStream.readInt();                                   // MSTAR  =
  mStream.readInt();                                   // NUNIT  =
  mStream.readInt();                                   // KBLEND =
  int num_light_element_groups   = mStream.readInt();  // NENLE  =
  int num_actinide_groups        = mStream.readInt();  // NENAC  =
  int num_fission_product_groups = mStream.readInt();  // NENFP  =
  mStream.readInt();                                   // L1     =
  mStream.readInt();                                   // L2     =
  mStream.readInt();                                   // L3     =
  mStream.readInt();                                   // L4     =

  mStream.readFloat();    // TMO    =
  mStream.readFloat();    // FRACPW =
  mStream.readFloat();    // TCONST =
  mStream.readString(4);  // TUNIT  =
  mStream.readFloat();    // TWRITE =
  mStream.readFloat();    // PWRITE =
  mStream.readFloat();    // FWRITE =

  // read end of record
  mStream.readFooter();

  // read record 2: the nuclides and their amounts
  // read header
  mStream.readHeader();
  std::vector<int> iza_list((size_t(num_nuclides)));
  mStream >> iza_list;
  std::vector<float> abundances((size_t(num_nuclides)));
  mStream >> abundances;
  std::string title = trim_string(mStream.readString(80));
  std::string basis = trim_string(mStream.readString(40));
  std::vector<float> gamma_le_bounds((size_t(num_light_element_groups)));
  mStream >> gamma_le_bounds;
  std::vector<float> gamma_ae_bounds((size_t(num_actinide_groups)));
  mStream >> gamma_ae_bounds;
  std::vector<float> gamma_fpe_bounds((size_t(num_fission_product_groups)));
  mStream >> gamma_fpe_bounds;

  mStream.peek();  // peek into the next bit. This ensures EOF is seen in good()
                   // call
}
}  // namespace radix

#endif /** RADIX_RADIXIO_F71STREAM_I_HH_ */