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 branches/2016/dev_r6519_HPC_4/NEMOGCM/NEMO/OPA_SRC/SBC – NEMO

source: branches/2016/dev_r6519_HPC_4/NEMOGCM/NEMO/OPA_SRC/SBC/geo2ocean.F90 @ 7525

Last change on this file since 7525 was 7525, checked in by mocavero, 8 years ago

changes after review

  • Property svn:keywords set to Id
File size: 22.2 KB
RevLine 
[3]1MODULE geo2ocean
2   !!======================================================================
3   !!                     ***  MODULE  geo2ocean  ***
[144]4   !! Ocean mesh    :  ???
[1218]5   !!======================================================================
6   !! History :  OPA  !  07-1996  (O. Marti)  Original code
[6140]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
[1218]11   !!----------------------------------------------------------------------
[3]12
13   !!----------------------------------------------------------------------
[6140]14   !!   rot_rep       : Rotate the Repere: geographic grid <==> stretched coordinates grid
15   !!   angle         :
16   !!   geo2oce       :
17   !!   oce2geo       :
[3]18   !!----------------------------------------------------------------------
[6140]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
[3]25
26   IMPLICIT NONE
[1218]27   PRIVATE
[3]28
[6140]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
[3]33
[6140]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
[2528]39
[2715]40   LOGICAL ,              SAVE, DIMENSION(4)     ::   linit = .FALSE.
41   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   gsinlon, gcoslon, gsinlat, gcoslat
42
[6140]43   LOGICAL ::   lmust_init = .TRUE.        !: used to initialize the cos/sin variables (see above)
[672]44
[1218]45   !! * Substitutions
[3]46#  include "vectopt_loop_substitute.h90"
[1218]47   !!----------------------------------------------------------------------
[2528]48   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
[1226]49   !! $Id$
[2715]50   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
[1218]51   !!----------------------------------------------------------------------
[3]52CONTAINS
53
[685]54   SUBROUTINE rot_rep ( pxin, pyin, cd_type, cdtodo, prot )
[672]55      !!----------------------------------------------------------------------
56      !!                  ***  ROUTINE rot_rep  ***
57      !!
58      !! ** Purpose :   Rotate the Repere: Change vector componantes between
59      !!                geographic grid <--> stretched coordinates grid.
60      !!----------------------------------------------------------------------
[6140]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     
[672]69      !!----------------------------------------------------------------------
[6140]70      !
71      IF( lmust_init ) THEN      ! at 1st call only: set  gsin. & gcos.
[3]72         IF(lwp) WRITE(numout,*)
[6140]73         IF(lwp) WRITE(numout,*) ' rot_rep: coordinate transformation : geographic <==> model (i,j)-components'
74         IF(lwp) WRITE(numout,*) ' ~~~~~~~~    '
[2715]75         !
[3]76         CALL angle       ! initialization of the transformation
[672]77         lmust_init = .FALSE.
[3]78      ENDIF
[6140]79      !
80      SELECT CASE( cdtodo )      ! type of rotation
81      !
82      CASE( 'en->i' )                  ! east-north to i-component
[672]83         SELECT CASE (cd_type)
[685]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(:,:)
[672]88         CASE DEFAULT   ;   CALL ctl_stop( 'Only T, U, V and F grid points are coded' )
89         END SELECT
[6140]90      CASE ('en->j')                   ! east-north to j-component
[672]91         SELECT CASE (cd_type)
[685]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(:,:)   
[672]96         CASE DEFAULT   ;   CALL ctl_stop( 'Only T, U, V and F grid points are coded' )
97         END SELECT
[6140]98      CASE ('ij->e')                   ! (i,j)-components to east
[672]99         SELECT CASE (cd_type)
[685]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(:,:)
[672]104         CASE DEFAULT   ;   CALL ctl_stop( 'Only T, U, V and F grid points are coded' )
105         END SELECT
[6140]106      CASE ('ij->n')                   ! (i,j)-components to north
[672]107         SELECT CASE (cd_type)
[685]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(:,:)
[672]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' )
[6140]115      !
[672]116      END SELECT
[6140]117      !
[685]118   END SUBROUTINE rot_rep
[3]119
120
121   SUBROUTINE angle
122      !!----------------------------------------------------------------------
123      !!                  ***  ROUTINE angle  ***
124      !!
[672]125      !! ** Purpose :   Compute angles between model grid lines and the North direction
[3]126      !!
[6140]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.
[3]130      !!
[6140]131      !! ** Action  : - gsint, gcost, gsinu, gcosu, gsinv, gcosv, gsinf, gcosf
[3]132      !!----------------------------------------------------------------------
[6140]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
[3]145      !!----------------------------------------------------------------------
[6140]146      !
[2715]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 )
[6140]152      IF( ierr /= 0 )   CALL ctl_stop( 'angle: unable to allocate arrays' )
153      !
[3]154      ! ============================= !
155      ! Compute the cosinus and sinus !
156      ! ============================= !
157      ! (computation done on the north stereographic polar plane)
[6140]158      !
[7037]159!$OMP PARALLEL
[7525]160!$OMP DO schedule(static) private(jj,ji,zlam,zphi,zxnpt,zynpt,znnpt,zxnpu,zynpu,znnpu,zxnpv,zynpv,znnpv,zxnpf) &
161!$OMP& private(zynpf,znnpf,zlan,zphh,zxvvt,zyvvt,znvvt,zxffu,zyffu,znffu,zxffv,zyffv,znffv,zxuuf,zyuuf,znuuf)
[672]162      DO jj = 2, jpjm1
[3]163         DO ji = fs_2, jpi   ! vector opt.
[6140]164            !                 
165            zlam = glamt(ji,jj)     ! north pole direction & modulous (at t-point)
[672]166            zphi = gphit(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
[6140]170            !
171            zlam = glamu(ji,jj)     ! north pole direction & modulous (at u-point)
[3]172            zphi = gphiu(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
[6140]176            !
177            zlam = glamv(ji,jj)     ! north pole direction & modulous (at v-point)
[3]178            zphi = gphiv(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
[6140]182            !
183            zlam = glamf(ji,jj)     ! north pole direction & modulous (at f-point)
[672]184            zphi = gphif(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
[6140]188            !
189            zlam = glamv(ji,jj  )   ! j-direction: v-point segment direction (around t-point)
[672]190            zphi = gphiv(ji,jj  )
191            zlan = glamv(ji,jj-1)
192            zphh = gphiv(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 )
[6140]199            !
200            zlam = glamf(ji,jj  )   ! j-direction: f-point segment direction (around u-point)
[3]201            zphi = gphif(ji,jj  )
202            zlan = glamf(ji,jj-1)
203            zphh = gphif(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. )
[672]208            znffu = SQRT( znnpu * ( zxffu*zxffu + zyffu*zyffu )  )
209            znffu = MAX( znffu, 1.e-14 )
[6140]210            !
211            zlam = glamf(ji  ,jj)   ! i-direction: f-point segment direction (around v-point)
[3]212            zphi = gphif(ji  ,jj)
213            zlan = glamf(ji-1,jj)
214            zphh = gphif(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. )
[672]219            znffv = SQRT( znnpv * ( zxffv*zxffv + zyffv*zyffv )  )
220            znffv = MAX( znffv, 1.e-14 )
[6140]221            !
222            zlam = glamu(ji,jj+1)   ! j-direction: u-point segment direction (around f-point)
[672]223            zphi = gphiu(ji,jj+1)
224            zlan = glamu(ji,jj  )
225            zphh = gphiu(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 )
[6140]232            !
233            !                       ! cosinus and sinus using dot and cross products
[672]234            gsint(ji,jj) = ( zxnpt*zyvvt - zynpt*zxvvt ) / znvvt
235            gcost(ji,jj) = ( zxnpt*zxvvt + zynpt*zyvvt ) / znvvt
[6140]236            !
[672]237            gsinu(ji,jj) = ( zxnpu*zyffu - zynpu*zxffu ) / znffu
238            gcosu(ji,jj) = ( zxnpu*zxffu + zynpu*zyffu ) / znffu
[6140]239            !
[672]240            gsinf(ji,jj) = ( zxnpf*zyuuf - zynpf*zxuuf ) / znuuf
241            gcosf(ji,jj) = ( zxnpf*zxuuf + zynpf*zyuuf ) / znuuf
[6140]242            !
[672]243            gsinv(ji,jj) = ( zxnpv*zxffv + zynpv*zyffv ) / znffv
[6140]244            gcosv(ji,jj) =-( zxnpv*zyffv - zynpv*zxffv ) / znffv     ! (caution, rotation of 90 degres)
245            !
[3]246         END DO
247      END DO
248
249      ! =============== !
250      ! Geographic mesh !
251      ! =============== !
252
[7037]253!$OMP DO schedule(static) private(jj,ji)
[672]254      DO jj = 2, jpjm1
[3]255         DO ji = fs_2, jpi   ! vector opt.
[672]256            IF( MOD( ABS( glamv(ji,jj) - glamv(ji,jj-1) ), 360. ) < 1.e-8 ) THEN
257               gsint(ji,jj) = 0.
258               gcost(ji,jj) = 1.
259            ENDIF
260            IF( MOD( ABS( glamf(ji,jj) - glamf(ji,jj-1) ), 360. ) < 1.e-8 ) THEN
[3]261               gsinu(ji,jj) = 0.
262               gcosu(ji,jj) = 1.
263            ENDIF
[672]264            IF(      ABS( gphif(ji,jj) - gphif(ji-1,jj) )         < 1.e-8 ) THEN
[3]265               gsinv(ji,jj) = 0.
266               gcosv(ji,jj) = 1.
267            ENDIF
[672]268            IF( MOD( ABS( glamu(ji,jj) - glamu(ji,jj+1) ), 360. ) < 1.e-8 ) THEN
269               gsinf(ji,jj) = 0.
270               gcosf(ji,jj) = 1.
271            ENDIF
[3]272         END DO
273      END DO
[7037]274!$OMP END DO NOWAIT
275!$OMP END PARALLEL
[3]276
277      ! =========================== !
278      ! Lateral boundary conditions !
279      ! =========================== !
[6140]280      !           ! lateral boundary cond.: T-, U-, V-, F-pts, sgn
[1833]281      CALL lbc_lnk( gcost, 'T', -1. )   ;   CALL lbc_lnk( gsint, 'T', -1. )
282      CALL lbc_lnk( gcosu, 'U', -1. )   ;   CALL lbc_lnk( gsinu, 'U', -1. )
283      CALL lbc_lnk( gcosv, 'V', -1. )   ;   CALL lbc_lnk( gsinv, 'V', -1. )
284      CALL lbc_lnk( gcosf, 'F', -1. )   ;   CALL lbc_lnk( gsinf, 'F', -1. )
[6140]285      !
[3]286   END SUBROUTINE angle
287
288
[6140]289   SUBROUTINE geo2oce ( pxx, pyy, pzz, cgrid, pte, ptn )
[3]290      !!----------------------------------------------------------------------
291      !!                    ***  ROUTINE geo2oce  ***
292      !!     
293      !! ** Purpose :
294      !!
[6140]295      !! ** Method  :   Change a vector from geocentric to east/north
[3]296      !!
297      !!----------------------------------------------------------------------
[1218]298      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::  pxx, pyy, pzz
299      CHARACTER(len=1)            , INTENT(in   ) ::  cgrid
300      REAL(wp), DIMENSION(jpi,jpj), INTENT(  out) ::  pte, ptn
[6140]301      !
[2715]302      REAL(wp), PARAMETER :: rpi = 3.141592653e0
[88]303      REAL(wp), PARAMETER :: rad = rpi / 180.e0
[1218]304      INTEGER ::   ig     !
[2715]305      INTEGER ::   ierr   ! local integer
[1218]306      !!----------------------------------------------------------------------
[6140]307      !
[2715]308      IF( .NOT. ALLOCATED( gsinlon ) ) THEN
309         ALLOCATE( gsinlon(jpi,jpj,4) , gcoslon(jpi,jpj,4) ,   &
310            &      gsinlat(jpi,jpj,4) , gcoslat(jpi,jpj,4) , STAT=ierr )
311         IF( lk_mpp    )   CALL mpp_sum( ierr )
[4162]312         IF( ierr /= 0 )   CALL ctl_stop('geo2oce: unable to allocate arrays' )
[2715]313      ENDIF
[6140]314      !
[1218]315      SELECT CASE( cgrid)
[6140]316      CASE ( 'T' )   
317         ig = 1
318         IF( .NOT. linit(ig) ) THEN
319            gsinlon(:,:,ig) = SIN( rad * glamt(:,:) )
320            gcoslon(:,:,ig) = COS( rad * glamt(:,:) )
321            gsinlat(:,:,ig) = SIN( rad * gphit(:,:) )
322            gcoslat(:,:,ig) = COS( rad * gphit(:,:) )
323            linit(ig) = .TRUE.
324         ENDIF
325      CASE ( 'U' )   
326         ig = 2
327         IF( .NOT. linit(ig) ) THEN
328            gsinlon(:,:,ig) = SIN( rad * glamu(:,:) )
329            gcoslon(:,:,ig) = COS( rad * glamu(:,:) )
330            gsinlat(:,:,ig) = SIN( rad * gphiu(:,:) )
331            gcoslat(:,:,ig) = COS( rad * gphiu(:,:) )
332            linit(ig) = .TRUE.
333         ENDIF
334      CASE ( 'V' )   
335         ig = 3
336         IF( .NOT. linit(ig) ) THEN
337            gsinlon(:,:,ig) = SIN( rad * glamv(:,:) )
338            gcoslon(:,:,ig) = COS( rad * glamv(:,:) )
339            gsinlat(:,:,ig) = SIN( rad * gphiv(:,:) )
340            gcoslat(:,:,ig) = COS( rad * gphiv(:,:) )
341            linit(ig) = .TRUE.
342         ENDIF
343      CASE ( 'F' )   
344         ig = 4
345         IF( .NOT. linit(ig) ) THEN
346            gsinlon(:,:,ig) = SIN( rad * glamf(:,:) )
347            gcoslon(:,:,ig) = COS( rad * glamf(:,:) )
348            gsinlat(:,:,ig) = SIN( rad * gphif(:,:) )
349            gcoslat(:,:,ig) = COS( rad * gphif(:,:) )
350            linit(ig) = .TRUE.
351         ENDIF
352      CASE default   
353         WRITE(ctmp1,*) 'geo2oce : bad grid argument : ', cgrid
354         CALL ctl_stop( ctmp1 )
[1218]355      END SELECT
[6140]356      !
[2715]357      pte = - gsinlon(:,:,ig) * pxx + gcoslon(:,:,ig) * pyy
358      ptn = - gcoslon(:,:,ig) * gsinlat(:,:,ig) * pxx    &
[6140]359         &  - gsinlon(:,:,ig) * gsinlat(:,:,ig) * pyy    &
360         &  + gcoslat(:,:,ig) * pzz
[1218]361      !
362   END SUBROUTINE geo2oce
363
[6140]364
365   SUBROUTINE oce2geo ( pte, ptn, cgrid, pxx , pyy , pzz )
[1218]366      !!----------------------------------------------------------------------
367      !!                    ***  ROUTINE oce2geo  ***
368      !!     
369      !! ** Purpose :
370      !!
371      !! ** Method  :   Change vector from east/north to geocentric
372      !!
[6140]373      !! History :     ! (A. Caubel)  oce2geo - Original code
[1218]374      !!----------------------------------------------------------------------
375      REAL(wp), DIMENSION(jpi,jpj), INTENT( IN    ) ::  pte, ptn
376      CHARACTER(len=1)            , INTENT( IN    ) ::  cgrid
377      REAL(wp), DIMENSION(jpi,jpj), INTENT(   OUT ) ::  pxx , pyy , pzz
378      !!
379      REAL(wp), PARAMETER :: rpi = 3.141592653E0
380      REAL(wp), PARAMETER :: rad = rpi / 180.e0
[3]381      INTEGER ::   ig     !
[2715]382      INTEGER ::   ierr   ! local integer
[3]383      !!----------------------------------------------------------------------
384
[4162]385      IF( .NOT. ALLOCATED( gsinlon ) ) THEN
[2715]386         ALLOCATE( gsinlon(jpi,jpj,4) , gcoslon(jpi,jpj,4) ,   &
387            &      gsinlat(jpi,jpj,4) , gcoslat(jpi,jpj,4) , STAT=ierr )
388         IF( lk_mpp    )   CALL mpp_sum( ierr )
[4162]389         IF( ierr /= 0 )   CALL ctl_stop('oce2geo: unable to allocate arrays' )
[2715]390      ENDIF
391
[3]392      SELECT CASE( cgrid)
[1226]393         CASE ( 'T' )   
394            ig = 1
395            IF( .NOT. linit(ig) ) THEN
[2715]396               gsinlon(:,:,ig) = SIN( rad * glamt(:,:) )
397               gcoslon(:,:,ig) = COS( rad * glamt(:,:) )
398               gsinlat(:,:,ig) = SIN( rad * gphit(:,:) )
399               gcoslat(:,:,ig) = COS( rad * gphit(:,:) )
[1226]400               linit(ig) = .TRUE.
401            ENDIF
402         CASE ( 'U' )   
403            ig = 2
404            IF( .NOT. linit(ig) ) THEN
[2715]405               gsinlon(:,:,ig) = SIN( rad * glamu(:,:) )
406               gcoslon(:,:,ig) = COS( rad * glamu(:,:) )
407               gsinlat(:,:,ig) = SIN( rad * gphiu(:,:) )
408               gcoslat(:,:,ig) = COS( rad * gphiu(:,:) )
[1226]409               linit(ig) = .TRUE.
410            ENDIF
411         CASE ( 'V' )   
412            ig = 3
413            IF( .NOT. linit(ig) ) THEN
[2715]414               gsinlon(:,:,ig) = SIN( rad * glamv(:,:) )
415               gcoslon(:,:,ig) = COS( rad * glamv(:,:) )
416               gsinlat(:,:,ig) = SIN( rad * gphiv(:,:) )
417               gcoslat(:,:,ig) = COS( rad * gphiv(:,:) )
[1226]418               linit(ig) = .TRUE.
419            ENDIF
420         CASE ( 'F' )   
421            ig = 4
422            IF( .NOT. linit(ig) ) THEN
[2715]423               gsinlon(:,:,ig) = SIN( rad * glamf(:,:) )
424               gcoslon(:,:,ig) = COS( rad * glamf(:,:) )
425               gsinlat(:,:,ig) = SIN( rad * gphif(:,:) )
426               gcoslat(:,:,ig) = COS( rad * gphif(:,:) )
[1226]427               linit(ig) = .TRUE.
428            ENDIF
429         CASE default   
430            WRITE(ctmp1,*) 'geo2oce : bad grid argument : ', cgrid
[474]431            CALL ctl_stop( ctmp1 )
[1226]432      END SELECT
[6140]433      !
434      pxx = - gsinlon(:,:,ig) * pte - gcoslon(:,:,ig) * gsinlat(:,:,ig) * ptn 
435      pyy =   gcoslon(:,:,ig) * pte - gsinlon(:,:,ig) * gsinlat(:,:,ig) * ptn
436      pzz =   gcoslat(:,:,ig) * ptn
437      !
[1218]438   END SUBROUTINE oce2geo
[3]439
440
[6140]441   SUBROUTINE obs_rot( psinu, pcosu, psinv, pcosv )
[3]442      !!----------------------------------------------------------------------
[2528]443      !!                  ***  ROUTINE obs_rot  ***
444      !!
445      !! ** Purpose :   Copy gsinu, gcosu, gsinv and gsinv
446      !!                to input data for rotations of
447      !!                current at observation points
448      !!
[6140]449      !! History :  9.2  !  09-02  (K. Mogensen)
[2528]450      !!----------------------------------------------------------------------
[2715]451      REAL(wp), DIMENSION(jpi,jpj), INTENT( OUT )::   psinu, pcosu, psinv, pcosv   ! copy of data
[2528]452      !!----------------------------------------------------------------------
[6140]453      !
[2528]454      ! Initialization of gsin* and gcos* at first call
455      ! -----------------------------------------------
456      IF( lmust_init ) THEN
457         IF(lwp) WRITE(numout,*)
458         IF(lwp) WRITE(numout,*) ' obs_rot : geographic <--> stretched'
459         IF(lwp) WRITE(numout,*) ' ~~~~~~~   coordinate transformation'
460         CALL angle       ! initialization of the transformation
461         lmust_init = .FALSE.
462      ENDIF
[6140]463      !
[2528]464      psinu(:,:) = gsinu(:,:)
465      pcosu(:,:) = gcosu(:,:)
466      psinv(:,:) = gsinv(:,:)
467      pcosv(:,:) = gcosv(:,:)
[6140]468      !
[2528]469   END SUBROUTINE obs_rot
470
[3]471  !!======================================================================
472END MODULE geo2ocean
Note: See TracBrowser for help on using the repository browser.