summaryrefslogtreecommitdiff
path: root/Donjon/src/DETFIL.f
blob: cb4b16c568f7c24b438589bae5a71585cc348a21 (plain)
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
*DECK DETFIL
      SUBROUTINE DETFIL(Y,X,XL,TC,DT,N)
*
*----------------------------------------------------------------------
*
*Purpose:
* Filters the n values of x vector for TC seconds.
* Formulations are taken from the expression of the different
* equation of a filter with a linear variation of x in DT time
* step.
*
*Author(s): 
* xxx
*
*Parameters:
* Y   real variables Y(I) at previous time
* X   real variables to filtered
* XL  real variables X(I) at previous time
* TC  filter time constant
* DT  time step between two calculations
* N   dimension of the vectors X,XL,Y
*
*--------------------------------------------------------------------
*
      IMPLICIT NONE
      INTEGER  N,I
      REAL     Y(N),X(N),XL(N),TC,DT,AA,A,B,C
*
*     COMPUTE PONDERATION FACTORS FOR Y,X ET XL
*
      AA =  - DT / TC
      A  = EXP ( AA )
      B  = 1. - A
      C  = 1. - B * TC/DT
*
*     COMPUTE NEW Y
*
      DO 10 I=1,N
*
        Y(I)  = A * Y(I) + ( B - C ) * XL(I) + C * X(I)
        XL(I) = X(I)
*
 10   CONTINUE
      RETURN
      END