MCPcopy Create free account
hub / github.com/SeisSol/SeisSol / parseSRF

Function parseSRF

preprocessing/science/rconv/src/SRF.cpp:86–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86std::vector<SRFPointSource> parseSRF(char const* filename)
87{
88 std::vector<SRFPointSource> srf;
89
90 std::ifstream in(filename, std::ifstream::in);
91
92 double version;
93 in >> version;
94 void (*parsePoints)(std::ifstream&, SRFPointSource&);
95
96 if (version == 2.0) {
97 parsePoints = parsePOINTS_2_0;
98 } else if (version == 1.0) {
99 parsePoints = parsePOINTS_1_0;
100 } else {
101 std::cerr << "Unsupported SRF version " << version << " in " << filename << "." << std::endl;
102 return srf;
103 }
104
105 while (in.good()) {
106 std::string block;
107 unsigned num;
108 in >> block;
109 if (block.compare("POINTS") == 0) {
110 in >> num;
111 unsigned numSources = srf.size();
112 unsigned newSize = numSources + num;
113 srf.resize(newSize);
114 for (unsigned point = numSources; point < newSize; ++point) {
115 parsePoints(in, srf[point]);
116 }
117 } else if (block.compare("PLANE") == 0) {
118 in >> num;
119 // skip plane segments
120 for (unsigned l = 0; l < 2*num && in.good(); ++ l) {
121 std::string line;
122 getline(in, line);
123 }
124 } else if (block.compare(0, 1, "#") == 0) { // ignore comments
125 std::string line;
126 getline(in, line); // skip line
127 } else if (block.find_first_not_of(" \t\n\v\f\r") == std::string::npos) { // ignore whitespace line
128 continue;
129 } else {
130 std::cerr << "Unsupported block type " << block << " in " << filename << "." << std::endl;
131 return srf;
132 }
133 }
134
135 in.close();
136
137 // Erasing sources with zero samples
138 unsigned numRemoved = 0;
139 std::vector<SRFPointSource>::iterator source = srf.begin();
140 while (source != srf.end()) {
141 if (source->slipRate[0].size() != 0 || source->slipRate[1].size() != 0 || source->slipRate[2].size() != 0) {
142 ++source;
143 } else {

Callers 1

mainFunction · 0.85

Calls 6

compareMethod · 0.80
resizeMethod · 0.80
sizeMethod · 0.45
closeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected