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