Skip to content

Commit

Permalink
calcalcs rename the calcalcs namespace to teca_calcalcs
Browse files Browse the repository at this point in the history
  • Loading branch information
burlen committed May 5, 2021
1 parent 3006fd4 commit 4ac4200
Show file tree
Hide file tree
Showing 21 changed files with 48 additions and 42 deletions.
2 changes: 1 addition & 1 deletion alg/teca_evaluate_expression.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <boost/program_options.hpp>
#endif
#if defined(TECA_HAS_UDUNITS)
#include "calcalcs.h"
#include "teca_calcalcs.h"
#endif
#if defined(TECA_HAS_MPI)
#include <mpi.h>
Expand Down
4 changes: 2 additions & 2 deletions alg/teca_table_calendar.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <boost/program_options.hpp>
#endif
#if defined(TECA_HAS_UDUNITS)
#include "calcalcs.h"
#include "teca_calcalcs.h"
#endif
#if defined(TECA_HAS_MPI)
#include <mpi.h>
Expand Down Expand Up @@ -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()))
{
Expand Down
2 changes: 1 addition & 1 deletion alg/teca_table_region_mask.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <boost/program_options.hpp>
#endif
#if defined(TECA_HAS_UDUNITS)
#include "calcalcs.h"
#include "teca_calcalcs.h"
#endif
#if defined(TECA_HAS_MPI)
#include <mpi.h>
Expand Down
2 changes: 1 addition & 1 deletion alg/teca_table_remove_rows.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <boost/program_options.hpp>
#endif
#if defined(TECA_HAS_UDUNITS)
#include "calcalcs.h"
#include "teca_calcalcs.h"
#endif
#if defined(TECA_HAS_MPI)
#include <mpi.h>
Expand Down
2 changes: 1 addition & 1 deletion alg/teca_tc_classify.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <boost/program_options.hpp>
#endif
#if defined(TECA_HAS_UDUNITS)
#include "calcalcs.h"
#include "teca_calcalcs.h"
#endif
#if defined(TECA_HAS_MPI)
#include <mpi.h>
Expand Down
2 changes: 1 addition & 1 deletion apps/teca_bayesian_ar_detect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <vector>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion apps/teca_cf_restripe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <iostream>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion apps/teca_integrated_vapor_transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <vector>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion apps/teca_integrated_water_vapor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <vector>
#include <string>
Expand Down
6 changes: 3 additions & 3 deletions apps/teca_metadata_probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "teca_app_util.h"

#if defined(TECA_HAS_UDUNITS)
#include "calcalcs.h"
#include "teca_calcalcs.h"
#endif

#include <vector>
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion apps/teca_tc_detect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <vector>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion apps/teca_tc_trajectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <vector>
Expand Down
2 changes: 1 addition & 1 deletion core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions core/calcalcs.cxx → core/teca_calcalcs.cxx
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -35,9 +38,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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 );
Expand Down
5 changes: 4 additions & 1 deletion core/calcalcs.h → core/teca_calcalcs.h
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -28,7 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.


/// A threadsafe port of the calcalcs library.
namespace calcalcs
namespace teca_calcalcs
{

/// @cond
Expand Down
12 changes: 6 additions & 6 deletions data/teca_calendar_util.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <algorithm>

Expand Down Expand Up @@ -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()))
{
Expand Down Expand Up @@ -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 "
Expand Down Expand Up @@ -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 "
Expand Down Expand Up @@ -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 "
Expand Down Expand Up @@ -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 "
Expand Down
8 changes: 4 additions & 4 deletions data/teca_coordinate_util.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "teca_common.h"
#if defined(TECA_HAS_UDUNITS)
#include "calcalcs.h"
#include "teca_calcalcs.h"
#endif

#include <string>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()))
{
Expand Down
8 changes: 4 additions & 4 deletions io/teca_cf_reader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <netcdf.h>
#include <iostream>
Expand Down Expand Up @@ -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 << "] = "
Expand All @@ -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 "
Expand Down Expand Up @@ -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(), &current_time))
{
TECA_ERROR("conversion of date inferred from "
Expand Down
4 changes: 2 additions & 2 deletions io/teca_wrf_reader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <netcdf.h>
#include <iostream>
Expand Down Expand Up @@ -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(), &current_time))
{
TECA_ERROR("conversion of date inferred from "
Expand Down
4 changes: 2 additions & 2 deletions paraview/vtkTECATimeAnnotation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <iomanip>
#include <algorithm>

#include "calcalcs.h"
#include "teca_calcalcs.h"

//----------------------------------------------------------------------------
vtkStandardNewMacro(vtkTECATimeAnnotation);
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions python/teca_py_core.i
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%{
#include <vector>

#include "calcalcs.h"
#include "teca_calcalcs.h"
#include "teca_algorithm_executive.h"
#include "teca_index_executive.h"
#include "teca_metadata.h"
Expand Down Expand Up @@ -874,7 +874,7 @@ typedef std::pair<std::shared_ptr<teca_algorithm>, unsigned int> teca_algorithm_
%include "teca_dataset_capture.h"

/***************************************************************************
calcalcs
teca_calcalcs
***************************************************************************/
%inline
%{
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand Down

0 comments on commit 4ac4200

Please sign in to comment.