Changeset 77


Ignore:
Timestamp:
Sep 29, 2005 10:21:05 PM (15 years ago)
Author:
dkearney
Message:
  1. initial checkin of RpLibrary? code, includes c++/c/fortran bindings
  2. minor modifications to makefiles to accommodate new code
  3. updated README in src to tell how to compile code in src and test
Location:
trunk
Files:
11 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/fortran/RpFortranCommon.h

    r76 r77  
    33#include <ctype.h>
    44#include <string.h>
     5#include <string>
    56
    67#ifndef _RpFORTRAN_COMMON_H
    78#define _RpFORTRAN_COMMON_H
     9
    810
    911#ifdef __cplusplus
     
    1214
    1315char* null_terminate(char* inStr, int len);
    14 
     16std::string null_terminate_str(const char* inStr, int len);
    1517void fortranify(const char* inBuff, char* retText, int retTextLen);
    1618
  • trunk/src/Makefile

    r76 r77  
    88
    99EMB_PY_FLAGS    = -Wl,-rpath,$(EMB_PY_LIB_DIR) -L$(EMB_PY_LIB_DIR) $(EMB_PY_LIB_FLAG)
     10
     11
     12# tell make where to find the libscew sources
     13SCEW_HEADERS    = /opt/rappture/include/scew
     14LIB_SCEW_INCL   = -I $(SCEW_HEADERS)
     15LIB_SCEW_FLAG   = -L/opt/rappture/lib -lscew
     16#LIB_SCEW_FLAG  = -static -L/opt/rappture/lib -lscew
     17
    1018
    1119# everything below should be ok, but check to make sure
     
    2331PROGS                   =       librappture                             \
    2432                                        libRpObjects                    \
     33                                        librappture_test
    2534
    2635# define our compiling environment
     
    7887LIB_RP_OBJECTS  = $(LIB_INC_PREFIX) -lRpObjects
    7988LIB_RAPPTURE    = -Wl,-rpath,$(LIB_DIR) -L$(LIB_DIR) -lrappture
     89LIB_RAPPTURE_T  = -Wl,-rpath,$(LIB_DIR) -L$(LIB_DIR) -lrappture_test
    8090
    8191INCL_CORE               = -I $(INCLUDES_DIR)/core
     
    8999all: ${PROGS}
    90100
     101RP_IO_DEPS              = RpLibrary.o RpLibraryCInterface.o RpLibraryFInterface.o scew_extras.o
     102RP_UNITS_DEPS   =  RpUnitsStd.o RpUnits.o RpUnitsCInterface.o RpUnitsFInterface.o
     103RP_OTHER_DEPS   = RpFortranCommon.o
     104
    91105# include rappture library definitions
    92106
     
    99113        /sbin/ldconfig -n $(LIB_DIR)
    100114
     115librappture_test: $(RP_IO_DEPS) $(RP_UNITS_DEPS) $(RP_OTHER_DEPS)
     116        $(CXX) $(DEGUG) -shared -Wl,-rpath,$(LIB_DIR)/ \
     117                -Wl,-soname,$@.so -o $(LIB_DIR)/$@.so.0.0 $^ $(LIB_SCEW_FLAG)
     118
     119        /sbin/ldconfig -n $(LIB_DIR)
    101120
    102121#### libRpObjects ########################################################
    103122libRpObjects: RpVariable.o RpAbout.o RpNumber.o RpString.o RpBoolean.o RpChoice.o RpOption.o RpUnitsStd.o RpUnits.o
    104123        $(CXX) $(DEGUG) -shared -Wl,-rpath,$(LIB_DIR)/ \
    105                 -Wl,-soname,$@.so -o $(LIB_DIR)/$@.so.0.0 $^ -lc
     124                -Wl,-soname,$@.so -o $(LIB_DIR)/$@.so.0.0 $^
    106125       
    107126        /sbin/ldconfig -n $(LIB_DIR)
     
    110129# include core source files
    111130
     131RpLibrary.o: $(CORE_SRC)/RpLibrary.cc
     132        $(CXX) -fPIC $(DEBUG) $(INCL_CORE) $(LIB_SCEW_INCL) -o $@ -c $?
     133
     134scew_extras.o: $(CORE_SRC)/scew_extras.c
     135        $(CC) -fPIC $(DEBUG) $(INCL_CORE) $(LIB_SCEW_INCL) -o $@ -c $?
     136
    112137RpVariable.o: $(CORE_SRC)/RpVariable.cc
    113138        $(CXX) -fPIC $(DEBUG) $(INCL_CORE) -o $@ -c $?
     
    146171
    147172RpUnitsCInterface.o: $(CEE_SRC)/RpUnitsCInterface.cc
    148         $(CXX) $(CFLAGS) -fPIC $(DEBUG) $(INCL_CORE) $(INCL_CEE) -o $@ -c $?
     173        $(CXX) -fPIC $(DEBUG) $(INCL_CORE) $(INCL_CEE) -o $@ -c $?
     174
     175RpLibraryCInterface.o: $(CEE_SRC)/RpLibraryCInterface.cc
     176        $(CXX) -fPIC $(DEBUG) $(INCL_CORE) $(INCL_CEE) $(LIB_SCEW_INCL) -o $@ -c $?
    149177
    150178
     
    160188
    161189RpFortranCommon.o: $(FORT_SRC)/RpFortranCommon.c
    162         $(CC) $(CFLAGS) -fPIC $(DEBUG) $(INCL_FORTRAN) -o $@ -c $<
     190        $(CXX) $(CFLAGS) -fPIC $(DEBUG) $(INCL_FORTRAN) -o $@ -c $<
     191
     192RpLibraryFInterface.o: $(FORT_SRC)/RpLibraryFInterface.cc
     193        $(CXX) $(CFLAGS) -fPIC $(DEBUG) $(INCL_CORE) $(INCL_FORTRAN) $(LIB_SCEW_INCL) -o $@ -c $?
    163194
    164195
     
    167198#### CLEAN UP ############################################################
    168199clean:
    169         - rm -f $(BIN_DIR)/* *.o librappture.* libR*.so*
     200        - rm -f *.o librappture*.so* libRp*.so*
  • trunk/src/README

    r41 r77  
    11To compile the Rappture Library, the following must be done:
    22
    3 1) Adjust the Makefile.
     31)  Adjust the Makefile.
    44
    55    Change Makefile variables as needed. Pay particular attention to
     
    1010    above this directory.
    1111
    12 2) Adjust the file 'include/cee/rappture_interface.h'
     12    Check the Following variables:
     13       
     14        PY_SRC_HEADERS  = /opt/rappture/include/python2.4
     15        EMB_PY_LIB_FLAG = -lpython2.4
     16        EMB_PY_LIB_DIR  = /opt/rappture/lib
    1317
    14     Line 1 of rappture_interface.h includes 'python2.4/Python.h'.
    15     Make sure this file (and all of its supporting files) exist
    16     in the directory 'include/cee/'. Replace 'python2.4/Python.h'
    17     with the version of python being used and the location where
    18     Python.h can be found. Python.h and all of its suppoting files
    19     can be downloaded from http://www.python.org/download/. You
    20     will only need the header files to fulfill this task.
    21     If you do not have a python object library, you will need to
    22     compile python with the appropriate flags (--enable-shared) to
    23     get it.
    24    
    25 3) Make sure the Rappture module is installed in Python.
     18        # tell make where to find the libscew sources
     19        SCEW_HEADERS    = /opt/rappture/include/scew
     20        LIB_SCEW_INCL   = -I $(SCEW_HEADERS)
     21        LIB_SCEW_FLAG   = -L/opt/rappture/lib -lscew
    2622
    27 4) Make a library
    28    
    29     make librappture
     23        # define the top of our directory structure
     24        # replace this with the full path of the directory
     25        # containing the rappture directory
     26        TOP_DIR
    3027
    31 5) Make the Rappture Test programs
     28        CFLAGS         
    3229
    33     make test
     302) Make the Rappture library
     31
     32    To make the Rappture Library, you will need to make sure the Scew
     33    library header files are installed and the makefile variable
     34    SCEW_HEADERS is properly defined. The following scew related header
     35    files must be available in the library search path, preferably in
     36    same directory as the scew header files.
     37
     38     |  Header File Name  |   Provider   |
     39    -+--------------------+--------------+-
     40     |   xelement.h       | scew source  |
     41     |   xattribute.h     | scew source  |
     42     |   xerror.h         | scew source  |
     43    -+--------------------|--------------+-
     44     |   attribute.h      | scew source  |
     45     |   element.h        | scew source  |
     46     |   error.h          | scew source  |
     47     |   parser.h         | scew source  |
     48     |   scew.h           | scew source  |
     49     |   str.h            | scew source  |
     50     |   tree.h           | scew source  |
     51     |   writer.h         | scew source  |
     52    -+--------------------+--------------+-
     53     |   expat.h          | expat source |
     54     |   expat_external.h | expat source |
     55    -+--------------------+--------------+-
     56
     57    Once You've verified that these header files are available,
     58    issue the following commands:
     59        cd rappture/src
     60        make
     61
     623)  Installing Python's Rappture.Units module.
     63        cd rappture/python
     64        python setup.py install
     65
     664)  Make the Rappture Test programs
     67        cd rappture/test
     68        make
  • trunk/src/fortran/RpFortranCommon.c

    r76 r77  
    3737}
    3838
     39std::string null_terminate_str(const char* inStr, int len)
     40{
     41    int retVal = 0;
     42    std::string newStr = "";
     43    const char* current = NULL;
     44
     45    if (inStr) {
     46
     47        current = inStr+len-1;
     48
     49        while ((len > 0) && (isspace(*(current)))) {
     50            // dont strip off newlines
     51
     52            if ( (*(current) == '\f')
     53              || (*(current) == '\n')
     54              || (*(current) == '\r')
     55              || (*(current) == '\t')
     56              || (*(current) == '\v') )
     57            {
     58                break;
     59            }
     60
     61            if (--len) {
     62                current--;
     63            }
     64        }
     65
     66        newStr = std::string(inStr,len);
     67
     68        retVal++;
     69    }
     70
     71    // return retVal;
     72
     73    return newStr;
     74}             
     75
     76
    3977void fortranify(const char* inBuff, char* retText, int retTextLen) {
    4078
     
    4280    int i = 0;
    4381
    44     inBuffLen = strlen(inBuff);
     82    if (inBuff && retText && (retTextLen > 0)) {
     83        inBuffLen = strlen(inBuff);
    4584
    46     strncpy(retText, inBuff, retTextLen);
     85        strncpy(retText, inBuff, retTextLen);
    4786
    48     // fortran-ify the string
    49     if (inBuffLen < retTextLen) {
    50         for (i = inBuffLen; i < retTextLen; i++) {
    51             retText[i] = ' ';
     87        // fortran-ify the string
     88        if (inBuffLen < retTextLen) {
     89            for (i = inBuffLen; i < retTextLen; i++) {
     90                retText[i] = ' ';
     91            }
    5292        }
    5393    }
  • trunk/test/Makefile

    r76 r77  
     1
     2# tell make where to find the libscew sources
     3SCEW_HEADERS    = /opt/rappture/include/scew
     4LIB_SCEW_INCL   = -I $(SCEW_HEADERS)
     5LIB_SCEW_FLAG   = -L/opt/rappture/lib -lscew
     6#LIB_SCEW_FLAG  = -static -L/opt/rappture/lib -lscew
     7
    18# define the top of our directory structure
    29# replace this with the full path of the directory
     
    1623                      RpVariable_test   \
    1724                      RpUnitsC_test             \
    18                       RpUnitsF_test
     25                      RpUnitsF_test             \
     26                                          RpLibrary_test        \
     27                                          RpLibraryCInterface_test
    1928
    2029# define our compiling environment
     
    6574LIB_RP_OBJECTS  = $(LIB_INC_PREFIX) -lRpObjects
    6675LIB_RAPPTURE    = -Wl,-rpath,$(LIB_DIR) -L$(LIB_DIR) -lrappture
     76LIB_RAPPTURE_T  = -Wl,-rpath,$(LIB_DIR) -L$(LIB_DIR) -lrappture_test
    6777
    6878INCL_CORE               = -I $(INCLUDES_DIR)/core
     
    100110
    101111RpUnitsC_test: $(SRC_TEST)/RpUnitsC_test.c
    102         $(CC) $(DEBUG) $(INCL_CEE) $(INCL_CORE) -o $@ $^ $(LIB_RAPPTURE)
     112        $(CC) $(DEBUG) $(INCL_CEE) $(INCL_CORE) -o $@ $^ $(LIB_RAPPTURE_T)
     113
     114RpLibrary_test: $(SRC_TEST)/RpLibrary_test.cc
     115        $(CXX) $(DEBUG) $(INCL_CEE) $(INCL_CORE) $(LIB_SCEW_INCL) -o $@ $^ $(LIB_RAPPTURE_T)
     116
     117RpLibraryCInterface_test: $(SRC_TEST)/RpLibraryCInterface_test.c
     118        $(CC) $(DEBUG) $(INCL_CEE) $(INCL_CORE) $(LIB_SCEW_INCL) -o $@ $^ $(LIB_RAPPTURE_T)
    103119
    104120RpUnitsF_test: $(SRC_TEST)/RpUnitsF_test.f
    105         $(F77) $(DEBUG) -o $@ $^ $(LIB_RAPPTURE)
     121        $(F77) $(DEBUG) -o $@ $^ $(LIB_RAPPTURE_T)
    106122
    107123
Note: See TracChangeset for help on using the changeset viewer.