1 | !!---------------------------------------------------------------------- |
---|
2 | !! NEMO/OCE 4.0 , NEMO Consortium (2018) |
---|
3 | !! $Id$ |
---|
4 | !! Software governed by the CeCILL license (see ./LICENSE) |
---|
5 | !!---------------------------------------------------------------------- |
---|
6 | |
---|
7 | SUBROUTINE obs_int_z1d( kpk, kkco, k1dint, kdep, & |
---|
8 | & pobsdep, pobsk, pobs2k, & |
---|
9 | & pobs, pdep, pobsmask ) |
---|
10 | !!--------------------------------------------------------------------- |
---|
11 | !! |
---|
12 | !! *** ROUTINE obs_int_z1d *** |
---|
13 | !! |
---|
14 | !! ** Purpose : Vertical interpolation to the observation point. |
---|
15 | !! |
---|
16 | !! ** Method : If k1dint = 0 then use linear interpolation. |
---|
17 | !! If k1dint = 1 then use cubic spline interpolation. |
---|
18 | !! |
---|
19 | !! ** Action : |
---|
20 | !! |
---|
21 | !! References : |
---|
22 | !! |
---|
23 | !! History |
---|
24 | !! ! 97-11 (A. Weaver, S. Ricci, N. Daget) |
---|
25 | !! ! 06-03 (G. Smith) Conversion to F90 for use with NEMOVAR |
---|
26 | !! ! 06-10 (A. Weaver) Cleanup |
---|
27 | !! ! 07-01 (K. Mogensen) Use profile rather than single level |
---|
28 | !!--------------------------------------------------------------------- |
---|
29 | |
---|
30 | !! * Arguments |
---|
31 | INTEGER, INTENT(IN) :: kpk ! Number of vertical levels |
---|
32 | INTEGER, INTENT(IN) :: k1dint ! 0 = linear; 1 = cubic spline interpolation |
---|
33 | INTEGER, INTENT(IN) :: kdep ! Number of levels in profile |
---|
34 | INTEGER, INTENT(IN), DIMENSION(kdep) :: & |
---|
35 | & kkco ! Array indicies for interpolation |
---|
36 | REAL(KIND=wp), INTENT(IN), DIMENSION(kdep) :: & |
---|
37 | & pobsdep ! Depth of the observation |
---|
38 | REAL(KIND=wp), INTENT(IN), DIMENSION(kpk) :: & |
---|
39 | & pobsk, & ! Model profile at a given (lon,lat) |
---|
40 | & pobs2k, & ! 2nd derivative of the interpolating function |
---|
41 | & pdep, & ! Model depth array |
---|
42 | & pobsmask ! Vertical mask |
---|
43 | REAL(KIND=wp), INTENT(OUT), DIMENSION(kdep) :: & |
---|
44 | & pobs ! Model equivalent at observation point |
---|
45 | |
---|
46 | !! * Local declarations |
---|
47 | REAL(KIND=wp) :: z1dm ! Distance above and below obs to model grid points |
---|
48 | REAL(KIND=wp) :: z1dp |
---|
49 | REAL(KIND=wp) :: zsum ! Dummy variables for computation |
---|
50 | REAL(KIND=wp) :: zsum2 |
---|
51 | INTEGER :: jdep ! Observation depths loop variable |
---|
52 | |
---|
53 | !------------------------------------------------------------------------ |
---|
54 | ! Loop over all observation depths |
---|
55 | !------------------------------------------------------------------------ |
---|
56 | |
---|
57 | DO jdep = 1, kdep |
---|
58 | |
---|
59 | !--------------------------------------------------------------------- |
---|
60 | ! Initialization |
---|
61 | !--------------------------------------------------------------------- |
---|
62 | z1dm = ( pdep(kkco(jdep)) - pobsdep(jdep) ) |
---|
63 | z1dp = ( pobsdep(jdep) - pdep(kkco(jdep)-1) ) |
---|
64 | IF ( pobsmask(kkco(jdep)) == 0.0_wp ) z1dp = 0.0_wp |
---|
65 | |
---|
66 | zsum = z1dm + z1dp |
---|
67 | |
---|
68 | IF ( k1dint == 0 ) THEN |
---|
69 | |
---|
70 | !----------------------------------------------------------------- |
---|
71 | ! Linear interpolation |
---|
72 | !----------------------------------------------------------------- |
---|
73 | pobs(jdep) = ( z1dm * pobsk(kkco(jdep)-1) & |
---|
74 | & + z1dp * pobsk(kkco(jdep) ) ) / zsum |
---|
75 | |
---|
76 | ELSEIF ( k1dint == 1 ) THEN |
---|
77 | |
---|
78 | !----------------------------------------------------------------- |
---|
79 | ! Cubic spline interpolation |
---|
80 | !----------------------------------------------------------------- |
---|
81 | zsum2 = zsum * zsum |
---|
82 | pobs(jdep) = ( z1dm * pobsk (kkco(jdep)-1) & |
---|
83 | & + z1dp * pobsk (kkco(jdep) ) & |
---|
84 | & + ( z1dm * ( z1dm * z1dm - zsum2 ) * pobs2k(kkco(jdep)-1) & |
---|
85 | & + z1dp * ( z1dp * z1dp - zsum2 ) * pobs2k(kkco(jdep) ) & |
---|
86 | & ) / 6.0_wp & |
---|
87 | & ) / zsum |
---|
88 | |
---|
89 | ENDIF |
---|
90 | END DO |
---|
91 | |
---|
92 | END SUBROUTINE obs_int_z1d |
---|
93 | |
---|
94 | SUBROUTINE obs_int_z1d_spl( kpk, pobsk, pobs2k, & |
---|
95 | & pdep, pobsmask ) |
---|
96 | !!-------------------------------------------------------------------- |
---|
97 | !! |
---|
98 | !! *** ROUTINE obs_int_z1d_spl *** |
---|
99 | !! |
---|
100 | !! ** Purpose : Compute the local vector of vertical second-derivatives |
---|
101 | !! of the interpolating function used with a cubic spline. |
---|
102 | !! |
---|
103 | !! ** Method : |
---|
104 | !! |
---|
105 | !! Top and bottom boundary conditions on the 2nd derivative are |
---|
106 | !! set to zero. |
---|
107 | !! |
---|
108 | !! ** Action : |
---|
109 | !! |
---|
110 | !! References : |
---|
111 | !! |
---|
112 | !! History |
---|
113 | !! ! 01-11 (A. Weaver, S. Ricci, N. Daget) |
---|
114 | !! ! 06-03 (G. Smith) Conversion to F90 for use with NEMOVAR |
---|
115 | !! ! 06-10 (A. Weaver) Cleanup |
---|
116 | !!---------------------------------------------------------------------- |
---|
117 | |
---|
118 | !! * Arguments |
---|
119 | INTEGER, INTENT(IN) :: kpk ! Number of vertical levels |
---|
120 | REAL(KIND=wp), INTENT(IN), DIMENSION(kpk) :: & |
---|
121 | & pobsk, & ! Model profile at a given (lon,lat) |
---|
122 | & pdep, & ! Model depth array |
---|
123 | & pobsmask ! Vertical mask |
---|
124 | REAL(KIND=wp), INTENT(OUT), DIMENSION(kpk) :: & |
---|
125 | & pobs2k ! 2nd derivative of the interpolating function |
---|
126 | |
---|
127 | !! * Local declarations |
---|
128 | INTEGER :: jk |
---|
129 | REAL(KIND=wp) :: za |
---|
130 | REAL(KIND=wp) :: zb |
---|
131 | REAL(KIND=wp) :: zc |
---|
132 | REAL(KIND=wp) :: zpa |
---|
133 | REAL(KIND=wp) :: zkm |
---|
134 | REAL(KIND=wp) :: zkp |
---|
135 | REAL(KIND=wp) :: zk |
---|
136 | REAL(KIND=wp), DIMENSION(kpk-1) :: & |
---|
137 | & zs, & |
---|
138 | & zp, & |
---|
139 | & zu, & |
---|
140 | & zv |
---|
141 | |
---|
142 | !----------------------------------------------------------------------- |
---|
143 | ! Matrix initialisation |
---|
144 | !----------------------------------------------------------------------- |
---|
145 | zs(1) = 0.0_wp |
---|
146 | zp(1) = 0.0_wp |
---|
147 | zv(1) = -0.5_wp |
---|
148 | DO jk = 2, kpk-1 |
---|
149 | zs(jk) = ( pdep(jk ) - pdep(jk-1) ) & |
---|
150 | & / ( pdep(jk+1) - pdep(jk-1) ) |
---|
151 | zp(jk) = zs(jk) * zv(jk-1) + 2.0_wp |
---|
152 | zv(jk) = ( zs(jk) - 1.0_wp ) / zp(jk) |
---|
153 | END DO |
---|
154 | |
---|
155 | !----------------------------------------------------------------------- |
---|
156 | ! Solution of the tridiagonal system |
---|
157 | !----------------------------------------------------------------------- |
---|
158 | |
---|
159 | ! Top boundary condition |
---|
160 | zu(1) = 0.0_wp |
---|
161 | |
---|
162 | DO jk = 2, kpk-1 |
---|
163 | za = pdep(jk+1) - pdep(jk-1) |
---|
164 | zb = pdep(jk+1) - pdep(jk ) |
---|
165 | zc = pdep(jk ) - pdep(jk-1) |
---|
166 | |
---|
167 | zpa = 6.0_wp / ( zp(jk) * za ) |
---|
168 | zkm = zpa / zc |
---|
169 | zkp = zpa / zb |
---|
170 | zk = - ( zkm + zkp ) |
---|
171 | |
---|
172 | zu(jk) = pobsk(jk+1) * zkp & |
---|
173 | & + pobsk(jk ) * zk & |
---|
174 | & + pobsk(jk-1) * zkm & |
---|
175 | & + zu(jk-1) * ( -zs(jk) / zp(jk) ) |
---|
176 | END DO |
---|
177 | |
---|
178 | !----------------------------------------------------------------------- |
---|
179 | ! Second derivative |
---|
180 | !----------------------------------------------------------------------- |
---|
181 | pobs2k(kpk) = 0.0_wp |
---|
182 | |
---|
183 | ! Bottom boundary condition |
---|
184 | DO jk = kpk-1, 1, -1 |
---|
185 | pobs2k(jk) = zv(jk) * pobs2k(jk+1) + zu(jk) |
---|
186 | IF ( pobsmask(jk+1) == 0.0_wp ) pobs2k(jk) = 0.0_wp |
---|
187 | END DO |
---|
188 | |
---|
189 | END SUBROUTINE obs_int_z1d_spl |
---|
190 | |
---|
191 | |
---|