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/trunk/src/OCE/SBC – NEMO

source: NEMO/trunk/src/OCE/SBC/geo2ocean.F90 @ 10455

Last change on this file since 10455 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
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   !!----------------------------------------------------------------------
[6140]13   !!   rot_rep       : Rotate the Repere: geographic grid <==> stretched coordinates grid
14   !!   angle         :
15   !!   geo2oce       :
16   !!   oce2geo       :
[3]17   !!----------------------------------------------------------------------
[6140]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
[3]24
25   IMPLICIT NONE
[1218]26   PRIVATE
[3]27
[6140]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
[3]32
[6140]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
[2528]38
[2715]39   LOGICAL ,              SAVE, DIMENSION(4)     ::   linit = .FALSE.
40   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   gsinlon, gcoslon, gsinlat, gcoslat
41
[6140]42   LOGICAL ::   lmust_init = .TRUE.        !: used to initialize the cos/sin variables (see above)
[672]43
[1218]44   !! * Substitutions
[3]45#  include "vectopt_loop_substitute.h90"
[1218]46   !!----------------------------------------------------------------------
[9598]47   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
[1226]48   !! $Id$
[10068]49   !! Software governed by the CeCILL license (see ./LICENSE)
[1218]50   !!----------------------------------------------------------------------
[3]51CONTAINS
52
[685]53   SUBROUTINE rot_rep ( pxin, pyin, cd_type, cdtodo, prot )
[672]54      !!----------------------------------------------------------------------
55      !!                  ***  ROUTINE rot_rep  ***
56      !!
57      !! ** Purpose :   Rotate the Repere: Change vector componantes between
58      !!                geographic grid <--> stretched coordinates grid.
59      !!----------------------------------------------------------------------
[6140]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     
[672]68      !!----------------------------------------------------------------------
[6140]69      !
70      IF( lmust_init ) THEN      ! at 1st call only: set  gsin. & gcos.
[3]71         IF(lwp) WRITE(numout,*)
[6140]72         IF(lwp) WRITE(numout,*) ' rot_rep: coordinate transformation : geographic <==> model (i,j)-components'
73         IF(lwp) WRITE(numout,*) ' ~~~~~~~~    '
[2715]74         !
[10370]75         CALL angle( glamt, gphit, glamu, gphiu, glamv, gphiv, glamf, gphif )       ! initialization of the transformation
[672]76         lmust_init = .FALSE.
[3]77      ENDIF
[6140]78      !
79      SELECT CASE( cdtodo )      ! type of rotation
80      !
81      CASE( 'en->i' )                  ! east-north to i-component
[672]82         SELECT CASE (cd_type)
[7753]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(:,:)
[672]87         CASE DEFAULT   ;   CALL ctl_stop( 'Only T, U, V and F grid points are coded' )
88         END SELECT
[6140]89      CASE ('en->j')                   ! east-north to j-component
[672]90         SELECT CASE (cd_type)
[7753]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(:,:)   
[672]95         CASE DEFAULT   ;   CALL ctl_stop( 'Only T, U, V and F grid points are coded' )
96         END SELECT
[6140]97      CASE ('ij->e')                   ! (i,j)-components to east
[672]98         SELECT CASE (cd_type)
[7753]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(:,:)
[672]103         CASE DEFAULT   ;   CALL ctl_stop( 'Only T, U, V and F grid points are coded' )
104         END SELECT
[6140]105      CASE ('ij->n')                   ! (i,j)-components to north
[672]106         SELECT CASE (cd_type)
[7753]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(:,:)
[672]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' )
[6140]114      !
[672]115      END SELECT
[6140]116      !
[685]117   END SUBROUTINE rot_rep
[3]118
119
[10370]120   SUBROUTINE angle( plamt, pphit, plamu, pphiu, plamv, pphiv, plamf, pphif )
[3]121      !!----------------------------------------------------------------------
122      !!                  ***  ROUTINE angle  ***
123      !!
[672]124      !! ** Purpose :   Compute angles between model grid lines and the North direction
[3]125      !!
[6140]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.
[3]129      !!
[6140]130      !! ** Action  : - gsint, gcost, gsinu, gcosu, gsinv, gcosv, gsinf, gcosf
[3]131      !!----------------------------------------------------------------------
[10370]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      !
[6140]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
[3]148      !!----------------------------------------------------------------------
[6140]149      !
[2715]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 )
[10425]154      CALL mpp_sum( 'geo2ocean', ierr )
[6140]155      IF( ierr /= 0 )   CALL ctl_stop( 'angle: unable to allocate arrays' )
156      !
[3]157      ! ============================= !
158      ! Compute the cosinus and sinus !
159      ! ============================= !
160      ! (computation done on the north stereographic polar plane)
[6140]161      !
[672]162      DO jj = 2, jpjm1
[3]163         DO ji = fs_2, jpi   ! vector opt.
[6140]164            !                 
[10370]165            zlam = plamt(ji,jj)     ! north pole direction & modulous (at t-point)
166            zphi = pphit(ji,jj)
[672]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            !
[10370]171            zlam = plamu(ji,jj)     ! north pole direction & modulous (at u-point)
172            zphi = pphiu(ji,jj)
[3]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            !
[10370]177            zlam = plamv(ji,jj)     ! north pole direction & modulous (at v-point)
178            zphi = pphiv(ji,jj)
[3]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            !
[10370]183            zlam = plamf(ji,jj)     ! north pole direction & modulous (at f-point)
184            zphi = pphif(ji,jj)
[672]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            !
[10370]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)
[672]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            !
[10370]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)
[3]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            !
[10370]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)
[3]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            !
[10370]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  )
[672]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
[672]253      DO jj = 2, jpjm1
[3]254         DO ji = fs_2, jpi   ! vector opt.
[10370]255            IF( MOD( ABS( plamv(ji,jj) - plamv(ji,jj-1) ), 360. ) < 1.e-8 ) THEN
[672]256               gsint(ji,jj) = 0.
257               gcost(ji,jj) = 1.
258            ENDIF
[10370]259            IF( MOD( ABS( plamf(ji,jj) - plamf(ji,jj-1) ), 360. ) < 1.e-8 ) THEN
[3]260               gsinu(ji,jj) = 0.
261               gcosu(ji,jj) = 1.
262            ENDIF
[10370]263            IF(      ABS( pphif(ji,jj) - pphif(ji-1,jj) )         < 1.e-8 ) THEN
[3]264               gsinv(ji,jj) = 0.
265               gcosv(ji,jj) = 1.
266            ENDIF
[10370]267            IF( MOD( ABS( plamu(ji,jj) - plamu(ji,jj+1) ), 360. ) < 1.e-8 ) THEN
[672]268               gsinf(ji,jj) = 0.
269               gcosf(ji,jj) = 1.
270            ENDIF
[3]271         END DO
272      END DO
273
274      ! =========================== !
275      ! Lateral boundary conditions !
276      ! =========================== !
[6140]277      !           ! lateral boundary cond.: T-, U-, V-, F-pts, sgn
[10425]278      CALL lbc_lnk_multi( 'geo2ocean', gcost, 'T', -1., gsint, 'T', -1., gcosu, 'U', -1., gsinu, 'U', -1., & 
[9098]279                      &   gcosv, 'V', -1., gsinv, 'V', -1., gcosf, 'F', -1., gsinf, 'F', -1.  )
[6140]280      !
[3]281   END SUBROUTINE angle
282
283
[6140]284   SUBROUTINE geo2oce ( pxx, pyy, pzz, cgrid, pte, ptn )
[3]285      !!----------------------------------------------------------------------
286      !!                    ***  ROUTINE geo2oce  ***
287      !!     
288      !! ** Purpose :
289      !!
[6140]290      !! ** Method  :   Change a vector from geocentric to east/north
[3]291      !!
292      !!----------------------------------------------------------------------
[1218]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
[6140]296      !
[2715]297      REAL(wp), PARAMETER :: rpi = 3.141592653e0
[88]298      REAL(wp), PARAMETER :: rad = rpi / 180.e0
[1218]299      INTEGER ::   ig     !
[2715]300      INTEGER ::   ierr   ! local integer
[1218]301      !!----------------------------------------------------------------------
[6140]302      !
[2715]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 )
[10425]306         CALL mpp_sum( 'geo2ocean', ierr )
[4162]307         IF( ierr /= 0 )   CALL ctl_stop('geo2oce: unable to allocate arrays' )
[2715]308      ENDIF
[6140]309      !
[1218]310      SELECT CASE( cgrid)
[6140]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 )
[1218]350      END SELECT
[6140]351      !
[2715]352      pte = - gsinlon(:,:,ig) * pxx + gcoslon(:,:,ig) * pyy
353      ptn = - gcoslon(:,:,ig) * gsinlat(:,:,ig) * pxx    &
[6140]354         &  - gsinlon(:,:,ig) * gsinlat(:,:,ig) * pyy    &
355         &  + gcoslat(:,:,ig) * pzz
[1218]356      !
357   END SUBROUTINE geo2oce
358
[6140]359
360   SUBROUTINE oce2geo ( pte, ptn, cgrid, pxx , pyy , pzz )
[1218]361      !!----------------------------------------------------------------------
362      !!                    ***  ROUTINE oce2geo  ***
363      !!     
364      !! ** Purpose :
365      !!
366      !! ** Method  :   Change vector from east/north to geocentric
367      !!
[6140]368      !! History :     ! (A. Caubel)  oce2geo - Original code
[1218]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
[3]376      INTEGER ::   ig     !
[2715]377      INTEGER ::   ierr   ! local integer
[3]378      !!----------------------------------------------------------------------
379
[4162]380      IF( .NOT. ALLOCATED( gsinlon ) ) THEN
[2715]381         ALLOCATE( gsinlon(jpi,jpj,4) , gcoslon(jpi,jpj,4) ,   &
382            &      gsinlat(jpi,jpj,4) , gcoslat(jpi,jpj,4) , STAT=ierr )
[10425]383         CALL mpp_sum( 'geo2ocean', ierr )
[4162]384         IF( ierr /= 0 )   CALL ctl_stop('oce2geo: unable to allocate arrays' )
[2715]385      ENDIF
386
[3]387      SELECT CASE( cgrid)
[1226]388         CASE ( 'T' )   
389            ig = 1
390            IF( .NOT. linit(ig) ) THEN
[2715]391               gsinlon(:,:,ig) = SIN( rad * glamt(:,:) )
392               gcoslon(:,:,ig) = COS( rad * glamt(:,:) )
393               gsinlat(:,:,ig) = SIN( rad * gphit(:,:) )
394               gcoslat(:,:,ig) = COS( rad * gphit(:,:) )
[1226]395               linit(ig) = .TRUE.
396            ENDIF
397         CASE ( 'U' )   
398            ig = 2
399            IF( .NOT. linit(ig) ) THEN
[2715]400               gsinlon(:,:,ig) = SIN( rad * glamu(:,:) )
401               gcoslon(:,:,ig) = COS( rad * glamu(:,:) )
402               gsinlat(:,:,ig) = SIN( rad * gphiu(:,:) )
403               gcoslat(:,:,ig) = COS( rad * gphiu(:,:) )
[1226]404               linit(ig) = .TRUE.
405            ENDIF
406         CASE ( 'V' )   
407            ig = 3
408            IF( .NOT. linit(ig) ) THEN
[2715]409               gsinlon(:,:,ig) = SIN( rad * glamv(:,:) )
410               gcoslon(:,:,ig) = COS( rad * glamv(:,:) )
411               gsinlat(:,:,ig) = SIN( rad * gphiv(:,:) )
412               gcoslat(:,:,ig) = COS( rad * gphiv(:,:) )
[1226]413               linit(ig) = .TRUE.
414            ENDIF
415         CASE ( 'F' )   
416            ig = 4
417            IF( .NOT. linit(ig) ) THEN
[2715]418               gsinlon(:,:,ig) = SIN( rad * glamf(:,:) )
419               gcoslon(:,:,ig) = COS( rad * glamf(:,:) )
420               gsinlat(:,:,ig) = SIN( rad * gphif(:,:) )
421               gcoslat(:,:,ig) = COS( rad * gphif(:,:) )
[1226]422               linit(ig) = .TRUE.
423            ENDIF
424         CASE default   
425            WRITE(ctmp1,*) 'geo2oce : bad grid argument : ', cgrid
[474]426            CALL ctl_stop( ctmp1 )
[1226]427      END SELECT
[6140]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      !
[1218]433   END SUBROUTINE oce2geo
[3]434
435
[6140]436   SUBROUTINE obs_rot( psinu, pcosu, psinv, pcosv )
[3]437      !!----------------------------------------------------------------------
[2528]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      !!
[6140]444      !! History :  9.2  !  09-02  (K. Mogensen)
[2528]445      !!----------------------------------------------------------------------
[2715]446      REAL(wp), DIMENSION(jpi,jpj), INTENT( OUT )::   psinu, pcosu, psinv, pcosv   ! copy of data
[2528]447      !!----------------------------------------------------------------------
[6140]448      !
[2528]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'
[10370]455         CALL angle( glamt, gphit, glamu, gphiu, glamv, gphiv, glamf, gphif )       ! initialization of the transformation
[2528]456         lmust_init = .FALSE.
457      ENDIF
[6140]458      !
[2528]459      psinu(:,:) = gsinu(:,:)
460      pcosu(:,:) = gcosu(:,:)
461      psinv(:,:) = gsinv(:,:)
462      pcosv(:,:) = gcosv(:,:)
[6140]463      !
[2528]464   END SUBROUTINE obs_rot
465
[3]466  !!======================================================================
467END MODULE geo2ocean
Note: See TracBrowser for help on using the repository browser.