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

source: NEMO/trunk/tests/TSUNAMI/MY_SRC/usrdef_hgr.F90 @ 14433

Last change on this file since 14433 was 14433, checked in by smasson, 3 years ago

trunk: merge dev_r14312_MPI_Interface into the trunk, #2598

File size: 7.1 KB
Line 
1MODULE usrdef_hgr
2   !!======================================================================
3   !!                       ***  MODULE  usrdef_hgr  ***
4   !!
5   !!                      ===  TSUNAMI 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 TSUNAMI 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   !! * Substitutions
29#  include "do_loop_substitute.h90"
30   !!----------------------------------------------------------------------
31   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
32   !! $Id: usrdef_hgr.F90 14223 2020-12-19 10:22:45Z smasson $
33   !! Software governed by the CeCILL license (see ./LICENSE)
34   !!----------------------------------------------------------------------
35CONTAINS
36
37   SUBROUTINE usr_def_hgr( plamt , plamu , plamv  , plamf  ,   &   ! geographic position (required)
38      &                    pphit , pphiu , pphiv  , pphif  ,   &   !
39      &                    kff   , pff_f , pff_t  ,            &   ! Coriolis parameter  (if domain not on the sphere)
40      &                    pe1t  , pe1u  , pe1v   , pe1f   ,   &   ! scale factors       (required)
41      &                    pe2t  , pe2u  , pe2v   , pe2f   ,   &   !
42      &                    ke1e2u_v      , pe1e2u , pe1e2v     )   ! u- & v-surfaces (if gridsize reduction is used in strait(s))
43      !!----------------------------------------------------------------------
44      !!                  ***  ROUTINE usr_def_hgr  ***
45      !!
46      !! ** Purpose :   user defined mesh and Coriolis parameter
47      !!
48      !! ** Method  :   set all intent(out) argument to a proper value
49      !!                TSUNAMI configuration : beta-plance with uniform grid spacing (rn_dx)
50      !!
51      !! ** Action  : - define longitude & latitude of t-, u-, v- and f-points (in degrees)
52      !!              - define coriolis parameter at f-point if the domain in not on the sphere (on beta-plane)
53      !!              - define i- & j-scale factors at t-, u-, v- and f-points (in meters)
54      !!              - define u- & v-surfaces (if gridsize reduction is used in some straits) (in m2)
55      !!----------------------------------------------------------------------
56      REAL(wp), DIMENSION(:,:), INTENT(out) ::   plamt, plamu, plamv, plamf   ! longitude outputs                     [degrees]
57      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pphit, pphiu, pphiv, pphif   ! latitude outputs                      [degrees]
58      INTEGER                 , INTENT(out) ::   kff                          ! =1 Coriolis parameter computed here, =0 otherwise
59      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pff_f, pff_t                 ! Coriolis factor at f-point                [1/s]
60      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1t, pe1u, pe1v, pe1f       ! i-scale factors                             [m]
61      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe2t, pe2u, pe2v, pe2f       ! j-scale factors                             [m]
62      INTEGER                 , INTENT(out) ::   ke1e2u_v                     ! =1 u- & v-surfaces computed here, =0 otherwise
63      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1e2u, pe1e2v               ! u- & v-surfaces (if reduction in strait)   [m2]
64      !
65      INTEGER  ::   ji, jj     ! dummy loop indices
66      INTEGER  ::   ii0, ij0   ! dummy loop indices
67      REAL(wp) ::   zbeta, zf0
68      REAL(wp) ::   zti, ztj   ! local scalars
69      !!-------------------------------------------------------------------------------
70      !
71      IF(lwp) WRITE(numout,*)
72      IF(lwp) WRITE(numout,*) 'usr_def_hgr : TSUNAMI 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      ii0 = NINT( REAL(Ni0glo, wp) * rn_0xratio )
81      ij0 = NINT( REAL(Nj0glo, wp) * rn_0yratio )
82
83#if defined key_agrif
84      ! ! let lower left longitude and latitude from parent
85      IF (.NOT.Agrif_root()) THEN
86          to be coded...
87      ENDIF 
88#endif
89         
90      DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )         
91         zti = REAL( mig0(ji)-ii0, wp )   ! =0 at i=ii0 in the global grid without halos
92         ztj = REAL( mjg0(jj)-ij0, wp )   ! =0 at i=ij0 in the global grid without halos
93         
94         plamt(ji,jj) = rn_dx *   zti
95         plamu(ji,jj) = rn_dx * ( zti + 0.5_wp ) 
96         plamv(ji,jj) = plamt(ji,jj) 
97         plamf(ji,jj) = plamu(ji,jj) 
98         
99         pphit(ji,jj) = rn_dy *   ztj
100         pphiv(ji,jj) = rn_dy * ( ztj + 0.5_wp ) 
101         pphiu(ji,jj) = pphit(ji,jj) 
102         pphif(ji,jj) = pphiv(ji,jj) 
103      END_2D
104      !     
105      ! Horizontal scale factors (in meters)
106      !                              ======
107      pe1t(:,:) = rn_dx * 1.e+3  ;   pe2t(:,:) = rn_dy * 1.e+3 
108      pe1u(:,:) = rn_dx * 1.e+3  ;   pe2u(:,:) = rn_dy * 1.e+3
109      pe1v(:,:) = rn_dx * 1.e+3  ;   pe2v(:,:) = rn_dy * 1.e+3
110      pe1f(:,:) = rn_dx * 1.e+3  ;   pe2f(:,:) = rn_dy * 1.e+3 
111
112      !                             ! NO reduction of grid size in some straits
113      ke1e2u_v = 0                  !    ==>> u_ & v_surfaces will be computed in dom_hgr routine
114      pe1e2u(:,:) = 0._wp           !    CAUTION: set to zero to avoid error with some compilers that
115      pe1e2v(:,:) = 0._wp           !             require an initialization of INTENT(out) arguments
116      !
117      !
118      !                       !==  Coriolis parameter  ==!
119      kff = 1                       !  indicate not to compute Coriolis parameter afterward
120      !
121      SELECT CASE(nn_fcase)
122      CASE(0)
123         zf0   = 2._wp * omega * SIN( rad * rn_ppgphi0 )
124         pff_f(:,:) = zf0
125         pff_t(:,:) = zf0
126      CASE(1)
127         zbeta = 2._wp * omega * COS( rad * rn_ppgphi0 ) / ra
128         zf0   = 2._wp * omega * SIN( rad * rn_ppgphi0 )
129         pff_f(:,:) = zf0 + zbeta * pphif(:,:) * 1.e+3
130         pff_t(:,:) = zf0 + zbeta * pphit(:,:) * 1.e+3
131      CASE(2)
132         pff_f(:,:) = 2._wp * omega * SIN( rad * ( rn_ppgphi0 + pphif(:,:)/110. ) )
133         pff_t(:,:) = 2._wp * omega * SIN( rad * ( rn_ppgphi0 + pphit(:,:)/110. ) )
134      END SELECT
135      !
136   END SUBROUTINE usr_def_hgr
137
138   !!======================================================================
139END MODULE usrdef_hgr
Note: See TracBrowser for help on using the repository browser.