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.
usrdef_hgr.F90 in NEMO/branches/2020/dev_r12527_Gurvan_ShallowWater/cfgs/AM98/MY_SRC – NEMO

source: NEMO/branches/2020/dev_r12527_Gurvan_ShallowWater/cfgs/AM98/MY_SRC/usrdef_hgr.F90 @ 13005

Last change on this file since 13005 was 13005, checked in by gm, 4 years ago

ADE and more options to AM98 config

File size: 9.0 KB
Line 
1MODULE usrdef_hgr
2   !!======================================================================
3   !!                     ***  MODULE usrdef_hgr   ***
4   !!
5   !!                     ===  AM98 configuration  ===
6   !!
7   !! User defined :   mesh and Coriolis parameter of a user configuration
8   !!======================================================================
9   !! History :  4.0 ! 2016-03  (S. Flavoni)
10   !!----------------------------------------------------------------------
11
12   !!----------------------------------------------------------------------
13   !!   usr_def_hgr   : initialize the horizontal mesh
14   !!----------------------------------------------------------------------
15   USE dom_oce  , ONLY: nimpp, njmpp       ! ocean space and time domain
16   USE par_oce        ! ocean space and time domain
17   USE phycst         ! physical constants
18   USE usrdef_nam     !
19   !
20   USE in_out_manager ! I/O manager
21   USE lib_mpp        ! MPP library
22   
23   IMPLICIT NONE
24   PRIVATE
25
26   PUBLIC   usr_def_hgr   ! called in domhgr.F90
27   
28   !!----------------------------------------------------------------------
29   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
30   !! $Id: usrdef_hgr.F90 10069 2018-08-28 14:12:24Z nicolasmartin $
31   !! Software governed by the CeCILL license (see ./LICENSE)
32   !!----------------------------------------------------------------------
33CONTAINS
34
35   SUBROUTINE usr_def_hgr( plamt , plamu , plamv  , plamf  ,   &   ! geographic position (required)
36      &                    pphit , pphiu , pphiv  , pphif  ,   &   !
37      &                    kff   , pff_f , pff_t  ,            &   ! Coriolis parameter  (if domain not on the sphere)
38      &                    pe1t  , pe1u  , pe1v   , pe1f   ,   &   ! scale factors       (required)
39      &                    pe2t  , pe2u  , pe2v   , pe2f   ,   &   !
40      &                    ke1e2u_v      , pe1e2u , pe1e2v     )   ! u- & v-surfaces (if gridsize reduction is used in strait(s))
41      !!----------------------------------------------------------------------
42      !!                  ***  ROUTINE usr_def_hgr  ***
43      !!
44      !! ** Purpose :   user defined mesh and Coriolis parameter
45      !!
46      !! ** Method  :   set all intent(out) argument to a proper value
47      !!
48      !!                Here AM98 configuration :
49      !!          Rectangular mid-latitude domain
50      !!          - with axes rotated by 45 degrees
51      !!          - a constant horizontal resolution of 106 km
52      !!          - on a beta-plane
53      !!
54      !! ** Action  : - define longitude & latitude of t-, u-, v- and f-points (in degrees)
55      !!              - define coriolis parameter at f-point if the domain in not on the sphere (on beta-plane)
56      !!              - define i- & j-scale factors at t-, u-, v- and f-points (in meters)
57      !!              - define u- & v-surfaces (if gridsize reduction is used in some straits) (in m2)
58      !!----------------------------------------------------------------------
59      REAL(wp), DIMENSION(:,:), INTENT(out) ::   plamt, plamu, plamv, plamf   ! longitude outputs                     [degrees]
60      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pphit, pphiu, pphiv, pphif   ! latitude outputs                      [degrees]
61      INTEGER                 , INTENT(out) ::   kff                          ! =1 Coriolis parameter computed here, =0 otherwise
62      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pff_f, pff_t                 ! Coriolis factor at f-point                [1/s]
63      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1t, pe1u, pe1v, pe1f       ! i-scale factors                             [m]
64      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe2t, pe2u, pe2v, pe2f       ! j-scale factors                             [m]
65      INTEGER                 , INTENT(out) ::   ke1e2u_v                     ! =1 u- & v-surfaces computed here, =0 otherwise
66      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1e2u, pe1e2v               ! u- & v-surfaces (if reduction in strait)   [m2]
67      !
68      INTEGER  ::   ji, jj               ! dummy loop indices
69      REAL(wp) ::   zlam1, zlam0, zcos_theta, zim1 , zjm1 , ze1  , ze1deg ! local scalars
70      REAL(wp) ::   zphi1, zphi0, zsin_theta, zim05, zjm05, znorme        !   -      -
71      REAL(wp) ::   zgl, zbl      !   -      -
72
73      !!-------------------------------------------------------------------------------
74      !
75      !     !==  beta-plane with regular grid-spacing and rotated domain ==!  (AM98 configuration)
76      !
77      IF(lwp) WRITE(numout,*)
78      IF(lwp) WRITE(numout,*) 'usr_def_hgr : AM98 configuration (beta-plane with rotated regular grid-spacing)'
79      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
80      !
81      !
82      !                       !==  grid point position  ==!
83      !
84      ze1 =  rn_dx / REAL(nn_AM98, wp)                   ! [m] gridspacing used
85      zgl =  rn_domsiz + 2._wp * REAL(nn_gc, wp) * ze1   ! [m] length of the square with ghostcells
86      ! fit the best square around the square + ghost cells
87      zbl = zgl * ( COS( rn_theta * rad ) + SIN( rn_theta * rad ) )   ! length side bigger domain [m]                                 
88
89      ! unrotated (0deg)
90      !zcos_theta = 1._wp
91      !zsin_theta = 0._wp
92      ! rotated case (45deg)
93      !zcos_theta =   1._wp / SQRT( 2._wp )
94      !zsin_theta =   1._wp / SQRT( 2._wp ) 
95      ! rotation angle
96      zcos_theta = COS( rn_theta * rad)
97      zsin_theta = SIN( rn_theta * rad)   
98
99      ! exact origin in meters
100      zlam1 =  zbl * COS((rn_theta + 45 )* rad ) / SQRT( 2._wp )  - rn_domsiz/2._wp 
101      zphi1 =  zbl * SIN((rn_theta + 45 )* rad ) / SQRT( 2._wp )  - rn_domsiz/2._wp 
102      ! origin put in the true corner of a cell so there will be no cropping
103      ! of the edge cells
104      zlam0 = REAL( anint( zlam1 / ze1 ), wp ) * ze1
105      zphi0 = REAl( anint( zphi1 / ze1 ), wp ) * ze1
106
107      IF(lwp) WRITE(numout,*) '                  origin position    zlam0   = ', zlam0/1000,   ' km'
108      IF(lwp) WRITE(numout,*) '                  origin position    zphi0   = ', zphi0/1000,   ' km'
109
110      ! O1M = OM x rotation_theta + OO1
111      ! zim1, zim05, zjm1, zjm05 fit for 2 ghost cells on each side
112      DO jj = 1, jpj 
113         DO ji = 1, jpi 
114            zim1 = REAL( ji + nimpp - 1 )   ;   zim05 = REAL( ji + nimpp - 1 ) - 0.5 
115            zjm1 = REAL( jj + njmpp - 1 )   ;   zjm05 = REAL( jj + njmpp - 1 ) - 0.5 
116            !   
117            !glamt(i,j) position (meters) at T-point
118            !gphit(i,j) position (meters) at T-point 
119            plamt(ji,jj) =   zim05 * ze1 * zcos_theta - zjm05 * ze1 * zsin_theta - zlam0
120            pphit(ji,jj) = + zim05 * ze1 * zsin_theta + zjm05 * ze1 * zcos_theta - zphi0
121            !   
122            !glamu(i,j) position (meters) at U-point
123            !gphiu(i,j) position (meters) at U-point
124            plamu(ji,jj) =   zim1  * ze1 * zcos_theta - zjm05 * ze1 * zsin_theta - zlam0
125            pphiu(ji,jj) = + zim1  * ze1 * zsin_theta + zjm05 * ze1 * zcos_theta - zphi0
126            !   
127            !glamv(i,j) position (meters) at V-point
128            !gphiv(i,j) position (meters) at V-point
129            plamv(ji,jj) =   zim05 * ze1 * zcos_theta - zjm1  * ze1 * zsin_theta - zlam0
130            pphiv(ji,jj) = + zim05 * ze1 * zsin_theta + zjm1  * ze1 * zcos_theta - zphi0
131            !
132            !glamf(i,j) position (meters) at F-point
133            !gphif(i,j) position (meters) at F-point
134            plamf(ji,jj) =   zim1  * ze1 * zcos_theta - zjm1  * ze1 * zsin_theta - zlam0
135            pphif(ji,jj) = + zim1  * ze1 * zsin_theta + zjm1  * ze1 * zcos_theta - zphi0
136         END DO
137      END DO
138      !
139      !                       !== Horizontal scale factors ==! (in meters)
140      !                     
141      !                                         ! constant grid spacing
142      pe1t(:,:) =  ze1     ;      pe2t(:,:) = ze1
143      pe1u(:,:) =  ze1     ;      pe2u(:,:) = ze1
144      pe1v(:,:) =  ze1     ;      pe2v(:,:) = ze1
145      pe1f(:,:) =  ze1     ;      pe2f(:,:) = ze1
146      !
147      !                                         ! NO reduction of grid size in some straits
148      ke1e2u_v = 0                              !    ==>> u_ & v_surfaces will be computed in dom_ghr routine
149      pe1e2u(:,:) = 0._wp                       !    CAUTION: set to zero to avoid error with some compilers that
150      pe1e2v(:,:) = 0._wp                       !             require an initialization of INTENT(out) arguments
151      !
152      !
153      !                       !==  Coriolis parameter  ==!
154      kff = 1                                            !  indicate not to compute ff afterward
155      !
156      pff_f(:,:) =  REAL( rn_f0, wp ) + REAL( rn_beta, wp ) * ABS( pphif(:,:) ) ! f = f0 +beta* y
157      pff_t(:,:) =  REAL( rn_f0, wp ) + REAL( rn_beta, wp ) * ABS( pphit(:,:) ) ! f = f0 +beta* y
158      !
159      IF(lwp) WRITE(numout,*) '                           beta-plane used. f0   = ', rn_f0 ,  ' 1/s'
160      IF(lwp) WRITE(numout,*) '                           beta-plane used. beta = ', rn_beta, ' 1/(s.m)'
161      !
162   END SUBROUTINE usr_def_hgr
163
164   !!======================================================================
165END MODULE usrdef_hgr
Note: See TracBrowser for help on using the repository browser.