Salome HOME
CCAR: complete Calcium C API with cp_lln, cp_eln and remove some bugs in fortran...
authorcaremoli <caremoli>
Fri, 12 Mar 2010 07:59:13 +0000 (07:59 +0000)
committercaremoli <caremoli>
Fri, 12 Mar 2010 07:59:13 +0000 (07:59 +0000)
      add CALCIUM_long as SALOME type

resources/KERNELCatalog.xml.in
src/DSC/DSC_Python/calcium.i
src/DSC/DSC_User/Datastream/Calcium/Calcium.c
src/DSC/DSC_User/Datastream/Calcium/Calcium.cxx
src/DSC/DSC_User/Datastream/Calcium/calcium.h
src/DSC/DSC_User/Datastream/Calcium/calciumf.c
src/DSC/DSC_User/Datastream/Calcium/calciumf.h

index 35b2edea45d5b2046fda288ed45586466f3d14b2..c60881e1718134c04afc6d34ba8d9a3563cfd902 100644 (file)
@@ -27,6 +27,7 @@
     <member name="ref" type="string"/>
   </struct>
   <objref name="CALCIUM_integer" id="IDL:Ports/Calcium_Ports/Calcium_Integer_Port:1.0"/>
+  <objref name="CALCIUM_long" id="IDL:Ports/Calcium_Ports/Calcium_Long_Port:1.0"/>
   <objref name="CALCIUM_real" id="IDL:Ports/Calcium_Ports/Calcium_Real_Port:1.0"/>
   <objref name="CALCIUM_double" id="IDL:Ports/Calcium_Ports/Calcium_Double_Port:1.0"/>
   <objref name="CALCIUM_string" id="IDL:Ports/Calcium_Ports/Calcium_String_Port:1.0"/>
index bc504c30fd9e02b3d75a641bc096057e62fd98ec..215ad0ab4b933014755ca05c152aae3f2a57bbab 100644 (file)
@@ -28,6 +28,8 @@
 
 %feature("autodoc", "1");
 
+%include cstring.i
+
 %{
 //C++ Includes 
 #include <SALOMEconfig.h>
@@ -118,6 +120,19 @@ typedef PyArrayObject ArrayObject;
 #define array_size(a,i)        (((PyArrayObject *)a)->dimensions[i])
 #define array_is_contiguous(a) (PyArray_ISCONTIGUOUS(a))
 
+const char* pytype_string(PyObject*);
+const char* typecode_string(int);
+int type_match(int, int);
+int require_size(PyArrayObject*, int*, int);
+int require_dimensions_n(PyArrayObject*, int*, int);
+int require_dimensions(PyArrayObject*, int);
+int require_contiguous(PyArrayObject*);
+PyArrayObject* make_contiguous(PyArrayObject*, int*, int, int);
+PyArrayObject* obj_to_array_no_conversion(PyObject*, int);
+PyArrayObject* obj_to_array_allow_conversion(PyObject*, int, int*);
+PyArrayObject* obj_to_array_contiguous_allow_conversion(PyObject*, int, int*);
+PyArrayObject* obj_to_array_contiguous_allow_conversion(PyObject*, int, int*);
+
 /* Given a PyObject, return a string describing its type.
  */
 const char* pytype_string(PyObject* py_obj) {
@@ -400,8 +415,9 @@ typedef PyObject ArrayObject;
 
 %include "carrays.i" 
 
-%array_class(int, intArray);
-%array_class(float, floatArray);
+%array_class(int,    intArray);
+%array_class(long,   longArray);
+%array_class(float,  floatArray);
 %array_class(double, doubleArray);
 
 /* special struct to handle string arrays */
@@ -410,6 +426,7 @@ struct stringArray
 {
   stringArray(int nelements,int size=0) {
     nelem=nelements;
+    size=size;
     data= new char*[nelements];
     for(int i=0;i<nelements;i++)
     {
@@ -432,6 +449,7 @@ struct stringArray
   }
   char** data;
   int nelem;
+  int size;
 };
 %}
 /* End of special struct to handle string arrays */
@@ -458,17 +476,22 @@ struct stringArray
   }
 }
 %typemap(freearg) type* IN_ARRAY3 {
-  if (is_new_object$argnum && array$argnum) Py_DECREF(array$argnum);
+  if (is_new_object$argnum && array$argnum) 
+    {
+      Py_DECREF(array$argnum);
+    }
 }
 %enddef
 
 TYPEMAP_IN3(int,     PyArray_INT)
+TYPEMAP_IN3(long,    PyArray_LONG)
 TYPEMAP_IN3(float,   PyArray_FLOAT )
 TYPEMAP_IN3(double,  PyArray_DOUBLE)
 
 #undef TYPEMAP_IN3
 
 %apply int*    IN_ARRAY3 {int    *eval};
+%apply long*   IN_ARRAY3 {long   *eval};
 %apply float*  IN_ARRAY3 {float  *eval};
 %apply double* IN_ARRAY3 {double *eval};
 
