Debugging
Debugging is an art. Everyone has their own favorite method. Here we offer a few tips we have found to be useful.
Compiling in debug mode (e.g., make DEBUG=TRUE for gmake users;
cmake -DDEBUG for cmake users) and running with
amrex.fpe_trap_invalid=1 in the inputs file can be helpful.
In debug mode, many compiler debugging flags are turned on and all
MultiFab s are initialized to signaling NaNs. The
amrex.fpe_trap_invalid parameter will result in backtrace files
when a floating point exception occurs. One can then examine those
files to track down the origin of the issue.
Several ways to look at the data include:
Writing a
MultiFabto disk withVisMF::Write(const FabArray<FArrayBox>& mf, const std::string& name);
and examining it with
Amrvis(section Amrvis in the AMReX documentation).You can also use the
print_stateroutine:void print_state(const MultiFab& mf, const IntVect& cell, const int n=-1);
which outputs the data for a single cell.
If you want to compare old and new plotfiles,
fcompare --infile1 plt00000_run1 --infile2 plt00000_run2 --diffvar u_g
will print out the maximum absolute and relative differences between the two plotfiles for each variable and will also create a new plotfile “diffs” that contains the difference in u_g (in this case) between the two plotfiles.
The
fcompareexecutable can be built in AMReX (go to amrex/Tools/Plotfile and type “make”).
Valgrind is another useful debugging tool. Note that for runs using more than one MPI process, one can tell valgrind to output to different files for different processes. For example,
mpiexec -n 4 valgrind --leak-check=yes --track-origins=yes --log-file=vallog.%p ./incflo.exe ...
Also see AMReX’s documentation on Debugging for further suggestions.
If you believe you’ve encountered a bug or incorrect behavior in incflo, please report the issue on incflo’s github page here .