File: coselm.f

package info (click to toggle)
scilab 2.6-4
  • links: PTS
  • area: non-free
  • in suites: woody
  • size: 54,632 kB
  • ctags: 40,267
  • sloc: ansic: 267,851; fortran: 166,549; sh: 10,005; makefile: 4,119; tcl: 1,070; cpp: 233; csh: 143; asm: 135; perl: 130; java: 39
file content (382 lines) | stat: -rw-r--r-- 8,901 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
      subroutine coselm
c ====================================================================
c
c     evaluate scicos utility functions
c
c ====================================================================
c
c     Copyright INRIA
      INCLUDE '../stack.h'
      integer id(nsiz)
      integer kfun
      common /curblk/ kfun
      double precision ptr
      integer iadr,sadr
c     
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1

c
      if (ddt .eq. 4) then
         write(buf(1:4),'(i4)') fin
         call basout(io,wte,' coselm '//buf(1:4))
      endif
c
c     functions/fin
c     var2vec  vec2var get_import set_import get_curblk getlabel
c       1          2       3         4         5          6
c
c     
      goto(10,20,30,40,50,60) fin

c     var2vec
 10   continue
      if (rhs .ne. 1) then
         call error(39)
         return
      endif
      if (lhs .ne. 1) then
         call error(41)
         return
      endif
c      if(istk(il).eq.1) return
      il=iadr(lstk(top))
      il1=il
      l1=sadr(il1+4)
      n=lstk(top+1)-lstk(top)
      call unsfdcopy(n,stk(lstk(top)),-1,stk(l1),-1)
      istk(il1)=1
      istk(il1+1)=n
      istk(il1+2)=1
      istk(il1+3)=0
      lstk(top+1)=l1+n
      goto 999
c
c     vec2var
 20   continue
      if (rhs .ne. 1) then
         call error(39)
         return
      endif
      if (lhs .ne. 1) then
         call error(41)
         return
      endif
      il1=iadr(lstk(top))
      if(istk(il1).ne.1) then
         err=1
         call error(44)
         return
      endif
      l1=sadr(il1+4)

      n=lstk(top+1)-l1
      call unsfdcopy(n,stk(l1),1,stk(lstk(top)),1)
      lstk(top+1)=lstk(top)+n
      goto 999
c
 30   continue
c     getscicosvars
      call intgetscicosvars
      return
c
 40   continue
c     setscicosvars
      call intgetscicosvars
      return
c
c     curblock
 50   continue
      call intcurblk
      goto 999

c     getblocklabel
 60   continue
      call intgetlabel
      goto 999
c
 999  return
      end

      subroutine intcurblk
      include '../stack.h'
      integer kfun
      common /curblk/ kfun
      integer iadr, sadr
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1

      top=top+1
      il=iadr(lstk(top))
      istk(il)=1
      istk(il+1)=1
      istk(il+2)=1
      istk(il+3)=0
      l=sadr(il+4)
      stk(l)=kfun
      lstk(top+1)=l+1
      return
      end

      subroutine intgetscicosvars
      include '../stack.h'
      integer kfun
      common /curblk/ kfun
      integer vol,type,getscicosvars,ierr
      double precision ptr
      external getscicosvars
      integer iadr, sadr
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1

      if(rhs.ne.1) then
         call error(39)
         return
      endif
      if (lhs .ne. 1) then
         call error(41)
         return
      endif
      il1=iadr(lstk(top))
      if(istk(il1).ne.10) then
         err=1
         call error(55)
         return
      endif
c     
      if(istk(il1+1)*istk(il1+2).ne.1) then
         err=1
         call error(36)
         return
      endif
c     
      mn1=1
      id1=il1+4
      l1=id1+mn1+1
      vol=istk(id1+mn1)-1
      call cvstr(vol,istk(l1),buf,1)
c
      if(buf(1:vol).eq.'x') then
        ierr=getscicosvars(1,ptr,nv,type)
      elseif(buf(1:vol).eq.'xptr') then
        ierr=getscicosvars(2,ptr,nv,type)
      elseif(buf(1:vol).eq.'z') then
        ierr=getscicosvars(3,ptr,nv,type)
      elseif(buf(1:vol).eq.'zptr') then
        ierr=getscicosvars(4,ptr,nv,type)
      elseif(buf(1:vol).eq.'rpar') then
        ierr=getscicosvars(5,ptr,nv,type)
      elseif(buf(1:vol).eq.'rpptr') then
        ierr=getscicosvars(6,ptr,nv,type)
      elseif(buf(1:vol).eq.'ipar') then
        ierr=getscicosvars(7,ptr,nv,type)
      elseif(buf(1:vol).eq.'ipptr') then
        ierr=getscicosvars(8,ptr,nv,type)
      elseif(buf(1:vol).eq.'outtb') then
        ierr=getscicosvars(9,ptr,nv,type)
      elseif(buf(1:vol).eq.'inpptr') then
        ierr=getscicosvars(10,ptr,nv,type)
      elseif(buf(1:vol).eq.'outptr') then
        ierr=getscicosvars(11,ptr,nv,type)
      elseif(buf(1:vol).eq.'inplnk') then
        ierr=getscicosvars(12,ptr,nv,type)
      elseif(buf(1:vol).eq.'outlnk') then
        ierr=getscicosvars(13,ptr,nv,type)
      elseif(buf(1:vol).eq.'lnkptr') then
        ierr=getscicosvars(14,ptr,nv,type)
      else
         buf='Undefined field'
         call error(999)
         return
      endif
      if(ierr.ne.0) then
         buf='scicosim is not running'
         call error(999)
         return
      endif
      l=sadr(il1+4)
      if(type.eq.0) then
         call cint(nv,ptr,stk(l))
      else
         call cdouble(nv,ptr,stk(l))
      endif
      istk(il1)=1
      istk(il1+1)=nv
      istk(il1+2)=min(nv,1)
      istk(il1+3)=0
      lstk(top+1)=l+nv
      return
      end


      subroutine intsetscicosvars
      include '../stack.h'
      integer kfun
      common /curblk/ kfun
      integer vol,type,getscicosvars,ierr
      double precision ptr
      external getscicosvars
      integer iadr, sadr
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1

      if(rhs.ne.2) then
         call error(39)
         return
      endif
      if (lhs .ne. 1) then
         call error(41)
         return
      endif
c     
      lw = lstk(top+1)
      il2=iadr(lstk(top))
      if(istk(il2).ne.1) then 
         err=2
         call error(53)
         return
      endif
      if(istk(il2+3).ne.0) then
         err=2
         call error(52)
         return
      endif
      nv2=istk(il2+1)*istk(il2+2)
      lv=sadr(il2+4)
      top=top-1
c
      il1=iadr(lstk(top))
      if(istk(il1+1)*istk(il1+2).ne.1) then
         err=1
         call error(36)
         return
      endif
c     
      mn1=1
      id1=il1+4
      l1=id1+mn1+1
      vol=istk(id1+mn1)-1
      call cvstr(vol,istk(l1),buf,1)

      if(buf(1:vol).eq.'x') then
        ierr=getscicosvars(1,ptr,nv,type)
      elseif(buf(1:vol).eq.'xptr') then
        ierr=getscicosvars(2,ptr,nv,type)
      elseif(buf(1:vol).eq.'z') then
        ierr=getscicosvars(3,ptr,nv,type)
      elseif(buf(1:vol).eq.'zptr') then
        ierr=getscicosvars(4,ptr,nv,type)
      elseif(buf(1:vol).eq.'rpar') then
        ierr=getscicosvars(5,ptr,nv,type)
      elseif(buf(1:vol).eq.'rpptr') then
        ierr=getscicosvars(6,ptr,nv,type)
      elseif(buf(1:vol).eq.'ipar') then
        ierr=getscicosvars(7,ptr,nv,type)
      elseif(buf(1:vol).eq.'ipptr') then
        ierr=getscicosvars(8,ptr,nv,type)
      elseif(buf(1:vol).eq.'outtb') then
        ierr=getscicosvars(9,ptr,nv,type)
      elseif(buf(1:vol).eq.'inpptr') then
        ierr=getscicosvars(10,ptr,nv,type)
      elseif(buf(1:vol).eq.'outptr') then
        ierr=getscicosvars(11,ptr,nv,type)
      elseif(buf(1:vol).eq.'inplnk') then
        ierr=getscicosvars(12,ptr,nv,type)
      elseif(buf(1:vol).eq.'outlnk') then
        ierr=getscicosvars(13,ptr,nv,type)
      elseif(buf(1:vol).eq.'lnkptr') then
        ierr=getscicosvars(14,ptr,nv,type)
      else
         buf='Undefined field'
         call error(999)
         return
      endif
      if(ierr.ne.0) then
         buf='scicosim is not running'
         call error(999)
         return
      endif
      if(nv.ne.nv2) then
         pstk(pt+1)=nv
         err=2
         call error(206)
         return
      endif
      if(type.eq.0) then
c     integer  
         call entier(nv,stk(lv),istk(iadr(lv)))
         call int2cint(nv,ptr,istk(iadr(lv)))
      else
         call dbl2cdbl(nv,ptr,stk(lv))
c     double
      endif
      il=iadr(lstk(top))
      istk(il)=0
      lstk(top+1)=lstk(top)+1
      return
      end

      subroutine intgetlabel
      include '../stack.h'
      integer iadr, sadr
      integer kfun
      integer getscilabel
      external getscilabel
      common /curblk/ kfun
c
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1

      if(rhs.gt.1) then
         call error(39)
         return
      endif
      if (lhs .ne. 1) then
         call error(41)
         return
      endif
      if(rhs.eq.1) then
         il=iadr(lstk(top))
         if(istk(il).ne.1) then 
            err=1
            call error(54)
            return
         endif
         if(istk(il+1)*istk(il+2).ne.1) then
            err=1
            call error(36)
            return
         endif
         kf=stk(sadr(il+4))
         top=top-1
      else
         kf=kfun
      endif

c     
      lw = lstk(top+1)
      top=top+1
      il1=iadr(lstk(top))
      
      id1=il1+4
      l1=id1+2
      err=sadr(l1+50)-lstk(bot)
      if(err.gt.0) then
         call error(17)
         return
      endif
      ierr=getscilabel(kf,istk(l1),n)
      if(ierr.ne.0) then
         buf='scicosim is not running'
         call error(999)
         return
      endif
      istk(il1)=10
      istk(il1+1)=1
      istk(il1+2)=1
      istk(il1+3)=0
      istk(il1+4)=1
      istk(il1+5)=1+n
      lstk(top+1)=sadr(l1+n)
      return
      end