1 subroutine da_legtra_inv_adj(jds, jde, jts, jte, max_wavenumber, alp_size, &
4 !-----------------------------------------------------------------------
6 !-----------------------------------------------------------------------
10 integer, intent(in) :: jds, jde ! Number of latitudes.
11 integer, intent(in) :: jts, jte ! Number of latitudes.
12 integer, intent(in) :: max_wavenumber ! Maximum wavenumber.
13 integer, intent(in) :: alp_size ! Dimension of ALPs.
14 integer, intent(in) :: m ! Zonal wavenumber.
15 real, intent(in) :: alp(1:alp_size) ! Associated Legendre Polynomials
17 complex, intent(out) :: v(m:max_wavenumber) ! Output spectral coefficient.
18 complex, intent(in) :: r_leg(jts:jte) ! Field to transform.
20 integer :: l, j, js, je ! Loop counters.
21 integer :: index_m, index_j ! Markers.
22 complex :: sum_legtra ! Summation scalars.
24 integer :: jc, iequator, temp
26 if (trace_use) call da_trace_entry("da_legtra_inv_adj")
28 index_m = m * (max_wavenumber + 1 - m) + m * (m + 1) / 2 + 1 - m
32 iequator = mod(jde-jds+1, 2)
34 js = max(jts, jc+iequator+1)
35 je = min(jc+iequator, jte)
37 temp = (max_wavenumber + 1) * (max_wavenumber + 2) / 2
39 do l = m, max_wavenumber
40 sum_legtra = da_zero_complex
42 if (mod(l+m,2) == 1) then
44 index_j = (jds+jde - j - 1) * temp
45 sum_legtra = sum_legtra - r_leg(j) * alp(index_j + index_m + l)
49 index_j = (jds+jde - j - 1) * temp
50 sum_legtra = sum_legtra + r_leg(j) * alp(index_j + index_m + l)
55 index_j = (j - 1) * temp
56 sum_legtra = sum_legtra + r_leg(j) * alp(index_j + index_m + l)
62 if (trace_use) call da_trace_exit("da_legtra_inv_adj")
64 end subroutine da_legtra_inv_adj