1c     Scicos
2c
3c     Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
4c
5c     This program is free software; you can redistribute it and/or modify
6c     it under the terms of the GNU General Public License as published by
7c     the Free Software Foundation; either version 2 of the License, or
8c     (at your option) any later version.
9c
10c     This program is distributed in the hope that it will be useful,
11c     but WITHOUT ANY WARRANTY; without even the implied warranty of
12c     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13c     GNU General Public License for more details.
14c
15c     You should have received a copy of the GNU General Public License
16c     along with this program; if not, write to the Free Software
17c     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18c
19c     See the file ./license.txt
20c
21
22      subroutine forblk(flag,nevprt,t,xd,x,nx,z,nz,tvec,ntvec,
23     &     rpar,nrpar,ipar,nipar,u,nu,y,ny)
24c     Copyright INRIA
25
26c     Scicos block simulator
27c     For block
28c
29      double precision t,xd(*),x(*),z(*),tvec(*),rpar(*),u(*),y(*)
30      integer flag,nevprt,nx,nz,ntvec,nrpar,ipar(*)
31      integer nipar,nu,ny
32
33c
34      double precision atol,rtol,ttol,deltat
35      common /costol/ atol,rtol,ttol,deltat
36c
37c
38      if(flag.eq.3) then
39         if(nevprt.eq.1) then
40            z(2)=u(1)
41            z(1)=1.d0
42c
43            if(u(1).ge.1) then
44               tvec(1)=t-1.d0
45               tvec(2)=t+ttol/2.0d0
46            else
47               tvec(1)=t-1.d0
48               tvec(2)=t-1.d0
49            endif
50
51         else
52            z(1)=z(1)+1.d0
53c
54            if(z(1).ge.z(2)) then
55               tvec(1)=t+ttol/2.0d0
56               tvec(2)=t-1.d0
57            else
58               tvec(1)=t-1.d0
59               tvec(2)=t+ttol/2.0d0
60            endif
61         endif
62      endif
63
64      if(flag.eq.1.or.flag.eq.3) then
65         y(1)=z(1)
66      endif
67
68      end
69