Changeset 119
- Timestamp:
- Oct 27, 2005 4:48:56 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/app-fermi/fortran/fermi.f
r115 r119 17 17 IMPLICIT NONE 18 18 19 integer rp_lib, rp_units_convert_dbl , rp_units_add_presets19 integer rp_lib, rp_units_convert_dbl 20 20 21 21 integer driver, ok … … 26 26 call getarg(1,inFile) 27 27 driver = rp_lib(inFile) 28 29 ok = rp_units_add_presets("all")30 28 31 29 call rp_lib_get(driver, -
trunk/include/fortran/RpLibraryFInterface.h
r115 r119 46 46 int path_len ); 47 47 48 /*49 * rp_lib_child_num still needs to be written50 * keep function declaration around51 int rp_lib_child_num ( int* handle,52 char* path,53 int* childHandle,54 int path_len);55 */56 57 48 int rp_lib_children ( int* handle, /* integer handle of library */ 58 49 char* path, /* search path of the xml */ … … 60 51 int path_len /*length of the search path buffer*/ 61 52 ); 62 63 53 64 54 void rp_lib_get ( int* handle, … … 146 136 void rp_result( int* handle ); 147 137 148 void rp_quit();149 150 151 138 /**********************************************************/ 152 139 -
trunk/include/fortran/RpLibraryFStubs.h
r115 r119 126 126 void rp_result_( int* handle ); 127 127 128 void rp_quit_();129 128 130 129 /**********************************************************/ … … 236 235 void rp_result__( int* handle ); 237 236 238 void rp_quit__();239 237 240 238 /**********************************************************/ … … 347 345 void RP_RESULT( int* handle ); 348 346 349 void RP_QUIT();350 347 351 348 /**********************************************************/ -
trunk/include/fortran/RpUnitsFInterface.h
r115 r119 49 49 int retText_len ); 50 50 51 int rp_units_add_presets ( char* presetName, int presetName_len);52 53 51 #ifdef __cplusplus 54 52 } -
trunk/include/fortran/RpUnitsFStubs.h
r115 r119 82 82 int retText_len ); 83 83 84 int rp_units_add_presets_ (char* presetName, int presetName_len);85 int rp_units_add_presets__ (char* presetName, int presetName_len);86 int RP_UNITS_ADD_PRESETS (char* presetName, int presetName_len);87 88 84 #ifdef __cplusplus 89 85 } -
trunk/src/core/RpLibrary.cc
r115 r119 432 432 } 433 433 434 /*435 // as not implemented, use nodeType, nodeId, nodeComp.436 RpLibrary**437 RpLibrary::children (std::string path, std::string as, std::string type)438 {439 RpLibrary** retLib = NULL;440 int childCount = 0;441 int childNum = 0;442 scew_element* parentNode = NULL;443 scew_element* childNode = NULL;444 std::string childName = "";445 446 if (path.empty()) {447 // an empty path returns the current RpLibrary448 // you can still get the children of the root node449 parentNode = this->root;450 }451 else {452 parentNode = _find(path,0);453 }454 455 if (parentNode == NULL) {456 // node not found457 // add error code here458 return NULL;459 }460 461 childCount = scew_element_count(parentNode);462 463 // even if there are no children, we can send back a null array464 retLib = new RpLibrary*[childCount+1];465 466 if (!retLib) {467 // there was an error mallocing memory for a RpLibrary object468 return NULL;469 }470 471 if (childCount) {472 473 while ( (childNode = scew_element_next(parentNode,childNode)) ) {474 if (childNode) {475 if (!type.empty()) {476 childName = scew_element_name(childNode);477 if (type == childName) {478 retLib[childNum++] = new RpLibrary( childNode );479 }480 }481 else {482 retLib[childNum++] = new RpLibrary( childNode );483 }484 }485 else {486 // somthing happened within scew, get error code and display487 return NULL;488 }489 }490 }491 492 std::cout << "childNum = " << childNum << std::endl;493 retLib[childNum] = NULL;494 495 // how do you free this??496 return retLib;497 }498 */499 500 434 RpLibrary* 501 435 RpLibrary::children ( std::string path, … … 721 655 /* 722 656 * ---------------------------------------------------------------------- 723 * FUNCTION: r pResult657 * FUNCTION: result 724 658 * 725 659 * Clients call this function at the end of their simulation, to -
trunk/src/core/RpUnits.cc
r118 r119 242 242 /**********************************************************************/ 243 243 // METHOD: getUnits() 244 // /// Report the text portion of the units of this object back to caller.245 / / /**246 //* See Also getUnitsName().247 //*/248 // 244 /// Report the text portion of the units of this object back to caller. 245 /** 246 * See Also getUnitsName(). 247 */ 248 249 249 std::string 250 250 RpUnits::getUnits() const { … … 261 261 /**********************************************************************/ 262 262 // METHOD: getUnitsName() 263 // /// Report the full name of the units of this object back to caller.264 / / /**265 //* Reports the full text and exponent of the units represented by this266 //* object, back to the caller. Note that if the exponent == 1, no267 //* exponent will be printed.268 //*/269 // 263 /// Report the full name of the units of this object back to caller. 264 /** 265 * Reports the full text and exponent of the units represented by this 266 * object, back to the caller. Note that if the exponent == 1, no 267 * exponent will be printed. 268 */ 269 270 270 std::string 271 271 RpUnits::getUnitsName() const { … … 293 293 /**********************************************************************/ 294 294 // METHOD: getExponent() 295 // /// Report the exponent of the units of this object back to caller.296 / / /**297 //* Reports the exponent of the units represented by this298 //* object, back to the caller. Note that if the exponent == 1, no299 //* exponent will be printed.300 //*/301 // 295 /// Report the exponent of the units of this object back to caller. 296 /** 297 * Reports the exponent of the units represented by this 298 * object, back to the caller. Note that if the exponent == 1, no 299 * exponent will be printed. 300 */ 301 302 302 double 303 303 RpUnits::getExponent() const { … … 313 313 /**********************************************************************/ 314 314 // METHOD: getBasis() 315 // /// Retrieve the RpUnits object representing the basis of this object.316 / / /**317 //* Returns a pointer to a RpUnits object which, on success, points to the318 //* RpUnits object that is the basis of the calling object.319 //*/320 // 315 /// Retrieve the RpUnits object representing the basis of this object. 316 /** 317 * Returns a pointer to a RpUnits object which, on success, points to the 318 * RpUnits object that is the basis of the calling object. 319 */ 320 321 321 const RpUnits * 322 322 RpUnits::getBasis() const { … … 766 766 767 767 if (showUnits) { 768 outVal << val << toUnitsName;768 outVal << numVal << toUnitsName; 769 769 } 770 770 else { 771 outVal << val;771 outVal << numVal; 772 772 } 773 773 … … 892 892 } 893 893 894 /*895 * this code will be removed after dsk does some more testing896 *897 // convert function so people can just send in two strings and898 // we'll see if the units exists and do a conversion899 // strVal = RpUnits::convert("300K","C",1);900 std::string901 RpUnits::convert ( std::string val,902 std::string toUnitsName,903 int showUnits,904 int* result ) {905 906 RpUnitsList toUnitsList;907 RpUnitsList fromUnitsList;908 909 const RpUnits* toUnits = NULL;910 const RpUnits* fromUnits = NULL;911 912 std::string tmpNumVal = "";913 std::string fromUnitsName = "";914 std::string convVal = "";915 double numVal = 0;916 int convResult = 0;917 char* endptr = NULL;918 std::stringstream outVal;919 920 921 // set default result flag/error code922 if (result) {923 *result = 0;924 }925 926 toUnits = find(toUnitsName);927 928 // did we find the unit in the dictionary?929 if (toUnits == NULL) {930 // toUnitsName was not found in the dictionary931 if (result) {932 *result = 1;933 }934 return val;935 }936 937 // search our string to see where the numeric part stops938 // and the units part starts939 //940 // convert("5J", "neV") => 3.12075e+28neV941 // convert("3.12075e+28neV", "J") => 4.99999J942 // now we can actually get the scientific notation portion of the string.943 //944 945 numVal = strtod(val.c_str(),&endptr);946 947 if ( (numVal == 0) && (endptr == val.c_str()) ) {948 // no conversion was done.949 // number in incorrect format probably.950 if (result) {951 *result = 1;952 }953 return val;954 }955 956 fromUnitsName = std::string(endptr);957 if ( fromUnitsName.empty() ) {958 // there were no units in the input string959 // assume fromUnitsName = toUnitsName960 // return the correct value961 if (result) {962 *result = 0;963 }964 965 if (showUnits) {966 outVal << val << toUnitsName;967 }968 else {969 outVal << val;970 }971 972 return std::string(outVal.str());973 }974 975 fromUnits = find(fromUnitsName);976 977 // did we find the unit in the dictionary?978 if (fromUnits == NULL) {979 // fromUnitsName was not found in the dictionary980 if (result) {981 *result = 1;982 }983 return val;984 }985 986 convVal = fromUnits->convert(toUnits, numVal, showUnits, &convResult);987 988 if ( (result) && (*result == 0) ) {989 *result = convResult;990 }991 992 return convVal;993 994 }995 */996 997 894 std::string 998 895 RpUnits::convert ( const RpUnits* toUnits, -
trunk/src/fortran/RpLibraryFInterface.cc
r115 r119 16 16 #include "RpLibraryFStubs.c" 17 17 18 int rp_lib(const char* filePath, int filePath_len) 19 { 18 /**********************************************************************/ 19 // FUNCTION: rp_lib(const char* filePath, int filePath_len) 20 /// Open the file at 'filePath' and return Rappture Library Object. 21 /** 22 */ 23 24 int rp_lib(const char* filePath, int filePath_len) { 25 20 26 RpLibrary* lib = NULL; 21 27 int handle = -1; … … 34 40 } 35 41 42 /**********************************************************************/ 43 // FUNCTION: rp_lib_element_obj() 44 /// Return the node located at 'path'. 45 /** 46 */ 36 47 int rp_lib_element_obj(int* handle, /* integer handle of library */ 37 48 char* path, /* null terminated path */ … … 62 73 } 63 74 75 /**********************************************************************/ 76 // FUNCTION: rp_lib_element_comp() 77 /// Return the component name of the node located at 'path'. 78 /** 79 */ 64 80 void rp_lib_element_comp( int* handle, /* integer handle of library */ 65 81 char* path, /* null terminated path */ … … 86 102 } 87 103 88 void rp_lib_element_id( int* handle, /* integer handle of library */ 89 char* path, /* null terminated path */ 90 char* retText, /* return buffer for fortran*/ 104 /**********************************************************************/ 105 // FUNCTION: rp_lib_element_id() 106 /// Return the 'id' of node located at 'path'. 107 /** 108 */ 109 void rp_lib_element_id( int* handle, /* integer handle of library */ 110 char* path, /* path of element within xml */ 111 char* retText, /* return buffer for fortran */ 91 112 int path_len, 92 int retText_len /* length of return text buffer */113 int retText_len /* length of return text buffer */ 93 114 ) 94 115 { … … 109 130 } 110 131 111 void rp_lib_element_type( int* handle, /* integer handle of library */ 132 /**********************************************************************/ 133 // FUNCTION: rp_lib_element_type() 134 /// Return the type of the node located at 'path'. 135 /** 136 */ 137 void rp_lib_element_type( int* handle, /* integer handle of library */ 112 138 char* path, /* search path inside xml */ 113 139 char* retText, /* return buffer for fortran*/ 114 140 int path_len, 115 int retText_len /* length of return text buffer */141 int retText_len /* length of return text buffer */ 116 142 ) 117 143 { … … 130 156 } 131 157 158 /**********************************************************************/ 159 // FUNCTION: rp_lib_children(const char* filePath, int filePath_len) 160 /// Retrieve the next child of 'path' from the Rappture Library Object. 161 /** 162 */ 132 163 int rp_lib_children ( int* handle, /* integer handle of library */ 133 164 char* path, /* search path of the xml */ … … 178 209 } 179 210 180 /*181 int rp_lib_child_num( int* handle,182 char* path,183 int path_len184 )185 {186 int numChildren = 0;187 188 PyObject* lib = NULL;189 PyObject* list = NULL;190 char* inPath = NULL;191 192 inPath = null_terminate(path,path_len);193 194 if (rapptureStarted) {195 if ((handle) && (*handle != 0)) {196 lib = getObject_Lib(*handle);197 198 if (lib) {199 list = rpChildren_f(lib, inPath, "type");200 if (list) {201 numChildren = PyList_Size(list);202 Py_DECREF(list);203 }204 else {205 206 }207 }208 }209 }210 211 if (inPath) {212 free(inPath);213 inPath = NULL;214 }215 216 return numChildren;217 218 }219 */220 211 221 212 //int rp_lib_child_comp ( int* handle, /* integer handle of library */ … … 447 438 */ 448 439 440 /**********************************************************************/ 441 // FUNCTION: rp_lib() 442 /// Get data located at 'path' and return it as a string value. 443 /** 444 */ 449 445 void rp_lib_get( int* handle, /* integer handle of library */ 450 446 char* path, /* null terminated path */ … … 475 471 } 476 472 473 /**********************************************************************/ 474 // FUNCTION: rp_lib_get_double() 475 /// Get data located at 'path' and return it as a double precision value. 476 /** 477 */ 477 478 double rp_lib_get_double( int* handle, /* integer handle of library */ 478 479 char* path, /* null terminated path */ … … 500 501 501 502 503 /**********************************************************************/ 504 // FUNCTION: rp_lib_put_str() 505 /// Put string into Rappture Library Object at location 'path'. 506 /** 507 */ 502 508 void rp_lib_put_str( int* handle, 503 509 char* path, … … 528 534 529 535 536 /**********************************************************************/ 537 // FUNCTION: rp_lib_put_id_str() 538 /// Put string into Rappture Library Object at location 'path' with id = 'id' 539 /** 540 */ 530 541 void rp_lib_put_id_str ( int* handle, 531 542 char* path, … … 707 718 */ 708 719 720 /**********************************************************************/ 721 // FUNCTION: rp_lib_write_xml() 722 /// Write the xml text into a file. 723 /** 724 * \sa {rp_result} 725 */ 709 726 int rp_lib_write_xml(int* handle, char* outFile, int outFile_len) 710 727 { … … 740 757 } 741 758 759 /**********************************************************************/ 760 // FUNCTION: rp_lib_xml() 761 /// Return this node's xml text 762 /** 763 */ 742 764 void rp_lib_xml(int* handle, char* retText, int retText_len) 743 765 { … … 758 780 } 759 781 782 /**********************************************************************/ 783 // FUNCTION: rp_lib_node_comp() 784 /// Return this node's component name 785 /** 786 */ 760 787 void rp_lib_node_comp ( int* handle, char* retText, int retText_len ) { 761 788 … … 775 802 } 776 803 804 /**********************************************************************/ 805 // FUNCTION: rp_lib_node_type() 806 /// Return this node's type 807 /** 808 */ 777 809 void rp_lib_node_type ( int* handle, char* retText, int retText_len ) { 778 810 … … 792 824 } 793 825 826 /**********************************************************************/ 827 // FUNCTION: rp_lib_node_id() 828 /// Return this node's id. 829 /** 830 */ 794 831 void rp_lib_node_id ( int* handle, char* retText, int retText_len ) { 795 832 … … 809 846 } 810 847 811 void rp_quit() 812 { 813 814 // clean up the dictionary 815 816 /* 817 RpDictEntry DICT_TEMPLATE_L *hPtr; 818 // RpDictIterator DICT_TEMPLATE iter(fortObjDict_Lib); 819 // should rp_quit clean up the dict or some function in RpBindingsCommon.h 820 RpDictIterator DICT_TEMPLATE_L iter(ObjDict_Lib); 821 822 hPtr = iter.first(); 823 824 while (hPtr) { 825 // Py_DECREF(*(hPtr->getValue())); 826 hPtr->erase(); 827 hPtr = iter.next(); 828 } 829 830 // if (fortObjDict_Lib.size()) { 831 if (ObjDict_Lib.size()) { 832 // probably want to change the warning sometime 833 // printf("\nWARNING: internal dictionary is not empty..deleting\n"); 834 } 835 */ 836 cleanLibDict(); 837 } 838 848 /**********************************************************************/ 849 // FUNCTION: rp_result() 850 /// Write xml text to a run.xml file and signal the program has completed 851 /** 852 */ 839 853 void rp_result(int* handle) { 840 854 RpLibrary* lib = NULL; … … 846 860 } 847 861 } 848 } 849 862 863 // do no delete this, still working on testing this 864 cleanLibDict(); 865 } 866 -
trunk/src/fortran/RpLibraryFStubs.c
r115 r119 577 577 return rp_result(handle); 578 578 } 579 void580 rp_quit_ () {581 return rp_quit();582 }583 584 void585 rp_quit__ () {586 return rp_quit();587 }588 589 void590 RP_QUIT () {591 return rp_quit();592 }593 579 594 580 -
trunk/src/fortran/RpUnitsFInterface.cc
r115 r119 253 253 return result; 254 254 } 255 256 int257 rp_units_add_presets ( char* presetName, int presetName_len) {258 259 char* inPresetName = NULL;260 int result = -1;261 262 inPresetName = null_terminate(presetName,presetName_len);263 264 result = RpUnits::addPresets(inPresetName);265 266 if (inPresetName) {267 free(inPresetName);268 inPresetName = NULL;269 }270 271 return result;272 }273 -
trunk/src/fortran/RpUnitsFStubs.c
r115 r119 193 193 } 194 194 195 int196 rp_units_add_presets_ (char* presetName, int presetName_len) {197 return rp_units_add_presets(presetName,presetName_len);198 }199 200 int201 rp_units_add_presets__ (char* presetName, int presetName_len) {202 return rp_units_add_presets(presetName,presetName_len);203 }204 205 int206 RP_UNITS_ADD_PRESETS (char* presetName, int presetName_len) {207 return rp_units_add_presets(presetName,presetName_len);208 }209 210 195 #ifdef __cplusplus 211 196 }
Note: See TracChangeset
for help on using the changeset viewer.