source: trunk/src/fortran/RpUnitsFStubs.c @ 829

Last change on this file since 829 was 568, checked in by dkearney, 14 years ago

reworking of the Rappture Units code.
Rappture Units no longer creates an object for each metric extension of every
metric unit. Now the metric prefixes are kept in the dictionary as unit objects,
and when a unit is parsed out of the string received from the user, the unit
is checked to see if it acccepts metric prefixes, if so, a search is done for
the prefix. This allows Rappture Units code to more easily tackle case insensitive
unit name searches. Eventually the prefixes will be removed as direct Rappture Units objects and be turned into (possibly a derived object) rappture units prefix objects.

The find function of the core Rappture Units code now accepts
a "hints" function pointer. The function pointer is executed by the dictionary when
the dictionary thinks it found a matching object. This allows the user of the
dictionary to insert different objects with the same key. For Rappture Units,
multiple units objects with the same key can be inserted into the dictionary.
This is important for units like "A" which could stand for angstroms or amperes.

Additionally, the "make metric" functions were removed because the idea of being a
metric unit has been reduced to a flag inside the Rappture Units object and some
newly added logic. The role of setting the metric flag has been added to the define()
function as an additional function input. The fortran and c code has been updated to
reflect the removal of the function. No updates were made to the define function in
the fortran and c code.

The units.test file was also updated with new tests. Old tests were updated, removing
derived units from the list of compatible units. When searching for micro-meters (um),
compatible units of (A,in,m) will be provided instead of (A,in,m,um).

File size: 5.1 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Fortran Rappture Units Stub Function Source
4 *
5 * ======================================================================
6 *  AUTHOR:  Derrick Kearney, Purdue University
7 *  Copyright (c) 2004-2005  Purdue Research Foundation
8 *
9 *  See the file "license.terms" for information on usage and
10 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11 * ======================================================================
12 */
13
14#ifndef _RpUNITS_F_STUBS_SRC
15#define _RpUNITS_F_STUBS_SRC
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21int
22rp_define_unit_ (char* unitName, int* basisName, int unitName_len) {
23    return rp_define_unit(unitName,basisName,unitName_len);
24}
25
26int
27rp_define_unit__ (char* unitName, int* basisName, int unitName_len) {
28    return rp_define_unit(unitName,basisName,unitName_len);
29}
30
31int
32RP_DEFINE_UNIT (char* unitName, int* basisName, int unitName_len) {
33    return rp_define_unit(unitName,basisName,unitName_len);
34}
35
36int
37rp_find_ (char* searchName, int searchName_len) {
38    return rp_find(searchName,searchName_len);
39}
40
41int
42rp_find__ (char* searchName, int searchName_len) {
43    return rp_find(searchName,searchName_len);
44}
45
46int
47RP_FIND (char* searchName, int searchName_len) {
48    return rp_find(searchName,searchName_len);
49}
50
51int
52rp_get_units_ (int* unitRefVal, char* retText, int retText_len) {
53    return rp_get_units(unitRefVal,retText,retText_len);
54}
55
56int
57rp_get_units__ (int* unitRefVal, char* retText, int retText_len) {
58    return rp_get_units(unitRefVal,retText,retText_len);
59}
60
61int
62RP_GET_UNITS (int* unitRefVal, char* retText, int retText_len) {
63    return rp_get_units(unitRefVal,retText,retText_len);
64}
65
66int
67rp_get_units_name_     (int* unitRefVal, char* retText, int retText_len) {
68    return rp_get_units_name(unitRefVal,retText,retText_len);
69}
70
71int
72rp_get_units_name__    (int* unitRefVal, char* retText, int retText_len) {
73    return rp_get_units_name(unitRefVal,retText,retText_len);
74}
75
76int
77RP_GET_UNITS_NAME      (int* unitRefVal, char* retText, int retText_len) {
78    return rp_get_units_name(unitRefVal,retText,retText_len);
79}
80
81int
82rp_get_exponent_       (int* unitRefVal, double* retExponent) {
83    return rp_get_exponent(unitRefVal,retExponent);
84}
85
86int
87rp_get_exponent__      (int* unitRefVal, double* retExponent) {
88    return rp_get_exponent(unitRefVal,retExponent);
89}
90
91int
92RP_GET_EXPONENT        (int* unitRefVal, double* retExponent) {
93    return rp_get_exponent(unitRefVal,retExponent);
94}
95
96int
97rp_get_basis_          (int* unitRefVal) {
98    return rp_get_basis(unitRefVal);
99}
100
101int
102rp_get_basis__         (int* unitRefVal) {
103    return rp_get_basis(unitRefVal);
104}
105
106int
107RP_GET_BASIS           (int* unitRefVal) {
108    return rp_get_basis(unitRefVal);
109}
110
111int
112rp_units_convert_dbl_  (char* fromVal,
113                            char* toUnitsName,
114                            double* convResult,
115                            int fromVal_len,
116                            int toUnitsName_len ) {
117
118    return rp_units_convert_dbl( fromVal, toUnitsName, convResult,
119                                 fromVal_len, toUnitsName_len);
120}
121
122int
123rp_units_convert_dbl__ (char* fromVal,
124                            char* toUnitsName,
125                            double* convResult,
126                            int fromVal_len,
127                            int toUnitsName_len ) {
128
129    return rp_units_convert_dbl( fromVal, toUnitsName, convResult,
130                                 fromVal_len, toUnitsName_len);
131}
132
133int
134RP_UNITS_CONVERT_DBL   (char* fromVal,
135                            char* toUnitsName,
136                            double* convResult,
137                            int fromVal_len,
138                            int toUnitsName_len ) {
139
140    return rp_units_convert_dbl( fromVal, toUnitsName, convResult,
141                                 fromVal_len, toUnitsName_len);
142}
143
144int
145rp_units_convert_str_  (char* fromVal,
146                            char* toUnitsName,
147                            char* retText,
148                            int fromVal_len,
149                            int toUnitsName_len,
150                            int retText_len     ) {
151
152    return rp_units_convert_str( fromVal,toUnitsName, retText, fromVal_len,
153                                 toUnitsName_len, retText_len);
154}
155
156int
157rp_units_convert_str__ (char* fromVal,
158                            char* toUnitsName,
159                            char* retText,
160                            int fromVal_len,
161                            int toUnitsName_len,
162                            int retText_len     ) {
163
164    return rp_units_convert_str( fromVal,toUnitsName, retText, fromVal_len,
165                                 toUnitsName_len, retText_len);
166}
167
168int
169RP_UNITS_CONVERT_STR   (char* fromVal,
170                            char* toUnitsName,
171                            char* retText,
172                            int fromVal_len,
173                            int toUnitsName_len,
174                            int retText_len     ) {
175
176    return rp_units_convert_str( fromVal,toUnitsName, retText, fromVal_len,
177                                 toUnitsName_len, retText_len);
178}
179
180#ifdef __cplusplus
181}
182#endif
183
184#endif
Note: See TracBrowser for help on using the repository browser.