-
Notifications
You must be signed in to change notification settings - Fork 27
Description
Python Meshtal Class Fails for mct < 0 on PRDMP Card
I'm performing validation of MCNP6.3 and thus have disabled printing of run-specific information in my output files. I'm using the mct option on the PRDMP card (mct = -1 or -2). Though the MCNP6.3 manual only mentions the disabled printing for MCTAL and output files, run-specific information is also removed from MESHTAL files. For example,
mcnp version 6 ld=02/20/18 probid = 10/11/23 13:51:15
MY TITLE
Number of histories used for normalizing tallies = 10000.00
Mesh Tally Number 4
...
becomes
MY TITLE
Number of histories used for normalizing tallies = 10000.00
Mesh Tally Number 4
...
When I try to read these MESHTAL files using the Meshtal class within MCNPTools' Python bindings, I get a generic RuntimeError: McnpToolsException. Re-enabling printing of run-specific info fixes the issue. I haven't had the same issue with the MctalTally and MctalKcode classes, so it appears to be limited to the Meshtal class.
I have very limited knowledge of C++, but I think the issue is in the source code for file Meshtal.cpp, lines 31-43 (and repeated on lines 422-434?):
// read the header line
cjsoft::stringops::getline(m_handle,line);
std::vector<std::string> spline;
cjsoft::stringops::tokenize<std::vector<std::string>,cjsoft::stringops::StringTrim>(line,spline);
if( spline.size() == 8 ) {
m_code = spline[0];
m_version = spline[2];
m_probid = spline[6] + " " + spline[7];
}
else {
throw McnpToolsException("file " + fname + " does not look like an MCNP meshtal file");
}It looks like the code expects to find 8 substrings which make up the run-specific information in the header line. If not found, it throws an exception. In pseudocode, it seems like the fix would be:
read header line
if (header line starts with 'mcnp'): \\ Follow existing logic
split line into substrings
assign values to run-specific variables
load next line
else if (header line starts with space): \\ Comment line seems to always start with space, even if blank
assign blank values to run-specific variables
\\ already on comment line, so don't load next line
else:
throw exception
process comment line...