Skip to content

Commit

Permalink
Merge pull request #3994 from pnorbert/fix-example-basics-values
Browse files Browse the repository at this point in the history
Fix 1: bpls handle when BP5 throws logic error on minmax for unsuppor…
  • Loading branch information
pnorbert authored Jan 9, 2024
2 parents 4ace858 + 732255d commit 5de40ef
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/basics/values/values.F90
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ subroutine reader
! Note, every process reads everything in this example

call adios2_declare_io(io, adios, "ValuesInput", ierr)
call adios2_open(engine, io, "adios2-values-f.bp", adios2_mode_read, MPI_COMM_SELF, ierr)
call adios2_open(engine, io, "adios2-values-f.bp", adios2_mode_readRandomAccess, MPI_COMM_SELF, ierr)

call adios2_inquire_variable(var_gc, io, "GlobalConstant", ierr)
call adios2_get(engine, var_gc, gc , ierr)
Expand Down
8 changes: 8 additions & 0 deletions examples/basics/values/valuesWrite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

#include <iostream>
#include <string>
#include <vector>

#include <adios2.h>
Expand Down Expand Up @@ -80,6 +81,8 @@ int main(int argc, char *argv[])

// 2. Global value, same value across processes, varying value over time
adios2::Variable<int> varStep = io.DefineVariable<int>("Step");
adios2::Variable<std::string> varGlobalString =
io.DefineVariable<std::string>("GlobalString");

// 3. Local value, varying across processes, constant over time
adios2::Variable<int> varProcessID =
Expand Down Expand Up @@ -110,6 +113,11 @@ int main(int argc, char *argv[])
writer.Put<int>(varNproc, nproc);
}
writer.Put<int>(varStep, step);

std::string str = "This is step " + std::to_string(step);
// str will go out of scope before EndStep(), so we must use
// Sync mode in Put()
writer.Put<std::string>(varGlobalString, str, adios2::Mode::Sync);
}

// 3. and 4. Writing a local value on every process. Will be shown
Expand Down
28 changes: 17 additions & 11 deletions source/utils/bpls/bpls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1144,21 +1144,27 @@ int printVariableInfo(core::Engine *fp, core::IO *io, core::Variable<T> *variabl
if (timestep == false)
{
MinMaxStruct MinMax;
if (fp->VariableMinMax(*variable, DefaultSizeT, MinMax))
try
{
fprintf(outf, " = ");
print_data(&MinMax.MinUnion, 0, adiosvartype, false);
fprintf(outf, " / ");
print_data(&MinMax.MaxUnion, 0, adiosvartype, false);
if (fp->VariableMinMax(*variable, DefaultSizeT, MinMax))
{
fprintf(outf, " = ");
print_data(&MinMax.MinUnion, 0, adiosvartype, false);
fprintf(outf, " / ");
print_data(&MinMax.MaxUnion, 0, adiosvartype, false);
}
else
{
fprintf(outf, " = ");
print_data(&variable->m_Min, 0, adiosvartype, false);
fprintf(outf, " / ");
print_data(&variable->m_Max, 0, adiosvartype, false);
}
// fprintf(outf," {MIN / MAX} ");
}
else
catch (std::logic_error &)
{
fprintf(outf, " = ");
print_data(&variable->m_Min, 0, adiosvartype, false);
fprintf(outf, " / ");
print_data(&variable->m_Max, 0, adiosvartype, false);
}
// fprintf(outf," {MIN / MAX} ");
}
#if 0
else
Expand Down

0 comments on commit 5de40ef

Please sign in to comment.