1 : |
agomez |
1 |
#include "ecosystem.h" |
2 : |
|
|
#include "keeper.h" |
3 : |
|
|
#include "stockstdprinter.h" |
4 : |
|
|
#include "stockprinter.h" |
5 : |
|
|
#include "predatorprinter.h" |
6 : |
|
|
#include "predatorpreyprinter.h" |
7 : |
|
|
#include "predatoroverprinter.h" |
8 : |
|
|
#include "preyoverprinter.h" |
9 : |
|
|
#include "stockpreyfullprinter.h" |
10 : |
|
|
#include "stockpreyprinter.h" |
11 : |
|
|
#include "stockfullprinter.h" |
12 : |
|
|
#include "likelihoodprinter.h" |
13 : |
|
|
#include "summaryprinter.h" |
14 : |
|
|
#include "surveyindices.h" |
15 : |
|
|
#include "understocking.h" |
16 : |
|
|
#include "catchdistribution.h" |
17 : |
|
|
#include "stockdistribution.h" |
18 : |
|
|
#include "catchstatistics.h" |
19 : |
|
|
#include "recstatistics.h" |
20 : |
|
|
#include "stomachcontent.h" |
21 : |
|
|
#include "recapture.h" |
22 : |
|
|
#include "migrationpenalty.h" |
23 : |
|
|
#include "catchinkilos.h" |
24 : |
|
|
#include "boundlikelihood.h" |
25 : |
|
|
#include "surveydistribution.h" |
26 : |
|
|
#include "migrationproportion.h" |
27 : |
|
|
#include "readword.h" |
28 : |
|
|
#include "gadget.h" |
29 : |
|
|
#include "global.h" |
30 : |
|
|
|
31 : |
|
|
//
|
32 : |
|
|
// A function to read fleet information
|
33 : |
|
|
//
|
34 : |
|
|
void Ecosystem::readFleet(CommentStream& infile) {
|
35 : |
|
|
char text[MaxStrLength];
|
36 : |
|
|
char value[MaxStrLength];
|
37 : |
|
|
strncpy(text, "", MaxStrLength);
|
38 : |
|
|
strncpy(value, "", MaxStrLength);
|
39 : |
|
|
|
40 : |
|
|
while (!infile.eof()) {
|
41 : |
|
|
infile >> text >> ws;
|
42 : |
|
|
if ((strcasecmp(text, "[fleetcomponent]") != 0) && (strcasecmp(text, "[component]") != 0))
|
43 : |
|
|
handle.logFileUnexpected(LOGFAIL, "[component]", text);
|
44 : |
|
|
|
45 : |
|
|
infile >> text >> value;
|
46 : |
|
|
if (strcasecmp(text, "totalfleet") == 0)
|
47 : |
|
|
fleetvec.resize(new Fleet(infile, value, Area, TimeInfo, keeper, TOTALFLEET));
|
48 : |
|
|
else if (strcasecmp(text, "linearfleet") == 0)
|
49 : |
|
|
fleetvec.resize(new Fleet(infile, value, Area, TimeInfo, keeper, LINEARFLEET));
|
50 : |
|
|
else if (strcasecmp(text, "numberfleet") == 0)
|
51 : |
|
|
fleetvec.resize(new Fleet(infile, value, Area, TimeInfo, keeper, NUMBERFLEET));
|
52 : |
|
|
else if (strcasecmp(text, "effortfleet") == 0)
|
53 : |
|
|
fleetvec.resize(new Fleet(infile, value, Area, TimeInfo, keeper, EFFORTFLEET));
|
54 : |
|
|
else if (strcasecmp(text, "quotafleet") == 0)
|
55 : |
|
|
fleetvec.resize(new Fleet(infile, value, Area, TimeInfo, keeper, QUOTAFLEET));
|
56 : |
|
|
else if (strcasecmp(text, "mortalityfleet") == 0)
|
57 : |
|
|
handle.logFileMessage(LOGFAIL, "\nThe mortalityfleet fleet type is no longer supported");
|
58 : |
|
|
else
|
59 : |
|
|
handle.logFileMessage(LOGFAIL, "unrecognised fleet class", text);
|
60 : |
|
|
|
61 : |
|
|
handle.logMessage(LOGMESSAGE, "Read fleet OK - created fleet", value);
|
62 : |
|
|
}
|
63 : |
|
|
}
|
64 : |
|
|
|
65 : |
|
|
//
|
66 : |
|
|
// A function to read tagging information
|
67 : |
|
|
//
|
68 : |
|
|
void Ecosystem::readTagging(CommentStream& infile) {
|
69 : |
|
|
char text[MaxStrLength];
|
70 : |
|
|
strncpy(text, "", MaxStrLength);
|
71 : |
|
|
|
72 : |
|
|
while (!infile.eof()) {
|
73 : |
|
|
infile >> text >> ws;
|
74 : |
|
|
if ((strcasecmp(text, "[tagcomponent]") != 0) && (strcasecmp(text, "[component]") != 0))
|
75 : |
|
|
handle.logFileUnexpected(LOGFAIL, "[component]", text);
|
76 : |
|
|
|
77 : |
|
|
readWordAndValue(infile, "tagid", text);
|
78 : |
|
|
tagvec.resize(new Tags(infile, text, Area, TimeInfo, keeper, stockvec));
|
79 : |
|
|
handle.logMessage(LOGMESSAGE, "Read tagging experiment OK - created tag", text);
|
80 : |
|
|
}
|
81 : |
|
|
}
|
82 : |
|
|
|
83 : |
|
|
//
|
84 : |
|
|
// A function to read otherfood information
|
85 : |
|
|
//
|
86 : |
|
|
void Ecosystem::readOtherFood(CommentStream& infile) {
|
87 : |
|
|
char text[MaxStrLength];
|
88 : |
|
|
strncpy(text, "", MaxStrLength);
|
89 : |
|
|
|
90 : |
|
|
while (!infile.eof()) {
|
91 : |
|
|
infile >> text >> ws;
|
92 : |
|
|
if ((strcasecmp(text, "[foodcomponent]") != 0) && (strcasecmp(text, "[component]") != 0))
|
93 : |
|
|
handle.logFileUnexpected(LOGFAIL, "[component]", text);
|
94 : |
|
|
|
95 : |
|
|
readWordAndValue(infile, "foodname", text);
|
96 : |
|
|
otherfoodvec.resize(new OtherFood(infile, text, Area, TimeInfo, keeper));
|
97 : |
|
|
handle.logMessage(LOGMESSAGE, "Read otherfood OK - created otherfood", text);
|
98 : |
|
|
}
|
99 : |
|
|
}
|
100 : |
|
|
|
101 : |
|
|
//
|
102 : |
|
|
// A function to read stock information
|
103 : |
|
|
// Note: there is only ever one stock in each file
|
104 : |
|
|
//
|
105 : |
|
|
void Ecosystem::readStock(CommentStream& infile) {
|
106 : |
|
|
char text[MaxStrLength];
|
107 : |
|
|
strncpy(text, "", MaxStrLength);
|
108 : |
|
|
|
109 : |
|
|
readWordAndValue(infile, "stockname", text);
|
110 : |
|
|
stockvec.resize(new Stock(infile, text, Area, TimeInfo, keeper));
|
111 : |
|
|
handle.logMessage(LOGMESSAGE, "Read stock OK - created stock", text);
|
112 : |
|
|
}
|
113 : |
|
|
|
114 : |
|
|
//
|
115 : |
|
|
// A function to read information on printing
|
116 : |
|
|
//
|
117 : |
|
|
void Ecosystem::readPrinters(CommentStream& infile) {
|
118 : |
|
|
char text[MaxStrLength];
|
119 : |
|
|
char type[MaxStrLength];
|
120 : |
|
|
strncpy(text, "", MaxStrLength);
|
121 : |
|
|
strncpy(type, "", MaxStrLength);
|
122 : |
|
|
|
123 : |
|
|
if (!infile.eof())
|
124 : |
|
|
infile >> text >> ws;
|
125 : |
|
|
|
126 : |
|
|
if (strcasecmp(text, "[component]") != 0)
|
127 : |
|
|
handle.logFileUnexpected(LOGFAIL, "[component]", text);
|
128 : |
|
|
|
129 : |
|
|
while (!infile.eof()) {
|
130 : |
|
|
readWordAndValue(infile, "type", type);
|
131 : |
|
|
|
132 : |
|
|
if (strcasecmp(type, "stockstdprinter") == 0)
|
133 : |
|
|
printvec.resize(new StockStdPrinter(infile, TimeInfo));
|
134 : |
|
|
else if (strcasecmp(type, "stockfullprinter") == 0)
|
135 : |
|
|
printvec.resize(new StockFullPrinter(infile, TimeInfo));
|
136 : |
|
|
else if (strcasecmp(type, "stockprinter") == 0)
|
137 : |
|
|
printvec.resize(new StockPrinter(infile, TimeInfo));
|
138 : |
|
|
else if (strcasecmp(type, "predatorprinter") == 0)
|
139 : |
|
|
printvec.resize(new PredatorPrinter(infile, TimeInfo));
|
140 : |
|
|
else if (strcasecmp(type, "predatoroverprinter") == 0)
|
141 : |
|
|
printvec.resize(new PredatorOverPrinter(infile, TimeInfo));
|
142 : |
|
|
else if (strcasecmp(type, "preyoverprinter") == 0)
|
143 : |
|
|
printvec.resize(new PreyOverPrinter(infile, TimeInfo));
|
144 : |
|
|
else if (strcasecmp(type, "stockpreyprinter") == 0)
|
145 : |
|
|
printvec.resize(new StockPreyPrinter(infile, TimeInfo));
|
146 : |
|
|
else if (strcasecmp(type, "stockpreyfullprinter") == 0)
|
147 : |
|
|
printvec.resize(new StockPreyFullPrinter(infile, TimeInfo));
|
148 : |
|
|
else if (strcasecmp(type, "predatorpreyprinter") == 0)
|
149 : |
|
|
printvec.resize(new PredatorPreyPrinter(infile, TimeInfo));
|
150 : |
|
|
else if (strcasecmp(type, "likelihoodprinter") == 0)
|
151 : |
|
|
printvec.resize(new LikelihoodPrinter(infile, TimeInfo));
|
152 : |
|
|
else if (strcasecmp(type, "likelihoodsummaryprinter") == 0)
|
153 : |
|
|
printvec.resize(new SummaryPrinter(infile));
|
154 : |
|
|
|
155 : |
|
|
else if (strcasecmp(type, "formatedstockprinter") == 0)
|
156 : |
|
|
handle.logFileMessage(LOGFAIL, "\nThe formatedstockprinter printer class is no longer supported");
|
157 : |
|
|
else if (strcasecmp(type, "formatedchatprinter") == 0)
|
158 : |
|
|
handle.logFileMessage(LOGFAIL, "\nThe formatedchatprinter printer class is no longer supported");
|
159 : |
|
|
else if (strcasecmp(type, "formatedpreyprinter") == 0)
|
160 : |
|
|
handle.logFileMessage(LOGFAIL, "\nThe formatedpreyprinter printer class is no longer supported");
|
161 : |
|
|
else if (strcasecmp(type, "mortprinter") == 0)
|
162 : |
|
|
handle.logFileMessage(LOGFAIL, "\nThe mortprinter printer class is no longer supported");
|
163 : |
|
|
else if (strcasecmp(type, "biomassprinter") == 0)
|
164 : |
|
|
handle.logFileMessage(LOGFAIL, "\nThe biomassprinter printer class is no longer supported");
|
165 : |
|
|
else if (strcasecmp(type, "formatedcatchprinter") == 0)
|
166 : |
|
|
handle.logFileMessage(LOGFAIL, "\nThe formatedcatchprinter printer class is no longer supported");
|
167 : |
|
|
else if (strcasecmp(type, "predpreystdlengthprinter") == 0)
|
168 : |
|
|
handle.logFileMessage(LOGFAIL, "\nThe predpreystdlengthprinter printer class is no longer supported");
|
169 : |
|
|
else if (strcasecmp(type, "predpreystdageprinter") == 0)
|
170 : |
|
|
handle.logFileMessage(LOGFAIL, "\nThe predpreystdageprinter printer class is no longer supported");
|
171 : |
|
|
|
172 : |
|
|
else
|
173 : |
|
|
handle.logFileMessage(LOGFAIL, "unrecognised printer class", type);
|
174 : |
|
|
|
175 : |
|
|
handle.logMessage(LOGMESSAGE, "Read printer OK - created printer class", type);
|
176 : |
|
|
}
|
177 : |
|
|
}
|
178 : |
|
|
|
179 : |
|
|
//
|
180 : |
|
|
// A function to read likelihood information
|
181 : |
|
|
//
|
182 : |
|
|
void Ecosystem::readLikelihood(CommentStream& infile) {
|
183 : |
|
|
double weight = 0.0;
|
184 : |
|
|
char text[MaxStrLength];
|
185 : |
|
|
char type[MaxStrLength];
|
186 : |
|
|
char name[MaxStrLength];
|
187 : |
|
|
char datafilename[MaxStrLength];
|
188 : |
|
|
strncpy(text, "", MaxStrLength);
|
189 : |
|
|
strncpy(type, "", MaxStrLength);
|
190 : |
|
|
strncpy(name, "", MaxStrLength);
|
191 : |
|
|
strncpy(datafilename, "", MaxStrLength);
|
192 : |
|
|
|
193 : |
|
|
ifstream datafile;
|
194 : |
|
|
CommentStream subdata(datafile);
|
195 : |
|
|
|
196 : |
|
|
if (!infile.eof())
|
197 : |
|
|
infile >> text >> ws;
|
198 : |
|
|
|
199 : |
|
|
if (strcasecmp(text, "[component]") != 0)
|
200 : |
|
|
handle.logFileUnexpected(LOGFAIL, "[component]", text);
|
201 : |
|
|
|
202 : |
|
|
while (!infile.eof()) {
|
203 : |
|
|
readWordAndValue(infile, "name", name);
|
204 : |
|
|
readWordAndVariable(infile, "weight", weight);
|
205 : |
|
|
readWordAndValue(infile, "type", type);
|
206 : |
|
|
|
207 : |
|
|
if (strcasecmp(type, "penalty") == 0) {
|
208 : |
|
|
readWordAndValue(infile, "datafile", datafilename);
|
209 : |
|
|
datafile.open(datafilename, ios::in);
|
210 : |
|
|
handle.checkIfFailure(datafile, datafilename);
|
211 : |
|
|
handle.Open(datafilename);
|
212 : |
|
|
likevec.resize(new BoundLikelihood(subdata, Area, TimeInfo, keeper, weight, name));
|
213 : |
|
|
handle.Close();
|
214 : |
|
|
datafile.close();
|
215 : |
|
|
datafile.clear();
|
216 : |
|
|
|
217 : |
|
|
//prepare for next likelihood component
|
218 : |
|
|
infile >> ws;
|
219 : |
|
|
if (!infile.eof()) {
|
220 : |
|
|
infile >> text >> ws;
|
221 : |
|
|
if (strcasecmp(text, "[component]") != 0)
|
222 : |
|
|
handle.logFileUnexpected(LOGFAIL, "[component]", text);
|
223 : |
|
|
}
|
224 : |
|
|
|
225 : |
|
|
} else if (strcasecmp(type, "understocking") == 0) {
|
226 : |
|
|
likevec.resize(new UnderStocking(infile, Area, TimeInfo, weight, name));
|
227 : |
|
|
|
228 : |
|
|
} else if (strcasecmp(type, "catchstatistics") == 0) {
|
229 : |
|
|
likevec.resize(new CatchStatistics(infile, Area, TimeInfo, weight, name));
|
230 : |
|
|
|
231 : |
|
|
} else if (strcasecmp(type, "catchdistribution") == 0) {
|
232 : |
|
|
likevec.resize(new CatchDistribution(infile, Area, TimeInfo, keeper, weight, name));
|
233 : |
|
|
|
234 : |
|
|
} else if (strcasecmp(type, "stockdistribution") == 0) {
|
235 : |
|
|
likevec.resize(new StockDistribution(infile, Area, TimeInfo, weight, name));
|
236 : |
|
|
|
237 : |
|
|
} else if (strcasecmp(type, "surveyindices") == 0) {
|
238 : |
|
|
likevec.resize(new SurveyIndices(infile, Area, TimeInfo, weight, name));
|
239 : |
|
|
|
240 : |
|
|
} else if (strcasecmp(type, "surveydistribution") == 0) {
|
241 : |
|
|
likevec.resize(new SurveyDistribution(infile, Area, TimeInfo, keeper, weight, name));
|
242 : |
|
|
|
243 : |
|
|
} else if (strcasecmp(type, "stomachcontent") == 0) {
|
244 : |
|
|
likevec.resize(new StomachContent(infile, Area, TimeInfo, keeper, weight, name));
|
245 : |
|
|
|
246 : |
|
|
} else if (strcasecmp(type, "recaptures") == 0) {
|
247 : |
|
|
likevec.resize(new Recaptures(infile, Area, TimeInfo, weight, tagvec, name));
|
248 : |
|
|
|
249 : |
|
|
} else if ((strcasecmp(type, "catchintons") == 0) || (strcasecmp(type, "catchinkilos") == 0)) {
|
250 : |
|
|
likevec.resize(new CatchInKilos(infile, Area, TimeInfo, weight, name));
|
251 : |
|
|
|
252 : |
|
|
} else if (strcasecmp(type, "migrationpenalty") == 0) {
|
253 : |
|
|
likevec.resize(new MigrationPenalty(infile, weight, name));
|
254 : |
|
|
|
255 : |
|
|
} else if (strcasecmp(type, "recstatistics") == 0) {
|
256 : |
|
|
likevec.resize(new RecStatistics(infile, Area, TimeInfo, weight, tagvec, name));
|
257 : |
|
|
|
258 : |
|
|
} else if (strcasecmp(type, "migrationproportion") == 0) {
|
259 : |
|
|
likevec.resize(new MigrationProportion(infile, Area, TimeInfo, weight, name));
|
260 : |
|
|
|
261 : |
|
|
} else if (strcasecmp(type, "predatorindices") == 0) {
|
262 : |
|
|
handle.logFileMessage(LOGFAIL, "\nThe predatorindices likelihood component is no longer supported\nUse the sibyfleet surveyindices likelihood component instead\nThis is done by setting the sitype to 'fleets' in the likelihood file");
|
263 : |
|
|
|
264 : |
|
|
} else if (strcasecmp(type, "logcatch") == 0) {
|
265 : |
|
|
handle.logFileMessage(LOGFAIL, "\nThe logcatch likelihood component is no longer supported\nUse the log function from the catchdistribution likelihood component instead");
|
266 : |
|
|
|
267 : |
|
|
} else if (strcasecmp(type, "logsurveyindices") == 0) {
|
268 : |
|
|
handle.logFileMessage(LOGFAIL, "\nThe logsurveyindices likelihood component is no longer supported\nUse the log function from the surveyindices likelihood component instead");
|
269 : |
|
|
|
270 : |
|
|
} else {
|
271 : |
|
|
handle.logFileMessage(LOGFAIL, "unrecognised likelihood class", type);
|
272 : |
|
|
}
|
273 : |
|
|
|
274 : |
|
|
handle.logMessage(LOGMESSAGE, "Read likelihood OK - created likelihood component", name);
|
275 : |
|
|
}
|
276 : |
|
|
}
|
277 : |
|
|
|
278 : |
|
|
//
|
279 : |
|
|
// A function to read optimisation information
|
280 : |
|
|
//
|
281 : |
|
|
void Ecosystem::readOptimisation(CommentStream& infile) {
|
282 : |
|
|
char* text = new char[MaxStrLength];
|
283 : |
|
|
strncpy(text, "", MaxStrLength);
|
284 : |
|
|
handle.logMessage(LOGMESSAGE, "Reading optimisation information");
|
285 : |
|
|
|
286 : |
|
|
infile >> ws;
|
287 : |
|
|
if (!infile.eof())
|
288 : |
|
|
infile >> text;
|
289 : |
|
|
|
290 : |
|
|
int count = 0;
|
291 : |
|
|
while (!infile.eof()) {
|
292 : |
|
|
infile >> ws; //trim whitespace from infile
|
293 : |
|
|
if (strcasecmp(text, "seed") == 0) {
|
294 : |
|
|
int seed = 0;
|
295 : |
|
|
infile >> seed >> ws;
|
296 : |
|
|
handle.logMessage(LOGMESSAGE, "Initialising random number generator with", seed);
|
297 : |
|
|
srand(seed);
|
298 : |
|
|
if (!infile.eof())
|
299 : |
|
|
infile >> text;
|
300 : |
|
|
}
|
301 : |
|
|
|
302 : |
|
|
if (strcasecmp(text, "[hooke]") == 0)
|
303 : |
|
|
optvec.resize(new OptInfoHooke());
|
304 : |
|
|
else if (strcasecmp(text, "[simann]") == 0)
|
305 : |
|
|
optvec.resize(new OptInfoSimann());
|
306 : |
|
|
else if (strcasecmp(text, "[bfgs]") == 0)
|
307 : |
|
|
optvec.resize(new OptInfoBFGS());
|
308 : |
|
|
else
|
309 : |
|
|
handle.logFileUnexpected(LOGFAIL, "[hooke], [simann], or [bfgs]", text);
|
310 : |
|
|
|
311 : |
|
|
if (!infile.eof()) {
|
312 : |
|
|
infile >> text;
|
313 : |
|
|
optvec[count]->read(infile, text);
|
314 : |
|
|
} else
|
315 : |
|
|
handle.logMessage(LOGINFO, "Warning - no parameters specified for optimisation algorithm");
|
316 : |
|
|
count++;
|
317 : |
|
|
}
|
318 : |
|
|
|
319 : |
|
|
delete[] text;
|
320 : |
|
|
if (count == 0) {
|
321 : |
|
|
handle.logFileMessage(LOGWARN, "no optimisation algorithms found, using default values");
|
322 : |
|
|
optvec.resize(new OptInfoHooke());
|
323 : |
|
|
}
|
324 : |
|
|
}
|
325 : |
|
|
|
326 : |
|
|
//
|
327 : |
|
|
// The main reading function
|
328 : |
|
|
//
|
329 : |
|
|
void Ecosystem::readMain(CommentStream& infile, const MainInfo& main) {
|
330 : |
|
|
|
331 : |
|
|
int i, j;
|
332 : |
|
|
char text[MaxStrLength];
|
333 : |
|
|
char filename[MaxStrLength];
|
334 : |
|
|
strncpy(text, "", MaxStrLength);
|
335 : |
|
|
strncpy(filename, "", MaxStrLength);
|
336 : |
|
|
|
337 : |
|
|
ifstream subfile;
|
338 : |
|
|
CommentStream subcomment(subfile);
|
339 : |
|
|
|
340 : |
|
|
//first, read in the time information
|
341 : |
|
|
readWordAndValue(infile, "timefile", filename);
|
342 : |
|
|
subfile.open(filename, ios::in);
|
343 : |
|
|
handle.checkIfFailure(subfile, filename);
|
344 : |
|
|
handle.Open(filename);
|
345 : |
|
|
TimeInfo = new TimeClass(subcomment, main.getMaxRatio());
|
346 : |
|
|
handle.Close();
|
347 : |
|
|
subfile.close();
|
348 : |
|
|
subfile.clear();
|
349 : |
|
|
|
350 : |
|
|
//second, read in the area information
|
351 : |
|
|
readWordAndValue(infile, "areafile", filename);
|
352 : |
|
|
subfile.open(filename, ios::in);
|
353 : |
|
|
handle.checkIfFailure(subfile, filename);
|
354 : |
|
|
handle.Open(filename);
|
355 : |
|
|
Area = new AreaClass(subcomment, keeper, TimeInfo);
|
356 : |
|
|
handle.Close();
|
357 : |
|
|
subfile.close();
|
358 : |
|
|
subfile.clear();
|
359 : |
|
|
|
360 : |
|
|
//next, read in the printing information
|
361 : |
|
|
infile >> text >> ws;
|
362 : |
|
|
if ((strcasecmp(text, "printfile") != 0) && (strcasecmp(text, "printfiles") != 0))
|
363 : |
|
|
handle.logFileUnexpected(LOGFAIL, "printfiles", text);
|
364 : |
|
|
|
365 : |
|
|
//Now we have found the string "printfiles" we can create printer classes
|
366 : |
|
|
infile >> text >> ws;
|
367 : |
|
|
while ((strcasecmp(text, "[stock]") != 0) && !infile.eof()) {
|
368 : |
|
|
//Do not try to read printfile if we dont need it
|
369 : |
|
|
if (main.runPrint()) {
|
370 : |
|
|
subfile.open(text, ios::in);
|
371 : |
|
|
handle.checkIfFailure(subfile, text);
|
372 : |
|
|
handle.Open(text);
|
373 : |
|
|
this->readPrinters(subcomment);
|
374 : |
|
|
handle.Close();
|
375 : |
|
|
subfile.close();
|
376 : |
|
|
subfile.clear();
|
377 : |
|
|
}
|
378 : |
|
|
infile >> text >> ws;
|
379 : |
|
|
}
|
380 : |
|
|
|
381 : |
|
|
//then read in the stock information
|
382 : |
|
|
if (strcasecmp(text, "[stock]") != 0)
|
383 : |
|
|
handle.logFileUnexpected(LOGFAIL, "[stock]", text);
|
384 : |
|
|
infile >> text >> ws;
|
385 : |
|
|
|
386 : |
|
|
if (strcasecmp(text, "mortalitymodel") == 0)
|
387 : |
|
|
handle.logFileMessage(LOGFAIL, "\nFleksibest-style mortality models are no longer supported\nGadget version 2.0.07 was the last version to allow this functionality");
|
388 : |
|
|
|
389 : |
|
|
if (strcasecmp(text, "stockfiles") != 0)
|
390 : |
|
|
handle.logFileUnexpected(LOGFAIL, "stockfiles", text);
|
391 : |
|
|
|
392 : |
|
|
//Now we have found the string "stockfiles" we can create stock
|
393 : |
|
|
infile >> text >> ws;
|
394 : |
|
|
while ((strcasecmp(text, "[tagging]") != 0) && !infile.eof()) {
|
395 : |
|
|
subfile.open(text, ios::in);
|
396 : |
|
|
handle.checkIfFailure(subfile, text);
|
397 : |
|
|
handle.Open(text);
|
398 : |
|
|
this->readStock(subcomment);
|
399 : |
|
|
handle.Close();
|
400 : |
|
|
subfile.close();
|
401 : |
|
|
subfile.clear();
|
402 : |
|
|
infile >> text >> ws;
|
403 : |
|
|
}
|
404 : |
|
|
|
405 : |
|
|
//Now we read the names of the tagging files
|
406 : |
|
|
if (strcasecmp(text, "[tagging]") != 0)
|
407 : |
|
|
handle.logFileUnexpected(LOGFAIL, "[tagging]", text);
|
408 : |
|
|
|
409 : |
|
|
infile >> text >> ws;
|
410 : |
|
|
if (strcasecmp(text, "tagfiles") == 0) {
|
411 : |
|
|
//There might not be any tagging files
|
412 : |
|
|
infile >> text >> ws;
|
413 : |
|
|
while ((strcasecmp(text, "[otherfood]") != 0) && !infile.eof()) {
|
414 : |
|
|
subfile.open(text, ios::in);
|
415 : |
|
|
handle.checkIfFailure(subfile, text);
|
416 : |
|
|
handle.Open(text);
|
417 : |
|
|
this->readTagging(subcomment);
|
418 : |
|
|
handle.Close();
|
419 : |
|
|
subfile.close();
|
420 : |
|
|
subfile.clear();
|
421 : |
|
|
infile >> text >> ws;
|
422 : |
|
|
}
|
423 : |
|
|
}
|
424 : |
|
|
|
425 : |
|
|
//Now we read the names of the otherfood files
|
426 : |
|
|
if (strcasecmp(text, "[otherfood]") != 0)
|
427 : |
|
|
handle.logFileUnexpected(LOGFAIL, "[otherfood]", text);
|
428 : |
|
|
|
429 : |
|
|
infile >> text >> ws;
|
430 : |
|
|
if (strcasecmp(text, "otherfoodfiles") == 0) {
|
431 : |
|
|
//There might not be any otherfood files
|
432 : |
|
|
infile >> text >> ws;
|
433 : |
|
|
while ((strcasecmp(text, "[fleet]") != 0) && !infile.eof()) {
|
434 : |
|
|
subfile.open(text, ios::in);
|
435 : |
|
|
handle.checkIfFailure(subfile, text);
|
436 : |
|
|
handle.Open(text);
|
437 : |
|
|
this->readOtherFood(subcomment);
|
438 : |
|
|
handle.Close();
|
439 : |
|
|
subfile.close();
|
440 : |
|
|
subfile.clear();
|
441 : |
|
|
infile >> text >> ws;
|
442 : |
|
|
}
|
443 : |
|
|
}
|
444 : |
|
|
|
445 : |
|
|
//Now we read the names of the fleet files
|
446 : |
|
|
if (strcasecmp(text, "[fleet]") != 0)
|
447 : |
|
|
handle.logFileUnexpected(LOGFAIL, "[fleet]", text);
|
448 : |
|
|
|
449 : |
|
|
infile >> text >> ws;
|
450 : |
|
|
if (strcasecmp(text, "fleetfiles") == 0) {
|
451 : |
|
|
//There might not be any fleet files
|
452 : |
|
|
infile >> text >> ws;
|
453 : |
|
|
while ((strcasecmp(text, "[likelihood]") != 0) && !infile.eof()) {
|
454 : |
|
|
subfile.open(text, ios::in);
|
455 : |
|
|
handle.checkIfFailure(subfile, text);
|
456 : |
|
|
handle.Open(text);
|
457 : |
|
|
this->readFleet(subcomment);
|
458 : |
|
|
handle.Close();
|
459 : |
|
|
subfile.close();
|
460 : |
|
|
subfile.clear();
|
461 : |
|
|
infile >> text >> ws;
|
462 : |
|
|
}
|
463 : |
|
|
}
|
464 : |
|
|
|
465 : |
|
|
if (strcasecmp(text, "[likelihood]") != 0)
|
466 : |
|
|
handle.logFileUnexpected(LOGFAIL, "[likelihood]", text);
|
467 : |
|
|
|
468 : |
|
|
//Now we have either read the word likelihood or reached the end of file
|
469 : |
|
|
if (!infile.eof()) {
|
470 : |
|
|
infile >> text >> ws;
|
471 : |
|
|
if (strcasecmp(text, "likelihoodfiles") == 0) {
|
472 : |
|
|
//There might not be any likelihood files
|
473 : |
|
|
infile >> text;
|
474 : |
|
|
while (!infile.eof()) {
|
475 : |
|
|
subfile.open(text, ios::in);
|
476 : |
|
|
handle.checkIfFailure(subfile, text);
|
477 : |
|
|
handle.Open(text);
|
478 : |
|
|
this->readLikelihood(subcomment);
|
479 : |
|
|
handle.Close();
|
480 : |
|
|
subfile.close();
|
481 : |
|
|
subfile.clear();
|
482 : |
|
|
|
483 : |
|
|
infile >> ws;
|
484 : |
|
|
if (!infile.eof())
|
485 : |
|
|
infile >> text;
|
486 : |
|
|
}
|
487 : |
|
|
}
|
488 : |
|
|
}
|
489 : |
|
|
}
|