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/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/ICE_AGRIF/MY_SRC – NEMO

source: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/ICE_AGRIF/MY_SRC/usrdef_hgr.F90 @ 12960

Last change on this file since 12960 was 12960, checked in by smasson, 4 years ago

Extra_Halo: additional bugfixes and developments, see #2366

  • Property svn:keywords set to Id
File size: 8.9 KB
Line 
1MODULE usrdef_hgr
2   !!======================================================================
3   !!                       ***  MODULE  usrdef_hgr  ***
4   !!
5   !!                      ===  ICE_AGRIF 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 ICE_AGRIF 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, ln_corio, rn_ppgphi0   ! horizontal resolution in meters
19   !                                                            coriolis 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$
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      !!                ICE_AGRIF configuration : uniform grid spacing (rn_dx)
50      !!                without Coriolis force (f=0)
51      !!
52      !! ** Action  : - define longitude & latitude of t-, u-, v- and f-points (in degrees)
53      !!              - define coriolis parameter at f-point if the domain in not on the sphere (on beta-plane)
54      !!              - define i- & j-scale factors at t-, u-, v- and f-points (in meters)
55      !!              - define u- & v-surfaces (if gridsize reduction is used in some straits) (in m2)
56      !!----------------------------------------------------------------------
57      REAL(wp), DIMENSION(:,:), INTENT(out) ::   plamt, plamu, plamv, plamf   ! longitude outputs                     [degrees]
58      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pphit, pphiu, pphiv, pphif   ! latitude outputs                      [degrees]
59      INTEGER                 , INTENT(out) ::   kff                          ! =1 Coriolis parameter computed here, =0 otherwise
60      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pff_f, pff_t                 ! Coriolis factor at f-point                [1/s]
61      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1t, pe1u, pe1v, pe1f       ! i-scale factors                             [m]
62      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe2t, pe2u, pe2v, pe2f       ! j-scale factors                             [m]
63      INTEGER                 , INTENT(out) ::   ke1e2u_v                     ! =1 u- & v-surfaces computed here, =0 otherwise
64      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1e2u, pe1e2v               ! u- & v-surfaces (if reduction in strait)   [m2]
65      !
66      INTEGER  ::   ji, jj     ! dummy loop indices
67      REAL(wp) ::   zphi0, zlam0, zbeta, zf0
68      REAL(wp) ::   zti, ztj   ! local scalars
69      !!-------------------------------------------------------------------------------
70      !
71      IF(lwp) WRITE(numout,*)
72      IF(lwp) WRITE(numout,*) 'usr_def_hgr : ICE_AGRIF configuration bassin'
73      IF(lwp) WRITE(numout,*)
74      IF(lwp) WRITE(numout,*) '          f-plane with irregular grid-spacing (+- 10%)'
75      IF(lwp) WRITE(numout,*) '          the max is given by rn_dx and rn_dy' 
76
77      !                          ==========
78      zlam0 = -REAL(Ni0glo-1)/2, wp) * 1.e-3 * rn_dx
79      zphi0 = -REAL(Nj0glo-1)/2, wp) * 1.e-3 * rn_dy 
80
81#if defined key_agrif 
82      IF( .NOT. Agrif_Root() ) THEN
83!clem         zlam0  = Agrif_Parent(zlam0) + (Agrif_ix())*Agrif_Parent(rn_dx) * 1.e-5
84!clem         zphi0  = Agrif_Parent(zphi0) + (Agrif_iy())*Agrif_Parent(rn_dy) * 1.e-5
85         zlam0 = ( 0.5_wp - ( Agrif_parent(jpiglo) - 1 ) / 2 ) * 1.e-3 * Agrif_irhox() * rn_dx  &
86            &  + ( Agrif_Ix() + nbghostcells - 1 ) * Agrif_irhox() * rn_dx * 1.e-3 - ( 0.5_wp + nbghostcells ) * rn_dx * 1.e-3
87         zphi0 = ( 0.5_wp - ( Agrif_parent(jpjglo) - 1 ) / 2 ) * 1.e-3 * Agrif_irhoy() * rn_dy  &
88            &  + ( Agrif_Iy() + nbghostcells - 1 ) * Agrif_irhoy() * rn_dy * 1.e-3 - ( 0.5_wp + nbghostcells ) * rn_dy * 1.e-3
89      ENDIF
90#endif         
91
92      DO_2D_11_11
93         zti = REAL( mig0_oldcmp(ji) - 1, wp )   ! start at i=0 in the global grid without halos
94         ztj = REAL( mjg0_oldcmp(jj) - 1, wp )   ! start at j=0 in the global grid without halos
95         
96         plamt(ji,jj) = zlam0 + rn_dx * 1.e-3 *   zti
97         plamu(ji,jj) = zlam0 + rn_dx * 1.e-3 * ( zti + 0.5_wp )
98         plamv(ji,jj) = plamt(ji,jj) 
99         plamf(ji,jj) = plamu(ji,jj) 
100         
101         pphit(ji,jj) = zphi0 + rn_dy * 1.e-3 *   ztj
102         pphiv(ji,jj) = zphi0 + rn_dy * 1.e-3 * ( ztj + 0.5_wp )
103         pphiu(ji,jj) = pphit(ji,jj) 
104         pphif(ji,jj) = pphiv(ji,jj) 
105      END_2D
106         
107         ! Horizontal scale factors (in meters)
108         !                              ======
109!! ==> EITHER 1) variable scale factors
110!! clem: This can be used with a 1proc simulation but I think it breaks repro when >1procs are used     
111!!         DO jj = 1, jpj
112!!            DO ji = 1, jpi
113!!               !!pe1t(ji,jj) = rn_dx * EXP( -0.8/REAL(jpiglo**2) * (mi0(ji)-REAL(jpiglo+1)*0.5)**2 )  ! gaussian shape
114!!               !!pe2t(ji,jj) = rn_dy * EXP( -0.8/REAL(jpjglo**2) * (mj0(jj)-REAL(jpjglo+1)*0.5)**2 )  ! gaussian shape
115!!               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
116!!               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
117!!            END DO
118!!         END DO
119!!#if defined key_agrif
120!!         IF( .NOT. Agrif_Root() ) THEN ! only works if the zoom is positioned at the center of the parent grid
121!!            DO jj = 1, jpj
122!!               DO ji = 1, jpi
123!!                  pe1t(ji,jj) = rn_dx * ( 1. -0.1 * ABS(REAL(mi0(ji))-REAL(jpiglo+1)*0.5) / (1.-REAL(jpiglo+1)*0.5)  &
124!!                     &                            * REAL(jpiglo) / REAL(Agrif_Parent(jpiglo) * Agrif_Rhox()) )       ! factor to match parent grid
125!!                  pe2t(ji,jj) = rn_dy * ( 1. -0.1 * ABS(REAL(mj0(jj))-REAL(jpjglo+1)*0.5) / (1.-REAL(jpjglo+1)*0.5)  &
126!!                     &                            * REAL(jpjglo) / REAL(Agrif_Parent(jpjglo) * Agrif_Rhoy()) )       ! factor to match parent grid
127!!               END DO
128!!            END DO
129!!         ENDIF
130!!#endif
131!! ==> OR 2) constant scale factors
132         pe1t(:,:) = rn_dx
133         pe2t(:,:) = rn_dy
134!! ==> END
135         
136      pe1u(:,:) = pe1t(:,:)      ;      pe2u(:,:) = pe2t(:,:)
137      pe1v(:,:) = pe1t(:,:)      ;      pe2v(:,:) = pe2t(:,:)
138      pe1f(:,:) = pe1t(:,:)      ;      pe2f(:,:) = pe2t(:,:)
139
140      !                             ! NO reduction of grid size in some straits
141      ke1e2u_v = 0                  !    ==>> u_ & v_surfaces will be computed in dom_ghr routine
142      pe1e2u(:,:) = 0._wp           !    CAUTION: set to zero to avoid error with some compilers that
143      pe1e2v(:,:) = 0._wp           !             require an initialization of INTENT(out) arguments
144      !
145      !
146      !                       !==  Coriolis parameter  ==!
147      kff = 1                       !  indicate not to compute Coriolis parameter afterward
148      !
149      IF( ln_corio ) THEN
150         zbeta = 2._wp * omega * COS( rad * rn_ppgphi0 ) / ra
151         zf0   = 2._wp * omega * SIN( rad * rn_ppgphi0 )
152         pff_f(:,:) = zf0 + zbeta * pphif(:,:) * 1.e+3
153         pff_t(:,:) = zf0 + zbeta * pphit(:,:) * 1.e+3
154      ELSE
155         pff_f(:,:) = 0.
156         pff_t(:,:) = 0.
157      ENDIF
158      !
159   END SUBROUTINE usr_def_hgr
160
161   !!======================================================================
162END MODULE usrdef_hgr
Note: See TracBrowser for help on using the repository browser.