Skip to content

Commit

Permalink
Tools/Plotfile: Fix build errors in single precision mode (AMReX-Code…
Browse files Browse the repository at this point in the history
…s#1577)

This PR fixes one build error and one warning observed when compiling `Tools/Plotfile` utilities with `-DAMREX_USE_FLOAT`
  • Loading branch information
sayerhs authored Nov 30, 2020
1 parent 82eceae commit a779686
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 6 additions & 2 deletions Tools/Plotfile/fcompare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,14 @@ int main_main()
} else {
Real aerr = 0., rerr = 0.;
if (aerror[icomp_a] > 0.) {
aerr = std::min(std::max(aerror[icomp_a], 1.e-99), 1.e98);
aerr = std::min(
std::max(aerror[icomp_a], std::numeric_limits<Real>::min()),
std::numeric_limits<Real>::max());
}
if (rerror[icomp_a] > 0.) {
rerr = std::min(std::max(rerror[icomp_a], 1.e-99), 1.e98);
rerr = std::min(
std::max(rerror[icomp_a], std::numeric_limits<Real>::min()),
std::numeric_limits<Real>::max());
}
amrex::Print() << " " << std::setw(24) << std::left << names_a[icomp_a]
<< std::right
Expand Down
12 changes: 6 additions & 6 deletions Tools/Plotfile/fextract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ void main_main()
if (m(i,j,k) == 0) { // not covered by fine
if (pos.size() == data[ivar].size()) {
Array<Real,AMREX_SPACEDIM> p
= {AMREX_D_DECL(problo[0]+(i+0.5)*dx[0],
problo[1]+(j+0.5)*dx[1],
problo[2]+(k+0.5)*dx[2])};
= {AMREX_D_DECL(problo[0]+static_cast<Real>(i+0.5)*dx[0],
problo[1]+static_cast<Real>(j+0.5)*dx[1],
problo[2]+static_cast<Real>(k+0.5)*dx[2])};
pos.push_back(p[idir]);
}
data[ivar].push_back(fab(i,j,k));
Expand All @@ -220,9 +220,9 @@ void main_main()
for (int i = lo.x; i <= hi.x; ++i) {
if (pos.size() == data[ivar].size()) {
Array<Real,AMREX_SPACEDIM> p
= {AMREX_D_DECL(problo[0]+(i+0.5)*dx[0],
problo[1]+(j+0.5)*dx[1],
problo[2]+(k+0.5)*dx[2])};
= {AMREX_D_DECL(problo[0]+static_cast<Real>(i+0.5)*dx[0],
problo[1]+static_cast<Real>(j+0.5)*dx[1],
problo[2]+static_cast<Real>(k+0.5)*dx[2])};
pos.push_back(p[idir]);
}
data[ivar].push_back(fab(i,j,k));
Expand Down

0 comments on commit a779686

Please sign in to comment.