Changeset 7646 for trunk/NEMOGCM/NEMO/TOP_SRC/trcbc.F90
- Timestamp:
- 2017-02-06T10:25:03+01:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/NEMOGCM/NEMO/TOP_SRC/trcbc.F90
r6140 r7646 4 4 !! TOP : module for passive tracer boundary conditions 5 5 !!===================================================================== 6 !! History : 3.5 ! 2014-04 (M. Vichi, T. Lovato) Original 7 !! 3.6 ! 2015-03 (T . Lovato) Revision and BDY support 6 !! History : 3.5 ! 2014 (M. Vichi, T. Lovato) Original 7 !! 3.6 ! 2015 (T . Lovato) Revision and BDY support 8 !! 4.0 ! 2016 (T . Lovato) Include application of sbc and cbc 8 9 !!---------------------------------------------------------------------- 9 10 #if defined key_top … … 11 12 !! 'key_top' TOP model 12 13 !!---------------------------------------------------------------------- 13 !! trc_bc : read and time interpolatedtracer Boundary Conditions14 !! trc_bc : Apply tracer Boundary Conditions 14 15 !!---------------------------------------------------------------------- 15 16 USE par_trc ! passive tracers parameters … … 19 20 USE lib_mpp ! MPP library 20 21 USE fldread ! read input fields 21 #if defined key_bdy 22 USE bdy_oce, only: nb_bdy , idx_bdy, ln_coords_file, rn_time_dmp, rn_time_dmp_out 23 #endif 22 USE bdy_oce, ONLY: ln_bdy, nb_bdy , idx_bdy, ln_coords_file, rn_time_dmp, rn_time_dmp_out 24 23 25 24 IMPLICIT NONE 26 25 PRIVATE 27 26 28 PUBLIC trc_bc _init ! called in trcini.F9029 PUBLIC trc_bc_ read ! called in trcstp.F90 or within27 PUBLIC trc_bc ! called in trcstp.F90 or within TOP modules 28 PUBLIC trc_bc_ini ! called in trcini.F90 30 29 31 30 INTEGER , SAVE, PUBLIC :: nb_trcobc ! number of tracers with open BC … … 43 42 TYPE(MAP_POINTER), ALLOCATABLE, DIMENSION(:) :: nbmap_ptr ! array of pointers to nbmap 44 43 45 !!---------------------------------------------------------------------- 46 !! NEMO/OPA 3.6 , NEMO Consortium (2015) 44 !! * Substitutions 45 # include "vectopt_loop_substitute.h90" 46 !!---------------------------------------------------------------------- 47 !! NEMO/TOP 4.0 , NEMO Consortium (2016) 47 48 !! $Id$ 48 49 !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) … … 50 51 CONTAINS 51 52 52 SUBROUTINE trc_bc_ini t( ntrc )53 SUBROUTINE trc_bc_ini( ntrc ) 53 54 !!---------------------------------------------------------------------- 54 !! *** ROUTINE trc_bc_ini t***55 !! *** ROUTINE trc_bc_ini *** 55 56 !! 56 57 !! ** Purpose : initialisation of passive tracer BC data … … 77 78 REAL(wp) , DIMENSION(jpmaxtrc) :: rn_trcfac ! multiplicative factor for tracer values 78 79 !! 79 NAMELIST/namtrc_bc/ cn_dir_ sbc, cn_dir_cbc, cn_dir_obc, sn_trcobc, rn_trofac, sn_trcsbc, rn_trsfac, sn_trccbc, rn_trcfac80 #if defined key_bdy 80 NAMELIST/namtrc_bc/ cn_dir_obc, sn_trcobc, rn_trofac, cn_dir_sbc, sn_trcsbc, rn_trsfac, & 81 & cn_dir_cbc, sn_trccbc, rn_trcfac, ln_rnf_ctl, rn_bc_time 81 82 NAMELIST/namtrc_bdy/ cn_trc_dflt, cn_trc, nn_trcdmp_bdy 82 #endif 83 83 84 !!---------------------------------------------------------------------- 84 IF( nn_timing == 1 ) CALL timing_start('trc_bc_ini t')85 IF( nn_timing == 1 ) CALL timing_start('trc_bc_ini') 85 86 ! 86 87 IF( lwp ) THEN 87 88 WRITE(numout,*) ' ' 88 WRITE(numout,*) 'trc_bc_ini t: Tracers Boundary Conditions (BC)'89 WRITE(numout,*) 'trc_bc_ini : Tracers Boundary Conditions (BC)' 89 90 WRITE(numout,*) '~~~~~~~~~~~ ' 90 91 ENDIF … … 93 94 ALLOCATE( slf_i(ntrc), STAT=ierr0 ) 94 95 IF( ierr0 > 0 ) THEN 95 CALL ctl_stop( 'trc_bc_ini t: unable to allocate local slf_i' ) ; RETURN96 CALL ctl_stop( 'trc_bc_ini: unable to allocate local slf_i' ) ; RETURN 96 97 ENDIF 97 98 … … 99 100 ALLOCATE( n_trc_indobc(ntrc), STAT=ierr0 ) 100 101 IF( ierr0 > 0 ) THEN 101 CALL ctl_stop( 'trc_bc_ini t: unable to allocate n_trc_indobc' ) ; RETURN102 CALL ctl_stop( 'trc_bc_ini: unable to allocate n_trc_indobc' ) ; RETURN 102 103 ENDIF 103 104 nb_trcobc = 0 … … 106 107 ALLOCATE( n_trc_indsbc(ntrc), STAT=ierr0 ) 107 108 IF( ierr0 > 0 ) THEN 108 CALL ctl_stop( 'trc_bc_ini t: unable to allocate n_trc_indsbc' ) ; RETURN109 CALL ctl_stop( 'trc_bc_ini: unable to allocate n_trc_indsbc' ) ; RETURN 109 110 ENDIF 110 111 nb_trcsbc = 0 … … 113 114 ALLOCATE( n_trc_indcbc(ntrc), STAT=ierr0 ) 114 115 IF( ierr0 > 0 ) THEN 115 CALL ctl_stop( 'trc_bc_ini t: unable to allocate n_trc_indcbc' ) ; RETURN116 CALL ctl_stop( 'trc_bc_ini: unable to allocate n_trc_indcbc' ) ; RETURN 116 117 ENDIF 117 118 nb_trccbc = 0 … … 128 129 IF(lwm) WRITE ( numont, namtrc_bc ) 129 130 130 #if defined key_bdy 131 REWIND( numnat_ref ) ! Namelist namtrc_bc in reference namelist : Passive tracer data structure 132 READ ( numnat_ref, namtrc_bdy, IOSTAT = ios, ERR = 903) 133 903 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_bdy in reference namelist', lwp ) 134 135 REWIND( numnat_cfg ) ! Namelist namtrc_bc in configuration namelist : Passive tracer data structure 136 READ ( numnat_cfg, namtrc_bdy, IOSTAT = ios, ERR = 904 ) 137 904 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_bdy in configuration namelist', lwp ) 138 IF(lwm) WRITE ( numont, namtrc_bdy ) 139 ! setup up preliminary informations for BDY structure 140 DO jn = 1, ntrc 141 DO ib = 1, nb_bdy 142 ! Set type of obc in BDY data structure (around here we may plug user override of obc type from nml) 143 IF ( ln_trc_obc(jn) ) THEN 144 trcdta_bdy(jn,ib)%cn_obc = TRIM( cn_trc(ib) ) 145 ELSE 146 trcdta_bdy(jn,ib)%cn_obc = TRIM( cn_trc_dflt(ib) ) 147 ENDIF 148 ! set damping use in BDY data structure 149 trcdta_bdy(jn,ib)%dmp = .false. 150 IF(nn_trcdmp_bdy(ib) .EQ. 1 .AND. ln_trc_obc(jn) ) trcdta_bdy(jn,ib)%dmp = .true. 151 IF(nn_trcdmp_bdy(ib) .EQ. 2 ) trcdta_bdy(jn,ib)%dmp = .true. 152 IF(trcdta_bdy(jn,ib)%cn_obc == 'frs' .AND. nn_trcdmp_bdy(ib) .NE. 0 ) & 153 & CALL ctl_stop( 'Use FRS OR relaxation' ) 154 IF (nn_trcdmp_bdy(ib) .LT. 0 .OR. nn_trcdmp_bdy(ib) .GT. 2) & 155 & CALL ctl_stop( 'Not a valid option for nn_trcdmp_bdy. Allowed: 0,1,2.' ) 131 IF ( ln_bdy ) THEN 132 REWIND( numnat_ref ) ! Namelist namtrc_bdy in reference namelist : Passive tracer data structure 133 READ ( numnat_ref, namtrc_bdy, IOSTAT = ios, ERR = 903) 134 903 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_bdy in reference namelist', lwp ) 135 136 REWIND( numnat_cfg ) ! Namelist namtrc_bdy in configuration namelist : Passive tracer data structure 137 READ ( numnat_cfg, namtrc_bdy, IOSTAT = ios, ERR = 904 ) 138 904 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_bdy in configuration namelist', lwp ) 139 IF(lwm) WRITE ( numont, namtrc_bdy ) 140 141 ! setup up preliminary informations for BDY structure 142 DO jn = 1, ntrc 143 DO ib = 1, nb_bdy 144 ! Set type of obc in BDY data structure (around here we may plug user override of obc type from nml) 145 IF ( ln_trc_obc(jn) ) THEN 146 trcdta_bdy(jn,ib)%cn_obc = TRIM( cn_trc(ib) ) 147 ELSE 148 trcdta_bdy(jn,ib)%cn_obc = TRIM( cn_trc_dflt(ib) ) 149 ENDIF 150 ! set damping use in BDY data structure 151 trcdta_bdy(jn,ib)%dmp = .false. 152 IF(nn_trcdmp_bdy(ib) .EQ. 1 .AND. ln_trc_obc(jn) ) trcdta_bdy(jn,ib)%dmp = .true. 153 IF(nn_trcdmp_bdy(ib) .EQ. 2 ) trcdta_bdy(jn,ib)%dmp = .true. 154 IF(trcdta_bdy(jn,ib)%cn_obc == 'frs' .AND. nn_trcdmp_bdy(ib) .NE. 0 ) & 155 & CALL ctl_stop( 'Use FRS OR relaxation' ) 156 IF (nn_trcdmp_bdy(ib) .LT. 0 .OR. nn_trcdmp_bdy(ib) .GT. 2) & 157 & CALL ctl_stop( 'Not a valid option for nn_trcdmp_bdy. Allowed: 0,1,2.' ) 158 ENDDO 156 159 ENDDO 157 ENDDO 158 159 #else 160 ! Force all tracers OBC to false if bdy not used 161 ln_trc_obc = .false. 162 #endif 160 ELSE 161 ! Force all tracers OBC to false if bdy not used 162 ln_trc_obc = .false. 163 ENDIF 164 163 165 ! compose BC data indexes 164 166 DO jn = 1, ntrc … … 188 190 WRITE(numout,*) ' ' 189 191 WRITE(numout,'(a,i3)') ' Total tracers to be initialized with COASTAL BCs data:', nb_trccbc 190 IF 192 IF( nb_trccbc > 0 ) THEN 191 193 WRITE(numout,*) ' #trc NAME Boundary Mult.Fact. ' 192 194 DO jn = 1, ntrc … … 195 197 ENDIF 196 198 WRITE(numout,'(2a)') ' COASTAL BC data repository : ', TRIM(cn_dir_cbc) 197 199 IF( .NOT.ln_rnf .OR. .NOT.ln_linssh ) ln_rnf_ctl = .FALSE. 200 IF( ln_rnf_ctl ) WRITE(numout,'(a)') ' -> Remove runoff dilution effect on tracers with absent river load (ln_rnf_ctl = .TRUE.)' 198 201 WRITE(numout,*) ' ' 199 202 WRITE(numout,'(a,i3)') ' Total tracers to be initialized with OPEN BCs data:', nb_trcobc 200 #if defined key_bdy 201 IF (nb_trcobc > 0 ) THEN203 204 IF( ln_bdy .AND. nb_trcobc > 0 ) THEN 202 205 WRITE(numout,*) ' #trc NAME Boundary Mult.Fact. OBC Settings' 203 206 DO jn = 1, ntrc 204 IF 205 IF 207 IF( ln_trc_obc(jn) ) WRITE(numout, 9001) jn, TRIM( sn_trcobc(jn)%clvar ), 'OBC', rn_trofac(jn), (trcdta_bdy(jn,ib)%cn_obc,ib=1,nb_bdy) 208 IF( .NOT. ln_trc_obc(jn) ) WRITE(numout, 9002) jn, 'Set data to IC and use default condition', (trcdta_bdy(jn,ib)%cn_obc,ib=1,nb_bdy) 206 209 ENDDO 207 210 WRITE(numout,*) ' ' 208 211 DO ib = 1, nb_bdy 209 IF 210 IF 211 IF 212 IF 212 IF(nn_trcdmp_bdy(ib) .EQ. 0) WRITE(numout,9003) ' Boundary ',ib,' -> NO damping of tracers' 213 IF(nn_trcdmp_bdy(ib) .EQ. 1) WRITE(numout,9003) ' Boundary ',ib,' -> damping ONLY for tracers with external data provided' 214 IF(nn_trcdmp_bdy(ib) .EQ. 2) WRITE(numout,9003) ' Boundary ',ib,' -> damping of ALL tracers' 215 IF(nn_trcdmp_bdy(ib) .GT. 0) THEN 213 216 WRITE(numout,9003) ' USE damping parameters from nambdy for boundary ', ib,' : ' 214 217 WRITE(numout,'(a,f10.2,a)') ' - Inflow damping time scale : ',rn_time_dmp(ib),' days' … … 217 220 ENDDO 218 221 ENDIF 219 #endif 222 220 223 WRITE(numout,'(2a)') ' OPEN BC data repository : ', TRIM(cn_dir_obc) 221 224 ENDIF … … 225 228 226 229 ! 227 #if defined key_bdy228 230 ! OPEN Lateral boundary conditions 229 IF( nb_trcobc > 0 ) THEN231 IF( ln_bdy .AND. nb_trcobc > 0 ) THEN 230 232 ALLOCATE ( sf_trcobc(nb_trcobc), rf_trofac(nb_trcobc), nbmap_ptr(nb_trcobc), STAT=ierr1 ) 231 233 IF( ierr1 > 0 ) THEN 232 CALL ctl_stop( 'trc_bc_ini t: unable to allocate sf_trcobc structure' ) ; RETURN234 CALL ctl_stop( 'trc_bc_ini: unable to allocate sf_trcobc structure' ) ; RETURN 233 235 ENDIF 234 236 … … 248 250 IF( sn_trcobc(jn)%ln_tint ) ALLOCATE( sf_trcobc(jl)%fdta(nblen,1,jpk,2) , STAT=ierr3 ) 249 251 IF( ierr2 + ierr3 > 0 ) THEN 250 CALL ctl_stop( 'trc_bc_ini t: unable to allocate passive tracer OBC data arrays' ) ; RETURN252 CALL ctl_stop( 'trc_bc_ini : unable to allocate passive tracer OBC data arrays' ) ; RETURN 251 253 ENDIF 252 254 trcdta_bdy(jn,ib)%trc => sf_trcobc(jl)%fnow(:,1,:) … … 270 272 ENDDO 271 273 272 CALL fld_fill( sf_trcobc, slf_i, cn_dir_obc, 'trc_bc_ini t', 'Passive tracer OBC data', 'namtrc_bc' )273 ENDIF 274 #endif 274 CALL fld_fill( sf_trcobc, slf_i, cn_dir_obc, 'trc_bc_ini', 'Passive tracer OBC data', 'namtrc_bc' ) 275 ENDIF 276 275 277 ! SURFACE Boundary conditions 276 278 IF( nb_trcsbc > 0 ) THEN ! allocate only if the number of tracer to initialise is greater than zero 277 279 ALLOCATE( sf_trcsbc(nb_trcsbc), rf_trsfac(nb_trcsbc), STAT=ierr1 ) 278 280 IF( ierr1 > 0 ) THEN 279 CALL ctl_stop( 'trc_bc_ini t: unable to allocate sf_trcsbc structure' ) ; RETURN281 CALL ctl_stop( 'trc_bc_ini: unable to allocate sf_trcsbc structure' ) ; RETURN 280 282 ENDIF 281 283 ! … … 288 290 IF( sn_trcsbc(jn)%ln_tint ) ALLOCATE( sf_trcsbc(jl)%fdta(jpi,jpj,1,2) , STAT=ierr3 ) 289 291 IF( ierr2 + ierr3 > 0 ) THEN 290 CALL ctl_stop( 'trc_bc_ini t: unable to allocate passive tracer SBC data arrays' ) ; RETURN292 CALL ctl_stop( 'trc_bc_ini : unable to allocate passive tracer SBC data arrays' ) ; RETURN 291 293 ENDIF 292 294 ENDIF … … 294 296 ENDDO 295 297 ! ! fill sf_trcsbc with slf_i and control print 296 CALL fld_fill( sf_trcsbc, slf_i, cn_dir_sbc, 'trc_bc_ini t', 'Passive tracer SBC data', 'namtrc_bc' )298 CALL fld_fill( sf_trcsbc, slf_i, cn_dir_sbc, 'trc_bc_ini', 'Passive tracer SBC data', 'namtrc_bc' ) 297 299 ! 298 300 ENDIF … … 319 321 ENDDO 320 322 ! ! fill sf_trccbc with slf_i and control print 321 CALL fld_fill( sf_trccbc, slf_i, cn_dir_cbc, 'trc_bc_ini t', 'Passive tracer CBC data', 'namtrc_bc' )323 CALL fld_fill( sf_trccbc, slf_i, cn_dir_cbc, 'trc_bc_ini', 'Passive tracer CBC data', 'namtrc_bc' ) 322 324 ! 323 325 ENDIF 324 326 ! 325 327 DEALLOCATE( slf_i ) ! deallocate local field structure 326 IF( nn_timing == 1 ) CALL timing_stop('trc_bc_ini t')327 ! 328 END SUBROUTINE trc_bc_ini t329 330 331 SUBROUTINE trc_bc _read(kt, jit)328 IF( nn_timing == 1 ) CALL timing_stop('trc_bc_ini') 329 ! 330 END SUBROUTINE trc_bc_ini 331 332 333 SUBROUTINE trc_bc(kt, jit) 332 334 !!---------------------------------------------------------------------- 333 !! *** ROUTINE trc_bc _init***335 !! *** ROUTINE trc_bc *** 334 336 !! 335 !! ** Purpose : Read passive tracer Boundary Conditions data337 !! ** Purpose : Apply Boundary Conditions data to tracers 336 338 !! 337 !! ** Method : Read BC inputs and update data structures using fldread 339 !! ** Method : 1) Read BC inputs and update data structures using fldread 340 !! 2) Apply Boundary Conditions to tracers 338 341 !! 339 342 !!---------------------------------------------------------------------- … … 341 344 342 345 !! * Arguments 343 INTEGER, INTENT( in ) :: kt ! ocean time-step index346 INTEGER, INTENT( in ) :: kt ! ocean time-step index 344 347 INTEGER, INTENT( in ), OPTIONAL :: jit ! subcycle time-step index (for timesplitting option) 348 !! 349 INTEGER :: ji, jj, jk, jn, jl ! Loop index 350 REAL(wp) :: zfact, zrnf 345 351 !!--------------------------------------------------------------------- 346 352 ! 347 IF( nn_timing == 1 ) CALL timing_start('trc_bc _read')353 IF( nn_timing == 1 ) CALL timing_start('trc_bc') 348 354 349 355 IF( kt == nit000 .AND. lwp) THEN 350 356 WRITE(numout,*) 351 WRITE(numout,*) 'trc_bc _read: Surface boundary conditions for passive tracers.'357 WRITE(numout,*) 'trc_bc : Surface boundary conditions for passive tracers.' 352 358 WRITE(numout,*) '~~~~~~~~~~~ ' 353 359 ENDIF 354 360 361 ! 1. Update Boundary conditions data 355 362 IF ( PRESENT(jit) ) THEN 356 363 … … 395 402 ENDIF 396 403 397 ! 398 IF( nn_timing == 1 ) CALL timing_stop('trc_bc_read') 399 ! 400 END SUBROUTINE trc_bc_read 404 ! 2. Apply Boundary conditions data 405 ! 406 DO jn = 1 , jptra 407 ! 408 ! Remove river dilution for tracers with absent river load 409 IF ( ln_rnf_ctl .AND. .NOT. ln_trc_cbc(jn) ) THEN 410 DO jj = 2, jpj 411 DO ji = fs_2, fs_jpim1 412 DO jk = 1, nk_rnf(ji,jj) 413 zrnf = (rnf(ji,jj) + rnf_b(ji,jj)) * 0.5_wp * r1_rau0 / h_rnf(ji,jj) 414 tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + (trn(ji,jj,jk,jn) * zrnf) 415 ENDDO 416 ENDDO 417 ENDDO 418 ENDIF 419 420 ! OPEN boundary conditions: trcbdy is called in trcnxt ! 421 422 ! SURFACE boundary conditions 423 IF (ln_trc_sbc(jn)) THEN 424 jl = n_trc_indsbc(jn) 425 DO jj = 2, jpj 426 DO ji = fs_2, fs_jpim1 ! vector opt. 427 zfact = 1. / ( e3t_n(ji,jj,1) * rn_bc_time ) 428 tra(ji,jj,1,jn) = tra(ji,jj,1,jn) + rf_trsfac(jl) * sf_trcsbc(jl)%fnow(ji,jj,1) * zfact 429 END DO 430 END DO 431 END IF 432 433 ! COASTAL boundary conditions 434 IF ( ln_rnf .AND. ln_trc_cbc(jn)) THEN 435 jl = n_trc_indcbc(jn) 436 DO jj = 2, jpj 437 DO ji = fs_2, fs_jpim1 ! vector opt. 438 DO jk = 1, nk_rnf(ji,jj) 439 zfact = rn_rfact / ( e1e2t(ji,jj) * h_rnf(ji,jj) * rn_bc_time ) 440 tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + rf_trcfac(jl) * sf_trccbc(jl)%fnow(ji,jj,1) * zfact 441 ENDDO 442 END DO 443 END DO 444 END IF 445 ! ! =========== 446 END DO ! tracer loop 447 ! ! =========== 448 ! 449 IF( nn_timing == 1 ) CALL timing_stop('trc_bc') 450 ! 451 END SUBROUTINE trc_bc 401 452 402 453 #else … … 406 457 CONTAINS 407 458 408 SUBROUTINE trc_bc_ini t( ntrc ) ! Empty routine459 SUBROUTINE trc_bc_ini( ntrc ) ! Empty routine 409 460 INTEGER,INTENT(IN) :: ntrc ! number of tracers 410 WRITE(*,*) 'trc_bc_ini t: You should not have seen this print! error?', kt411 END SUBROUTINE trc_bc_ini t412 413 SUBROUTINE trc_bc _read( kt ) ! Empty routine414 WRITE(*,*) 'trc_bc _read: You should not have seen this print! error?', kt415 END SUBROUTINE trc_bc _read461 WRITE(*,*) 'trc_bc_ini: You should not have seen this print! error?', kt 462 END SUBROUTINE trc_bc_ini 463 464 SUBROUTINE trc_bc( kt ) ! Empty routine 465 WRITE(*,*) 'trc_bc: You should not have seen this print! error?', kt 466 END SUBROUTINE trc_bc 416 467 #endif 417 468
Note: See TracChangeset
for help on using the changeset viewer.