Changeset 119 for trunk


Ignore:
Timestamp:
Oct 27, 2005, 4:48:56 PM (19 years ago)
Author:
dkearney
Message:
  1. added doxygen headers to some fortran RpLibrary? bindings
  2. cleaned up app-fermi/fortran example
  3. removed rp_add_presets(...) function from api
  4. minor logic changes to RpUnits.cc.
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/examples/app-fermi/fortran/fermi.f

    r115 r119  
    1717        IMPLICIT NONE
    1818
    19         integer rp_lib, rp_units_convert_dbl, rp_units_add_presets
     19        integer rp_lib, rp_units_convert_dbl
    2020
    2121        integer driver, ok
     
    2626        call getarg(1,inFile)
    2727        driver = rp_lib(inFile)
    28 
    29         ok = rp_units_add_presets("all")
    3028
    3129        call rp_lib_get(driver,
  • trunk/include/fortran/RpLibraryFInterface.h

    r115 r119  
    4646                            int path_len );
    4747
    48 /*
    49  * rp_lib_child_num still needs to be written
    50  * keep function declaration around
    51 int rp_lib_child_num (      int* handle,
    52                             char* path,
    53                             int* childHandle,
    54                             int path_len);
    55 */
    56 
    5748int rp_lib_children (       int* handle, /* integer handle of library */
    5849                            char* path, /* search path of the xml */
     
    6051                            int path_len  /*length of the search path buffer*/
    6152                    );
    62 
    6353
    6454void rp_lib_get (           int* handle,
     
    146136void rp_result(             int* handle );
    147137
    148 void rp_quit();
    149 
    150 
    151138/**********************************************************/
    152139
  • trunk/include/fortran/RpLibraryFStubs.h

    r115 r119  
    126126void rp_result_(            int* handle );
    127127
    128 void rp_quit_();
    129128
    130129/**********************************************************/
     
    236235void rp_result__(           int* handle );
    237236
    238 void rp_quit__();
    239237
    240238/**********************************************************/
     
    347345void RP_RESULT(             int* handle );
    348346
    349 void RP_QUIT();
    350347
    351348/**********************************************************/
  • trunk/include/fortran/RpUnitsFInterface.h

    r115 r119  
    4949                            int retText_len     );
    5050
    51 int rp_units_add_presets ( char* presetName, int presetName_len);
    52 
    5351#ifdef __cplusplus
    5452}
  • trunk/include/fortran/RpUnitsFStubs.h

    r115 r119  
    8282                            int retText_len     );
    8383
    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 
    8884#ifdef __cplusplus
    8985}
  • trunk/src/core/RpLibrary.cc

    r115 r119  
    432432}
    433433
    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 RpLibrary
    448         // you can still get the children of the root node
    449         parentNode = this->root;
    450     }
    451     else {
    452         parentNode = _find(path,0);
    453     }
    454 
    455     if (parentNode == NULL) {
    456         // node not found
    457         // add error code here
    458         return NULL;
    459     }
    460 
    461     childCount = scew_element_count(parentNode);
    462 
    463     // even if there are no children, we can send back a null array
    464     retLib = new RpLibrary*[childCount+1];
    465 
    466     if (!retLib) {
    467         // there was an error mallocing memory for a RpLibrary object
    468         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 display
    487                 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 
    500434RpLibrary*
    501435RpLibrary::children (   std::string path,
     
    721655/*
    722656 * ----------------------------------------------------------------------
    723  *  FUNCTION: rpResult
     657 *  FUNCTION: result
    724658 *
    725659 *  Clients call this function at the end of their simulation, to
  • trunk/src/core/RpUnits.cc

    r118 r119  
    242242/**********************************************************************/
    243243// 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
    249249std::string
    250250RpUnits::getUnits() const {
     
    261261/**********************************************************************/
    262262// 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 this
    266 // * object, back to the caller. Note that if the exponent == 1, no
    267 // * 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
    270270std::string
    271271RpUnits::getUnitsName() const {
     
    293293/**********************************************************************/
    294294// 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 this
    298 // * object, back to the caller. Note that if the exponent == 1, no
    299 // * 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
    302302double
    303303RpUnits::getExponent() const {
     
    313313/**********************************************************************/
    314314// 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 the
    318 // * 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
    321321const RpUnits *
    322322RpUnits::getBasis() const {
     
    766766
    767767        if (showUnits) {
    768             outVal << val << toUnitsName;
     768            outVal << numVal << toUnitsName;
    769769        }
    770770        else {
    771             outVal << val;
     771            outVal << numVal;
    772772        }
    773773
     
    892892}
    893893
    894 /*
    895  * this code will be removed after dsk does some more testing
    896  *
    897 // convert function so people can just send in two strings and
    898 // we'll see if the units exists and do a conversion
    899 // strVal = RpUnits::convert("300K","C",1);
    900 std::string
    901 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 code
    922     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 dictionary
    931         if (result) {
    932             *result = 1;
    933         }
    934         return val;
    935     }
    936 
    937     // search our string to see where the numeric part stops
    938     // and the units part starts
    939     //
    940     //  convert("5J", "neV") => 3.12075e+28neV
    941     //  convert("3.12075e+28neV", "J") => 4.99999J
    942     // 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 string
    959         // assume fromUnitsName = toUnitsName
    960         // return the correct value
    961         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 dictionary
    980         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 
    997894std::string
    998895RpUnits::convert ( const  RpUnits* toUnits,
  • trunk/src/fortran/RpLibraryFInterface.cc

    r115 r119  
    1616#include "RpLibraryFStubs.c"
    1717
    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
     24int rp_lib(const char* filePath, int filePath_len) {
     25
    2026    RpLibrary* lib = NULL;
    2127    int handle = -1;
     
    3440}
    3541
     42/**********************************************************************/
     43// FUNCTION: rp_lib_element_obj()
     44/// Return the node located at 'path'.
     45/**
     46 */
    3647int rp_lib_element_obj(int* handle,     /* integer handle of library */
    3748                          char* path,     /* null terminated path */
     
    6273}
    6374
     75/**********************************************************************/
     76// FUNCTION: rp_lib_element_comp()
     77/// Return the component name of the node located at 'path'.
     78/**
     79 */
    6480void rp_lib_element_comp( int* handle, /* integer handle of library */
    6581                            char* path,      /* null terminated path */
     
    86102}
    87103
    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 */
     109void 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    */
    91112                            int path_len,
    92                             int retText_len /* length of return text buffer */
     113                            int retText_len  /* length of return text buffer */
    93114                        )
    94115{
     
    109130}
    110131
    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 */
     137void rp_lib_element_type( int* handle,       /* integer handle of library */
    112138                            char* path,      /* search path inside xml */
    113139                            char* retText,   /* return buffer for fortran*/
    114140                            int path_len,
    115                             int retText_len /* length of return text buffer */
     141                            int retText_len  /* length of return text buffer */
    116142                          )
    117143{
     
    130156}
    131157
     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 */
    132163int rp_lib_children (   int* handle, /* integer handle of library */
    133164                        char* path, /* search path of the xml */
     
    178209}
    179210
    180 /*
    181 int rp_lib_child_num( int* handle,
    182                          char* path,
    183                          int path_len
    184                        )
    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 */
    220211
    221212//int rp_lib_child_comp (   int* handle,    /* integer handle of library */
     
    447438*/
    448439
     440/**********************************************************************/
     441// FUNCTION: rp_lib()
     442/// Get data located at 'path' and return it as a string value.
     443/**
     444 */
    449445void rp_lib_get( int* handle, /* integer handle of library */
    450446                   char* path,      /* null terminated path */
     
    475471}
    476472
     473/**********************************************************************/
     474// FUNCTION: rp_lib_get_double()
     475/// Get data located at 'path' and return it as a double precision value.
     476/**
     477 */
    477478double rp_lib_get_double( int* handle,   /* integer handle of library */
    478479                            char* path,    /* null terminated path */
     
    500501
    501502
     503/**********************************************************************/
     504// FUNCTION: rp_lib_put_str()
     505/// Put string into Rappture Library Object at location 'path'.
     506/**
     507 */
    502508void rp_lib_put_str( int* handle,
    503509                        char* path,
     
    528534
    529535
     536/**********************************************************************/
     537// FUNCTION: rp_lib_put_id_str()
     538/// Put string into Rappture Library Object at location 'path' with id = 'id'
     539/**
     540 */
    530541void rp_lib_put_id_str ( int* handle,
    531542                        char* path,
     
    707718*/
    708719
     720/**********************************************************************/
     721// FUNCTION: rp_lib_write_xml()
     722/// Write the xml text into a file.
     723/**
     724 * \sa {rp_result}
     725 */
    709726int rp_lib_write_xml(int* handle, char* outFile, int outFile_len)
    710727{
     
    740757}
    741758
     759/**********************************************************************/
     760// FUNCTION: rp_lib_xml()
     761/// Return this node's xml text
     762/**
     763 */
    742764void  rp_lib_xml(int* handle, char* retText, int retText_len)
    743765{
     
    758780}
    759781
     782/**********************************************************************/
     783// FUNCTION: rp_lib_node_comp()
     784/// Return this node's component name
     785/**
     786 */
    760787void rp_lib_node_comp ( int* handle, char* retText, int retText_len ) {
    761788
     
    775802}
    776803
     804/**********************************************************************/
     805// FUNCTION: rp_lib_node_type()
     806/// Return this node's type
     807/**
     808 */
    777809void rp_lib_node_type ( int* handle, char* retText, int retText_len ) {
    778810
     
    792824}
    793825
     826/**********************************************************************/
     827// FUNCTION: rp_lib_node_id()
     828/// Return this node's id.
     829/**
     830 */
    794831void rp_lib_node_id ( int* handle, char* retText, int retText_len ) {
    795832
     
    809846}
    810847
    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 */
    839853void rp_result(int* handle) {
    840854    RpLibrary* lib = NULL;
     
    846860        }
    847861    }
    848 }
    849 
     862
     863    // do no delete this, still working on testing this
     864    cleanLibDict();
     865}
     866
  • trunk/src/fortran/RpLibraryFStubs.c

    r115 r119  
    577577    return rp_result(handle);
    578578}
    579 void
    580 rp_quit_ () {
    581     return rp_quit();
    582 }
    583 
    584 void
    585 rp_quit__ () {
    586     return rp_quit();
    587 }
    588 
    589 void
    590 RP_QUIT () {
    591     return rp_quit();
    592 }
    593579
    594580
  • trunk/src/fortran/RpUnitsFInterface.cc

    r115 r119  
    253253    return result;
    254254}
    255 
    256 int
    257 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  
    193193}
    194194
    195 int
    196 rp_units_add_presets_  (char* presetName, int presetName_len) {
    197     return rp_units_add_presets(presetName,presetName_len);
    198 }
    199 
    200 int
    201 rp_units_add_presets__ (char* presetName, int presetName_len) {
    202     return rp_units_add_presets(presetName,presetName_len);
    203 }
    204 
    205 int
    206 RP_UNITS_ADD_PRESETS   (char* presetName, int presetName_len) {
    207     return rp_units_add_presets(presetName,presetName_len);
    208 }
    209 
    210195#ifdef __cplusplus
    211196}
Note: See TracChangeset for help on using the changeset viewer.