diff --git a/alg/teca_evaluate_expression.cxx b/alg/teca_evaluate_expression.cxx index c18b3898c..4a1948321 100644 --- a/alg/teca_evaluate_expression.cxx +++ b/alg/teca_evaluate_expression.cxx @@ -18,7 +18,7 @@ #include #endif #if defined(TECA_HAS_UDUNITS) -#include "calcalcs.h" +#include "teca_calcalcs.h" #endif #if defined(TECA_HAS_MPI) #include diff --git a/alg/teca_table_calendar.cxx b/alg/teca_table_calendar.cxx index 8875efb23..57f5ef945 100644 --- a/alg/teca_table_calendar.cxx +++ b/alg/teca_table_calendar.cxx @@ -16,7 +16,7 @@ #include #endif #if defined(TECA_HAS_UDUNITS) -#include "calcalcs.h" +#include "teca_calcalcs.h" #endif #if defined(TECA_HAS_MPI) #include @@ -274,7 +274,7 @@ const_p_teca_dataset teca_table_calendar::execute( int curr_minute = 0; double curr_second = 0; - if (calcalcs::date(curr_time[i], &curr_year, &curr_month, + if (teca_calcalcs::date(curr_time[i], &curr_year, &curr_month, &curr_day, &curr_hour, &curr_minute, &curr_second, units.c_str(), calendar.c_str())) { diff --git a/alg/teca_table_region_mask.cxx b/alg/teca_table_region_mask.cxx index 260450b96..75bbc37a8 100644 --- a/alg/teca_table_region_mask.cxx +++ b/alg/teca_table_region_mask.cxx @@ -17,7 +17,7 @@ #include #endif #if defined(TECA_HAS_UDUNITS) -#include "calcalcs.h" +#include "teca_calcalcs.h" #endif #if defined(TECA_HAS_MPI) #include diff --git a/alg/teca_table_remove_rows.cxx b/alg/teca_table_remove_rows.cxx index 9ead8eff6..6840f8641 100644 --- a/alg/teca_table_remove_rows.cxx +++ b/alg/teca_table_remove_rows.cxx @@ -17,7 +17,7 @@ #include #endif #if defined(TECA_HAS_UDUNITS) -#include "calcalcs.h" +#include "teca_calcalcs.h" #endif #if defined(TECA_HAS_MPI) #include diff --git a/alg/teca_tc_classify.cxx b/alg/teca_tc_classify.cxx index 73d4a5401..503c58100 100644 --- a/alg/teca_tc_classify.cxx +++ b/alg/teca_tc_classify.cxx @@ -17,7 +17,7 @@ #include #endif #if defined(TECA_HAS_UDUNITS) -#include "calcalcs.h" +#include "teca_calcalcs.h" #endif #if defined(TECA_HAS_MPI) #include diff --git a/apps/teca_bayesian_ar_detect.cpp b/apps/teca_bayesian_ar_detect.cpp index 1244640ed..9d11971ce 100644 --- a/apps/teca_bayesian_ar_detect.cpp +++ b/apps/teca_bayesian_ar_detect.cpp @@ -22,7 +22,7 @@ #include "teca_table.h" #include "teca_dataset_source.h" #include "teca_app_util.h" -#include "calcalcs.h" +#include "teca_calcalcs.h" #include #include diff --git a/apps/teca_cf_restripe.cpp b/apps/teca_cf_restripe.cpp index 1c2bc017b..ae2496a9e 100644 --- a/apps/teca_cf_restripe.cpp +++ b/apps/teca_cf_restripe.cpp @@ -17,7 +17,7 @@ #include "teca_mpi_manager.h" #include "teca_mpi.h" #include "teca_app_util.h" -#include "calcalcs.h" +#include "teca_calcalcs.h" #include #include diff --git a/apps/teca_integrated_vapor_transport.cpp b/apps/teca_integrated_vapor_transport.cpp index f127f9173..b8b0d89eb 100644 --- a/apps/teca_integrated_vapor_transport.cpp +++ b/apps/teca_integrated_vapor_transport.cpp @@ -20,7 +20,7 @@ #include "teca_table.h" #include "teca_dataset_source.h" #include "teca_app_util.h" -#include "calcalcs.h" +#include "teca_calcalcs.h" #include #include diff --git a/apps/teca_integrated_water_vapor.cpp b/apps/teca_integrated_water_vapor.cpp index 90c38e41f..405a83aa2 100644 --- a/apps/teca_integrated_water_vapor.cpp +++ b/apps/teca_integrated_water_vapor.cpp @@ -20,7 +20,7 @@ #include "teca_table.h" #include "teca_dataset_source.h" #include "teca_app_util.h" -#include "calcalcs.h" +#include "teca_calcalcs.h" #include #include diff --git a/apps/teca_metadata_probe.cpp b/apps/teca_metadata_probe.cpp index e607b3be1..76d87fda8 100644 --- a/apps/teca_metadata_probe.cpp +++ b/apps/teca_metadata_probe.cpp @@ -12,7 +12,7 @@ #include "teca_app_util.h" #if defined(TECA_HAS_UDUNITS) -#include "calcalcs.h" +#include "teca_calcalcs.h" #endif #include @@ -258,7 +258,7 @@ int main(int argc, char **argv) int Y = 0, M = 0, D = 0, h = 0, m = 0; double s = 0; #if defined(TECA_HAS_UDUNITS) - if (calcalcs::date(time->get(i0), &Y, &M, &D, &h, &m, &s, + if (teca_calcalcs::date(time->get(i0), &Y, &M, &D, &h, &m, &s, units.c_str(), calendar.c_str())) { TECA_ERROR("failed to detmine the first available time in the file") @@ -274,7 +274,7 @@ int main(int argc, char **argv) // human readbale last time available Y = 0, M = 0, D = 0, h = 0, m = 0, s = 0; #if defined(TECA_HAS_UDUNITS) - if (calcalcs::date(time->get(i1), &Y, &M, &D, &h, &m, &s, + if (teca_calcalcs::date(time->get(i1), &Y, &M, &D, &h, &m, &s, units.c_str(), calendar.c_str())) { TECA_ERROR("failed to detmine the last available time in the file") diff --git a/apps/teca_tc_detect.cpp b/apps/teca_tc_detect.cpp index 12fa52d93..8171d27eb 100644 --- a/apps/teca_tc_detect.cpp +++ b/apps/teca_tc_detect.cpp @@ -19,7 +19,7 @@ #include "teca_mpi_manager.h" #include "teca_coordinate_util.h" #include "teca_app_util.h" -#include "calcalcs.h" +#include "teca_calcalcs.h" #include #include diff --git a/apps/teca_tc_trajectory.cpp b/apps/teca_tc_trajectory.cpp index cc9e84eb4..a7a945b98 100644 --- a/apps/teca_tc_trajectory.cpp +++ b/apps/teca_tc_trajectory.cpp @@ -16,7 +16,7 @@ #include "teca_table_writer.h" #include "teca_mpi_manager.h" #include "teca_coordinate_util.h" -#include "calcalcs.h" +#include "teca_calcalcs.h" #include "teca_app_util.h" #include diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index b787bad22..c1251e2db 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -44,7 +44,7 @@ endif() if (TECA_HAS_UDUNITS) include_directories(SYSTEM ${UDUNITS_INCLUDE_DIR}) list(APPEND teca_core_link ${UDUNITS_LIBRARY}) - list(APPEND teca_core_srcs calcalcs.cxx) + list(APPEND teca_core_srcs teca_calcalcs.cxx) endif() list(APPEND teca_core_link pthread) diff --git a/core/calcalcs.cxx b/core/teca_calcalcs.cxx similarity index 99% rename from core/calcalcs.cxx rename to core/teca_calcalcs.cxx index d76612055..1e93e8cad 100644 --- a/core/calcalcs.cxx +++ b/core/teca_calcalcs.cxx @@ -1,4 +1,7 @@ /* +A threadsafe port of the calcalcs library +Burlen Loring Thu Apr 22 06:22:16 PM PDT 2021 + The CalCalcs routines, a set of C-language routines to perform calendar calculations. @@ -35,9 +38,9 @@ along with this program. If not, see . #endif #include "udunits2.h" -#include "calcalcs.h" +#include "teca_calcalcs.h" -namespace calcalcs +namespace teca_calcalcs { static int c_isleap_gregorian ( int year, int *leap ); diff --git a/core/calcalcs.h b/core/teca_calcalcs.h similarity index 99% rename from core/calcalcs.h rename to core/teca_calcalcs.h index 63568d644..4c837fb7c 100644 --- a/core/calcalcs.h +++ b/core/teca_calcalcs.h @@ -1,4 +1,7 @@ /* +A threadsafe port of the calcalcs library +Burlen Loring Thu Apr 22 06:22:16 PM PDT 2021 + The CalCalcs routines, a set of C-language routines to perform calendar calculations. @@ -28,7 +31,7 @@ along with this program. If not, see . /// A threadsafe port of the calcalcs library. -namespace calcalcs +namespace teca_calcalcs { /// @cond diff --git a/data/teca_calendar_util.cxx b/data/teca_calendar_util.cxx index 28229474a..5d8954faa 100644 --- a/data/teca_calendar_util.cxx +++ b/data/teca_calendar_util.cxx @@ -3,7 +3,7 @@ #include "teca_common.h" #include "teca_variant_array.h" #include "teca_coordinate_util.h" -#include "calcalcs.h" +#include "teca_calcalcs.h" #include @@ -104,7 +104,7 @@ time_point::time_point(long i, double t, const std::string &units, day(0), hour(0), minute(0), second(0) { - if (calcalcs::date(t, &this->year, &this->month, &this->day, + if (teca_calcalcs::date(t, &this->year, &this->month, &this->day, &this->hour, &this->minute, &this->second, units.c_str(), calendar.c_str())) { @@ -247,7 +247,7 @@ int season_iterator::get_season_end(int y_in, int m_in, int &y_out, return -1; } - if (calcalcs::days_in_month(this->calendar.c_str(), + if (teca_calcalcs::days_in_month(this->calendar.c_str(), this->units.c_str(), y_out, m_out, d_out)) { TECA_ERROR("Failed to get the last day of the month " @@ -459,7 +459,7 @@ int year_iterator::get_next_interval(time_point &first_step, // find the time step of the last day int n_days = 0; - if (calcalcs::days_in_month(this->calendar.c_str(), + if (teca_calcalcs::days_in_month(this->calendar.c_str(), this->units.c_str(), this->year, 12, n_days)) { TECA_ERROR("Failed to get the last day of the month " @@ -585,7 +585,7 @@ int month_iterator::get_next_interval(time_point &first_step, // find the time step of the last day int n_days = 0; - if (calcalcs::days_in_month(this->calendar.c_str(), + if (teca_calcalcs::days_in_month(this->calendar.c_str(), this->units.c_str(), this->year, this->month, n_days)) { TECA_ERROR("Failed to get the last day of the month " @@ -739,7 +739,7 @@ int day_iterator::get_next_interval(time_point &first_step, // move to next day int n_days = 0; - if (calcalcs::days_in_month(this->calendar.c_str(), + if (teca_calcalcs::days_in_month(this->calendar.c_str(), this->units.c_str(), this->year, this->month, n_days)) { TECA_ERROR("Failed to get the last day of the month " diff --git a/data/teca_coordinate_util.cxx b/data/teca_coordinate_util.cxx index e244de07a..0a2965b47 100644 --- a/data/teca_coordinate_util.cxx +++ b/data/teca_coordinate_util.cxx @@ -2,7 +2,7 @@ #include "teca_common.h" #if defined(TECA_HAS_UDUNITS) -#include "calcalcs.h" +#include "teca_calcalcs.h" #endif #include @@ -37,7 +37,7 @@ int time_step_of(const const_p_teca_variant_array &time, // apply calendaring to get a time offset double t = 0.0; - if (calcalcs::coordinate(Y, M, D, h, m, s, + if (teca_calcalcs::coordinate(Y, M, D, h, m, s, units.c_str(), calendar.c_str(), &t)) { TECA_ERROR("failed to convert date \"" << date @@ -92,10 +92,10 @@ int time_to_string(double val, const std::string &calendar, const std::string &units, const std::string &format, std::string &date) { #if defined(TECA_HAS_UDUNITS) - // use calcalcs to convert val to a set of year/month/day/etc. + // use teca_calcalcs to convert val to a set of year/month/day/etc. struct tm timedata = {}; double seconds = 0.0; - if (calcalcs::date(val, &timedata.tm_year, &timedata.tm_mon, + if (teca_calcalcs::date(val, &timedata.tm_year, &timedata.tm_mon, &timedata.tm_mday, &timedata.tm_hour, &timedata.tm_min, &seconds, units.c_str(), calendar.c_str())) { diff --git a/io/teca_cf_reader.cxx b/io/teca_cf_reader.cxx index 486792391..f05fe069e 100644 --- a/io/teca_cf_reader.cxx +++ b/io/teca_cf_reader.cxx @@ -10,7 +10,7 @@ #include "teca_coordinate_util.h" #include "teca_netcdf_util.h" #include "teca_system_util.h" -#include "calcalcs.h" +#include "teca_calcalcs.h" #include #include @@ -668,7 +668,7 @@ teca_metadata teca_cf_reader::get_output_metadata( int hh=0; int mm=0; double ss=0.0; - if (calcalcs::date(double(p_ti[j]), &YY, &MM, &DD, &hh, &mm, &ss, + if (teca_calcalcs::date(double(p_ti[j]), &YY, &MM, &DD, &hh, &mm, &ss, units_i.c_str(), base_calendar.c_str())) { TECA_ERROR("Failed to convert offset ti[" << j << "] = " @@ -679,7 +679,7 @@ teca_metadata teca_cf_reader::get_output_metadata( // convert time to offsets from base units double offs = 0.0; - if (calcalcs::coordinate(YY, MM, DD, hh, mm, ss, + if (teca_calcalcs::coordinate(YY, MM, DD, hh, mm, ss, base_units.c_str(), base_calendar.c_str(), &offs)) { TECA_ERROR("Failed to convert time " @@ -835,7 +835,7 @@ teca_metadata teca_cf_reader::get_output_metadata( int minute = current_tm.tm_min; double second = current_tm.tm_sec; double current_time = 0; - if (calcalcs::coordinate(year, mon, day, hour, minute, + if (teca_calcalcs::coordinate(year, mon, day, hour, minute, second, t_units.c_str(), calendar.c_str(), ¤t_time)) { TECA_ERROR("conversion of date inferred from " diff --git a/io/teca_wrf_reader.cxx b/io/teca_wrf_reader.cxx index 43cfe53a3..73a621b04 100644 --- a/io/teca_wrf_reader.cxx +++ b/io/teca_wrf_reader.cxx @@ -5,7 +5,7 @@ #include "teca_thread_pool.h" #include "teca_coordinate_util.h" #include "teca_netcdf_util.h" -#include "calcalcs.h" +#include "teca_calcalcs.h" #include #include @@ -774,7 +774,7 @@ teca_metadata teca_wrf_reader::get_output_metadata( int minute = current_tm.tm_min; double second = current_tm.tm_sec; double current_time = 0; - if (calcalcs::coordinate(year, mon, day, hour, minute, + if (teca_calcalcs::coordinate(year, mon, day, hour, minute, second, t_units.c_str(), calendar.c_str(), ¤t_time)) { TECA_ERROR("conversion of date inferred from " diff --git a/paraview/vtkTECATimeAnnotation.cxx b/paraview/vtkTECATimeAnnotation.cxx index 1794d58b2..340659c09 100644 --- a/paraview/vtkTECATimeAnnotation.cxx +++ b/paraview/vtkTECATimeAnnotation.cxx @@ -15,7 +15,7 @@ #include #include -#include "calcalcs.h" +#include "teca_calcalcs.h" //---------------------------------------------------------------------------- vtkStandardNewMacro(vtkTECATimeAnnotation); @@ -111,7 +111,7 @@ int vtkTECATimeAnnotation::RequestData(vtkInformation *req, int minute = 0; double second = 0; - if (calcalcs::date(time, &year, &month, &day, &hour, &minute, &second, + if (teca_calcalcs::date(time, &year, &month, &day, &hour, &minute, &second, time_units.c_str(), calendar.c_str())) { vtkErrorMacro("Failed to compute the date time=" << time) diff --git a/python/teca_py_core.i b/python/teca_py_core.i index 30ae345a4..20dc6843a 100644 --- a/python/teca_py_core.i +++ b/python/teca_py_core.i @@ -1,7 +1,7 @@ %{ #include -#include "calcalcs.h" +#include "teca_calcalcs.h" #include "teca_algorithm_executive.h" #include "teca_index_executive.h" #include "teca_metadata.h" @@ -874,7 +874,7 @@ typedef std::pair, unsigned int> teca_algorithm_ %include "teca_dataset_capture.h" /*************************************************************************** - calcalcs + teca_calcalcs ***************************************************************************/ %inline %{ @@ -894,7 +894,7 @@ PyObject *date(double offset, const char *units, const char *calendar) int minute = -1; double second = -1.0; - if (calcalcs::date(offset, &year, &month, &day, &hour, + if (teca_calcalcs::date(offset, &year, &month, &day, &hour, &minute, &second, units, calendar)) { TECA_PY_ERROR_NOW(PyExc_RuntimeError, "Failed to convert time") @@ -916,7 +916,7 @@ PyObject *is_leap_year(const char *calendar, const char *units, teca_py_gil_state gil; int leap = 0; - if (calcalcs::is_leap_year(calendar, units, year, leap)) + if (teca_calcalcs::is_leap_year(calendar, units, year, leap)) { TECA_PY_ERROR_NOW(PyExc_RuntimeError, "Failed to determine leap year status") @@ -934,7 +934,7 @@ PyObject *days_in_month(const char *calendar, const char *units, teca_py_gil_state gil; int dpm = 0; - if (calcalcs::days_in_month(calendar, units, year, month, dpm)) + if (teca_calcalcs::days_in_month(calendar, units, year, month, dpm)) { TECA_PY_ERROR_NOW(PyExc_RuntimeError, "Failed to determine days in month")