-
Notifications
You must be signed in to change notification settings - Fork 202
[WIP] ABLASTR: IntervalsParser & SafeCast #5227
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: development
Are you sure you want to change the base?
[WIP] ABLASTR: IntervalsParser & SafeCast #5227
Conversation
Refactor and move out the `SafeCast` and `IntervalsParser` from WarpX to ABLASTR.
{ | ||
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(!m_isBTD || !insplit[1].empty(), "must specify interval stop for BTD"); | ||
if (!insplit[0].empty()){ | ||
m_start = parseStringtoInt(insplit[0], "interval start");} |
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.
parseStringtoInt
: @WeiqunZhang can I use an AMReX intrinsic for this now?
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.
I looked at the implementation of that function. It use amrex::Parser to parse it as double precision numbers and then check if it can be safely cast to int. There is amrex::IParser we can use. It parses the numbers as long long. So the chance of overflowing during parsing is tiny. The safety checking for casting to int would also be much simpler.
|
||
ablastr::utils::parser::SliceParser::SliceParser ( | ||
const std::string& instr, | ||
const bool isBTD |
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.
Urgh, such a hack: The isBTD
should never have made it into this interface and needs to be removed. BTDIntervalsParser
can handle this.
Refactor and move out the
SafeCast
andIntervalsParser
from WarpX to ABLASTR.