Skip to content

Commit ef8d454

Browse files
authored
Merge pull request #156 compile_warnings_clang
Edits to CHM to remove compiler warnings on Apple Clang 17.0.0 on Intel MacOSX Sequoia 15.7.2
2 parents 5167ac1 + a49af4c commit ef8d454

File tree

14 files changed

+58
-94
lines changed

14 files changed

+58
-94
lines changed

src/core.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323

2424
#include "core.hpp"
2525

26-
#include "mesh/vtk_writer.hpp"
27-
28-
2926
core::core()
3027
{
3128

@@ -2216,11 +2213,16 @@ void core::_determine_module_dep()
22162213
std::string font = "Helvetica";
22172214
int fontsize = 11;
22182215

2219-
std::string edge_str = "E[edgetype == \"%s\"] {\n color=\"/paired12/%i\";\n fontsize=%i;\n fontname=\"%s\"\n }";
22202216
int idx = 1;
22212217
for (const auto& itr : graphviz_vars)
22222218
{
2223-
std::string edge = str_format(edge_str, itr.c_str(), idx, fontsize, font.c_str());
2219+
std::string edge = std::format(
2220+
"E[edgetype = \"{}\"] {{\n color=\"/paired12/{}\";\n fontsize={};\n fontname=\"{}\"\n }}",
2221+
itr,
2222+
idx,
2223+
fontsize,
2224+
font
2225+
);
22242226
idx++;
22252227
gvpr << edge << std::endl;
22262228
}
@@ -2421,7 +2423,8 @@ void core::run()
24212423
ss << _global->posix_time();
24222424

24232425
c.tic();
2424-
size_t chunks = 0;
2426+
// Commented to remove set but not used compiler warnings
2427+
// size_t chunks = 0;
24252428
try
24262429
{
24272430
for (auto &itr : _chunked_modules)
@@ -2466,7 +2469,7 @@ void core::run()
24662469
}
24672470
}
24682471

2469-
chunks++;
2472+
// chunks++;
24702473

24712474
}
24722475
}

src/core.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include <unistd.h> //for getpid
4949
#include <utility> // std::pair
5050
#include <vector>
51+
#include <format>
5152

5253
//boost includes
5354
#include <boost/algorithm/cxx11/any_of.hpp>
@@ -93,13 +94,13 @@ namespace po = boost::program_options;
9394
#include "logger.hpp"
9495
#include "math/coordinates.hpp"
9596
#include "mesh/ugrid_writer.hpp"
97+
#include "mesh/vtk_writer.hpp"
9698
#include "metdata.hpp"
9799
#include "module_base.hpp"
98100
#include "chkpt_op.hpp"
99101
#include "output_info.hpp"
100102
#include "readjson.hpp"
101103
#include "station.hpp"
102-
#include "str_format.h"
103104
#include "timer.hpp"
104105
#include "timeseries/netcdf.hpp"
105106
#include "triangulation.hpp"

src/mesh/triangulation.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ class triangulation
569569
friend class vtk_writer;
570570

571571
triangulation();
572-
~triangulation();
572+
virtual ~triangulation();
573573

574574

