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/VORTEX/MY_SRC – NEMO

source: branches/2017/dev_merge_2017/NEMOGCM/CONFIG/TEST_CASES/VORTEX/MY_SRC/usrdef_hgr.F90 @ 9113

Last change on this file since 9113 was 9113, checked in by jchanut, 6 years ago

Properly take into account ghostcells in VORTEX domain definition

File size: 7.1 KB
Line 
1MODULE usrdef_hgr
2   !!======================================================================
3   !!                       ***  MODULE  usrdef_hgr  ***
4   !!
5   !!                      ===  VORTEX 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 VORTEX 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_ppgphi0   ! horizontal resolution in meters
19   !                                                  and reference latitude
20   USE in_out_manager  ! I/O manager
21   USE lib_mpp         ! MPP library
22   USE timing          ! Timing
23   
24   IMPLICIT NONE
25   PRIVATE
26
27   PUBLIC   usr_def_hgr   ! called by domhgr.F90
28
29   !!----------------------------------------------------------------------
30   !! NEMO/OPA 4.0, NEMO Consortium (2016)
31   !! $Id$
32   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
33   !!----------------------------------------------------------------------
34CONTAINS
35
36   SUBROUTINE usr_def_hgr( plamt , plamu , plamv  , plamf  ,   &   ! geographic position (required)
37      &                    pphit , pphiu , pphiv  , pphif  ,   &   !
38      &                    kff   , pff_f , pff_t  ,            &   ! Coriolis parameter  (if domain not on the sphere)
39      &                    pe1t  , pe1u  , pe1v   , pe1f   ,   &   ! scale factors       (required)
40      &                    pe2t  , pe2u  , pe2v   , pe2f   ,   &   !
41      &                    ke1e2u_v      , pe1e2u , pe1e2v     )   ! u- & v-surfaces (if gridsize reduction is used in strait(s))
42      !!----------------------------------------------------------------------
43      !!                  ***  ROUTINE usr_def_hgr  ***
44      !!
45      !! ** Purpose :   user defined mesh and Coriolis parameter
46      !!
47      !! ** Method  :   set all intent(out) argument to a proper value
48      !!                VORTEX configuration : beta-plance with uniform grid spacing (rn_dx)
49      !!
50      !! ** Action  : - define longitude & latitude of t-, u-, v- and f-points (in degrees)
51      !!              - define coriolis parameter at f-point if the domain in not on the sphere (on beta-plane)
52      !!              - define i- & j-scale factors at t-, u-, v- and f-points (in meters)
53      !!              - define u- & v-surfaces (if gridsize reduction is used in some straits) (in m2)
54      !!----------------------------------------------------------------------
55      REAL(wp), DIMENSION(:,:), INTENT(out) ::   plamt, plamu, plamv, plamf   ! longitude outputs                     [degrees]
56      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pphit, pphiu, pphiv, pphif   ! latitude outputs                      [degrees]
57      INTEGER                 , INTENT(out) ::   kff                          ! =1 Coriolis parameter computed here, =0 otherwise
58      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pff_f, pff_t                 ! Coriolis factor at f-point                [1/s]
59      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1t, pe1u, pe1v, pe1f       ! i-scale factors                             [m]
60      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe2t, pe2u, pe2v, pe2f       ! j-scale factors                             [m]
61      INTEGER                 , INTENT(out) ::   ke1e2u_v                     ! =1 u- & v-surfaces computed here, =0 otherwise
62      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1e2u, pe1e2v               ! u- & v-surfaces (if reduction in strait)   [m2]
63      !
64      INTEGER  ::   ji, jj   ! dummy loop indices
65      REAL(wp) ::   zphi0, zlam0, zbeta, zf0
66      REAL(wp) ::   zti, zui, ztj, zvj   ! local scalars
67      !!-------------------------------------------------------------------------------
68      !
69      IF( nn_timing == 1 )  CALL timing_start('usr_def_hgr')
70      !
71      IF(lwp) WRITE(numout,*)
72      IF(lwp) WRITE(numout,*) 'usr_def_hgr : VORTEX configuration bassin'
73      IF(lwp) WRITE(numout,*)
74      IF(lwp) WRITE(numout,*) '          Beta-plane with regular grid-spacing'
75      IF(lwp) WRITE(numout,*) '          given by rn_dx and rn_dy' 
76      !
77      !                         
78      ! Position coordinates (in kilometers)
79      !                          ==========
80      zlam0 = -(jpiglo-1)/2 * 1.e-3 * rn_dx
81      zphi0 = -(jpjglo-1)/2 * 1.e-3 * rn_dy 
82
83#if defined key_agrif
84      ! ! let lower left longitude and latitude from parent
85      IF (.NOT.Agrif_root()) THEN
86          zlam0 = (0.5_wp-(Agrif_parent(jpiglo)-1)/2)*1.e-3*Agrif_irhox()*rn_dx &
87             &+(Agrif_Ix()+nbghostcells-1)*Agrif_irhox()*rn_dx*1.e-3-(0.5_wp+nbghostcells)*rn_dx*1.e-3
88          zphi0 = (0.5_wp-(Agrif_parent(jpjglo)-1)/2)*1.e-3*Agrif_irhoy()*rn_dy &
89             &+(Agrif_Iy()+nbghostcells-1)*Agrif_irhoy()*rn_dy*1.e-3-(0.5_wp+nbghostcells)*rn_dy*1.e-3
90      ENDIF 
91#endif
92         
93      DO jj = 1, jpj
94         DO ji = 1, jpi
95            zti = FLOAT( ji - 1 + nimpp - 1 )          ;  ztj = FLOAT( jj - 1 + njmpp - 1 )
96            zui = FLOAT( ji - 1 + nimpp - 1 ) + 0.5_wp ;  zvj = FLOAT( jj - 1 + njmpp - 1 ) + 0.5_wp
97
98            plamt(ji,jj) = zlam0 + rn_dx * 1.e-3 * zti
99            plamu(ji,jj) = zlam0 + rn_dx * 1.e-3 * zui
100            plamv(ji,jj) = plamt(ji,jj) 
101            plamf(ji,jj) = plamu(ji,jj) 
102   
103            pphit(ji,jj) = zphi0 + rn_dy * 1.e-3 * ztj
104            pphiv(ji,jj) = zphi0 + rn_dy * 1.e-3 * zvj
105            pphiu(ji,jj) = pphit(ji,jj) 
106            pphif(ji,jj) = pphiv(ji,jj) 
107         END DO
108      END DO
109      !     
110      ! Horizontal scale factors (in meters)
111      !                              ======
112      pe1t(:,:) = rn_dx  ;   pe2t(:,:) = rn_dy 
113      pe1u(:,:) = rn_dx  ;   pe2u(:,:) = rn_dy 
114      pe1v(:,:) = rn_dx  ;   pe2v(:,:) = rn_dy 
115      pe1f(:,:) = rn_dx  ;   pe2f(:,:) = rn_dy 
116
117      !                             ! NO reduction of grid size in some straits
118      ke1e2u_v = 0                  !    ==>> u_ & v_surfaces will be computed in dom_hgr routine
119      pe1e2u(:,:) = 0._wp           !    CAUTION: set to zero to avoid error with some compilers that
120      pe1e2v(:,:) = 0._wp           !             require an initialization of INTENT(out) arguments
121      !
122      !
123      !                       !==  Coriolis parameter  ==!
124      kff = 1                       !  indicate not to compute Coriolis parameter afterward
125      !
126      zbeta = 2._wp * omega * COS( rad * rn_ppgphi0 ) / ra
127      zf0   = 2._wp * omega * SIN( rad * rn_ppgphi0 )
128      pff_f(:,:) = zf0 + zbeta * pphif(:,:) * 1.e+3
129      pff_t(:,:) = zf0 + zbeta * pphit(:,:) * 1.e+3
130      !
131      IF( nn_timing == 1 )  CALL timing_stop('usr_def_hgr')
132      !
133      END SUBROUTINE usr_def_hgr
134
135   !!======================================================================
136END MODULE usrdef_hgr
Note: See TracBrowser for help on using the repository browser.