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

source: NEMO/trunk/tests/VORTEX/MY_SRC/usrdef_hgr.F90

Last change on this file was 15119, checked in by jchanut, 3 years ago

#2638, changes to accomodate nn_hls=2 and AGRIF zooms crossing cyclic boundaries. E-W case ok, update for North-Fold still needed.

  • Property svn:keywords set to Id
File size: 7.2 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   
23   IMPLICIT NONE
24   PRIVATE
25
26   REAL(wp) :: roffsetx, roffsety ! Offset in km to first f-point
27
28   PUBLIC   usr_def_hgr   ! called by domhgr.F90
29
30   !! * Substitutions
31#  include "do_loop_substitute.h90"
32   !!----------------------------------------------------------------------
33   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
34   !! $Id$
35   !! Software governed by the CeCILL license (see ./LICENSE)
36   !!----------------------------------------------------------------------
37CONTAINS
38
39   SUBROUTINE usr_def_hgr( plamt , plamu , plamv  , plamf  ,   &   ! geographic position (required)
40      &                    pphit , pphiu , pphiv  , pphif  ,   &   !
41      &                    kff   , pff_f , pff_t  ,            &   ! Coriolis parameter  (if domain not on the sphere)
42      &                    pe1t  , pe1u  , pe1v   , pe1f   ,   &   ! scale factors       (required)
43      &                    pe2t  , pe2u  , pe2v   , pe2f   ,   &   !
44      &                    ke1e2u_v      , pe1e2u , pe1e2v     )   ! u- & v-surfaces (if gridsize reduction is used in strait(s))
45      !!----------------------------------------------------------------------
46      !!                  ***  ROUTINE usr_def_hgr  ***
47      !!
48      !! ** Purpose :   user defined mesh and Coriolis parameter
49      !!
50      !! ** Method  :   set all intent(out) argument to a proper value
51      !!                VORTEX configuration : beta-plance with uniform grid spacing (rn_dx)
52      !!
53      !! ** Action  : - define longitude & latitude of t-, u-, v- and f-points (in degrees)
54      !!              - define coriolis parameter at f-point if the domain in not on the sphere (on beta-plane)
55      !!              - define i- & j-scale factors at t-, u-, v- and f-points (in meters)
56      !!              - define u- & v-surfaces (if gridsize reduction is used in some straits) (in m2)
57      !!----------------------------------------------------------------------
58      REAL(wp), DIMENSION(:,:), INTENT(out) ::   plamt, plamu, plamv, plamf   ! longitude outputs                     [degrees]
59      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pphit, pphiu, pphiv, pphif   ! latitude outputs                      [degrees]
60      INTEGER                 , INTENT(out) ::   kff                          ! =1 Coriolis parameter computed here, =0 otherwise
61      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pff_f, pff_t                 ! Coriolis factor at f-point                [1/s]
62      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1t, pe1u, pe1v, pe1f       ! i-scale factors                             [m]
63      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe2t, pe2u, pe2v, pe2f       ! j-scale factors                             [m]
64      INTEGER                 , INTENT(out) ::   ke1e2u_v                     ! =1 u- & v-surfaces computed here, =0 otherwise
65      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1e2u, pe1e2v               ! u- & v-surfaces (if reduction in strait)   [m2]
66      !
67      INTEGER  ::   ji, jj     ! dummy loop indices
68      REAL(wp) ::   zbeta, zf0
69      REAL(wp) ::   zti, ztj   ! local scalars
70      !!-------------------------------------------------------------------------------
71      !
72      IF(lwp) WRITE(numout,*)
73      IF(lwp) WRITE(numout,*) 'usr_def_hgr : VORTEX configuration bassin'
74      IF(lwp) WRITE(numout,*)
75      IF(lwp) WRITE(numout,*) '          Beta-plane with regular grid-spacing'
76      IF(lwp) WRITE(numout,*) '          given by rn_dx and rn_dy' 
77      !
78      !                         
79      ! Position coordinates (in kilometers)
80      !                          ==========
81      ! offset is given at first f-point, i.e. at (i,j) = (nn_hls+1, nn_hls+1)
82      ! Here we assume the grid is centred around a T-point at the middle of
83      ! of the domain (hence domain size is odd)
84      roffsetx = (-REAL(Ni0glo-1, wp) + 1._wp) * 0.5 * 1.e-3 * rn_dx
85      roffsety = (-REAL(Nj0glo-1, wp) + 1._wp) * 0.5 * 1.e-3 * rn_dy
86#if defined key_agrif
87      IF( .NOT.Agrif_Root() ) THEN
88         ! deduce offset from parent:
89         roffsetx = Agrif_Parent(roffsetx) &
90                  & + (-(nbghostcells_x_w - 1) + (Agrif_Parent(nbghostcells_x_w) + Agrif_Ix()-2)*Agrif_Rhox()) * 1.e-3 * rn_dx
91         roffsety = Agrif_Parent(roffsety) &
92                  & + (-(nbghostcells_y_s - 1) + (Agrif_Parent(nbghostcells_y_s) + Agrif_Iy()-2)*Agrif_Rhoy()) * 1.e-3 * rn_dy
93      ENDIF
94#endif         
95      DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
96         zti = REAL( mig0(ji)-1, wp )  ! start at i=0 in the global grid without halos
97         ztj = REAL( mjg0(jj)-1, wp )  ! start at j=0 in the global grid without halos
98         
99         plamt(ji,jj) = roffsetx + rn_dx * 1.e-3 * ( zti - 0.5_wp )
100         plamu(ji,jj) = roffsetx + rn_dx * 1.e-3 *   zti 
101         plamv(ji,jj) = plamt(ji,jj) 
102         plamf(ji,jj) = plamu(ji,jj) 
103         
104         pphit(ji,jj) = roffsety + rn_dy * 1.e-3 * ( ztj - 0.5_wp )
105         pphiv(ji,jj) = roffsety + rn_dy * 1.e-3 *   ztj 
106         pphiu(ji,jj) = pphit(ji,jj) 
107         pphif(ji,jj) = pphiv(ji,jj) 
108      END_2D
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   END SUBROUTINE usr_def_hgr
132
133   !!======================================================================
134END MODULE usrdef_hgr
Note: See TracBrowser for help on using the repository browser.