@@ -488,12 +511,15 @@ TYPEMAP_IN3(double,  PyArray_DOUBLE)
   }
 }
 %typemap(freearg) float* ecpval {
-  if (is_new_object$argnum && array$argnum) Py_DECREF(array$argnum);
+  if (is_new_object$argnum && array$argnum) 
+    {
+      Py_DECREF(array$argnum);
+    }
 }
 /* End of  Specific typemap for complex */
 
 /* array of strings on input */
-%typemap(in) char** eval
+%typemap(in) (char** eval,int strSize)
          (ArrayObject* array=NULL, int is_new_object) {
   stringArray* sarray;
   if ((SWIG_ConvertPtr($input, (void **) &sarray, $descriptor(stringArray *),0)) == -1)
@@ -503,8 +529,13 @@ TYPEMAP_IN3(double,  PyArray_DOUBLE)
     array = obj_to_array_contiguous_allow_conversion($input, PyArray_STRING, &is_new_object);
     if (!array || !require_dimensions(array,1) || !require_size(array,size,1)) SWIG_fail;
     $1 = (char**) malloc(array_size(array,0)*sizeof(char*));
+    $2 = array->strides[0];
     for(int i=0;i<array_size(array,0);i++)
-      $1[i]=(char*) array->data + i* array->strides[0];
+      {
+        $1[i]=(char*) malloc(sizeof(char)*(array->strides[0]+1));
+        strncpy($1[i],(char*) array->data + i* array->strides[0],array->strides[0]);
+        *($1[i]+array->strides[0])='\0';
+      }
 %#else
     SWIG_exception(SWIG_TypeError, "string array expected");
 %#endif
@@ -512,12 +543,21 @@ TYPEMAP_IN3(double,  PyArray_DOUBLE)
   else
   {
     $1=sarray->data;
+    $2=sarray->size;
   }
 }
 
