Skip to content

Commit

Permalink
Hush more compiler warnings and address some review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tokusanya committed Sep 11, 2024
1 parent 61236e4 commit 2794a19
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 104 deletions.
11 changes: 5 additions & 6 deletions packages/seacas/libraries/ioss/src/Ioss_ChangeSet.C
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ namespace {
int file_exists( const Ioss::ParallelUtils &util,
const std::string& filename,
std::string& message,
bool specifiedDecomp )
bool filePerRank )
{
std::string filenameBase = filename;
const int par_size = util.parallel_size();
const int par_rank = util.parallel_rank();

if( par_size > 1 && !specifiedDecomp ) {
if( par_size > 1 && !filePerRank ) {
filenameBase = Ioss::Utils::decode_filename(filenameBase, par_rank, par_size);
}

Expand Down Expand Up @@ -168,8 +168,8 @@ namespace Ioss {
if(index >= m_changeSetNames.size()) {
std::ostringstream errmsg;
fmt::print(errmsg,
"Invalid change set index {} with a max range of {}\n",
index, m_changeSetNames.size());
"Invalid change set index {} with a max value of {}\n",
index, m_changeSetNames.size()-1);
IOSS_ERROR(errmsg);
}
}
Expand Down Expand Up @@ -216,9 +216,8 @@ namespace Ioss {

db = Ioss::IOFactory::create(dbType, ioDB, usage, util().communicator(),
get_database()->get_property_manager());
int bad_count = 0;
std::string error_message;
bool is_valid_file = db != nullptr && db->ok(false, &error_message, &bad_count);
bool is_valid_file = db != nullptr && db->ok(false, &error_message, nullptr);
if(!is_valid_file) {
delete db;
std::ostringstream errmsg;
Expand Down
10 changes: 3 additions & 7 deletions packages/seacas/libraries/ioss/src/Ioss_ChangeSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@
#include "Ioss_DBUsage.h"
#include "Ioss_Region.h"
#include "Ioss_ParallelUtils.h"
#include "Ioss_PropertyManager.h"

#include <utility>
#include <climits>
#include <cstddef>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <functional>
#include <map>

namespace Ioss {

Expand Down Expand Up @@ -55,6 +52,8 @@ class IOSS_EXPORT ChangeSet {
ChangeSet(Ioss::DatabaseIO* db, const std::string& dbName, const std::string& dbType, unsigned fileCyclicCount);

virtual ~ChangeSet();
ChangeSet() = delete;
ChangeSet(const ChangeSet&) = delete;

IOSS_NODISCARD unsigned supported_formats() const { return m_supportedFormats; }
IOSS_NODISCARD unsigned database_format() const { return m_databaseFormat; }
Expand All @@ -71,9 +70,6 @@ class IOSS_EXPORT ChangeSet {
IOSS_NODISCARD unsigned get_file_cyclic_count() const { return m_fileCyclicCount; }

private:
ChangeSet() = delete;
ChangeSet(const ChangeSet&) = delete;

std::vector<DatabaseIO*> m_changeSetDatabases;

protected:
Expand Down
3 changes: 0 additions & 3 deletions packages/seacas/libraries/ioss/src/Ioss_ChangeSetFactory.C
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,3 @@ Ioss::ChangeSetFactoryMap *Ioss::ChangeSetFactory::registry()
return &registry_;
}

/** \brief Empty method.
*/
void Ioss::ChangeSetFactory::clean() {}
1 change: 0 additions & 1 deletion packages/seacas/libraries/ioss/src/Ioss_ChangeSetFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class IOSS_EXPORT ChangeSetFactory

static int describe(NameList *names);
IOSS_NODISCARD static NameList describe();
static void clean();

static const ChangeSetFactory * factory();

Expand Down
34 changes: 10 additions & 24 deletions packages/seacas/libraries/ioss/src/Ioss_DynamicTopology.C
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@
#include "Ioss_SideSet.h"
#include "Ioss_StructuredBlock.h"

#include <climits>
#include <cstddef>
#include <fmt/core.h>
#include <fmt/format.h>
#include <fmt/ostream.h>
#include <string>

#include <climits>
#include <cstddef>
#include <functional>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <assert.h>

#include "Ioss_ParallelUtils.h"
Expand Down Expand Up @@ -145,7 +143,6 @@ bool file_exists(const Ioss::ParallelUtils &util,
const std::string &db_type,
Ioss::DatabaseUsage db_usage)
{
bool exists = false;
int par_size = util.parallel_size();
int par_rank = util.parallel_rank();
bool is_parallel = par_size > 1;
Expand All @@ -156,28 +153,17 @@ bool file_exists(const Ioss::ParallelUtils &util,
full_filename = Ioss::Utils::decode_filename(filename, par_rank, par_size);
}

if (!is_parallel || par_rank == 0) {
// Now, see if this file exists...
// Don't want to do a system call on all processors since it can take minutes
// on some of the larger machines, filesystems, and processor counts...
Ioss::FileInfo file = Ioss::FileInfo(full_filename);
exists = file.exists();
}

if (is_parallel) {
int iexists = exists ? 1 : 0;
util.broadcast(iexists, 0);
exists = iexists == 1;
}
return exists;
std::string message;
Ioss::FileInfo file = Ioss::FileInfo(full_filename);
return file.parallel_exists(util.communicator(), message);
}

}


namespace Ioss {

void DynamicTopologyObserver::check_region() const
void DynamicTopologyObserver::verify_region_is_registered() const
{
if(nullptr == m_region) {
std::ostringstream errmsg;
Expand Down Expand Up @@ -265,13 +251,13 @@ bool DynamicTopologyObserver::is_topology_modified() const

const ParallelUtils &DynamicTopologyObserver::util() const
{
check_region();
verify_region_is_registered();
return m_region->get_database()->util();
}

void DynamicTopologyObserver::synchronize_topology_modified_flags()
{
check_region();
verify_region_is_registered();
int num_processors = m_region->get_database()->parallel_size();
// Synchronize the topology flags between all processors in case
// it has not been set consistently.
Expand All @@ -289,7 +275,7 @@ void DynamicTopologyObserver::synchronize_topology_modified_flags()

int DynamicTopologyObserver::get_cumulative_topology_modification_field()
{
check_region();
verify_region_is_registered();
const std::string variable_name = topology_modification_change_name();

int ivalue = 0;
Expand Down
19 changes: 10 additions & 9 deletions packages/seacas/libraries/ioss/src/Ioss_DynamicTopology.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,15 @@
#include "Ioss_DatabaseIO.h" // for DatabaseIO
#include "Ioss_ParallelUtils.h" // for ParallelUtils
#include "Ioss_PropertyManager.h" // for PropertyManager
#include <assert.h>
#include <cstddef> // for size_t, nullptr
#include <cstdint> // for int64_t

#include "Ioss_CodeTypes.h"
#include "Ioss_Utils.h"
#include "ioss_export.h"

#include <iosfwd> // for ostream
#include <cstddef> // for size_t, nullptr
#include <cstdint> // for int64_t
#include <iomanip>
#include <sstream>
#include <string> // for string, operator<
#include <strings.h>

namespace Ioss {
class Region;
Expand Down Expand Up @@ -111,7 +108,7 @@ namespace Ioss {

DynamicTopologyNotifier *m_notifier{nullptr};

void check_region() const;
void verify_region_is_registered() const;
IOSS_NODISCARD const ParallelUtils &util() const;
void synchronize_topology_modified_flags();

Expand Down Expand Up @@ -230,6 +227,10 @@ namespace Ioss {

static std::string get_internal_file_change_set_name(unsigned int step);

unsigned int get_topology_change_count() const { return m_dbChangeCount; }
unsigned int get_file_cyclic_count() const { return m_fileCyclicCount; }
IfDatabaseExistsBehavior get_if_database_exists_behavior() const { return m_ifDatabaseExists; }

private:
Region *m_region{nullptr};
std::string m_ioDB;
Expand All @@ -238,8 +239,8 @@ namespace Ioss {
PropertyManager m_properties;

unsigned int m_fileCyclicCount;
IfDatabaseExistsBehavior &m_ifDatabaseExists;
unsigned int &m_dbChangeCount;
IfDatabaseExistsBehavior m_ifDatabaseExists;
unsigned int m_dbChangeCount;

IOSS_NODISCARD const ParallelUtils &util() const;

Expand Down
32 changes: 17 additions & 15 deletions packages/seacas/libraries/ioss/src/Ioss_Region.C
Original file line number Diff line number Diff line change
Expand Up @@ -2900,6 +2900,10 @@ namespace Ioss {
DynamicTopologyFileControl fileControl(this, fileCyclicCount, ifDatabaseExists,
dbChangeCount);
fileControl.add_output_database_change_set(state);

// Reset based on fileControl values
dbChangeCount = fileControl.get_topology_change_count();
ifDatabaseExists = fileControl.get_if_database_exists_behavior();
}
}

Expand Down Expand Up @@ -2939,6 +2943,10 @@ namespace Ioss {
DynamicTopologyFileControl fileControl(this, fileCyclicCount, ifDatabaseExists,
dbChangeCount);
fileControl.clone_and_replace_output_database(state);

// Reset based on fileControl values
dbChangeCount = fileControl.get_topology_change_count();
ifDatabaseExists = fileControl.get_if_database_exists_behavior();
}
}

Expand Down Expand Up @@ -3048,11 +3056,9 @@ namespace Ioss {

std::tuple<std::string, int, double> Region::locate_db_state(double targetTime) const
{
IfDatabaseExistsBehavior ifDatabaseExists{Ioss::DB_OVERWRITE};
unsigned int dbChangeCount{1};

DynamicTopologyFileControl fileControl(const_cast<Region*>(this), get_file_cyclic_count(),
ifDatabaseExists, dbChangeCount);
auto *cregion = const_cast<Region*>(this);
DynamicTopologyFileControl fileControl(cregion, get_file_cyclic_count(),
cregion->ifDatabaseExists, cregion->dbChangeCount);

return fileControl.locate_db_state(targetTime);
}
Expand All @@ -3065,11 +3071,9 @@ namespace Ioss {
return std::make_tuple(get_internal_change_set_name(), currentState, stateTimes[0]);
}

IfDatabaseExistsBehavior ifDatabaseExists{Ioss::DB_OVERWRITE};
unsigned int dbChangeCount{1};

DynamicTopologyFileControl fileControl(const_cast<Region*>(this), get_file_cyclic_count(),
ifDatabaseExists, dbChangeCount);
auto *cregion = const_cast<Region*>(this);
DynamicTopologyFileControl fileControl(cregion, get_file_cyclic_count(),
cregion->ifDatabaseExists, cregion->dbChangeCount);

return fileControl.get_db_max_time();
}
Expand All @@ -3082,11 +3086,9 @@ namespace Ioss {
return std::make_tuple(get_internal_change_set_name(), currentState, stateTimes[0]);
}

IfDatabaseExistsBehavior ifDatabaseExists{Ioss::DB_OVERWRITE};
unsigned int dbChangeCount{1};

DynamicTopologyFileControl fileControl(const_cast<Region*>(this), get_file_cyclic_count(),
ifDatabaseExists, dbChangeCount);
auto *cregion = const_cast<Region*>(this);
DynamicTopologyFileControl fileControl(cregion, get_file_cyclic_count(),
cregion->ifDatabaseExists, cregion->dbChangeCount);

return fileControl.get_db_min_time();
}
Expand Down
Loading

0 comments on commit 2794a19

Please sign in to comment.