1 subroutine da_recursive_filter_1d(pass, alpha, field, n)
3 !---------------------------------------------------------------------------
4 ! Purpose: Perform one pass of recursive filter on 1D array.
6 ! Method: Perform right-moving filter followed by left-moving filter.
7 !---------------------------------------------------------------------------
11 integer, intent(in) :: pass ! Current pass of filter.
12 real, intent(in) :: alpha ! Alpha coefficient for RF.
13 real, intent(inout) :: field(:) ! Array to be filtered.
14 integer, intent(in) :: n ! Size of field array.
16 integer :: j ! Loop counter.
17 real :: one_alpha ! 1 - alpha.
18 real :: a(1:n) ! Input field.
19 real :: b(1:n) ! Field after left-right pass.
20 real :: c(1:n) ! Field after right-left pass.
22 if (trace_use_dull) call da_trace_entry("da_recursive_filter_1d")
24 !-------------------------------------------------------------------------
26 !-------------------------------------------------------------------------
28 one_alpha = 1.0 - alpha
32 !-------------------------------------------------------------------------
33 ! [2.0] Perform right-moving filter:
34 !-------------------------------------------------------------------------
36 ! use turning conditions as in the appendix of Hayden & Purser (1995):
39 b(1) = one_alpha * a(1)
40 else if (pass == 2) then
41 b(1) = a(1) / (1.0 + alpha)
43 b(1) = one_alpha * (a(1) - alpha**3 * a(2)) / (1.0 - alpha**2)**2
46 ! [2.2] Perform pass left to right:
49 b(j) = alpha * b(j-1) + one_alpha * a(j)
52 !-------------------------------------------------------------------------
53 ! [3.0] Perform left-moving filter:
54 !-------------------------------------------------------------------------
56 ! use turning conditions as in the appendix of Hayden & Purser (1995):
59 c(n) = b(n) / (1.0 + alpha)
61 c(n) = one_alpha * (b(n) - alpha**3 * b(n-1)) / (1.0 - alpha**2)**2
64 ! [3.2] Perform pass left to right:
67 c(j) = alpha * c(j+1) + one_alpha * b(j)
72 if (trace_use_dull) call da_trace_exit("da_recursive_filter_1d")
74 end subroutine da_recursive_filter_1d