diff --git a/src/CoolingTime.C b/src/CoolingTime.C index cb2d4057..1a2f7e61 100644 --- a/src/CoolingTime.C +++ b/src/CoolingTime.C @@ -12,6 +12,7 @@ #include "CoolingTime.h" #include "Input_def.h" +#include "Output_def.h" /*************************** ********* Service ********* @@ -131,7 +132,7 @@ int CoolingTime::makeCoolingTimes(double *& coolingTimes) /** There is a column for the isotope, a column for the @shutdown result, and then a column for each after-shutdown cooling time. */ -void CoolingTime::writeHeader() +void CoolingTime::writeHeader(int cooltime_units) { CoolingTime *ptr = this; char textBuf[16]; @@ -141,7 +142,16 @@ void CoolingTime::writeHeader() while (ptr->next != NULL) { ptr = ptr->next; - sprintf(textBuf,"%7g %c ",ptr->coolingTime, ptr->units); + if (cooltime_units == COOLTIME_S) // print cooling time converted to seconds + { + double t_sec = convertTime(ptr->coolingTime, ptr->units); + sprintf(textBuf, "%9.3e s ", t_sec); + } + else // print cooling time in default units + { + sprintf(textBuf, "%7g %c ", ptr->coolingTime, ptr->units); + } + cout << textBuf; } cout << endl; @@ -168,7 +178,7 @@ void CoolingTime::getCoolTimesStrings(std::vector& coolTimesList) /** There is a column indicating the counter for the total in question, one column for @ shutdown results, and then one column for each of the after-shutdown cooling times. */ -void CoolingTime::writeTotalHeader(const char* type) +void CoolingTime::writeTotalHeader(const char* type, int cooltime_units) { CoolingTime *ptr = this; char textBuf[16]; @@ -181,7 +191,16 @@ void CoolingTime::writeTotalHeader(const char* type) while (ptr->next != NULL) { ptr = ptr->next; - sprintf(textBuf,"%7g %c ",ptr->coolingTime, ptr->units); + if (cooltime_units == COOLTIME_S) // print cooling time converted to seconds + { + double t_sec = convertTime(ptr->coolingTime, ptr->units); + sprintf(textBuf, "%9.3e s ", t_sec); + } + else // print cooling time in default units + { + sprintf(textBuf, "%7g %c ", ptr->coolingTime, ptr->units); + } + cout << textBuf; } cout << endl; diff --git a/src/CoolingTime.h b/src/CoolingTime.h index 1499f0da..bcd4b259 100644 --- a/src/CoolingTime.h +++ b/src/CoolingTime.h @@ -49,13 +49,13 @@ class CoolingTime int makeCoolingTimes(double *&); /// This function writes a header for the standard response table. - void writeHeader(); + void writeHeader(int cooltime_units); /// This function returns a string containing the nth shutdown time void getCoolTimesStrings(std::vector&); /// This function writes a header for the table of totals. - void writeTotalHeader(const char*); + void writeTotalHeader(const char*, int cooltime_units); /// This function writes an appropriately sized separator of /// "===...===" to frame the table. diff --git a/src/Loading.C b/src/Loading.C index 11083757..51d0bb06 100644 --- a/src/Loading.C +++ b/src/Loading.C @@ -470,7 +470,7 @@ void Loading::write(int response, int writeComp, CoolingTime* coolList, cout << Result::getReminderStr() << endl; /* write header for totals */ - coolList->writeTotalHeader("zone"); + coolList->writeTotalHeader("zone", Result::getCooltimeMode()); /* for each zone */ while (ptr->next != NULL) diff --git a/src/Mixture.C b/src/Mixture.C index 85b17f68..6a030963 100644 --- a/src/Mixture.C +++ b/src/Mixture.C @@ -616,7 +616,7 @@ void Mixture::write(int response, int writeComp, CoolingTime* coolList, cout << Result::getReminderStr() << endl; /* write header for totals */ - coolList->writeTotalHeader("mixture"); + coolList->writeTotalHeader("mixture", Result::getCooltimeMode()); /* for each mixture */ while (ptr->next != NULL) diff --git a/src/OutputFormat.C b/src/OutputFormat.C index 985ef430..fc63ff5c 100644 --- a/src/OutputFormat.C +++ b/src/OutputFormat.C @@ -51,6 +51,10 @@ OutputFormat::OutputFormat(int type) strcpy(normUnits,"/cm3"); normType = 1; + cooltimeUnits = new char[5]; + strcpy(cooltimeUnits,"def"); + cooltimeType = 1; + gammaSrc = NULL; contactDose = NULL; @@ -58,7 +62,7 @@ OutputFormat::OutputFormat(int type) } OutputFormat::OutputFormat(const OutputFormat& o) : - resolution(o.resolution), outTypes(o.outTypes), normType(o.normType), actMult(o.actMult) + resolution(o.resolution), outTypes(o.outTypes), normType(o.normType), actMult(o.actMult), cooltimeType(o.cooltimeType) { actUnits = new char[strlen(o.actUnits)+1]; @@ -67,6 +71,9 @@ OutputFormat::OutputFormat(const OutputFormat& o) : normUnits = new char[strlen(o.normUnits)+1]; strcpy(normUnits,o.normUnits); + cooltimeUnits = new char[strlen(o.cooltimeUnits)+1]; + strcpy(cooltimeUnits,o.cooltimeUnits); + next = NULL; } @@ -74,6 +81,7 @@ OutputFormat::~OutputFormat() { delete[] actUnits; delete[] normUnits; + delete[] cooltimeUnits; delete gammaSrc; delete contactDose; delete next; @@ -141,6 +149,7 @@ OutputFormat* OutputFormat::getOutFmts(istream& input) switch (1<outTypes |= 1<actUnits; input >> token; @@ -175,7 +184,34 @@ OutputFormat* OutputFormat::getOutFmts(istream& input) next->normType = OUTNORM_CM3; break; } - break; + + delete[] next->cooltimeUnits; + next->cooltimeUnits = new char[strlen(token)+1]; + strcpy(next->cooltimeUnits, ""); + + next->cooltimeType = COOLTIME_DEF; + std::streampos pos = input.tellg(); + + if (input >> token) + { + if (tolower(token[0]) == 's') + { + next->cooltimeType = COOLTIME_S; + + delete[] next->cooltimeUnits; + next->cooltimeUnits = new char[strlen(token)+1]; + strcpy(next->cooltimeUnits, token); + } + else if (tolower(token[0]) == 'd') + { + input.seekg(pos); + } + else + { + error(230, "Unknown cooling time unit '%s'", token); + } + } + } case OUTFMT_WDR: next->outTypes |= 1<> token; @@ -282,7 +318,7 @@ void OutputFormat::write(Volume* volList, Mixture* mixList, Loading* loadList, /* units */ outTypeNum = 0; cout << "\t" << Out_Types_Str[outTypeNum] << ": " - << ptr->actUnits << " " << ptr->normUnits << endl; + << ptr->actUnits << " " << ptr->normUnits << " " << ptr->cooltimeUnits << endl; /* regular singular responses */ for (++outTypeNum;outTypeNumoutTypes & 1<actUnits,ptr->normUnits); + ptr->actUnits,ptr->normUnits,ptr->cooltimeUnits); break; case (OUTFMT_SRC) : sprintf(buffer,Out_Types_Str[outTypeNum], /* deliver gamma src filename, */ - ptr->normUnits, ptr->gammaSrc->getFileName(),ptr->actUnits,ptr->normUnits); + ptr->normUnits, ptr->gammaSrc->getFileName(),ptr->actUnits,ptr->normUnits,ptr->cooltimeUnits); break; case (OUTFMT_CDOSE) : sprintf(buffer,Out_Types_Str[outTypeNum], - ptr->contactDose->getFileName()); + ptr->contactDose->getFileName(),ptr->cooltimeUnits); break; case (OUTFMT_ADJ) : sprintf(buffer,Out_Types_Str[outTypeNum], - ptr->adjointDose->getFileName()); + ptr->adjointDose->getFileName(),ptr->cooltimeUnits); break; case (OUTFMT_EXP) : sprintf(buffer, Out_Types_Str[outTypeNum], - ptr->exposureDose->getFileName()); + ptr->exposureDose->getFileName(),ptr->cooltimeUnits); break; case (OUTFMT_EXP_CYL_VOL) : sprintf(buffer, Out_Types_Str[outTypeNum], - ptr->exposureCylVolDose->getFileName()); + ptr->exposureCylVolDose->getFileName(),ptr->cooltimeUnits); break; default: sprintf(buffer,Out_Types_Str[outTypeNum], - ptr->normUnits); + ptr->normUnits,ptr->cooltimeUnits); } cout << "\t" << buffer << endl; } @@ -333,7 +369,7 @@ void OutputFormat::write(Volume* volList, Mixture* mixList, Loading* loadList, cout << endl << endl; /* set units for activity */ - Result::setNorm(ptr->actMult,ptr->normType); + Result::setNorm(ptr->actMult,ptr->normType,ptr->cooltimeType); /* for each indicated response */ for (outTypeNum=firstResponse;outTypeNumwriteHeader(); + coolList->writeHeader(Result::getCooltimeMode()); if (response == OUTFMT_SRC) { @@ -592,12 +593,19 @@ void Result::readDump() } } -void Result::setNorm(double passedActMult, int normType) +int Result::getCooltimeMode() +{ + return cooltime_units; +} + + +void Result::setNorm(double passedActMult, int normType, int cooltimeType) { actMult = passedActMult; - switch (normType) { + switch (normType) + { case OUTNORM_M3: metricMult = 1.0/CM3_M3; break; @@ -607,6 +615,7 @@ void Result::setNorm(double passedActMult, int normType) default: metricMult = 1; } + cooltime_units = cooltimeType; } diff --git a/src/Result.h b/src/Result.h index 6fdc7f32..41b9201c 100644 --- a/src/Result.h +++ b/src/Result.h @@ -60,6 +60,8 @@ class Result /// data is for. int kza; + static int cooltime_units; + /// This is an array of results, one for each cooling time and at /// shutdown. double *N; @@ -129,7 +131,9 @@ class Result /// This function is used to set actMult from the first argument and /// metricMult by interpretation of the second argument. - static void setNorm(double,int); + static void setNorm(double,int,int); + + static int getCooltimeMode(); /// This function is used to set outReminderStr so that each table /// makes it clear what is being written. Corresponding function to query diff --git a/src/Volume.C b/src/Volume.C index b1b6ecde..18b8a785 100644 --- a/src/Volume.C +++ b/src/Volume.C @@ -778,7 +778,7 @@ void Volume::write(int response, int writeComp, CoolingTime* coolList, cout << Result::getReminderStr() << endl; /* write header for totals */ - coolList->writeTotalHeader("interval"); + coolList->writeTotalHeader("interval", Result::getCooltimeMode()); /* for each interval */ while (ptr->next != NULL)