-%typemap(freearg) char** eval {
-  if (array$argnum) free($1);
-  if (is_new_object$argnum && array$argnum) Py_DECREF(array$argnum);
+%typemap(freearg) (char** eval,int strSize) {
+  if (array$argnum)
+    {
+      for(int i=0;i<array_size(array$argnum,0);i++)
+        free($1[i]);
+      free($1);
+    }
+  if (is_new_object$argnum && array$argnum) 
+    {
+      Py_DECREF(array$argnum);
+    }
 }
 /* End of array of strings on input */
 
@@ -543,12 +583,14 @@ TYPEMAP_IN3(double,  PyArray_DOUBLE)
 %enddef
 
 TYPEMAP_INPLACE3(int,     PyArray_INT)
+TYPEMAP_INPLACE3(long,    PyArray_LONG)
 TYPEMAP_INPLACE3(float,   PyArray_FLOAT )
 TYPEMAP_INPLACE3(double,  PyArray_DOUBLE)
 
 #undef TYPEMAP_INPLACE3
 
 %apply int*    INPLACE_ARRAY3 {int    *lval};
+%apply long*   INPLACE_ARRAY3 {long   *lval};
 %apply float*  INPLACE_ARRAY3 {float  *lval};
 %apply double* INPLACE_ARRAY3 {double *lval};
 
@@ -570,7 +612,7 @@ TYPEMAP_INPLACE3(double,  PyArray_DOUBLE)
 /*  End of typemap for complex inout */
 
 /* typemap for array of strings on input/output */
-%typemap(in) char** lval
+%typemap(in) (char** lval,int strSize)
             (ArrayObject* temp=NULL) {
   stringArray* sarray;
   if ((SWIG_ConvertPtr($input, (void **) &sarray, $descriptor(stringArray *) ,0)) == -1)
@@ -579,8 +621,12 @@ TYPEMAP_INPLACE3(double,  PyArray_DOUBLE)
     temp = obj_to_array_no_conversion($input,PyArray_STRING);
     if (!temp  || !require_contiguous(temp)) SWIG_fail;
     $1 = (char**) malloc(array_size(temp,0)*sizeof(char*));
+    $2 = temp->strides[0];
     for(int i=0;i<array_size(temp,0);i++)
-      $1[i]=(char*) temp->data+i*temp->strides[0];
+      {
+        $1[i]=(char*) temp->data+i*temp->strides[0];
+        memset($1[i],0,temp->strides[0]); //numpy strings must be completed with 0 up to elsize
+      }
 %#else
     temp = NULL;
     SWIG_exception(SWIG_TypeError, "string array expected");
@@ -589,9 +635,10 @@ TYPEMAP_INPLACE3(double,  PyArray_DOUBLE)
   else
   {
     $1=sarray->data;
+    $2=sarray->size;
   }
 }
-%typemap(freearg) char** lval {
+%typemap(freearg) (char** lval,int strSize) {
   if (temp$argnum) free($1);
 }
 /* End of typemap for array of strings on input/output */
@@ -828,7 +875,9 @@ extern "C" void create_calcium_port(Superv_Component_i* compo,char* name,char* t
 %ignore CPMESSAGE;
 %include "calciumP.h"
 
-int  cp_cd(Superv_Component_i *component,char *name);
+%cstring_bounded_output(char *instanceName, 1024);
+
+int  cp_cd(Superv_Component_i *component,char *instanceName);
 
 int cp_een(Superv_Component_i *component,int dep,float  t,int n,char *nom,int nval,int    *eval);
 int cp_edb(Superv_Component_i *component,int dep,double t,int n,char *nom,int nval,double *eval);
@@ -836,6 +885,8 @@ int cp_ere(Superv_Component_i *component,int dep,float  t,int n,char *nom,int nv
 int cp_ecp(Superv_Component_i *component,int dep,float  t,int n,char *nom,int nval,float  *ecpval);
 int cp_elo(Superv_Component_i *component,int dep,float  t,int n,char *nom,int nval,int    *eval);
 int cp_ech(Superv_Component_i *component,int dep,float  t,int n,char *nom,int nval,char** eval,int strSize);
+int cp_elg(Superv_Component_i *component,int dep,float  t,int n,char *nom,int nval,long   *eval);
+int cp_eln(Superv_Component_i *component,int dep,float  t,int n,char *nom,int nval,long   *eval);
 
 
 int cp_len(Superv_Component_i *component,int dep,float  *ti,float  *tf,int *niter,char *nom,int nmax,int *nval,int    *lval);
@@ -844,6 +895,8 @@ int cp_lre(Superv_Component_i *component,int dep,float  *ti,float  *tf,int *nite
 int cp_lcp(Superv_Component_i *component,int dep,float  *ti,float  *tf,int *niter,char *nom,int nmax,int *nval,float  *lcpval);
 int cp_llo(Superv_Component_i *component,int dep,float  *ti,float  *tf,int *niter,char *nom,int nmax,int *nval,int    *lval);
 int cp_lch(Superv_Component_i *component,int dep,float  *ti,float  *tf,int *niter,char *nom,int nmax,int *nval,char** lval,int strSize);
+int cp_llg(Superv_Component_i *component,int dep,float  *ti,float  *tf,int *niter,char *nom,int nmax,int *nval,long   *lval);
+int cp_lln(Superv_Component_i *component,int dep,float  *ti,float  *tf,int *niter,char *nom,int nmax,int *nval,long   *lval);
 
 int cp_fin(Superv_Component_i *component,int cp_end);
 
index b9ce3521e0397eeff0c583939c4c892477a0ac55..86064a721549bf9b7f1a50d4258f44605b1cf3f6 100644 (file)
@@ -31,7 +31,7 @@
 #include <string.h>
 #include <stddef.h>
 
-// Interface C de SalomeCalcium 
+// Interface C de SalomeCalcium
 
 typedef int InfoType;
 typedef char bool;
@@ -89,22 +89,21 @@ InfoType ecp_lch(void * component, int mode, float * ti,        float * tf, int
                 char  * nomvar, int bufferLength, int * nRead,
                 char *** data, int strSize) {
 
-  size_t _nRead;                                                        
-  long   _i=*i;                                                 
-  fflush(stdout);fflush(stderr);                                                        
-  InfoType info =  ecp_lecture_str (component, mode, ti, tf, &_i, 
-                                    nomvar, bufferLength, &_nRead, 
-                                    data);/*, strSize ); 
+  size_t _nRead;
+  long   _i=*i;
+  fflush(stdout);fflush(stderr);
+
+  InfoType info =  ecp_lecture_str (component, mode, ti, tf, &_i,
+                                    nomvar, bufferLength, &_nRead,
+                                    data);/*, strSize );
                                              strSize est  inutile pour les ports CALCIUM
                                              qui gèrent des tailles quelconques de chaines. */
-  if(mode == CP_SEQUENTIEL)                                             
-    *i = _i;                                                            
-  *nRead=_nRead;                                                        
-  fflush(stdout);fflush(stderr);                                                        
-                                                                        
-  return info;                                                  
-};                                                                      
+  if(mode == CP_SEQUENTIEL)
+    *i = _i;
+  *nRead=_nRead;
+  fflush(stdout);fflush(stderr);
+  return info;
+};
 
 void ecp_lch_free (char* * data) {                              \
   ecp_lecture_str_free(data);                                   \
@@ -171,9 +170,7 @@ CALCIUM_EXT_LECT_INTERFACE_C_(lcp,float,float,cplx,);
 /*   long   _i=*i;                                                       */
 /*   fflush(stdout);fflush(stderr);                                                      */
 /*   fprintf(stderr,"Beginning of cp_lch: %s %d %f\n",nomvar,*i,*ti);    */
-                                                                        
 /*   if ( (data == NULL) || (bufferLength < 1) ) return CPNTNULL;        */
-  
 /*   InfoType info =  ecp_lecture_str (component, mode, ti, tf, &_i,  */
 /*                                  nomvar, bufferLength, &_nRead,  */
 /*                                  &data);*/
@@ -185,7 +182,6 @@ CALCIUM_EXT_LECT_INTERFACE_C_(lcp,float,float,cplx,);
 /*   *nRead=_nRead;                                                      */
 /*   fprintf(stderr,"End of cp_lch: %s %d \n",nomvar,*i);                        */
 /*   fflush(stdout);fflush(stderr);                                                      */
-                                                                        
 /*   return info;                                                        */
 /* };                                                                    */
 
@@ -195,13 +191,15 @@ CALCIUM_EXT_LECT_INTERFACE_C_(lcp,float,float,cplx,);
                               <type de données>, <nom de l'interface C2CPP à utiliser>, <qualificateur de type optionnel des données>,<paramètres supplémentaire ignoré>)*/
 
 CALCIUM_LECT_INTERFACE_C_(len,float ,int,int    ,int2integer,,);
-/*llg ne sera pas disponible si sizeof(long) == 64 bits && cal_int==int
-  sinon problème de conversion de 64bits vers 32bits */  
+/*llg ne fonctionnera pas toujours correctement (port calcium_integer) si sizeof(long) == 64 bits && cal_int==int (32 bits)
+  sinon problème de conversion de 64bits vers 32bits */
 CALCIUM_LECT_INTERFACE_C_(llg,float ,int,long   ,long2integer,,);
 
+CALCIUM_LECT_INTERFACE_C_(lln,float ,int,long   ,long,,);
+
 CALCIUM_LECT_INTERFACE_C_(lre,float ,int,float  ,float,,);
 CALCIUM_LECT_INTERFACE_C_(ldb,double,int,double ,double,,);
-CALCIUM_LECT_INTERFACE_C_(llo,float ,int,int    ,bool,,); 
+CALCIUM_LECT_INTERFACE_C_(llo,float ,int,int    ,bool,,);
 CALCIUM_LECT_INTERFACE_C_(lcp,float ,int,float  ,cplx,,);
 #define STAR *
 #define LCH_LAST_PARAM ,int strsize
@@ -213,8 +211,8 @@ CALCIUM_LECT_INTERFACE_C_(lch,float ,int,char   ,str,STAR, LCH_LAST_PARAM );
 
 CALCIUM_LECT_INTERFACE_C_(len_fort_,float ,cal_int,cal_int ,integer,,);
 CALCIUM_LECT_INTERFACE_C_(lin_fort_,float ,cal_int,int     ,int2integer,,);
-/*llg ne sera pas disponible si sizeof(long) == 64 bits && cal_int==int
-  sinon problème de conversion de 64bits vers 32bits */  
+/*llg_fort_ ne fonctionnera pas toujours correctement (port calcium_integer) si sizeof(long) == 64 bits && cal_int==int (32 bits)
+  sinon problème de conversion de 64bits vers 32bits */
 CALCIUM_LECT_INTERFACE_C_(llg_fort_,float ,cal_int,long    ,long2integer,,);
 
 CALCIUM_LECT_INTERFACE_C_(lre_fort_,float ,cal_int,float   ,float,,);
@@ -223,6 +221,7 @@ CALCIUM_LECT_INTERFACE_C_(llo_fort_,float ,cal_int,int     ,bool,,);   /*int pou
 CALCIUM_LECT_INTERFACE_C_(lcp_fort_,float ,cal_int,float   ,cplx,,);
 CALCIUM_LECT_INTERFACE_C_(lch_fort_,float ,cal_int,char    ,str,STAR, LCH_LAST_PARAM );
 
+CALCIUM_LECT_INTERFACE_C_(lln_fort_,float ,cal_int,long    ,long,,);
 
 /**********************************************/
 /*  INTERFACES DE DÉBUT ET DE FIN DE COUPLAGE */
@@ -235,9 +234,9 @@ InfoType cp_cd (void * component, char * instanceName) {
 
 InfoType cp_fin (void * component, int code) {
   /* TODO : gérer avec les callbacks des ports DSC */
-  
+
   InfoType info =  ecp_fin_(component,code);
-  
+
   return info;
 }
 
@@ -276,12 +275,12 @@ InfoType cp_fin (void * component, int code) {
 /* InfoType cp_ech(void * component, int mode, float t, int i, */
 /*              char  * nomvar,  int nbelem, */
 /*              char ** data, int strSize) { */
-                                                                        
-/*long   _i=i;*/                                                         
+
+/*long   _i=i;*/
 /*   fflush(stdout);fflush(stderr);                                                      */
 /*   fprintf(stderr,"Beginning of cp_ech: %s %d %f\n",nomvar,i,t);       */
 /*   if ( (data == NULL) || (nbelem < 1) ) return CPNTNULL;              */
-    
+
 /*   InfoType info =  ecp_ecriture_str (component, mode, &t, i,  */
 /*                                   nomvar, nbelem,             */
 /*                                   data); */
@@ -289,13 +288,15 @@ InfoType cp_fin (void * component, int code) {
 /*   fprintf(stderr,"End of cp_ech: %s %d \n",nomvar,i);                         */
 /*   fflush(stdout);                                                     */
 /*   fflush(stderr);                                                     */
-                                                                        
+
 /*   return info;                                                        */
 /* };                                                                    */
 
 /*  Definition des méthodes calcium standard  */
 /*  CALCIUM_ECR_INTERFACE_C_(_name,_timeType,_calInt,type,_typeName,_qual) */
 CALCIUM_ECR_INTERFACE_C_(een,float ,int,int   ,int2integer,,);
+/*elg ne fonctionnera pas toujours correctement (port calcium_integer) si sizeof(long) == 64 bits && cal_int==int (32 bits)
+  sinon problème de conversion de 64bits vers 32bits */
 CALCIUM_ECR_INTERFACE_C_(elg,float ,int,long  ,long2integer,,);
 CALCIUM_ECR_INTERFACE_C_(ere,float ,int,float ,float,,);
 CALCIUM_ECR_INTERFACE_C_(edb,double,int,double,double,,);
@@ -303,10 +304,14 @@ CALCIUM_ECR_INTERFACE_C_(elo,float ,int,int   ,bool,,);
 CALCIUM_ECR_INTERFACE_C_(ecp,float ,int,float ,cplx,,);
 CALCIUM_ECR_INTERFACE_C_(ech,float ,int,char  ,str,STAR,LCH_LAST_PARAM );
 
+CALCIUM_ECR_INTERFACE_C_(eln,float ,int,long  ,long,,);
+
 /* Definition des méthodes calcium destinées à l'interfaçage fortran
    avec une taille des INTEGER fortran paramétrés à la configuration du KERNEL  */
 
 CALCIUM_ECR_INTERFACE_C_(een_fort_,float ,cal_int,cal_int,integer,,);
+/*elg_fort_ ne fonctionnera pas toujours correctement (port calcium_integer) si sizeof(long) == 64 bits && cal_int==int (32 bits)
+  sinon problème de conversion de 64bits vers 32bits */
 CALCIUM_ECR_INTERFACE_C_(elg_fort_,float ,cal_int,long   ,long2integer,,);
 CALCIUM_ECR_INTERFACE_C_(ein_fort_,float ,cal_int,int    ,int2integer,,);
 CALCIUM_ECR_INTERFACE_C_(ere_fort_,float ,cal_int,float ,float,,);
@@ -314,3 +319,6 @@ CALCIUM_ECR_INTERFACE_C_(edb_fort_,double,cal_int,double,double,,);
 CALCIUM_ECR_INTERFACE_C_(elo_fort_,float ,cal_int,int   ,bool,,);
 CALCIUM_ECR_INTERFACE_C_(ecp_fort_,float ,cal_int,float ,cplx,,);
 CALCIUM_ECR_INTERFACE_C_(ech_fort_,float ,cal_int,char  ,str,STAR,LCH_LAST_PARAM );
+
+CALCIUM_ECR_INTERFACE_C_(eln_fort_,float ,cal_int,long   ,long,,);
+
index 2b6429f8a33441cd7bc2b969d7721d900425d2a0..26943cfdea34e1cc64110ea200bcfe80837cfd2e 100644 (file)
@@ -42,7 +42,7 @@ PySupervCompo::~PySupervCompo()
 }
 
 
-extern "C" 
+extern "C"
 {
   void cp_exit(int);
   void setDependency(provides_port*, char*, CalciumTypes::DependencyType);
@@ -66,6 +66,10 @@ extern "C"
       {
         dynamic_cast<calcium_integer_port_provides *>(port)->setDependencyType(depend);
       }
+    else if(std::string(type)=="CALCIUM_long")
+      {
+        dynamic_cast<calcium_long_port_provides *>(port)->setDependencyType(depend);
+      }
     else if(std::string(type)=="CALCIUM_string")
       {
         dynamic_cast<calcium_string_port_provides *>(port)->setDependencyType(depend);
index f547f3bcedfb270f249455d4bd1609c542635628..bc7a2b55cf0ccbd8bb3e457966919699cf1e9892 100644 (file)
@@ -102,6 +102,50 @@ extern int      cp_len(
 #endif
 );
 
+extern int      cp_llg(
+/*              ------                                          */
+#if CPNeedPrototype
+        void * component /* Pointeur de type Superv_Component_i* sur le */
+                         /* composant SALOME Supervisable  */,
+        int     /* E   Type de dependance ou de lecture         */
+                /*     CP_TEMPS, CP_ITERATION, CP_SEQUENTIEL    */,
+        float * /* E/S Borne inf de l'intervalle de lecture     */
+                /*     Retourne le pas lu dans le cas de        */
+                /*     lecture sequentielle                     */,
+        float * /* E   Borne Sup de l'intervalle de lecture     */,
+        int   * /* E/S Pas d'iteration a lire                   */
+                /*     Retourne le pas lu dans le cas de        */
+                /*     lecture sequentielle                     */,
+        char  * /* E   Nom de la variable a lire                */,
+        int     /* E   Nombre max de valeurs a lire             */,
+        int   * /* S   Nombre de valeurs rellement lues         */,
+        long  * /* S   Tableau d'entiers pour stocker les       */
+                /*     valeurs lues                             */
+#endif
+);
+
+extern int      cp_lln(
+/*              ------                                          */
+#if CPNeedPrototype
+        void * component /* Pointeur de type Superv_Component_i* sur le */
+                         /* composant SALOME Supervisable  */,
+        int     /* E   Type de dependance ou de lecture         */
+                /*     CP_TEMPS, CP_ITERATION, CP_SEQUENTIEL    */,
+        float * /* E/S Borne inf de l'intervalle de lecture     */
+                /*     Retourne le pas lu dans le cas de        */
+                /*     lecture sequentielle                     */,
+        float * /* E   Borne Sup de l'intervalle de lecture     */,
+        int   * /* E/S Pas d'iteration a lire                   */
+                /*     Retourne le pas lu dans le cas de        */
+                /*     lecture sequentielle                     */,
+        char  * /* E   Nom de la variable a lire                */,
+        int     /* E   Nombre max de valeurs a lire             */,
+        int   * /* S   Nombre de valeurs rellement lues         */,
+        long  * /* S   Tableau d'entiers pour stocker les       */
+                /*     valeurs lues                             */
+#endif
+);
+
 extern int      cp_lre(
 /*              ------                                          */
 #if CPNeedPrototype
@@ -395,6 +439,21 @@ extern int      cp_elg(
 #endif
 );
 
+extern int      cp_eln(
+/*              ------                                          */
+#if CPNeedPrototype
+        void * component /* Pointeur de type Superv_Component_i* sur le */
+                         /* composant SALOME Supervisable  */,
+        int     /* E   Type de dependance                       */
+                /*     CP_TEMPS, CP_ITERATION                   */,
+        float   /* E   Pas de temps a ecrire                    */,
+        int     /* E   Pas d'iteration a ecrire                 */,
+        char  * /* E   Nom de la variable a ecrire              */,
+        int     /* E   Nombre de valeurs a ecrire               */,
+        long  * /* E   Tableau d'entiers a ecrire               */
+#endif
+);
+
 extern int      cp_ere(
 /*              ------                                          */
 #if CPNeedPrototype
index b73dba9fa8d2a7b4de45e26af32700c45e5c994a..fedab9d3499a59ee70decade481be59e641349e0 100644 (file)
 #include "CalciumFortranInt.h"
 #include <stdio.h>
 
-static void* COMPO=0;
-
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 
-static void fstrtocstr(char *cstr, char *fstr,cal_int fstr_len) 
+static void fstrtocstr(char *cstr, char *fstr,cal_int fstr_len)
 {
   cal_int i,iend;
-  for (iend = fstr_len-1; iend >= 0; 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,cal_int fstr_len) 
+static void cstrtofstr(char *cstr, char *fstr,cal_int fstr_len)
 {
   cal_int i, len;
   len = strlen(cstr);
@@ -95,6 +93,8 @@ void F_FUNC(cplin,CPLIN)(long *compo,cal_int *dep,float *ti,float *tf,cal_int *i
                          cal_int *max,cal_int *n, int *tab,cal_int *err STR_PLEN(nom));
 void F_FUNC(cpllg,CPLLG)(long *compo,cal_int *dep,float *ti,float *tf,cal_int *iter,STR_PSTR(nom),
             cal_int *max,cal_int *n, long *tab,cal_int *err STR_PLEN(nom));
+void F_FUNC(cplln,CPLLN)(long *compo,cal_int *dep,float *ti,float *tf,cal_int *iter,STR_PSTR(nom),
+            cal_int *max,cal_int *n, long *tab,cal_int *err STR_PLEN(nom));
 void F_FUNC(cplen,CPLEN)(long *compo,cal_int *dep,float *ti,float *tf,cal_int *iter,STR_PSTR(nom),
             cal_int *max,cal_int *n, cal_int *tab,cal_int *err STR_PLEN(nom));
 void F_FUNC(cpllo,CPLLO)(long *compo,cal_int *dep,float *ti,float *tf,cal_int *iter,STR_PSTR(nom),
@@ -115,7 +115,7 @@ void F_FUNC(cplin,CPLIN)(long *compo,cal_int *dep,float *ti,float *tf,cal_int *i
   char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom));
 
 #if   !SIZEOF_INT
-#error "The macro SIZEOF_INT must be defined."    
+#error "The macro SIZEOF_INT must be defined."
 #elif SIZEOF_INT == 4
   *err=cp_lin_fort_((void *)*compo,*dep,ti,tf,iter,cnom,*max,n,tab);
 #else
@@ -130,7 +130,7 @@ void F_FUNC(cpllg,CPLLG)(long *compo,cal_int *dep,float *ti,float *tf,cal_int *i
 {
   char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom));
 #if   !SIZEOF_LONG
-#error "The macro SIZEOF_LONG must be defined."    
+#error "The macro SIZEOF_LONG must be defined."
 #elif SIZEOF_LONG == 8
   *err=cp_llg_fort_((void *)*compo,*dep,ti,tf,iter,cnom,*max,n,tab);
 #else
@@ -140,6 +140,22 @@ void F_FUNC(cpllg,CPLLG)(long *compo,cal_int *dep,float *ti,float *tf,cal_int *i
   free_str1(cnom);
 }
 
+void F_FUNC(cplln,CPLLN)(long *compo,cal_int *dep,float *ti,float *tf,cal_int *iter,STR_PSTR(nom),
+                                    cal_int *max,cal_int *n, long *tab,cal_int *err STR_PLEN(nom))
+{
+ char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom));
+#if   !SIZEOF_LONG
+#error "The macro SIZEOF_LONG must be defined."
+#elif SIZEOF_LONG == 8
+  *err=cp_lln_fort_((void *)*compo,*dep,ti,tf,iter,cnom,*max,n,tab);
+#else
+  fprintf(stderr,"End of CPLLN: %s : Can't use fortran INTEGER*8 because long C is not 64bits long on this machine.\n",
+          cnom);
+#endif
+  free_str1(cnom);
+}
+
+
 void F_FUNC(cplen,CPLEN)(long *compo,cal_int *dep,float *ti,float *tf,cal_int *iter,STR_PSTR(nom),
             cal_int *max,cal_int *n, cal_int *tab,cal_int *err STR_PLEN(nom))
 {
@@ -194,14 +210,22 @@ void F_FUNC(cplch,CPLCH)(long *compo,cal_int *dep,float *ti,float *tf,cal_int *i
 
   *err=cp_lch_fort_((void *)*compo,*dep,ti,tf,iter,cnom,*max,n,tabChaine,STR_LEN(tab));
 
-  for (index = 0; index < *n; index++)
-    strncpy(&tab[index * STR_LEN(tab)], tabChaine[index], strlen(tabChaine[index]));
+  if (*err == CPOK )
+    {
+      for (index = 0; index < *n; index++)
+        {
+          strncpy(&tab[index * STR_LEN(tab)], tabChaine[index], strlen(tabChaine[index]));
+          if(STR_LEN(tab) > strlen(tabChaine[index]))
+            memset(&tab[index * STR_LEN(tab)+strlen(tabChaine[index])],' ',STR_LEN(tab)-strlen(tabChaine[index]));
+        }
+    }
 
-  if (tabChaine != (char **) NULL)  {
-    for (index = 0; index < *n; index++)
-      free(tabChaine[index]);
-    free(tabChaine);
-  }
+  if (tabChaine != (char **) NULL)
+    {
+      for (index = 0; index < *max; index++)
+        free(tabChaine[index]);
+      free(tabChaine);
+    }
   free_str1(cnom);
 }
 
@@ -209,17 +233,18 @@ void F_FUNC(cplch,CPLCH)(long *compo,cal_int *dep,float *ti,float *tf,cal_int *i
 /***************************/
 /*  INTERFACES D'ECRITURE  */
 /***************************/
-void F_FUNC(cpech,CPECH)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, char *tab,cal_int *err 
+void F_FUNC(cpech,CPECH)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, char *tab,cal_int *err
                          STR_PLEN(nom) STR_PLEN(tab));
 void F_FUNC(cpedb,CPEDB)(long *compo,cal_int *dep,double *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, double *tab,cal_int *err STR_PLEN(nom));
 void F_FUNC(cpere,CPERE)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, float *tab,cal_int *err STR_PLEN(nom));
 void F_FUNC(cpecp,CPECP)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, float *tab,cal_int *err STR_PLEN(nom));
 void F_FUNC(cpein,CPEIN)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, int *tab,cal_int *err STR_PLEN(nom));
 void F_FUNC(cpelg,CPELG)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, long *tab,cal_int *err STR_PLEN(nom));
+void F_FUNC(cpeln,CPELN)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, long *tab,cal_int *err STR_PLEN(nom));
 void F_FUNC(cpeen,CPEEN)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, cal_int *tab,cal_int *err STR_PLEN(nom));
 void F_FUNC(cpelo,CPELO)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, int *tab,cal_int *err STR_PLEN(nom));
 
-void F_FUNC(cpech,CPECH)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, char *tab,cal_int *err 
+void F_FUNC(cpech,CPECH)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, char *tab,cal_int *err
                          STR_PLEN(nom) STR_PLEN(tab))
 {
   char ** tabChaine=NULL;
@@ -227,26 +252,26 @@ void F_FUNC(cpech,CPECH)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PS
   char*   cnom=fstr1(STR_PTR(nom),STR_LEN(nom));
 
   tabChaine = (char **) malloc(sizeof(char *) * *n);
-  for (index = 0; index < *n; index++) {
-    
-    tabChaine[index] = (char *) malloc(sizeof(char) * (STR_LEN(tab) + 1));
-    strncpy(tabChaine[index],&tab[STR_LEN(tab) * index],STR_LEN(tab));
-    tabChaine[index][STR_LEN(tab)]='\0';
-    for (index2 = STR_LEN(tab) - 1; index2 >= 0; index2--) {
-      if ( tabChaine[index][index2] == ' '  ||
-           tabChaine[index][index2] == '\0'   )
-        tabChaine[index][index2]='\0';
+  for (index = 0; index < *n; index++)
+    {
+      tabChaine[index] = (char *) malloc(sizeof(char) * (STR_LEN(tab) + 1));
+      strncpy(tabChaine[index],&tab[STR_LEN(tab) * index],STR_LEN(tab));
+      tabChaine[index][STR_LEN(tab)]='\0';
+      for (index2 = STR_LEN(tab) - 1; index2 >= 0; index2--)
+        {
+          if ( tabChaine[index][index2] == ' ' || tabChaine[index][index2] == '\0' )
+            tabChaine[index][index2]='\0';
+        }
     }
-  }
 
   *err=cp_ech_fort_((void *)*compo,*dep,*ti,*iter,cnom,*n,tabChaine,STR_LEN(tab) );
 
-  if (tabChaine != (char **) NULL) {
-    for (index = 0; index < *n; index++)
-      free(tabChaine[index]);
-
-    free(tabChaine);
-  }
+  if (tabChaine != (char **) NULL)
+    {
+      for (index = 0; index < *n; index++)
+        free(tabChaine[index]);
+      free(tabChaine);
+    }
   free_str1(cnom);
 }
 
@@ -277,7 +302,7 @@ void F_FUNC(cpein,CPEIN)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PS
 
   char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom));
 #if   !SIZEOF_INT
-#error "The macro SIZEOF_INT must be defined."    
+#error "The macro SIZEOF_INT must be defined."
 #elif SIZEOF_INT == 4
   *err=cp_ein_fort_((void *)*compo,*dep,*ti,*iter,cnom,*n,tab);
 #else
@@ -292,7 +317,7 @@ void F_FUNC(cpelg,CPELG)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PS
 
   char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom));
 #if   !SIZEOF_LONG
-#error "The macro SIZEOF_LONG must be defined."    
+#error "The macro SIZEOF_LONG must be defined."
 #elif SIZEOF_LONG == 8
   *err=cp_elg_fort_((void *)*compo,*dep,*ti,*iter,cnom,*n,tab);
 #else
@@ -302,6 +327,22 @@ void F_FUNC(cpelg,CPELG)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PS
   free_str1(cnom);
 }
 