575575
/**

src/mesh/ugrid_writer.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
#include "ugrid_writer.hpp"
1818

1919
ugrid_writer::ugrid_writer(mesh m, std::shared_ptr<global> g, bool write_parameters, std::string fname, bool use_zarr):
20-
_mesh(m),
2120
_fname(""),
2221
_store_path(std::move(fname)),
2322
_use_zarr(use_zarr),
23+
_mesh(m),
2424
_global(g),
2525
_write_parameters(write_parameters)
2626
{
@@ -435,7 +435,8 @@ void ugrid_writer::init_ugrid(const std::vector<std::string>& output_variables)
435435
if (status != NC_NOERR)
436436
{
437437
SPDLOG_ERROR("nc_create_par={}", status);
438-
CHM_THROW_EXCEPTION(file_write_error, "Failed to create ugrid output file, error="+status);
438+
std::string err = std::format("Failed to create ugrid output file, error = {}",status);
439+
CHM_THROW_EXCEPTION(file_write_error, err);
439440
}
440441

441442
// We also only have per-rank vertex IDs (they aren't global)

src/mesh/ugrid_writer.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <string>
2525
#include <utility>
2626
#include <cstdint>
27+
#include <format>
2728

2829
#include <boost/mpi.hpp>
2930
#include <boost/optional.hpp>

src/modules/snow_slide.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ void snow_slide::run(mesh& domain)
100100
do
101101
{
102102

103-
int this_iter_moved_snow = false;
103+
// Commented to remove set but not used compiler warning (as well as any uses)
104+
// int this_iter_moved_snow = false;
104105
// Make a vector of pairs (elevation + snowdepth, pointer to face)
105106
tbb::concurrent_vector<std::pair<double, mesh_elem>> sorted_z(domain->size_local_faces());
106107

@@ -197,7 +198,7 @@ void snow_slide::run(mesh& domain)
197198
if ( snowdepthavg > maxDepth)
198199
{
199200
done = 0;
200-
this_iter_moved_snow = true;
201+
// this_iter_moved_snow = true;
201202

202203
double del_depth = snowdepthavg - maxDepth; // Amount to be removed (positive) [m]
203204
double del_swe = swe * (1 - maxDepth / snowdepthavg); // Amount of swe to be removed (positive) [m]
@@ -371,7 +372,7 @@ void snow_slide::run(mesh& domain)
371372

372373
// only do another iteration if we have incoming mass transport from the ghosts or if we have moved mass this itr
373374
// this algorithm tends to need a couple passes to make sure there are no straglers
374-
if(ghost_transport > 0) // || this_iter_moved_snow)
375+
if(ghost_transport > 0) // || this_iter_moved_snow)
375376
done = 0;
376377
else
377378
done = 1;

src/output_info.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ class output_info
4545
{
4646
public:
4747
output_info():
48+
type{output_type::output_type_none},
49+
mesh_output_formats{mesh_outputs::mesh_outputs_none},
4850
name{""},
4951
fname{""},
5052
latitude{0}, longitude{0},
51-
x{0}, y{0}, type{output_type::output_type_none},
52-
mesh_output_formats{mesh_outputs::mesh_outputs_none},
53+
x{0}, y{0},
5354
only_last_n{SIZE_MAX},
5455
write_ghost_neighbors{false}
5556
{
@@ -142,8 +143,8 @@ class output_info
142143
}
143144

144145
output_type type; // the type of output, timeseries or mesh
145-
std::string name;
146146
mesh_outputs mesh_output_formats;
147+
std::string name;
147148
std::string fname;
148149
std::string base_name; // base file name for vtu or ugrid outputs
149150

src/preprocessing/partition/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,12 @@ class preprocessingTriangulation : public triangulation
141141
}
142142
// each processor only knows its own start and end indices
143143
size_t face_start_idx = 0;
144-
size_t face_end_idx = _num_faces_in_partition.at(0) - 1;
144+
// Commented to avoid set but not used compiler warning
145+
// size_t face_end_idx = _num_faces_in_partition.at(0) - 1;
145146
for (int i = 1; i <= _comm_world.rank(); ++i)
146147
{
147148
face_start_idx += _num_faces_in_partition.at(i - 1);
148-
face_end_idx += _num_faces_in_partition.at(i);
149+
// face_end_idx += _num_faces_in_partition.at(i);
149150
}
150151

151152
#pragma omp parallel for

src/utility/gis.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,21 @@ namespace gis
9898

9999
OGRFieldDefn oFieldX("X", OFTReal);
100100
oFieldX.SetWidth(32);
101-
poLayer->CreateField(&oFieldX);
102-
101+
OGRErr err = poLayer->CreateField(&oFieldX);
102+
if (err)
103+
{
104+
std::string msg = std::format("GDAL CreateField error of type {}. See ogr_core.h for meaning.",err);
105+
CHM_THROW_EXCEPTION(chm_error,msg);
106+
}
103107

104108
OGRFieldDefn oFieldY("Y", OFTReal);
105109
oFieldY.SetWidth(32);
106-
poLayer->CreateField(&oFieldY);
107-
110+
err = poLayer->CreateField(&oFieldY);
111+
if (err)
112+
{
113+
std::string msg = std::format("GDAL CreateField error of type {}. See ogr_core.h for meaning.",err);
114+
CHM_THROW_EXCEPTION(chm_error,msg);
115+
}
108116
// double xCoordinates[] = {10.0, 20.0, 30.0}; // Example x coordinates
109117
// double yCoordinates[] = {40.0, 50.0, 60.0}; // Example y coordinates
110118
int numPoints = xy.size();
@@ -135,4 +143,4 @@ namespace gis
135143
GDALClose(poDS);
136144
}
137145

138-
}
146+
}

src/utility/gis.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <vector>
2727
#include <tuple>
2828
#include <string>
29+
#include <format>
2930

3031
#include "exception.hpp"
3132

0 commit comments

Comments
 (0)