Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/compiler warnings #110

Merged
merged 11 commits into from
Jan 31, 2022
20 changes: 18 additions & 2 deletions cmake/SetupSpheral.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ include(ExternalProject)
# Configure CMake
#-------------------------------------------------------------------------------
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undefined-var-template")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wno-missing-include-dirs") # -Wno-undefined-var-template
set(CMAKE_EXPORT_COMPILE_COMMANDS On)

if (NOT CMAKE_MODULE_PATH)
Expand All @@ -24,10 +24,26 @@ message("-- compiler warnings ${ENABLE_WARNINGS}")

option(ENABLE_UNUSED_VARIABLE_WARNINGS "show unused variable compiler warnings" ON)
if (NOT ENABLE_UNUSED_VARIABLE_WARNINGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable -Wno-unused-parameter")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable")
endif()
message("-- compiler unused variable warnings ${ENABLE_UNUSED_VARIABLE_WARNINGS}")

option(ENABLE_WARNINGS_AS_ERRORS "make warnings errors" OFF)
if (ENABLE_WARNINGS_AS_ERRORS)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(CXX_WARNING_FLAGS /W4 /WX)
else()
set(CXX_WARNING_FLAGS -Wall -Wextra -pedantic -Werror -Wl,--fatal-warnings)
endif()
add_compile_options(${CXX_WARNING_FLAGS})
message("-- treating warnings as errors with compile flags ${CXX_WARNING_FLAGS}")
endif()

# We build some Fortran code from outside sources (like the Helmholtz EOS) that
# cause building errors if the compiler is too picky...
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -w")
message("-- Fortran flags: ${CMAKE_Fortran_FLAGS}")

#-------------------------------------------------------------------------------
# Configure and Include blt
#-------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions cmake/spheral/SpheralAddLibs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ function(spheral_add_pybind11_library package_name)
)
add_dependencies(${MODULE_NAME} ${spheral_py_depends} ${spheral_depends})
target_compile_options(${MODULE_NAME} PRIVATE
"-Wno-error"
"-Wno-unused-local-typedefs"
"-Wno-self-assign-overloaded"
"-Wno-overloaded-virtual"
Expand Down
5 changes: 4 additions & 1 deletion cmake/spheral/SpheralHandleTPL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ function(Spheral_Handle_TPL lib_name dep_list)
# Include the actual <tpl>.cmake file
include(${TPL_CMAKE_DIR}/${lib_name}.cmake)

list(APPEND ${lib_name}_INCLUDES $<BUILD_INTERFACE:${${lib_name}_DIR}/include>)
if (NOT DEFINED ${lib_name}_NO_INCLUDES)
list(APPEND ${lib_name}_INCLUDES $<BUILD_INTERFACE:${${lib_name}_DIR}/include>)
#message("-- including path ${lib_name} : ${lib_name}_INCLUDES")
endif()

# Generate full path to lib file for output list
set(${lib_name}_LIBRARIES )
Expand Down
1 change: 1 addition & 0 deletions cmake/tpl/aneos.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set(ANEOS_SRC_DIR "${ANEOS_PREFIX}/src/aneos/src")
set(ANEOS_DEST_DIR "${${lib_name}_DIR}/lib")
set(ANEOS_INPUT_SRC_DIR "${ANEOS_PREFIX}/src/aneos/input")
set(ANEOS_INPUT_DEST_DIR "${${lib_name}_DIR}/input")
set(ANEOS_NO_INCLUDES On) # ANEOS does not produce any include header files

#set(${lib_name}_INCLUDES aneos.h)
set(${lib_name}_libs libaneos.a)
Expand Down
10 changes: 5 additions & 5 deletions src/FSISPH/SlideSurface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ isSlideSurface(const int nodeListi,
const int nodeListj) const {
const auto oneDimIndex = mNumNodeLists * nodeListi + nodeListj;
return mIsSlideSurface[oneDimIndex];
};
}

//------------------------------------------------------------------------------
// return correction factor [0,1] for the artificial viscosity pressure
Expand Down Expand Up @@ -206,7 +206,7 @@ const auto& connectivityMap = dataBase.connectivityMap();



};
}