+void F_FUNC(cpeln,CPELN)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, long *tab,cal_int *err STR_PLEN(nom))
+{
+
+  char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom));
+#if   !SIZEOF_LONG
+#error "The macro SIZEOF_LONG must be defined."
+#elif SIZEOF_LONG == 8
+  *err=cp_eln_fort_((void *)*compo,*dep,*ti,*iter,cnom,*n,tab);
+#else
+  fprintf(stderr,"CPELN: %s %f %d : Can't use fortran INTEGER*8 because long C is not 64bits long on this machine.\n",
+          cnom, *ti,*iter);
+#endif
+  free_str1(cnom);
+}
+
+
 void F_FUNC(cpeen,CPEEN)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, cal_int *tab,cal_int *err STR_PLEN(nom))
 {
   char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom));
index 61ad82cbae9cb86d099b09eb545fe2cab100d1b5..1fd5bb2484984c5040715c22b6d6ac5db8b4ed8a 100644 (file)
@@ -46,6 +46,7 @@
 
 CALCIUM_ECR_INTERFACE_C_H(een_fort_,float ,cal_int,cal_int,integer,,);
 CALCIUM_ECR_INTERFACE_C_H(elg_fort_,float ,cal_int,long   ,long2integer,,);
+CALCIUM_ECR_INTERFACE_C_H(eln_fort_,float ,cal_int,long   ,long,,);
 CALCIUM_ECR_INTERFACE_C_H(ein_fort_,float ,cal_int,int    ,int2integer,,);
 CALCIUM_ECR_INTERFACE_C_H(ere_fort_,float ,cal_int,float ,float,,);
 CALCIUM_ECR_INTERFACE_C_H(edb_fort_,double,cal_int,double,double,,);
