Skip to content

Commit

Permalink
IOSS: Clean up timestep count fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gdsjaar committed Jul 9, 2024
1 parent c1d8ced commit d286b81
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1586,9 +1586,7 @@ namespace Ioex {
// common
int64_t BaseDatabaseIO::add_results_fields(Ioss::GroupingEntity *entity, int64_t position)
{
auto timestep_count = get_region()->get_optional_property("state_count", 0);
if (timestep_count == 0) return 0;

if (m_timestepCount == 0) return 0;
ex_entity_type type = Ioex::map_exodus_type(entity->type());
return internal_add_results_fields(type, entity, position, m_groupCount[type],
m_truthTable[type], m_variables[type]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ namespace Ioex {

time_t timeLastFlush{0};
int flushInterval{-1};
int m_timestepCount{0};

mutable bool fileExists{false}; // False if file has never been opened/created
mutable bool minimizeOpenFiles{false};
Expand Down
27 changes: 13 additions & 14 deletions packages/seacas/libraries/ioss/src/exodus/Ioex_DatabaseIO.C
Original file line number Diff line number Diff line change
Expand Up @@ -642,13 +642,12 @@ namespace Ioex {
{
bool exists = false;
double last_time = DBL_MAX;
int timestep_count = 0;
std::vector<double> tsteps(0);

if (dbUsage == Ioss::WRITE_HISTORY) {
if (myProcessor == 0) {
timestep_count = ex_inquire_int(get_file_pointer(), EX_INQ_TIME);
if (timestep_count <= 0) {
m_timestepCount = ex_inquire_int(get_file_pointer(), EX_INQ_TIME);
if (m_timestepCount <= 0) {
return;
}

Expand All @@ -657,15 +656,15 @@ namespace Ioex {
// Read the timesteps and add them to the region.
// Since we can't access the Region's stateCount directly, we just add
// all of the steps and assume the Region is dealing with them directly...
tsteps.resize(timestep_count);
tsteps.resize(m_timestepCount);

int error = ex_get_all_times(get_file_pointer(), Data(tsteps));
if (error < 0) {
Ioex::exodus_error(get_file_pointer(), __LINE__, __func__, __FILE__);
}

int max_step = properties.get_optional("APPEND_OUTPUT_AFTER_STEP", timestep_count);
max_step = std::min(max_step, timestep_count);
int max_step = properties.get_optional("APPEND_OUTPUT_AFTER_STEP", m_timestepCount);
max_step = std::min(max_step, m_timestepCount);

double max_time =
properties.get_optional("APPEND_OUTPUT_AFTER_TIME", std::numeric_limits<double>::max());
Expand All @@ -681,12 +680,12 @@ namespace Ioex {
else {
{
Ioss::SerializeIO serializeIO_(this);
timestep_count = ex_inquire_int(get_file_pointer(), EX_INQ_TIME);
m_timestepCount = ex_inquire_int(get_file_pointer(), EX_INQ_TIME);
// Need to sync timestep count across ranks if parallel...
if (isParallel) {
auto min_timestep_count = util().global_minmax(timestep_count, Ioss::ParallelUtils::DO_MIN);
auto min_timestep_count = util().global_minmax(m_timestepCount, Ioss::ParallelUtils::DO_MIN);
if (min_timestep_count == 0) {
auto max_timestep_count = util().global_minmax(timestep_count, Ioss::ParallelUtils::DO_MAX);
auto max_timestep_count = util().global_minmax(m_timestepCount, Ioss::ParallelUtils::DO_MAX);
if (max_timestep_count != 0) {
if (myProcessor == 0) {
// NOTE: Don't want to warn on all processors if the
Expand All @@ -697,16 +696,16 @@ namespace Ioex {
}
}
}
timestep_count = min_timestep_count;
m_timestepCount = min_timestep_count;
}

if (timestep_count <= 0) {
if (m_timestepCount <= 0) {
return;
}

// For an exodus file, timesteps are global and are stored in the region.
// Read the timesteps and add to the region
tsteps.resize(timestep_count, -std::numeric_limits<double>::max());
tsteps.resize(m_timestepCount, -std::numeric_limits<double>::max());

// The `EXODUS_CALL_GET_ALL_TIMES=NO` is typically only used in
// isSerialParallel mode and the client is responsible for
Expand Down Expand Up @@ -752,8 +751,8 @@ namespace Ioex {
// One use case is that job is restarting at a time prior to what has been
// written to the results file, so want to start appending after
// restart time instead of at end time on database.
int max_step = properties.get_optional("APPEND_OUTPUT_AFTER_STEP", timestep_count);
max_step = std::min(max_step, timestep_count);
int max_step = properties.get_optional("APPEND_OUTPUT_AFTER_STEP", m_timestepCount);
max_step = std::min(max_step, m_timestepCount);

double max_time =
properties.get_optional("APPEND_OUTPUT_AFTER_TIME", std::numeric_limits<double>::max());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -793,10 +793,9 @@ namespace Ioex {
Ioex::read_exodus_basis(exoid);
Ioex::read_exodus_quadrature(exoid);

get_elemblocks();

get_step_times_nl();

get_elemblocks();
get_nodeblocks();
get_edgeblocks();
get_faceblocks();
Expand Down Expand Up @@ -922,6 +921,7 @@ namespace Ioex {

{
timestep_count = ex_inquire_int(get_file_pointer(), EX_INQ_TIME);
m_timestepCount = timestep_count;
if (timestep_count <= 0) {
return;
}
Expand Down

0 comments on commit d286b81

Please sign in to comment.