- Timestamp:
- Sep 28, 2005 12:09:43 AM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/Makefile
r41 r73 1 # you need to change this to where your version of python is installed. 2 # tell make where to find python header files 3 PY_SRC_HEADERS = /opt/rappture/include/python2.4 4 5 # tell make where to find the python shared library 6 EMB_PY_LIB_FLAG = -lpython2.4 7 EMB_PY_LIB_DIR = /opt/rappture/lib 8 9 EMB_PY_FLAGS = -Wl,-rpath,$(EMB_PY_LIB_DIR) -L$(EMB_PY_LIB_DIR) $(EMB_PY_LIB_FLAG) 10 11 # everything below should be ok, but check to make sure 12 # especially check the fortran flags, if youre using fortran 13 # 1 14 # define the top of our directory structure 2 15 # replace this with the full path of the directory … … 8 21 9 22 # define which programs can be made 10 PROGS = libRpUnits_CInterface \ 11 libRpUnits_FInterface \ 12 librappture \ 13 libRapptureIO \ 14 libRpUnits \ 15 libRpVariable \ 16 libRpNumber \ 17 libRpString \ 18 libRpBoolean \ 19 libRpChoice \ 20 libRpOption 21 23 PROGS = librappture \ 24 libRpObjects \ 22 25 23 26 # define our compiling environment 24 27 # 25 AR = ar26 28 CC = gcc 27 29 CPP = g++ … … 62 64 # define our directories 63 65 # 64 WORK_DIR = $(RP_BASE)/work65 66 INCLUDES_DIR = $(RP_BASE)/include 66 67 BIN_DIR = $(RP_BASE)/bin 67 LIB_DIR = $(RP_BASE)/ lib68 LIB_DIR = $(RP_BASE)/src 68 69 SRC_DIR = $(RP_BASE)/src 69 70 TEST_DIR = $(RP_BASE)/test … … 74 75 PY_SRC = $(SRC_DIR)/python 75 76 76 #LIB_RPUNITS = -Wl,-rpath,$(LIB_DIR) -L$(LIB_DIR) -lRpUnits77 #LIB_RPDICT = -Wl,-rpath,$(LIB_DIR) -L$(LIB_DIR) -lRpDict78 79 77 LIB_INC_PREFIX = -Wl,-rpath,$(LIB_DIR) -L$(LIB_DIR) 80 81 #LIB_RPUNITS_C = $(LIB_INC_PREFIX) -lRpUnits_CInterface 82 #LIB_RAPPTUREIO = $(LIB_INC_PREFIX) -lrappture 83 84 LIB_RP_UNITS = $(LIB_INC_PREFIX) -lRpUnits 85 LIB_RP_VARIABLE = $(LIB_INC_PREFIX) -lRpVariable 86 LIB_RP_NUMBER = $(LIB_INC_PREFIX) -lRpNumber 87 LIB_RP_STRING = $(LIB_INC_PREFIX) -lRpString 88 LIB_RP_BOOLEAN = $(LIB_INC_PREFIX) -lRpBoolean 89 LIB_RP_OPTION = $(LIB_INC_PREFIX) -lRpOption 90 LIB_RP_CHOICE = $(LIB_INC_PREFIX) -lRpChoice 91 LIB_RP_PRESET = $(LIB_INC_PREFIX) -lRpPreset 92 93 94 LIB_RPUNITS_C = -Wl,-rpath,$(LIB_DIR) -L$(LIB_DIR) -lRpUnits_CInterface 95 LIB_RPUNITS_F = -Wl,-rpath,$(LIB_DIR) -L$(LIB_DIR) -lRpUnits_FInterface 78 LIB_RP_OBJECTS = $(LIB_INC_PREFIX) -lRpObjects 96 79 LIB_RAPPTURE = -Wl,-rpath,$(LIB_DIR) -L$(LIB_DIR) -lrappture 97 LIB_RAPPTUREIO = -Wl,-rpath,$(LIB_DIR) -L$(LIB_DIR) -lRapptureIO98 80 99 81 INCL_CORE = -I $(INCLUDES_DIR)/core 100 INCL_CEE = -I $(INCLUDES_DIR)/cee 82 INCL_CEE = -I $(INCLUDES_DIR)/cee -I $(PY_SRC_HEADERS) 101 83 INCL_FORTRAN = -I $(INCLUDES_DIR)/fortran 102 84 INCL_PY = -I $(INCLUDES_DIR)/python 103 104 # you need to change this to where your version of python is installed.105 EMB_PY_FLAGS = -L$(LIB_DIR) -lpython2.4106 107 # tell make where to find files of each specific type108 #109 vpath %.o $(WORK_DIR)110 vpath %.so $(LIB_DIR)111 vpath %.h $(INCLUDES_DIR)112 #vpath %.c $(CORE_SRC)113 #vpath %.cc $(CORE_SRC)114 #vpath %.tcc $(CORE_SRC)115 #vpath %.cpp $(CORE_SRC)116 85 117 86 … … 121 90 122 91 # include rappture library definitions 123 include $(SRC_DIR)/make.inc 92 93 #### librappture shared object ########################################### 94 95 librappture: rappture_fortran.o rappture_interface.o RpUnitsCInterface.o RpUnitsStd.o RpUnits.o 96 $(CPP) $(DEGUG) -shared -Wl,-rpath,$(LIB_DIR)/ \ 97 -Wl,-soname,$@.so -o $(LIB_DIR)/$@.so.0.0 $^ $(EMB_PY_FLAGS) 98 99 /sbin/ldconfig -n $(LIB_DIR) 100 101 102 #### libRpObjects ######################################################## 103 libRpObjects: RpVariable.o RpAbout.o RpNumber.o RpString.o RpBoolean.o RpChoice.o RpOption.o RpUnitsStd.o RpUnits.o 104 $(CPP) $(DEGUG) -shared -Wl,-rpath,$(LIB_DIR)/ \ 105 -Wl,-soname,$@.so -o $(LIB_DIR)/$@.so.0.0 $^ -lc 106 107 /sbin/ldconfig -n $(LIB_DIR) 108 124 109 125 110 # include core source files 126 include $(CORE_SRC)/make.inc 111 112 Rp%.o: $(CORE_SRC)/Rp%.cc 113 $(CPP) -fPIC $(DEBUG) $(INCL_CORE) -o $@ -c $? 127 114 128 115 # include cee binding definitions 129 include $(CEE_SRC)/make.inc 116 117 rappture_interface.o: $(CEE_SRC)/rappture_interface.c 118 $(CPP) -fPIC $(DEBUG) $(INCL_CEE) $(INCL_PY) -o $@ -c $< 119 120 RpUnitsCInterface.o: $(CEE_SRC)/RpUnitsCInterface.cc 121 $(CPP) $(CFLAGS) -fPIC $(DEBUG) $(INCL_CORE) $(INCL_CEE) -o $@ -c $? 130 122 131 123 # include fortran binding definitions 132 include $(FORT_SRC)/make.inc133 124 134 # include test programs 135 include $(TEST_DIR)/make.inc 125 RpUnits_fortran.o: $(FORT_SRC)/RpUnits_fortran.c 126 $(CPP) $(CFLAGS) -fPIC $(DEBUG) $(INCL_CORE) -o $@ -c $? 127 128 rappture_fortran.o: $(FORT_SRC)/rappture_fortran.c 129 $(CPP) $(CFLAGS) -fPIC $(DEBUG) $(INCL_CORE) $(INCL_CEE) $(INCL_PY) -o $@ -c $< 136 130 137 131 #### CLEAN UP ############################################################ 138 132 clean: 139 - rm -f $(BIN_DIR)/* $(WORK_DIR)/*.o $(LIB_DIR)/librappture.* $(LIB_DIR)/libR*.so*133 - rm -f $(BIN_DIR)/* *.o librappture.* libR*.so* -
trunk/src/cee/make.inc
r33 r73 1 1 2 $(WORK_DIR)/rappture_interface.o: $(CEE_SRC)/rappture_interface.c2 rappture_interface.o: $(CEE_SRC)/rappture_interface.c 3 3 $(CPP) -fPIC $(DEBUG) $(INCL_CEE) $(INCL_PY) -o $@ -c $< 4 4 5 $(WORK_DIR)/RpUnitsCInterface.o: $(CEE_SRC)/RpUnitsCInterface.cc5 RpUnitsCInterface.o: $(CEE_SRC)/RpUnitsCInterface.cc 6 6 $(CPP) $(CFLAGS) -fPIC $(DEBUG) $(INCL_CORE) $(INCL_CEE) -o $@ -c $? -
trunk/src/cee/rappture_interface.c
r49 r73 829 829 830 830 } 831 832 /* 833 * ---------------------------------------------------------------------- 834 * FUNCTION: rpResult 835 * 836 * Clients call this function at the end of their simulation, to 837 * pass the simulation result back to the Rappture GUI. It writes 838 * out the given XML object to a runXXX.xml file, and then writes 839 * out the name of that file to stdout. 840 * ====================================================================== 841 * AUTHOR: Michael McLennan, Purdue University 842 * Copyright (c) 2004-2005 843 * Purdue Research Foundation, West Lafayette, IN 844 * ====================================================================== 845 */ 846 // #include <stdlib.h> 847 // #include <time.h> 848 849 void 850 rpResult(PyObject* lib) { 851 char outputFile[100]; 852 char* xtext; 853 FILE* fp; 854 time_t t; 855 856 xtext = rpXml(lib); 857 858 // create output filename 859 snprintf(outputFile, 50, "run%d.xml", (int)time(&t)); 860 861 // write out the result file 862 fp = fopen(outputFile, "w"); 863 if(!fp) { 864 fprintf(stderr,"can't save results (err=%d)\n", errno); 865 return; 866 } 867 int fsize = fwrite(xtext, strlen(xtext), sizeof(char), fp); 868 fclose(fp); 869 870 // tell Rappture the file name 871 printf("=RAPPTURE-RUN=>%s\n", outputFile); 872 } -
trunk/src/core/RpUnits.cc
r68 r73 1 #ifndef _RpUNITS_H 2 #include "RpUnits.h" 3 #endif 1 /* 2 * ---------------------------------------------------------------------- 3 * RpUnits.cc 4 * 5 * Data Members and member functions for the RpUnits class 6 * 7 * ====================================================================== 8 * AUTHOR: Derrick Kearney, Purdue University 9 * Copyright (c) 2004-2005 10 * Purdue Research Foundation, West Lafayette, IN 11 * ====================================================================== 12 */ 13 14 #include "RpUnits.h" 4 15 5 16 // dict pointer 6 // RpDict<std::string,RpUnits*> RpUnits::dict = RpDict<std::string,RpUnits*>();7 17 RpDict<std::string,RpUnits*>* RpUnits::dict = new RpDict<std::string,RpUnits*>(); 8 9 18 10 19 /************************************************************************ … … 29 38 } 30 39 31 // char * cmpPtr = NULL; 40 double exp = 0.0; 41 double oldExponent = 0; 42 double newExponent = 0; 43 int digiSearch = 0; // flag to show we are searching digits 44 int alphaSearch = 0; // flag to show we are searching chars 45 46 std::string cmpStr = ""; 47 48 std::string::size_type length = units.length(); 49 int srchIndex = length; 50 std::string srchStr = units; 51 52 while ((srchStr.length() > 0)) { 53 54 srchIndex--; 55 56 if (srchIndex < 0) { 57 break; 58 } 59 60 if ( isdigit(srchStr[srchIndex]) && !digiSearch && !alphaSearch) { 61 digiSearch = 1; 62 } 63 else if(!isdigit(srchStr[srchIndex]) && digiSearch && !alphaSearch) { 64 65 // convert our exponent to integer 66 67 // check to see if there is a + or - sign 68 if ( ( srchStr[srchIndex] == '+' ) 69 || ( srchStr[srchIndex] == '-' ) ) { 70 71 // evaluate a '+' or '-' sign with the value 72 srchIndex--; 73 } 74 75 srchIndex++; 76 77 exp = atoi(&srchStr[srchIndex]); 78 79 // we are no longer in a digit search 80 digiSearch = 0; 81 82 // place null character where the number starts 83 // so we know what we've already parsed 84 85 srchStr.erase(srchIndex); 86 length = srchStr.length(); 87 88 } 89 else if( isalpha(srchStr[srchIndex]) && !digiSearch && !alphaSearch) { 90 alphaSearch = 1; 91 } 92 else if(!isalpha(srchStr[srchIndex]) && !digiSearch && alphaSearch) { 93 94 // adjust the exponent if none was provided 95 if (exp == 0) { 96 exp = 1; 97 } 98 99 // compare unit string to see if it is a recognized system 100 101 102 std::string cmpStr = srchStr.substr(srchIndex+1,length-srchIndex-1); 103 if (newRpUnit) { 104 newRpUnit->addUnit( cmpStr, exp, basis); 105 } 106 else { 107 newRpUnit= new RpUnits(cmpStr, exp, basis); 108 } 109 110 // place a null character at the end of the string 111 // so we know what we've parsed so far. 112 113 srchStr.erase(srchIndex); 114 length = srchStr.length(); 115 116 // fix our searching flag 117 alphaSearch = 0; 118 119 } 120 else if( srchStr[srchIndex] == '/' ) { 121 // have to go back to all of the objects created and 122 // multiply their exponents by -1. 123 124 if (newRpUnit) { 125 unit* p = newRpUnit->head; 126 while (p) { 127 oldExponent = p->getExponent(); 128 newExponent = oldExponent*-1; 129 p->newExponent(newExponent); 130 p = p->next; 131 } 132 } 133 134 // place a null character at the end of the string 135 // so we know what we've parsed so far. 136 137 srchStr.erase(srchIndex); 138 length = srchStr.length(); 139 140 } 141 else { 142 continue; 143 } 144 145 146 } // end while loop 147 148 149 // complete the last iteration 150 if (srchIndex < 0) { 151 152 153 if (digiSearch) { 154 // convert whatever is left 155 exp = atoi(&srchStr[srchIndex+1]); 156 157 // if we get here, that means units name starts with a digit 158 // normally we wont get here, but if we do, should we place 159 // the unit into the dictionary? i think not since digits are 160 // always considered exponents. 161 } 162 else if (alphaSearch) { 163 // adjust the exponent if none was provided 164 if (exp == 0) { 165 exp = 1; 166 } 167 168 // compare unit string to see if it is a recognized system 169 170 std::string cmpStr = srchStr.substr(srchIndex+1,length-srchIndex-1); 171 newRpUnit= new RpUnits(cmpStr, exp, basis); 172 newRpUnit->insert(newRpUnit->getUnitsName()); 173 } 174 } 175 176 // place the new object into the dictionary 177 178 // return a copy of the new object to user 179 return newRpUnit; 180 } 181 182 183 /************************************************************************ 184 * 185 * add a complex RpUnits Object 186 * 187 ************************************************************************/ 188 189 RpUnits * RpUnits::defineCmplx ( const std::string units, 190 RpUnits * basis ) 191 { 192 RpUnits * newRpUnit = NULL; 193 194 if (units == "") { 195 // raise error, user sent null units! 196 return NULL; 197 } 198 199 // check to see if the user is trying to trick me! 200 if ( (basis) && (units == basis->getUnits()) ) { 201 // dont trick me! 202 return NULL; 203 } 204 32 205 double exp = 0.0; 33 206 double oldExponent = 0; … … 44 217 std::string srchStr = units; 45 218 46 // unit* p = NULL;47 219 48 220 while ((srchStr.length() > 0)) { … … 82 254 length = srchStr.length(); 83 255 84 /*85 // shortcut so we dont have to go through an additional while86 // loop iteration.87 if (isalpha(srchStr[srchIndex-1])) {88 dbText = "alphaSearch = 1";89 dbprint(1,dbText);90 alphaSearch = 1;91 srchIndex--;92 }93 */94 256 } 95 257 else if( isalpha(srchStr[srchIndex]) && !digiSearch && !alphaSearch) { … … 117 279 // we may want to deal with them differntly in the future 118 280 119 // srchStr.erase(srchIndex+1);120 281 // erase only the last character and reprocess the string 121 282 // because our precompare doesnt take care of this yet. … … 142 303 143 304 // we need pre-compare to return the basis of what it found. 144 // addUnit( newUnit, exp, basis)145 305 if (newRpUnit) { 146 // newRpUnit->addUnit( newUnitText, exp, NULL);147 306 newRpUnit->addUnit( newUnitText, exp, basis); 148 307 } 149 308 else { 150 // newRpUnit= new RpUnits(newUnitText, exp, NULL);151 309 newRpUnit= new RpUnits(newUnitText, exp, basis); 152 310 } 153 311 154 // sprintf(dbText,"creating unit: %s,%d\n\0", newUnit.c_str(),exp);155 312 156 313 // place a null character at the end of the string … … 163 320 alphaSearch = 0; 164 321 165 // shortcut so we dont have to go through an additional while 166 // loop iteration. 167 // this doesnt work out so well, maybe need to reconsider 168 // if (isdigit(*(search--))) { 169 // dbprint(1,"digiSearch = 1"); 170 // digiSearch = 1; 171 // } 172 } 173 // else if ( *search == '/' ) { 322 } 174 323 else if( srchStr[srchIndex] == '/' ) { 175 324 // have to go back to all of the objects created and … … 189 338 // so we know what we've parsed so far. 190 339 191 /*192 end = (search);193 *end = '\0';194 */195 196 // srchStr.erase(srchIndex+1);197 340 srchStr.erase(srchIndex); 198 341 length = srchStr.length(); … … 235 378 236 379 // there are units we did not recognize, 237 // right now we ignore them,238 // we may want to deal with them differntly in the future239 // ignoring unit240 241 // break out of creating the last unit.242 380 243 381 // create a new unit with basis of null to show its a 244 382 // fundamental type 245 // newRpUnit = new RpUnits(cmpStr, exp, NULL);246 383 newRpUnit = new RpUnits(cmpStr, exp, basis); 247 384 248 385 // put the unit into the dictionary 249 // newRpUnit->insert(cmpStr);250 386 // 251 387 newRpUnit->insert(newRpUnit->getUnitsName()); 252 388 253 // RpUnits::dict.set(cmpStr,newRpUnit);254 389 255 390 } … … 265 400 266 401 // we need pre-compare to return the basis of what it found. 267 // addUnit( newUnit, exp, basis)268 402 if (newRpUnit) { 269 // newRpUnit->addUnit( newUnitText, exp, NULL );270 403 newRpUnit->addUnit( newUnitText, exp, basis ); 271 404 } 272 405 else { 273 // newRpUnit = new RpUnits(newUnitText, exp, NULL);274 406 newRpUnit = new RpUnits(newUnitText, exp, basis); 275 407 } … … 332 464 std::string RpUnits::getUnits() 333 465 { 334 // return units;335 336 466 std::stringstream unitText; 337 467 unit* p = head; 338 468 339 469 while (p) { 340 // unitText << p->getUnits() << p->getExponent();341 470 unitText << p->getUnits() ; 342 471 p = p->next; … … 353 482 std::string RpUnits::getUnitsName() 354 483 { 355 // return units;356 357 484 std::stringstream unitText; 358 485 unit* p = head; … … 383 510 double RpUnits::getExponent() 384 511 { 385 // return exponent;386 387 512 return head->getExponent(); 388 389 513 return 0; 390 514 } … … 397 521 RpUnits * RpUnits::getBasis() 398 522 { 399 // return basis;400 401 523 // check if head exists? 402 403 524 return head->getBasis(); 404 525 } … … 477 598 * 478 599 * **********************************************************************/ 479 //static int RpUnits::makeMetric(RpUnits * basis) {480 600 int RpUnits::makeMetric(RpUnits * basis) { 481 601 … … 536 656 RpUnits::define(peta, basis, peta2base, base2peta); 537 657 538 //539 658 return (1); 540 659 } … … 599 718 } 600 719 } 601 fromUnitsName = val.substr(idx, valLen-idx +1);720 fromUnitsName = val.substr(idx, valLen-idx); 602 721 } 603 722 else { … … 655 774 656 775 // currently we convert this object to its basis and look for the 657 // connection otthe toUnit object from the basis.776 // connection to the toUnit object from the basis. 658 777 659 778 double value = val; … … 888 1007 RpUnits* val = this; 889 1008 // dict pointer 890 // RpUnits::dict.set(key,val,&newRecord);891 1009 RpUnits::dict->set(key,val,&newRecord); 892 // std::cout << "key = :" << key << ":" << std::endl;893 1010 return newRecord; 894 1011 } … … 923 1040 (searchStr.length() > 0) ) { 924 1041 925 // std::cout << "units = :" << units << ":" << std::endl;926 // std::cout << "searchStr = :" << searchStr << ":" << std::endl;927 928 // if (!compare(searchStr)) {929 1042 // dict pointer 930 // if (dict.find(searchStr) == dict.getNullEntry()) {931 1043 if (dict->find(searchStr) == dict->getNullEntry()) { 932 1044 // the string was not found, … … 969 1081 } 970 1082 971 // if (!compare(searchStr)) {972 1083 // dict pointer 973 // if (dict.find(searchStr) == dict.getNullEntry()) {974 1084 if (dict->find(searchStr) == dict->getNullEntry()) { 975 1085 // the string was not found, … … 1014 1124 return retIndex; 1015 1125 1016 /*1017 if (retIndex) {1018 // if we found a match return a1019 // pointer to where the matching units1020 // string can be found.1021 dbText = "pre_compare returning an index";1022 dbprint(1, dbText);1023 return retIndex;1024 }1025 else {1026 // if there was no match, return a negative value.1027 dbText = "pre_compare returning -1";1028 dbprint(1, dbText);1029 return -1;1030 }1031 */1032 1126 } 1033 1127 … … 1035 1129 void RpUnits::connectConversion(RpUnits* myRpUnit) 1036 1130 { 1037 1038 /*1039 int index = 0;1040 1041 while ( (myRpUnit->staticConvArr[index] != NULL)1042 && (index < myRpUnit->numBuckets) ){1043 1044 index++;1045 }1046 1047 if ( (myRpUnit->staticConvArr[index] == NULL)1048 && (index < myRpUnit->numBuckets) ) {1049 1050 myRpUnit->staticConvArr[index] = this->conv;1051 }1052 */1053 1054 1131 convEntry* p = myRpUnit->convList; 1055 1132 … … 1094 1171 RpUnits::addPresetAll () { 1095 1172 1096 // RpUnits* volt = RpUnits::define("V", NULL);1097 1098 RpUnits::define("V", NULL);1099 1173 1100 1174 addPresetTime(); … … 1162 1236 RpUnits::addPresetEnergy () { 1163 1237 1238 RpUnits* volt = RpUnits::define("V", NULL); 1164 1239 RpUnits* electrVolt = RpUnits::define("eV", NULL); 1165 1240 RpUnits* joule = RpUnits::define("J", NULL); 1166 1241 1242 RpUnits::makeMetric(volt); 1243 1167 1244 // add energy definitions 1168 1245 RpUnits::define(electrVolt,joule,electronVolt2joule,joule2electronVolt); -
trunk/src/core/make.inc
r39 r73 1 $(WORK_DIR)/Rp%.o: $(CORE_SRC)/Rp%.cc1 Rp%.o: $(CORE_SRC)/Rp%.cc 2 2 $(CPP) -fPIC $(DEBUG) $(INCL_CORE) -o $@ -c $? -
trunk/src/fortran/make.inc
r33 r73 1 2 $(WORK_DIR)/RpUnits_fortran.o: $(FORT_SRC)/RpUnits_fortran.c 1 RpUnits_fortran.o: $(FORT_SRC)/RpUnits_fortran.c 3 2 $(CPP) $(CFLAGS) -fPIC $(DEBUG) $(INCL_CORE) -o $@ -c $? 4 3 5 $(WORK_DIR)/rappture_fortran.o: $(FORT_SRC)/rappture_fortran.c4 rappture_fortran.o: $(FORT_SRC)/rappture_fortran.c 6 5 $(CPP) $(CFLAGS) -fPIC $(DEBUG) $(INCL_CORE) $(INCL_CEE) $(INCL_PY) -o $@ -c $< -
trunk/src/make.inc
r39 r73 1 1 #### librappture shared object ########################################### 2 2 3 libRpUnits_CInterface: $(WORK_DIR)/RpUnitsCInterface.o $(WORK_DIR)/RpUnitsStd.o $(WORK_DIR)/RpUnits.o4 $(CPP) $(DEGUG) -shared -Wl,-rpath,. ./lib\5 -Wl,-soname,$@.so -o $ (LIB_DIR)/$@.so.0.0 $^ -lc3 libRpUnits_CInterface: RpUnitsCInterface.o RpUnitsStd.o RpUnits.o 4 $(CPP) $(DEGUG) -shared -Wl,-rpath,./ \ 5 -Wl,-soname,$@.so -o $@.so.0.0 $^ -lc 6 6 7 /sbin/ldconfig -n $(LIB_DIR)7 /sbin/ldconfig -n ./ 8 8 9 libRpUnits_FInterface: $(WORK_DIR)/RpUnitsStd.o $(WORK_DIR)/RpUnits.o $(WORK_DIR)/RpUnits_fortran.o10 $(CPP) $(DEBUG) -shared -Wl,-rpath,. ./lib\11 -Wl,-soname,$@.so -o $ (LIB_DIR)/$@.so.0.0 $^ -lstdc++9 libRpUnits_FInterface: RpUnitsStd.o RpUnits.o RpUnits_fortran.o 10 $(CPP) $(DEBUG) -shared -Wl,-rpath,./ \ 11 -Wl,-soname,$@.so -o $@.so.0.0 $^ -lstdc++ 12 12 13 /sbin/ldconfig -n $(LIB_DIR)13 /sbin/ldconfig -n ./ 14 14 15 librappture: $(WORK_DIR)/rappture_fortran.o $(WORK_DIR)/rappture_interface.o16 $(CC) $(DEGUG) -shared -Wl,-rpath,. ./lib\17 -Wl,-soname,$@.so -o $ (LIB_DIR)/$@.so.0.0 $^ $(EMB_PY_FLAGS) -lstdc++15 librappture: rappture_fortran.o rappture_interface.o 16 $(CC) $(DEGUG) -shared -Wl,-rpath,./ \ 17 -Wl,-soname,$@.so -o $@.so.0.0 $^ $(EMB_PY_FLAGS) -lstdc++ 18 18 19 /sbin/ldconfig -n $(LIB_DIR)19 /sbin/ldconfig -n ./ 20 20 21 libRapptureIO: $(WORK_DIR)/rappture_fortran.o $(WORK_DIR)/rappture_interface.o22 $(CC) $(DEGUG) -shared -Wl,-rpath,. ./lib\23 -Wl,-soname,$@.so -o $ (LIB_DIR)/$@.so.0.0 $^ $(EMB_PY_FLAGS) -lstdc++21 libRapptureIO: rappture_fortran.o rappture_interface.o 22 $(CC) $(DEGUG) -shared -Wl,-rpath,./ \ 23 -Wl,-soname,$@.so -o $@.so.0.0 $^ $(EMB_PY_FLAGS) -lstdc++ 24 24 25 /sbin/ldconfig -n $(LIB_DIR)25 /sbin/ldconfig -n ./ 26 26 27 27 28 28 #### libRpUnits ########################################################### 29 libRpUnits: $(WORK_DIR)/RpUnits.o $(WORK_DIR)/RpUnitsStd.o30 $(CPP) $(DEGUG) -shared -Wl,-rpath,. ./lib\31 -Wl,-soname,$@.so -o $ (LIB_DIR)/$@.so.0.0 $^ -lc29 libRpUnits: RpUnits.o RpUnitsStd.o 30 $(CPP) $(DEGUG) -shared -Wl,-rpath,./ \ 31 -Wl,-soname,$@.so -o $@.so.0.0 $^ -lc 32 32 33 /sbin/ldconfig -n $(LIB_DIR)33 /sbin/ldconfig -n ./ 34 34 35 35 #### libRpVariable ######################################################## 36 libRpVariable: $(WORK_DIR)/RpVariable.o $(WORK_DIR)/RpAbout.o37 $(CPP) $(DEGUG) -shared -Wl,-rpath,. ./lib\38 -Wl,-soname,$@.so -o $ (LIB_DIR)/$@.so.0.0 $^ -lc36 libRpVariable: RpVariable.o RpAbout.o 37 $(CPP) $(DEGUG) -shared -Wl,-rpath,./ \ 38 -Wl,-soname,$@.so -o $@.so.0.0 $^ -lc 39 39 40 /sbin/ldconfig -n $(LIB_DIR)40 /sbin/ldconfig -n ./ 41 41 42 42 #### libRpNumber ########################################################## 43 libRpNumber: $(WORK_DIR)/RpNumber.o libRpUnits libRpVariable44 $(CPP) $(DEGUG) -shared -Wl,-rpath,. ./lib\45 -Wl,-soname,$@.so -o $ (LIB_DIR)/$@.so.0.0 $< -lc $(LIB_RP_UNITS) $(LIB_RP_VARIABLE)43 libRpNumber: RpNumber.o libRpUnits libRpVariable 44 $(CPP) $(DEGUG) -shared -Wl,-rpath,./ \ 45 -Wl,-soname,$@.so -o $@.so.0.0 $< -lc $(LIB_RP_UNITS) $(LIB_RP_VARIABLE) 46 46 47 /sbin/ldconfig -n $(LIB_DIR)47 /sbin/ldconfig -n ./ 48 48 49 49 #### libRpString ########################################################## 50 libRpString: $(WORK_DIR)/RpString.o libRpVariable51 $(CPP) $(DEGUG) -shared -Wl,-rpath,. ./lib\52 -Wl,-soname,$@.so -o $ (LIB_DIR)/$@.so.0.0 $< -lc $(LIB_RP_VARIABLE)50 libRpString: RpString.o libRpVariable 51 $(CPP) $(DEGUG) -shared -Wl,-rpath,./ \ 52 -Wl,-soname,$@.so -o $@.so.0.0 $< -lc $(LIB_RP_VARIABLE) 53 53 54 /sbin/ldconfig -n $(LIB_DIR)54 /sbin/ldconfig -n ./ 55 55 56 56 #### libRpBoolean ########################################################## 57 libRpBoolean: $(WORK_DIR)/RpBoolean.o libRpVariable58 $(CPP) $(DEGUG) -shared -Wl,-rpath,. ./lib\59 -Wl,-soname,$@.so -o $ (LIB_DIR)/$@.so.0.0 $< -lc $(LIB_RP_VARIABLE)57 libRpBoolean: RpBoolean.o libRpVariable 58 $(CPP) $(DEGUG) -shared -Wl,-rpath,./ \ 59 -Wl,-soname,$@.so -o $@.so.0.0 $< -lc $(LIB_RP_VARIABLE) 60 60 61 /sbin/ldconfig -n $(LIB_DIR)61 /sbin/ldconfig -n ./ 62 62 63 63 #### libRpChoice ########################################################## 64 libRpChoice: $(WORK_DIR)/RpChoice.o libRpVariable libRpOption65 $(CPP) $(DEGUG) -shared -Wl,-rpath,. ./lib\66 -Wl,-soname,$@.so -o $ (LIB_DIR)/$@.so.0.0 $< -lc $(LIB_RP_VARIABLE) $(LIB_RP_OPTION)64 libRpChoice: RpChoice.o libRpVariable libRpOption 65 $(CPP) $(DEGUG) -shared -Wl,-rpath,./ \ 66 -Wl,-soname,$@.so -o $@.so.0.0 $< -lc $(LIB_RP_VARIABLE) $(LIB_RP_OPTION) 67 67 68 /sbin/ldconfig -n $(LIB_DIR)68 /sbin/ldconfig -n ./ 69 69 70 70 #### libRpOption ########################################################## 71 libRpOption: $(WORK_DIR)/RpOption.o $(WORK_DIR)/RpAbout.o72 $(CPP) $(DEGUG) -shared -Wl,-rpath,. ./lib\73 -Wl,-soname,$@.so -o $ (LIB_DIR)/$@.so.0.0 $< -lc $(LIB_RP_ABOUT)71 libRpOption: RpOption.o RpAbout.o 72 $(CPP) $(DEGUG) -shared -Wl,-rpath,./ \ 73 -Wl,-soname,$@.so -o $@.so.0.0 $< -lc $(LIB_RP_ABOUT) 74 74 75 /sbin/ldconfig -n $(LIB_DIR)75 /sbin/ldconfig -n ./ 76 76 -
trunk/src/python/PyRpUnits.cc
r71 r73 428 428 char* to = NULL; 429 429 char* units = NULL; 430 char* tmpRetStr = NULL; 430 431 std::string fromVal_S = ""; 431 432 std::string to_S = ""; … … 434 435 int result = 0; 435 436 std::string retStr = ""; 437 PyObject* retVal = NULL; 436 438 437 439 static char *kwlist[] = {"fromVal", "to", "units", NULL}; … … 462 464 retStr = RpUnits::convert(fromVal_S,to_S,unitsVal,&result); 463 465 464 if (!retStr.empty()) { 465 466 } 467 468 return PyString_FromString(retStr.c_str()); 466 if ( (!retStr.empty()) && (result == 1) ) { 467 if (unitsVal) { 468 retVal = PyString_FromString(retStr.c_str()); 469 } 470 else { 471 // convert to an integer and return that if 472 // the units were turned off 473 tmpRetStr = (char*) calloc(retStr.length(), sizeof(char)); 474 if (tmpRetStr) { 475 strncpy(tmpRetStr,retStr.c_str(),retStr.length()); 476 retVal = PyInt_FromString(tmpRetStr, NULL, 0); 477 free(tmpRetStr); 478 tmpRetStr = NULL; 479 } 480 } 481 } 482 else { 483 //keeping this around in case you want string returned instead of None 484 //if (fromVal) { 485 // retVal = PyString_FromString(fromVal); 486 //} 487 //else { 488 retVal = Py_None; 489 Py_INCREF(retVal); 490 //} 491 } 492 493 return retVal; 469 494 } 470 495
Note: See TracChangeset
for help on using the changeset viewer.