@@ -56,16 +57,18 @@ CALCIUM_ECR_INTERFACE_C_H(ech_fort_,float ,cal_int,char  ,str,STAR,LCH_LAST_PARA
 
 
 #define CALCIUM_LECT_INTERFACE_C_H(_name,_timeType,_calInt,_type,_typeName,_qual,lastarg) \
+  extern void cp_##_name##_free ( _type _qual * data);                  \
   extern _calInt cp_##_name (void * component, _calInt mode,            \
                              _timeType * ti, _timeType * tf, _calInt * i, \
                              char * nomvar, _calInt bufferLength,       \
                              _calInt * nRead, _type _qual * data        \
                              lastarg ) ;                                \
                                                                         \
+
 
 CALCIUM_LECT_INTERFACE_C_H(len_fort_,float ,cal_int,cal_int ,integer,,);
 CALCIUM_LECT_INTERFACE_C_H(llg_fort_,float ,cal_int,long    ,long2integer,,);
+CALCIUM_LECT_INTERFACE_C_H(lln_fort_,float ,cal_int,long    ,long,,);
 CALCIUM_LECT_INTERFACE_C_H(lin_fort_,float ,cal_int,int     ,int2integer,,);
 CALCIUM_LECT_INTERFACE_C_H(lre_fort_,float ,cal_int,float   ,float,,);
 CALCIUM_LECT_INTERFACE_C_H(ldb_fort_,double,cal_int,double  ,double,,);