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 | |
---|
65 | ! If kkco(jdep) is masked then set pobs(jdep) to the lowest value located above bathymetry |
---|
66 | IF ( pobsmask(kkco(jdep)) == 0.0_wp ) THEN |
---|
67 | pobs(jdep) = pobsk(kkco(jdep)-1) |
---|
68 | ELSE |
---|
69 | zsum = z1dm + z1dp |
---|
70 | |
---|
71 | IF ( k1dint == 0 ) THEN |
---|
72 | |
---|
73 | !----------------------------------------------------------------- |
---|
74 | ! Linear interpolation |
---|
75 | !----------------------------------------------------------------- |
---|
76 | pobs(jdep) = ( z1dm * pobsk(kkco(jdep)-1) & |
---|
77 | & + z1dp * pobsk(kkco(jdep) ) ) / zsum |
---|
78 | |
---|
79 | ELSEIF ( k1dint == 1 ) THEN |
---|
80 | |
---|
81 | !----------------------------------------------------------------- |
---|
82 | ! Cubic spline interpolation |
---|
83 | !----------------------------------------------------------------- |
---|
84 | zsum2 = zsum * zsum |
---|
85 | pobs(jdep) = ( z1dm * pobsk (kkco(jdep)-1) & |
---|
86 | & + z1dp * pobsk (kkco(jdep) ) & |
---|
87 | & + ( z1dm * ( z1dm * z1dm - zsum2 ) * pobs2k(kkco(jdep)-1) & |
---|
88 | & + z1dp * ( z1dp * z1dp - zsum2 ) * pobs2k(kkco(jdep) ) & |
---|
89 | & ) / 6.0_wp & |
---|
90 | & ) / zsum |
---|
91 | |
---|
92 | ENDIF |
---|
93 | ENDIF |
---|
94 | END DO |
---|
95 | |
---|
96 | END SUBROUTINE obs_int_z1d |
---|
97 | |
---|
98 | SUBROUTINE obs_int_z1d_spl( kpk, pobsk, pobs2k, & |
---|
99 | & pdep, pobsmask ) |
---|
100 | !!-------------------------------------------------------------------- |
---|
101 | !! |
---|
102 | !! *** ROUTINE obs_int_z1d_spl *** |
---|
103 | !! |
---|
104 | !! ** Purpose : Compute the local vector of vertical second-derivatives |
---|
105 | !! of the interpolating function used with a cubic spline. |
---|
106 | !! |
---|
107 | !! ** Method : |
---|
108 | !! |
---|
109 | !! Top and bottom boundary conditions on the 2nd derivative are |
---|
110 | !! set to zero. |
---|
111 | !! |
---|
112 | !! ** Action : |
---|
113 | !! |
---|
114 | !! References : |
---|
115 | !! |
---|
116 | !! History |
---|
117 | !! ! 01-11 (A. Weaver, S. Ricci, N. Daget) |
---|
118 | !! ! 06-03 (G. Smith) Conversion to F90 for use with NEMOVAR |
---|
119 | !! ! 06-10 (A. Weaver) Cleanup |
---|
120 | !!---------------------------------------------------------------------- |
---|
121 | |
---|
122 | !! * Arguments |
---|
123 | INTEGER, INTENT(IN) :: kpk ! Number of vertical levels |
---|
124 | REAL(KIND=wp), INTENT(IN), DIMENSION(kpk) :: & |
---|
125 | & pobsk, & ! Model profile at a given (lon,lat) |
---|
126 | & pdep, & ! Model depth array |
---|
127 | & pobsmask ! Vertical mask |
---|
128 | REAL(KIND=wp), INTENT(OUT), DIMENSION(kpk) :: & |
---|
129 | & pobs2k ! 2nd derivative of the interpolating function |
---|
130 | |
---|
131 | !! * Local declarations |
---|
132 | INTEGER :: jk |
---|
133 | REAL(KIND=wp) :: za |
---|
134 | REAL(KIND=wp) :: zb |
---|
135 | REAL(KIND=wp) :: zc |
---|
136 | REAL(KIND=wp) :: zpa |
---|
137 | REAL(KIND=wp) :: zkm |
---|
138 | REAL(KIND=wp) :: zkp |
---|
139 | REAL(KIND=wp) :: zk |
---|
140 | REAL(KIND=wp), DIMENSION(kpk-1) :: & |
---|
141 | & zs, & |
---|
142 | & zp, & |
---|
143 | & zu, & |
---|
144 | & zv |
---|
145 | |
---|
146 | !----------------------------------------------------------------------- |
---|
147 | ! Matrix initialisation |
---|
148 | !----------------------------------------------------------------------- |
---|
149 | zs(1) = 0.0_wp |
---|
150 | zp(1) = 0.0_wp |
---|
151 | zv(1) = -0.5_wp |
---|
152 | DO jk = 2, kpk-1 |
---|
153 | zs(jk) = ( pdep(jk ) - pdep(jk-1) ) & |
---|
154 | & / ( pdep(jk+1) - pdep(jk-1) ) |
---|
155 | zp(jk) = zs(jk) * zv(jk-1) + 2.0_wp |
---|
156 | zv(jk) = ( zs(jk) - 1.0_wp ) / zp(jk) |
---|
157 | END DO |
---|
158 | |
---|
159 | !----------------------------------------------------------------------- |
---|
160 | ! Solution of the tridiagonal system |
---|
161 | !----------------------------------------------------------------------- |
---|
162 | |
---|
163 | ! Top boundary condition |
---|
164 | zu(1) = 0.0_wp |
---|
165 | |
---|
166 | DO jk = 2, kpk-1 |
---|
167 | za = pdep(jk+1) - pdep(jk-1) |
---|
168 | zb = pdep(jk+1) - pdep(jk ) |
---|
169 | zc = pdep(jk ) - pdep(jk-1) |
---|
170 | |
---|
171 | zpa = 6.0_wp / ( zp(jk) * za ) |
---|
172 | zkm = zpa / zc |
---|
173 | zkp = zpa / zb |
---|
174 | zk = - ( zkm + zkp ) |
---|
175 | |
---|
176 | zu(jk) = pobsk(jk+1) * zkp & |
---|
177 | & + pobsk(jk ) * zk & |
---|
178 | & + pobsk(jk-1) * zkm & |
---|
179 | & + zu(jk-1) * ( -zs(jk) / zp(jk) ) |
---|
180 | END DO |
---|
181 | |
---|
182 | !----------------------------------------------------------------------- |
---|
183 | ! Second derivative |
---|
184 | !----------------------------------------------------------------------- |
---|
185 | pobs2k(kpk) = 0.0_wp |
---|
186 | |
---|
187 | ! Bottom boundary condition |
---|
188 | DO jk = kpk-1, 1, -1 |
---|
189 | pobs2k(jk) = zv(jk) * pobs2k(jk+1) + zu(jk) |
---|
190 | IF ( pobsmask(jk+1) == 0.0_wp ) pobs2k(jk) = 0.0_wp |
---|
191 | END DO |
---|
192 | |
---|
193 | END SUBROUTINE obs_int_z1d_spl |
---|
194 | |
---|
195 | |
---|