/[lmdze]/trunk/Sources/filtrez/inifilr_hemisph.f
ViewVC logotype

Annotation of /trunk/Sources/filtrez/inifilr_hemisph.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 166 - (hide annotations)
Wed Jul 29 14:32:55 2015 UTC (8 years, 10 months ago) by guez
File size: 2166 byte(s)
Split ppm3d.f into files containing a single procedure.

Factorized computations of filtering matrices into a procedure
inifilr_hemisph. Had then to change the matrices from allocatable to
pointer and from customized lower bound to lower bound 1. The change
in lower bounds does not matter because the matrices are only used as
a whole as actual arguments.

Also, in infilr, instead of finding jfilt[ns][uv] from approximately
jjm /2, start at index j1 that corresponds to the equator. This is not
the same if there is a zoom in latitude.

Also, the test (rlamda(modfrst[ns][uv](j)) * cos(rlat[uv](j)) < 1) in
the loops on filtered latitudes is not useful now that we start from
j1: it is necessarily true. See notes.

Just encapsulated lwvn into a module and removed unused argument ktraer.

1 guez 166 module inifilr_hemisph_m
2    
3     implicit none
4    
5     contains
6    
7     subroutine inifilr_hemisph(rlat, colat0, rlamda, unit, eignfn, jfilt, &
8     matrice, matrinv)
9    
10     ! See notes.
11    
12     USE dimens_m, ONLY : iim
13     use nr_util, only: pi, ifirstloc
14    
15     real, intent(in):: rlat(:) ! (n)
16     ! latitudes, in rad, in [0, pi / 2[, in strictly ascending order
17    
18     REAL, intent(in):: colat0 ! > 0
19     REAL, intent(in):: rlamda(2:) ! (2:iim) > 0, in descending order
20     integer, intent(in):: unit
21    
22     real, intent(in):: eignfn(:, :) ! (iim, iim)
23     ! eigenvectors of the discrete second derivative with respect to longitude
24    
25     integer, intent(out):: jfilt
26     real, pointer:: matrice(:, :, :) ! (iim, iim, n - jfilt + 1) matrice filtre
27    
28     real, pointer, optional:: matrinv(:, :, :) ! (iim, iim, n - jfilt + 1)
29     ! matrice pour le filtre inverse
30    
31     ! Local:
32    
33     integer n, i, j
34     REAL eignft(iim, iim)
35    
36     ! Index of the mode from where modes are filtered:
37     integer, allocatable:: modfrst(:) ! (jfilt:n) in {2, ..., iim}
38    
39     ! Filtering coefficients (lamda_max * cos(rlat) / lamda):
40     real coefil(iim)
41    
42     !-----------------------------------------------------------
43    
44     n = size(rlat)
45     jfilt = ifirstloc(cos(rlat) < min(colat0, 1. / rlamda(iim)))
46     allocate(modfrst(jfilt:n))
47    
48     DO j = jfilt, n
49     modfrst(j) = ifirstloc(rlamda < 1. / cos(rlat(j)), my_lbound = 2)
50     write(unit, fmt = *) rlat(j) / pi * 180., modfrst(j)
51     END DO
52    
53     allocate(matrice(iim, iim, n - jfilt + 1))
54     if (present(matrinv)) allocate(matrinv(iim, iim, n - jfilt + 1))
55    
56     DO j = jfilt, n
57     DO i = modfrst(j), iim
58     coefil(i) = rlamda(i) * cos(rlat(j)) - 1.
59     end DO
60    
61     eignft(:modfrst(j) - 1, :) = 0.
62    
63     forall (i = modfrst(j):iim) eignft(i, :) = eignfn(:, i) * coefil(i)
64     matrice(:, :, j - jfilt + 1) = matmul(eignfn, eignft)
65    
66     if (present(matrinv)) then
67     forall (i = modfrst(j):iim) eignft(i, :) = eignfn(:, i) * coefil(i) &
68     / (1. + coefil(i))
69     matrinv(:, :, j - jfilt + 1) = matmul(eignfn, eignft)
70     end if
71     END DO
72    
73     end subroutine inifilr_hemisph
74    
75     end module inifilr_hemisph_m

  ViewVC Help
Powered by ViewVC 1.1.21