New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
geo2ocean.F90 in NEMO/branches/UKMO/r8395_coupling_sequence/NEMOGCM/NEMO/OPA_SRC/SBC – NEMO

source: NEMO/branches/UKMO/r8395_coupling_sequence/NEMOGCM/NEMO/OPA_SRC/SBC/geo2ocean.F90 @ 10761

Last change on this file since 10761 was 10761, checked in by jcastill, 5 years ago

Remove svn keys

File size: 21.9 KB
Line 
1MODULE 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
13   !!----------------------------------------------------------------------
14   !!   rot_rep       : Rotate the Repere: geographic grid <==> stretched coordinates grid
15   !!   angle         :
16   !!   geo2oce       :
17   !!   oce2geo       :
18   !!----------------------------------------------------------------------
19   USE dom_oce        ! mesh and scale factors
20   USE phycst         ! physical constants
21   !
22   USE in_out_manager ! I/O manager
23   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
24   USE lib_mpp        ! MPP library
25
26   IMPLICIT NONE
27   PRIVATE
28
29   PUBLIC   rot_rep   ! called in sbccpl, fldread, and cyclone
30   PUBLIC   geo2oce   ! called in sbccpl
31   PUBLIC   oce2geo   ! called in sbccpl
32   PUBLIC   obs_rot   ! called in obs_rot_vel and obs_write
33
34   !                                         ! cos/sin between model grid lines and NP direction
35   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   gsint, gcost   ! at T point
36   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   gsinu, gcosu   ! at U point
37   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   gsinv, gcosv   ! at V point
38   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   gsinf, gcosf   ! at F point
39
40   LOGICAL ,              SAVE, DIMENSION(4)     ::   linit = .FALSE.
41   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   gsinlon, gcoslon, gsinlat, gcoslat
42
43   LOGICAL ::   lmust_init = .TRUE.        !: used to initialize the cos/sin variables (see above)
44
45   !! * Substitutions
46#  include "vectopt_loop_substitute.h90"
47   !!----------------------------------------------------------------------
48   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
49   !! $Id$
50   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
51   !!----------------------------------------------------------------------
52CONTAINS
53
54   SUBROUTINE rot_rep ( pxin, pyin, cd_type, cdtodo, prot )
55      !!----------------------------------------------------------------------
56      !!                  ***  ROUTINE rot_rep  ***
57      !!
58      !! ** Purpose :   Rotate the Repere: Change vector componantes between
59      !!                geographic grid <--> stretched coordinates grid.
60      !!----------------------------------------------------------------------
61      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   pxin, pyin   ! vector componantes
62      CHARACTER(len=1),             INTENT(in   ) ::   cd_type      ! define the nature of pt2d array grid-points
63      CHARACTER(len=5),             INTENT(in   ) ::   cdtodo       ! type of transpormation:
64      !                                                             ! 'en->i' = east-north to i-component
65      !                                                             ! 'en->j' = east-north to j-component
66      !                                                             ! 'ij->e' = (i,j) components to east
67      !                                                             ! 'ij->n' = (i,j) components to north
68      REAL(wp), DIMENSION(jpi,jpj), INTENT(  out) ::   prot     
69      !!----------------------------------------------------------------------
70      !
71      IF( lmust_init ) THEN      ! at 1st call only: set  gsin. & gcos.
72         IF(lwp) WRITE(numout,*)
73         IF(lwp) WRITE(numout,*) ' rot_rep: coordinate transformation : geographic <==> model (i,j)-components'
74         IF(lwp) WRITE(numout,*) ' ~~~~~~~~    '
75         !
76         CALL angle       ! initialization of the transformation
77         lmust_init = .FALSE.
78      ENDIF
79      !
80      SELECT CASE( cdtodo )      ! type of rotation
81      !
82      CASE( 'en->i' )                  ! east-north to i-component
83         SELECT CASE (cd_type)
84         CASE ('T')   ;   prot(:,:) = pxin(:,:) * gcost(:,:) + pyin(:,:) * gsint(:,:)
85         CASE ('U')   ;   prot(:,:) = pxin(:,:) * gcosu(:,:) + pyin(:,:) * gsinu(:,:)
86         CASE ('V')   ;   prot(:,:) = pxin(:,:) * gcosv(:,:) + pyin(:,:) * gsinv(:,:)
87         CASE ('F')   ;   prot(:,:) = pxin(:,:) * gcosf(:,:) + pyin(:,:) * gsinf(:,:)
88         CASE DEFAULT   ;   CALL ctl_stop( 'Only T, U, V and F grid points are coded' )
89         END SELECT
90      CASE ('en->j')                   ! east-north to j-component
91         SELECT CASE (cd_type)
92         CASE ('T')   ;   prot(:,:) = pyin(:,:) * gcost(:,:) - pxin(:,:) * gsint(:,:)
93         CASE ('U')   ;   prot(:,:) = pyin(:,:) * gcosu(:,:) - pxin(:,:) * gsinu(:,:)
94         CASE ('V')   ;   prot(:,:) = pyin(:,:) * gcosv(:,:) - pxin(:,:) * gsinv(:,:)   
95         CASE ('F')   ;   prot(:,:) = pyin(:,:) * gcosf(:,:) - pxin(:,:) * gsinf(:,:)   
96         CASE DEFAULT   ;   CALL ctl_stop( 'Only T, U, V and F grid points are coded' )
97         END SELECT
98      CASE ('ij->e')                   ! (i,j)-components to east
99         SELECT CASE (cd_type)
100         CASE ('T')   ;   prot(:,:) = pxin(:,:) * gcost(:,:) - pyin(:,:) * gsint(:,:)
101         CASE ('U')   ;   prot(:,:) = pxin(:,:) * gcosu(:,:) - pyin(:,:) * gsinu(:,:)
102         CASE ('V')   ;   prot(:,:) = pxin(:,:) * gcosv(:,:) - pyin(:,:) * gsinv(:,:)
103         CASE ('F')   ;   prot(:,:) = pxin(:,:) * gcosf(:,:) - pyin(:,:) * gsinf(:,:)
104         CASE DEFAULT   ;   CALL ctl_stop( 'Only T, U, V and F grid points are coded' )
105         END SELECT
106      CASE ('ij->n')                   ! (i,j)-components to north
107         SELECT CASE (cd_type)
108         CASE ('T')   ;   prot(:,:) = pyin(:,:) * gcost(:,:) + pxin(:,:) * gsint(:,:)
109         CASE ('U')   ;   prot(:,:) = pyin(:,:) * gcosu(:,:) + pxin(:,:) * gsinu(:,:)
110         CASE ('V')   ;   prot(:,:) = pyin(:,:) * gcosv(:,:) + pxin(:,:) * gsinv(:,:)
111         CASE ('F')   ;   prot(:,:) = pyin(:,:) * gcosf(:,:) + pxin(:,:) * gsinf(:,:)
112         CASE DEFAULT   ;   CALL ctl_stop( 'Only T, U, V and F grid points are coded' )
113         END SELECT
114      CASE DEFAULT   ;   CALL ctl_stop( 'rot_rep: Syntax Error in the definition of cdtodo' )
115      !
116      END SELECT
117      !
118   END SUBROUTINE rot_rep
119
120
121   SUBROUTINE angle
122      !!----------------------------------------------------------------------
123      !!                  ***  ROUTINE angle  ***
124      !!
125      !! ** Purpose :   Compute angles between model grid lines and the North direction
126      !!
127      !! ** Method  :   sinus and cosinus of the angle between the north-south axe
128      !!              and the j-direction at t, u, v and f-points
129      !!                dot and cross products are used to obtain cos and sin, resp.
130      !!
131      !! ** Action  : - gsint, gcost, gsinu, gcosu, gsinv, gcosv, gsinf, gcosf
132      !!----------------------------------------------------------------------
133      INTEGER  ::   ji, jj   ! dummy loop indices
134      INTEGER  ::   ierr     ! local integer
135      REAL(wp) ::   zlam, zphi            ! local scalars
136      REAL(wp) ::   zlan, zphh            !   -      -
137      REAL(wp) ::   zxnpt, zynpt, znnpt   ! x,y components and norm of the vector: T point to North Pole
138      REAL(wp) ::   zxnpu, zynpu, znnpu   ! x,y components and norm of the vector: U point to North Pole
139      REAL(wp) ::   zxnpv, zynpv, znnpv   ! x,y components and norm of the vector: V point to North Pole
140      REAL(wp) ::   zxnpf, zynpf, znnpf   ! x,y components and norm of the vector: F point to North Pole
141      REAL(wp) ::   zxvvt, zyvvt, znvvt   ! x,y components and norm of the vector: between V points below and above a T point
142      REAL(wp) ::   zxffu, zyffu, znffu   ! x,y components and norm of the vector: between F points below and above a U point
143      REAL(wp) ::   zxffv, zyffv, znffv   ! x,y components and norm of the vector: between F points left  and right a V point
144      REAL(wp) ::   zxuuf, zyuuf, znuuf   ! x,y components and norm of the vector: between U points below and above a F point
145      !!----------------------------------------------------------------------
146      !
147      ALLOCATE( gsint(jpi,jpj), gcost(jpi,jpj),   & 
148         &      gsinu(jpi,jpj), gcosu(jpi,jpj),   & 
149         &      gsinv(jpi,jpj), gcosv(jpi,jpj),   & 
150         &      gsinf(jpi,jpj), gcosf(jpi,jpj), STAT=ierr )
151      IF(lk_mpp)   CALL mpp_sum( ierr )
152      IF( ierr /= 0 )   CALL ctl_stop( 'angle: unable to allocate arrays' )
153      !
154      ! ============================= !
155      ! Compute the cosinus and sinus !
156      ! ============================= !
157      ! (computation done on the north stereographic polar plane)
158      !
159      DO jj = 2, jpjm1
160         DO ji = fs_2, jpi   ! vector opt.
161            !                 
162            zlam = glamt(ji,jj)     ! north pole direction & modulous (at t-point)
163            zphi = gphit(ji,jj)
164            zxnpt = 0. - 2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )
165            zynpt = 0. - 2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )
166            znnpt = zxnpt*zxnpt + zynpt*zynpt
167            !
168            zlam = glamu(ji,jj)     ! north pole direction & modulous (at u-point)
169            zphi = gphiu(ji,jj)
170            zxnpu = 0. - 2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )
171            zynpu = 0. - 2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )
172            znnpu = zxnpu*zxnpu + zynpu*zynpu
173            !
174            zlam = glamv(ji,jj)     ! north pole direction & modulous (at v-point)
175            zphi = gphiv(ji,jj)
176            zxnpv = 0. - 2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )
177            zynpv = 0. - 2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )
178            znnpv = zxnpv*zxnpv + zynpv*zynpv
179            !
180            zlam = glamf(ji,jj)     ! north pole direction & modulous (at f-point)
181            zphi = gphif(ji,jj)
182            zxnpf = 0. - 2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )
183            zynpf = 0. - 2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )
184            znnpf = zxnpf*zxnpf + zynpf*zynpf
185            !
186            zlam = glamv(ji,jj  )   ! j-direction: v-point segment direction (around t-point)
187            zphi = gphiv(ji,jj  )
188            zlan = glamv(ji,jj-1)
189            zphh = gphiv(ji,jj-1)
190            zxvvt =  2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )   &
191               &  -  2. * COS( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. )
192            zyvvt =  2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )   &
193               &  -  2. * SIN( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. )
194            znvvt = SQRT( znnpt * ( zxvvt*zxvvt + zyvvt*zyvvt )  )
195            znvvt = MAX( znvvt, 1.e-14 )
196            !
197            zlam = glamf(ji,jj  )   ! j-direction: f-point segment direction (around u-point)
198            zphi = gphif(ji,jj  )
199            zlan = glamf(ji,jj-1)
200            zphh = gphif(ji,jj-1)
201            zxffu =  2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )   &
202               &  -  2. * COS( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. )
203            zyffu =  2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )   &
204               &  -  2. * SIN( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. )
205            znffu = SQRT( znnpu * ( zxffu*zxffu + zyffu*zyffu )  )
206            znffu = MAX( znffu, 1.e-14 )
207            !
208            zlam = glamf(ji  ,jj)   ! i-direction: f-point segment direction (around v-point)
209            zphi = gphif(ji  ,jj)
210            zlan = glamf(ji-1,jj)
211            zphh = gphif(ji-1,jj)
212            zxffv =  2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )   &
213               &  -  2. * COS( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. )
214            zyffv =  2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )   &
215               &  -  2. * SIN( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. )
216            znffv = SQRT( znnpv * ( zxffv*zxffv + zyffv*zyffv )  )
217            znffv = MAX( znffv, 1.e-14 )
218            !
219            zlam = glamu(ji,jj+1)   ! j-direction: u-point segment direction (around f-point)
220            zphi = gphiu(ji,jj+1)
221            zlan = glamu(ji,jj  )
222            zphh = gphiu(ji,jj  )
223            zxuuf =  2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )   &
224               &  -  2. * COS( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. )
225            zyuuf =  2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. )   &
226               &  -  2. * SIN( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. )
227            znuuf = SQRT( znnpf * ( zxuuf*zxuuf + zyuuf*zyuuf )  )
228            znuuf = MAX( znuuf, 1.e-14 )
229            !
230            !                       ! cosinus and sinus using dot and cross products
231            gsint(ji,jj) = ( zxnpt*zyvvt - zynpt*zxvvt ) / znvvt
232            gcost(ji,jj) = ( zxnpt*zxvvt + zynpt*zyvvt ) / znvvt
233            !
234            gsinu(ji,jj) = ( zxnpu*zyffu - zynpu*zxffu ) / znffu
235            gcosu(ji,jj) = ( zxnpu*zxffu + zynpu*zyffu ) / znffu
236            !
237            gsinf(ji,jj) = ( zxnpf*zyuuf - zynpf*zxuuf ) / znuuf
238            gcosf(ji,jj) = ( zxnpf*zxuuf + zynpf*zyuuf ) / znuuf
239            !
240            gsinv(ji,jj) = ( zxnpv*zxffv + zynpv*zyffv ) / znffv
241            gcosv(ji,jj) =-( zxnpv*zyffv - zynpv*zxffv ) / znffv     ! (caution, rotation of 90 degres)
242            !
243         END DO
244      END DO
245
246      ! =============== !
247      ! Geographic mesh !
248      ! =============== !
249
250      DO jj = 2, jpjm1
251         DO ji = fs_2, jpi   ! vector opt.
252            IF( MOD( ABS( glamv(ji,jj) - glamv(ji,jj-1) ), 360. ) < 1.e-8 ) THEN
253               gsint(ji,jj) = 0.
254               gcost(ji,jj) = 1.
255            ENDIF
256            IF( MOD( ABS( glamf(ji,jj) - glamf(ji,jj-1) ), 360. ) < 1.e-8 ) THEN
257               gsinu(ji,jj) = 0.
258               gcosu(ji,jj) = 1.
259            ENDIF
260            IF(      ABS( gphif(ji,jj) - gphif(ji-1,jj) )         < 1.e-8 ) THEN
261               gsinv(ji,jj) = 0.
262               gcosv(ji,jj) = 1.
263            ENDIF
264            IF( MOD( ABS( glamu(ji,jj) - glamu(ji,jj+1) ), 360. ) < 1.e-8 ) THEN
265               gsinf(ji,jj) = 0.
266               gcosf(ji,jj) = 1.
267            ENDIF
268         END DO
269      END DO
270
271      ! =========================== !
272      ! Lateral boundary conditions !
273      ! =========================== !
274      !           ! lateral boundary cond.: T-, U-, V-, F-pts, sgn
275      CALL lbc_lnk( gcost, 'T', -1. )   ;   CALL lbc_lnk( gsint, 'T', -1. )
276      CALL lbc_lnk( gcosu, 'U', -1. )   ;   CALL lbc_lnk( gsinu, 'U', -1. )
277      CALL lbc_lnk( gcosv, 'V', -1. )   ;   CALL lbc_lnk( gsinv, 'V', -1. )
278      CALL lbc_lnk( gcosf, 'F', -1. )   ;   CALL lbc_lnk( 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  !!======================================================================
466END MODULE geo2ocean
Note: See TracBrowser for help on using the repository browser.