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/UKMO/dev_r8864_restart_date/NEMOGCM/CONFIG/TEST_CASES/SAS_BIPER/MY_SRC – NEMO

source: branches/UKMO/dev_r8864_restart_date/NEMOGCM/CONFIG/TEST_CASES/SAS_BIPER/MY_SRC/usrdef_hgr.F90 @ 9235

Last change on this file since 9235 was 9235, checked in by davestorkey, 6 years ago

UKMO/dev_r8864_restart_date : clear SVN keywords.

File size: 8.5 KB
Line 
1MODULE usrdef_hgr
2   !!======================================================================
3   !!                       ***  MODULE  usrdef_hgr  ***
4   !!
5   !!                     ===  SAS_BIPER configuration  ===
6   !!
7   !! User defined :   mesh and Coriolis parameter of a user configuration
8   !!======================================================================
9   !! History :  NEMO  ! 2016-08  (S. Flavoni, G. Madec)  Original code
10   !!----------------------------------------------------------------------
11
12   !!----------------------------------------------------------------------
13   !!   usr_def_hgr    : initialize the horizontal mesh for SAS_BIPER 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   ! horizontal resolution in meters
19   !
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      !!                SAS_BIPER configuration : uniform grid spacing (rn_dx)
49      !!                without Coriolis force (f=0)
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      REAL(wp) ::   zphi0, zlam0
67      REAL(wp) ::   zti, zui, zvi, zfi   ! local scalars
68      REAL(wp) ::   ztj, zuj, zvj, zfj   !   -      -
69      !!-------------------------------------------------------------------------------
70      !
71      IF( nn_timing == 1 )  CALL timing_start('usr_def_hgr')
72      !
73      IF(lwp) WRITE(numout,*)
74      IF(lwp) WRITE(numout,*) 'usr_def_hgr : SAS_BIPER configuration bassin'
75      IF(lwp) WRITE(numout,*)
76      IF(lwp) WRITE(numout,*) '          f-plane with irregular grid-spacing (+- 10%)'
77      IF(lwp) WRITE(numout,*) '          the max is given by rn_dx and rn_dy' 
78
79      !                          ==========
80      zlam0 = 0._wp
81      zphi0 = 0._wp
82         
83#if defined key_agrif 
84      IF( .NOT. Agrif_Root() ) THEN
85         zlam0  = Agrif_Parent(zlam0) + (Agrif_ix())*Agrif_Parent(rn_dx) * 1.e-5
86         zphi0  = Agrif_Parent(zphi0) + (Agrif_iy())*Agrif_Parent(rn_dy) * 1.e-5
87         rn_dx = Agrif_Parent(rn_dx)/Agrif_Rhox()
88         rn_dy = Agrif_Parent(rn_dy)/Agrif_Rhoy()         
89      ENDIF
90#endif         
91
92      DO jj = 1, jpj
93         DO ji = 1, jpi
94            zti = FLOAT( ji - 1 + nimpp - 1 )         ;   ztj = FLOAT( jj - 1 + njmpp - 1 )
95            zui = FLOAT( ji - 1 + nimpp - 1 ) + 0.5   ;   zuj = FLOAT( jj - 1 + njmpp - 1 )
96            zvi = FLOAT( ji - 1 + nimpp - 1 )         ;   zvj = FLOAT( jj - 1 + njmpp - 1 ) + 0.5
97            zfi = FLOAT( ji - 1 + nimpp - 1 ) + 0.5   ;   zfj = FLOAT( jj - 1 + njmpp - 1 ) + 0.5
98
99            plamt(ji,jj) = zlam0 + rn_dx * 1.e-5 * zti
100            plamu(ji,jj) = zlam0 + rn_dx * 1.e-5 * zui
101            plamv(ji,jj) = zlam0 + rn_dx * 1.e-5 * zvi
102            plamf(ji,jj) = zlam0 + rn_dx * 1.e-5 * zfi
103   
104            pphit(ji,jj) = zphi0 + rn_dy * 1.e-5 * ztj
105            pphiu(ji,jj) = zphi0 + rn_dy * 1.e-5 * zuj
106            pphiv(ji,jj) = zphi0 + rn_dy * 1.e-5 * zvj
107            pphif(ji,jj) = zphi0 + rn_dy * 1.e-5 * zfj
108         END DO
109      END DO
110         
111         ! Horizontal scale factors (in meters)
112         !                              ======
113!! ==> EITHER 1) variable scale factors
114         DO jj = 1, jpj
115            DO ji = 1, jpi
116               !!pe1t(ji,jj) = rn_dx * EXP( -0.8/REAL(jpiglo**2) * (mi0(ji)-REAL(jpiglo+1)*0.5)**2 )  ! gaussian shape
117               !!pe2t(ji,jj) = rn_dy * EXP( -0.8/REAL(jpjglo**2) * (mj0(jj)-REAL(jpjglo+1)*0.5)**2 )  ! gaussian shape
118               pe1t(ji,jj) = rn_dx * ( 1. -0.1 * ABS(REAL(mi0(ji))-REAL(jpiglo+1)*0.5) / (1.-REAL(jpiglo+1)*0.5) ) ! linear shape
119               pe2t(ji,jj) = rn_dy * ( 1. -0.1 * ABS(REAL(mj0(jj))-REAL(jpjglo+1)*0.5) / (1.-REAL(jpjglo+1)*0.5) ) ! linear shape
120            END DO
121         END DO
122#if defined key_agrif 
123         IF( .NOT. Agrif_Root() ) THEN ! only works if the zoom is positioned at the center of the parent grid
124            DO jj = 1, jpj
125               DO ji = 1, jpi
126                  pe1t(ji,jj) = rn_dx * ( 1. -0.1 * ABS(REAL(mi0(ji))-REAL(jpiglo+1)*0.5) / (1.-REAL(jpiglo+1)*0.5)  &
127                     &                            * REAL(jpiglo) / REAL(Agrif_Parent(jpiglo) * Agrif_Rhox()) )       ! factor to match parent grid
128                  pe2t(ji,jj) = rn_dy * ( 1. -0.1 * ABS(REAL(mj0(jj))-REAL(jpjglo+1)*0.5) / (1.-REAL(jpjglo+1)*0.5)  &
129                     &                            * REAL(jpjglo) / REAL(Agrif_Parent(jpjglo) * Agrif_Rhoy()) )       ! factor to match parent grid
130               END DO
131            END DO
132         ENDIF
133#endif
134!! ==> OR 2) constant scale factors
135!!         pe1t(:,:) = rn_dx
136!!         pe2t(:,:) = rn_dy
137         
138         pe1u(:,:) = pe1t(:,:)      ;      pe2u(:,:) = pe2t(:,:)
139         pe1v(:,:) = pe1t(:,:)      ;      pe2v(:,:) = pe2t(:,:)
140         pe1f(:,:) = pe1t(:,:)      ;      pe2f(:,:) = pe2t(:,:)
141
142      !                             ! NO reduction of grid size in some straits
143      ke1e2u_v = 0                  !    ==>> u_ & v_surfaces will be computed in dom_ghr routine
144      pe1e2u(:,:) = 0._wp           !    CAUTION: set to zero to avoid error with some compilers that
145      pe1e2v(:,:) = 0._wp           !             require an initialization of INTENT(out) arguments
146      !
147      !
148      !                       !==  Coriolis parameter  ==!
149      kff = 1                       !  indicate not to compute Coriolis parameter afterward
150      !
151      pff_f(:,:) = 0._wp            ! here No earth rotation: f=0
152      pff_t(:,:) = 0._wp
153      !
154      IF( nn_timing == 1 )  CALL timing_stop('usr_def_hgr')
155      !
156      END SUBROUTINE usr_def_hgr
157
158   !!======================================================================
159END MODULE usrdef_hgr
Note: See TracBrowser for help on using the repository browser.