Changeset 83 for trunk/src/fortran


Ignore:
Timestamp:
Oct 5, 2005, 8:17:26 AM (19 years ago)
Author:
dkearney
Message:
  1. More cleaning of RpUnits and RpLibrary? code
  2. added rp_result code to c++/fortran/c code
  3. added rp_children, rp_lib_node[comp,type,id] for fortran code (need to test)
  4. adjusted convert function to recognize statements as follows:

convert("5J","neV")
convert("3.12075e+28neV","J")

  1. made joules a metric unit in RpUnits.cc
  2. tested examples/app-fermi/fortran/fermi.f with new rappture library.

added units conversion.

Location:
trunk/src/fortran
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • 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
    115#include "RpFortranCommon.h"
    216
  • 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
    112#include "RpLibraryFInterface.h"
    213
     
    819
    920    inFilePath = null_terminate_str(filePath, filePath_len);
    10    
     21
    1122    // create a RapptureIO object and store in dictionary
    1223    lib = new RpLibrary(inFilePath);
     
    3748        if (lib) {
    3849            retObj = lib->element(inPath);
    39            
     50
    4051            if (retObj) {
    4152                newObjHandle = storeObject_Lib(retObj);
     
    6879        }
    6980    }
    70    
     81
    7182}
    7283
     
    95106
    96107void rp_lib_element_type( int* handle, /* integer handle of library */
    97                             char* path,      /* null terminated path */
     108                            char* path,      /* search path inside xml */
    98109                            char* retText,   /* return buffer for fortran*/
    99110                            int path_len,
     
    113124        fortranify(retStr.c_str(),retText,retText_len);
    114125    }
     126}
     127
     128int 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
    115174}
    116175
     
    128187
    129188    inPath = null_terminate(path,path_len);
    130    
     189
    131190    if (rapptureStarted) {
    132191        if ((handle) && (*handle != 0)) {
     
    140199                }
    141200                else {
    142                    
     201
    143202                }
    144203            }
     
    394453
    395454    RpLibrary* lib = NULL;
    396    
     455
    397456    std::string inPath = "";
    398457
     
    401460    if ((handle) && (*handle != 0)) {
    402461        lib = getObject_Lib(*handle);
    403        
     462
    404463        if (lib) {
    405464            xmlText = lib->getString(inPath);
     
    420479
    421480    RpLibrary* lib = NULL;
    422    
     481
    423482    std::string inPath = "";
    424483
     
    427486    if ((handle) && (*handle != 0)) {
    428487        lib = getObject_Lib(*handle);
    429        
     488
    430489        if (lib) {
    431490            retVal = lib->getDouble(inPath);
     
    443502                        int path_len,
    444503                        int value_len
    445                       ) 
     504                      )
    446505{
    447506    std::string inPath = "";
     
    459518        }
    460519    }
    461    
     520
    462521    return;
    463    
     522
    464523}
    465524
     
    476535{
    477536    RpLibrary* lib = NULL;
    478    
     537
    479538    std::string inPath = "";
    480539    std::string inValue = "";
     
    487546    if ((handle) && (*handle != 0)) {
    488547        lib = getObject_Lib(*handle);
    489        
     548
    490549        if (lib) {
    491550            lib->put(inPath,inValue,inId,*append);
     
    586645    PyObject* lib = NULL;
    587646    PyObject* removedObj = NULL;
    588    
     647
    589648    char* inPath = NULL;
    590649
     
    597656            if (lib) {
    598657                removedObj = rpRemove(lib, inPath);
    599                
     658
    600659                if (removedObj) {
    601660                    newObjHandle = storeObject_Lib(removedObj);
     
    606665        }
    607666    }
    608    
     667
    609668    if (inPath) {
    610669        free(inPath);
     
    643702}
    644703*/
    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 }
    663704
    664705int rp_lib_write_xml(int* handle, char* outFile, int outFile_len)
     
    695736}
    696737
     738void  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
     756void 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
     773void 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
     790void 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
    697807void rp_quit()
    698808{
     
    701811
    702812    RpDictEntry DICT_TEMPLATE *hPtr;
    703     // RpDictIterator DICT_TEMPLATE iter((RpDict&)*this);                     
     813    // RpDictIterator DICT_TEMPLATE iter((RpDict&)*this);
    704814    RpDictIterator DICT_TEMPLATE iter(fortObjDict_Lib);
    705    
    706     hPtr = iter.first();                                                     
    707    
     815
     816    hPtr = iter.first();
     817
    708818    while (hPtr) {
    709819        // Py_DECREF(*(hPtr->getValue()));
    710820        hPtr->erase();
    711         hPtr = iter.next();                                                   
     821        hPtr = iter.next();
    712822    }
    713823
     
    717827    }
    718828
     829}
     830
     831void 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    }
    719840}
    720841
     
    756877        fortObjDict_Lib.set(dictKey,objectName, &newEntry);
    757878    }
    758    
     879
    759880    retVal = dictKey;
    760881    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
    112#include "RpUnits.h"
    213#include "RpDict.h"
Note: See TracChangeset for help on using the changeset viewer.