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.
dommsk.F90 in branches/2017/dev_merge_2017/NEMOGCM/NEMO/OPA_SRC/DOM – NEMO

source: branches/2017/dev_merge_2017/NEMOGCM/NEMO/OPA_SRC/DOM/dommsk.F90 @ 9169

Last change on this file since 9169 was 9169, checked in by gm, 6 years ago

dev_merge_2017: all SRC: finalize the removal of useless warning when reading namelist_cfg + remove all nn_closea + nn_msh replaced by a logical

  • Property svn:keywords set to Id
File size: 14.4 KB
Line 
1MODULE dommsk
2   !!======================================================================
3   !!                       ***  MODULE dommsk   ***
4   !! Ocean initialization : domain land/sea mask
5   !!======================================================================
6   !! History :  OPA  ! 1987-07  (G. Madec)  Original code
7   !!            6.0  ! 1993-03  (M. Guyon)  symetrical conditions (M. Guyon)
8   !!            7.0  ! 1996-01  (G. Madec)  suppression of common work arrays
9   !!             -   ! 1996-05  (G. Madec)  mask computed from tmask
10   !!            8.0  ! 1997-02  (G. Madec)  mesh information put in domhgr.F
11   !!            8.1  ! 1997-07  (G. Madec)  modification of kbat and fmask
12   !!             -   ! 1998-05  (G. Roullet)  free surface
13   !!            8.2  ! 2000-03  (G. Madec)  no slip accurate
14   !!             -   ! 2001-09  (J.-M. Molines)  Open boundaries
15   !!   NEMO     1.0  ! 2002-08  (G. Madec)  F90: Free form and module
16   !!             -   ! 2005-11  (V. Garnier) Surface pressure gradient organization
17   !!            3.2  ! 2009-07  (R. Benshila) Suppression of rigid-lid option
18   !!            3.6  ! 2015-05  (P. Mathiot) ISF: add wmask,wumask and wvmask
19   !!            4.0  ! 2016-06  (G. Madec, S. Flavoni)  domain configuration / user defined interface
20   !!----------------------------------------------------------------------
21
22   !!----------------------------------------------------------------------
23   !!   dom_msk       : compute land/ocean mask
24   !!----------------------------------------------------------------------
25   USE oce            ! ocean dynamics and tracers
26   USE dom_oce        ! ocean space and time domain
27   USE usrdef_fmask   ! user defined fmask
28   USE bdy_oce        ! open boundary
29   !
30   USE in_out_manager ! I/O manager
31   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
32   USE lib_mpp        ! Massively Parallel Processing library
33
34   IMPLICIT NONE
35   PRIVATE
36
37   PUBLIC   dom_msk    ! routine called by inidom.F90
38
39   !                            !!* Namelist namlbc : lateral boundary condition *
40   REAL(wp)        :: rn_shlat   ! type of lateral boundary condition on velocity
41   LOGICAL, PUBLIC :: ln_vorlat  !  consistency of vorticity boundary condition
42   !                                            with analytical eqs.
43
44   !! * Substitutions
45#  include "vectopt_loop_substitute.h90"
46   !!----------------------------------------------------------------------
47   !! NEMO/OPA 3.2 , LODYC-IPSL  (2009)
48   !! $Id$
49   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
50   !!----------------------------------------------------------------------
51CONTAINS
52
53   SUBROUTINE dom_msk( k_top, k_bot )
54      !!---------------------------------------------------------------------
55      !!                 ***  ROUTINE dom_msk  ***
56      !!
57      !! ** Purpose :   Compute land/ocean mask arrays at tracer points, hori-
58      !!      zontal velocity points (u & v), vorticity points (f) points.
59      !!
60      !! ** Method  :   The ocean/land mask  at t-point is deduced from ko_top
61      !!      and ko_bot, the indices of the fist and last ocean t-levels which
62      !!      are either defined in usrdef_zgr or read in zgr_read.
63      !!                The velocity masks (umask, vmask, wmask, wumask, wvmask)
64      !!      are deduced from a product of the two neighboring tmask.
65      !!                The vorticity mask (fmask) is deduced from tmask taking
66      !!      into account the choice of lateral boundary condition (rn_shlat) :
67      !!         rn_shlat = 0, free slip  (no shear along the coast)
68      !!         rn_shlat = 2, no slip  (specified zero velocity at the coast)
69      !!         0 < rn_shlat < 2, partial slip   | non-linear velocity profile
70      !!         2 < rn_shlat, strong slip        | in the lateral boundary layer
71      !!
72      !!      tmask_i : interior ocean mask at t-point, i.e. excluding duplicated
73      !!                rows/lines due to cyclic or North Fold boundaries as well
74      !!                as MPP halos.
75      !!      tmask_h : halo mask at t-point, i.e. excluding duplicated rows/lines
76      !!                due to cyclic or North Fold boundaries as well as MPP halos.
77      !!
78      !! ** Action :   tmask, umask, vmask, wmask, wumask, wvmask : land/ocean mask
79      !!                         at t-, u-, v- w, wu-, and wv-points (=0. or 1.)
80      !!               fmask   : land/ocean mask at f-point (=0., or =1., or
81      !!                         =rn_shlat along lateral boundaries)
82      !!               tmask_i : interior ocean mask
83      !!               tmask_h : halo mask
84      !!               ssmask , ssumask, ssvmask, ssfmask : 2D ocean mask
85      !!----------------------------------------------------------------------
86      INTEGER, DIMENSION(:,:), INTENT(in) ::   k_top, k_bot   ! first and last ocean level
87      !
88      INTEGER  ::   ji, jj, jk     ! dummy loop indices
89      INTEGER  ::   iif, iil       ! local integers
90      INTEGER  ::   ijf, ijl       !   -       -
91      INTEGER  ::   iktop, ikbot   !   -       -
92      INTEGER  ::   ios, inum
93      REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zwf   ! 2D workspace
94      !!
95      NAMELIST/namlbc/ rn_shlat, ln_vorlat
96      NAMELIST/nambdy/ ln_bdy ,nb_bdy, ln_coords_file, cn_coords_file,         &
97         &             ln_mask_file, cn_mask_file, cn_dyn2d, nn_dyn2d_dta,     &
98         &             cn_dyn3d, nn_dyn3d_dta, cn_tra, nn_tra_dta,             &
99         &             ln_tra_dmp, ln_dyn3d_dmp, rn_time_dmp, rn_time_dmp_out, &
100         &             cn_ice_lim, nn_ice_lim_dta,                           &
101         &             rn_ice_tem, rn_ice_sal, rn_ice_age,                 &
102         &             ln_vol, nn_volctl, nn_rimwidth, nb_jpk_bdy
103      !!---------------------------------------------------------------------
104      !
105      REWIND( numnam_ref )              ! Namelist namlbc in reference namelist : Lateral momentum boundary condition
106      READ  ( numnam_ref, namlbc, IOSTAT = ios, ERR = 901 )
107901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namlbc in reference namelist', lwp )
108      REWIND( numnam_cfg )              ! Namelist namlbc in configuration namelist : Lateral momentum boundary condition
109      READ  ( numnam_cfg, namlbc, IOSTAT = ios, ERR = 902 )
110902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namlbc in configuration namelist', lwp )
111      IF(lwm) WRITE ( numond, namlbc )
112     
113      IF(lwp) THEN                  ! control print
114         WRITE(numout,*)
115         WRITE(numout,*) 'dommsk : ocean mask '
116         WRITE(numout,*) '~~~~~~'
117         WRITE(numout,*) '   Namelist namlbc'
118         WRITE(numout,*) '      lateral momentum boundary cond.    rn_shlat  = ',rn_shlat
119         WRITE(numout,*) '      consistency with analytical form   ln_vorlat = ',ln_vorlat 
120      ENDIF
121      !
122      IF(lwp) WRITE(numout,*)
123      IF     (      rn_shlat == 0.               ) THEN   ;   IF(lwp) WRITE(numout,*) '   ==>>>   ocean lateral  free-slip'
124      ELSEIF (      rn_shlat == 2.               ) THEN   ;   IF(lwp) WRITE(numout,*) '   ==>>>   ocean lateral  no-slip'
125      ELSEIF ( 0. < rn_shlat .AND. rn_shlat < 2. ) THEN   ;   IF(lwp) WRITE(numout,*) '   ==>>>   ocean lateral  partial-slip'
126      ELSEIF ( 2. < rn_shlat                     ) THEN   ;   IF(lwp) WRITE(numout,*) '   ==>>>   ocean lateral  strong-slip'
127      ELSE
128         WRITE(ctmp1,*) ' rn_shlat is negative = ', rn_shlat
129         CALL ctl_stop( ctmp1 )
130      ENDIF
131
132
133      !  Ocean/land mask at t-point  (computed from ko_top and ko_bot)
134      ! ----------------------------
135      !
136      tmask(:,:,:) = 0._wp
137      DO jj = 1, jpj
138         DO ji = 1, jpi
139            iktop = k_top(ji,jj)
140            ikbot = k_bot(ji,jj)
141            IF( iktop /= 0 ) THEN       ! water in the column
142               tmask(ji,jj,iktop:ikbot  ) = 1._wp
143            ENDIF
144         END DO 
145      END DO 
146!SF  add here lbc_lnk: bug not still understood : cause now domain configuration is read !
147!!gm I don't understand why... 
148      CALL lbc_lnk( tmask  , 'T', 1._wp )      ! Lateral boundary conditions
149
150     ! Mask corrections for bdy (read in mppini2)
151      REWIND( numnam_ref )              ! Namelist nambdy in reference namelist :Unstructured open boundaries
152      READ  ( numnam_ref, nambdy, IOSTAT = ios, ERR = 903)
153903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy in reference namelist', lwp )
154      REWIND( numnam_cfg )              ! Namelist nambdy in configuration namelist :Unstructured open boundaries
155      READ  ( numnam_cfg, nambdy, IOSTAT = ios, ERR = 904 )
156904   IF( ios >  0 )   CALL ctl_nam ( ios , 'nambdy in configuration namelist', lwp )
157      ! ------------------------
158      IF ( ln_bdy .AND. ln_mask_file ) THEN
159         DO jk = 1, jpkm1
160            DO jj = 1, jpj
161               DO ji = 1, jpi
162                  tmask(ji,jj,jk) = tmask(ji,jj,jk) * bdytmask(ji,jj)
163               END DO
164            END DO
165         END DO
166      ENDIF
167         
168      !  Ocean/land mask at u-, v-, and f-points   (computed from tmask)
169      ! ----------------------------------------
170      ! NB: at this point, fmask is designed for free slip lateral boundary condition
171      DO jk = 1, jpk
172         DO jj = 1, jpjm1
173            DO ji = 1, fs_jpim1   ! vector loop
174               umask(ji,jj,jk) = tmask(ji,jj  ,jk) * tmask(ji+1,jj  ,jk)
175               vmask(ji,jj,jk) = tmask(ji,jj  ,jk) * tmask(ji  ,jj+1,jk)
176            END DO
177            DO ji = 1, jpim1      ! NO vector opt.
178               fmask(ji,jj,jk) = tmask(ji,jj  ,jk) * tmask(ji+1,jj  ,jk)   &
179                  &            * tmask(ji,jj+1,jk) * tmask(ji+1,jj+1,jk)
180            END DO
181         END DO
182      END DO
183      CALL lbc_lnk_multi( umask, 'U', 1., vmask, 'V', 1., fmask, 'F', 1. )      ! Lateral boundary conditions
184 
185      ! Ocean/land mask at wu-, wv- and w points    (computed from tmask)
186      !-----------------------------------------
187      wmask (:,:,1) = tmask(:,:,1)     ! surface
188      wumask(:,:,1) = umask(:,:,1)
189      wvmask(:,:,1) = vmask(:,:,1)
190      DO jk = 2, jpk                   ! interior values
191         wmask (:,:,jk) = tmask(:,:,jk) * tmask(:,:,jk-1)
192         wumask(:,:,jk) = umask(:,:,jk) * umask(:,:,jk-1)   
193         wvmask(:,:,jk) = vmask(:,:,jk) * vmask(:,:,jk-1)
194      END DO
195
196
197      ! Ocean/land column mask at t-, u-, and v-points   (i.e. at least 1 wet cell in the vertical)
198      ! ----------------------------------------------
199      ssmask (:,:) = MAXVAL( tmask(:,:,:), DIM=3 )
200      ssumask(:,:) = MAXVAL( umask(:,:,:), DIM=3 )
201      ssvmask(:,:) = MAXVAL( vmask(:,:,:), DIM=3 )
202
203
204      ! Interior domain mask  (used for global sum)
205      ! --------------------
206      !
207      iif = nn_hls   ;   iil = nlci - nn_hls + 1
208      ijf = nn_hls   ;   ijl = nlcj - nn_hls + 1
209      !
210      !                          ! halo mask : 0 on the halo and 1 elsewhere
211      tmask_h(:,:) = 1._wp                 
212      tmask_h( 1 :iif,   :   ) = 0._wp      ! first columns
213      tmask_h(iil:jpi,   :   ) = 0._wp      ! last  columns (including mpp extra columns)
214      tmask_h(   :   , 1 :ijf) = 0._wp      ! first rows
215      tmask_h(   :   ,ijl:jpj) = 0._wp      ! last  rows (including mpp extra rows)
216      !
217      !                          ! north fold mask
218      tpol(1:jpiglo) = 1._wp 
219      fpol(1:jpiglo) = 1._wp
220      IF( jperio == 3 .OR. jperio == 4 ) THEN      ! T-point pivot
221         tpol(jpiglo/2+1:jpiglo) = 0._wp
222         fpol(     1    :jpiglo) = 0._wp
223         IF( mjg(nlej) == jpjglo ) THEN                  ! only half of the nlcj-1 row for tmask_h
224            DO ji = iif+1, iil-1
225               tmask_h(ji,nlej-1) = tmask_h(ji,nlej-1) * tpol(mig(ji))
226            END DO
227         ENDIF
228      ENDIF
229      !
230      IF( jperio == 5 .OR. jperio == 6 ) THEN      ! F-point pivot
231         tpol(     1    :jpiglo) = 0._wp
232         fpol(jpiglo/2+1:jpiglo) = 0._wp
233      ENDIF
234      !
235      !                          ! interior mask : 2D ocean mask x halo mask
236      tmask_i(:,:) = ssmask(:,:) * tmask_h(:,:)
237
238
239      ! Lateral boundary conditions on velocity (modify fmask)
240      ! --------------------------------------- 
241      IF( rn_shlat /= 0 ) THEN      ! Not free-slip lateral boundary condition
242         !
243         ALLOCATE( zwf(jpi,jpj) )
244         !
245         DO jk = 1, jpk
246            zwf(:,:) = fmask(:,:,jk)         
247            DO jj = 2, jpjm1
248               DO ji = fs_2, fs_jpim1   ! vector opt.
249                  IF( fmask(ji,jj,jk) == 0._wp ) THEN
250                     fmask(ji,jj,jk) = rn_shlat * MIN( 1._wp , MAX( zwf(ji+1,jj), zwf(ji,jj+1),   &
251                        &                                           zwf(ji-1,jj), zwf(ji,jj-1)  )  )
252                  ENDIF
253               END DO
254            END DO
255            DO jj = 2, jpjm1
256               IF( fmask(1,jj,jk) == 0._wp ) THEN
257                  fmask(1  ,jj,jk) = rn_shlat * MIN( 1._wp , MAX( zwf(2,jj), zwf(1,jj+1), zwf(1,jj-1) ) )
258               ENDIF
259               IF( fmask(jpi,jj,jk) == 0._wp ) THEN
260                  fmask(jpi,jj,jk) = rn_shlat * MIN( 1._wp , MAX( zwf(jpi,jj+1), zwf(jpim1,jj), zwf(jpi,jj-1) ) )
261               ENDIF
262            END DO         
263            DO ji = 2, jpim1
264               IF( fmask(ji,1,jk) == 0._wp ) THEN
265                  fmask(ji, 1 ,jk) = rn_shlat * MIN( 1._wp , MAX( zwf(ji+1,1), zwf(ji,2), zwf(ji-1,1) ) )
266               ENDIF
267               IF( fmask(ji,jpj,jk) == 0._wp ) THEN
268                  fmask(ji,jpj,jk) = rn_shlat * MIN( 1._wp , MAX( zwf(ji+1,jpj), zwf(ji-1,jpj), zwf(ji,jpjm1) ) )
269               ENDIF
270            END DO
271#if defined key_agrif 
272            IF( .NOT. AGRIF_Root() ) THEN
273               IF ((nbondi ==  1).OR.(nbondi == 2)) fmask(nlci-1 , :     ,jk) = 0.e0      ! east
274               IF ((nbondi == -1).OR.(nbondi == 2)) fmask(1      , :     ,jk) = 0.e0      ! west
275               IF ((nbondj ==  1).OR.(nbondj == 2)) fmask(:      ,nlcj-1 ,jk) = 0.e0      ! north
276               IF ((nbondj == -1).OR.(nbondj == 2)) fmask(:      ,1      ,jk) = 0.e0      ! south
277            ENDIF 
278#endif
279         END DO
280         !
281         DEALLOCATE( zwf )
282         !
283         CALL lbc_lnk( fmask, 'F', 1._wp )      ! Lateral boundary conditions on fmask
284         !
285         ! CAUTION : The fmask may be further modified in dyn_vor_init ( dynvor.F90 ) depending on ln_vorlat
286         !
287      ENDIF
288     
289      ! User defined alteration of fmask (use to reduce ocean transport in specified straits)
290      ! --------------------------------
291      !
292      CALL usr_def_fmask( cn_cfg, nn_cfg, fmask )
293      !
294   END SUBROUTINE dom_msk
295   
296   !!======================================================================
297END MODULE dommsk
Note: See TracBrowser for help on using the repository browser.