Changeset 83
- Timestamp:
- Oct 5, 2005 8:17:26 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 21 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/app-fermi/fortran/Makefile
r73 r83 14 14 15 15 LIB_DIR = $(RAPPTURE_DIR)/lib 16 LIB_RAPPTURE = -Wl,-rpath,$(LIB_DIR) -L$(LIB_DIR) -lrappture 16 LIB_RAPPTURE = -Wl,-rpath,$(LIB_DIR) -L$(LIB_DIR) -lrappture_test 17 17 18 18 all: $(PROGS) -
trunk/examples/app-fermi/fortran/fermi.f
r66 r83 13 13 IMPLICIT NONE 14 14 15 integer rp_lib 16 double precision rp_lib_get_double 15 integer rp_lib, rp_units_convert_dbl, rp_units_add_presets 17 16 18 integer driver 17 integer driver, ok 19 18 double precision T, Ef, kT, Emin, Emax, dE, f, E 20 CHARACTER*100 inFile 19 CHARACTER*100 inFile, strVal 21 20 character*40 xy 22 21 … … 24 23 driver = rp_lib(inFile) 25 24 26 T = rp_lib_get_double(driver, 27 + "input.number(temperature).current") 28 Ef = rp_lib_get_double(driver, 29 + "input.number(Ef).current") 25 ok = rp_units_add_presets("all") 26 27 call rp_lib_get(driver, 28 + "input.number(temperature).current", strVal) 29 ok = rp_units_convert_dbl(strVal,"K",T) 30 31 call rp_lib_get(driver, 32 + "input.number(Ef).current", strVal) 33 ok = rp_units_convert_dbl(strVal,"K",Ef) 30 34 31 35 kT = 8.61734e-5 * T -
trunk/gui/scripts/units.tcl
r56 r83 476 476 477 477 Rappture::Units::define eV -type energy -metric yes 478 Rappture::Units::define J->eV {J/1.602177e-19} {eV*1.602177e-19} 478 479 479 480 Rappture::Units::define V -type voltage -metric yes -
trunk/include/cee/RpLibraryCInterface.h
r77 r83 1 /* 2 * ---------------------------------------------------------------------- 3 * INTERFACE: C Rappture Library Header 4 * 5 * ====================================================================== 6 * AUTHOR: Derrick Kearney, Purdue University 7 * Copyright (c) 2005 8 * Purdue Research Foundation, West Lafayette, IN 9 * ====================================================================== 10 */ 1 11 2 12 … … 72 82 const char* nodeId (RpLibrary* node); 73 83 84 void result (RpLibrary* lib); 85 74 86 #ifdef __cplusplus 75 87 } -
trunk/include/cee/RpUnitsCInterface.h
r76 r83 1 1 /* 2 * ---------------------------------------------------------------------- 3 * INTERFACE: C Rappture Units Header 4 * 5 * ====================================================================== 6 * AUTHOR: Derrick Kearney, Purdue University 7 * Copyright (c) 2005 8 * Purdue Research Foundation, West Lafayette, IN 9 * ====================================================================== 10 */ 2 11 3 12 #ifdef __cplusplus … … 20 29 21 30 const char* getUnitsName(RpUnits* unit); 22 31 23 32 double getExponent(RpUnits* unit); 24 33 25 34 RpUnits* getBasis(RpUnits* unit); 26 35 … … 35 44 int showUnits, 36 45 int* result ); 37 46 38 47 const char* convert_str ( const char* fromVal, 39 48 const char* toUnitsName, 40 49 int showUnits, 41 50 int* result ); 42 51 43 52 const char* convert_obj_str ( RpUnits* fromUnits, 44 53 RpUnits* toUnits, 45 54 double val, 46 55 int showUnits ); 47 56 48 57 const char* convert_obj_str_result( RpUnits* fromUnits, 49 58 RpUnits* toUnits, … … 55 64 const char* toUnitsName, 56 65 int* result ); 57 66 58 67 double convert_obj_double ( RpUnits* fromUnits, 59 68 RpUnits* toUnits, -
trunk/include/core/RpLibrary.h
r77 r83 1 /* 2 * ---------------------------------------------------------------------- 3 * Rappture Library Header 4 * 5 * ====================================================================== 6 * AUTHOR: Derrick Kearney, Purdue University 7 * Copyright (c) 2005 8 * Purdue Research Foundation, West Lafayette, IN 9 * ====================================================================== 10 */ 1 11 2 12 #include "scew.h" … … 5 15 #include <string> 6 16 #include <sstream> 17 #include <fstream> 7 18 #include <stdlib.h> 8 19 #include <errno.h> 20 #include <time.h> 9 21 10 22 /* indentation size (in whitespaces) */ … … 17 29 { 18 30 public: 19 31 20 32 // users member fxns 21 33 22 34 RpLibrary* element (std::string path = "", std::string as = "object"); 35 23 36 // should return RpObject& but for simplicity right now it doesnt 24 37 // RpObject will either be an Array, RpString, RpNumber ... 25 /* 26 RpLibrary** children ( std::string path = "", 27 std::string as = "object", 28 std::string type = "" ); 29 */ 30 31 RpLibrary* children ( std::string path = "", 32 RpLibrary* rpChildNode = NULL, 38 39 RpLibrary* children ( std::string path = "", 40 RpLibrary* rpChildNode = NULL, 33 41 std::string type = "", 34 42 int* childCount = NULL ); … … 42 50 std::string id = "", 43 51 int append = 0 ); 44 52 45 53 RpLibrary& put ( std::string path, 46 54 double value, … … 55 63 std::string nodeId(); 56 64 std::string nodeComp(); 57 65 66 void result(); 58 67 const char* nodeTypeC(); 59 68 const char* nodeIdC(); … … 67 76 tree (NULL), 68 77 root (NULL) 69 70 78 { 71 79 tree = scew_tree_create(); … … 81 89 root (NULL) 82 90 { 83 91 84 92 if (filePath.length() != 0) { 85 93 // file path should not be null or empty string unless we are … … 105 113 if (code == scew_error_expat) 106 114 { 107 enum XML_Error expat_code = 115 enum XML_Error expat_code = 108 116 scew_error_expat_code(parser); 109 printf("Expat error #%d (line %d, column %d): %s\n", 117 printf("Expat error #%d (line %d, column %d): %s\n", 110 118 expat_code, 111 119 scew_error_expat_line(parser), … … 115 123 // should probably exit program or something 116 124 // return EXIT_FAILURE; 117 125 118 126 } 119 127 … … 127 135 } 128 136 129 137 130 138 // copy constructor 131 139 // for some reason making this a const gives me problems when calling xml() … … 149 157 buffer = other.xml(); 150 158 buffLen = buffer.length(); 151 159 152 160 if (buffLen > 0) { 153 161 if (!scew_parser_load_buffer(parser,buffer.c_str(),buffLen)) … … 161 169 if (code == scew_error_expat) 162 170 { 163 enum XML_Error expat_code = 171 enum XML_Error expat_code = 164 172 scew_error_expat_code(parser); 165 173 printf("Expat error #%d (line %d, column %d): %s\n", … … 172 180 // return an empty RpLibrary? 173 181 // return EXIT_FAILURE; 174 182 175 183 parser = NULL; 176 184 } … … 214 222 215 223 // Loads the XML from other 216 // the length cannot be 0 because xml() should not be returning 224 // the length cannot be 0 because xml() should not be returning 217 225 // empty strings 218 226 buffer = other.xml(); 219 227 buffLen = buffer.length(); 220 228 221 229 if (buffLen > 0) { 222 230 if (!scew_parser_load_buffer(parser,buffer.c_str(),buffLen)) … … 242 250 // or maybe return an empty RpLibrary? 243 251 // return EXIT_FAILURE; 244 252 245 253 // return this object to its previous state. 246 254 parser = tmp_parser; … … 256 264 257 265 // free the current RpLibrary's data 258 // we do the free so far down so we can see if 266 // we do the free so far down so we can see if 259 267 // parsing the other object's xml fails. 260 // if the parsing fails, we can still return this 268 // if the parsing fails, we can still return this 261 269 // object to its previous state. 262 270 if (tmp_tree && tmp_freeTree) { … … 278 286 return *this; 279 287 } // end operator= 280 288 281 289 282 290 // default destructor … … 304 312 scew_tree* tree; 305 313 scew_element* root; 306 307 // flag to tell if we are responsible for calling scew_tree_free 308 // on the tree structure. if we get our tree by using the scew_tree_create 309 // fxn, we need to free it. if we get our tree using the scew_parser_tree 314 315 // flag to tell if we are responsible for calling scew_tree_free 316 // on the tree structure. if we get our tree by using the 317 // scew_tree_create 318 // fxn, we need to free it. if we get our tree using the 319 // scew_parser_tree 310 320 // fxn, then it will be free'd when the parser is free'd. 311 321 int freeTree; … … 316 326 tree (NULL), 317 327 root (node) 318 328 319 329 {} 320 330 … … 324 334 std::string _node2name (scew_element* node); 325 335 std::string _node2comp (scew_element* node); 326 int _splitPath (std::string& path, 327 std::string& tagName, 328 int* idx, 336 int _splitPath (std::string& path, 337 std::string& tagName, 338 int* idx, 329 339 std::string& id ); 330 scew_element* _find (std::string path, int create); 340 scew_element* _find (std::string path, int create); 331 341 void print_indent (unsigned int indent, std::stringstream& outString); 332 342 void print_attributes (scew_element* element, std::stringstream& outString); 333 void print_element( scew_element* element, 334 unsigned int indent, 343 void print_element( scew_element* element, 344 unsigned int indent, 335 345 std::stringstream& outString ); 336 346 -
trunk/include/core/RpUnits.h
r76 r83 1 /* 2 * ---------------------------------------------------------------------- 3 * RpUnits.h - Header file for Rappture Units 4 * 5 * RpUnits Class Declaration / Definition 6 * 7 * ====================================================================== 8 * AUTHOR: Derrick Kearney, Purdue University 9 * Copyright (c) 2004-2005 10 * Purdue Research Foundation, West Lafayette, IN 11 * ====================================================================== 12 */ 13 1 14 #include <iostream> 2 15 #include <string> … … 11 24 #include "RpUnitsStd.h" 12 25 13 #ifndef _RpUNITS_H 26 #ifndef _RpUNITS_H 14 27 #define _RpUNITS_H 15 28 16 class RpUnits; 29 class RpUnits; 17 30 18 31 class unit … … 30 43 const std::string units; 31 44 double exponent; 32 // RpUnits* basis[4]; 33 RpUnits* basis; 45 RpUnits* basis; 34 46 35 47 unit* prev; 36 48 unit* next; 37 49 38 unit (39 const std::string& units,40 double& exponent,41 // RpUnits** basis,42 RpUnits* basis, 50 // private constructor 51 unit ( 52 const std::string& units, 53 double& exponent, 54 RpUnits* basis, 43 55 unit* next 44 56 ) 45 : units (units), 46 exponent (exponent), 47 basis (basis), 57 : units (units), 58 exponent (exponent), 59 basis (basis), 48 60 prev (NULL), 49 61 next (next) 50 { }; 51 62 {}; 63 64 /* 65 // private copy constructor 66 unit ( unit& other ) 67 : units (other.units), 68 exponent (other.exponent), 69 basis (other.basis), 70 prev (other.prev), 71 next (other.next) 72 {}; 73 74 // copy assignment operator 75 unit& operator= (unit& other) { 76 units = other.units; 77 exponent = other.exponent; 78 basis = other.basis; 79 prev = other.prev; 80 next = other.next; 81 } 82 83 // destructor (its not virtual yet, still testing) 84 ~unit () { 85 86 } 87 */ 52 88 53 89 void newExponent(double newExponent) {exponent = newExponent;}; … … 61 97 // hold the pointer to a function to do the forward conversion (from->to) 62 98 // hold the pointer to a function to do the backward conversion (to->from) 63 // 99 // 64 100 class conversion 65 101 { … … 68 104 const RpUnits* getFrom() { return (const RpUnits*) fromPtr; }; 69 105 const RpUnits* getTo() { return (const RpUnits*) toPtr; }; 70 106 71 107 friend class RpUnits; 72 108 … … 86 122 87 123 // constructor 88 // private because i only want RpUnits to be able to 124 // private because i only want RpUnits to be able to 89 125 // create a conversion 90 conversion ( 91 RpUnits* fromPtr, 92 RpUnits* toPtr, 126 conversion ( 127 RpUnits* fromPtr, 128 RpUnits* toPtr, 93 129 double (*convForwFxnPtr)(double), 94 130 double (*convBackFxnPtr)(double), … … 97 133 ) 98 134 : fromPtr (fromPtr), 99 toPtr (toPtr), 135 toPtr (toPtr), 100 136 convForwFxnPtr (convForwFxnPtr), 101 137 convBackFxnPtr (convBackFxnPtr), … … 106 142 prev (prev), 107 143 next (next) 108 { 109 }; 110 111 conversion ( 144 {}; 145 146 conversion ( 112 147 RpUnits* fromPtr, 113 148 RpUnits* toPtr, … … 120 155 ) 121 156 : fromPtr (fromPtr), 122 toPtr (toPtr), 157 toPtr (toPtr), 123 158 convForwFxnPtr (NULL), 124 159 convBackFxnPtr (NULL), … … 129 164 prev (prev), 130 165 next (next) 131 { 132 }; 166 {}; 133 167 134 168 // copy constructor … … 139 173 // used by the RpUnits class to create a linked list of the conversions 140 174 // associated with the specific unit. 141 // 175 // 142 176 // we could templitize this and make a generic linked list 143 177 // or could use generic linked list class from book programming with objects … … 156 190 convEntry* next; 157 191 158 convEntry ( 159 conversion* conv, 192 convEntry ( 193 conversion* conv, 160 194 convEntry* prev, 161 195 convEntry* next 162 196 ) 163 : conv (conv), 197 : conv (conv), 164 198 prev (prev), 165 199 next (next) 166 { 200 {}; 167 201 168 202 /* … … 176 210 class RpUnits 177 211 { 178 /* 212 /* 179 213 * helpful units site 180 214 * http://aurora.regenstrief.org/~gunther/units.html … … 182 216 183 217 public: 184 218 185 219 // users member fxns 186 220 std::string getUnits(); … … 190 224 191 225 // convert from one RpUnits to another if the conversion is defined 192 double convert(RpUnits* toUnits, double val, int* result = NULL); 226 double convert(RpUnits* toUnits, double val, int* result = NULL); 193 227 // convert from one RpUnits to another if the conversion is defined 194 void* convert(RpUnits* toUnits, void* val, int* result = NULL); 228 void* convert(RpUnits* toUnits, void* val, int* result = NULL); 195 229 // convert from one RpUnits to another if the conversion is defined 196 double convert(std::string, double val); 230 double convert(std::string, double val); 197 231 // convert from one RpUnits to another if the conversion is defined 198 std::string convert ( RpUnits* toUnits, 199 double val, 200 int showUnits = 0, 201 int* result = NULL ); 232 std::string convert ( RpUnits* toUnits, 233 double val, 234 int showUnits = 0, 235 int* result = NULL ); 202 236 203 237 static std::string convert ( std::string val, … … 210 244 211 245 // turn the current unit to the metric system 212 // this should only be used for units that are part of the 246 // this should only be used for units that are part of the 213 247 // metric system. doesnt deal with exponents, just prefixes 214 248 double makeBasis(double value, int* result = NULL); 215 249 RpUnits & makeBasis(double* value, int* result = NULL); 216 250 217 251 static int makeMetric(RpUnits * basis); 218 252 … … 222 256 static RpUnits* find(std::string key) 223 257 { 224 // dict.find seems to return a (RpUnits* const) so i had to 258 // dict.find seems to return a (RpUnits* const) so i had to 225 259 // cast it as a (RpUnits*) 226 260 227 261 // dict pointer 228 // RpUnits* unitEntry = (RpUnits*) *(dict.find(key).getValue()); 229 RpUnits* unitEntry = (RpUnits*) *(dict->find(key).getValue()); 230 231 // RpUnits* unitEntry = (RpUnits*) dEntr.getValue(); 262 RpUnits* unitEntry = (RpUnits*) *(dict->find(key).getValue()); 232 263 233 264 // dict pointer 234 // if (unitEntry == (RpUnits*)dict.getNullEntry().getValue()) {235 265 if (unitEntry == (RpUnits*)dict->getNullEntry().getValue()) { 236 266 unitEntry = NULL; … … 246 276 static RpUnits * defineCmplx(const std::string units,RpUnits * basis); 247 277 // 248 // add relation rule 249 250 static RpUnits * define(RpUnits* from, 251 RpUnits* to, 278 // add relation rule 279 280 static RpUnits * define(RpUnits* from, 281 RpUnits* to, 252 282 double (*convForwFxnPtr)(double), 253 283 double (*convBackFxnPtr)(double)); 254 284 255 static RpUnits * define(RpUnits* from, 256 RpUnits* to, 285 static RpUnits * define(RpUnits* from, 286 RpUnits* to, 257 287 void* (*convForwFxnPtr)(void*, void*), 258 288 void* convForwData, … … 271 301 static int addPresets (std::string group); 272 302 273 // undefining a relation rule is probably not needed 303 // undefining a relation rule is probably not needed 274 304 // int undefine(); // delete a relation 275 305 … … 279 309 280 310 // why are these functions friends... 281 // probably need to find a better way to let RpUnits 311 // probably need to find a better way to let RpUnits 282 312 // use the RpDict and RpDictEntry fxns 283 313 friend class RpDict<std::string,RpUnits*>; … … 286 316 // copy constructor 287 317 RpUnits ( const RpUnits& myRpUnit ) 288 { 318 { 289 319 290 320 /* … … 295 325 */ 296 326 297 // copy constructor for unit 327 // copy constructor for unit 298 328 unit* tmp = NULL; 299 329 unit* newUnit = NULL; … … 319 349 320 350 head = tmp; 321 351 322 352 }; 323 353 324 354 /* 355 // copy assignment operator 325 356 RpUnits& operator= (const RpUnits& myRpUnit) { 326 357 … … 332 363 } 333 364 */ 334 365 335 366 private: 336 367 … … 348 379 // move through the linked list, only converting the metric elements. 349 380 // 350 381 351 382 // used by the RpUnits when defining units elements 352 383 unit* head; … … 371 402 372 403 373 RpUnits ( 374 const std::string& units, 375 double& exponent, 376 // RpUnits* basis[] 404 RpUnits ( 405 const std::string& units, 406 double& exponent, 377 407 RpUnits* basis 378 408 ) … … 386 416 387 417 388 389 RpUnits ( 418 419 RpUnits ( 390 420 RpUnits* from, 391 421 RpUnits* to, … … 397 427 : head (NULL), 398 428 convList (NULL), 399 conv (new conversion 429 conv (new conversion 400 430 (from,to,convForwFxnPtr,convBackFxnPtr,prev,next)) 401 { 431 { 402 432 connectConversion(from); 403 433 connectConversion(to); … … 407 437 408 438 409 410 RpUnits ( 439 440 RpUnits ( 411 441 RpUnits* from, 412 442 RpUnits* to, … … 426 456 ) 427 457 ) 428 { 458 { 429 459 connectConversion(from); 430 460 connectConversion(to); … … 457 487 // returns 0 on success (object inserted or already exists) 458 488 // returns !0 on failure (object cannot be inserted or dne) 459 int RpUnits::insert(std::string key); 489 int RpUnits::insert(std::string key); 460 490 461 491 // link two RpUnits objects that already exist in RpUnitsTable -
trunk/include/fortran/RpFortranCommon.h
r77 r83 1 /* 2 * ---------------------------------------------------------------------- 3 * INTERFACE: Fortran Rappture Common Functions 4 * 5 * Fortran functions common to all interfaces. 6 * 7 * ====================================================================== 8 * AUTHOR: Derrick Kearney, Purdue University 9 * Copyright (c) 2005 10 * Purdue Research Foundation, West Lafayette, IN 11 * ====================================================================== 12 */ 1 13 2 14 #include <stdlib.h> … … 9 21 10 22 11 #ifdef __cplusplus 23 #ifdef __cplusplus 12 24 extern "C" { 13 25 #endif … … 17 29 void fortranify(const char* inBuff, char* retText, int retTextLen); 18 30 19 #ifdef __cplusplus 31 #ifdef __cplusplus 20 32 } 21 33 #endif -
trunk/include/fortran/RpLibraryFInterface.h
r77 r83 1 /* 2 * ---------------------------------------------------------------------- 3 * INTERFACE: Fortran Rappture Library Header 4 * 5 * ====================================================================== 6 * AUTHOR: Derrick Kearney, Purdue University 7 * Copyright (c) 2005 8 * Purdue Research Foundation, West Lafayette, IN 9 * ====================================================================== 10 */ 1 11 2 12 #include "RpLibrary.h" … … 36 46 # define rp_lib_write_xml rp_lib_write_xml_ 37 47 # define rp_lib_xml rp_lib_xml_ 48 # define rp_lib_node_comp rp_lib_node_comp_ 49 # define rp_lib_node_type rp_lib_node_type_ 50 # define rp_lib_node_id rp_lib_node_id_ 51 # define rp_result rp_result_ 38 52 # define rp_quit rp_quit_ 39 53 #elif defined(COMPNAME_ADD2UNDERSCORE) … … 59 73 # define rp_lib_write_xml rp_lib_write_xml__ 60 74 # define rp_lib_xml rp_lib_xml__ 75 # define rp_lib_node_comp rp_lib_node_comp__ 76 # define rp_lib_node_type rp_lib_node_type__ 77 # define rp_lib_node_id rp_lib_node_id__ 78 # define rp_result rp_result__ 61 79 # define rp_quit rp_quit__ 62 80 #elif defined(COMPNAME_NOCHANGE) … … 82 100 # define rp_lib_write_xml rp_lib_write_xml 83 101 # define rp_lib_xml rp_lib_xml 102 # define rp_lib_node_comp rp_lib_node_comp 103 # define rp_lib_node_type rp_lib_node_type 104 # define rp_lib_node_id rp_lib_node_id 105 # define rp_result rp_result 84 106 # define rp_quit rp_quit 85 107 #elif defined(COMPNAME_UPPERCASE) … … 105 127 # define rp_lib_write_xml RP_LIB_WRITE_XML 106 128 # define rp_lib_xml RP_LIB_XML 129 # define rp_lib_node_comp RP_LIB_NODE_COMP 130 # define rp_lib_node_type RP_LIB_NODE_TYPE 131 # define rp_lib_node_id RP_LIB_NODE_ID 132 # define rp_result RP_RESULT 107 133 # define rp_quit RP_QUIT 108 134 #endif … … 111 137 void rp_init(); 112 138 113 int rp_lib (const char* filePath, int filePath_len);114 115 void rp_lib_element_comp ( int* handle,116 char* path, 117 char* retText, 118 int path_len, 119 int retText_len ); 120 121 void rp_lib_element_id ( int* handle,122 char* path, 123 char* retText, 124 int path_len, 125 int retText_len ); 126 127 void rp_lib_element_type (int* handle,128 char* path, 129 char* retText, 130 int path_len, 131 int retText_len ); 132 133 int rp_lib_element_obj ( int* handle,139 int rp_lib ( const char* filePath, int filePath_len ); 140 141 void rp_lib_element_comp ( int* handle, 142 char* path, 143 char* retText, 144 int path_len, 145 int retText_len ); 146 147 void rp_lib_element_id ( int* handle, 148 char* path, 149 char* retText, 150 int path_len, 151 int retText_len ); 152 153 void rp_lib_element_type ( int* handle, 154 char* path, 155 char* retText, 156 int path_len, 157 int retText_len ); 158 159 int rp_lib_element_obj ( int* handle, 134 160 char* path, 135 161 int path_len ); 136 162 137 int rp_lib_child_num( int* handle, 138 char* path, 163 int rp_lib_child_num ( int* handle, 164 char* path, 165 int* childHandle, 139 166 int path_len); 140 167 141 int rp_lib_child_comp( int* handle, /* integer handle of library */ 142 char* path, /* DOM path of requested object */ 143 char* type, /* specific name of element */ 144 int* childNum, /* child number for iteration */ 145 char* retText, /* buffer to store return text */ 146 int path_len, /* length of path */ 147 int type_len, /* length of type */ 148 int retText_len /* length of return text buffer */ 149 ); 150 151 int rp_lib_child_id( int* handle, /* integer handle of library */ 152 char* path, /* DOM path of requested object */ 153 char* type, /* specific name of element */ 154 int* childNum, /* child number for iteration */ 155 char* retText, /* buffer to store return text */ 156 int path_len, /* length of path */ 157 int type_len, /* length of type */ 158 int retText_len /* length of return text buffer */ 159 ); 160 161 int rp_lib_child_type( int* handle, /* integer handle of library */ 162 char* path, /* DOM path of requested object */ 163 char* type, /* specific name of element */ 164 int* childNum, /* child number for iteration */ 165 char* retText, /* buffer to store return text */ 166 int path_len, /* length of path */ 167 int type_len, /* length of type */ 168 int retText_len /* length of return text buffer */ 169 ); 170 171 int rp_lib_child_obj( int* handle, 172 char* path, 173 char* type, 174 int path_len, 175 int type_len 176 ); 177 178 void rp_lib_get( int* handle, 179 char* path, 180 char* retText, 181 int path_len, 182 int retText_len ); 183 184 double rp_lib_get_double( int* handle, 168 int rp_lib_children ( int* handle, /* integer handle of library */ 169 char* path, /* search path of the xml */ 170 int* childHandle, /*int handle of last returned child*/ 171 int path_len /*length of the search path buffer*/ 172 ); 173 174 175 void rp_lib_get ( int* handle, 176 char* path, 177 char* retText, 178 int path_len, 179 int retText_len ); 180 181 double rp_lib_get_double ( int* handle, 185 182 char* path, 186 183 int path_len); 187 184 188 void rp_lib_put_str (int* handle,185 void rp_lib_put_str ( int* handle, 189 186 char* path, 190 187 char* value, … … 193 190 int value_len ); 194 191 195 void rp_lib_put_id_str (int* handle,192 void rp_lib_put_id_str ( int* handle, 196 193 char* path, 197 194 char* value, … … 202 199 int id_len ); 203 200 204 void rp_lib_put_obj (int* handle,201 void rp_lib_put_obj ( int* handle, 205 202 char* path, 206 203 int* valHandle, … … 208 205 int path_len ); 209 206 210 void rp_lib_put_id_obj (int* handle,207 void rp_lib_put_id_obj ( int* handle, 211 208 char* path, 212 209 int* valHandle, … … 216 213 int id_len ); 217 214 218 int rp_lib_remove ( int* handle,219 char* path, 215 int rp_lib_remove ( int* handle, 216 char* path, 220 217 int path_len); 221 218 222 int rp_lib_xml_len( int* handle);223 224 void rp_lib_xml( int* handle,225 char* retText, 226 int retText_len); 227 228 int rp_lib_write_xml( int* handle,229 char* outFile, 219 int rp_lib_xml_len( int* handle); 220 221 void rp_lib_xml( int* handle, 222 char* retText, 223 int retText_len); 224 225 int rp_lib_write_xml( int* handle, 226 char* outFile, 230 227 int outFile_len); 228 229 void rp_lib_node_comp ( int* handle, 230 char* retText, 231 int retText_len); 232 233 void rp_lib_node_type ( int* handle, 234 char* retText, 235 int retText_len); 236 237 void rp_lib_node_id ( int* handle, 238 char* retText, 239 int retText_len); 240 241 void rp_result( int* handle ); 242 231 243 void rp_quit(); 232 244 -
trunk/include/fortran/RpUnitsFInterface.h
r76 r83 1 /* 2 * ---------------------------------------------------------------------- 3 * INTERFACE: Fortran Rappture Units Source 4 * 5 * ====================================================================== 6 * AUTHOR: Derrick Kearney, Purdue University 7 * Copyright (c) 2005 8 * Purdue Research Foundation, West Lafayette, IN 9 * ====================================================================== 10 */ 11 1 12 #include "RpFortranCommon.h" 2 13 -
trunk/src/Makefile
r77 r83 14 14 LIB_SCEW_INCL = -I $(SCEW_HEADERS) 15 15 LIB_SCEW_FLAG = -L/opt/rappture/lib -lscew 16 #LIB_SCEW_FLAG = /opt/rappture/lib/libscew.a 16 17 #LIB_SCEW_FLAG = -static -L/opt/rappture/lib -lscew 17 18 … … 100 101 101 102 RP_IO_DEPS = RpLibrary.o RpLibraryCInterface.o RpLibraryFInterface.o scew_extras.o 102 RP_UNITS_DEPS = 103 RP_UNITS_DEPS = RpUnitsStd.o RpUnits.o RpUnitsCInterface.o RpUnitsFInterface.o 103 104 RP_OTHER_DEPS = RpFortranCommon.o 104 105 … … 121 122 #### libRpObjects ######################################################## 122 123 libRpObjects: RpVariable.o RpAbout.o RpNumber.o RpString.o RpBoolean.o RpChoice.o RpOption.o RpUnitsStd.o RpUnits.o 123 $(CXX) $(DEGUG) -shared -Wl,-rpath,$(LIB_DIR)/ \ 124 -Wl,-soname,$@.so -o $(LIB_DIR)/$@.so.0.0 $^ 124 $(CC) $(DEGUG) -shared -Wl,-rpath,$(LIB_DIR)/ \ 125 -Wl,-soname,$@.so -o $(LIB_DIR)/$@.so.0.0 $^ -lstdc++ 126 # $(CXX) $(DEGUG) -shared -Wl,-rpath,$(LIB_DIR)/ \ 127 # -Wl,-soname,$@.so -o $(LIB_DIR)/$@.so.0.0 $^ 125 128 126 129 /sbin/ldconfig -n $(LIB_DIR) -
trunk/src/cee/RpLibraryCInterface.cc
r77 r83 1 /* 2 * ---------------------------------------------------------------------- 3 * INTERFACE: C Rappture Library Source 4 * 5 * ====================================================================== 6 * AUTHOR: Derrick Kearney, Purdue University 7 * Copyright (c) 2005 8 * Purdue Research Foundation, West Lafayette, IN 9 * ====================================================================== 10 */ 11 1 12 #include "RpLibrary.h" 2 13 #include "RpLibraryCInterface.h" … … 6 17 #endif 7 18 8 RpLibrary* 19 RpLibrary* 9 20 library (const char* path) 10 21 { … … 24 35 return lib->element(path); 25 36 } 26 27 RpLibrary* 37 38 RpLibrary* 28 39 elementAsObject (RpLibrary* lib, const char* path) 29 40 { … … 31 42 } 32 43 33 const char* 44 const char* 34 45 elementAsType (RpLibrary* lib, const char* path) 35 46 { … … 44 55 } 45 56 46 const char* 57 const char* 47 58 elementAsComp (RpLibrary* lib, const char* path) 48 59 { … … 57 68 } 58 69 59 const char* 70 const char* 60 71 elementAsId (RpLibrary* lib, const char* path) 61 72 { … … 78 89 79 90 RpLibrary* 80 childrenByType( RpLibrary* lib, 81 const char* path, 82 RpLibrary* childEle, 91 childrenByType( RpLibrary* lib, 92 const char* path, 93 RpLibrary* childEle, 83 94 const char* type ) 84 95 { … … 86 97 } 87 98 88 /* 89 RpLibrary** 90 childrenAsObject (RpLibrary* lib, const char* path, const char* type) 91 { 92 return chilren(lib, path,type); 93 } 94 95 const char* 96 childrenAsType (RpLibrary* lib, const char* path, const char* type) 97 { 98 99 } 100 101 const char* 102 childrenAsComp (RpLibrary* lib, const char* path, const char* type) 103 { 104 105 } 106 107 const char* 108 childrenAsId (RpLibrary* lib, const char* path, const char* type) 109 { 110 111 } 112 */ 113 114 RpLibrary* 99 RpLibrary* 115 100 get (RpLibrary* lib, const char* path) 116 101 { … … 118 103 } 119 104 120 const char* 105 const char* 121 106 getString (RpLibrary* lib, const char* path) 122 107 { … … 126 111 } 127 112 128 double 113 double 129 114 getDouble (RpLibrary* lib, const char* path) 130 115 { … … 132 117 } 133 118 134 void 135 put (RpLibrary* lib, 136 const char* path, 119 void 120 put (RpLibrary* lib, 121 const char* path, 137 122 const char* value, 138 123 const char* id, … … 142 127 } 143 128 144 void 145 putStringId (RpLibrary* lib, 146 const char* path, 147 const char* value, 129 void 130 putStringId (RpLibrary* lib, 131 const char* path, 132 const char* value, 148 133 const char* id, 149 134 int append ) … … 152 137 } 153 138 154 void 155 putString ( RpLibrary* lib, 156 const char* path, 157 const char* value, 139 void 140 putString ( RpLibrary* lib, 141 const char* path, 142 const char* value, 158 143 int append ) 159 144 { … … 162 147 163 148 void 164 putDoubleId (RpLibrary* lib, 165 const char* path, 166 double value, 149 putDoubleId (RpLibrary* lib, 150 const char* path, 151 double value, 167 152 const char* id, 168 153 int append ) … … 172 157 173 158 void 174 putDouble (RpLibrary* lib, 175 const char* path, 176 double value, 159 putDouble (RpLibrary* lib, 160 const char* path, 161 double value, 177 162 int append ) 178 163 { … … 180 165 } 181 166 182 const char* 167 const char* 183 168 xml (RpLibrary* lib) 184 169 { … … 188 173 } 189 174 190 const char* 175 const char* 191 176 nodeComp (RpLibrary* node) 192 177 { … … 196 181 } 197 182 198 const char* 183 const char* 199 184 nodeType (RpLibrary* node) 200 185 { … … 204 189 } 205 190 206 const char* 191 const char* 207 192 nodeId (RpLibrary* node) 208 193 { … … 212 197 } 213 198 214 199 void 200 result (RpLibrary* lib) 201 { 202 lib->result(); 203 } 215 204 216 205 #ifdef __cplusplus -
trunk/src/cee/RpUnitsCInterface.cc
r76 r83 1 /* 2 * ---------------------------------------------------------------------- 3 * INTERFACE: C Rappture Units Source 4 * 5 * ====================================================================== 6 * AUTHOR: Derrick Kearney, Purdue University 7 * Copyright (c) 2005 8 * Purdue Research Foundation, West Lafayette, IN 9 * ====================================================================== 10 */ 11 1 12 #include "RpUnits.h" 2 13 #include "RpUnitsCInterface.h" … … 7 18 8 19 RpUnits* defineUnit(const char* unitSymbol, RpUnits* basis) { 9 20 10 21 return RpUnits::define(unitSymbol, basis); 11 22 } … … 20 31 21 32 RpUnits* find(const char* key) { 22 33 23 34 return RpUnits::find(key); 24 35 } 25 36 26 37 const char* getUnits(RpUnits* unit) { 27 38 28 39 static std::string retVal; 29 40 retVal = unit->getUnits(); … … 32 43 33 44 const char* getUnitsName(RpUnits* unit) { 34 45 35 46 static std::string retVal; 36 47 retVal = unit->getUnitsName(); … … 44 55 45 56 RpUnits* getBasis(RpUnits* unit) { 46 57 47 58 return unit->getBasis(); 48 59 } … … 80 91 return convert_obj_str_result(fromUnits,toUnits,val,showUnits,NULL); 81 92 } 82 93 83 94 const char* convert_obj_str_result( RpUnits* fromUnits, 84 95 RpUnits* toUnits, … … 86 97 int showUnits, 87 98 int* result ) { 88 99 89 100 static std::string retVal; 90 101 retVal = fromUnits->convert(toUnits,val,showUnits,result); … … 119 130 double val, 120 131 int* result ) { 121 132 122 133 return fromUnits->convert(toUnits,val,result); 123 134 } -
trunk/src/core/RpLibrary.cc
r77 r83 1 /* 2 * ---------------------------------------------------------------------- 3 * Rappture Library Source 4 * 5 * ====================================================================== 6 * AUTHOR: Derrick Kearney, Purdue University 7 * Copyright (c) 2005 8 * Purdue Research Foundation, West Lafayette, IN 9 * ====================================================================== 10 */ 1 11 2 12 #include "RpLibrary.h" … … 15 25 while((attribute=scew_attribute_next(element, attribute)) != NULL) 16 26 { 17 if (strcmp(scew_attribute_name(attribute),attributeName.c_str()) == 0){ 27 if ( strcmp( scew_attribute_name(attribute), 28 attributeName.c_str()) == 0 ){ 18 29 attrVal = scew_attribute_value(attribute); 19 30 } … … 28 39 } 29 40 30 int 41 int 31 42 RpLibrary::_path2list (std::string& path, std::string** list, int listLen) 32 43 { … … 43 54 list[index++] = new std::string(path.substr(start,pos-start)); 44 55 start = ++pos; 45 } 56 } 46 57 47 58 // add the last path to the list … … 98 109 retVal << type; 99 110 } 100 111 101 112 /* 102 113 if (retVal == NULL) { … … 109 120 110 121 scew_element_list_free(siblings); 111 122 112 123 } 113 124 else { 114 125 115 126 retVal << name; 116 127 } 117 128 118 129 return (retVal.str()); 119 130 } … … 167 178 } 168 179 scew_element_list_free(siblings); 169 180 170 181 } 171 182 else { … … 175 186 // retVal = scew_strjoinXX(type,name); 176 187 retVal << type << "(" << name << ")"; 177 178 } 179 188 189 } 190 180 191 return (retVal.str()); 181 192 } 182 193 183 int 194 int 184 195 RpLibrary::_splitPath (std::string& path, std::string& tagName, int* idx, std::string& id ) 185 196 { … … 249 260 scew_element* node = NULL; 250 261 scew_element** eleList = NULL; 251 252 262 263 253 264 if (path.empty()) { 254 265 //user gave an empty path … … 256 267 return tmpElement; 257 268 } 258 269 259 270 if (!list) { 260 271 // error calloc'ing space for list … … 275 286 # If the name is like "type", then assume the index is 0. 276 287 */ 277 288 278 289 // eleList = scew_element_list(tmpElement, tagName->c_str(), &count); 279 290 eleList = scew_element_list(tmpElement, tagName.c_str(), &count); … … 285 296 /* there is no element with the specified index */ 286 297 node = NULL; 287 } 298 } 288 299 289 300 scew_element_list_free(eleList); … … 328 339 scew_element_list_free(eleList); 329 340 eleList = NULL; 330 331 } 332 341 342 } 343 333 344 if (node == NULL) { 334 345 if (create == 0) { … … 342 353 // create == 1 343 354 // we should create the rest of the path 344 355 345 356 // create the new element 346 357 // need to figure out how to properly number the new element … … 360 371 } 361 372 362 373 363 374 // change this so youre not allocating and deallocating so much. 364 375 // make it static or something. … … 386 397 // list = NULL; 387 398 } 388 399 389 400 390 401 return tmpElement; … … 403 414 404 415 scew_element* retNode = _find(path,0); 405 416 406 417 if (retNode == NULL) { 407 418 // add error information as to why we are returning NULL … … 410 421 411 422 retLib = new RpLibrary( retNode ); 412 423 413 424 if (!retLib) { 414 425 // add error information as to why we are returning NULL … … 440 451 parentNode = _find(path,0); 441 452 } 442 453 443 454 if (parentNode == NULL) { 444 455 // node not found … … 480 491 std::cout << "childNum = " << childNum << std::endl; 481 492 retLib[childNum] = NULL; 482 493 483 494 // how do you free this?? 484 495 return retLib; … … 521 532 } 522 533 } 523 534 524 535 old_path = path; 525 536 … … 539 550 540 551 if ( (childNode = scew_element_next(parentNode,childNode)) ) { 541 552 542 553 if (!type.empty()) { 543 554 childName = scew_element_name(childNode); … … 578 589 579 590 scew_element* retNode = _find(path,0); 580 591 581 592 if (retNode == NULL) { 582 593 // need to raise error … … 602 613 603 614 scew_element* retNode = _find(path,0); 604 615 605 616 if (retNode == NULL) { 606 617 // need to raise error … … 637 648 if (! path.empty()) { 638 649 retNode = _find(path,1); 639 650 640 651 if (retNode) { 641 652 … … 646 657 value = tmpVal + value; 647 658 } 648 659 649 660 scew_element_set_contents(retNode,value.c_str()); 650 661 } … … 685 696 outString << "<?xml version=\"1.0\"?>\n"; 686 697 print_element(this->root, 0, outString); 687 698 688 699 return outString.str(); 689 700 } … … 705 716 { 706 717 return _node2comp(root); 718 } 719 720 /* 721 * ---------------------------------------------------------------------- 722 * FUNCTION: rpResult 723 * 724 * Clients call this function at the end of their simulation, to 725 * pass the simulation result back to the Rappture GUI. It writes 726 * out the given XML object to a runXXX.xml file, and then writes 727 * out the name of that file to stdout. 728 * ====================================================================== 729 * AUTHOR: Michael McLennan, Purdue University 730 * Copyright (c) 2004-2005 731 * Purdue Research Foundation, West Lafayette, IN 732 * ====================================================================== 733 */ 734 void 735 RpLibrary::result() { 736 std::stringstream outputFile; 737 std::fstream file; 738 std::string xmlText = ""; 739 time_t t = 0; 740 741 outputFile << "run" << (int)time(&t) << ".xml"; 742 file.open(outputFile.str().c_str(),std::ios::out); 743 744 if ( file.is_open() ) { 745 xmlText = xml(); 746 if (!xmlText.empty()) { 747 file << xmlText; 748 } 749 } 750 std::cout << "=RAPPTURE-RUN=>" << outputFile.str() << std::endl; 707 751 } 708 752 … … 745 789 746 790 void 747 RpLibrary::print_element( scew_element* element, 748 unsigned int indent, 791 RpLibrary::print_element( scew_element* element, 792 unsigned int indent, 749 793 std::stringstream& outString ) 750 794 { -
trunk/src/core/RpUnits.cc
r80 r83 3 3 * RpUnits.cc 4 4 * 5 * Data Members and member functions for the RpUnits class6 * 5 * Data Members and member functions for the RpUnits class 6 * 7 7 * ====================================================================== 8 8 * AUTHOR: Derrick Kearney, Purdue University … … 18 18 19 19 /************************************************************************ 20 * 21 * add RpUnits Object 22 * 20 * 21 * add RpUnits Object 22 * 23 23 ************************************************************************/ 24 24 25 25 RpUnits * RpUnits::define(const std::string units, RpUnits * basis) 26 { 26 { 27 27 RpUnits * newRpUnit = NULL; 28 28 … … 53 53 54 54 srchIndex--; 55 55 56 56 if (srchIndex < 0) { 57 57 break; 58 58 } 59 59 60 60 if ( isdigit(srchStr[srchIndex]) && !digiSearch && !alphaSearch) { 61 61 digiSearch = 1; 62 62 } 63 63 else if(!isdigit(srchStr[srchIndex]) && digiSearch && !alphaSearch) { 64 64 65 65 // convert our exponent to integer 66 66 67 67 // check to see if there is a + or - sign 68 68 if ( ( srchStr[srchIndex] == '+' ) 69 69 || ( srchStr[srchIndex] == '-' ) ) { 70 70 71 71 // evaluate a '+' or '-' sign with the value 72 72 srchIndex--; 73 73 } 74 74 75 75 srchIndex++; 76 76 77 77 exp = atoi(&srchStr[srchIndex]); 78 78 79 79 // we are no longer in a digit search 80 80 digiSearch = 0; 81 81 82 82 // place null character where the number starts 83 83 // so we know what we've already parsed 84 84 85 85 srchStr.erase(srchIndex); 86 86 length = srchStr.length(); 87 87 88 88 } 89 89 else if( isalpha(srchStr[srchIndex]) && !digiSearch && !alphaSearch) { … … 91 91 } 92 92 else if(!isalpha(srchStr[srchIndex]) && !digiSearch && alphaSearch) { 93 93 94 94 // adjust the exponent if none was provided 95 95 if (exp == 0) { 96 96 exp = 1; 97 97 } 98 98 99 99 // compare unit string to see if it is a recognized system 100 101 100 101 102 102 std::string cmpStr = srchStr.substr(srchIndex+1,length-srchIndex-1); 103 103 if (newRpUnit) { … … 110 110 // place a null character at the end of the string 111 111 // so we know what we've parsed so far. 112 112 113 113 srchStr.erase(srchIndex); 114 114 length = srchStr.length(); 115 115 116 116 // fix our searching flag 117 117 alphaSearch = 0; … … 121 121 // have to go back to all of the objects created and 122 122 // multiply their exponents by -1. 123 123 124 124 if (newRpUnit) { 125 125 unit* p = newRpUnit->head; … … 134 134 // place a null character at the end of the string 135 135 // so we know what we've parsed so far. 136 136 137 137 srchStr.erase(srchIndex); 138 138 length = srchStr.length(); … … 145 145 146 146 } // end while loop 147 147 148 148 149 149 // complete the last iteration … … 154 154 // convert whatever is left 155 155 exp = atoi(&srchStr[srchIndex+1]); 156 156 157 157 // if we get here, that means units name starts with a digit 158 158 // normally we wont get here, but if we do, should we place … … 175 175 176 176 // place the new object into the dictionary 177 177 178 178 // return a copy of the new object to user 179 179 return newRpUnit; … … 182 182 183 183 /************************************************************************ 184 * 185 * add a complex RpUnits Object 186 * 184 * 185 * add a complex RpUnits Object 186 * 187 187 ************************************************************************/ 188 188 189 RpUnits * RpUnits::defineCmplx ( const std::string units, 190 RpUnits * basis ) 191 { 189 RpUnits * RpUnits::defineCmplx ( const std::string units, RpUnits * basis ) 190 { 192 191 RpUnits * newRpUnit = NULL; 193 192 … … 221 220 222 221 srchIndex--; 223 222 224 223 if (srchIndex < 0) { 225 224 break; 226 225 } 227 226 228 227 if ( isdigit(srchStr[srchIndex]) && !digiSearch && !alphaSearch) { 229 228 digiSearch = 1; 230 229 } 231 230 else if(!isdigit(srchStr[srchIndex]) && digiSearch && !alphaSearch) { 232 231 233 232 // convert our exponent to integer 234 233 235 234 // check to see if there is a + or - sign 236 235 if ( ( srchStr[srchIndex] == '+' ) 237 236 || ( srchStr[srchIndex] == '-' ) ) { 238 237 239 238 // evaluate a '+' or '-' sign with the value 240 239 srchIndex--; 241 240 } 242 241 243 242 srchIndex++; 244 243 245 244 exp = atoi(&srchStr[srchIndex]); 246 245 247 246 // we are no longer in a digit search 248 247 digiSearch = 0; 249 248 250 249 // place null character where the number starts 251 250 // so we know what we've already parsed 252 251 253 252 srchStr.erase(srchIndex); 254 253 length = srchStr.length(); 255 254 256 255 } 257 256 else if( isalpha(srchStr[srchIndex]) && !digiSearch && !alphaSearch) { … … 259 258 } 260 259 else if(!isalpha(srchStr[srchIndex]) && !digiSearch && alphaSearch) { 261 260 262 261 // adjust the exponent if none was provided 263 262 if (exp == 0) { 264 263 exp = 1; 265 264 } 266 265 267 266 // compare unit string to see if it is a recognized system 268 269 267 268 270 269 std::string cmpStr = srchStr.substr(srchIndex+1,length-srchIndex-1); 271 270 cmpIndex = 0; 272 271 273 272 if ( (unsigned)(cmpIndex = pre_compare(cmpStr,basis)) == 274 273 std::string::npos ) { 275 274 alphaSearch = 0; 276 275 277 276 // there are units we did not recognize, 278 277 // right now we ignore them, 279 278 // we may want to deal with them differntly in the future 280 279 281 280 // erase only the last character and reprocess the string 282 281 // because our precompare doesnt take care of this yet. … … 284 283 length = srchStr.length(); 285 284 srchIndex = length; 286 287 285 286 288 287 // continue parsing characters 289 288 continue; 290 289 } 291 290 292 291 // the compare function was successful 293 292 // move the search pointer to one value infront of … … 299 298 srchIndex = cmpIndex; 300 299 std::string newUnitText = srchStr.substr(cmpIndex,length-cmpIndex); 301 300 302 301 // call the function to create the unit object 303 302 304 303 // we need pre-compare to return the basis of what it found. 305 304 if (newRpUnit) { … … 309 308 newRpUnit= new RpUnits(newUnitText, exp, basis); 310 309 } 311 312 310 311 313 312 // place a null character at the end of the string 314 313 // so we know what we've parsed so far. 315 314 316 315 srchStr.erase(srchIndex); 317 316 length = srchStr.length(); 318 317 319 318 // fix our searching flag 320 319 alphaSearch = 0; … … 324 323 // have to go back to all of the objects created and 325 324 // multiply their exponents by -1. 326 325 327 326 if (newRpUnit) { 328 327 unit* p = newRpUnit->head; … … 337 336 // place a null character at the end of the string 338 337 // so we know what we've parsed so far. 339 338 340 339 srchStr.erase(srchIndex); 341 340 length = srchStr.length(); … … 348 347 349 348 } // end while loop 350 349 351 350 352 351 // complete the last iteration … … 357 356 // convert whatever is left 358 357 exp = atoi(&srchStr[srchIndex+1]); 359 358 360 359 // if we get here, that means units name starts with a digit 361 360 // normally we wont get here, but if we do, should we place … … 382 381 // fundamental type 383 382 newRpUnit = new RpUnits(cmpStr, exp, basis); 384 383 385 384 // put the unit into the dictionary 386 385 // 387 386 newRpUnit->insert(newRpUnit->getUnitsName()); 388 387 389 388 390 389 } … … 395 394 // where the units were found. 396 395 // adjusting the search pointer to point to the units 397 std::string newUnitText = srchStr.substr(cmpIndex,length-cmpIndex); 396 std::string newUnitText = srchStr.substr(cmpIndex,length-cmpIndex); 398 397 399 398 // call the function to create the unit object … … 417 416 418 417 // place the new object into the dictionary 419 418 420 419 // return a copy of the new object to user 421 420 return newRpUnit; … … 424 423 425 424 /************************************************************************ 426 * 427 * add relation rule 428 * 425 * 426 * add relation rule 427 * 429 428 ************************************************************************/ 430 429 RpUnits * RpUnits::define( RpUnits* from, … … 432 431 double (*convForwFxnPtr)(double), 433 432 double (*convBackFxnPtr)(double)) 434 { 435 RpUnits* conv = new RpUnits(from,to,convForwFxnPtr,convBackFxnPtr,NULL,NULL); 436 437 return conv; 433 { 434 RpUnits* conv = new RpUnits( from, 435 to, 436 convForwFxnPtr, 437 convBackFxnPtr, 438 NULL, 439 NULL); 440 441 return conv; 438 442 } 439 443 … … 444 448 void* (*convBackFxnPtr)(void*, void*), 445 449 void* convBackData) 446 { 450 { 447 451 RpUnits* conv = new RpUnits( from, 448 452 to, … … 453 457 NULL, 454 458 NULL); 455 456 return conv; 459 460 return conv; 457 461 } 458 462 459 463 /************************************************************************ 460 * 461 * report the units this object represents back to the user 462 * 464 * 465 * report the units this object represents back to the user 466 * 463 467 * **********************************************************************/ 464 std::string RpUnits::getUnits() 468 std::string RpUnits::getUnits() 465 469 { 466 470 std::stringstream unitText; 467 471 unit* p = head; 468 472 469 473 while (p) { 470 474 unitText << p->getUnits() ; 471 475 p = p->next; 472 476 } 473 474 return (unitText.str()); 477 478 return (unitText.str()); 475 479 } 476 480 477 481 /************************************************************************ 478 * 479 * report the units this object represents back to the user 480 * 482 * 483 * report the units this object represents back to the user 484 * 481 485 * **********************************************************************/ 482 std::string RpUnits::getUnitsName() 486 std::string RpUnits::getUnitsName() 483 487 { 484 488 std::stringstream unitText; 485 489 unit* p = head; 486 490 double exponent; 487 491 488 492 while (p) { 489 493 … … 499 503 p = p->next; 500 504 } 501 502 return (unitText.str()); 505 506 return (unitText.str()); 503 507 } 504 508 505 509 /************************************************************************ 506 * 510 * 507 511 * report the exponent of the units of this object back to the user 508 * 512 * 509 513 * **********************************************************************/ 510 double RpUnits::getExponent() 511 { 514 double RpUnits::getExponent() 515 { 512 516 return head->getExponent(); 513 517 } 514 518 515 519 /************************************************************************ 516 * 517 * report the basis of this object to the user 518 * 520 * 521 * report the basis of this object to the user 522 * 519 523 * **********************************************************************/ 520 RpUnits * RpUnits::getBasis() 521 { 522 // check if head exists? 524 RpUnits * RpUnits::getBasis() 525 { 526 // check if head exists? 523 527 return head->getBasis(); 524 528 } 525 529 526 530 /************************************************************************ 527 * 531 * 528 532 * convert the current unit to its basis units 529 * 533 * 530 534 * Return Codes 531 535 * 0) no error (could also mean or no prefix was found) 532 536 * in some cases, this means the value is in its basis format 533 537 * 1) the prefix found does not have a built in factor associated. 534 * 538 * 535 539 ************************************************************************/ 536 540 double RpUnits::makeBasis(double value, int* result) 537 { 541 { 538 542 539 543 RpUnits* basis = getBasis(); … … 547 551 // this unit is a basis 548 552 // do nothing 549 553 550 554 if (result) { 551 555 *result = 1; … … 568 572 // this unit is a basis 569 573 // do nothing 570 574 571 575 if (result) { 572 576 *result = 1; … … 585 589 } 586 590 587 591 588 592 589 593 return *this; … … 591 595 592 596 /************************************************************************ 593 * 594 * static int makeMetric(RpUnits * basis); 597 * 598 * static int makeMetric(RpUnits * basis); 595 599 * create the metric attachments for the given basis. 596 * should only be used if this unit is of metric type 597 * 600 * should only be used if this unit is of metric type 601 * 598 602 * **********************************************************************/ 599 603 int RpUnits::makeMetric(RpUnits * basis) { … … 606 610 std::string name; 607 611 std::string forw, back; 608 612 609 613 name = "c" + basisName; 610 614 RpUnits * centi = RpUnits::define(name, basis); … … 622 626 RpUnits * nano = RpUnits::define(name, basis); 623 627 RpUnits::define(nano, basis, nano2base, base2nano); 624 628 625 629 name = "p" + basisName; 626 630 RpUnits * pico = RpUnits::define(name, basis); … … 654 658 RpUnits * peta = RpUnits::define(name, basis); 655 659 RpUnits::define(peta, basis, peta2base, base2peta); 656 660 657 661 return (1); 658 662 } 659 663 660 // convert function so people can just send in two strings and 661 // we'll see if the units exists and do a conversion 664 // convert function so people can just send in two strings and 665 // we'll see if the units exists and do a conversion 662 666 // strVal = RpUnits::convert("300K","C",1); 663 std::string 664 RpUnits::convert ( std::string val, 665 std::string toUnitsName, 667 std::string 668 RpUnits::convert ( std::string val, 669 std::string toUnitsName, 666 670 int showUnits, 667 671 int* result ) { … … 682 686 *result = 0; 683 687 } 684 685 toUnits = find(toUnitsName); 688 689 toUnits = find(toUnitsName); 686 690 687 691 // did we find the unit in the dictionary? 688 692 if (toUnits == NULL) { 689 693 // toUnitsName was not found in the dictionary 694 if (result) { 695 *result = 1; 696 } 690 697 return val; 691 698 } 692 699 693 700 valLen = val.length(); 694 701 695 // search our string to see where the numeric part stops 702 // search our string to see where the numeric part stops 696 703 // and the units part starts 704 // 705 // switched from the code that starts at the beginning of the string 706 // and check to see where the numeric part stops 707 // to the uncommented code section below that starts at the end of the 708 // string checks to see where the alpha part starts. This approach 709 // seems to work better so we can parse and convert strings as follows: 710 // convert("5J", "neV") => 3.12075e+28neV 711 // convert("3.12075e+28neV", "J") => 4.99999J 712 // now we can actually get the scientific notation portion of the string. 713 // 697 714 // make sure not to stop searching if we encounter '.', '-', '+' 715 /* 698 716 for (idx=0; idx < valLen; idx++) { 699 717 if ( !((val[idx] >= '0') && (val[idx] <= '9')) ) { … … 703 721 } 704 722 } 723 */ 724 725 // consider using stdtod because it does error checking 726 // supposedly according to man page? 727 for (idx=valLen-1; idx >= 0; idx--) { 728 if ( !( ((val[idx] >= 'A') && (val[idx] <= 'Z')) 729 || ((val[idx] >= 'a') && (val[idx] <= 'z')) ) ) { 730 731 if ( (val[idx] != '.')&&(val[idx] != '-')&&(val[idx] != '+') ) { 732 break; 733 } 734 } 735 } 736 737 idx++; 705 738 706 739 if ( (idx < valLen) && (idx > 0) ) { … … 716 749 *result = 1; 717 750 } 751 // not a big fan of multiple returns, but... 752 return val; 718 753 } 719 754 fromUnitsName = val.substr(idx, valLen-idx); … … 724 759 *result = 1; 725 760 } 726 } 727 728 fromUnits = find(fromUnitsName); 761 // not a big fan of multiple returns, but... 762 return val; 763 } 764 765 fromUnits = find(fromUnitsName); 729 766 730 767 // did we find the unit in the dictionary? 731 768 if (fromUnits == NULL) { 732 769 // fromUnitsName was not found in the dictionary 770 if (result) { 771 *result = 1; 772 } 733 773 return val; 734 774 } 735 775 736 776 convVal = fromUnits->convert(toUnits, numVal, showUnits, &convResult); 737 777 738 778 if ( (result) && (*result == 0) ) { 739 779 *result = convResult; … … 744 784 } 745 785 746 std::string RpUnits::convert ( RpUnits* toUnits, 747 double val, 748 int showUnits, 786 std::string RpUnits::convert ( RpUnits* toUnits, 787 double val, 788 int showUnits, 749 789 int* result ) 750 790 { 751 double retVal = convert(toUnits,val,result); 791 double retVal = convert(toUnits,val,result); 752 792 std::stringstream unitText; 753 793 754 794 755 795 if (showUnits) { … … 767 807 // if it exists as a conversion from the basis 768 808 // example 769 // cm.convert(meter,10) 809 // cm.convert(meter,10) 770 810 // cm.convert(angstrum,100) 771 811 double RpUnits::convert(RpUnits* toUnit, double val, int* result) … … 796 836 return val; 797 837 } 798 838 799 839 // convert unit to the basis 800 840 // makeBasis(&value); … … 806 846 if (my_result == 0) { 807 847 fromUnit = basis; 808 } 848 } 809 849 } 810 850 … … 843 883 // loop through our conversion list looking for the correct conversion 844 884 do { 845 885 846 886 if ( (p->conv->toPtr == dictToUnit) && (p->conv->fromPtr == fromUnit) ) { 847 887 // we found our conversion … … 849 889 850 890 value = p->conv->convForwFxnPtr(value); 851 891 852 892 // check to see if we converted to the actual requested unit 853 893 // or to the requested unit's basis. … … 864 904 } 865 905 } 866 906 867 907 // we can probably remove this 868 908 if (result) { … … 871 911 break; 872 912 } 873 913 874 914 if ( (p->conv->toPtr == fromUnit) && (p->conv->fromPtr == dictToUnit) ) { 875 915 // we found our conversion … … 877 917 878 918 value = p->conv->convBackFxnPtr(value); 879 919 880 920 // check to see if we converted to the actual requested unit 881 921 // or to the requested unit's basis. … … 892 932 } 893 933 } 894 934 895 935 // we can probably remove this 896 936 if (result) { … … 947 987 return val; 948 988 } 949 989 950 990 // convert unit to the basis 951 991 // makeBasis(&value); 952 992 // trying to avoid the recursive way of converting to the basis. 953 993 // need to rethink this. 954 // 994 // 955 995 if ( (basis) && (basis->getUnits() != toUnit->getUnits()) ) { 956 996 value = convert(basis,value,&my_result); 957 997 if (my_result == 0) { 958 998 fromUnit = basis; 959 } 999 } 960 1000 } 961 1001 … … 994 1034 // loop through our conversion list looking for the correct conversion 995 1035 do { 996 1036 997 1037 if ( (p->conv->toPtr == dictToUnit) && (p->conv->fromPtr == fromUnit) ) { 998 1038 // we found our conversion … … 1015 1055 } 1016 1056 } 1017 1057 1018 1058 // we can probably remove this 1019 1059 if (result) { … … 1022 1062 break; 1023 1063 } 1024 1064 1025 1065 if ( (p->conv->toPtr == fromUnit) && (p->conv->fromPtr == dictToUnit) ) { 1026 1066 // we found our conversion … … 1043 1083 } 1044 1084 } 1045 1085 1046 1086 // we can probably remove this 1047 1087 if (result) { … … 1103 1143 { 1104 1144 1105 // compare the incomming units with the previously defined units. 1106 // compareStr will hold a copy of the incomming string. 1145 // compare the incomming units with the previously defined units. 1146 // compareStr will hold a copy of the incomming string. 1107 1147 // first look for the units as they are listed in the incomming variable 1108 1148 // next look move searchStr toward the end of the string, … … 1122 1162 std::string searchStr = units; 1123 1163 std::string dbText = ""; 1124 1164 1125 1165 // pass 1: look for exact match of units as they came into the function 1126 1166 // move searchStr pointer through string to find match. 1127 while ( ! compareSuccess && 1167 while ( ! compareSuccess && 1128 1168 (searchStr.length() > 0) ) { 1129 1169 … … 1190 1230 break; 1191 1231 } 1192 1232 1193 1233 } 1194 1234 … … 1233 1273 1234 1274 // return codes: 0 success, anything else is error 1235 int 1275 int 1236 1276 RpUnits::addPresets (std::string group) { 1237 1277 int retVal = -1; … … 1251 1291 retVal = addPresetTime(); 1252 1292 } 1253 1293 1254 1294 return retVal; 1255 1295 } 1256 1296 1257 1297 // return codes: 0 success, anything else is error 1258 int 1298 int 1259 1299 RpUnits::addPresetAll () { 1260 1300 … … 1270 1310 1271 1311 // return codes: 0 success, anything else is error 1272 int 1312 int 1273 1313 RpUnits::addPresetTime () { 1274 1314 1275 1315 RpUnits* seconds = RpUnits::define("s", NULL); 1276 1316 1277 1317 RpUnits::makeMetric(seconds); 1278 1318 1279 1319 // add time definitions 1280 1320 … … 1283 1323 1284 1324 // return codes: 0 success, anything else is error 1285 int 1325 int 1286 1326 RpUnits::addPresetTemp () { 1287 1327 … … 1290 1330 RpUnits* kelvin = RpUnits::define("K", NULL); 1291 1331 RpUnits* rankine = RpUnits::define("R", NULL); 1292 1332 1293 1333 // add temperature definitions 1294 1334 RpUnits::define(fahrenheit, celcius, fahrenheit2centigrade, centigrade2fahrenheit); … … 1301 1341 1302 1342 // return codes: 0 success, anything else is error 1303 int 1343 int 1304 1344 RpUnits::addPresetLength () { 1305 1345 … … 1309 1349 RpUnits* feet = RpUnits::define("ft", NULL); 1310 1350 RpUnits* yard = RpUnits::define("yd", NULL); 1311 1351 1312 1352 RpUnits::makeMetric(meters); 1313 1353 … … 1322 1362 1323 1363 // return codes: 0 success, anything else is error 1324 int 1364 int 1325 1365 RpUnits::addPresetEnergy () { 1326 1366 … … 1328 1368 RpUnits* eVolt = RpUnits::define("eV", NULL); 1329 1369 RpUnits* joule = RpUnits::define("J", NULL); 1330 1370 1331 1371 RpUnits::makeMetric(volt); 1332 1372 RpUnits::makeMetric(eVolt); 1373 RpUnits::makeMetric(joule); 1333 1374 1334 1375 // add energy definitions -
trunk/src/core/RpUnitsStd.cc
r68 r83 7 7 ****************************************/ 8 8 9 double centi2base (double centi) 10 { 11 return centi*1e-2; 9 double centi2base (double centi) 10 { 11 return centi*1e-2; 12 12 } 13 13 … … 67 67 } 68 68 69 double base2centi (double base) 70 { 71 return base*1e2; 69 double base2centi (double base) 70 { 71 return base*1e2; 72 72 } 73 73 … … 230 230 double joule2electronVolt (double J) 231 231 { 232 return (J *1.602177e19);232 return (J/1.602177e-19); 233 233 } 234 234 -
trunk/src/fortran/RpFortranCommon.c
r77 r83 1 /* 2 * ---------------------------------------------------------------------- 3 * INTERFACE: Fortran Rappture Common Functions Source 4 * 5 * Fortran functions common to all interfaces. 6 * 7 * ====================================================================== 8 * AUTHOR: Derrick Kearney, Purdue University 9 * Copyright (c) 2005 10 * Purdue Research Foundation, West Lafayette, IN 11 * ====================================================================== 12 */ 13 14 1 15 #include "RpFortranCommon.h" 2 16 -
trunk/src/fortran/RpLibraryFInterface.cc
r77 r83 1 /* 2 * ---------------------------------------------------------------------- 3 * INTERFACE: Fortran Rappture Library Source 4 * 5 * ====================================================================== 6 * AUTHOR: Derrick Kearney, Purdue University 7 * Copyright (c) 2005 8 * Purdue Research Foundation, West Lafayette, IN 9 * ====================================================================== 10 */ 11 1 12 #include "RpLibraryFInterface.h" 2 13 … … 8 19 9 20 inFilePath = null_terminate_str(filePath, filePath_len); 10 21 11 22 // create a RapptureIO object and store in dictionary 12 23 lib = new RpLibrary(inFilePath); … … 37 48 if (lib) { 38 49 retObj = lib->element(inPath); 39 50 40 51 if (retObj) { 41 52 newObjHandle = storeObject_Lib(retObj); … … 68 79 } 69 80 } 70 81 71 82 } 72 83 … … 95 106 96 107 void rp_lib_element_type( int* handle, /* integer handle of library */ 97 char* path, /* null terminated path*/108 char* path, /* search path inside xml */ 98 109 char* retText, /* return buffer for fortran*/ 99 110 int path_len, … … 113 124 fortranify(retStr.c_str(),retText,retText_len); 114 125 } 126 } 127 128 int rp_lib_children ( int* handle, /* integer handle of library */ 129 char* path, /* search path of the xml */ 130 int* childHandle, /*integer hanlde of last returned child*/ 131 int path_len /* length of the search path buffer */ 132 ) { 133 134 std::string inPath = ""; 135 RpLibrary* lib = NULL; 136 RpLibrary* childNode = NULL; 137 int newObjHandle = -1; 138 139 inPath = null_terminate_str(path,path_len); 140 141 if (handle && (*handle >= 0) ) { 142 lib = getObject_Lib(*handle); 143 if (lib) { 144 if (*childHandle < 1) { 145 // check to see if there were any previously returned children 146 childNode = getObject_Lib(*childHandle); 147 } 148 149 // call the children base method 150 childNode = lib->children(path,childNode); 151 152 // store the childNode in the dictionary. 153 // 154 // because the base method is using static memory to get store the 155 // children we should be able to chekc and see if the childHandle 156 // was valud. 157 // if so, then we can just return the childHandle back to the user 158 // if not, store the object in the dictionary and return the new 159 // handle. 160 161 if (childNode) { 162 if (*childHandle < 1) { 163 newObjHandle = storeObject_Lib(childNode); 164 } 165 else { 166 newObjHandle = *childHandle; 167 } 168 } 169 } 170 } 171 172 return newObjHandle; 173 115 174 } 116 175 … … 128 187 129 188 inPath = null_terminate(path,path_len); 130 189 131 190 if (rapptureStarted) { 132 191 if ((handle) && (*handle != 0)) { … … 140 199 } 141 200 else { 142 201 143 202 } 144 203 } … … 394 453 395 454 RpLibrary* lib = NULL; 396 455 397 456 std::string inPath = ""; 398 457 … … 401 460 if ((handle) && (*handle != 0)) { 402 461 lib = getObject_Lib(*handle); 403 462 404 463 if (lib) { 405 464 xmlText = lib->getString(inPath); … … 420 479 421 480 RpLibrary* lib = NULL; 422 481 423 482 std::string inPath = ""; 424 483 … … 427 486 if ((handle) && (*handle != 0)) { 428 487 lib = getObject_Lib(*handle); 429 488 430 489 if (lib) { 431 490 retVal = lib->getDouble(inPath); … … 443 502 int path_len, 444 503 int value_len 445 ) 504 ) 446 505 { 447 506 std::string inPath = ""; … … 459 518 } 460 519 } 461 520 462 521 return; 463 522 464 523 } 465 524 … … 476 535 { 477 536 RpLibrary* lib = NULL; 478 537 479 538 std::string inPath = ""; 480 539 std::string inValue = ""; … … 487 546 if ((handle) && (*handle != 0)) { 488 547 lib = getObject_Lib(*handle); 489 548 490 549 if (lib) { 491 550 lib->put(inPath,inValue,inId,*append); … … 586 645 PyObject* lib = NULL; 587 646 PyObject* removedObj = NULL; 588 647 589 648 char* inPath = NULL; 590 649 … … 597 656 if (lib) { 598 657 removedObj = rpRemove(lib, inPath); 599 658 600 659 if (removedObj) { 601 660 newObjHandle = storeObject_Lib(removedObj); … … 606 665 } 607 666 } 608 667 609 668 if (inPath) { 610 669 free(inPath); … … 643 702 } 644 703 */ 645 646 void rp_lib_xml(int* handle, char* retText, int retText_len)647 {648 std::string xmlText = "";649 650 RpLibrary* lib = NULL;651 652 if ((handle) && (*handle != 0)) {653 lib = getObject_Lib(*handle);654 655 if (lib) {656 xmlText = lib->xml();657 if (!xmlText.empty()) {658 fortranify(xmlText.c_str(), retText, retText_len);659 }660 }661 }662 }663 704 664 705 int rp_lib_write_xml(int* handle, char* outFile, int outFile_len) … … 695 736 } 696 737 738 void rp_lib_xml(int* handle, char* retText, int retText_len) 739 { 740 std::string xmlText = ""; 741 742 RpLibrary* lib = NULL; 743 744 if ((handle) && (*handle != 0)) { 745 lib = getObject_Lib(*handle); 746 747 if (lib) { 748 xmlText = lib->xml(); 749 if (!xmlText.empty()) { 750 fortranify(xmlText.c_str(), retText, retText_len); 751 } 752 } 753 } 754 } 755 756 void rp_lib_node_comp ( int* handle, char* retText, int retText_len ) { 757 758 std::string retStr = ""; 759 RpLibrary* node = NULL; 760 761 if ((handle) && (*handle != 0)) { 762 node = getObject_Lib(*handle); 763 764 if (node) { 765 retStr = node->nodeComp(); 766 if (!retStr.empty()) { 767 fortranify(retStr.c_str(), retText, retText_len); 768 } 769 } 770 } 771 } 772 773 void rp_lib_node_type ( int* handle, char* retText, int retText_len ) { 774 775 std::string retStr = ""; 776 RpLibrary* node = NULL; 777 778 if ((handle) && (*handle != 0)) { 779 node = getObject_Lib(*handle); 780 781 if (node) { 782 retStr = node->nodeType(); 783 if (!retStr.empty()) { 784 fortranify(retStr.c_str(), retText, retText_len); 785 } 786 } 787 } 788 } 789 790 void rp_lib_node_id ( int* handle, char* retText, int retText_len ) { 791 792 std::string retStr = ""; 793 RpLibrary* node = NULL; 794 795 if ((handle) && (*handle != 0)) { 796 node = getObject_Lib(*handle); 797 798 if (node) { 799 retStr = node->nodeId(); 800 if (!retStr.empty()) { 801 fortranify(retStr.c_str(), retText, retText_len); 802 } 803 } 804 } 805 } 806 697 807 void rp_quit() 698 808 { … … 701 811 702 812 RpDictEntry DICT_TEMPLATE *hPtr; 703 // RpDictIterator DICT_TEMPLATE iter((RpDict&)*this); 813 // RpDictIterator DICT_TEMPLATE iter((RpDict&)*this); 704 814 RpDictIterator DICT_TEMPLATE iter(fortObjDict_Lib); 705 706 hPtr = iter.first(); 707 815 816 hPtr = iter.first(); 817 708 818 while (hPtr) { 709 819 // Py_DECREF(*(hPtr->getValue())); 710 820 hPtr->erase(); 711 hPtr = iter.next(); 821 hPtr = iter.next(); 712 822 } 713 823 … … 717 827 } 718 828 829 } 830 831 void rp_result(int* handle) { 832 RpLibrary* lib = NULL; 833 834 if (handle && *handle != 0) { 835 lib = getObject_Lib(*handle); 836 if (lib) { 837 lib->result(); 838 } 839 } 719 840 } 720 841 … … 756 877 fortObjDict_Lib.set(dictKey,objectName, &newEntry); 757 878 } 758 879 759 880 retVal = dictKey; 760 881 return retVal; -
trunk/src/fortran/RpUnitsFInterface.cc
r76 r83 1 /* 2 * ---------------------------------------------------------------------- 3 * INTERFACE: Fortran Rappture Units Source 4 * 5 * ====================================================================== 6 * AUTHOR: Derrick Kearney, Purdue University 7 * Copyright (c) 2005 8 * Purdue Research Foundation, West Lafayette, IN 9 * ====================================================================== 10 */ 11 1 12 #include "RpUnits.h" 2 13 #include "RpDict.h" -
trunk/test/Makefile
r77 r83 12 12 13 13 # define the top of the rappture directory structure 14 RP_BASE = $(TOP_DIR)/rappture14 RP_BASE = $(TOP_DIR)/rappture 15 15 16 16 # define which programs can be made 17 18 TEST_PROGS 19 20 21 22 23 24 RpUnitsC_test\25 RpUnitsF_test\26 RpLibrary_test\27 RpLibraryCInterface_test17 18 TEST_PROGS = RpBoolean_test \ 19 RpChoice_test \ 20 RpNumber_test \ 21 RpString_test \ 22 RpUnits_test \ 23 RpVariable_test \ 24 RpUnitsC_test \ 25 RpUnitsF_test \ 26 RpLibrary_test \ 27 RpLibraryC_test 28 28 29 29 # define our compiling environment 30 # 31 CC 32 CXX 33 DEBUG 34 DEBUG_PLUS 30 # 31 CC = gcc 32 CXX = g++ 33 DEBUG = -g -Wall 34 DEBUG_PLUS = -g -DDEBUG 35 35 36 # FORTRAN BINDINGS COMPILER FLAGS 36 # FORTRAN BINDINGS COMPILER FLAGS 37 37 # 38 38 # available flags 39 39 # 40 # COMPNAME_NOCHANGE -No change to the Rappture Library function41 # 42 # COMPNAME_UPPERCASE -Replace the Rappture Library function name43 # 44 # COMPNAME_ADD1UNDERSCORE - add 1 underscore to the end of the Rappture45 # 46 # COMPNAME_ADD2UNDERSCORE - add 2 underscores to the end of the Rappture47 # 48 # 40 # COMPNAME_NOCHANGE No change to the Rappture Library function 41 # name 42 # COMPNAME_UPPERCASE Replace the Rappture Library function name 43 # with an all uppercase version of the name 44 # COMPNAME_ADD1UNDERSCORE Add 1 underscore to the end of the Rappture 45 # Library function name 46 # COMPNAME_ADD2UNDERSCORE Add 2 underscores to the end of the Rappture 47 # Library function name 48 # 49 49 # when setting CFLAGS, use the following guide for help 50 50 # 51 # gnu's g77/f77 52 # absoft's f77 53 # intel's ifort 54 # intel's mpif90 51 # gnu's g77/f77 COMPNAME_ADD2UNDERSCORE 52 # absoft's f77 COMPNAME_ADD1UNDERSCORE 53 # intel's ifort COMPNAME_ADD1UNDERSCORE 54 # intel's mpif90 COMPNAME_ADD1UNDERSCORE 55 55 # 56 56 # 57 57 58 CFLAGS 58 CFLAGS = -DCOMPNAME_ADD2UNDERSCORE 59 59 60 F77 60 F77 = g77 61 61 62 62 LN = ln … … 64 64 # define our directories 65 65 # 66 INCLUDES_DIR 67 BIN_DIR 68 LIB_DIR 69 SRC_DIR 70 TEST_DIR 66 INCLUDES_DIR = $(RP_BASE)/include 67 BIN_DIR = $(RP_BASE)/bin 68 LIB_DIR = $(RP_BASE)/src 69 SRC_DIR = $(RP_BASE)/src 70 TEST_DIR = $(RP_BASE)/test 71 71 72 LIB_INC_PREFIX 72 LIB_INC_PREFIX = -Wl,-rpath,$(LIB_DIR) -L$(LIB_DIR) 73 73 74 LIB_RP_OBJECTS 75 LIB_RAPPTURE 76 LIB_RAPPTURE_T 74 LIB_RP_OBJECTS = $(LIB_INC_PREFIX) -lRpObjects 75 LIB_RAPPTURE = -Wl,-rpath,$(LIB_DIR) -L$(LIB_DIR) -lrappture 76 LIB_RAPPTURE_T = -Wl,-rpath,$(LIB_DIR) -L$(LIB_DIR) -lrappture_test 77 77 78 INCL_CORE 79 INCL_CEE 80 INCL_FORTRAN 81 INCL_PY 78 INCL_CORE = -I $(INCLUDES_DIR)/core 79 INCL_CEE = -I $(INCLUDES_DIR)/cee 80 INCL_FORTRAN = -I $(INCLUDES_DIR)/fortran 81 INCL_PY = -I $(INCLUDES_DIR)/python 82 82 83 # default:84 83 84 default: $(TEST_PROGS) 85 85 all: $(TEST_PROGS) 86 86 test: $(TEST_PROGS) … … 115 115 $(CXX) $(DEBUG) $(INCL_CEE) $(INCL_CORE) $(LIB_SCEW_INCL) -o $@ $^ $(LIB_RAPPTURE_T) 116 116 117 RpLibraryC Interface_test: $(SRC_TEST)/RpLibraryCInterface_test.c117 RpLibraryC_test: $(SRC_TEST)/RpLibraryC_test.c 118 118 $(CC) $(DEBUG) $(INCL_CEE) $(INCL_CORE) $(LIB_SCEW_INCL) -o $@ $^ $(LIB_RAPPTURE_T) 119 120 RpLibraryF_test: $(SRC_TEST)/RpLibraryF_test.f 121 $(F77) $(DEBUG) -o $@ $^ $(LIB_RAPPTURE_T) 119 122 120 123 RpUnitsF_test: $(SRC_TEST)/RpUnitsF_test.f -
trunk/test/src/RpLibraryC_test.c
r77 r83 106 106 id = nodeId(childEle); 107 107 type = nodeType(childEle); 108 108 109 109 printf("childEle comp = :%s:\n",comp); 110 110 printf("childEle id = :%s:\n",id); … … 132 132 id = nodeId(childEle); 133 133 type = nodeType(childEle); 134 134 135 135 printf("childEle comp = :%s:\n",comp); 136 136 printf("childEle id = :%s:\n",id); -
trunk/test/src/RpLibrary_test.cc
r77 r83 187 187 std::cout << "//////////////////// LIB 3 ////////////////////" << std::endl; 188 188 std::cout << lib3.xml() << std::endl; 189 190 lib2.result(); 189 191 190 192 return 0;
Note: See TracChangeset
for help on using the changeset viewer.