1 | MODULE geo2ocean |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE geo2ocean *** |
---|
4 | !! Ocean mesh : ??? |
---|
5 | !!====================================================================== |
---|
6 | !! History : OPA ! 07-1996 (O. Marti) Original code |
---|
7 | !! NEMO 1.0 ! 06-2006 (G. Madec ) Free form, F90 + opt. |
---|
8 | !! ! 04-2007 (S. Masson) angle: Add T, F points and bugfix in cos lateral boundary |
---|
9 | !! 3.0 ! 07-2008 (G. Madec) geo2oce suppress lon/lat agruments |
---|
10 | !! 3.7 ! 11-2015 (G. Madec) remove the unused repere and repcmo routines |
---|
11 | !!---------------------------------------------------------------------- |
---|
12 | #if defined key_agrif |
---|
13 | !DIR$ OPTIMIZE:1 |
---|
14 | #endif |
---|
15 | !!---------------------------------------------------------------------- |
---|
16 | !! rot_rep : Rotate the Repere: geographic grid <==> stretched coordinates grid |
---|
17 | !! angle : |
---|
18 | !! geo2oce : |
---|
19 | !! oce2geo : |
---|
20 | !!---------------------------------------------------------------------- |
---|
21 | USE dom_oce ! mesh and scale factors |
---|
22 | USE phycst ! physical constants |
---|
23 | ! |
---|
24 | USE in_out_manager ! I/O manager |
---|
25 | USE lbclnk ! ocean lateral boundary conditions (or mpp link) |
---|
26 | USE lib_mpp ! MPP library |
---|
27 | |
---|
28 | IMPLICIT NONE |
---|
29 | PRIVATE |
---|
30 | |
---|
31 | PUBLIC rot_rep ! called in sbccpl, fldread, and cyclone |
---|
32 | PUBLIC geo2oce ! called in sbccpl |
---|
33 | PUBLIC oce2geo ! called in sbccpl |
---|
34 | PUBLIC obs_rot ! called in obs_rot_vel and obs_write |
---|
35 | |
---|
36 | ! ! cos/sin between model grid lines and NP direction |
---|
37 | REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: gsint, gcost ! at T point |
---|
38 | REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: gsinu, gcosu ! at U point |
---|
39 | REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: gsinv, gcosv ! at V point |
---|
40 | REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: gsinf, gcosf ! at F point |
---|
41 | |
---|
42 | LOGICAL , SAVE, DIMENSION(4) :: linit = .FALSE. |
---|
43 | REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: gsinlon, gcoslon, gsinlat, gcoslat |
---|
44 | |
---|
45 | LOGICAL :: lmust_init = .TRUE. !: used to initialize the cos/sin variables (see above) |
---|
46 | |
---|
47 | !! * Substitutions |
---|
48 | # include "vectopt_loop_substitute.h90" |
---|
49 | !!---------------------------------------------------------------------- |
---|
50 | !! NEMO/OPA 3.3 , NEMO Consortium (2010) |
---|
51 | !! $Id$ |
---|
52 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
53 | !!---------------------------------------------------------------------- |
---|
54 | CONTAINS |
---|
55 | |
---|
56 | SUBROUTINE rot_rep ( pxin, pyin, cd_type, cdtodo, prot ) |
---|
57 | !!---------------------------------------------------------------------- |
---|
58 | !! *** ROUTINE rot_rep *** |
---|
59 | !! |
---|
60 | !! ** Purpose : Rotate the Repere: Change vector componantes between |
---|
61 | !! geographic grid <--> stretched coordinates grid. |
---|
62 | !!---------------------------------------------------------------------- |
---|
63 | REAL(wp), DIMENSION(jpi,jpj), INTENT(in ) :: pxin, pyin ! vector componantes |
---|
64 | CHARACTER(len=1), INTENT(in ) :: cd_type ! define the nature of pt2d array grid-points |
---|
65 | CHARACTER(len=5), INTENT(in ) :: cdtodo ! type of transpormation: |
---|
66 | ! ! 'en->i' = east-north to i-component |
---|
67 | ! ! 'en->j' = east-north to j-component |
---|
68 | ! ! 'ij->e' = (i,j) components to east |
---|
69 | ! ! 'ij->n' = (i,j) components to north |
---|
70 | REAL(wp), DIMENSION(jpi,jpj), INTENT( out) :: prot |
---|
71 | !!---------------------------------------------------------------------- |
---|
72 | ! |
---|
73 | IF( lmust_init ) THEN ! at 1st call only: set gsin. & gcos. |
---|
74 | IF(lwp) WRITE(numout,*) |
---|
75 | IF(lwp) WRITE(numout,*) ' rot_rep: coordinate transformation : geographic <==> model (i,j)-components' |
---|
76 | IF(lwp) WRITE(numout,*) ' ~~~~~~~~ ' |
---|
77 | ! |
---|
78 | CALL angle ! initialization of the transformation |
---|
79 | lmust_init = .FALSE. |
---|
80 | ENDIF |
---|
81 | ! |
---|
82 | SELECT CASE( cdtodo ) ! type of rotation |
---|
83 | ! |
---|
84 | CASE( 'en->i' ) ! east-north to i-component |
---|
85 | SELECT CASE (cd_type) |
---|
86 | CASE ('T') ; prot(:,:) = pxin(:,:) * gcost(:,:) + pyin(:,:) * gsint(:,:) |
---|
87 | CASE ('U') ; prot(:,:) = pxin(:,:) * gcosu(:,:) + pyin(:,:) * gsinu(:,:) |
---|
88 | CASE ('V') ; prot(:,:) = pxin(:,:) * gcosv(:,:) + pyin(:,:) * gsinv(:,:) |
---|
89 | CASE ('F') ; prot(:,:) = pxin(:,:) * gcosf(:,:) + pyin(:,:) * gsinf(:,:) |
---|
90 | CASE DEFAULT ; CALL ctl_stop( 'Only T, U, V and F grid points are coded' ) |
---|
91 | END SELECT |
---|
92 | CASE ('en->j') ! east-north to j-component |
---|
93 | SELECT CASE (cd_type) |
---|
94 | CASE ('T') ; prot(:,:) = pyin(:,:) * gcost(:,:) - pxin(:,:) * gsint(:,:) |
---|
95 | CASE ('U') ; prot(:,:) = pyin(:,:) * gcosu(:,:) - pxin(:,:) * gsinu(:,:) |
---|
96 | CASE ('V') ; prot(:,:) = pyin(:,:) * gcosv(:,:) - pxin(:,:) * gsinv(:,:) |
---|
97 | CASE ('F') ; prot(:,:) = pyin(:,:) * gcosf(:,:) - pxin(:,:) * gsinf(:,:) |
---|
98 | CASE DEFAULT ; CALL ctl_stop( 'Only T, U, V and F grid points are coded' ) |
---|
99 | END SELECT |
---|
100 | CASE ('ij->e') ! (i,j)-components to east |
---|
101 | SELECT CASE (cd_type) |
---|
102 | CASE ('T') ; prot(:,:) = pxin(:,:) * gcost(:,:) - pyin(:,:) * gsint(:,:) |
---|
103 | CASE ('U') ; prot(:,:) = pxin(:,:) * gcosu(:,:) - pyin(:,:) * gsinu(:,:) |
---|
104 | CASE ('V') ; prot(:,:) = pxin(:,:) * gcosv(:,:) - pyin(:,:) * gsinv(:,:) |
---|
105 | CASE ('F') ; prot(:,:) = pxin(:,:) * gcosf(:,:) - pyin(:,:) * gsinf(:,:) |
---|
106 | CASE DEFAULT ; CALL ctl_stop( 'Only T, U, V and F grid points are coded' ) |
---|
107 | END SELECT |
---|
108 | CASE ('ij->n') ! (i,j)-components to north |
---|
109 | SELECT CASE (cd_type) |
---|
110 | CASE ('T') ; prot(:,:) = pyin(:,:) * gcost(:,:) + pxin(:,:) * gsint(:,:) |
---|
111 | CASE ('U') ; prot(:,:) = pyin(:,:) * gcosu(:,:) + pxin(:,:) * gsinu(:,:) |
---|
112 | CASE ('V') ; prot(:,:) = pyin(:,:) * gcosv(:,:) + pxin(:,:) * gsinv(:,:) |
---|
113 | CASE ('F') ; prot(:,:) = pyin(:,:) * gcosf(:,:) + pxin(:,:) * gsinf(:,:) |
---|
114 | CASE DEFAULT ; CALL ctl_stop( 'Only T, U, V and F grid points are coded' ) |
---|
115 | END SELECT |
---|
116 | CASE DEFAULT ; CALL ctl_stop( 'rot_rep: Syntax Error in the definition of cdtodo' ) |
---|
117 | ! |
---|
118 | END SELECT |
---|
119 | ! |
---|
120 | END SUBROUTINE rot_rep |
---|
121 | |
---|
122 | |
---|
123 | SUBROUTINE angle |
---|
124 | !!---------------------------------------------------------------------- |
---|
125 | !! *** ROUTINE angle *** |
---|
126 | !! |
---|
127 | !! ** Purpose : Compute angles between model grid lines and the North direction |
---|
128 | !! |
---|
129 | !! ** Method : sinus and cosinus of the angle between the north-south axe |
---|
130 | !! and the j-direction at t, u, v and f-points |
---|
131 | !! dot and cross products are used to obtain cos and sin, resp. |
---|
132 | !! |
---|
133 | !! ** Action : - gsint, gcost, gsinu, gcosu, gsinv, gcosv, gsinf, gcosf |
---|
134 | !!---------------------------------------------------------------------- |
---|
135 | INTEGER :: ji, jj ! dummy loop indices |
---|
136 | INTEGER :: ierr ! local integer |
---|
137 | REAL(wp) :: zlam, zphi ! local scalars |
---|
138 | REAL(wp) :: zlan, zphh ! - - |
---|
139 | REAL(wp) :: zxnpt, zynpt, znnpt ! x,y components and norm of the vector: T point to North Pole |
---|
140 | REAL(wp) :: zxnpu, zynpu, znnpu ! x,y components and norm of the vector: U point to North Pole |
---|
141 | REAL(wp) :: zxnpv, zynpv, znnpv ! x,y components and norm of the vector: V point to North Pole |
---|
142 | REAL(wp) :: zxnpf, zynpf, znnpf ! x,y components and norm of the vector: F point to North Pole |
---|
143 | REAL(wp) :: zxvvt, zyvvt, znvvt ! x,y components and norm of the vector: between V points below and above a T point |
---|
144 | REAL(wp) :: zxffu, zyffu, znffu ! x,y components and norm of the vector: between F points below and above a U point |
---|
145 | REAL(wp) :: zxffv, zyffv, znffv ! x,y components and norm of the vector: between F points left and right a V point |
---|
146 | REAL(wp) :: zxuuf, zyuuf, znuuf ! x,y components and norm of the vector: between U points below and above a F point |
---|
147 | !!---------------------------------------------------------------------- |
---|
148 | ! |
---|
149 | ALLOCATE( gsint(jpi,jpj), gcost(jpi,jpj), & |
---|
150 | & gsinu(jpi,jpj), gcosu(jpi,jpj), & |
---|
151 | & gsinv(jpi,jpj), gcosv(jpi,jpj), & |
---|
152 | & gsinf(jpi,jpj), gcosf(jpi,jpj), STAT=ierr ) |
---|
153 | IF(lk_mpp) CALL mpp_sum( ierr ) |
---|
154 | IF( ierr /= 0 ) CALL ctl_stop( 'angle: unable to allocate arrays' ) |
---|
155 | ! |
---|
156 | ! ============================= ! |
---|
157 | ! Compute the cosinus and sinus ! |
---|
158 | ! ============================= ! |
---|
159 | ! (computation done on the north stereographic polar plane) |
---|
160 | ! |
---|
161 | DO jj = 2, jpjm1 |
---|
162 | DO ji = fs_2, jpi ! vector opt. |
---|
163 | ! |
---|
164 | zlam = glamt(ji,jj) ! north pole direction & modulous (at t-point) |
---|
165 | zphi = gphit(ji,jj) |
---|
166 | zxnpt = 0. - 2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) |
---|
167 | zynpt = 0. - 2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) |
---|
168 | znnpt = zxnpt*zxnpt + zynpt*zynpt |
---|
169 | ! |
---|
170 | zlam = glamu(ji,jj) ! north pole direction & modulous (at u-point) |
---|
171 | zphi = gphiu(ji,jj) |
---|
172 | zxnpu = 0. - 2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) |
---|
173 | zynpu = 0. - 2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) |
---|
174 | znnpu = zxnpu*zxnpu + zynpu*zynpu |
---|
175 | ! |
---|
176 | zlam = glamv(ji,jj) ! north pole direction & modulous (at v-point) |
---|
177 | zphi = gphiv(ji,jj) |
---|
178 | zxnpv = 0. - 2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) |
---|
179 | zynpv = 0. - 2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) |
---|
180 | znnpv = zxnpv*zxnpv + zynpv*zynpv |
---|
181 | ! |
---|
182 | zlam = glamf(ji,jj) ! north pole direction & modulous (at f-point) |
---|
183 | zphi = gphif(ji,jj) |
---|
184 | zxnpf = 0. - 2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) |
---|
185 | zynpf = 0. - 2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) |
---|
186 | znnpf = zxnpf*zxnpf + zynpf*zynpf |
---|
187 | ! |
---|
188 | zlam = glamv(ji,jj ) ! j-direction: v-point segment direction (around t-point) |
---|
189 | zphi = gphiv(ji,jj ) |
---|
190 | zlan = glamv(ji,jj-1) |
---|
191 | zphh = gphiv(ji,jj-1) |
---|
192 | zxvvt = 2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) & |
---|
193 | & - 2. * COS( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. ) |
---|
194 | zyvvt = 2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) & |
---|
195 | & - 2. * SIN( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. ) |
---|
196 | znvvt = SQRT( znnpt * ( zxvvt*zxvvt + zyvvt*zyvvt ) ) |
---|
197 | znvvt = MAX( znvvt, 1.e-14 ) |
---|
198 | ! |
---|
199 | zlam = glamf(ji,jj ) ! j-direction: f-point segment direction (around u-point) |
---|
200 | zphi = gphif(ji,jj ) |
---|
201 | zlan = glamf(ji,jj-1) |
---|
202 | zphh = gphif(ji,jj-1) |
---|
203 | zxffu = 2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) & |
---|
204 | & - 2. * COS( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. ) |
---|
205 | zyffu = 2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) & |
---|
206 | & - 2. * SIN( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. ) |
---|
207 | znffu = SQRT( znnpu * ( zxffu*zxffu + zyffu*zyffu ) ) |
---|
208 | znffu = MAX( znffu, 1.e-14 ) |
---|
209 | ! |
---|
210 | zlam = glamf(ji ,jj) ! i-direction: f-point segment direction (around v-point) |
---|
211 | zphi = gphif(ji ,jj) |
---|
212 | zlan = glamf(ji-1,jj) |
---|
213 | zphh = gphif(ji-1,jj) |
---|
214 | zxffv = 2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) & |
---|
215 | & - 2. * COS( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. ) |
---|
216 | zyffv = 2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) & |
---|
217 | & - 2. * SIN( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. ) |
---|
218 | znffv = SQRT( znnpv * ( zxffv*zxffv + zyffv*zyffv ) ) |
---|
219 | znffv = MAX( znffv, 1.e-14 ) |
---|
220 | ! |
---|
221 | zlam = glamu(ji,jj+1) ! j-direction: u-point segment direction (around f-point) |
---|
222 | zphi = gphiu(ji,jj+1) |
---|
223 | zlan = glamu(ji,jj ) |
---|
224 | zphh = gphiu(ji,jj ) |
---|
225 | zxuuf = 2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) & |
---|
226 | & - 2. * COS( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. ) |
---|
227 | zyuuf = 2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) & |
---|
228 | & - 2. * SIN( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. ) |
---|
229 | znuuf = SQRT( znnpf * ( zxuuf*zxuuf + zyuuf*zyuuf ) ) |
---|
230 | znuuf = MAX( znuuf, 1.e-14 ) |
---|
231 | ! |
---|
232 | ! ! cosinus and sinus using dot and cross products |
---|
233 | gsint(ji,jj) = ( zxnpt*zyvvt - zynpt*zxvvt ) / znvvt |
---|
234 | gcost(ji,jj) = ( zxnpt*zxvvt + zynpt*zyvvt ) / znvvt |
---|
235 | ! |
---|
236 | gsinu(ji,jj) = ( zxnpu*zyffu - zynpu*zxffu ) / znffu |
---|
237 | gcosu(ji,jj) = ( zxnpu*zxffu + zynpu*zyffu ) / znffu |
---|
238 | ! |
---|
239 | gsinf(ji,jj) = ( zxnpf*zyuuf - zynpf*zxuuf ) / znuuf |
---|
240 | gcosf(ji,jj) = ( zxnpf*zxuuf + zynpf*zyuuf ) / znuuf |
---|
241 | ! |
---|
242 | gsinv(ji,jj) = ( zxnpv*zxffv + zynpv*zyffv ) / znffv |
---|
243 | gcosv(ji,jj) =-( zxnpv*zyffv - zynpv*zxffv ) / znffv ! (caution, rotation of 90 degres) |
---|
244 | ! |
---|
245 | END DO |
---|
246 | END DO |
---|
247 | |
---|
248 | ! =============== ! |
---|
249 | ! Geographic mesh ! |
---|
250 | ! =============== ! |
---|
251 | |
---|
252 | DO jj = 2, jpjm1 |
---|
253 | DO ji = fs_2, jpi ! vector opt. |
---|
254 | IF( MOD( ABS( glamv(ji,jj) - glamv(ji,jj-1) ), 360. ) < 1.e-8 ) THEN |
---|
255 | gsint(ji,jj) = 0. |
---|
256 | gcost(ji,jj) = 1. |
---|
257 | ENDIF |
---|
258 | IF( MOD( ABS( glamf(ji,jj) - glamf(ji,jj-1) ), 360. ) < 1.e-8 ) THEN |
---|
259 | gsinu(ji,jj) = 0. |
---|
260 | gcosu(ji,jj) = 1. |
---|
261 | ENDIF |
---|
262 | IF( ABS( gphif(ji,jj) - gphif(ji-1,jj) ) < 1.e-8 ) THEN |
---|
263 | gsinv(ji,jj) = 0. |
---|
264 | gcosv(ji,jj) = 1. |
---|
265 | ENDIF |
---|
266 | IF( MOD( ABS( glamu(ji,jj) - glamu(ji,jj+1) ), 360. ) < 1.e-8 ) THEN |
---|
267 | gsinf(ji,jj) = 0. |
---|
268 | gcosf(ji,jj) = 1. |
---|
269 | ENDIF |
---|
270 | END DO |
---|
271 | END DO |
---|
272 | |
---|
273 | ! =========================== ! |
---|
274 | ! Lateral boundary conditions ! |
---|
275 | ! =========================== ! |
---|
276 | ! ! lateral boundary cond.: T-, U-, V-, F-pts, sgn |
---|
277 | CALL lbc_lnk_multi( gcost, 'T', -1., gsint, 'T', -1., gcosu, 'U', -1., gsinu, 'U', -1., & |
---|
278 | & gcosv, 'V', -1., gsinv, 'V', -1., gcosf, 'F', -1., gsinf, 'F', -1. ) |
---|
279 | ! |
---|
280 | END SUBROUTINE angle |
---|
281 | |
---|
282 | |
---|
283 | SUBROUTINE geo2oce ( pxx, pyy, pzz, cgrid, pte, ptn ) |
---|
284 | !!---------------------------------------------------------------------- |
---|
285 | !! *** ROUTINE geo2oce *** |
---|
286 | !! |
---|
287 | !! ** Purpose : |
---|
288 | !! |
---|
289 | !! ** Method : Change a vector from geocentric to east/north |
---|
290 | !! |
---|
291 | !!---------------------------------------------------------------------- |
---|
292 | REAL(wp), DIMENSION(jpi,jpj), INTENT(in ) :: pxx, pyy, pzz |
---|
293 | CHARACTER(len=1) , INTENT(in ) :: cgrid |
---|
294 | REAL(wp), DIMENSION(jpi,jpj), INTENT( out) :: pte, ptn |
---|
295 | ! |
---|
296 | REAL(wp), PARAMETER :: rpi = 3.141592653e0 |
---|
297 | REAL(wp), PARAMETER :: rad = rpi / 180.e0 |
---|
298 | INTEGER :: ig ! |
---|
299 | INTEGER :: ierr ! local integer |
---|
300 | !!---------------------------------------------------------------------- |
---|
301 | ! |
---|
302 | IF( .NOT. ALLOCATED( gsinlon ) ) THEN |
---|
303 | ALLOCATE( gsinlon(jpi,jpj,4) , gcoslon(jpi,jpj,4) , & |
---|
304 | & gsinlat(jpi,jpj,4) , gcoslat(jpi,jpj,4) , STAT=ierr ) |
---|
305 | IF( lk_mpp ) CALL mpp_sum( ierr ) |
---|
306 | IF( ierr /= 0 ) CALL ctl_stop('geo2oce: unable to allocate arrays' ) |
---|
307 | ENDIF |
---|
308 | ! |
---|
309 | SELECT CASE( cgrid) |
---|
310 | CASE ( 'T' ) |
---|
311 | ig = 1 |
---|
312 | IF( .NOT. linit(ig) ) THEN |
---|
313 | gsinlon(:,:,ig) = SIN( rad * glamt(:,:) ) |
---|
314 | gcoslon(:,:,ig) = COS( rad * glamt(:,:) ) |
---|
315 | gsinlat(:,:,ig) = SIN( rad * gphit(:,:) ) |
---|
316 | gcoslat(:,:,ig) = COS( rad * gphit(:,:) ) |
---|
317 | linit(ig) = .TRUE. |
---|
318 | ENDIF |
---|
319 | CASE ( 'U' ) |
---|
320 | ig = 2 |
---|
321 | IF( .NOT. linit(ig) ) THEN |
---|
322 | gsinlon(:,:,ig) = SIN( rad * glamu(:,:) ) |
---|
323 | gcoslon(:,:,ig) = COS( rad * glamu(:,:) ) |
---|
324 | gsinlat(:,:,ig) = SIN( rad * gphiu(:,:) ) |
---|
325 | gcoslat(:,:,ig) = COS( rad * gphiu(:,:) ) |
---|
326 | linit(ig) = .TRUE. |
---|
327 | ENDIF |
---|
328 | CASE ( 'V' ) |
---|
329 | ig = 3 |
---|
330 | IF( .NOT. linit(ig) ) THEN |
---|
331 | gsinlon(:,:,ig) = SIN( rad * glamv(:,:) ) |
---|
332 | gcoslon(:,:,ig) = COS( rad * glamv(:,:) ) |
---|
333 | gsinlat(:,:,ig) = SIN( rad * gphiv(:,:) ) |
---|
334 | gcoslat(:,:,ig) = COS( rad * gphiv(:,:) ) |
---|
335 | linit(ig) = .TRUE. |
---|
336 | ENDIF |
---|
337 | CASE ( 'F' ) |
---|
338 | ig = 4 |
---|
339 | IF( .NOT. linit(ig) ) THEN |
---|
340 | gsinlon(:,:,ig) = SIN( rad * glamf(:,:) ) |
---|
341 | gcoslon(:,:,ig) = COS( rad * glamf(:,:) ) |
---|
342 | gsinlat(:,:,ig) = SIN( rad * gphif(:,:) ) |
---|
343 | gcoslat(:,:,ig) = COS( rad * gphif(:,:) ) |
---|
344 | linit(ig) = .TRUE. |
---|
345 | ENDIF |
---|
346 | CASE default |
---|
347 | WRITE(ctmp1,*) 'geo2oce : bad grid argument : ', cgrid |
---|
348 | CALL ctl_stop( ctmp1 ) |
---|
349 | END SELECT |
---|
350 | ! |
---|
351 | pte = - gsinlon(:,:,ig) * pxx + gcoslon(:,:,ig) * pyy |
---|
352 | ptn = - gcoslon(:,:,ig) * gsinlat(:,:,ig) * pxx & |
---|
353 | & - gsinlon(:,:,ig) * gsinlat(:,:,ig) * pyy & |
---|
354 | & + gcoslat(:,:,ig) * pzz |
---|
355 | ! |
---|
356 | END SUBROUTINE geo2oce |
---|
357 | |
---|
358 | |
---|
359 | SUBROUTINE oce2geo ( pte, ptn, cgrid, pxx , pyy , pzz ) |
---|
360 | !!---------------------------------------------------------------------- |
---|
361 | !! *** ROUTINE oce2geo *** |
---|
362 | !! |
---|
363 | !! ** Purpose : |
---|
364 | !! |
---|
365 | !! ** Method : Change vector from east/north to geocentric |
---|
366 | !! |
---|
367 | !! History : ! (A. Caubel) oce2geo - Original code |
---|
368 | !!---------------------------------------------------------------------- |
---|
369 | REAL(wp), DIMENSION(jpi,jpj), INTENT( IN ) :: pte, ptn |
---|
370 | CHARACTER(len=1) , INTENT( IN ) :: cgrid |
---|
371 | REAL(wp), DIMENSION(jpi,jpj), INTENT( OUT ) :: pxx , pyy , pzz |
---|
372 | !! |
---|
373 | REAL(wp), PARAMETER :: rpi = 3.141592653E0 |
---|
374 | REAL(wp), PARAMETER :: rad = rpi / 180.e0 |
---|
375 | INTEGER :: ig ! |
---|
376 | INTEGER :: ierr ! local integer |
---|
377 | !!---------------------------------------------------------------------- |
---|
378 | |
---|
379 | IF( .NOT. ALLOCATED( gsinlon ) ) THEN |
---|
380 | ALLOCATE( gsinlon(jpi,jpj,4) , gcoslon(jpi,jpj,4) , & |
---|
381 | & gsinlat(jpi,jpj,4) , gcoslat(jpi,jpj,4) , STAT=ierr ) |
---|
382 | IF( lk_mpp ) CALL mpp_sum( ierr ) |
---|
383 | IF( ierr /= 0 ) CALL ctl_stop('oce2geo: unable to allocate arrays' ) |
---|
384 | ENDIF |
---|
385 | |
---|
386 | SELECT CASE( cgrid) |
---|
387 | CASE ( 'T' ) |
---|
388 | ig = 1 |
---|
389 | IF( .NOT. linit(ig) ) THEN |
---|
390 | gsinlon(:,:,ig) = SIN( rad * glamt(:,:) ) |
---|
391 | gcoslon(:,:,ig) = COS( rad * glamt(:,:) ) |
---|
392 | gsinlat(:,:,ig) = SIN( rad * gphit(:,:) ) |
---|
393 | gcoslat(:,:,ig) = COS( rad * gphit(:,:) ) |
---|
394 | linit(ig) = .TRUE. |
---|
395 | ENDIF |
---|
396 | CASE ( 'U' ) |
---|
397 | ig = 2 |
---|
398 | IF( .NOT. linit(ig) ) THEN |
---|
399 | gsinlon(:,:,ig) = SIN( rad * glamu(:,:) ) |
---|
400 | gcoslon(:,:,ig) = COS( rad * glamu(:,:) ) |
---|
401 | gsinlat(:,:,ig) = SIN( rad * gphiu(:,:) ) |
---|
402 | gcoslat(:,:,ig) = COS( rad * gphiu(:,:) ) |
---|
403 | linit(ig) = .TRUE. |
---|
404 | ENDIF |
---|
405 | CASE ( 'V' ) |
---|
406 | ig = 3 |
---|
407 | IF( .NOT. linit(ig) ) THEN |
---|
408 | gsinlon(:,:,ig) = SIN( rad * glamv(:,:) ) |
---|
409 | gcoslon(:,:,ig) = COS( rad * glamv(:,:) ) |
---|
410 | gsinlat(:,:,ig) = SIN( rad * gphiv(:,:) ) |
---|
411 | gcoslat(:,:,ig) = COS( rad * gphiv(:,:) ) |
---|
412 | linit(ig) = .TRUE. |
---|
413 | ENDIF |
---|
414 | CASE ( 'F' ) |
---|
415 | ig = 4 |
---|
416 | IF( .NOT. linit(ig) ) THEN |
---|
417 | gsinlon(:,:,ig) = SIN( rad * glamf(:,:) ) |
---|
418 | gcoslon(:,:,ig) = COS( rad * glamf(:,:) ) |
---|
419 | gsinlat(:,:,ig) = SIN( rad * gphif(:,:) ) |
---|
420 | gcoslat(:,:,ig) = COS( rad * gphif(:,:) ) |
---|
421 | linit(ig) = .TRUE. |
---|
422 | ENDIF |
---|
423 | CASE default |
---|
424 | WRITE(ctmp1,*) 'geo2oce : bad grid argument : ', cgrid |
---|
425 | CALL ctl_stop( ctmp1 ) |
---|
426 | END SELECT |
---|
427 | ! |
---|
428 | pxx = - gsinlon(:,:,ig) * pte - gcoslon(:,:,ig) * gsinlat(:,:,ig) * ptn |
---|
429 | pyy = gcoslon(:,:,ig) * pte - gsinlon(:,:,ig) * gsinlat(:,:,ig) * ptn |
---|
430 | pzz = gcoslat(:,:,ig) * ptn |
---|
431 | ! |
---|
432 | END SUBROUTINE oce2geo |
---|
433 | |
---|
434 | |
---|
435 | SUBROUTINE obs_rot( psinu, pcosu, psinv, pcosv ) |
---|
436 | !!---------------------------------------------------------------------- |
---|
437 | !! *** ROUTINE obs_rot *** |
---|
438 | !! |
---|
439 | !! ** Purpose : Copy gsinu, gcosu, gsinv and gsinv |
---|
440 | !! to input data for rotations of |
---|
441 | !! current at observation points |
---|
442 | !! |
---|
443 | !! History : 9.2 ! 09-02 (K. Mogensen) |
---|
444 | !!---------------------------------------------------------------------- |
---|
445 | REAL(wp), DIMENSION(jpi,jpj), INTENT( OUT ):: psinu, pcosu, psinv, pcosv ! copy of data |
---|
446 | !!---------------------------------------------------------------------- |
---|
447 | ! |
---|
448 | ! Initialization of gsin* and gcos* at first call |
---|
449 | ! ----------------------------------------------- |
---|
450 | IF( lmust_init ) THEN |
---|
451 | IF(lwp) WRITE(numout,*) |
---|
452 | IF(lwp) WRITE(numout,*) ' obs_rot : geographic <--> stretched' |
---|
453 | IF(lwp) WRITE(numout,*) ' ~~~~~~~ coordinate transformation' |
---|
454 | CALL angle ! initialization of the transformation |
---|
455 | lmust_init = .FALSE. |
---|
456 | ENDIF |
---|
457 | ! |
---|
458 | psinu(:,:) = gsinu(:,:) |
---|
459 | pcosu(:,:) = gcosu(:,:) |
---|
460 | psinv(:,:) = gsinv(:,:) |
---|
461 | pcosv(:,:) = gcosv(:,:) |
---|
462 | ! |
---|
463 | END SUBROUTINE obs_rot |
---|
464 | |
---|
465 | !!====================================================================== |
---|
466 | END MODULE geo2ocean |
---|