//------------------------------------------------------------------------------
Expand All @@ -223,7 +223,7 @@ registerState(DataBase<Dimension>& dataBase,
state.enroll(mSurfaceNormals);
state.enroll(mSurfaceFraction);
state.enroll(mSurfaceSmoothness);
};
}


//------------------------------------------------------------------------------
Expand All @@ -238,7 +238,7 @@ registerState(DataBase<Dimension>& dataBase,
// const typename Dimension::Scalar /*currentTime*/) const{

// return make_pair(std::numeric_limits<double>::max(), this->label());
// };
// }



Expand Down Expand Up @@ -270,4 +270,4 @@ registerState(DataBase<Dimension>& dataBase,
// restoreState(const FileIO& /*file*/,
// const std::string& /*pathName*/){};

}
}
2 changes: 1 addition & 1 deletion src/Field/FieldListInline.hh
Original file line number Diff line number Diff line change
Expand Up @@ -1848,7 +1848,7 @@ operator*(const FieldList<Dimension, DataType>& lhs,
REQUIRE(lhs.numFields() == rhs.numFields());
FieldList<Dimension, typename CombineTypes<DataType, OtherDataType>::ProductType> result;
result.copyFields();
for (int i = 0; i < lhs.numFields(); ++i) {
for (auto i = 0u; i < lhs.numFields(); ++i) {
CHECK2(lhs[i]->nodeListPtr() == rhs[i]->nodeListPtr(), lhs[i]->nodeListPtr()->name() << " != " << rhs[i]->nodeListPtr()->name());
result.appendField((*(lhs[i])) * (*(rhs[i])));
}
Expand Down
9 changes: 3 additions & 6 deletions src/FileIO/SiloFileIO.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,11 @@ void readInt(DBfile* filePtr, int& value, const string pathName) {
//------------------------------------------------------------------------------
void writeString(DBfile* filePtr, const string& value, const string pathName) {
const int size = value.size();
char cvalue[size];
std::copy(value.begin(), value.end(), cvalue);
//cvalue[size] = '\0';
int dims[1] = {size};
writeInt(filePtr, dims[0], pathName + "/size");
if (dims[0] > 0) {
const string varname = setdir(filePtr, pathName + "/value");
VERIFY2(DBWrite(filePtr, varname.c_str(), cvalue, dims, 1, DB_CHAR) == 0,
VERIFY2(DBWrite(filePtr, varname.c_str(), value.c_str(), dims, 1, DB_CHAR) == 0,
"SiloFileIO ERROR: unable to write string variable " << pathName);
}
}
Expand All @@ -125,9 +122,9 @@ void readString(DBfile* filePtr, string& value, const string pathName) {
if (valsize == 0) {
value = "";
} else {
char cvalue[valsize + 1]; // Do we need to allow space for trailing null?
std::vector<char> cvalue(valsize + 1); // Do we need to allow space for trailing null?
const string varname = setdir(filePtr, pathName + "/value");
VERIFY2(DBReadVar(filePtr, varname.c_str(), cvalue) == 0,
VERIFY2(DBReadVar(filePtr, varname.c_str(), &cvalue[0]) == 0,
"SiloFileIO ERROR: failed to read string variable " << pathName);
value = string(&cvalue[0], &cvalue[valsize]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Neighbor/NestedGridNeighbor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public:
std::vector<int>& coarseNeighbors) const override;

// Reassign the grid cell info for a given set of nodes.
virtual void updateNodes() override;;
virtual void updateNodes() override;
virtual void updateNodes(const std::vector<int>& nodeIDs) override;

// Function to determine the appropriate gridlevel for a node.
Expand Down
2 changes: 1 addition & 1 deletion src/Neighbor/NodePairList.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Spheral {
NodePairIdxType::NodePairIdxType(int i_n, int i_l, int j_n, int j_l, double f) :
i_node(i_n), i_list(i_l), j_node(j_n), j_list(j_l), f_couple(f) {}

NodePairList::NodePairList(){};
NodePairList::NodePairList(){}

void NodePairList::push_back(NodePairIdxType nodePair) {
mNodePairList.push_back(nodePair);
Expand Down
9 changes: 5 additions & 4 deletions src/Utilities/SidreDataCollectionInline.hh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//SidreDataCollectionInLine.hh
#include "axom/sidre.hpp"
#include "Field/Field.hh"
#include <vector>

namespace Spheral
{
Expand Down Expand Up @@ -166,7 +167,7 @@ axom::sidre::Group *SidreDataCollection::sidreStoreField(const std::string &view
axom::IndexType num_elements = DataTypeTraits<DataType>::numElements(field[0]);
int view_count = 0;

double data [num_elements];
std::vector<double> data(num_elements);
for (u_int i = 0; i < field.size(); ++i)
{
int index = 0;
Expand All @@ -176,7 +177,7 @@ axom::sidre::Group *SidreDataCollection::sidreStoreField(const std::string &view
index++;
}
axom::sidre::Buffer* buff = m_datastore_ptr->createBuffer()->allocate(dtype, num_elements)
->copyBytesIntoBuffer(data, sizeof(double) * num_elements);
->copyBytesIntoBuffer(&data[0], sizeof(double) * num_elements);
wholeField->createView(view_name + std::to_string(view_count), dtype, num_elements, buff);
view_count++;
}
Expand All @@ -194,7 +195,7 @@ axom::sidre::Group *SidreDataCollection::sidreStoreField(const std::string &view
axom::IndexType num_elements = DataTypeTraits<Dim<2>::Vector>::numElements(field[0]);
int view_count = 0;

double data [num_elements];
std::vector<double> data(num_elements);
for (u_int i = 0; i < field.size(); ++i)
{
int index = 0;
Expand All @@ -204,7 +205,7 @@ axom::sidre::Group *SidreDataCollection::sidreStoreField(const std::string &view
index++;
}
axom::sidre::Buffer* buff = m_datastore_ptr->createBuffer()->allocate(dtype, num_elements)
->copyBytesIntoBuffer(data, sizeof(double) * num_elements);
->copyBytesIntoBuffer(&data[0], sizeof(double) * num_elements);
wholeField->createView(view_name + std::to_string(view_count), dtype, num_elements, buff);
view_count++;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Utilities/lineSegmentIntersections.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace bg = boost::geometry;

BOOST_GEOMETRY_REGISTER_POINT_2D_GET_SET(Spheral::Dim<2>::Vector, double, bg::cs::cartesian,
Spheral::Dim<2>::Vector::x, Spheral::Dim<2>::Vector::y,
Spheral::Dim<2>::Vector::x, Spheral::Dim<2>::Vector::y);
Spheral::Dim<2>::Vector::x, Spheral::Dim<2>::Vector::y)

using std::vector;
using std::string;
Expand Down
8 changes: 4 additions & 4 deletions src/Utilities/refinePolyhedron.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ GeomPolyhedron refinePolyhedron(const GeomPolyhedron& poly0,
const unsigned numVertices0 = verts0.size();
const unsigned numFaces0 = facetVerts0.size();
// float g_verts[numVertices0][3];
int g_vertsperface[numFaces0];
vector<int> g_vertsperface(numFaces0);
unsigned vertsPerFaceSum = 0;
{
// for (unsigned i = 0; i != numVertices0; ++i) {
Expand All @@ -121,7 +121,7 @@ GeomPolyhedron refinePolyhedron(const GeomPolyhedron& poly0,
vertsPerFaceSum += facetVerts0[i].size();
}
}
int g_vertIndices[vertsPerFaceSum];
vector<int> g_vertIndices(vertsPerFaceSum);
{
unsigned j = 0;
for (const auto& inds: facetVerts0) {
Expand Down Expand Up @@ -161,8 +161,8 @@ GeomPolyhedron refinePolyhedron(const GeomPolyhedron& poly0,
Descriptor desc;
desc.numVertices = numVertices0;
desc.numFaces = numFaces0;
desc.numVertsPerFace = g_vertsperface;
desc.vertIndicesPerFace = g_vertIndices;
desc.numVertsPerFace = &g_vertsperface[0];
desc.vertIndicesPerFace = &g_vertIndices[0];

// Instantiate a FarTopologyRefiner from the descriptor
Far::TopologyRefiner * refiner = Far::TopologyRefinerFactory<Descriptor>::Create(desc,
Expand Down