Skip to content

Commit

Permalink
Add check for plotfile tools (AMReX-Codes#1610)
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiqunZhang authored Dec 7, 2020
1 parent 65615e9 commit 81a56bd
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 17 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,19 @@ jobs:
make -j2 WARN_ALL=TRUE WARN_ERROR=TRUE XTRA_CXXFLAGS=-fno-operator-names
make install
# Build Tools/Plotfile
plotfile-tools:
name: GNU Plotfile Tools [tools]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Dependencies
run: .github/workflows/dependencies/dependencies.sh
- name: Build & Install
run: |
cd Tools/Plotfile
make -j2 USE_MPI=FALSE USE_OMP=FALSE WARN_ALL=TRUE WARN_ERROR=TRUE XTRA_CXXFLAGS=-fno-operator-names
# Build libamrex and run all tests
tests:
name: GNU@7.5 C++14 [tests]
Expand Down
10 changes: 5 additions & 5 deletions Tools/Plotfile/fboxinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ void main_main()
int farg = 1;
while (farg <= narg) {
const auto fname = get_command_argument(farg);
if (fname == "-f" or fname == "--full") {
if (fname == "-f" || fname == "--full") {
b_full = true;
} else if (fname == "-g" or fname == "--gridfile") {
} else if (fname == "-g" || fname == "--gridfile") {
b_gridfile = true;
} else if (fname == "-l" or fname == "--levels") {
} else if (fname == "-l" || fname == "--levels") {
b_levels = true;
} else {
break;
}
++farg;
}

if (b_gridfile and b_full) {
if (b_gridfile && b_full) {
amrex::Abort("ERROR: cannot specify both full and gridfile modes");
}

Expand All @@ -86,7 +86,7 @@ void main_main()
const auto& fname = amrex::get_command_argument(f);
PlotFileData plotfile(fname);

if (!b_gridfile and !b_levels) {
if (!b_gridfile && !b_levels) {
amrex::Print() << " plotfile: " << fname << "\n";
}

Expand Down
22 changes: 11 additions & 11 deletions Tools/Plotfile/fextract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,29 @@ void main_main()
int farg = 1;
while (farg <= narg) {
const std::string& name = amrex::get_command_argument(farg);
if (name == "-s" or name == "--slicefile") {
if (name == "-s" || name == "--slicefile") {
slicefile = amrex::get_command_argument(++farg);
} else if (name == "-d" or name == "--direction") {
} else if (name == "-d" || name == "--direction") {
idir = std::stoi(amrex::get_command_argument(++farg));
} else if (name == "-v" or name == "--variable") {
} else if (name == "-v" || name == "--variable") {
varnames_arg = amrex::get_command_argument(++farg);
} else if (name == "-y") {
ycoord = std::stod(amrex::get_command_argument(++farg));
} else if (name == "-l" or name == "--lower_left") {
} else if (name == "-l" || name == "--lower_left") {
center = false;
} else if (name == "-c" or name == "--coarse_level") {
} else if (name == "-c" || name == "--coarse_level") {
coarse_level = std::stoi(amrex::get_command_argument(++farg));
} else if (name == "-f" or name == "--fine_level") {
} else if (name == "-f" || name == "--fine_level") {
fine_level = std::stoi(amrex::get_command_argument(++farg));
} else if (name == "-e" or name == "--scientific") {
} else if (name == "-e" || name == "--scientific") {
scientific = true;
} else {
break;
}
++farg;
}

if (pltfile.empty() and farg <= narg) {
if (pltfile.empty() && farg <= narg) {
pltfile = amrex::get_command_argument(farg);
}

Expand Down Expand Up @@ -92,7 +92,7 @@ void main_main()
PlotFileData pf(pltfile);
const int dim = pf.spaceDim();

if (idir < 0 or idir >= dim) {
if (idir < 0 || idir >= dim) {
amrex::Print() << " invalid direction\n";
return;
} else if (idir == 0) {
Expand Down Expand Up @@ -140,7 +140,7 @@ void main_main()
kloc = (hi0.z-lo0.z+1)/2 + lo0.z;
}

if (ycoord > -1.e-36 and AMREX_SPACEDIM >= 2) {
if (ycoord > -1.e-36 && AMREX_SPACEDIM >= 2) {
// we specified the y value to pass through
for (int j = lo0.y; j <= hi0.y; ++j) {
amrex::Real yc = problo[1] + (j+0.5)*dx0[1];
Expand All @@ -155,7 +155,7 @@ void main_main()

if (fine_level < 0) fine_level = pf.finestLevel();
// sanity check on valid selected levels
if (fine_level > pf.finestLevel() or coarse_level < 0 or coarse_level > fine_level) {
if (fine_level > pf.finestLevel() || coarse_level < 0 || coarse_level > fine_level) {
amrex::Abort("Invalid level selection");
}

Expand Down
2 changes: 1 addition & 1 deletion Tools/Plotfile/fextrema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void main_main()
int farg = 1;
while (farg <= narg) {
const std::string& name = amrex::get_command_argument(farg);
if (name == "-v" or name == "--variable") {
if (name == "-v" || name == "--variable") {
varnames_arg = amrex::get_command_argument(++farg);
} else {
break;
Expand Down

0 comments on commit 81a56bd

Please sign in to comment.