File: varpack.f

package info (click to toggle)
scilab 2.4-1
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 55,196 kB
  • ctags: 38,019
  • sloc: ansic: 231,970; fortran: 148,976; tcl: 7,099; makefile: 4,585; sh: 2,978; csh: 154; cpp: 101; asm: 39; sed: 5
file content (236 lines) | stat: -rw-r--r-- 5,351 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
c     Copyright INRIA 
      subroutine varpak(k,pack,n,nmax,ierr)
c     Given a scilab variable, stored in the stack at the position k (in
c     lstk) this function returns a "packing" vector pack for pvm.
c     A scilab variable is a consecutive memory region formed by a
c     succession of integer and double precision vectors.
c     pack contains a sequence of pairs of integers. 

c     varpak returns a vector which contains the size of this integer
c     and double precision vectors. pack contains a sequence of pairs of
c     integers:  pack=[i1,r1,i2,r2,...,in,rn]
c     il is a number of integer words
c     rl is a number of double precision word
c
c     n    : is the returned length of pack
c     nmax : is the maximum size allowed for pack
      INCLUDE '../stack.h'
c
      integer k,pack(*)
      integer iadr,sadr
c     
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1
      ierr=0

      il=iadr(lstk(k))
      if(istk(il).lt.0) il=iadr(istk(il+1))

c      pack(1) = 2
c      pack(2) = 3
c      pack(3) = 4
c      pack(4) = 5
c      pack(5) = 6
c      pack(6) = 7
c      pack(7) = 8
c      pack(8) = 9
c      n = 8
c      return
c      write(*,*) 'VARPACK:', istk(il)
      if(istk(il).eq.1) then
         call spak(il,pack,n,nmax)
      elseif(istk(il).eq.2) then
         call ppak(il,pack,n,nmax)
      elseif(istk(il).eq.4) then
         call bpak(il,pack,n,nmax)
      elseif(istk(il).eq.5) then
         call sppak(il,pack,n,nmax)
      elseif(istk(il).eq.6) then
         call bsppak(il,pack,n,nmax)
      elseif(istk(il).eq.10) then
         call cpak(il,pack,n,nmax)
      elseif(istk(il).eq.11.or.istk(il).eq.13) then
         call mpak(il,pack,n,nmax)
c      elseif(istk(il).eq.14) then
c         call libpak(il,pack,n,nmax)
      elseif(istk(il).eq.15.or.istk(il).eq.16) then
         call lpak(il,pack,n,nmax)
      else
         ierr=1
         return
      endif
      if(n.gt.nmax) then
         ierr=2
         return
      endif
      return
      end

      integer function odd(n)
      n1=n
      if (2*int(n1/2).ne.n1) n1=n1+1
      odd=n1
      return
      end

      subroutine spak(il,pack,n,nmax)
c     matrix of number case
      INCLUDE '../stack.h'
      integer pack(*)
      integer iadr,sadr
c     
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1

      n=2
      if(n.gt.nmax) return
      pack(1)=4
      pack(2)=istk(il+1)*istk(il+2)*(istk(il+3)+1)
      return
      end

      subroutine ppak(il,pack,np,npmax)
c     matrix of polynomial case
      INCLUDE '../stack.h'
      integer pack(*),np,npmax,odd
      integer iadr,sadr
c     
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1

      np=2
      if(np.gt.npmax) return

      id=il+8
      mn=istk(il+1)*istk(il+2)
      pack(1)=odd(8+mn+1)
      pack(2)=(istk(id+mn)-1)*(istk(il+3)+1)
      return
      end

      subroutine bpak(il,pack,np,npmax)
c     matrix of boolean case
      INCLUDE '../stack.h'
      integer pack(*),np,npmax,odd
      integer iadr,sadr
c     
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1

      np=2
      if(np.gt.npmax) return

      id=il+8
      mn=istk(il+1)*istk(il+2)
      pack(1)=odd(3+mn)
      pack(2)=0
      return
      end

      subroutine sppak(il,pack,np,npmax)
c     sparse matrix of numbers  case
      INCLUDE '../stack.h'
      integer pack(*),np,npmax,odd
      integer iadr,sadr
c     
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1

      np=2
      if(np.gt.npmax) return

      nel=istk(il+4)
      m=istk(il+1)
      n=istk(il+2)
      it=istk(il+3)

      pack(1)=odd(5+m+nel)
      pack(2)=nel*(it+1)
      return
      end

      subroutine bsppak(il,pack,np,npmax)
c     sparse matrix of numbers  case
      INCLUDE '../stack.h'
      integer pack(*),np,npmax,odd
      integer iadr,sadr
c     
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1

      np=2
      if(np.gt.npmax) return

      nel=istk(il+4)
      m=istk(il+1)
      n=istk(il+2)
      it=istk(il+3)

      pack(1)=odd(5+m+nel)
      pack(2)=0
      return
      end

      subroutine cpak(il,pack,np,npmax)
c     matrix of strings  case
      INCLUDE '../stack.h'
      integer pack(*),np,npmax,odd,vol
      integer iadr,sadr
c     
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1

      np=2
      if(np.gt.npmax) return

      mn=istk(il+1)*istk(il+2)
      id=il+4
      vol=istk(il+4+mn)-1
      pack(1)=odd(4+mn+1+vol)
      pack(2)=0
      return
      end

      subroutine mpak(il,pack,np,npmax)
c     function  case (compiled or not)
      INCLUDE '../stack.h'
      integer pack(*),np,npmax,odd,il1,nin,nout,nt
      integer iadr,sadr
c     
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1

      np=2
      if(np.gt.npmax) return
      il1=il+1
      nin=istk(il1)
      il1=il1+nin*nsiz+1
      nout=istk(il1)
      il1=il1+nout*nsiz+1
      nt=istk(il1)
      pack(1)=odd(4+nin*nsiz+nout*nsiz+nt)
      pack(2)=0
      return
      end

      subroutine libpak(il,pack,np,npmax)
c     function  case (compiled or not)
      INCLUDE '../stack.h'
      integer pack(*),np,npmax,il,odd,nf,ilh,nh,iln,nm
      integer iadr,sadr
c     
      iadr(l)=l+l-1
      sadr(l)=(l/2)+1

      np=2
      if(np.gt.npmax) return
      nf = istk(il+1)
      ilh = istk(il+2+nf)
      nh = istk(ilh)
      iln = ilh+nh+1
      nm = istk(iln)
      write(*,*) nf, nh, nm, istk(iln+1)
      pack(1)=odd(4+nf+nh+2*nm+100)
      pack(2)=0
      return
      end