]> SALOME platform Git repositories - modules/kernel.git/blob - src/DSC/DSC_User/Datastream/Calcium/calciumf.c
Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/kernel.git] / src / DSC / DSC_User / Datastream / Calcium / calciumf.c
1 #include <string.h>
2 #include <stdlib.h>
3 #include <fortoc.h>
4 #include <calcium.h>
5 #include <stdio.h>
6
7 static void* COMPO=0;
8
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12
13 static void fstrtocstr(char *cstr, char *fstr,int fstr_len) 
14 {
15   int i,iend;
16   for (iend = fstr_len-1; iend >= 0; iend--) 
17     if (fstr[iend] != ' ') break;
18   for (i = 0; i <= iend; i++)
19     cstr[i] = fstr[i];
20   cstr[i] = '\0';
21 }
22
23 static void cstrtofstr(char *cstr, char *fstr,int fstr_len) 
24 {
25   int i, len;
26   len = strlen(cstr);
27   if (len > fstr_len) len = fstr_len;
28   for (i = 0; i < len; i++)
29     fstr[i] = cstr[i];
30   while (i < fstr_len)
31     fstr[i++] = ' ';
32 }
33
34 static char * fstr1(char *nom,int nnom)
35 {
36   char * cnom=(char*)malloc((nnom+1)*sizeof(char));
37   fstrtocstr(cnom,nom,nnom);
38   return cnom;
39 }
40
41 static char * free_str1(char *nom)
42 {
43   free(nom);
44 }
45
46 void F_FUNC(cpcd,CPCD)(long *compo,STR_PSTR(nom),int *info STR_PLEN(nom))
47 {
48   /* nom is OUT argument */
49   cp_cd((void *)*compo,STR_PTR(nom));
50   /* replace in place ??? */
51   cstrtofstr(STR_PTR(nom),STR_PTR(nom),STR_LEN(nom));
52 }
53
54 void F_FUNC(cplen,CPLEN)(long *compo,int *dep,float *ti,float *tf,int *iter,STR_PSTR(nom),
55             int *max,int *n, int *tab,int *err STR_PLEN(nom))
56 {
57   char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom));
58   fprintf(stderr,"CPLEN: %s %f %f\n",cnom,*ti,*tf);
59   *err=cp_len((void *)*compo,*dep,ti,tf,iter,cnom,*max,n,tab);
60   fprintf(stderr,"End of CPLEN: %s \n",cnom);
61   free_str1(cnom);
62 }
63
64 void F_FUNC(cpllo,CPLLO)(long *compo,int *dep,float *ti,float *tf,int *iter,STR_PSTR(nom),
65             int *max,int *n, int *tab,int *err STR_PLEN(nom))
66 {
67   char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom));
68   fprintf(stderr,"CPLLO: %s %f %f\n",cnom,*ti,*tf);
69   *err=cp_llo((void *)*compo,*dep,ti,tf,iter,cnom,*max,n,tab);
70   fprintf(stderr,"End of CPLLO: %s \n",cnom);
71   free_str1(cnom);
72 }
73
74 void F_FUNC(cpldb,CPLDB)(long *compo,int *dep,double *ti,double *tf,int *iter,STR_PSTR(nom),
75             int *max,int *n, double *tab,int *err STR_PLEN(nom))
76 {
77   char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom));
78   fprintf(stderr,"CPLDB: %s %f %f \n",cnom, *ti,*tf);
79   *err=cp_ldb((void *)*compo,*dep,ti,tf,iter,cnom,*max,n,tab);
80   fprintf(stderr,"End of CPLDB: %s %f %f \n",cnom,*ti,*tf);
81   free_str1(cnom);
82 }
83
84 void F_FUNC(cplre,CPLRE)(long *compo,int *dep,float *ti,float *tf,int *iter,STR_PSTR(nom),
85             int *max,int *n, float *tab,int *err STR_PLEN(nom))
86 {
87   char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom));
88   fprintf(stderr,"CPLRE: %s %f %f \n",cnom, *ti,*tf);
89   *err=cp_lre((void *)*compo,*dep,ti,tf,iter,cnom,*max,n,tab);
90   fprintf(stderr,"End of CPLRE: %s %f %f \n",cnom,*ti,*tf);
91   free_str1(cnom);
92 }
93
94 void F_FUNC(cplcp,CPLCP)(long *compo,int *dep,float *ti,float *tf,int *iter,STR_PSTR(nom),
95             int *max,int *n, float *tab,int *err STR_PLEN(nom))
96 {
97   char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom));
98   fprintf(stderr,"CPLCP: %s %f %f \n",cnom, *ti,*tf);
99   *err=cp_lcp((void *)*compo,*dep,ti,tf,iter,cnom,*max,n,tab);
100   fprintf(stderr,"End of CPLCP: %s %f %f \n",cnom,*ti,*tf);
101   free_str1(cnom);
102 }
103
104 void F_FUNC(cplch,CPLCH)(long *compo,int *dep,float *ti,float *tf,int *iter,STR_PSTR(nom),
105             int *max,int *n, char *tab,int *err STR_PLEN(nom) STR_PLEN(tab) )
106 {
107   char **tabChaine=NULL;
108   int    index=0;
109   char*  cnom=fstr1(STR_PTR(nom),STR_LEN(nom));
110   fprintf(stderr,"CPLCH: %s %f %f \n",cnom, *ti,*tf);
111
112   tabChaine = (char **) malloc(sizeof(char *) * (*max));
113   for (index = 0; index < *max; index++)
114     tabChaine[index] = (char *) malloc(sizeof(char) * (STR_LEN(tab)+1));
115
116   *err=cp_lch((void *)*compo,*dep,ti,tf,iter,cnom,*max,n,tabChaine,STR_LEN(tab));
117
118   for (index = 0; index < *n; index++)
119     strcpy(&tab[index * STR_LEN(tab)], tabChaine[index]);
120
121   fprintf(stderr,"End of CPLCH: %s %f %f \n",cnom,*ti,*tf);
122   if (tabChaine != (char **) NULL)  {
123     for (index = 0; index < *n; index++)
124       free(tabChaine[index]);
125     free(tabChaine);
126   }
127   free_str1(cnom);
128 }
129
130 void F_FUNC(cpech,CPECH)(long *compo,int *dep,float *ti,int *iter,STR_PSTR(nom),int *n, char *tab,int *err 
131                          STR_PLEN(nom) STR_PLEN(tab))
132 {
133   char ** tabChaine=NULL;
134   int     index=0,index2=0;
135   char*   cnom=fstr1(STR_PTR(nom),STR_LEN(nom));
136   fprintf(stderr,"CPECH: %s %f \n",cnom, *ti);
137
138   tabChaine = (char **) malloc(sizeof(char *) * *n);
139   for (index = 0; index < *n; index++) {
140     
141     tabChaine[index] = (char *) malloc(sizeof(char) * (STR_LEN(tab) + 1));
142     strncpy(tabChaine[index],&tab[STR_LEN(tab) * index],STR_LEN(tab));
143     tabChaine[index][STR_LEN(tab)]='\0';
144     for (index2 = STR_LEN(tab) - 1; index2 >= 0; index2--) {
145       if ( tabChaine[index][index2] == ' '  ||
146            tabChaine[index][index2] == '\0'   )
147         tabChaine[index][index2]='\0';
148     }
149   }
150
151   *err=cp_ech((void *)*compo,*dep,*ti,*iter,cnom,*n,tabChaine,STR_LEN(tab) );
152
153   fprintf(stderr,"End of CPECH: %s %f \n",cnom, *ti);
154   if (tabChaine != (char **) NULL) {
155     for (index = 0; index < *n; index++)
156       free(tabChaine[index]);
157
158     free(tabChaine);
159   }
160   free_str1(cnom);
161 }
162
163 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))
164 {
165   char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom));
166   fprintf(stderr,"CPEDB: %s %f \n",cnom, *ti);
167   *err=cp_edb((void *)*compo,*dep,*ti,*iter,cnom,*n,tab);
168   fprintf(stderr,"End of CPEDB: %s %f \n",cnom, *ti);
169   free_str1(cnom);
170 }
171
172 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))
173 {
174   char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom));
175   fprintf(stderr,"CPERE: %s %f \n",cnom, *ti);
176   *err=cp_ere((void *)*compo,*dep,*ti,*iter,cnom,*n,tab);
177   fprintf(stderr,"End of CPERE: %s %f \n",cnom, *ti);
178   free_str1(cnom);
179 }
180
181 void F_FUNC(cpecp,CPECP)(long *compo,int *dep,float *ti,int *iter,STR_PSTR(nom),int *n, float *tab,int *err STR_PLEN(nom))
182 {
183   char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom));
184   fprintf(stderr,"CPECP: %s %f \n",cnom, *ti);
185   *err=cp_ecp((void *)*compo,*dep,*ti,*iter,cnom,*n,tab);
186   fprintf(stderr,"End of CPECP: %s %f \n",cnom, *ti);
187   free_str1(cnom);
188 }
189
190 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))
191 {
192   char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom));
193   fprintf(stderr,"CPEEN: %s %f %d\n",cnom, *ti,*iter);
194   *err=cp_een((void *)*compo,*dep,*ti,*iter,cnom,*n,tab);
195   fprintf(stderr,"End of CPEEN: %s %f \n",cnom,*ti);
196   free_str1(cnom);
197 }
198
199 void F_FUNC(cpelo,CPELO)(long *compo,int *dep,float *ti,int *iter,STR_PSTR(nom),int *n, int *tab,int *err STR_PLEN(nom))
200 {
201   char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom));
202   fprintf(stderr,"CPELO: %s %f %d\n",cnom, *ti,*iter);
203   *err=cp_elo((void *)*compo,*dep,*ti,*iter,cnom,*n,tab);
204   fprintf(stderr,"End of CPELO: %s %f \n",cnom,*ti);
205   free_str1(cnom);
206 }
207
208 void F_FUNC(cpfin,CPFIN)(long *compo,int *dep,int *err)
209 {
210   fprintf(stderr,"CPFIN: \n");
211   *err=cp_fin((void *)*compo,*dep);
212 }
213
214 #ifdef __cplusplus
215 }
216 #endif
217