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/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM – NEMO

source: branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM/dommsk.F90 @ 6717

Last change on this file since 6717 was 6717, checked in by gm, 8 years ago

#1692 - branch SIMPLIF_2_usrdef: numerous improvement in the user defined interface

  • Property svn:keywords set to Id
File size: 12.6 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   !
29   USE in_out_manager ! I/O manager
30   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
31   USE lib_mpp        ! Massively Parallel Processing library
32   USE wrk_nemo       ! Memory allocation
33   USE timing         ! Timing
34
35   IMPLICIT NONE
36   PRIVATE
37
38   PUBLIC   dom_msk    ! routine called by inidom.F90
39
40   !                            !!* Namelist namlbc : lateral boundary condition *
41   REAL(wp)        :: rn_shlat   ! type of lateral boundary condition on velocity
42   LOGICAL, PUBLIC :: ln_vorlat  !  consistency of vorticity boundary condition
43   !                                            with analytical eqs.
44
45   !! * Substitutions
46#  include "vectopt_loop_substitute.h90"
47   !!----------------------------------------------------------------------
48   !! NEMO/OPA 3.2 , LODYC-IPSL  (2009)
49   !! $Id$
50   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
51   !!----------------------------------------------------------------------
52CONTAINS
53
54   SUBROUTINE dom_msk( k_top, k_bot )
55      !!---------------------------------------------------------------------
56      !!                 ***  ROUTINE dom_msk  ***
57      !!
58      !! ** Purpose :   Compute land/ocean mask arrays at tracer points, hori-
59      !!      zontal velocity points (u & v), vorticity points (f) points.
60      !!
61      !! ** Method  :   The ocean/land mask  at t-point is deduced from ko_top
62      !!      and ko_bot, the indices of the fist and last ocean t-levels which
63      !!      are either defined in usrdef_zgr or read in zgr_read.
64      !!                The velocity masks (umask, vmask, wmask, wumask, wvmask)
65      !!      are deduced from a product of the two neighboring tmask.
66      !!                The vorticity mask (fmask) is deduced from tmask taking
67      !!      into account the choice of lateral boundary condition (rn_shlat) :
68      !!         rn_shlat = 0, free slip  (no shear along the coast)
69      !!         rn_shlat = 2, no slip  (specified zero velocity at the coast)
70      !!         0 < rn_shlat < 2, partial slip   | non-linear velocity profile
71      !!         2 < rn_shlat, strong slip        | in the lateral boundary layer
72      !!
73      !!      tmask_i : interior ocean mask at t-point, i.e. excluding duplicated
74      !!                rows/lines due to cyclic or North Fold boundaries as well
75      !!                as MPP halos.
76      !!      tmask_h : halo mask at t-point, i.e. excluding duplicated rows/lines
77      !!                due to cyclic or North Fold boundaries as well as MPP halos.
78      !!
79      !! ** Action :   tmask, umask, vmask, wmask, wumask, wvmask : land/ocean mask
80      !!                         at t-, u-, v- w, wu-, and wv-points (=0. or 1.)
81      !!               fmask   : land/ocean mask at f-point (=0., or =1., or
82      !!                         =rn_shlat along lateral boundaries)
83      !!               tmask_i : interior ocean mask
84      !!               tmask_h : halo mask
85      !!               ssmask , ssumask, ssvmask, ssfmask : 2D ocean mask
86      !!----------------------------------------------------------------------
87      INTEGER, DIMENSION(:,:), INTENT(in) ::   k_top, k_bot   ! first and last ocean level
88      !
89      INTEGER  ::   ji, jj, jk     ! dummy loop indices
90      INTEGER  ::   iif, iil       ! local integers
91      INTEGER  ::   ijf, ijl       !   -       -
92      INTEGER  ::   iktop, ikbot   !   -       -
93      INTEGER  ::   ios
94      REAL(wp), POINTER, DIMENSION(:,:) ::   zwf   ! 2D workspace
95      !!
96      NAMELIST/namlbc/ rn_shlat, ln_vorlat
97      !!---------------------------------------------------------------------
98      !
99      IF( nn_timing == 1 )  CALL timing_start('dom_msk')
100      !
101      REWIND( numnam_ref )              ! Namelist namlbc in reference namelist : Lateral momentum boundary condition
102      READ  ( numnam_ref, namlbc, IOSTAT = ios, ERR = 901 )
103901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namlbc in reference namelist', lwp )
104
105      REWIND( numnam_cfg )              ! Namelist namlbc in configuration namelist : Lateral momentum boundary condition
106      READ  ( numnam_cfg, namlbc, IOSTAT = ios, ERR = 902 )
107902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namlbc in configuration namelist', lwp )
108      IF(lwm) WRITE ( numond, namlbc )
109     
110      IF(lwp) THEN                  ! control print
111         WRITE(numout,*)
112         WRITE(numout,*) 'dommsk : ocean mask '
113         WRITE(numout,*) '~~~~~~'
114         WRITE(numout,*) '   Namelist namlbc'
115         WRITE(numout,*) '      lateral momentum boundary cond.    rn_shlat  = ',rn_shlat
116         WRITE(numout,*) '      consistency with analytical form   ln_vorlat = ',ln_vorlat 
117      ENDIF
118
119      IF     (      rn_shlat == 0.               ) THEN   ;   IF(lwp) WRITE(numout,*) '   ocean lateral  free-slip '
120      ELSEIF (      rn_shlat == 2.               ) THEN   ;   IF(lwp) WRITE(numout,*) '   ocean lateral  no-slip '
121      ELSEIF ( 0. < rn_shlat .AND. rn_shlat < 2. ) THEN   ;   IF(lwp) WRITE(numout,*) '   ocean lateral  partial-slip '
122      ELSEIF ( 2. < rn_shlat                     ) THEN   ;   IF(lwp) WRITE(numout,*) '   ocean lateral  strong-slip '
123      ELSE
124         WRITE(ctmp1,*) ' rn_shlat is negative = ', rn_shlat
125         CALL ctl_stop( ctmp1 )
126      ENDIF
127
128
129      !  Ocean/land mask at t-point  (computed from ko_top and ko_bot)
130      ! ----------------------------
131      !
132      DO jj = 1, jpj
133         DO ji = 1, jpi
134            iktop = k_top(ji,jj)
135            ikbot = k_bot(ji,jj)
136            tmask(ji,jj,      1:iktop-1) = 0._wp      ! mask the iceshelves
137            tmask(ji,jj,iktop  :ikbot  ) = 1._wp
138            tmask(ji,jj,ikbot+1:jpkglo ) = 0._wp      ! mask the ocean topography
139         END DO 
140      END DO 
141
142     
143      !  Ocean/land mask at u-, v-, and f-points   (computed from tmask)
144      ! ----------------------------------------
145      ! NB: at this point, fmask is designed for free slip lateral boundary condition
146      DO jk = 1, jpk
147         DO jj = 1, jpjm1
148            DO ji = 1, fs_jpim1   ! vector loop
149               umask(ji,jj,jk) = tmask(ji,jj  ,jk) * tmask(ji+1,jj  ,jk)
150               vmask(ji,jj,jk) = tmask(ji,jj  ,jk) * tmask(ji  ,jj+1,jk)
151            END DO
152            DO ji = 1, jpim1      ! NO vector opt.
153               fmask(ji,jj,jk) = tmask(ji,jj  ,jk) * tmask(ji+1,jj  ,jk)   &
154                  &            * tmask(ji,jj+1,jk) * tmask(ji+1,jj+1,jk)
155            END DO
156         END DO
157      END DO
158      CALL lbc_lnk( umask  , 'U', 1._wp )      ! Lateral boundary conditions
159      CALL lbc_lnk( vmask  , 'V', 1._wp )
160      CALL lbc_lnk( fmask  , 'F', 1._wp )
161
162 
163      ! Ocean/land mask at wu-, wv- and w points    (computed from tmask)
164      !-----------------------------------------
165      wmask (:,:,1) = tmask(:,:,1)     ! surface
166      wumask(:,:,1) = umask(:,:,1)
167      wvmask(:,:,1) = vmask(:,:,1)
168      DO jk = 2, jpk                   ! interior values
169         wmask (:,:,jk) = tmask(:,:,jk) * tmask(:,:,jk-1)
170         wumask(:,:,jk) = umask(:,:,jk) * umask(:,:,jk-1)   
171         wvmask(:,:,jk) = vmask(:,:,jk) * vmask(:,:,jk-1)
172      END DO
173
174
175      ! Ocean/land column mask at t-, u-, and v-points   (i.e. at least 1 wet cell in the vertical)
176      ! ----------------------------------------------
177      ssmask (:,:) = MAXVAL( tmask(:,:,:), DIM=3 )
178      ssumask(:,:) = MAXVAL( umask(:,:,:), DIM=3 )
179      ssvmask(:,:) = MAXVAL( vmask(:,:,:), DIM=3 )
180
181
182      ! Interior domain mask  (used for global sum)
183      ! --------------------
184      !
185      iif = jpreci   ;   iil = nlci - jpreci + 1
186      ijf = jprecj   ;   ijl = nlcj - jprecj + 1
187      !
188      !                          ! halo mask : 0 on the halo and 1 elsewhere
189      tmask_h(:,:) = 1._wp                 
190      tmask_h( 1 :iif,   :   ) = 0._wp      ! first columns
191      tmask_h(iil:jpi,   :   ) = 0._wp      ! last  columns (including mpp extra columns)
192      tmask_h(   :   , 1 :ijf) = 0._wp      ! first rows
193      tmask_h(   :   ,ijl:jpj) = 0._wp      ! last  rows (including mpp extra rows)
194      !
195      !                          ! north fold mask
196      tpol(1:jpiglo) = 1._wp 
197      fpol(1:jpiglo) = 1._wp
198      IF( jperio == 3 .OR. jperio == 4 ) THEN      ! T-point pivot
199         tpol(jpiglo/2+1:jpiglo) = 0._wp
200         fpol(     1    :jpiglo) = 0._wp
201         IF( mjg(nlej) == jpjglo ) THEN                  ! only half of the nlcj-1 row for tmask_h
202            DO ji = iif+1, iil-1
203               tmask_h(ji,nlej-1) = tmask_h(ji,nlej-1) * tpol(mig(ji))
204            END DO
205         ENDIF
206      ENDIF
207      !
208      IF( jperio == 5 .OR. jperio == 6 ) THEN      ! F-point pivot
209         tpol(     1    :jpiglo) = 0._wp
210         fpol(jpiglo/2+1:jpiglo) = 0._wp
211      ENDIF
212      !
213      !                          ! interior mask : 2D ocean mask x halo mask
214      tmask_i(:,:) = ssmask(:,:) * tmask_h(:,:)
215
216
217      ! Lateral boundary conditions on velocity (modify fmask)
218      ! --------------------------------------- 
219      IF( rn_shlat /= 0 ) THEN      ! Not free-slip lateral boundary condition
220         !
221         CALL wrk_alloc( jpi,jpj,   zwf )
222         !
223         DO jk = 1, jpk
224            zwf(:,:) = fmask(:,:,jk)         
225            DO jj = 2, jpjm1
226               DO ji = fs_2, fs_jpim1   ! vector opt.
227                  IF( fmask(ji,jj,jk) == 0._wp ) THEN
228                     fmask(ji,jj,jk) = rn_shlat * MIN( 1._wp , MAX( zwf(ji+1,jj), zwf(ji,jj+1),   &
229                        &                                           zwf(ji-1,jj), zwf(ji,jj-1)  )  )
230                  ENDIF
231               END DO
232            END DO
233            DO jj = 2, jpjm1
234               IF( fmask(1,jj,jk) == 0._wp ) THEN
235                  fmask(1  ,jj,jk) = rn_shlat * MIN( 1._wp , MAX( zwf(2,jj), zwf(1,jj+1), zwf(1,jj-1) ) )
236               ENDIF
237               IF( fmask(jpi,jj,jk) == 0._wp ) THEN
238                  fmask(jpi,jj,jk) = rn_shlat * MIN( 1._wp , MAX( zwf(jpi,jj+1), zwf(jpim1,jj), zwf(jpi,jj-1) ) )
239               ENDIF
240            END DO         
241            DO ji = 2, jpim1
242               IF( fmask(ji,1,jk) == 0._wp ) THEN
243                  fmask(ji, 1 ,jk) = rn_shlat * MIN( 1._wp , MAX( zwf(ji+1,1), zwf(ji,2), zwf(ji-1,1) ) )
244               ENDIF
245               IF( fmask(ji,jpj,jk) == 0._wp ) THEN
246                  fmask(ji,jpj,jk) = rn_shlat * MIN( 1._wp , MAX( zwf(ji+1,jpj), zwf(ji-1,jpj), zwf(ji,jpjm1) ) )
247               ENDIF
248            END DO
249         END DO
250         !
251         CALL wrk_dealloc( jpi,jpj,   zwf )
252         !
253         CALL lbc_lnk( fmask, 'F', 1._wp )      ! Lateral boundary conditions on fmask
254         !
255         ! CAUTION : The fmask may be further modified in dyn_vor_init ( dynvor.F90 ) depending on ln_vorlat
256         !
257      ENDIF
258     
259      ! User defined alteration of fmask (use to reduce ocean transport in specified straits)
260      ! --------------------------------
261      !
262      CALL usr_def_fmask( cp_cfg, jp_cfg, fmask )
263      !
264      !
265      IF( nn_timing == 1 )  CALL timing_stop('dom_msk')
266      !
267   END SUBROUTINE dom_msk
268   
269   !!======================================================================
270END MODULE dommsk
Note: See TracBrowser for help on using the repository browser.