Use udunits package for units conversions

So our unit tests did their job, they pointed to quite a few errors.
Fixed them all on my platform (CentOS 7).

refs #231
This commit is contained in:
Alex Lin 2016-05-11 09:01:54 -05:00
parent d72aa59fdd
commit 26cb44e946
31 changed files with 128 additions and 88 deletions

View File

@ -23,7 +23,10 @@
#include "trick/var.h" #include "trick/var.h"
#include "trick/CheckPointAgent.hh" #include "trick/CheckPointAgent.hh"
#include "trick/UCFn.hh"
// forward declare the units converter types used by ref_assignment
union cv_converter ;
struct ut_system ;
namespace Trick { namespace Trick {
@ -738,7 +741,7 @@ namespace Trick {
@param v_tree - RHS data to be assigned. @param v_tree - RHS data to be assigned.
@param cf - units conversion function. @param cf - units conversion function.
*/ */
int assign_recursive(void* base_addr, ATTRIBUTES* attr, int curr_dim, int offset, V_TREE* v_tree, UCFn* cf); int assign_recursive(void* base_addr, ATTRIBUTES* attr, int curr_dim, int offset, V_TREE* v_tree, cv_converter * cf);
/** /**
Copy the common elements from one array to another. The arrays must be of the same dimension, Copy the common elements from one array to another. The arrays must be of the same dimension,
@ -825,6 +828,11 @@ namespace Trick {
*/ */
void debug_write_alloc_info( ALLOC_INFO *alloc_info); void debug_write_alloc_info( ALLOC_INFO *alloc_info);
/**
Returns a pointer to the udunits system we are using.
*/
ut_system * get_unit_system() ;
}; // endof class MemoryManager }; // endof class MemoryManager
} // endof namespace Trick } // endof namespace Trick

View File

@ -49,7 +49,7 @@ def main():
print unit.mi print unit.mi
print unit.nmile print unit.nmile
unit.rad = trick.attach_units("r", 10) unit.rad = trick.attach_units("r ", 10)
unit.rad = 1 unit.rad = 1
unit.degree = unit.rad unit.degree = unit.rad

View File

@ -23,7 +23,7 @@ class unitSimObject : public Trick::SimObject {
double temp_C ; // trick_units(degC) test double temp_C ; // trick_units(degC) test
double fpf ; // trick_units(furlong/fortnight) test double fpf ; // trick_units(furlong/fortnight) test
double mps ; // trick_units(m/s) test double mps ; // trick_units(m/s ) test
double s ; // trick_units(s) test double s ; // trick_units(s) test
double ps ; // trick_units(ps) test double ps ; // trick_units(ps) test

View File

@ -1,4 +1,4 @@
sys.exec.out.time {s},drx.drt.charB.var1 {--},drx.drt.charB.var2 {--},drx.drt.charB.var3 {--},drx.drt.charB.var4 {--},drx.drt.intB.var1 {--},drx.drt.intB.var2 {--},drx.drt.intB.var3 {--},drx.drt.intB.var4 {--},drx.drt.shortB.var1 {--},drx.drt.shortB.var2 {--},drx.drt.shortB.var3 {--},drx.drt.shortB.var4 {--},drx.drt.ucharB.var1 {--},drx.drt.ucharB.var2 {--},drx.drt.ucharB.var3 {--},drx.drt.ucharB.var4 {--},drx.drt.uintB.var1 {--},drx.drt.uintB.var2 {--},drx.drt.uintB.var3 {--},drx.drt.uintB.var4 {--},drx.drt.ushortB.var1 {--},drx.drt.ushortB.var2 {--},drx.drt.ushortB.var3 {--},drx.drt.ushortB.var4 {--},drx.drt.mixB.var1 {--},drx.drt.mixB.var2 {--},drx.drt.mixB.var3 {--},drx.drt.mixB.var4 {--} sys.exec.out.time {s},drx.drt.charB.var1 {1},drx.drt.charB.var2 {1},drx.drt.charB.var3 {1},drx.drt.charB.var4 {1},drx.drt.intB.var1 {1},drx.drt.intB.var2 {1},drx.drt.intB.var3 {1},drx.drt.intB.var4 {1},drx.drt.shortB.var1 {1},drx.drt.shortB.var2 {1},drx.drt.shortB.var3 {1},drx.drt.shortB.var4 {1},drx.drt.ucharB.var1 {1},drx.drt.ucharB.var2 {1},drx.drt.ucharB.var3 {1},drx.drt.ucharB.var4 {1},drx.drt.uintB.var1 {1},drx.drt.uintB.var2 {1},drx.drt.uintB.var3 {1},drx.drt.uintB.var4 {1},drx.drt.ushortB.var1 {1},drx.drt.ushortB.var2 {1},drx.drt.ushortB.var3 {1},drx.drt.ushortB.var4 {1},drx.drt.mixB.var1 {1},drx.drt.mixB.var2 {1},drx.drt.mixB.var3 {1},drx.drt.mixB.var4 {1}
0,1,-2,0,0,63,-32768,0,-24,127,-1,0,-12,2,0,1,1,128,0,63,1,4,0,15,1,3,-128,0,2112 0,1,-2,0,0,63,-32768,0,-24,127,-1,0,-12,2,0,1,1,128,0,63,1,4,0,15,1,3,-128,0,2112
0.1,1,-2,0,0,63,-32768,0,-24,127,-1,0,-12,2,0,1,1,128,0,63,1,4,0,15,1,3,-128,0,2112 0.1,1,-2,0,0,63,-32768,0,-24,127,-1,0,-12,2,0,1,1,128,0,63,1,4,0,15,1,3,-128,0,2112
0.2,1,-2,0,0,63,-32768,0,-24,127,-1,0,-12,2,0,1,1,128,0,63,1,4,0,15,1,3,-128,0,2112 0.2,1,-2,0,0,63,-32768,0,-24,127,-1,0,-12,2,0,1,1,128,0,63,1,4,0,15,1,3,-128,0,2112

1 sys.exec.out.time {s} drx.drt.charB.var1 {--} drx.drt.charB.var1 {1} drx.drt.charB.var2 {--} drx.drt.charB.var2 {1} drx.drt.charB.var3 {--} drx.drt.charB.var3 {1} drx.drt.charB.var4 {--} drx.drt.charB.var4 {1} drx.drt.intB.var1 {--} drx.drt.intB.var1 {1} drx.drt.intB.var2 {--} drx.drt.intB.var2 {1} drx.drt.intB.var3 {--} drx.drt.intB.var3 {1} drx.drt.intB.var4 {--} drx.drt.intB.var4 {1} drx.drt.shortB.var1 {--} drx.drt.shortB.var1 {1} drx.drt.shortB.var2 {--} drx.drt.shortB.var2 {1} drx.drt.shortB.var3 {--} drx.drt.shortB.var3 {1} drx.drt.shortB.var4 {--} drx.drt.shortB.var4 {1} drx.drt.ucharB.var1 {--} drx.drt.ucharB.var1 {1} drx.drt.ucharB.var2 {--} drx.drt.ucharB.var2 {1} drx.drt.ucharB.var3 {--} drx.drt.ucharB.var3 {1} drx.drt.ucharB.var4 {--} drx.drt.ucharB.var4 {1} drx.drt.uintB.var1 {--} drx.drt.uintB.var1 {1} drx.drt.uintB.var2 {--} drx.drt.uintB.var2 {1} drx.drt.uintB.var3 {--} drx.drt.uintB.var3 {1} drx.drt.uintB.var4 {--} drx.drt.uintB.var4 {1} drx.drt.ushortB.var1 {--} drx.drt.ushortB.var1 {1} drx.drt.ushortB.var2 {--} drx.drt.ushortB.var2 {1} drx.drt.ushortB.var3 {--} drx.drt.ushortB.var3 {1} drx.drt.ushortB.var4 {--} drx.drt.ushortB.var4 {1} drx.drt.mixB.var1 {--} drx.drt.mixB.var1 {1} drx.drt.mixB.var2 {--} drx.drt.mixB.var2 {1} drx.drt.mixB.var3 {--} drx.drt.mixB.var3 {1} drx.drt.mixB.var4 {--} drx.drt.mixB.var4 {1}
2 0 1 -2 0 0 63 -32768 0 -24 127 -1 0 -12 2 0 1 1 128 0 63 1 4 0 15 1 3 -128 0 2112
3 0.1 1 -2 0 0 63 -32768 0 -24 127 -1 0 -12 2 0 1 1 128 0 63 1 4 0 15 1 3 -128 0 2112
4 0.2 1 -2 0 0 63 -32768 0 -24 127 -1 0 -12 2 0 1 1 128 0 63 1 4 0 15 1 3 -128 0 2112

View File

@ -1,4 +1,4 @@
sys.exec.out.time {s},drx.drt.a {--},drx.drt.b {--},drx.drt.c {--},drx.drt.d {--},drx.drt.e {--},drx.drt.f {--},drx.drt.g {--},drx.drt.h {--},drx.drt.i {--},drx.drt.j {--},drx.drt.k {--},drx.drt.l {--},drx.drt.m {--},drx.drt.n {--} sys.exec.out.time {s},drx.drt.a {1},drx.drt.b {1},drx.drt.c {1},drx.drt.d {1},drx.drt.e {1},drx.drt.f {1},drx.drt.g {1},drx.drt.h {1},drx.drt.i {1},drx.drt.j {1},drx.drt.k {1},drx.drt.l {1},drx.drt.m {1},drx.drt.n {1}
0,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3 0,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3
0.1,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3 0.1,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3
0.2,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3 0.2,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3

1 sys.exec.out.time {s} drx.drt.a {--} drx.drt.a {1} drx.drt.b {--} drx.drt.b {1} drx.drt.c {--} drx.drt.c {1} drx.drt.d {--} drx.drt.d {1} drx.drt.e {--} drx.drt.e {1} drx.drt.f {--} drx.drt.f {1} drx.drt.g {--} drx.drt.g {1} drx.drt.h {--} drx.drt.h {1} drx.drt.i {--} drx.drt.i {1} drx.drt.j {--} drx.drt.j {1} drx.drt.k {--} drx.drt.k {1} drx.drt.l {--} drx.drt.l {1} drx.drt.m {--} drx.drt.m {1} drx.drt.n {--} drx.drt.n {1}
2 0 a 98 -1234 1234 -123456 123456 -1234567 123456789 1234.5677 -1234.56789 -12345678912345 12345678912345 0 3
3 0.1 a 98 -1234 1234 -123456 123456 -1234567 123456789 1234.5677 -1234.56789 -12345678912345 12345678912345 0 3
4 0.2 a 98 -1234 1234 -123456 123456 -1234567 123456789 1234.5677 -1234.56789 -12345678912345 12345678912345 0 3

View File

@ -356,10 +356,10 @@ class ClassOfEverything {
int ikg ; /* kg unit-ed integer value testing */ int ikg ; /* kg unit-ed integer value testing */
int ilbm ; /* lbm unit-ed integer value testing */ int ilbm ; /* lb unit-ed integer value testing */
double dkg ; /* kg unit-ed double value testing */ double dkg ; /* kg unit-ed double value testing */
double dlbm ; /* lbm unit-ed double value testing */ double dlbm ; /* lb unit-ed double value testing */
double dno_units ; /* -- unitless double value testing */ double dno_units ; /* -- unitless double value testing */
double ds ; /* s unit-ed double value testing */ double ds ; /* s unit-ed double value testing */

View File

@ -228,6 +228,8 @@ void FieldDescription::parseComment(std::string comment) {
// Test if we have valid units. We need to have found a units string and an io spec not zero // Test if we have valid units. We need to have found a units string and an io spec not zero
// Possible todo is to create a map of valid units so we don't have to retest each string. // Possible todo is to create a map of valid units so we don't have to retest each string.
if ( units_found and io != 0 and (valid_units.find(units) == valid_units.end())) { if ( units_found and io != 0 and (valid_units.find(units) == valid_units.end())) {
// remove spaces
units.erase(remove_if(units.begin(), units.end(), isspace), units.end());
if ( !units.compare("--") ) { if ( !units.compare("--") ) {
units = "1" ; units = "1" ;
} else { } else {
@ -235,7 +237,7 @@ void FieldDescription::parseComment(std::string comment) {
std::string new_units = map_trick_units_to_udunits(units) ; std::string new_units = map_trick_units_to_udunits(units) ;
if ( units.compare(new_units) ) { if ( units.compare(new_units) ) {
if ( ! units_truth_is_scary ) { if ( ! units_truth_is_scary ) {
std::cout << "\033[31mUnits converted from [" << units << "] to [" << new_units << "] " std::cout << "\033[33mUnits converted from [" << units << "] to [" << new_units << "] "
<< file_name << ":" << line_no << "\033[0m" << std::endl ; << file_name << ":" << line_no << "\033[0m" << std::endl ;
} }
units = new_units ; units = new_units ;

View File

@ -6,7 +6,7 @@
<product version="1.0"> <product version="1.0">
<table> <table>
<column> <column>
<units>M</units> <units>s</units>
<var>sys.exec.out.time</var> <var>sys.exec.out.time</var>
</column> </column>
<column> <column>

View File

@ -62,7 +62,7 @@
<label>Pressure</label> <label>Pressure</label>
<units>ft</units> <units>ft</units>
<var label="Variable 2" <var label="Variable 2"
from_units="rev" units="as" from_units="revolution" units="arcsecond"
bias="left?" scale="4" max="34579257" bias="left?" scale="4" max="34579257"
symbol_style="dot" symbol_size="huge" symbol_style="dot" symbol_size="huge"
line_style="shiny" line_color="yellow" line_style="shiny" line_color="yellow"

View File

@ -171,7 +171,7 @@ TEST_F(DPCTest, VarvsTime_Binary) {
"X-axis label: time Y-axis label: declination" "X-axis label: time Y-axis label: declination"
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: sys.exec.out.time X Units: s" "X Var Name: sys.exec.out.time X Units: s"
"Y Var Name: sun_predictor.sun.declination Y Units: d" "Y Var Name: sun_predictor.sun.declination Y Units: degree"
"RUN Directory: RUN_BINARY" "RUN Directory: RUN_BINARY"
"First 5 points:" "First 5 points:"
"<0,23.4391>[0] <1,23.4391>[1] <2,23.4391>[2]" "<0,23.4391>[0] <1,23.4391>[1] <2,23.4391>[2]"
@ -183,7 +183,7 @@ TEST_F(DPCTest, VarvsTime_Binary) {
"X-axis label: time Y-axis label: declination" "X-axis label: time Y-axis label: declination"
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: sys.exec.out.time X Units: s" "X Var Name: sys.exec.out.time X Units: s"
"Y Var Name: sun_predictor.sun.declination Y Units: d" "Y Var Name: sun_predictor.sun.declination Y Units: degree"
"RUN Directory: RUN_BINARY" "RUN Directory: RUN_BINARY"
"First 5 points:" "First 5 points:"
"<0,23.4391>[0] <1,23.4391>[1] <2,23.4391>[2]" "<0,23.4391>[0] <1,23.4391>[1] <2,23.4391>[2]"
@ -209,7 +209,7 @@ TEST_F(DPCTest, VarvsTime_CSV) {
"X-axis label: time Y-axis label: declination" "X-axis label: time Y-axis label: declination"
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: sys.exec.out.time X Units: s" "X Var Name: sys.exec.out.time X Units: s"
"Y Var Name: sun_predictor.sun.declination Y Units: d" "Y Var Name: sun_predictor.sun.declination Y Units: degree"
"RUN Directory: RUN_ASCII" "RUN Directory: RUN_ASCII"
"First 5 points:" "First 5 points:"
"<0,14.0809>[0] <1,14.0809>[1] <2,14.0809>[2]" "<0,14.0809>[0] <1,14.0809>[1] <2,14.0809>[2]"
@ -221,7 +221,7 @@ TEST_F(DPCTest, VarvsTime_CSV) {
"X-axis label: time Y-axis label: declination" "X-axis label: time Y-axis label: declination"
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: sys.exec.out.time X Units: s" "X Var Name: sys.exec.out.time X Units: s"
"Y Var Name: sun_predictor.sun.declination Y Units: d" "Y Var Name: sun_predictor.sun.declination Y Units: degree"
"RUN Directory: RUN_ASCII" "RUN Directory: RUN_ASCII"
"First 5 points:" "First 5 points:"
"<0,14.0809>[0] <1,14.0809>[1] <2,14.0809>[2]" "<0,14.0809>[0] <1,14.0809>[1] <2,14.0809>[2]"
@ -243,8 +243,8 @@ TEST_F(DPCTest, SinglePlot) {
"Number of Curves: 1" "Number of Curves: 1"
"X-axis label: solar_azimuth Y-axis label: solar_elevation" "X-axis label: solar_azimuth Y-axis label: solar_elevation"
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: sun_predictor.sun.solar_azimuth X Units: d" "X Var Name: sun_predictor.sun.solar_azimuth X Units: degree"
"Y Var Name: sun_predictor.sun.solar_elevation Y Units: d" "Y Var Name: sun_predictor.sun.solar_elevation Y Units: degree"
"RUN Directory: RUN_BINARY" "RUN Directory: RUN_BINARY"
"First 5 points:" "First 5 points:"
"<353.673,-36.7426>[0] <353.678,-36.743>[1] <353.683,-36.7434>[2]" "<353.673,-36.7426>[0] <353.678,-36.743>[1] <353.683,-36.7434>[2]"
@ -272,10 +272,10 @@ TEST_F(DPCTest, SingleTable) {
"Column Units [0]: s" "Column Units [0]: s"
"Column Label [1]: solar_azimuth" "Column Label [1]: solar_azimuth"
"Variable Name[1]: sun_predictor.sun.solar_azimuth" "Variable Name[1]: sun_predictor.sun.solar_azimuth"
"Column Units [1]: d" "Column Units [1]: degree"
"Column Label [2]: solar_elevation" "Column Label [2]: solar_elevation"
"Variable Name[2]: sun_predictor.sun.solar_elevation" "Variable Name[2]: sun_predictor.sun.solar_elevation"
"Column Units [2]: d" "Column Units [2]: degree"
"time: 0 values: 0 353.673 -36.7426" "time: 0 values: 0 353.673 -36.7426"
"time: 1 values: 1 353.678 -36.743" "time: 1 values: 1 353.678 -36.743"
"time: 2 values: 2 353.683 -36.7434" "time: 2 values: 2 353.683 -36.7434"
@ -305,7 +305,7 @@ TEST_F(DPCTest, PlotAttr_Binary) {
"Attribute font: -*-new century schoolbook-bold-r-*--12-*-*-*-*-*-*-*" "Attribute font: -*-new century schoolbook-bold-r-*--12-*-*-*-*-*-*-*"
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: sys.exec.out.time X Units: s" "X Var Name: sys.exec.out.time X Units: s"
"Y Var Name: sun_predictor.sun.solar_elevation Y Units: d" "Y Var Name: sun_predictor.sun.solar_elevation Y Units: degree"
"RUN Directory: RUN_BINARY" "RUN Directory: RUN_BINARY"
"Attribute y line_style: dash" "Attribute y line_style: dash"
"Attribute y line_color: red" "Attribute y line_color: red"
@ -345,8 +345,8 @@ TEST_F(DPCTest, 3DProduct_2DPlot) {
"Attribute background_color: #fffff0" "Attribute background_color: #fffff0"
"Attribute font: -*-new century schoolbook-bold-r-*--12-*-*-*-*-*-*-*" "Attribute font: -*-new century schoolbook-bold-r-*--12-*-*-*-*-*-*-*"
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: sun_predictor.sun.solar_azimuth X Units: d" "X Var Name: sun_predictor.sun.solar_azimuth X Units: degree"
"Y Var Name: sun_predictor.sun.solar_elevation Y Units: d" "Y Var Name: sun_predictor.sun.solar_elevation Y Units: degree"
"RUN Directory: RUN_BINARY" "RUN Directory: RUN_BINARY"
"Attribute y line_color: #323200" "Attribute y line_color: #323200"
"First 5 points:" "First 5 points:"
@ -375,7 +375,7 @@ TEST_F(DPCTest, Table_Attributes) {
"Column Units [0]: s format [0]: %24.10f" "Column Units [0]: s format [0]: %24.10f"
"Column Label [1]: Azimuth" "Column Label [1]: Azimuth"
"Variable Name[1]: sun_predictor.sun.solar_azimuth" "Variable Name[1]: sun_predictor.sun.solar_azimuth"
"Column Units [1]: d format [1]: %16.5q" "Column Units [1]: degree format [1]: %16.5q"
"Column Label [2]: Hours" "Column Label [2]: Hours"
"Variable Name[2]: sys.exec.out.time" "Variable Name[2]: sys.exec.out.time"
"Column Units [2]: s format [2]: %24.10f" "Column Units [2]: s format [2]: %24.10f"
@ -384,7 +384,7 @@ TEST_F(DPCTest, Table_Attributes) {
"Column Units [3]: hr format [3]: %24.10f" "Column Units [3]: hr format [3]: %24.10f"
"Column Label [4]: Elevation" "Column Label [4]: Elevation"
"Variable Name[4]: sun_predictor.sun.solar_elevation" "Variable Name[4]: sun_predictor.sun.solar_elevation"
"Column Units [4]: d format [4]: %16.5f" "Column Units [4]: degree format [4]: %16.5f"
"time: 400 values: 400 355.576 400 0.111111 -36.8784" "time: 400 values: 400 355.576 400 0.111111 -36.8784"
"time: 401 values: 401 355.58 401 0.111389 -36.8787" "time: 401 values: 401 355.58 401 0.111389 -36.8787"
"time: 402 values: 402 355.585 402 0.111667 -36.879" "time: 402 values: 402 355.585 402 0.111667 -36.879"
@ -415,7 +415,7 @@ TEST_F(DPCTest, MultiplePlots) {
"Attribute font: -*-new century schoolbook-bold-r-*--12-*-*-*-*-*-*-*" "Attribute font: -*-new century schoolbook-bold-r-*--12-*-*-*-*-*-*-*"
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: sys.exec.out.time X Units: s" "X Var Name: sys.exec.out.time X Units: s"
"Y Var Name: sun_predictor.sun.solar_elevation Y Units: d" "Y Var Name: sun_predictor.sun.solar_elevation Y Units: degree"
"RUN Directory: RUN_BINARY" "RUN Directory: RUN_BINARY"
"Attribute y line_color: #323200" "Attribute y line_color: #323200"
"First 5 points:" "First 5 points:"
@ -431,7 +431,7 @@ TEST_F(DPCTest, MultiplePlots) {
"Attribute font: -*-new century schoolbook-bold-r-*--12-*-*-*-*-*-*-*" "Attribute font: -*-new century schoolbook-bold-r-*--12-*-*-*-*-*-*-*"
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: sys.exec.out.time X Units: s" "X Var Name: sys.exec.out.time X Units: s"
"Y Var Name: sun_predictor.sun.solar_azimuth Y Units: d" "Y Var Name: sun_predictor.sun.solar_azimuth Y Units: degree"
"RUN Directory: RUN_BINARY" "RUN Directory: RUN_BINARY"
"Attribute y line_color: #323200" "Attribute y line_color: #323200"
"First 5 points:" "First 5 points:"
@ -446,8 +446,8 @@ TEST_F(DPCTest, MultiplePlots) {
"Attribute background_color: #fffff0" "Attribute background_color: #fffff0"
"Attribute font: -*-new century schoolbook-bold-r-*--12-*-*-*-*-*-*-*" "Attribute font: -*-new century schoolbook-bold-r-*--12-*-*-*-*-*-*-*"
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: sun_predictor.sun.solar_azimuth X Units: d" "X Var Name: sun_predictor.sun.solar_azimuth X Units: degree"
"Y Var Name: sun_predictor.sun.solar_elevation Y Units: d" "Y Var Name: sun_predictor.sun.solar_elevation Y Units: degree"
"RUN Directory: RUN_BINARY" "RUN Directory: RUN_BINARY"
"Attribute y line_color: #323200" "Attribute y line_color: #323200"
"First 5 points:" "First 5 points:"
@ -479,7 +479,7 @@ TEST_F(DPCTest, MultPlots_MultTables) {
"Attribute font: -*-new century schoolbook-bold-r-*--12-*-*-*-*-*-*-*" "Attribute font: -*-new century schoolbook-bold-r-*--12-*-*-*-*-*-*-*"
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: sys.exec.out.time X Units: s" "X Var Name: sys.exec.out.time X Units: s"
"Y Var Name: sun_predictor.sun.solar_elevation Y Units: d" "Y Var Name: sun_predictor.sun.solar_elevation Y Units: degree"
"RUN Directory: RUN_BINARY" "RUN Directory: RUN_BINARY"
"Attribute y line_color: #323200" "Attribute y line_color: #323200"
"First 5 points:" "First 5 points:"
@ -497,8 +497,8 @@ TEST_F(DPCTest, MultPlots_MultTables) {
"Attribute background_color: #fffff0" "Attribute background_color: #fffff0"
"Attribute font: -*-new century schoolbook-bold-r-*--12-*-*-*-*-*-*-*" "Attribute font: -*-new century schoolbook-bold-r-*--12-*-*-*-*-*-*-*"
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: sun_predictor.sun.solar_azimuth X Units: d" "X Var Name: sun_predictor.sun.solar_azimuth X Units: degree"
"Y Var Name: sun_predictor.sun.solar_elevation Y Units: d" "Y Var Name: sun_predictor.sun.solar_elevation Y Units: degree"
"RUN Directory: RUN_BINARY" "RUN Directory: RUN_BINARY"
"Attribute y line_color: #323200" "Attribute y line_color: #323200"
"First 5 points:" "First 5 points:"
@ -514,10 +514,10 @@ TEST_F(DPCTest, MultPlots_MultTables) {
"Column Units [0]: s format[0]: %24.10f" "Column Units [0]: s format[0]: %24.10f"
"Column Label [1]: Azimuth" "Column Label [1]: Azimuth"
"Variable Name[1]: sun_predictor.sun.solar_azimuth" "Variable Name[1]: sun_predictor.sun.solar_azimuth"
"Column Units [1]: d format[1]: %16.5q" "Column Units [1]: degree format[1]: %16.5q"
"Column Label [2]: Elevation" "Column Label [2]: Elevation"
"Variable Name[2]: sun_predictor.sun.solar_elevation" "Variable Name[2]: sun_predictor.sun.solar_elevation"
"Column Units [2]: d format[2]: %16.5f" "Column Units [2]: degree format[2]: %16.5f"
"time: 500 values: 500 356.052 -36.9048" "time: 500 values: 500 356.052 -36.9048"
"time: 501 values: 501 356.057 -36.9051" "time: 501 values: 501 356.057 -36.9051"
"time: 502 values: 502 356.062 -36.9053" "time: 502 values: 502 356.062 -36.9053"
@ -574,10 +574,10 @@ TEST_F(DPCTest, MultTables) {
"Column Units [0]: s format [0]: %24.10f" "Column Units [0]: s format [0]: %24.10f"
"Column Label [1]: Azimuth" "Column Label [1]: Azimuth"
"Variable Name[1]: sun_predictor.sun.solar_azimuth" "Variable Name[1]: sun_predictor.sun.solar_azimuth"
"Column Units [1]: d format [1]: %16.5q" "Column Units [1]: degree format [1]: %16.5q"
"Column Label [2]: Elevation" "Column Label [2]: Elevation"
"Variable Name[2]: sun_predictor.sun.solar_elevation" "Variable Name[2]: sun_predictor.sun.solar_elevation"
"Column Units [2]: d format [2]: %16.5f" "Column Units [2]: degree format [2]: %16.5f"
"time: 500 values: 500 354.177 -46.1843" "time: 500 values: 500 354.177 -46.1843"
"time: 501 values: 501 354.183 -46.1846" "time: 501 values: 501 354.183 -46.1846"
"time: 502 values: 502 354.189 -46.185" "time: 502 values: 502 354.189 -46.185"
@ -649,14 +649,14 @@ TEST_F(DPCTest, ComparisonCurves) {
"X-axis label: time Y-axis label: declination" "X-axis label: time Y-axis label: declination"
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: sys.exec.out.time X Units: s" "X Var Name: sys.exec.out.time X Units: s"
"Y Var Name: sun_predictor.sun.declination Y Units: d" "Y Var Name: sun_predictor.sun.declination Y Units: degree"
"RUN Directory: RUN5" "RUN Directory: RUN5"
"First 5 points:" "First 5 points:"
"<0,-18.1012>[0] <1,-18.1012>[1] <2,-18.1012>[2]" "<0,-18.1012>[0] <1,-18.1012>[1] <2,-18.1012>[2]"
"<3,-18.1012>[3] <4,-18.1012>[4]" "<3,-18.1012>[3] <4,-18.1012>[4]"
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: sys.exec.out.time X Units: s" "X Var Name: sys.exec.out.time X Units: s"
"Y Var Name: sun_predictor.sun.declination Y Units: d" "Y Var Name: sun_predictor.sun.declination Y Units: degree"
"RUN Directory: RUN6" "RUN Directory: RUN6"
"First 5 points:" "First 5 points:"
"<0,-18.1668>[0] <1,-18.1668>[1] <2,-18.1668>[2]" "<0,-18.1668>[0] <1,-18.1668>[1] <2,-18.1668>[2]"
@ -668,14 +668,14 @@ TEST_F(DPCTest, ComparisonCurves) {
"X-axis label: time Y-axis label: hour_angle" "X-axis label: time Y-axis label: hour_angle"
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: sys.exec.out.time X Units: s" "X Var Name: sys.exec.out.time X Units: s"
"Y Var Name: sun_predictor.sun.hour_angle Y Units: d" "Y Var Name: sun_predictor.sun.hour_angle Y Units: degree"
"RUN Directory: RUN5" "RUN Directory: RUN5"
"First 5 points:" "First 5 points:"
"<0,-61.18>[0] <1,-61.1758>[1] <2,-61.1717>[2]" "<0,-61.18>[0] <1,-61.1758>[1] <2,-61.1717>[2]"
"<3,-61.1675>[3] <4,-61.1633>[4]" "<3,-61.1675>[3] <4,-61.1633>[4]"
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: sys.exec.out.time X Units: s" "X Var Name: sys.exec.out.time X Units: s"
"Y Var Name: sun_predictor.sun.hour_angle Y Units: d" "Y Var Name: sun_predictor.sun.hour_angle Y Units: degree"
"RUN Directory: RUN6" "RUN Directory: RUN6"
"First 5 points:" "First 5 points:"
"<0,28.8108>[0] <1,28.8149>[1] <2,28.8191>[2]" "<0,28.8108>[0] <1,28.8149>[1] <2,28.8191>[2]"
@ -713,7 +713,7 @@ TEST_F(DPCTest, DeltaCurves) {
"X-axis label: time Y-axis label: declination" "X-axis label: time Y-axis label: declination"
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: sys.exec.out.time X Units: s" "X Var Name: sys.exec.out.time X Units: s"
"Y Var Name: DELTA(sun_predictor.sun.declination) Y Units: d" "Y Var Name: DELTA(sun_predictor.sun.declination) Y Units: degree"
"RUN Directory: RUN1 - RUN2" "RUN Directory: RUN1 - RUN2"
"First 5 points:" "First 5 points:"
"<0,0.0110458>[0] <1,0.0110457>[1] <2,0.0110457>[2]" "<0,0.0110458>[0] <1,0.0110457>[1] <2,0.0110457>[2]"
@ -725,7 +725,7 @@ TEST_F(DPCTest, DeltaCurves) {
"X-axis label: time Y-axis label: hour_angle" "X-axis label: time Y-axis label: hour_angle"
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: sys.exec.out.time X Units: s" "X Var Name: sys.exec.out.time X Units: s"
"Y Var Name: DELTA(sun_predictor.sun.hour_angle) Y Units: d" "Y Var Name: DELTA(sun_predictor.sun.hour_angle) Y Units: degree"
"RUN Directory: RUN1 - RUN2" "RUN Directory: RUN1 - RUN2"
"First 5 points:" "First 5 points:"
"<0,-14.9985>[0] <1,-14.9985>[1] <2,-14.9985>[2]" "<0,-14.9985>[0] <1,-14.9985>[1] <2,-14.9985>[2]"
@ -771,14 +771,14 @@ TEST_F(DPCTest, ContrastCurves) {
"X-axis label: time Y-axis label: declination" "X-axis label: time Y-axis label: declination"
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: sys.exec.out.time X Units: s" "X Var Name: sys.exec.out.time X Units: s"
"Y Var Name: sun_predictor.sun.declination Y Units: d" "Y Var Name: sun_predictor.sun.declination Y Units: degree"
"RUN Directory: RUN4" "RUN Directory: RUN4"
"First 5 points:" "First 5 points:"
"<0,-18.0353>[0] <1,-18.0353>[1] <2,-18.0353>[2]" "<0,-18.0353>[0] <1,-18.0353>[1] <2,-18.0353>[2]"
"<3,-18.0353>[3] <4,-18.0353>[4]" "<3,-18.0353>[3] <4,-18.0353>[4]"
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: sys.exec.out.time X Units: s" "X Var Name: sys.exec.out.time X Units: s"
"Y Var Name: sun_predictor.sun.declination Y Units: d" "Y Var Name: sun_predictor.sun.declination Y Units: degree"
"RUN Directory: RUN5" "RUN Directory: RUN5"
"First 5 points:" "First 5 points:"
"<0,-18.1012>[0] <1,-18.1012>[1] <2,-18.1012>[2]" "<0,-18.1012>[0] <1,-18.1012>[1] <2,-18.1012>[2]"
@ -790,14 +790,14 @@ TEST_F(DPCTest, ContrastCurves) {
"X-axis label: time Y-axis label: hour_angle" "X-axis label: time Y-axis label: hour_angle"
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: sys.exec.out.time X Units: s" "X Var Name: sys.exec.out.time X Units: s"
"Y Var Name: sun_predictor.sun.hour_angle Y Units: d" "Y Var Name: sun_predictor.sun.hour_angle Y Units: degree"
"RUN Directory: RUN4" "RUN Directory: RUN4"
"First 5 points:" "First 5 points:"
"<0,-151.171>[0] <1,-151.167>[1] <2,-151.163>[2]" "<0,-151.171>[0] <1,-151.167>[1] <2,-151.163>[2]"
"<3,-151.158>[3] <4,-151.154>[4]" "<3,-151.158>[3] <4,-151.154>[4]"
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: sys.exec.out.time X Units: s" "X Var Name: sys.exec.out.time X Units: s"
"Y Var Name: sun_predictor.sun.hour_angle Y Units: d" "Y Var Name: sun_predictor.sun.hour_angle Y Units: degree"
"RUN Directory: RUN5" "RUN Directory: RUN5"
"First 5 points:" "First 5 points:"
"<0,-61.18>[0] <1,-61.1758>[1] <2,-61.1717>[2]" "<0,-61.18>[0] <1,-61.1758>[1] <2,-61.1717>[2]"
@ -821,7 +821,7 @@ TEST_F(DPCTest, ContrastCurves) {
"X-axis label: time Y-axis label: declination" "X-axis label: time Y-axis label: declination"
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: sys.exec.out.time X Units: s" "X Var Name: sys.exec.out.time X Units: s"
"Y Var Name: DELTA(sun_predictor.sun.declination) Y Units: d" "Y Var Name: DELTA(sun_predictor.sun.declination) Y Units: degree"
"RUN Directory: RUN4 - RUN5" "RUN Directory: RUN4 - RUN5"
"First 5 points:" "First 5 points:"
"<0,0.0659199>[0] <1,0.0659199>[1] <2,0.0659199>[2]" "<0,0.0659199>[0] <1,0.0659199>[1] <2,0.0659199>[2]"
@ -833,7 +833,7 @@ TEST_F(DPCTest, ContrastCurves) {
"X-axis label: time Y-axis label: hour_angle" "X-axis label: time Y-axis label: hour_angle"
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: sys.exec.out.time X Units: s" "X Var Name: sys.exec.out.time X Units: s"
"Y Var Name: DELTA(sun_predictor.sun.hour_angle) Y Units: d" "Y Var Name: DELTA(sun_predictor.sun.hour_angle) Y Units: degree"
"RUN Directory: RUN4 - RUN5" "RUN Directory: RUN4 - RUN5"
"First 5 points:" "First 5 points:"
"<0,-89.991>[0] <1,-89.991>[1] <2,-89.991>[2]" "<0,-89.991>[0] <1,-89.991>[1] <2,-89.991>[2]"
@ -876,7 +876,7 @@ TEST_F(DPCTest, DPV_Test) {
"X Var Name: sun_predictor.sun.observer_offset_from_UTC" "X Var Name: sun_predictor.sun.observer_offset_from_UTC"
"X Units: min" "X Units: min"
"Y Var Name: sun_predictor.sun.observer_latitude" "Y Var Name: sun_predictor.sun.observer_latitude"
"Y Units: d" "Y Units: degree"
"RUN Directory: RUN_BINARY" "RUN Directory: RUN_BINARY"
"Attribute x max: 100000000 Attribute x symbol_style: circles" "Attribute x max: 100000000 Attribute x symbol_style: circles"
"Attribute x symbol_size: small Attribute x line_style: dotted" "Attribute x symbol_size: small Attribute x line_style: dotted"
@ -895,7 +895,7 @@ TEST_F(DPCTest, DPV_Test) {
"Column Units [0]: s format [0]: feng shui" "Column Units [0]: s format [0]: feng shui"
"Column Label [1]: Pressure" "Column Label [1]: Pressure"
"Variable Name[1]: sun_predictor.sun.hour_angle" "Variable Name[1]: sun_predictor.sun.hour_angle"
"Column Units [1]: as format [1]: normal" "Column Units [1]: arcsecond format [1]: normal"
"time: 10 values: 10 628267" "time: 10 values: 10 628267"
"time: 11 values: 11 628282" "time: 11 values: 11 628282"
"time: 12 values: 12 628297" "time: 12 values: 12 628297"
@ -920,7 +920,7 @@ TEST_F(DPCTest, Plot_Matlab) {
"CURVE VIEW:" "CURVE VIEW:"
"X Var Name: s_simtime X Units: s" "X Var Name: s_simtime X Units: s"
"Y Var Name: dvvl_01c_3 Y Units: --" "Y Var Name: dvvl_01c_3 Y Units: 1"
"RUN Directory: RUN_MATLAB" "RUN Directory: RUN_MATLAB"
"First 5 points:" "First 5 points:"
"<0,0>[0] <0.05,-4.61208e-45>[1]" "<0,0>[0] <0.05,-4.61208e-45>[1]"

View File

@ -199,7 +199,7 @@ TEST_F(DPMTest, Table_NoAttributes) {
"<tstop>1.79769e+308</tstop>" "<tstop>1.79769e+308</tstop>"
"<frequency>1.79769e+308</frequency>" "<frequency>1.79769e+308</frequency>"
"<column>" "<column>"
"<units>M</units>" "<units>s</units>"
"<var>sys.exec.out.time</var>" "<var>sys.exec.out.time</var>"
"</column>" "</column>"
"<column>" "<column>"

View File

@ -138,7 +138,7 @@ TEST_F(DSTest, DataStream_Ascii) {
// GET UNIT // GET UNIT
output = run('u'); output = run('u');
result = strcmp_IgnoreWhiteSpace("getUnit : unitspec = \"d\"", output.c_str()); result = strcmp_IgnoreWhiteSpace("getUnit : unitspec = \"degree\"", output.c_str());
EXPECT_EQ(result, 0); EXPECT_EQ(result, 0);
// GET TIME UNIT // GET TIME UNIT
@ -209,7 +209,7 @@ TEST_F(DSTest, DataStream_Binary) {
// GET UNIT // GET UNIT
output = run('u'); output = run('u');
result = strcmp_IgnoreWhiteSpace("getUnit : unitspec = \"d\"", output.c_str()); result = strcmp_IgnoreWhiteSpace("getUnit : unitspec = \"degree\"", output.c_str());
EXPECT_EQ(result, 0); EXPECT_EQ(result, 0);
// GET TIME UNIT // GET TIME UNIT
@ -280,7 +280,7 @@ TEST_F(DSTest, DataStream_MatLab) {
// GET UNIT // GET UNIT
output = run('u'); output = run('u');
result = strcmp_IgnoreWhiteSpace("getUnit : unitspec= \"--\"", output.c_str()); result = strcmp_IgnoreWhiteSpace("getUnit : unitspec= \"1\"", output.c_str());
EXPECT_EQ(result, 0); EXPECT_EQ(result, 0);
// GET TIME UNIT // GET TIME UNIT
@ -362,7 +362,7 @@ TEST_F(DSTest, DataStream_DPCUnitConv) {
data_stream_factory = new DataStreamFactory(); data_stream_factory = new DataStreamFactory();
srcds = data_stream_factory->create(RUN_dir, VarName, NULL); srcds = data_stream_factory->create(RUN_dir, VarName, NULL);
testds = new DPC_UnitConvDataStream(srcds, "r", "d"); testds = new DPC_UnitConvDataStream(srcds, "rad", "degree");
output = run('g'); output = run('g');
result = strcmp_IgnoreWhiteSpace( result = strcmp_IgnoreWhiteSpace(
@ -370,7 +370,7 @@ TEST_F(DSTest, DataStream_DPCUnitConv) {
EXPECT_EQ(result, 0); EXPECT_EQ(result, 0);
output = run('u'); output = run('u');
result = strcmp_IgnoreWhiteSpace("getUnit : unitspec = \"r\"", output.c_str()); result = strcmp_IgnoreWhiteSpace("getUnit : unitspec = \"rad\"", output.c_str());
EXPECT_EQ(result, 0); EXPECT_EQ(result, 0);
output = run('t'); output = run('t');

View File

@ -25,7 +25,7 @@ INCDIRS = -I$(GTEST_HOME)/include \
-I${TRICK_HOME}/trick_source/data_products/DPX \ -I${TRICK_HOME}/trick_source/data_products/DPX \
${MOTIF_INCDIR} ${MOTIF_INCDIR}
CFLAGS = -g -Wall -Wextra ${INCDIRS} CFLAGS = -g -Wall -Wextra ${INCDIRS} $(UDUNITS_INCLUDES)
LIB_DPX_DIR = ${DPX_DIR}/lib_${TRICK_HOST_CPU} LIB_DPX_DIR = ${DPX_DIR}/lib_${TRICK_HOST_CPU}
LIB_DS_DIR = ${DS_DIR}/lib_${TRICK_HOST_CPU} LIB_DS_DIR = ${DS_DIR}/lib_${TRICK_HOST_CPU}
@ -47,14 +47,12 @@ else
endif endif
GTEST_LIBS = ${GTEST_HOME}/lib/libgtest.a ${GTEST_HOME}/lib/libgtest_main.a GTEST_LIBS = ${GTEST_HOME}/lib/libgtest.a ${GTEST_HOME}/lib/libgtest_main.a
TRICK_UNIT_LIBS = -L${TRICK_LIB_DIR} -ltrick_units DP_LIBS = -L${TRICK_HOME}/trick_source/data_products/lib_${TRICK_HOST_CPU} \
DP_LIBS = -L${TRICK_LIB_DIR} \ -llog -lvar -leqparse -ltrick_units
-L${TRICK_HOME}/trick_source/data_products/lib_${TRICK_HOST_CPU} \
-llog -lvar -leqparse
MODEL_LIBS = -lxml2 \ MODEL_LIBS = -lxml2 \
-L${DPX_DIR}/lib_${TRICK_HOST_CPU} -lDPM \ -L${DPX_DIR}/lib_${TRICK_HOST_CPU} -lDPM \
${GTEST_LIBS} -lpthread \ -L${TRICK_HOME}/trick_source/data_products/lib_${TRICK_HOST_CPU} -ltrick_units \
${TRICK_UNIT_LIBS} ${GTEST_LIBS} -lpthread -ludunits2
CONTROLLER_LIBS = -lDPC \ CONTROLLER_LIBS = -lDPC \
${MODEL_LIBS} ${DP_LIBS} \ ${MODEL_LIBS} ${DP_LIBS} \
${XLIBS} ${LIBRTDEF} \ ${XLIBS} ${LIBRTDEF} \

View File

@ -15,6 +15,7 @@
#include <sstream> #include <sstream>
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
#include <string.h>
const int Trick::ClassicCheckPointAgent::array_elements_per_line[TRICK_NUMBER_OF_TYPES] = { const int Trick::ClassicCheckPointAgent::array_elements_per_line[TRICK_NUMBER_OF_TYPES] = {
5, /** TRICK_VOID (for pointers) */ 5, /** TRICK_VOID (for pointers) */

View File

@ -224,7 +224,7 @@ void Trick::PythonPrint::write_singleton( std::ostream& chkpnt_os, void* address
break; break;
} }
if ( write_units && attr->units != NULL && strcmp(attr->units, "--") ) { if ( write_units && attr->units != NULL && strcmp(attr->units, "1") ) {
chkpnt_os << " " << attr->units ; chkpnt_os << " " << attr->units ;
} }
} }

View File

@ -14,6 +14,7 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include "trick/ChkPtParseContext.hh" #include "trick/ChkPtParseContext.hh"
#include "trick/vval.h" #include "trick/vval.h"

View File

@ -7,6 +7,7 @@
#include <unistd.h> #include <unistd.h>
#include <sys/syscall.h> #include <sys/syscall.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <string.h>
#ifdef _DMTCP #ifdef _DMTCP
#include "dmtcpaware.h" #include "dmtcpaware.h"

View File

@ -1,5 +1,6 @@
#include "trick/MemoryManager.hh" #include "trick/MemoryManager.hh"
#include <sstream> #include <sstream>
#include <string.h>
ALLOC_INFO* Trick::MemoryManager::get_alloc_info_of( void* addr) { ALLOC_INFO* Trick::MemoryManager::get_alloc_info_of( void* addr) {

View File

@ -3,6 +3,7 @@
#include <sstream> #include <sstream>
#include <dlfcn.h> #include <dlfcn.h>
#include <string.h>
#include "trick/MemoryManager.hh" #include "trick/MemoryManager.hh"
#include "trick/ADefParseContext.hh" #include "trick/ADefParseContext.hh"

View File

@ -1,4 +1,5 @@
#include "trick/MemoryManager.hh" #include "trick/MemoryManager.hh"
#include <string.h>
/** /**
* MEMBER FUNCTION * MEMBER FUNCTION

View File

@ -3,6 +3,7 @@
// Provides stringstream. // Provides stringstream.
#include <dlfcn.h> #include <dlfcn.h>
// Provides dlsym(). // Provides dlsym().
#include <string.h>
#include "trick/MemoryManager.hh" #include "trick/MemoryManager.hh"
// MEMBER FUNCTION: void* Trick::MemoryManager::io_src_allocate_class(const char* class_name, int num); // MEMBER FUNCTION: void* Trick::MemoryManager::io_src_allocate_class(const char* class_name, int num);

View File

@ -3,7 +3,7 @@
#include "trick/MemoryManager.hh" #include "trick/MemoryManager.hh"
static char * nil_units = "--"; static char * nil_units = "1";
// MEMBER FUNCTION // MEMBER FUNCTION
ATTRIBUTES* Trick::MemoryManager::make_reference_attr( ALLOC_INFO* alloc_info) { ATTRIBUTES* Trick::MemoryManager::make_reference_attr( ALLOC_INFO* alloc_info) {

View File

@ -1,5 +1,6 @@
#include <sstream> #include <sstream>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include "trick/MemoryManager.hh" #include "trick/MemoryManager.hh"
#include "trick/ADefParseContext.hh" #include "trick/ADefParseContext.hh"

View File

@ -2,6 +2,7 @@
#include <dlfcn.h> #include <dlfcn.h>
#include <stdlib.h> #include <stdlib.h>
#include <sstream> #include <sstream>
#include <string.h>
// PRIVATE MEMBER FUNCTION // PRIVATE MEMBER FUNCTION
void Trick::MemoryManager::recursive_array_copy( void *s_base, void Trick::MemoryManager::recursive_array_copy( void *s_base,

View File

@ -2,12 +2,12 @@
#include "trick/bitfield_proto.h" #include "trick/bitfield_proto.h"
#include "trick/vval.h" #include "trick/vval.h"
#include "trick/wcs_ext.h" #include "trick/wcs_ext.h"
#include "trick/Unit.hh"
#include "trick/UCFn.hh"
#include <limits.h> #include <limits.h>
#include <sstream> #include <sstream>
#include <udunits2.h>
#include <string.h>
int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, int curr_dim, int offset, V_TREE* v_tree, UCFn* cf) { int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, int curr_dim, int offset, V_TREE* v_tree, cv_converter* cf) {
char* assign_addr; char* assign_addr;
int remaining_dimensions = attr->num_index - curr_dim; int remaining_dimensions = attr->num_index - curr_dim;
@ -72,7 +72,7 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
if (cf == NULL) { if (cf == NULL) {
*(int *)assign_addr = input_value; *(int *)assign_addr = input_value;
} else { } else {
*(int *)assign_addr = input_value * cf->C[1] + cf->C[0]; *(int *)assign_addr = (int)cv_convert_double(cf, (double)input_value) ;
} }
} else { } else {
*(int *)assign_addr = 0; *(int *)assign_addr = 0;
@ -132,7 +132,7 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
if (cf == NULL) { if (cf == NULL) {
*(long *)assign_addr = input_value; *(long *)assign_addr = input_value;
} else { } else {
*(long *)assign_addr = input_value * cf->C[1] + cf->C[0]; *(long *)assign_addr = (long)cv_convert_double(cf, (double)input_value) ;
} }
} else { } else {
*(long *)assign_addr = 0; *(long *)assign_addr = 0;
@ -151,7 +151,7 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
if (cf == NULL) { // There is no units conversion. if (cf == NULL) { // There is no units conversion.
*(float *)assign_addr = input_value; *(float *)assign_addr = input_value;
} else { // There is units conversion. } else { // There is units conversion.
*(float *)assign_addr = input_value * cf->C[1] + cf->C[0]; *(float *)assign_addr = (float)cv_convert_double(cf, (double)input_value) ;
} }
} else { } else {
*(float *)assign_addr = 0; *(float *)assign_addr = 0;
@ -170,7 +170,7 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
if (cf == NULL) { if (cf == NULL) {
*(double *)assign_addr = input_value; *(double *)assign_addr = input_value;
} else { } else {
*(double *)assign_addr = input_value * cf->C[1] + cf->C[0]; *(double *)assign_addr = cv_convert_double(cf, input_value) ;
} }
} else { } else {
*(double *)assign_addr = 0; *(double *)assign_addr = 0;
@ -385,33 +385,48 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
return (0); return (0);
} }
#ifdef TRICK_VER
#include "trick/UdUnits.hh"
#else
static ut_system * u_system ;
#endif
ut_system * Trick::MemoryManager::get_unit_system() {
#ifdef TRICK_VER
return Trick::UdUnits::get_u_system() ;
#else
/* Initialize the udunits-2 library */
ut_set_error_message_handler(ut_ignore) ;
if( (u_system = ut_read_xml( NULL )) == NULL ) {
std::cerr << "Error initializing udunits-2 unit system" << std::endl ;
return -1 ;
}
ut_set_error_message_handler(ut_write_to_stderr) ;
return u_system ;
#endif
}
// MEMBER FUNCTION // MEMBER FUNCTION
int Trick::MemoryManager::ref_assignment( REF2* R, V_TREE* V) { int Trick::MemoryManager::ref_assignment( REF2* R, V_TREE* V) {
int ret = 0; int ret = 0;
UCFn *cf = NULL; cv_converter * cf = NULL ;
// Create a units conversion function if necessary. // Create a units conversion function if necessary.
if (R->units) { if (R->units) {
try { ut_unit * from = ut_parse(get_unit_system(), R->units, UT_ASCII) ;
Unit *from_units = new Unit(R->units); ut_unit * to = ut_parse(get_unit_system(), R->attr->units, UT_ASCII) ;
Unit *to_units = new Unit(R->attr->units); if ( !from or !to ) {
// This Conversion_to call allocates a new UCFn
cf = from_units->Conversion_to( to_units);
delete from_units;
delete to_units;
} catch (Unit::CONVERSION_ERROR) {
std::stringstream message; std::stringstream message;
message << "Can't convert \"" << R->units << "\" to \"" << R->attr->units << "\"."; message << "Can't convert \"" << R->units << "\" to \"" << R->attr->units << "\".";
emitError(message.str()); emitError(message.str());
cf = NULL;
return TRICK_UNITS_CONVERSION_ERROR ; return TRICK_UNITS_CONVERSION_ERROR ;
} }
cf = ut_get_converter(from,to) ;
} }
// R->num_index is badly named. It is really the current dimension // R->num_index is badly named. It is really the current dimension
ret = assign_recursive( R->address, R->attr, R->num_index, 0, V, cf); ret = assign_recursive( R->address, R->attr, R->num_index, 0, V, cf);
delete cf ; if ( cf ) cv_free(cf) ;
return ( ret); return ( ret);

View File

@ -1,5 +1,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <sstream> #include <sstream>
#include <fstream> #include <fstream>

View File

@ -1,4 +1,5 @@
#include "trick/MemoryManager.hh" #include "trick/MemoryManager.hh"
#include <string.h>
/** /**
@par Detailed Description: @par Detailed Description:

View File

@ -13,6 +13,7 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include "trick/vval.h" #include "trick/vval.h"
#include "trick/value.h" #include "trick/value.h"

View File

@ -13,6 +13,7 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include "trick/RefParseContext.hh" #include "trick/RefParseContext.hh"
#include "trick/vval.h" #include "trick/vval.h"

View File

@ -220,7 +220,7 @@ PyObject * swig_int::__pow__( PyObject * obj1 ) {
PyObject * ret = NULL ; PyObject * ret = NULL ;
void * argp2 ; void * argp2 ;
if ( units.compare("--")) { if ( units.compare("1")) {
PyErr_SetString(PyExc_TypeError,"Both arguments must be unitless. Cannot create new unit-ed type."); PyErr_SetString(PyExc_TypeError,"Both arguments must be unitless. Cannot create new unit-ed type.");
return NULL ; return NULL ;
} }

View File

@ -22,6 +22,10 @@ PyObject * attach_units(PyObject * in_units_obj , PyObject * in_object) {
if ( PyString_Check(in_units_obj) ) { if ( PyString_Check(in_units_obj) ) {
in_units = PyString_AsString(in_units_obj) ; in_units = PyString_AsString(in_units_obj) ;
in_units.erase(remove_if(in_units.begin(), in_units.end(), isspace), in_units.end());
if ( ! in_units.compare("--")) {
in_units = "1" ;
}
std::string new_units = map_trick_units_to_udunits(in_units) ; std::string new_units = map_trick_units_to_udunits(in_units) ;
if ( in_units.compare(new_units) ) { if ( in_units.compare(new_units) ) {
PyThreadState *tstate = PyThreadState_GET(); PyThreadState *tstate = PyThreadState_GET();
@ -31,7 +35,7 @@ PyObject * attach_units(PyObject * in_units_obj , PyObject * in_object) {
file_name = PyString_AsString(tstate->frame->f_code->co_filename); file_name = PyString_AsString(tstate->frame->f_code->co_filename);
line_no = PyFrame_GetLineNumber(tstate->frame) ; line_no = PyFrame_GetLineNumber(tstate->frame) ;
} }
std::cout << "\033[31mUnits converted from [" << in_units << "] to [" << new_units << "] " std::cout << "\033[33mUnits converted from [" << in_units << "] to [" << new_units << "] "
<< file_name << ":" << line_no << "\033[0m" << std::endl ; << file_name << ":" << line_no << "\033[0m" << std::endl ;
in_units = new_units ; in_units = new_units ;
} }