From: caremoli Date: Mon, 25 Jun 2007 15:04:44 +0000 (+0000) Subject: CCAR: add fortran interface and python interface to DSC calcium ports X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a5868ab51a9da9befa88f76a80ddecd6b2591b77;p=modules%2Fkernel.git CCAR: add fortran interface and python interface to DSC calcium ports --- diff --git a/src/DSC/DSC_User/Datastream/Calcium/Calcium.c b/src/DSC/DSC_User/Datastream/Calcium/Calcium.c index ffcb4801f..de497f752 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/Calcium.c +++ b/src/DSC/DSC_User/Datastream/Calcium/Calcium.c @@ -27,6 +27,7 @@ #include "calcium.h" #include #include +#include // Interface C de SalomeCalcium @@ -169,3 +170,4 @@ CALCIUM_ECR_INTERFACE_C_(ere,float,float,float,); CALCIUM_ECR_INTERFACE_C_(edb,double,double,double,); CALCIUM_ECR_INTERFACE_C_(elo,float,bool,bool,); CALCIUM_ECR_INTERFACE_C_(ecp,float,float,cplx,); + diff --git a/src/DSC/DSC_User/Datastream/Calcium/Calcium.cxx b/src/DSC/DSC_User/Datastream/Calcium/Calcium.cxx new file mode 100644 index 000000000..6c3a680ca --- /dev/null +++ b/src/DSC/DSC_User/Datastream/Calcium/Calcium.cxx @@ -0,0 +1,109 @@ +#include "Calcium.hxx" +#include +#include +#include +#include +#include + +PySupervCompo::PySupervCompo( CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + Engines::Container_ptr contain, + const char *instanceName, + const char *interfaceName, + bool notif) : + Superv_Component_i(orb, poa,poa->reference_to_id(contain), instanceName, interfaceName) +{ +} + +PySupervCompo::~PySupervCompo() +{ +} + + +extern "C" +{ + void cp_exit(int err) + { + throw CalciumException(err,LOC("Abort coupling")); + } + + void setDependency(provides_port * port,char* type,CalciumTypes::DependencyType depend) + { + if(std::string(type)=="CALCIUM_real") + { + dynamic_cast(port)->setDependencyType(depend); + } + else if(std::string(type)=="CALCIUM_double") + { + dynamic_cast(port)->setDependencyType(depend); + } + else if(std::string(type)=="CALCIUM_integer") + { + dynamic_cast(port)->setDependencyType(depend); + } + else + { + std::cerr << "unknown type:" << std::endl; + } + } + + void create_port(Superv_Component_i* compo,char* name,char* type,char *mode,char* depend) + { + std::cerr << "create_port: " << name << type << mode << depend << std::endl; + if(std::string(mode) == "IN") + { + provides_port * port ; + //provides port + try + { + port = compo->create_provides_data_port(type); + compo->add_port(port, name); + if(std::string(depend) == "I") + setDependency(port,type,CalciumTypes::ITERATION_DEPENDENCY); + else if(std::string(depend) == "T") + setDependency(port,type,CalciumTypes::TIME_DEPENDENCY); + else + { + std::cerr << "unknown dependency: " << depend << std::endl; + } + } + catch(const Superv_Component_i::PortAlreadyDefined& ex) + { + //Port already defined : we use the old one + delete port; + std::cerr << "create_port: " << ex.what() << std::endl; + } + catch ( ... ) + { + std::cerr << "create_port: unknown exception" << std::endl; + } + } + else if(std::string(mode) == "OUT") + { + uses_port * uport ; + try + { + uport = compo->create_uses_data_port(type); + compo->add_port(uport, name); + } + catch(const Superv_Component_i::PortAlreadyDefined& ex) + { + //Port already defined : we use the old one + delete uport; + std::cerr << "create_port: " << ex.what() << std::endl; + } + catch ( ... ) + { + std::cerr << "create_port: unknown exception" << std::endl; + } + } + else + { + //Unknown mode + std::cerr << "Unknown mode: " << mode << std::endl; + } + } + +} + + diff --git a/src/DSC/DSC_User/Datastream/Calcium/Calcium.hxx b/src/DSC/DSC_User/Datastream/Calcium/Calcium.hxx new file mode 100644 index 000000000..d8f6d501d --- /dev/null +++ b/src/DSC/DSC_User/Datastream/Calcium/Calcium.hxx @@ -0,0 +1,17 @@ +#include "Superv_Component_i.hxx" + +class PySupervCompo:public Superv_Component_i +{ + public: + PySupervCompo(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + Engines::Container_ptr contain, + const char *instanceName, + const char *interfaceName, + bool notif = false); + virtual ~PySupervCompo(); + CORBA::Boolean init_service(const char * service_name){return true;}; +}; + + +extern "C" void create_port(Superv_Component_i* compo,char* name,char* type,char *mode,char* depend); diff --git a/src/DSC/DSC_User/Datastream/Calcium/Makefile.am b/src/DSC/DSC_User/Datastream/Calcium/Makefile.am index db339dd53..ee7064940 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/Makefile.am +++ b/src/DSC/DSC_User/Datastream/Calcium/Makefile.am @@ -54,6 +54,7 @@ salomeinclude_HEADERS = calcium_port_factory.hxx \ Copy2CorbaSpace.hxx \ CalciumPortTraits.hxx \ calcium.h \ + Calcium.hxx \ calciumP.h \ version.h \ calcium.hf @@ -66,10 +67,14 @@ salomeinclude_HEADERS = calcium_port_factory.hxx \ # This local variable defines the list of CPPFLAGS common to all target in this package. COMMON_CPPFLAGS= -I$(top_srcdir)/src/DSC/DSC_User \ -I$(top_srcdir)/src/DSC/DSC_User/Datastream \ + -I$(top_srcdir)/src/DSC/DSC_User/Datastream/Palm \ + -I$(top_srcdir)/src/DSC/DSC_User/Basic \ -I$(top_srcdir)/src/DSC/DSC_Basic \ -I$(top_srcdir)/src/SALOMELocalTrace \ -I$(top_srcdir)/src/Basics \ -I$(top_srcdir)/src/Utils \ + -I$(top_srcdir)/src/Container \ + -I$(top_srcdir)/src/Notification \ -I$(top_builddir)/salome_adm/unix \ -I$(top_builddir)/idl \ @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ @BOOST_CPPFLAGS@ @@ -92,6 +97,7 @@ libSalomeCalcium_la_SOURCES = calcium_port_factory.cxx \ CorbaTypes2CalciumTypes.cxx \ CalciumTypes2CorbaTypes.cxx \ CalciumProvidesPort.cxx \ + Calcium.cxx \ calcium_destructors_port_uses.cxx libSalomeCalcium_la_CXXFLAGS = $(COMMON_CPPFLAGS) @@ -100,7 +106,28 @@ libSalomeCalcium_la_LDFLAGS = -no-undefined -version-info=0:0:0 AM_CFLAGS = -fexceptions lib_LTLIBRARIES = libCalciumC.la -libCalciumC_la_SOURCES = Calcium.c +libCalciumC_la_SOURCES = Calcium.c Calcium.cxx calciumf.c +libCalciumC_la_CXXFLAGS = $(COMMON_CPPFLAGS) + +pkgpython_PYTHON = calcium.py dsccalcium.py +pkgpyexec_LTLIBRARIES = _calcium.la +SWIG_FLAGS= -python -c++ -noexcept +SWIG_SRC=calcium.i +_calcium_la_SOURCES = calcium_wrap.cpp +_calcium_la_LDFLAGS = -module +_calcium_la_LIBADD = libCalciumC.la \ + ../libSalomeDatastream.la \ + ../../Basic/libSalomeDSCSupervBasic.la \ + ../../libSalomeDSCSuperv.la \ + ../../../DSC_Basic/libSalomeDSCContainer.la \ + ../../../../Container/libSalomeContainer.la + +_calcium_la_CXXFLAGS = $(PYTHON_INCLUDES) $(COMMON_CPPFLAGS) + +calcium_wrap.cpp calcium.py:calcium.i + $(SWIG) $(SWIG_FLAGS) -o calcium_wrap.cpp $< + +CLEANFILES = calcium_wrap.cpp # # =============================================================== diff --git a/src/DSC/DSC_User/Datastream/Calcium/calcium.h b/src/DSC/DSC_User/Datastream/Calcium/calcium.h index 6dbf201c8..b90d5499f 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/calcium.h +++ b/src/DSC/DSC_User/Datastream/Calcium/calcium.h @@ -753,7 +753,6 @@ extern int cp_getopt( - #if defined(__cplusplus) || defined(c_plusplus) } #endif diff --git a/src/DSC/DSC_User/Datastream/Calcium/calcium.i b/src/DSC/DSC_User/Datastream/Calcium/calcium.i new file mode 100644 index 000000000..3c7c49a6e --- /dev/null +++ b/src/DSC/DSC_User/Datastream/Calcium/calcium.i @@ -0,0 +1,241 @@ +%define DOCSTRING +"CALCIUM python wrapping : Superv_Component class +" +%enddef + +%module(docstring=DOCSTRING) calcium + +%feature("autodoc", "0"); + +%{ +//C++ Includes +#include +#include +#include +#include + +//--- from omniORBpy.h (not present on Debian Sarge packages) + +struct omniORBpyAPI { + + PyObject* (*cxxObjRefToPyObjRef)(const CORBA::Object_ptr cxx_obj, + CORBA::Boolean hold_lock); + // Convert a C++ object reference to a Python object reference. + // If is true, caller holds the Python interpreter lock. + + CORBA::Object_ptr (*pyObjRefToCxxObjRef)(PyObject* py_obj, + CORBA::Boolean hold_lock); + // Convert a Python object reference to a C++ object reference. + // Raises BAD_PARAM if the Python object is not an object reference. + // If is true, caller holds the Python interpreter lock. + + + omniORBpyAPI(); + // Constructor for the singleton. Sets up the function pointers. +}; + + omniORBpyAPI* api; + +%} + +%init +%{ + // init section + + PyObject* omnipy = PyImport_ImportModule((char*)"_omnipy"); + if (!omnipy) + { + PyErr_SetString(PyExc_ImportError, + (char*)"Cannot import _omnipy"); + return; + } + PyObject* pyapi = PyObject_GetAttrString(omnipy, (char*)"API"); + api = (omniORBpyAPI*)PyCObject_AsVoidPtr(pyapi); + Py_DECREF(pyapi); +%} + +%include "carrays.i" +%include "cpointer.i" + +/* Wrap a class interface around an "int *" */ +%pointer_class(int, intp); +/* Wrap a class interface around an "float *" */ +%pointer_class(float, floatp); +/* Wrap a class interface around an "double *" */ +%pointer_class(double, doublep); + +%array_class(int, intArray); +%array_class(float, floatArray); +%array_class(double, doubleArray); + +%typemap(python,in) CORBA::Boolean +{ + $1=(CORBA::Boolean)PyInt_AsLong($input); +} + +%typemap(python,in) CORBA::ORB_ptr +{ + try { + CORBA::Object_ptr obj = api->pyObjRefToCxxObjRef($input,1); + $1 = CORBA::ORB::_narrow(obj); + } + catch (...) { + PyErr_SetString(PyExc_RuntimeError, "not a valid CORBA object ptr"); + } +} +%typemap(python,in) PortableServer::POA_ptr +{ + try { + CORBA::Object_ptr obj = api->pyObjRefToCxxObjRef($input,1); + $1 = PortableServer::POA::_narrow(obj); + } + catch (...) { + PyErr_SetString(PyExc_RuntimeError, "not a valid CORBA object ptr"); + } +} + +%typemap(python,in) Engines::Container_ptr +{ + try { + CORBA::Object_ptr obj = api->pyObjRefToCxxObjRef($input,1); + $1 = Engines::Container::_narrow(obj); + } + catch (...) { + PyErr_SetString(PyExc_RuntimeError, "not a valid CORBA object ptr"); + } +} +%typemap(python,in) Ports::Port_ptr +{ + try { + CORBA::Object_ptr obj = api->pyObjRefToCxxObjRef($input,1); + $1 = Ports::Port::_narrow(obj); + } + catch (...) { + PyErr_SetString(PyExc_RuntimeError, "not a valid CORBA object ptr"); + } +} + +%typemap(python,out) Ports::Port_ptr , Ports::PortProperties_ptr +{ + $result = api->cxxObjRefToPyObjRef($1, 1); +} + +/* + * Exception section + */ +// a general exception handler +%exception { + try { + $action + } catch(Engines::DSC::PortNotDefined& _e) { + PyErr_SetString(PyExc_ValueError,"Port not defined"); + return NULL; + } catch(Engines::DSC::PortNotConnected& _e) { + PyErr_SetString(PyExc_ValueError,"Port not connected"); + return NULL; + } catch(Engines::DSC::BadPortType& _e) { + PyErr_SetString(PyExc_ValueError,"Bad port type"); + return NULL; + } catch(...) { + PyErr_SetString(PyExc_ValueError,"Unknown exception"); + return NULL; + } +} + +/* + * End of Exception section + */ +namespace Engines +{ +class DSC +{ + public: + enum Message { AddingConnection, RemovingConnection, ApplicationError }; +}; +} + +class PySupervCompo:public Superv_Component_i +{ + public: + + PySupervCompo(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + Engines::Container_ptr contai, + const char *instanceName, + const char *interfaceName); + + virtual ~PySupervCompo(); + CORBA::Boolean init_service(const char * service_name){return true;}; + virtual provides_port * create_provides_data_port(const char* port_fab_type) + throw (BadFabType); + virtual uses_port * create_uses_data_port(const char* port_fab_type) + throw (BadFabType); + virtual void add_port(const char * port_fab_type, + const char * port_type, + const char * port_name) + throw (PortAlreadyDefined, BadFabType, BadType, BadProperty); + template < typename SpecificPortType > + SpecificPortType * add_port(const char * port_fab_type, + const char * port_type, + const char * port_name) + throw (PortAlreadyDefined, BadFabType, BadType, BadCast, BadProperty); + virtual void add_port(provides_port * port, + const char* provides_port_name) + throw (PortAlreadyDefined, NilPort, BadProperty); + virtual void add_port(uses_port * port, + const char* uses_port_name) + throw (PortAlreadyDefined, NilPort, BadProperty); + template + SpecificPortType * get_port( const char * port_name) + throw (PortNotDefined, PortNotConnected, BadCast, UnexpectedState); + virtual Ports::Port_ptr get_provides_port(const char* provides_port_name, + const CORBA::Boolean connection_error) + throw (Engines::DSC::PortNotDefined, + Engines::DSC::PortNotConnected, + Engines::DSC::BadPortType); + virtual void connect_uses_port(const char* uses_port_name, + Ports::Port_ptr provides_port_ref) + throw (Engines::DSC::PortNotDefined, + Engines::DSC::BadPortType, + Engines::DSC::NilPort); + virtual void connect_provides_port(const char* provides_port_name) + throw (Engines::DSC::PortNotDefined); + virtual void disconnect_provides_port(const char* provides_port_name, + const Engines::DSC::Message message) + throw (Engines::DSC::PortNotDefined, + Engines::DSC::PortNotConnected); + + virtual void disconnect_uses_port(const char* uses_port_name, + Ports::Port_ptr provides_port_ref, + const Engines::DSC::Message message) + throw (Engines::DSC::PortNotDefined, + Engines::DSC::PortNotConnected, + Engines::DSC::BadPortReference); + + virtual Ports::PortProperties_ptr get_port_properties(const char* port_name); + + %extend + { + //To get the address of the component + long ptr() + { + return (long)self; + } + } +}; + +extern "C" void create_port(Superv_Component_i* compo,char* name,char* type,char *mode,char* depend); + +#define CP_TEMPS 40 +#define CP_ITERATION 41 +#define CP_SEQUENTIEL 42 +#define CP_CONT 20 +#define CP_ARRET 21 + +int cp_een(void *component,int dep,float t,int n,char *nom,int nval,int *val); +int cp_edb(void *component,int dep,double t,int n,char *nom,int nval,double *val); + +int cp_len(void *component,int dep,float *INOUT,float *INPUT,int *INOUT,char *nom,int nmax,int *OUTPUT,int *val); +int cp_ldb(void *component,int dep,double *INOUT,double *INPUT,int *INOUT,char *nom,int nmax,int *OUTPUT,double *val); +int cp_fin(void *component,int cp_end); + diff --git a/src/DSC/DSC_User/Datastream/Calcium/calciumf.c b/src/DSC/DSC_User/Datastream/Calcium/calciumf.c new file mode 100644 index 000000000..a31eda3c2 --- /dev/null +++ b/src/DSC/DSC_User/Datastream/Calcium/calciumf.c @@ -0,0 +1,120 @@ +#include +#include +#include +#include +#include + +static void* COMPO=0; + +#ifdef __cplusplus +extern "C" { +#endif + +static void fstrtocstr(char *cstr, char *fstr,int fstr_len) +{ + int i,iend; + for (iend = fstr_len-1; iend >= 0; iend--) + if (fstr[iend] != ' ') break; + for (i = 0; i <= iend; i++) + cstr[i] = fstr[i]; + cstr[i] = '\0'; +} + +static void cstrtofstr(char *cstr, char *fstr,int fstr_len) +{ + int i, len; + len = strlen(cstr); + if (len > fstr_len) len = fstr_len; + for (i = 0; i < len; i++) + fstr[i] = cstr[i]; + while (i < fstr_len) + fstr[i++] = ' '; +} + +static char * fstr1(char *nom,int nnom) +{ + char * cnom=(char*)malloc((nnom+1)*sizeof(char)); + fstrtocstr(cnom,nom,nnom); + return cnom; +} + +static char * free_str1(char *nom) +{ + free(nom); +} + +void F_FUNC(cpcd,CPCD)(long *compo,STR_PSTR(nom),int *info STR_PLEN(nom)) +{ + /* nom is OUT argument */ + cp_cd((void *)*compo,STR_PTR(nom)); + /* replace in place ??? */ + cstrtofstr(STR_PTR(nom),STR_PTR(nom),STR_LEN(nom)); +} + +void F_FUNC(cplen,CPLEN)(long *compo,int *dep,float *ti,float *tf,int *iter,STR_PSTR(nom), + int *max,int *n, int *tab,int *err STR_PLEN(nom)) +{ + char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); + fprintf(stderr,"CPLEN: %s %f %f\n",cnom,*ti,*tf); + *err=cp_len((void *)*compo,*dep,ti,tf,iter,cnom,*max,n,tab); + fprintf(stderr,"End of CPLEN: %s \n",cnom); + free_str1(cnom); +} + +void F_FUNC(cpldb,CPLDB)(long *compo,int *dep,double *ti,double *tf,int *iter,STR_PSTR(nom), + int *max,int *n, double *tab,int *err STR_PLEN(nom)) +{ + char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); + fprintf(stderr,"CPLDB: %s %f %f \n",cnom, *ti,*tf); + *err=cp_ldb((void *)*compo,*dep,ti,tf,iter,cnom,*max,n,tab); + fprintf(stderr,"End of CPLDB: %s %f %f \n",cnom,*ti,*tf); + free_str1(cnom); +} + +void F_FUNC(cplre,CPLRE)(long *compo,int *dep,float *ti,float *tf,int *iter,STR_PSTR(nom), + int *max,int *n, float *tab,int *err STR_PLEN(nom)) +{ + char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); + fprintf(stderr,"CPLRE: %s %f %f \n",cnom, *ti,*tf); + *err=cp_lre((void *)*compo,*dep,ti,tf,iter,cnom,*max,n,tab); + fprintf(stderr,"End of CPLRE: %s %f %f \n",cnom,*ti,*tf); + free_str1(cnom); +} + +void F_FUNC(cpedb,CPEDB)(long *compo,int *dep,double *ti,int *iter,STR_PSTR(nom),int *n, double *tab,int *err STR_PLEN(nom)) +{ + char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); + fprintf(stderr,"CPEDB: %s %f \n",cnom, *ti); + *err=cp_edb((void *)*compo,*dep,*ti,*iter,cnom,*n,tab); + fprintf(stderr,"End of CPEDB: %s %f \n",cnom, *ti); + free_str1(cnom); +} + +void F_FUNC(cpere,CPERE)(long *compo,int *dep,float *ti,int *iter,STR_PSTR(nom),int *n, float *tab,int *err STR_PLEN(nom)) +{ + char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); + fprintf(stderr,"CPERE: %s %f \n",cnom, *ti); + *err=cp_ere((void *)*compo,*dep,*ti,*iter,cnom,*n,tab); + fprintf(stderr,"End of CPERE: %s %f \n",cnom, *ti); + free_str1(cnom); +} + +void F_FUNC(cpeen,CPEEN)(long *compo,int *dep,float *ti,int *iter,STR_PSTR(nom),int *n, int *tab,int *err STR_PLEN(nom)) +{ + char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); + fprintf(stderr,"CPEEN: %s %f %d\n",cnom, *ti,*iter); + *err=cp_een((void *)*compo,*dep,*ti,*iter,cnom,*n,tab); + fprintf(stderr,"End of CPEEN: %s %f \n",cnom,*ti); + free_str1(cnom); +} + +void F_FUNC(cpfin,CPFIN)(long *compo,int *dep,int *err) +{ + fprintf(stderr,"CPFIN: \n"); + *err=cp_fin((void *)*compo,*dep); +} + +#ifdef __cplusplus +} +#endif + diff --git a/src/DSC/DSC_User/Datastream/Calcium/dsccalcium.py b/src/DSC/DSC_User/Datastream/Calcium/dsccalcium.py new file mode 100644 index 000000000..c96fdc16c --- /dev/null +++ b/src/DSC/DSC_User/Datastream/Calcium/dsccalcium.py @@ -0,0 +1,53 @@ +import calcium +import SALOME_ComponentPy +import SALOME_DriverPy +import Engines + +class PyDSCComponent(SALOME_ComponentPy.SALOME_ComponentPy_i, + SALOME_DriverPy.SALOME_DriverPy_i): + """ + A Python SALOME component is implemented by a Python class that has + the name of the component and is located in a python module that has the + name of the component. + + This class is a base class for Python DSC components. + + You must derive it and implement init_service and those methods + that are services of the component. + """ + def __init__ ( self, orb, poa, contID, containerName, instanceName, interfaceName ): + SALOME_ComponentPy.SALOME_ComponentPy_i.__init__(self, orb, poa, + contID, containerName, instanceName, interfaceName, 0) + SALOME_DriverPy.SALOME_DriverPy_i.__init__(self, interfaceName) + # create the DSC proxy + self.proxy=calcium.PySupervCompo(orb,poa,contID,instanceName,interfaceName ) + # Store a reference on naming service in _naming_service attribute + self._naming_service = SALOME_ComponentPy.SALOME_NamingServicePy_i( self._orb ) + + def init_service(self,service): + return True + + enums={Engines.DSC.RemovingConnection:calcium.DSC.RemovingConnection, + Engines.DSC.AddingConnection:calcium.DSC.AddingConnection, + Engines.DSC.ApplicationError:calcium.DSC.ApplicationError, + } + def get_provides_port(self,name,error): + return self.proxy.get_provides_port(name,error) + + def connect_uses_port(self,name,port): + self.proxy.connect_uses_port(name,port) + + def connect_provides_port(self,name): + self.proxy.connect_provides_port(name) + + def disconnect_provides_port(self,name,message): + self.proxy.disconnect_provides_port(name,message._v) + #self.proxy.disconnect_provides_port(name,self.enums[message]) + + def disconnect_uses_port(self,name,port,message): + self.proxy.disconnect_uses_port(name,port,message._v) + #self.proxy.disconnect_uses_port(name,port,self.enums[message]) + + def get_port_properties(self,name): + return self.proxy.get_port_properties(name) + diff --git a/src/DSC/DSC_User/Datastream/Calcium/fortoc.h b/src/DSC/DSC_User/Datastream/Calcium/fortoc.h new file mode 100644 index 000000000..67b45336d --- /dev/null +++ b/src/DSC/DSC_User/Datastream/Calcium/fortoc.h @@ -0,0 +1,20 @@ + +#ifndef FORTRAN_H +#define FORTRAN_H + +/* Operateur de concatenation */ +#define _(A,B) A##B + +#ifdef __linux +#define F_FUNC(lname,uname) _(lname,_) /* Fortran function name */ +#define F_CALL(lname,uname) _(lname,_) /* Fortran function call */ +#define STR_PSTR(str) char *str /* fortran string arg pointer */ +#define STR_PLEN(str) , int _(Len,str) /* fortran string arg length */ +#define STR_PTR(str) str /* fortran string pointer */ +#define STR_LEN(str) _(Len,str) /* fortran string length */ + + +#endif + +#endif +