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 branches/2017/dev_merge_2017/NEMOGCM/CONFIG/TEST_CASES/CANAL/MY_SRC – NEMO

source: branches/2017/dev_merge_2017/NEMOGCM/CONFIG/TEST_CASES/CANAL/MY_SRC/usrdef_hgr.F90 @ 9403

Last change on this file since 9403 was 9403, checked in by smasson, 6 years ago

dev_merge_2017: update test_cases CANAL

File size: 7.3 KB
Line 
1MODULE usrdef_hgr
2   !!======================================================================
3   !!                       ***  MODULE  usrdef_hgr  ***
4   !!
5   !!                      ===  CANAL configuration  ===
6   !!
7   !! User defined :   mesh and Coriolis parameter of a user configuration
8   !!======================================================================
9   !! History :  NEMO  ! 2017-11  (J. Chanut)  Original code
10   !!----------------------------------------------------------------------
11
12   !!----------------------------------------------------------------------
13   !!   usr_def_hgr    : initialize the horizontal mesh for CANAL configuration
14   !!----------------------------------------------------------------------
15   USE dom_oce         ! ocean space and time domain
16   USE par_oce         ! ocean space and time domain
17   USE phycst          ! physical constants
18   USE usrdef_nam, ONLY: rn_dx, rn_dy, rn_0xratio, rn_0yratio, rn_ppgphi0, nn_fcase
19   !                                                  and reference latitude
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 by domhgr.F90
27
28   !!----------------------------------------------------------------------
29   !! NEMO/OPA 4.0, NEMO Consortium (2016)
30   !! $Id$
31   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
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      !!                CANAL configuration : beta-plance with uniform grid spacing (rn_dx)
48      !!
49      !! ** Action  : - define longitude & latitude of t-, u-, v- and f-points (in degrees)
50      !!              - define coriolis parameter at f-point if the domain in not on the sphere (on beta-plane)
51      !!              - define i- & j-scale factors at t-, u-, v- and f-points (in meters)
52      !!              - define u- & v-surfaces (if gridsize reduction is used in some straits) (in m2)
53      !!----------------------------------------------------------------------
54      REAL(wp), DIMENSION(:,:), INTENT(out) ::   plamt, plamu, plamv, plamf   ! longitude outputs                     [degrees]
55      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pphit, pphiu, pphiv, pphif   ! latitude outputs                      [degrees]
56      INTEGER                 , INTENT(out) ::   kff                          ! =1 Coriolis parameter computed here, =0 otherwise
57      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pff_f, pff_t                 ! Coriolis factor at f-point                [1/s]
58      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1t, pe1u, pe1v, pe1f       ! i-scale factors                             [m]
59      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe2t, pe2u, pe2v, pe2f       ! j-scale factors                             [m]
60      INTEGER                 , INTENT(out) ::   ke1e2u_v                     ! =1 u- & v-surfaces computed here, =0 otherwise
61      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1e2u, pe1e2v               ! u- & v-surfaces (if reduction in strait)   [m2]
62      !
63      INTEGER  ::   ji, jj   ! dummy loop indices
64      REAL(wp) ::   zphi0, zlam0, zbeta, zf0
65      REAL(wp) ::   zti, zui, ztj, zvj   ! local scalars
66      !!-------------------------------------------------------------------------------
67      !
68      IF(lwp) WRITE(numout,*)
69      IF(lwp) WRITE(numout,*) 'usr_def_hgr : CANAL configuration bassin'
70      IF(lwp) WRITE(numout,*)
71      IF(lwp) WRITE(numout,*) '          Beta-plane with regular grid-spacing'
72      IF(lwp) WRITE(numout,*) '          given by rn_dx and rn_dy' 
73      !
74      !                         
75      ! Position coordinates (in kilometers)
76      !                          ==========
77      zlam0 = -REAL(NINT(jpiglo*rn_0xratio)-1, wp) * rn_dx
78      zphi0 = -REAL(NINT(jpjglo*rn_0yratio)-1, wp) * rn_dy 
79
80#if defined key_agrif
81      ! ! let lower left longitude and latitude from parent
82      IF (.NOT.Agrif_root()) THEN
83          zlam0 = (0.5_wp-(Agrif_parent(jpiglo)-1)/2)*Agrif_irhox()*rn_dx &
84             &+(Agrif_Ix()+nbghostcells-1)*Agrif_irhox()*rn_dx-(0.5_wp+nbghostcells)*rn_dx
85          zphi0 = (0.5_wp-(Agrif_parent(jpjglo)-1)/2)*Agrif_irhoy()*rn_dy &
86             &+(Agrif_Iy()+nbghostcells-1)*Agrif_irhoy()*rn_dy-(0.5_wp+nbghostcells)*rn_dy
87      ENDIF 
88#endif
89         
90      DO jj = 1, jpj
91         DO ji = 1, jpi
92            zti = FLOAT( ji - 1 + nimpp - 1 )          ;  ztj = FLOAT( jj - 1 + njmpp - 1 )
93            zui = FLOAT( ji - 1 + nimpp - 1 ) + 0.5_wp ;  zvj = FLOAT( jj - 1 + njmpp - 1 ) + 0.5_wp
94
95            plamt(ji,jj) = zlam0 + rn_dx * zti
96            plamu(ji,jj) = zlam0 + rn_dx * zui
97            plamv(ji,jj) = plamt(ji,jj) 
98            plamf(ji,jj) = plamu(ji,jj) 
99   
100            pphit(ji,jj) = zphi0 + rn_dy * ztj
101            pphiv(ji,jj) = zphi0 + rn_dy * zvj
102            pphiu(ji,jj) = pphit(ji,jj) 
103            pphif(ji,jj) = pphiv(ji,jj) 
104         END DO
105      END DO
106      !     
107      ! Horizontal scale factors (in meters)
108      !                              ======
109      pe1t(:,:) = rn_dx * 1.e+3  ;   pe2t(:,:) = rn_dy * 1.e+3 
110      pe1u(:,:) = rn_dx * 1.e+3  ;   pe2u(:,:) = rn_dy * 1.e+3
111      pe1v(:,:) = rn_dx * 1.e+3  ;   pe2v(:,:) = rn_dy * 1.e+3
112      pe1f(:,:) = rn_dx * 1.e+3  ;   pe2f(:,:) = rn_dy * 1.e+3 
113
114      !                             ! NO reduction of grid size in some straits
115      ke1e2u_v = 0                  !    ==>> u_ & v_surfaces will be computed in dom_hgr routine
116      pe1e2u(:,:) = 0._wp           !    CAUTION: set to zero to avoid error with some compilers that
117      pe1e2v(:,:) = 0._wp           !             require an initialization of INTENT(out) arguments
118      !
119      !
120      !                       !==  Coriolis parameter  ==!
121      kff = 1                       !  indicate not to compute Coriolis parameter afterward
122      !
123      SELECT CASE(nn_fcase)
124      CASE(0)
125         zf0   = 2._wp * omega * SIN( rad * rn_ppgphi0 )
126         pff_f(:,:) = zf0
127         pff_t(:,:) = zf0
128      CASE(1)
129         zbeta = 2._wp * omega * COS( rad * rn_ppgphi0 ) / ra
130         zf0   = 2._wp * omega * SIN( rad * rn_ppgphi0 )
131         pff_f(:,:) = zf0 + zbeta * pphif(:,:) * 1.e+3
132         pff_t(:,:) = zf0 + zbeta * pphit(:,:) * 1.e+3
133      CASE(2)
134         pff_f(:,:) = 2._wp * omega * SIN( rad * ( rn_ppgphi0 + pphif(:,:)/110. ) )
135         pff_t(:,:) = 2._wp * omega * SIN( rad * ( rn_ppgphi0 + pphit(:,:)/110. ) )
136      END SELECT
137      !
138   END SUBROUTINE usr_def_hgr
139
140   !!======================================================================
141END MODULE usrdef_hgr
Note: See TracBrowser for help on using the repository browser.