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/2019/dev_ASINTER-01-05_merged/src/OCE/SBC – NEMO

source: NEMO/branches/2019/dev_ASINTER-01-05_merged/src/OCE/SBC/geo2ocean.F90 @ 12021

Last change on this file since 12021 was 10425, checked in by smasson, 5 years ago

trunk: merge back dev_r10164_HPC09_ESIWACE_PREP_MERGE@10424 into the trunk

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