Gate
Gate copied to clipboard
GATE can't read Material.db with DOS newline
I ran into the problem, because a colleague of mine edited a material database file on windows, causing the newlines to be changed into \r\n
. When starting the GATE simulation with the edited material database, I got the following strange exception:
-------- EEEE ------- G4Exception-START -------- EEEE -------
*** G4Exception : DecodingException
issued by : GateMDBFieldDecoder::DecodingException
The definition of the element/material 'air' is incorrect: The value found for the state field ('gas') was not recognized.
You should check this definition in the database file.
*** Fatal Exception *** core dump ***
-------- EEEE -------- G4Exception-END --------- EEEE -------
It looks like 'gas' should be correct, but actually it's 'gas\r', because '\r' is not cleaned up by the GateTokenizer
:
void GateTokenizer::CleanUpString(G4String& stringToCleanup)
{
while (stringToCleanup.length()) {
if ( (stringToCleanup.at(0)==' ') || (stringToCleanup.at(0)=='\t') || (stringToCleanup.at(0)=='\n') )
stringToCleanup=stringToCleanup.substr(1);
else
break;
}
while (stringToCleanup.length()) {
G4String::size_type pos = stringToCleanup.length()-1;
if ( (stringToCleanup.at(pos)==' ') || (stringToCleanup.at(pos)=='\t') || (stringToCleanup.at(0)=='\n') )
stringToCleanup=stringToCleanup.substr(0,pos);
else
break;
}
}
Good day, Supernabla, I have encountered a similar problem after installing Gate v9.0, v9.1, and v9.2, the same exception popped up, G4Exception : DecodingException issued by : GateMDBFieldDecoder::DecodingException, it took me a while to understand that my GateMaterials.db was corrupted, at first eye everything seemed ok, even inside a text editor you couldn't see any difference, but the two files had different sizes, once I changed the corrupted GateMaterials.db file with the file I downloaded from GateContrib everything was working!