-
Notifications
You must be signed in to change notification settings - Fork 26
Add option to convert cooling times in output file to seconds #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1df072d
81d5d7f
a53e8ea
55c8258
bb93e50
a7228d1
9b4edba
9370056
182e487
266d1f4
5994579
4bc23ae
b142877
bbc962a
ef89289
8fec07e
6eba7c6
3d950f2
20dab87
717b0e5
598b1fb
cce2f7e
582f8b0
32fea30
5da0c69
ba06de0
73212f2
257c8d8
31d3c5e
5f0a04f
d75be17
36873b6
42bb443
daa06f4
6f9d84e
c937807
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,14 +51,18 @@ OutputFormat::OutputFormat(int type) | |
| strcpy(normUnits,"/cm3"); | ||
| normType = 1; | ||
|
|
||
| cooltimeUnits = new char[5]; | ||
| strcpy(cooltimeUnits,"def"); | ||
| cooltimeType = 1; | ||
|
|
||
| gammaSrc = NULL; | ||
| contactDose = NULL; | ||
|
|
||
| next = NULL; | ||
| } | ||
|
|
||
| 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,13 +71,17 @@ 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; | ||
| } | ||
|
|
||
| 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<<type) | ||
| { | ||
| case OUTFMT_UNITS: | ||
| { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need these braces?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need these braces due to the initialization of
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So if we end up getting rid of the |
||
| next->outTypes |= 1<<type; | ||
| delete[] next->actUnits; | ||
| input >> token; | ||
|
|
@@ -175,7 +184,28 @@ OutputFormat* OutputFormat::getOutFmts(istream& input) | |
| next->normType = OUTNORM_CM3; | ||
| break; | ||
| } | ||
| break; | ||
|
|
||
| delete[] next->cooltimeUnits; | ||
| next->cooltimeUnits = nullptr; | ||
| std::streampos pos = input.tellg(); | ||
|
|
||
| if (input >> token) { | ||
| if (tolower(token[0]) == 's') { | ||
| next->cooltimeType = COOLTIME_S; | ||
|
|
||
| next->cooltimeUnits = new char[strlen(token)+2]; | ||
| strcpy(next->cooltimeUnits, token); | ||
| } else { | ||
| input.seekg(pos); | ||
|
|
||
| next->cooltimeType = COOLTIME_DEF; | ||
| next->cooltimeUnits = new char[4]; | ||
| strcpy(next->cooltimeUnits, "def"); | ||
| } | ||
| } | ||
| break; | ||
| } | ||
|
Comment on lines
+190
to
+207
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This approach is fragile. For example, it fails if a user does NOT include the optional cooling time unit, and the next entry in the output format block is
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given the way that ALARA reads input files, I don't think we can avoid breaking backwards compatibility with this. The only way might be to add a new optional line in the output format block just for this purpose. |
||
|
|
||
| case OUTFMT_WDR: | ||
| next->outTypes |= 1<<type; | ||
| input >> token; | ||
|
|
@@ -282,7 +312,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;outTypeNum<lastSingularResponse;outTypeNum++) | ||
| if (ptr->outTypes & 1<<outTypeNum) | ||
|
|
@@ -291,32 +321,32 @@ void OutputFormat::write(Volume* volList, Mixture* mixList, Loading* loadList, | |
| { | ||
| case (OUTFMT_ACT): | ||
| sprintf(buffer,Out_Types_Str[outTypeNum], | ||
| ptr->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 +363,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;outTypeNum<lastSingularResponse;outTypeNum++) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,4 +31,7 @@ | |
| #define CM3_M3 1e-6 | ||
| #define G_KG 1e-3 | ||
|
|
||
| #define COOLTIME_DEF 1 | ||
| #define COOLTIME_S 2 | ||
|
|
||
| #endif | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a short function
That does this to ensure consistency across different places we do this (currently only two)