From 4627f76a0def07894c379967e6dce32d636f34fb Mon Sep 17 00:00:00 2001 From: Michael Uleysky Date: Fri, 15 Mar 2024 12:53:34 +1000 Subject: [PATCH] Update michlib, fix errors and warnings --- CMakeLists.txt | 9 ++++++++- actions/actiongenintfile.h | 4 ++-- actions/actionint.h | 6 +++--- include/actiondep.h | 4 ++-- include/layereddata.h | 2 +- michlib | 2 +- sources/AVISOLOCAL.h | 2 +- sources/BINFILE.h | 2 +- sources/VYLET.cpp | 10 +++++----- 9 files changed, 24 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c9c3e3d..325d14e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) include_directories(include sources sources-add GSW-C) -add_compile_options(-Wall) +add_compile_options(-Wall -Wno-deprecated-declarations) # Dwarf-4 support check include(CheckCXXCompilerFlag) @@ -54,6 +54,13 @@ if(COMPILER_SUPPORTS_ANALYZER AND STATIC_ANALYZER) add_compile_options(-fanalyzer) endif() +# Disable michlib warnings +add_compile_options(-Wno-deprecated-declarations) +CHECK_CXX_COMPILER_FLAG(-Wno-class-memaccess COMPILER_SUPPORTS_CLASSMEMACCESS) +if(COMPILER_SUPPORTS_CLASSMEMACCESS) + add_compile_options(-Wno-class-memaccess) +endif() + add_library(teos STATIC GSW-C/gsw_oceanographic_toolbox.c GSW-C/gsw_saar.c) set_target_properties(teos PROPERTIES LINKER_LANGUAGE C) diff --git a/actions/actiongenintfile.h b/actions/actiongenintfile.h index 0ddedcf..48a3f49 100644 --- a/actions/actiongenintfile.h +++ b/actions/actiongenintfile.h @@ -69,7 +69,7 @@ template MString ActionGenIntFile::DoAction(const CLArgs& args, D& ds) fw.SetParameter("dx", data.XStep() * 60.0); fw.SetParameter("dy", data.YStep() * 60.0); fw.SetParameter("nt", tindexes.size()); - fw.SetParameter("dt", (ds.Time(tindexes[1]) - ds.Time(tindexes[0])) / 86400.0); + fw.SetParameter("dt", (ds.Time(tindexes[1]) - ds.Time(tindexes[0])).D()); fw.SetParameter("FillValue", data.Fillval()); fw.UsePrefix("Info"); fw.SetParameter("Mode", mode ? "from ssh" : "normal"); @@ -92,7 +92,7 @@ template MString ActionGenIntFile::DoAction(const CLArgs& args, D& ds) fw.SetParameter("dotxdotylonlat2v", "(1.852/0.864)*%doty"); fw.SetParameter("BeginDate", ds.Time(tindexes.front()).ToTString()); fw.SetParameter("EndDate", ds.Time(tindexes.back()).ToTString()); - fw.SetParameter("Timestep", ds.Time(tindexes[1]) - ds.Time(tindexes[0])); + fw.SetParameter("Timestep", (ds.Time(tindexes[1]) - ds.Time(tindexes[0])).Seconds()); fw.SetParameter("DataID", michlib::UniqueId()); fw.SetParameter("Creation command", args.at("_cmdline")); } diff --git a/actions/actionint.h b/actions/actionint.h index ccca732..7d6eb4c 100644 --- a/actions/actionint.h +++ b/actions/actionint.h @@ -187,9 +187,9 @@ template MString ActionINT::DoAction(const CLArgs& args, D& ds) for(size_t j = 0; j < temp.size(); j++) hi.emplace_back(std::move(temp[j])); } } - auto step = ds.Time(hiind) - ds.Time(loind); - auto delta = points[i].t - ds.Time(loind); - real trel = static_cast(delta) / static_cast(step); + auto step = (ds.Time(hiind) - ds.Time(loind)).S(); + auto delta = (points[i].t - ds.Time(loind)).S(); + real trel = delta / step; fw.Write(points[i].lon0); fw.Write(points[i].lat0); diff --git a/include/actiondep.h b/include/actiondep.h index 27fc75d..d7c1df6 100644 --- a/include/actiondep.h +++ b/include/actiondep.h @@ -41,13 +41,13 @@ struct TimeData for(size_t i = 0; i < steps.size(); i++) { auto delta = data.Time(tindexes[i]) - refdate; - while(delta % stepunits[unitind] != 0) unitind++; + while(delta.Seconds() % stepunits[unitind] != 0) unitind++; } for(size_t i = 0; i < steps.size(); i++) { auto delta = data.Time(tindexes[i]) - refdate; - steps[i] = michlib::int_cast(delta / stepunits[unitind]); + steps[i] = michlib::int_cast(delta.Seconds() / stepunits[unitind]); } } diff --git a/include/layereddata.h b/include/layereddata.h index 7d8919d..0fdbd0f 100644 --- a/include/layereddata.h +++ b/include/layereddata.h @@ -162,7 +162,7 @@ class LayeredData: public NCFuncs return times[i]; } - time_t Timestep() const { return isOk() ? (times[1] - times[0]) : 0; } + time_t Timestep() const { return isOk() ? (times[1] - times[0]).Seconds() : 0; } MString Title() const { return title; } diff --git a/michlib b/michlib index e288290..1b673a0 160000 --- a/michlib +++ b/michlib @@ -1 +1 @@ -Subproject commit e2882902b88229bb4b0e6fbeb76c79ac6d46d53d +Subproject commit 1b673a0202011d06323f8aebaa7ee58cbc7b0649 diff --git a/sources/AVISOLOCAL.h b/sources/AVISOLOCAL.h index 76f7d5f..80ff270 100644 --- a/sources/AVISOLOCAL.h +++ b/sources/AVISOLOCAL.h @@ -49,7 +49,7 @@ class AVISOLOCALData: public NCFuncs return times[i]; } - time_t Timestep() const { return isOk() ? (times[1] - times[0]) : 0; } + time_t Timestep() const { return isOk() ? (times[1] - times[0]).Seconds() : 0; } explicit operator bool() const { return times.size() > 0; } diff --git a/sources/BINFILE.h b/sources/BINFILE.h index eb3cc18..7e9e0e8 100644 --- a/sources/BINFILE.h +++ b/sources/BINFILE.h @@ -38,7 +38,7 @@ class BINFILEData return times[i]; } - time_t Timestep() const { return isOk() ? (times[1] - times[0]) : 0; } + time_t Timestep() const { return isOk() ? (times[1] - times[0]).Seconds() : 0; } explicit operator bool() const { return times.size() > 0; } diff --git a/sources/VYLET.cpp b/sources/VYLET.cpp index 2d4e5b6..e0a421e 100644 --- a/sources/VYLET.cpp +++ b/sources/VYLET.cpp @@ -258,7 +258,7 @@ VYLETData::Data VYLETData::ReadL() const { time = R2Time((*vylet)[tcol - 1][iy * lons.size() + ix]); lambda = (*vylet)[lcol - 1][iy * lons.size() + ix]; - days = static_cast(time - start) / MDateTime::secondsperday; + days = (time - start).D(); out(ix, iy) = lambda / days; } @@ -284,7 +284,7 @@ VYLETData::Data VYLETData::ReadT() const const real acc = vylet->ParameterRValue("accuracy", 1.0); const real tstep = 2.0 * M_PI * 1000.0 / acc; - const real maxdays = static_cast(end - start) / MDateTime::secondsperday; + const real maxdays = (end - start).D(); MDateTime time; real days; @@ -297,7 +297,7 @@ VYLETData::Data VYLETData::ReadT() const x = (*vylet)[2][iy * lons.size() + ix]; y = (*vylet)[3][iy * lons.size() + ix]; time = R2Time((*vylet)[tcol - 1][iy * lons.size() + ix]); - days = static_cast(time - start) / MDateTime::secondsperday; + days = (time - start).D(); if(days <= tstep * 1.5) days = 0.0; inside = x > xl && x < xr && y > yd && y < yu; maxtime = days >= maxdays - tstep * 0.5; @@ -505,7 +505,7 @@ VYLETData::Data VYLETData::ReadTmask() const const real acc = vylet->ParameterRValue("accuracy", 1.0); const real tstep = 2.0 * M_PI * 1000.0 / acc; - const real maxdays = static_cast(end - start) / MDateTime::secondsperday; + const real maxdays = (end - start).D(); MDateTime time; real days; @@ -515,7 +515,7 @@ VYLETData::Data VYLETData::ReadTmask() const for(size_t ix = 0; ix < lons.size(); ix++) { time = R2Time((*vylet)[tcol - 1][iy * lons.size() + ix]); - days = static_cast(time - start) / MDateTime::secondsperday; + days = (time - start).D(); maxtime = days >= maxdays - tstep * 0.5; out(ix, iy) = maxtime ? 1.0 : NAN; }