[6103] | 1 | MODULE closea |
---|
| 2 | !!====================================================================== |
---|
| 3 | !! *** MODULE closea *** |
---|
| 4 | !! |
---|
| 5 | !! User define : specific treatments associated with closed seas |
---|
| 6 | !!====================================================================== |
---|
| 7 | !! History : 8.2 ! 2000-05 (O. Marti) Original code |
---|
| 8 | !! NEMO 1.0 ! 2002-06 (E. Durand, G. Madec) F90 |
---|
| 9 | !! 3.0 ! 2006-07 (G. Madec) add clo_rnf, clo_ups, clo_bat |
---|
| 10 | !! 3.4 ! 2014-12 (P.G. Fogli) sbc_clo bug fix & mpp reproducibility |
---|
| 11 | !! 4.0 ! 2016-06 (G. Madec) move to usrdef_closea, remove clo_ups |
---|
| 12 | !! 4.0 ! 2017-12 (D. Storkey) new formulation based on masks read from file |
---|
| 13 | !!---------------------------------------------------------------------- |
---|
| 14 | |
---|
| 15 | !!---------------------------------------------------------------------- |
---|
| 16 | !! dom_clo : read in masks which define closed seas and runoff areas |
---|
| 17 | !! sbc_clo : Special handling of freshwater fluxes over closed seas |
---|
| 18 | !! clo_rnf : set close sea outflows as river mouths (see sbcrnf) |
---|
| 19 | !! clo_bat : set to zero a field over closed sea (see domzgr) |
---|
| 20 | !!---------------------------------------------------------------------- |
---|
| 21 | USE oce ! dynamics and tracers |
---|
| 22 | USE dom_oce ! ocean space and time domain |
---|
| 23 | USE phycst ! physical constants |
---|
| 24 | USE sbc_oce ! ocean surface boundary conditions |
---|
| 25 | USE iom ! I/O routines |
---|
| 26 | ! |
---|
| 27 | USE in_out_manager ! I/O manager |
---|
| 28 | USE lib_fortran, ONLY: glob_sum |
---|
| 29 | USE lbclnk ! lateral boundary condition - MPP exchanges |
---|
| 30 | USE lib_mpp ! MPP library |
---|
| 31 | USE timing ! Timing |
---|
| 32 | |
---|
| 33 | IMPLICIT NONE |
---|
| 34 | PRIVATE |
---|
| 35 | |
---|
| 36 | PUBLIC dom_clo ! called by domain module |
---|
| 37 | PUBLIC sbc_clo ! called by sbcmod module |
---|
| 38 | PUBLIC clo_rnf ! called by sbcrnf module |
---|
| 39 | PUBLIC clo_bat ! called in domzgr module |
---|
| 40 | |
---|
| 41 | LOGICAL, PUBLIC :: ln_closea !: T => keep closed seas (defined by closea_mask field) in the domain and apply |
---|
| 42 | !: special treatment of freshwater fluxes. |
---|
| 43 | !: F => suppress closed seas (defined by closea_mask field) from the bathymetry |
---|
| 44 | !: at runtime. |
---|
| 45 | !: If there is no closea_mask field in the domain_cfg file or we do not use |
---|
| 46 | !: a domain_cfg file then this logical does nothing. |
---|
| 47 | !: |
---|
| 48 | LOGICAL, PUBLIC :: l_sbc_clo !: T => Closed seas defined, apply special treatment of freshwater fluxes. |
---|
| 49 | !: F => No closed seas defined (closea_mask field not found). |
---|
| 50 | LOGICAL, PUBLIC :: l_clo_rnf !: T => Some closed seas output freshwater (RNF or EMPMR) to specified runoff points. |
---|
| 51 | INTEGER :: jncs ! number of closed seas (inferred from closea_mask field) |
---|
| 52 | INTEGER :: jncsr ! number of closed seas rnf mappings (inferred from closea_mask_rnf field) |
---|
| 53 | INTEGER :: jncse ! number of closed seas empmr mappings (inferred from closea_mask_empmr field) |
---|
| 54 | |
---|
| 55 | INTEGER , ALLOCATABLE, DIMENSION(:,:) :: closea_mask ! mask of integers defining closed seas |
---|
| 56 | INTEGER , ALLOCATABLE, DIMENSION(:,:) :: closea_mask_rnf ! mask of integers defining closed seas rnf mappings |
---|
| 57 | INTEGER , ALLOCATABLE, DIMENSION(:,:) :: closea_mask_empmr ! mask of integers defining closed seas empmr mappings |
---|
| 58 | REAL(wp), ALLOCATABLE, DIMENSION(:) :: surf ! closed sea surface areas |
---|
| 59 | ! (and residual global surface area) |
---|
| 60 | REAL(wp), ALLOCATABLE, DIMENSION(:) :: surfr ! closed sea target rnf surface areas |
---|
| 61 | REAL(wp), ALLOCATABLE, DIMENSION(:) :: surfe ! closed sea target empmr surface areas |
---|
| 62 | |
---|
| 63 | !! * Substitutions |
---|
| 64 | # include "vectopt_loop_substitute.h90" |
---|
| 65 | !!---------------------------------------------------------------------- |
---|
| 66 | !! NEMO/OCE 4.0 , NEMO Consortium (2018) |
---|
| 67 | !! $Id: closea.F90 15680 2022-02-01 16:43:17Z clem $ |
---|
| 68 | !! Software governed by the CeCILL license (see ./LICENSE) |
---|
| 69 | !!---------------------------------------------------------------------- |
---|
| 70 | CONTAINS |
---|
| 71 | |
---|
| 72 | SUBROUTINE dom_clo() |
---|
| 73 | !!--------------------------------------------------------------------- |
---|
| 74 | !! *** ROUTINE dom_clo *** |
---|
| 75 | !! |
---|
| 76 | !! ** Purpose : Closed sea domain initialization |
---|
| 77 | !! |
---|
| 78 | !! ** Method : if a closed sea is located only in a model grid point |
---|
| 79 | !! just the thermodynamic processes are applied. |
---|
| 80 | !! |
---|
| 81 | !! ** Action : Read closea_mask* fields (if they exist) from domain_cfg file and infer |
---|
| 82 | !! number of closed seas from closea_mask field. |
---|
| 83 | !! closea_mask : integer values defining closed seas (or groups of closed seas) |
---|
| 84 | !! closea_mask_rnf : integer values defining mappings from closed seas or groups of |
---|
| 85 | !! closed seas to a runoff area for downwards flux only. |
---|
| 86 | !! closea_mask_empmr : integer values defining mappings from closed seas or groups of |
---|
| 87 | !! closed seas to a runoff area for net fluxes. |
---|
| 88 | !! |
---|
| 89 | !! Python code to generate the closea_masks* fields from the old-style indices |
---|
| 90 | !! definitions is available at TOOLS/DOMAINcfg/make_closea_masks.py |
---|
| 91 | !!---------------------------------------------------------------------- |
---|
| 92 | INTEGER :: inum ! input file identifier |
---|
| 93 | INTEGER :: ierr ! error code |
---|
| 94 | INTEGER :: id ! netcdf variable ID |
---|
| 95 | |
---|
| 96 | REAL(wp), DIMENSION(jpi,jpj) :: zdata_in ! temporary real array for input |
---|
| 97 | !!---------------------------------------------------------------------- |
---|
| 98 | ! |
---|
| 99 | IF(lwp) WRITE(numout,*) |
---|
| 100 | IF(lwp) WRITE(numout,*)'dom_clo : read in masks to define closed seas ' |
---|
| 101 | IF(lwp) WRITE(numout,*)'~~~~~~~' |
---|
| 102 | ! |
---|
| 103 | ! read the closed seas masks (if they exist) from domain_cfg file (if it exists) |
---|
| 104 | ! ------------------------------------------------------------------------------ |
---|
| 105 | ! |
---|
| 106 | IF( ln_read_cfg) THEN |
---|
| 107 | ! |
---|
| 108 | CALL iom_open( cn_domcfg, inum ) |
---|
| 109 | ! |
---|
| 110 | id = iom_varid(inum, 'closea_mask', ldstop = .false.) |
---|
| 111 | IF( id > 0 ) THEN |
---|
| 112 | l_sbc_clo = .true. |
---|
| 113 | ALLOCATE( closea_mask(jpi,jpj) , STAT=ierr ) |
---|
| 114 | IF( ierr /= 0 ) CALL ctl_stop( 'STOP', 'dom_clo: failed to allocate closea_mask array') |
---|
| 115 | zdata_in(:,:) = 0.0 |
---|
| 116 | CALL iom_get ( inum, jpdom_data, 'closea_mask', zdata_in ) |
---|
| 117 | closea_mask(:,:) = NINT(zdata_in(:,:)) * tmask(:,:,1) |
---|
| 118 | ! number of closed seas = global maximum value in closea_mask field |
---|
| 119 | jncs = maxval(closea_mask(:,:)) |
---|
| 120 | CALL mpp_max('closea', jncs) |
---|
| 121 | IF( jncs > 0 ) THEN |
---|
| 122 | IF( lwp ) WRITE(numout,*) 'Number of closed seas : ',jncs |
---|
| 123 | ELSE |
---|
| 124 | CALL ctl_stop( 'Problem with closea_mask field in domain_cfg file. Has no values > 0 so no closed seas defined.') |
---|
| 125 | ENDIF |
---|
| 126 | ELSE |
---|
| 127 | IF( lwp ) WRITE(numout,*) |
---|
| 128 | IF( lwp ) WRITE(numout,*) ' ==>>> closea_mask field not found in domain_cfg file.' |
---|
| 129 | IF( lwp ) WRITE(numout,*) ' No closed seas defined.' |
---|
| 130 | IF( lwp ) WRITE(numout,*) |
---|
| 131 | l_sbc_clo = .false. |
---|
| 132 | jncs = 0 |
---|
| 133 | ENDIF |
---|
| 134 | |
---|
| 135 | l_clo_rnf = .false. |
---|
| 136 | |
---|
| 137 | IF( l_sbc_clo ) THEN ! No point reading in closea_mask_rnf or closea_mask_empmr fields if no closed seas defined. |
---|
| 138 | |
---|
| 139 | id = iom_varid(inum, 'closea_mask_rnf', ldstop = .false.) |
---|
| 140 | IF( id > 0 ) THEN |
---|
| 141 | l_clo_rnf = .true. |
---|
| 142 | ALLOCATE( closea_mask_rnf(jpi,jpj) , STAT=ierr ) |
---|
| 143 | IF( ierr /= 0 ) CALL ctl_stop( 'STOP', 'dom_clo: failed to allocate closea_mask_rnf array') |
---|
| 144 | CALL iom_get ( inum, jpdom_data, 'closea_mask_rnf', zdata_in ) |
---|
| 145 | closea_mask_rnf(:,:) = NINT(zdata_in(:,:)) * tmask(:,:,1) |
---|
| 146 | ! number of closed seas rnf mappings = global maximum in closea_mask_rnf field |
---|
| 147 | jncsr = maxval(closea_mask_rnf(:,:)) |
---|
| 148 | CALL mpp_max('closea', jncsr) |
---|
| 149 | IF( jncsr > 0 ) THEN |
---|
| 150 | IF( lwp ) WRITE(numout,*) 'Number of closed seas rnf mappings : ',jncsr |
---|
| 151 | ELSE |
---|
| 152 | CALL ctl_stop( 'Problem with closea_mask_rnf field in domain_cfg file. Has no values > 0 so no closed seas rnf mappings defined.') |
---|
| 153 | ENDIF |
---|
| 154 | ELSE |
---|
| 155 | IF( lwp ) WRITE(numout,*) 'closea_mask_rnf field not found in domain_cfg file. No closed seas rnf mappings defined.' |
---|
| 156 | jncsr = 0 |
---|
| 157 | ENDIF |
---|
| 158 | |
---|
| 159 | id = iom_varid(inum, 'closea_mask_empmr', ldstop = .false.) |
---|
| 160 | IF( id > 0 ) THEN |
---|
| 161 | l_clo_rnf = .true. |
---|
| 162 | ALLOCATE( closea_mask_empmr(jpi,jpj) , STAT=ierr ) |
---|
| 163 | IF( ierr /= 0 ) CALL ctl_stop( 'STOP', 'dom_clo: failed to allocate closea_mask_empmr array') |
---|
| 164 | CALL iom_get ( inum, jpdom_data, 'closea_mask_empmr', zdata_in ) |
---|
| 165 | closea_mask_empmr(:,:) = NINT(zdata_in(:,:)) * tmask(:,:,1) |
---|
| 166 | ! number of closed seas empmr mappings = global maximum value in closea_mask_empmr field |
---|
| 167 | jncse = maxval(closea_mask_empmr(:,:)) |
---|
| 168 | CALL mpp_max('closea', jncse) |
---|
| 169 | IF( jncse > 0 ) THEN |
---|
| 170 | IF( lwp ) WRITE(numout,*) 'Number of closed seas empmr mappings : ',jncse |
---|
| 171 | ELSE |
---|
| 172 | CALL ctl_stop( 'Problem with closea_mask_empmr field in domain_cfg file. Has no values > 0 so no closed seas empmr mappings defined.') |
---|
| 173 | ENDIF |
---|
| 174 | ELSE |
---|
| 175 | IF( lwp ) WRITE(numout,*) 'closea_mask_empmr field not found in domain_cfg file. No closed seas empmr mappings defined.' |
---|
| 176 | jncse = 0 |
---|
| 177 | ENDIF |
---|
| 178 | |
---|
| 179 | ENDIF ! l_sbc_clo |
---|
| 180 | ! |
---|
| 181 | CALL iom_close( inum ) |
---|
| 182 | ! |
---|
| 183 | ELSE ! ln_read_cfg = .false. so no domain_cfg file |
---|
| 184 | IF( lwp ) WRITE(numout,*) 'No domain_cfg file so no closed seas defined.' |
---|
| 185 | l_sbc_clo = .false. |
---|
| 186 | l_clo_rnf = .false. |
---|
| 187 | ENDIF |
---|
| 188 | ! |
---|
| 189 | END SUBROUTINE dom_clo |
---|
| 190 | |
---|
| 191 | |
---|
| 192 | SUBROUTINE sbc_clo( kt ) |
---|
| 193 | !!--------------------------------------------------------------------- |
---|
| 194 | !! *** ROUTINE sbc_clo *** |
---|
| 195 | !! |
---|
| 196 | !! ** Purpose : Special handling of closed seas |
---|
| 197 | !! |
---|
| 198 | !! ** Method : Water flux is forced to zero over closed sea |
---|
| 199 | !! Excess is shared between remaining ocean, or |
---|
| 200 | !! put as run-off in open ocean. |
---|
| 201 | !! |
---|
| 202 | !! ** Action : emp updated surface freshwater fluxes and associated heat content at kt |
---|
| 203 | !! |
---|
| 204 | !! surf(1:jncs) = surface of closed seas (defined by mask/=0) |
---|
| 205 | !! surf(jncs+1) = surface of global ocean without closed seas |
---|
| 206 | !! surfe(1:jncse) = surface of target regions (defined by mask_empmr/=0 & mask=0) |
---|
| 207 | !! where empmr budget (zfwfe) from some closed seas is added |
---|
| 208 | !! (those where mask_empmr/=0 & mask/=0) |
---|
| 209 | !!---------------------------------------------------------------------- |
---|
| 210 | INTEGER , INTENT(in ) :: kt ! ocean model time step |
---|
| 211 | ! |
---|
| 212 | INTEGER :: ierr |
---|
| 213 | INTEGER :: jc, jcr, jce ! dummy loop indices |
---|
| 214 | REAL(wp) :: zfwf_total, zcoef ! |
---|
| 215 | REAL(wp), DIMENSION(jncs) :: zfwf ! |
---|
| 216 | REAL(wp), DIMENSION(jncsr+1) :: zfwfr ! freshwater fluxes over closed seas |
---|
| 217 | REAL(wp), DIMENSION(jncse+1) :: zfwfe ! |
---|
| 218 | REAL(wp), DIMENSION(jpi,jpj) :: ztmp2d ! 2D workspace |
---|
| 219 | !!---------------------------------------------------------------------- |
---|
| 220 | ! |
---|
| 221 | IF( ln_timing ) CALL timing_start('sbc_clo') |
---|
| 222 | ! |
---|
| 223 | ! !------------------! |
---|
| 224 | IF( kt == nit000 ) THEN ! Initialisation ! |
---|
| 225 | ! !------------------! |
---|
| 226 | IF(lwp) WRITE(numout,*) |
---|
| 227 | IF(lwp) WRITE(numout,*)'sbc_clo : closed seas ' |
---|
| 228 | IF(lwp) WRITE(numout,*)'~~~~~~~' |
---|
| 229 | |
---|
| 230 | ALLOCATE( surf(jncs+1) , STAT=ierr ) |
---|
| 231 | IF( ierr /= 0 ) CALL ctl_stop( 'STOP', 'sbc_clo: failed to allocate surf array') |
---|
| 232 | surf(:) = 0.e0_wp |
---|
| 233 | ! |
---|
| 234 | ! jncsr can be zero so add 1 to avoid allocating zero-length array |
---|
| 235 | ALLOCATE( surfr(jncsr+1) , STAT=ierr ) |
---|
| 236 | IF( ierr /= 0 ) CALL ctl_stop( 'STOP', 'sbc_clo: failed to allocate surfr array') |
---|
| 237 | surfr(:) = 0.e0_wp |
---|
| 238 | ! |
---|
| 239 | ! jncse can be zero so add 1 to avoid allocating zero-length array |
---|
| 240 | ALLOCATE( surfe(jncse+1) , STAT=ierr ) |
---|
| 241 | IF( ierr /= 0 ) CALL ctl_stop( 'STOP', 'sbc_clo: failed to allocate surfe array') |
---|
| 242 | surfe(:) = 0.e0_wp |
---|
| 243 | ! |
---|
| 244 | surf(jncs+1) = glob_sum( 'closea', e1e2t(:,:) ) ! surface of the global ocean |
---|
| 245 | ! |
---|
| 246 | ! ! surface areas of closed seas |
---|
| 247 | DO jc = 1, jncs |
---|
| 248 | ztmp2d(:,:) = 0.e0_wp |
---|
| 249 | WHERE( closea_mask(:,:) == jc ) ztmp2d(:,:) = e1e2t(:,:) * tmask_i(:,:) |
---|
| 250 | surf(jc) = glob_sum( 'closea', ztmp2d(:,:) ) |
---|
| 251 | END DO |
---|
| 252 | ! |
---|
| 253 | ! jncs+1 : surface area of global ocean, closed seas excluded |
---|
| 254 | IF( jncs > 0 ) surf(jncs+1) = surf(jncs+1) - SUM(surf(1:jncs)) |
---|
| 255 | ! |
---|
| 256 | ! ! surface areas of rnf target areas |
---|
| 257 | IF( jncsr > 0 ) THEN |
---|
| 258 | DO jcr = 1, jncsr |
---|
| 259 | ztmp2d(:,:) = 0.e0_wp |
---|
| 260 | WHERE( closea_mask_rnf(:,:) == jcr .and. closea_mask(:,:) == 0 ) ztmp2d(:,:) = e1e2t(:,:) * tmask_i(:,:) |
---|
| 261 | surfr(jcr) = glob_sum( 'closea', ztmp2d(:,:) ) |
---|
| 262 | END DO |
---|
| 263 | ENDIF |
---|
| 264 | ! |
---|
| 265 | ! ! surface areas of empmr target areas |
---|
| 266 | IF( jncse > 0 ) THEN |
---|
| 267 | DO jce = 1, jncse |
---|
| 268 | ztmp2d(:,:) = 0.e0_wp |
---|
| 269 | WHERE( closea_mask_empmr(:,:) == jce .and. closea_mask(:,:) == 0 ) ztmp2d(:,:) = e1e2t(:,:) * tmask_i(:,:) |
---|
| 270 | surfe(jce) = glob_sum( 'closea', ztmp2d(:,:) ) |
---|
| 271 | END DO |
---|
| 272 | ENDIF |
---|
| 273 | ! |
---|
| 274 | IF(lwp) WRITE(numout,*)' Closed sea surface areas (km2)' |
---|
| 275 | DO jc = 1, jncs |
---|
| 276 | IF(lwp) WRITE(numout,FMT='(1I3,5X,ES12.2)') jc, surf(jc) * 1.0e-6 |
---|
| 277 | END DO |
---|
| 278 | IF(lwp) WRITE(numout,FMT='(A,ES12.2)') 'Global surface area excluding closed seas (km2): ', surf(jncs+1) * 1.0e-6 |
---|
| 279 | ! |
---|
| 280 | IF(jncsr > 0) THEN |
---|
| 281 | IF(lwp) WRITE(numout,*)' Closed sea target rnf surface areas (km2)' |
---|
| 282 | DO jcr = 1, jncsr |
---|
| 283 | IF(lwp) WRITE(numout,FMT='(1I3,5X,ES12.2)') jcr, surfr(jcr) * 1.0e-6 |
---|
| 284 | END DO |
---|
| 285 | ENDIF |
---|
| 286 | ! |
---|
| 287 | IF(jncse > 0) THEN |
---|
| 288 | IF(lwp) WRITE(numout,*)' Closed sea target empmr surface areas (km2)' |
---|
| 289 | DO jce = 1, jncse |
---|
| 290 | IF(lwp) WRITE(numout,FMT='(1I3,5X,ES12.2)') jce, surfe(jce) * 1.0e-6 |
---|
| 291 | END DO |
---|
| 292 | ENDIF |
---|
| 293 | ENDIF |
---|
| 294 | ! |
---|
| 295 | ! !--------------------! |
---|
| 296 | ! ! update emp ! |
---|
| 297 | ! !--------------------! |
---|
| 298 | |
---|
| 299 | zfwf_total = 0._wp |
---|
| 300 | |
---|
| 301 | ! |
---|
| 302 | ! 1. Work out total freshwater fluxes over closed seas from EMP - RNF. |
---|
| 303 | ! |
---|
| 304 | zfwf(:) = 0.e0_wp |
---|
| 305 | DO jc = 1, jncs |
---|
| 306 | ztmp2d(:,:) = 0.e0_wp |
---|
| 307 | WHERE( closea_mask(:,:) == jc ) ztmp2d(:,:) = e1e2t(:,:) * ( emp(:,:)-rnf(:,:) ) * tmask_i(:,:) |
---|
| 308 | zfwf(jc) = glob_sum( 'closea', ztmp2d(:,:) ) |
---|
| 309 | END DO |
---|
| 310 | zfwf_total = SUM(zfwf) |
---|
| 311 | |
---|
| 312 | zfwfr(:) = 0.e0_wp |
---|
| 313 | IF( jncsr > 0 ) THEN |
---|
| 314 | ! |
---|
| 315 | ! 2. Work out total FW fluxes over rnf source areas and add to rnf target areas. |
---|
| 316 | ! Where zfwf is negative add flux at specified runoff points and subtract from fluxes for global redistribution. |
---|
| 317 | ! Where positive leave in global redistribution total. |
---|
| 318 | ! |
---|
| 319 | DO jcr = 1, jncsr |
---|
| 320 | ! |
---|
| 321 | IF( surfr(jcr) > 0._wp ) THEN ! target area /= 0 |
---|
| 322 | ztmp2d(:,:) = 0.e0_wp |
---|
| 323 | WHERE( closea_mask_rnf(:,:) == jcr .AND. closea_mask(:,:) > 0 ) ztmp2d(:,:) = e1e2t(:,:) * ( emp(:,:)-rnf(:,:) ) * tmask_i(:,:) |
---|
| 324 | zfwfr(jcr) = glob_sum( 'closea', ztmp2d(:,:) ) |
---|
| 325 | ! |
---|
| 326 | ! Add residuals to target runoff points if negative and subtract from total to be added globally |
---|
| 327 | IF( zfwfr(jcr) < 0.0 ) THEN |
---|
| 328 | zcoef = zfwfr(jcr) / surfr(jcr) |
---|
| 329 | WHERE( closea_mask_rnf(:,:) == jcr .AND. closea_mask(:,:) == 0 ) |
---|
| 330 | emp(:,:) = emp(:,:) + zcoef |
---|
| 331 | qns(:,:) = qns(:,:) - zcoef * rcp * sst_m(:,:) |
---|
| 332 | ENDWHERE |
---|
| 333 | zfwf_total = zfwf_total - zfwfr(jcr) |
---|
| 334 | ENDIF |
---|
| 335 | ! |
---|
| 336 | ENDIF |
---|
| 337 | END DO |
---|
| 338 | ENDIF ! jncsr > 0 |
---|
| 339 | ! |
---|
| 340 | zfwfe(:) = 0.e0_wp |
---|
| 341 | IF( jncse > 0 ) THEN |
---|
| 342 | ! |
---|
| 343 | ! 3. Work out total fluxes over empmr source areas and add to empmr target areas. |
---|
| 344 | ! |
---|
| 345 | DO jce = 1, jncse |
---|
| 346 | ! |
---|
| 347 | IF( surfe(jce) > 0._wp ) THEN ! target area /= 0 |
---|
| 348 | ztmp2d(:,:) = 0.e0_wp |
---|
| 349 | WHERE( closea_mask_empmr(:,:) == jce .AND. closea_mask(:,:) > 0 ) ztmp2d(:,:) = e1e2t(:,:) * ( emp(:,:)-rnf(:,:) ) * tmask_i(:,:) |
---|
| 350 | zfwfe(jce) = glob_sum( 'closea', ztmp2d(:,:) ) |
---|
| 351 | ! |
---|
| 352 | ! Add residuals to runoff points and subtract from total to be added globally |
---|
| 353 | zcoef = zfwfe(jce) / surfe(jce) |
---|
| 354 | WHERE( closea_mask_empmr(:,:) == jce .AND. closea_mask(:,:) == 0 ) |
---|
| 355 | emp(:,:) = emp(:,:) + zcoef |
---|
| 356 | qns(:,:) = qns(:,:) - zcoef * rcp * sst_m(:,:) |
---|
| 357 | ENDWHERE |
---|
| 358 | zfwf_total = zfwf_total - zfwfe(jce) |
---|
| 359 | ENDIF |
---|
| 360 | ! |
---|
| 361 | END DO |
---|
| 362 | ENDIF ! jncse > 0 |
---|
| 363 | |
---|
| 364 | ! |
---|
| 365 | ! 4. Spread residual flux over global ocean. |
---|
| 366 | ! |
---|
| 367 | zcoef = zfwf_total / surf(jncs+1) |
---|
| 368 | WHERE( closea_mask(:,:) == 0 ) |
---|
| 369 | emp(:,:) = emp(:,:) + zcoef |
---|
| 370 | qns(:,:) = qns(:,:) - zcoef * rcp * sst_m(:,:) |
---|
| 371 | ENDWHERE |
---|
| 372 | ! |
---|
| 373 | ! 5. Subtract area means from emp (and qns) over closed seas to give zero mean FW flux over each sea. |
---|
| 374 | ! |
---|
| 375 | DO jc = 1, jncs |
---|
| 376 | ! |
---|
| 377 | ! Subtract residuals from fluxes over closed sea |
---|
| 378 | zcoef = zfwf(jc) / surf(jc) |
---|
| 379 | WHERE( closea_mask(:,:) == jc ) |
---|
| 380 | emp(:,:) = emp(:,:) - zcoef |
---|
| 381 | qns(:,:) = qns(:,:) + zcoef * rcp * sst_m(:,:) |
---|
| 382 | ENDWHERE |
---|
| 383 | ! |
---|
| 384 | END DO |
---|
| 385 | ! |
---|
| 386 | emp (:,:) = emp (:,:) * tmask(:,:,1) |
---|
| 387 | ! |
---|
| 388 | CALL lbc_lnk( 'closea', emp , 'T', 1._wp ) ! clem: why do we need that? |
---|
| 389 | ! |
---|
| 390 | END SUBROUTINE sbc_clo |
---|
| 391 | |
---|
| 392 | SUBROUTINE clo_rnf( p_rnfmsk ) |
---|
| 393 | !!--------------------------------------------------------------------- |
---|
| 394 | !! *** ROUTINE sbc_rnf *** |
---|
| 395 | !! |
---|
| 396 | !! ** Purpose : allow the treatment of closed sea outflow grid-points |
---|
| 397 | !! to be the same as river mouth grid-points |
---|
| 398 | !! |
---|
| 399 | !! ** Method : set to 1 the runoff mask (mskrnf, see sbcrnf module) |
---|
| 400 | !! at the closed sea outflow grid-point. |
---|
| 401 | !! |
---|
| 402 | !! ** Action : update (p_)mskrnf (set 1 at closed sea outflow) |
---|
| 403 | !!---------------------------------------------------------------------- |
---|
| 404 | REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: p_rnfmsk ! river runoff mask (rnfmsk array) |
---|
| 405 | !!---------------------------------------------------------------------- |
---|
| 406 | ! |
---|
| 407 | IF( jncsr > 0 ) THEN |
---|
| 408 | WHERE( closea_mask_rnf(:,:) > 0 .and. closea_mask(:,:) == 0 ) |
---|
| 409 | p_rnfmsk(:,:) = MAX( p_rnfmsk(:,:), 1.0_wp ) |
---|
| 410 | ENDWHERE |
---|
| 411 | ENDIF |
---|
| 412 | ! |
---|
| 413 | IF( jncse > 0 ) THEN |
---|
| 414 | WHERE( closea_mask_empmr(:,:) > 0 .and. closea_mask(:,:) == 0 ) |
---|
| 415 | p_rnfmsk(:,:) = MAX( p_rnfmsk(:,:), 1.0_wp ) |
---|
| 416 | ENDWHERE |
---|
| 417 | ENDIF |
---|
| 418 | ! |
---|
| 419 | END SUBROUTINE clo_rnf |
---|
| 420 | |
---|
| 421 | |
---|
| 422 | SUBROUTINE clo_bat( k_top, k_bot ) |
---|
| 423 | !!--------------------------------------------------------------------- |
---|
| 424 | !! *** ROUTINE clo_bat *** |
---|
| 425 | !! |
---|
| 426 | !! ** Purpose : Suppress closed sea from the domain |
---|
| 427 | !! |
---|
| 428 | !! ** Method : Read in closea_mask field (if it exists) from domain_cfg file. |
---|
| 429 | !! Where closea_mask > 0 set first and last ocean level to 0 |
---|
| 430 | !! (As currently coded you can't define a closea_mask field in |
---|
| 431 | !! usr_def_zgr). |
---|
| 432 | !! |
---|
| 433 | !! ** Action : set k_top=0 and k_bot=0 over closed seas |
---|
| 434 | !!---------------------------------------------------------------------- |
---|
| 435 | INTEGER, DIMENSION(:,:), INTENT(inout) :: k_top, k_bot ! ocean first and last level indices |
---|
| 436 | INTEGER :: inum, id |
---|
| 437 | INTEGER, DIMENSION(jpi,jpj) :: closea_mask ! closea_mask field |
---|
| 438 | REAL(wp), DIMENSION(jpi,jpj) :: zdata_in ! temporary real array for input |
---|
| 439 | !!---------------------------------------------------------------------- |
---|
| 440 | ! |
---|
| 441 | IF(lwp) THEN ! Control print |
---|
| 442 | WRITE(numout,*) |
---|
| 443 | WRITE(numout,*) 'clo_bat : suppression of closed seas' |
---|
| 444 | WRITE(numout,*) '~~~~~~~' |
---|
| 445 | ENDIF |
---|
| 446 | ! |
---|
| 447 | IF( ln_read_cfg ) THEN |
---|
| 448 | ! |
---|
| 449 | CALL iom_open( cn_domcfg, inum ) |
---|
| 450 | ! |
---|
| 451 | id = iom_varid(inum, 'closea_mask', ldstop = .false.) |
---|
| 452 | IF( id > 0 ) THEN |
---|
| 453 | IF( lwp ) WRITE(numout,*) 'Suppressing closed seas in bathymetry based on closea_mask field,' |
---|
| 454 | CALL iom_get ( inum, jpdom_data, 'closea_mask', zdata_in ) |
---|
| 455 | closea_mask(:,:) = NINT(zdata_in(:,:)) |
---|
| 456 | WHERE( closea_mask(:,:) > 0 ) |
---|
| 457 | k_top(:,:) = 0 |
---|
| 458 | k_bot(:,:) = 0 |
---|
| 459 | ENDWHERE |
---|
| 460 | ELSE |
---|
| 461 | IF( lwp ) WRITE(numout,*) 'No closea_mask field found in domain_cfg file. No suppression of closed seas.' |
---|
| 462 | ENDIF |
---|
| 463 | ! |
---|
| 464 | CALL iom_close(inum) |
---|
| 465 | ! |
---|
| 466 | ELSE |
---|
| 467 | IF( lwp ) WRITE(numout,*) 'No domain_cfg file => no suppression of closed seas.' |
---|
| 468 | ENDIF |
---|
| 469 | ! |
---|
| 470 | ! Initialise l_sbc_clo and l_clo_rnf for this case (ln_closea=.false.) |
---|
| 471 | l_sbc_clo = .false. |
---|
| 472 | l_clo_rnf = .false. |
---|
| 473 | ! |
---|
| 474 | END SUBROUTINE clo_bat |
---|
| 475 | |
---|
| 476 | !!====================================================================== |
---|
| 477 | END MODULE closea |
---|
| 478 | |
---|