3 * Copyright (C) INRIA -
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * See the file ./license.txt
21 /*--------------------------------------------------------------------------*/
27 #include "scicos_internal.h"
29 /*--------------------------------------------------------------------------*/
30 ScicosImport scicos_imp =
32 (double *) NULL, /* x ** */
33 (int *) NULL, /* nx */
34 (int *) NULL, /* xptr ** */
35 (int *) NULL, /* zcptr ** */
36 (double *) NULL, /* z ** */
37 (int *) NULL, /* nz */
38 (int *) NULL, /* zptr ** */
39 (int *) NULL, /* noz */
40 (void **) NULL, /* oz */
41 (int *) NULL, /* ozsz */
42 (int *) NULL, /* oztyp */
43 (int *) NULL, /* ozptr */
44 (double *) NULL, /* g */
45 (int *) NULL, /* ng */
46 (int *) NULL, /* mod */
47 (int *) NULL, /* nmod */
48 (int *) NULL, /* modptr ** */
49 (int *) NULL, /* iz */
50 (int *) NULL, /* izptr */
51 (int *) NULL, /* uid */
52 (int *) NULL, /* uidptr */
53 (int *) NULL, /* inpptr ** */
54 (int *) NULL, /* inplnk ** */
55 (int *) NULL, /* outptr ** */
56 (int *) NULL, /* outlnk ** */
57 (double *) NULL, /* rpar ** */
58 (int *) NULL, /* rpptr ** */
59 (int *) NULL, /* ipar ** */
60 (int *) NULL, /* ipptr ** */
61 (void **) NULL, /* opar */
62 (int *) NULL, /* oparsz */
63 (int *) NULL, /* opartyp */
64 (int *) NULL, /* opptr */
65 (int *) NULL, /* nblk */
66 (void **) NULL, /* outtbptr */
67 (int *) NULL, /* outtbsz */
68 (int *) NULL, /* outtbtyp */
69 (int *) NULL, /* nlnk */
70 (int *) NULL, /* subs ** */
71 (int *) NULL, /* nsubs */
72 (double *) NULL, /* tevts ** */
73 (int *) NULL, /* evtspt ** */
74 (int *) NULL, /* nevts */
75 (int *) NULL, /* pointi ** */
76 (int *) NULL, /* iord ** */
77 (int *) NULL, /* niord */
78 (int *) NULL, /* oord ** */
79 (int *) NULL, /* noord */
80 (int *) NULL, /* zord ** */
81 (int *) NULL, /* nzord */
82 (int *) NULL, /* funptr */
83 (int *) NULL, /* funtyp ** */
84 (int *) NULL, /* ztyp ** */
85 (int *) NULL, /* cord ** */
86 (int *) NULL, /* ncord */
87 (int *) NULL, /* ordclk ** */
88 (int *) NULL, /* nordclk ** */
89 (int *) NULL, /* clkptr ** */
90 (int *) NULL, /* ordptr ** */
91 (int *) NULL, /* nordptr */
92 (int *) NULL, /* critev ** */
93 (int *) NULL, /* iwa */
94 (int *) NULL, /* mask */
95 (scicos_block *) NULL, /* blocks */
96 (double *) NULL, /* t0 */
97 (double *) NULL, /* tf */
98 (double *) NULL, /* Atol */
99 (double *) NULL, /* rtol */
100 (double *) NULL, /* ttol */
101 (double *) NULL, /* deltat */
102 (double *) NULL, /* hmax */
103 (outtb_el *) NULL, /* outtb_elem */
104 (int *) NULL, /* nelem */
105 (int *) NULL, /* xprop */
106 (double *) NULL, /* xd */
109 /*--------------------------------------------------------------------------*/
110 /* getscicosimportptr returns a pointer
111 * to the imported structure
113 ScicosImport* getscicosimportptr(void)
117 /*--------------------------------------------------------------------------*/
118 void makescicosimport(double *x, int *nx,
119 int *xptr, int *zcptr,
120 double *z, int *nz, int *zptr,
121 int *noz, void **oz, int *ozsz, int *oztyp, int *ozptr,
123 int *mod, int *nmod, int *modptr,
124 int *iz, int *izptr, int *uid, int *uidptr, int *inpptr, int *inplnk,
125 int *outptr, int *outlnk, void **outtbptr, int *outtbsz, int *outtbtyp,
126 outtb_el *outtb_elem, int *nelem,
127 int *nlnk, double *rpar, int *rpptr, int *ipar, int *ipptr,
128 void **opar, int *oparsz, int *opartyp, int *opptr,
129 int *nblk, int *subs, int *nsubs,
130 double *tevts, int *evtspt, int *nevts, int *pointi,
131 int *iord, int *niord, int *oord, int *noord, int *zord, int *nzord,
132 int *funptr, int *funtyp, int *ztyp,
133 int *cord, int *ncord, int *ordclk, int *nordclk, int *clkptr,
134 int *ordptr, int *nordptr, int *critev, int *iwa, scicos_block *blocks,
135 double *t0, double *tf, double *Atol, double *rtol, double *ttol, double *deltat, double *hmax,
136 int *xprop, double *xd)
140 scicos_imp.xptr = xptr;
141 scicos_imp.zcptr = zcptr;
144 scicos_imp.zptr = zptr;
146 scicos_imp.noz = noz;
148 scicos_imp.ozsz = ozsz;
149 scicos_imp.oztyp = oztyp;
150 scicos_imp.ozptr = ozptr;
154 scicos_imp.mod = mod;
155 scicos_imp.nmod = nmod;
156 scicos_imp.modptr = modptr;
158 scicos_imp.izptr = izptr;
159 scicos_imp.uid = uid;
160 scicos_imp.uidptr = uidptr;
162 scicos_imp.inpptr = inpptr;
163 scicos_imp.inplnk = inplnk;
164 scicos_imp.outptr = outptr;
165 scicos_imp.outlnk = outlnk;
167 scicos_imp.rpar = rpar;
168 scicos_imp.rpptr = rpptr;
169 scicos_imp.ipar = ipar;
170 scicos_imp.ipptr = ipptr;
172 scicos_imp.opar = opar;
173 scicos_imp.oparsz = oparsz;
174 scicos_imp.opartyp = opartyp;
175 scicos_imp.opptr = opptr;
177 scicos_imp.nblk = nblk;
178 scicos_imp.outtbptr = outtbptr;
179 scicos_imp.outtbsz = outtbsz;
180 scicos_imp.outtbtyp = outtbtyp;
181 scicos_imp.outtb_elem = outtb_elem;
182 scicos_imp.nelem = nelem;
183 scicos_imp.nlnk = nlnk;
185 scicos_imp.subs = subs;
186 scicos_imp.nsubs = nsubs;
188 scicos_imp.tevts = tevts;
189 scicos_imp.evtspt = evtspt;
190 scicos_imp.nevts = nevts;
191 scicos_imp.pointi = pointi;
193 scicos_imp.iord = iord;
194 scicos_imp.niord = niord;
195 scicos_imp.oord = oord;
196 scicos_imp.noord = noord;
197 scicos_imp.zord = zord;
198 scicos_imp.nzord = nzord;
200 scicos_imp.funptr = funptr;
201 scicos_imp.funtyp = funtyp;
203 scicos_imp.ztyp = ztyp;
204 scicos_imp.cord = cord;
205 scicos_imp.ncord = ncord;
206 scicos_imp.ordclk = ordclk;
207 scicos_imp.nordclk = nordclk;
208 scicos_imp.clkptr = clkptr;
209 scicos_imp.ordptr = ordptr;
210 scicos_imp.nordptr = nordptr;
211 scicos_imp.critev = critev;
212 scicos_imp.iwa = iwa;
213 scicos_imp.blocks = blocks;
217 scicos_imp.Atol = Atol;
218 scicos_imp.ttol = ttol;
219 scicos_imp.rtol = rtol;
220 scicos_imp.deltat = deltat;
221 scicos_imp.hmax = hmax;
223 scicos_imp.xprop = xprop;
226 /*--------------------------------------------------------------------------*/
227 void C2F(clearscicosimport)()
229 scicos_imp.x = (double *) NULL;
230 scicos_imp.nx = (int *) NULL;
231 scicos_imp.xptr = (int *) NULL;
232 scicos_imp.zcptr = (int *) NULL;
233 scicos_imp.z = (double *) NULL;
234 scicos_imp.nz = (int *) NULL;
235 scicos_imp.zptr = (int *) NULL;
237 scicos_imp.noz = (int *) NULL;
238 scicos_imp.oz = (void **) NULL;
239 scicos_imp.ozsz = (int *) NULL;
240 scicos_imp.oztyp = (int *) NULL;
241 scicos_imp.ozptr = (int *) NULL;
243 scicos_imp.g = (double *) NULL;
244 scicos_imp.ng = (int *) NULL;
245 scicos_imp.mod = (int *) NULL;
246 scicos_imp.nmod = (int *) NULL;
247 scicos_imp.modptr = (int *) NULL;
248 scicos_imp.iz = (int *) NULL;
249 scicos_imp.izptr = (int *) NULL;
250 scicos_imp.uid = (int *) NULL;
251 scicos_imp.uidptr = (int *) NULL;
253 scicos_imp.inpptr = (int *) NULL;
254 scicos_imp.inplnk = (int *) NULL;
255 scicos_imp.outptr = (int *) NULL;
256 scicos_imp.outlnk = (int *) NULL;
258 scicos_imp.rpar = (double *) NULL;
259 scicos_imp.rpptr = (int *) NULL;
260 scicos_imp.ipar = (int *) NULL;
261 scicos_imp.ipptr = (int *) NULL;
263 scicos_imp.opar = (void **) NULL;
264 scicos_imp.oparsz = (int *) NULL;
265 scicos_imp.opartyp = (int *) NULL;
266 scicos_imp.opptr = (int *) NULL;
268 scicos_imp.nblk = (int *) NULL;
269 scicos_imp.outtbptr = (void **) NULL;
270 scicos_imp.outtbsz = (int *) NULL;
271 scicos_imp.outtbtyp = (int *) NULL;
272 scicos_imp.outtb_elem = (outtb_el *) NULL;
273 scicos_imp.nelem = (int *) NULL;
274 scicos_imp.nlnk = (int *) NULL;
276 scicos_imp.subs = (int *) NULL;
277 scicos_imp.nsubs = (int *) NULL;
278 scicos_imp.tevts = (double *) NULL;
279 scicos_imp.evtspt = (int *) NULL;
280 scicos_imp.nevts = (int *) NULL;
281 scicos_imp.pointi = (int *) NULL;
283 scicos_imp.iord = (int *) NULL;
284 scicos_imp.niord = (int *) NULL;
285 scicos_imp.oord = (int *) NULL;
286 scicos_imp.noord = (int *) NULL;
287 scicos_imp.zord = (int *) NULL;
288 scicos_imp.nzord = (int *) NULL;
290 scicos_imp.funptr = (int *) NULL;
291 scicos_imp.funtyp = (int *) NULL;
293 scicos_imp.ztyp = (int *) NULL;
294 scicos_imp.cord = (int *) NULL;
295 scicos_imp.ncord = (int *) NULL;
296 scicos_imp.ordclk = (int *) NULL;
297 scicos_imp.nordclk = (int *) NULL;
298 scicos_imp.clkptr = (int *) NULL;
299 scicos_imp.ordptr = (int *) NULL;
300 scicos_imp.nordptr = (int *) NULL;
301 scicos_imp.critev = (int *) NULL;
303 scicos_imp.iwa = (int *) NULL;
304 scicos_imp.mask = (int *) NULL;
305 scicos_imp.blocks = (scicos_block *) NULL;
307 scicos_imp.t0 = (double *) NULL;
308 scicos_imp.tf = (double *) NULL;
309 scicos_imp.Atol = (double *) NULL;
310 scicos_imp.ttol = (double *) NULL;
311 scicos_imp.rtol = (double *) NULL;
312 scicos_imp.deltat = (double *) NULL;
313 scicos_imp.hmax = (double *) NULL;
315 scicos_imp.xprop = (int *) NULL;
316 scicos_imp.xd = (double *) NULL;
318 /*--------------------------------------------------------------------------*/
319 /* 20/06/06, Alan : review
320 * 08/02/07, Alan : update
323 int getscicosvarsfromimport(char *what, void **v, int *nv, int *mv)
324 /*char *what; data structure selection -see import.h for definition-*/
325 /*void **v; Pointer to the beginning of the imported data */
326 /*int *nv; size 1 of the imported data */
327 /*int *mv; size 1 of the imported data */
329 /*variable declaration*/
330 int nx, nz, noz, nmod, nblk, nlnk, nsubs, nevts, ng;
331 int niord, noord, ncord, nordptr, nzord, nelem;
333 /*test if scicosim is running*/
334 if (scicos_imp.x == (double *)NULL)
337 return 0; /* undefined import table scicos is not running */
340 /* retrieve length of x register */
341 nx = (int) scicos_imp.nx[0];
342 /* retrieve length of z register */
343 nz = (int) scicos_imp.nz[0];
344 /* retrieve length of oz register */
345 noz = (int) scicos_imp.noz[0];
346 /* retrieve number of block */
347 nmod = (int) scicos_imp.nmod[0];
348 /* retrieve number of block */
349 nblk = (int) scicos_imp.nblk[0];
350 /* retrieve number of link */
351 nlnk = (int) scicos_imp.nlnk[0];
352 /* retrieve number nsubs */
353 nsubs = (int) scicos_imp.nsubs[0];
354 /* retrieve number nevts */
355 nevts = (int) scicos_imp.nevts[0];
356 /* retrieve number niord */
357 niord = (int) scicos_imp.niord[0];
358 /* retrieve number noord */
359 noord = (int) scicos_imp.noord[0];
360 /* retrieve number ncord */
361 ncord = (int) scicos_imp.ncord[0];
362 /* retrieve number nordptr */
363 nordptr = (int) scicos_imp.nordptr[0];
364 /* retrieve number nzord */
365 nzord = (int) scicos_imp.nzord[0];
366 /* retrieve number ng */
367 ng = (int) scicos_imp.ng[0];
368 /* retrieve number nelem */
369 nelem = (int) scicos_imp.nelem[0];
372 if (strcmp(what, "x") == 0)
374 /* x - continuous state */
375 *nv = (int) (scicos_imp.xptr[nblk] - scicos_imp.xptr[0]);
377 *v = (double *)(scicos_imp.x);
379 else if (strcmp(what, "nx") == 0)
381 /* length of x register */
384 *v = (int *) (scicos_imp.nx);
386 else if (strcmp(what, "xptr") == 0)
388 /* xptr - continuous state splitting array */
391 *v = (int *) (scicos_imp.xptr);
393 else if (strcmp(what, "zcptr") == 0)
395 /* zcptr - zero crossing splitting array */
398 *v = (int *) (scicos_imp.zcptr);
400 else if (strcmp(what, "z") == 0)
402 /* z - discrete state */
403 *nv = (int)(scicos_imp.zptr[nblk] - scicos_imp.zptr[0]);
405 *v = (double *) (scicos_imp.z);
407 else if (strcmp(what, "nz") == 0)
409 /* length of z register */
412 *v = (int *) (scicos_imp.nz);
414 else if (strcmp(what, "noz") == 0)
416 /* length of oz register */
419 *v = (int *) (scicos_imp.noz);
421 else if (strcmp(what, "oz") == 0)
423 /* oz - vector of ptr of object discrete states */
424 *nv = (int)(scicos_imp.ozptr[nblk] - scicos_imp.ozptr[0]);
426 *v = (int *) (scicos_imp.oz);
428 else if (strcmp(what, "ozptr") == 0)
430 /* ozptr - object discrete states splitting array */
433 *v = (int *) (scicos_imp.ozptr);
435 else if (strcmp(what, "ozsz") == 0)
437 /* oparsz - object discrete states size array */
438 *nv = (int)(scicos_imp.ozptr[nblk] - scicos_imp.ozptr[0]);
440 *v = (int *) (scicos_imp.ozsz);
442 else if (strcmp(what, "oztyp") == 0)
444 /* opartyp - object discrete states type array */
445 *nv = (int)(scicos_imp.ozptr[nblk] - scicos_imp.ozptr[0]);
447 *v = (int *) (scicos_imp.oztyp);
449 else if (strcmp(what, "zptr") == 0)
451 /* zptr - discrete state splitting array */
454 *v = (int *) (scicos_imp.zptr);
456 else if (strcmp(what, "mod") == 0)
458 /* modes - block discontinuities array */
459 *nv = (int)(scicos_imp.modptr[nblk] - scicos_imp.modptr[0]);
461 *v = (int *) (scicos_imp.mod);
463 else if (strcmp(what, "nmod") == 0)
465 /* nmodes - number of block discontinuities array */
468 *v = (int *) (scicos_imp.nmod);
470 else if (strcmp(what, "modptr") == 0)
472 /* modptr - block discontinuities splitting array */
475 *v = (int *) (scicos_imp.modptr);
477 else if (strcmp(what, "iz") == 0)
479 /* iz - label integer code of blocks array */
480 *nv = (int)(scicos_imp.izptr[nblk] - scicos_imp.izptr[0]);
482 *v = (int *) (scicos_imp.iz);
484 else if (strcmp(what, "izptr") == 0)
486 /* izptr - label integer code of blocks splitting array */
489 *v = (int *) (scicos_imp.izptr);
491 else if (strcmp(what, "uid") == 0)
494 *nv = (int)(scicos_imp.uidptr[nblk] - scicos_imp.uidptr[0]);
496 *v = (int *) (scicos_imp.uid);
498 else if (strcmp(what, "uidptr") == 0)
503 *v = (int *) (scicos_imp.uidptr);
505 else if (strcmp(what, "inpptr") == 0)
510 *v = (int *) (scicos_imp.inpptr);
512 else if (strcmp(what, "inplnk") == 0)
515 *nv = (int)(scicos_imp.inpptr[nblk] - scicos_imp.inpptr[0]);
517 *v = (int *) (scicos_imp.inplnk);
519 else if (strcmp(what, "outptr") == 0)
524 *v = (int *) (scicos_imp.outptr);
526 else if (strcmp(what, "outlnk") == 0)
529 *nv = (int)(scicos_imp.outptr[nblk] - scicos_imp.outptr[0]);
531 *v = (int *) (scicos_imp.outlnk);
533 else if (strcmp(what, "rpar") == 0)
535 /* rpar - vector of real parameters */
536 *nv = (int)(scicos_imp.rpptr[nblk] - scicos_imp.rpptr[0]);
538 *v = (double *) (scicos_imp.rpar);
540 else if (strcmp(what, "rpptr") == 0)
542 /* rpptr - real parameters splitting array */
545 *v = (int *) (scicos_imp.rpptr);
547 else if (strcmp(what, "ipar") == 0)
549 /* ipar - vector of integer parameters */
550 *nv = (int)(scicos_imp.ipptr[nblk] - scicos_imp.ipptr[0]);
552 *v = (int *) (scicos_imp.ipar);
554 else if (strcmp(what, "ipptr") == 0)
556 /* ipptr - integer parameters splitting array */
559 *v = (int *) (scicos_imp.ipptr);
561 else if (strcmp(what, "opar") == 0)
563 /* opar - vector of ptr of objects parameters */
564 *nv = (int)(scicos_imp.opptr[nblk] - scicos_imp.opptr[0]);
566 *v = (int *) (scicos_imp.opar);
568 else if (strcmp(what, "opptr") == 0)
570 /* opptr - object parameters splitting array */
573 *v = (int *) (scicos_imp.opptr);
575 else if (strcmp(what, "oparsz") == 0)
577 /* oparsz - object parameters size array */
578 *nv = (int)(scicos_imp.opptr[nblk] - scicos_imp.opptr[0]);
580 *v = (int *) (scicos_imp.oparsz);
582 else if (strcmp(what, "opartyp") == 0)
584 /* opartyp - object parameters type array */
585 *nv = (int)(scicos_imp.opptr[nblk] - scicos_imp.opptr[0]);
587 *v = (int *) (scicos_imp.opartyp);
589 else if (strcmp(what, "nblk") == 0)
591 /* number of block */
594 *v = (int *) (scicos_imp.nblk);
596 else if (strcmp(what, "outtbptr") == 0)
598 /* ptr on output register */
601 *v = (int *) (scicos_imp.outtbptr);
603 else if (strcmp(what, "outtbsz") == 0)
605 /* size of output register */
608 *v = (int *) (scicos_imp.outtbsz);
610 else if (strcmp(what, "outtbtyp") == 0)
612 /* type of output register */
615 *v = (int *) (scicos_imp.outtbtyp);
617 else if (strcmp(what, "nlnk") == 0)
622 *v = (int *) (scicos_imp.nlnk);
624 else if (strcmp(what, "subs") == 0) /* Aquoisertsubs?? */
629 *v = (int *) (scicos_imp.subs);
631 else if (strcmp(what, "nsubs") == 0)
636 *v = (int *) (scicos_imp.nsubs);
638 else if (strcmp(what, "tevts") == 0)
643 *v = (double *) (scicos_imp.tevts);
645 else if (strcmp(what, "evtspt") == 0)
650 *v = (int *) (scicos_imp.evtspt);
652 else if (strcmp(what, "nevts") == 0)
657 *v = (int *) (scicos_imp.nevts);
659 else if (strcmp(what, "pointi") == 0)
664 *v = (int *) (scicos_imp.pointi);
666 else if (strcmp(what, "iord") == 0)
671 *v = (int *) (scicos_imp.iord);
673 else if (strcmp(what, "niord") == 0)
678 *v = (int *) (scicos_imp.niord);
680 else if (strcmp(what, "oord") == 0)
685 *v = (int *) (scicos_imp.oord);
687 else if (strcmp(what, "noord") == 0)
692 *v = (int *) (scicos_imp.noord);
694 else if (strcmp(what, "zord") == 0)
699 *v = (int *) (scicos_imp.zord);
701 else if (strcmp(what, "nzord") == 0)
706 *v = (int *) (scicos_imp.nzord);
708 else if (strcmp(what, "funptr") == 0)
713 *v = (int *) (scicos_imp.funptr);
715 else if (strcmp(what, "funtyp") == 0)
720 *v = (int *) (scicos_imp.funtyp);
722 else if (strcmp(what, "ztyp") == 0)
727 *v = (int *) (scicos_imp.ztyp);
729 else if (strcmp(what, "cord") == 0)
734 *v = (int *) (scicos_imp.cord);
736 else if (strcmp(what, "ncord") == 0)
741 *v = (int *) (scicos_imp.ncord);
743 else if (strcmp(what, "ordclk") == 0)
746 *nv = (int)(scicos_imp.ordptr[nordptr] - 1);
748 *v = (int *) (scicos_imp.ordclk);
750 else if (strcmp(what, "clkptr") == 0)
753 *nv = (int)(nblk + 1);
755 *v = (int *) (scicos_imp.clkptr);
757 else if (strcmp(what, "ordptr") == 0)
762 *v = (int *) (scicos_imp.ordptr);
764 else if (strcmp(what, "nordptr") == 0)
769 *v = (int *) (scicos_imp.nordptr);
771 else if (strcmp(what, "critev") == 0)
774 *nv = (int)(scicos_imp.clkptr[nblk] - 1); /* !! a faire verifier !! */
776 *v = (int *) (scicos_imp.critev);
778 else if (strcmp(what, "iwa") == 0)
781 *nv = nevts; /* !! a faire verifier !! */
783 *v = (int *) (scicos_imp.iwa);
785 else if (strcmp(what, "blocks") == 0)
790 *v = (scicos_block *) (scicos_imp.blocks);
792 else if (strcmp(what, "ng") == 0)
797 *v = (int *) (scicos_imp.ng);
799 else if (strcmp(what, "g") == 0)
804 *v = (double *) (scicos_imp.g);
806 else if (strcmp(what, "t0") == 0)
811 *v = (double *) (scicos_imp.t0);
813 else if (strcmp(what, "tf") == 0)
818 *v = (double *) (scicos_imp.tf);
820 else if (strcmp(what, "Atol") == 0)
825 *v = (double *) (scicos_imp.Atol);
827 else if (strcmp(what, "rtol") == 0)
832 *v = (double *) (scicos_imp.rtol);
834 else if (strcmp(what, "ttol") == 0)
839 *v = (double *) (scicos_imp.ttol);
841 else if (strcmp(what, "deltat") == 0)
846 *v = (double *) (scicos_imp.deltat);
848 else if (strcmp(what, "hmax") == 0)
853 *v = (double *) (scicos_imp.hmax);
855 else if (strcmp(what, "nelem") == 0)
860 *v = (int*) (scicos_imp.nelem);
862 else if (strcmp(what, "outtb_elem") == 0)
867 *v = (outtb_el *) (scicos_imp.outtb_elem);
869 else /*return FALSE_*/
877 /*--------------------------------------------------------------------------*/
878 /* Used in some scicos block */
879 void C2F(getlabel)(int *kfun, char *label, int *n)
880 /*int *n, *kfun; length of the label as input n gives the max length expected*/
886 if (*n > (int)(scicos_imp.izptr[k] - scicos_imp.izptr[k - 1]))
888 *n = (int)(scicos_imp.izptr[k] - scicos_imp.izptr[k - 1]);
892 F2C(cvstr)(n, &(scicos_imp.iz[scicos_imp.izptr[k - 1] - 1]), label, &job, *n);
896 /*never used, never interfaced */
897 void C2F(getblockbylabel)(int *kfun, char **label, int *n)
899 int k, i, i0, nblk, n1;
903 nblk = scicos_imp.nblk[0];
904 F2C(cvstr)(n, lab, *label, &job, *n);
907 for (k = 0; k < nblk; k++)
909 n1 = (int)(scicos_imp.izptr[k] - scicos_imp.izptr[k - 1]);
912 i0 = scicos_imp.izptr[k - 1] - 1;
914 while ((lab[i] == scicos_imp.iz[i0 + i]) & (i < n1))
926 /*--------------------------------------------------------------------------*/
927 /*never used, never interfaced */
928 int C2F(getsciblockbylabel)(int*kfun, int label[], int *n)
930 int k, i, i0, nblk, n1;
931 if (scicos_imp.x == (double *)NULL)
933 return (2); /* undefined import table scicos is not running */
935 nblk = scicos_imp.nblk[0];
938 for (k = 0; k < nblk; k++)
940 n1 = (int)(scicos_imp.izptr[k] - scicos_imp.izptr[k - 1]);
943 i0 = scicos_imp.izptr[k - 1] - 1;
945 while ((label[i] == scicos_imp.iz[i0 + i]) & (i < n1))
958 /*--------------------------------------------------------------------------*/
959 int C2F(getscilabel)(int *kfun, int label[], int *n)
964 if (scicos_imp.x == (double *)NULL)
966 return (2); /* undefined import table scicos is not running */
969 *n = (int)(scicos_imp.izptr[k] - scicos_imp.izptr[k - 1]);
972 u = (int *) & (scicos_imp.iz[scicos_imp.izptr[k - 1] - 1]);
974 for (i = 0; i < *n; i++)
981 /*--------------------------------------------------------------------------*/
982 int C2F(getcurblock)()
984 return (C2F(curblk).kfun);
986 /*--------------------------------------------------------------------------*/
989 * 30/06/06, Alan : Rewritte to preserve compatibility with fscope.f.
990 * Only first element of matrix is delivred and converted to double data.
993 void C2F(getouttb)(int *nsize, int *nvec, double *outtc)
995 /* declaration of ptr for typed port */
996 void **outtbptr; /*to store outtbptr*/
997 SCSREAL_COP *outtbdptr; /*to store double of outtb*/
998 SCSINT8_COP *outtbcptr; /*to store int8 of outtb*/
999 SCSINT16_COP *outtbsptr; /*to store int16 of outtb*/
1000 SCSINT32_COP *outtblptr; /*to store int32 of outtb*/
1001 SCSUINT8_COP *outtbucptr; /*to store unsigned int8 of outtb */
1002 SCSUINT16_COP *outtbusptr; /*to store unsigned int16 of outtb */
1003 SCSUINT32_COP *outtbulptr; /*to store unsigned int32 of outtb */
1004 int *outtb_nelem; /*to store maximum number of element*/
1005 int outtbtyp; /*to store type of data*/
1006 int *outtbsz; /*to store size of data*/
1007 outtb_el *outtb_elem; /*to store ptr of outtb_elem structure */
1009 /*auxiliary variable*/
1010 int j, sz, lnk, pos;
1012 /*get outtbptr from import struct.*/
1013 outtbptr = scicos_imp.outtbptr;
1014 /*get outtb_elem from import struct.*/
1015 outtb_elem = scicos_imp.outtb_elem;
1016 /*get outtbsz from import struct.*/
1017 outtbsz = scicos_imp.outtbsz;
1018 /*get max number of elem in outtb*/
1019 outtb_nelem = scicos_imp.nelem;
1021 /*initialization of position in outtc */
1026 /*test to know if we are outside outtb_elem*/
1027 if (nvec[j] > (*outtb_nelem))
1029 set_block_error(-1);
1033 lnk = outtb_elem[nvec[j] - 1].lnk;
1034 pos = outtb_elem[nvec[j] - 1].pos;
1035 outtbtyp = scicos_imp.outtbtyp[lnk];
1037 /*double data type*/
1038 if (outtbtyp == SCSREAL_N)
1040 outtbdptr = (SCSREAL_COP *)outtbptr[lnk];
1041 outtc[j] = (double)outtbdptr[pos];
1044 /*complex data type*/
1045 else if (outtbtyp == SCSCOMPLEX_N)
1047 sz = outtbsz[2 * lnk] + outtbsz[(2 * lnk) + 1];
1048 outtbdptr = (SCSCOMPLEX_COP *)outtbptr[lnk];
1049 outtc[j] = (double)outtbdptr[pos];
1050 /*outtc[j+1] = (double)outtbdptr[pos+sz];*/
1060 outtbcptr = (SCSINT8_COP *)outtbptr[lnk]; /*int8*/
1061 outtc[j] = (double)outtbcptr[pos];
1066 outtbsptr = (SCSINT16_COP *)outtbptr[lnk]; /*int16*/
1067 outtc[j] = (double)outtbsptr[pos];
1072 outtblptr = (SCSINT32_COP *)outtbptr[lnk]; /*int32*/
1073 outtc[j] = (double)outtblptr[pos];
1078 outtbucptr = (SCSUINT8_COP *)outtbptr[lnk]; /*uint8*/
1079 outtc[j] = (double)outtbucptr[pos];
1084 outtbusptr = (SCSUINT16_COP *)outtbptr[lnk]; /*uint16*/
1085 outtc[j] = (double)outtbusptr[pos];
1090 outtbulptr = (SCSUINT32_COP *)outtbptr[lnk]; /*uint32*/
1091 outtc[j] = (double)outtbulptr[pos];
1103 /*--------------------------------------------------------------------------*/