[4058] | 1 | MODULE trcbc |
---|
| 2 | !!====================================================================== |
---|
| 3 | !! *** MODULE trcdta *** |
---|
| 4 | !! TOP : module for passive tracer boundary conditions |
---|
| 5 | !!===================================================================== |
---|
[10156] | 6 | !! History : 3.5 ! 2014-04 (M. Vichi, T. Lovato) Original |
---|
| 7 | !! 3.6 ! 2015-03 (T . Lovato) Revision and BDY support |
---|
[4058] | 8 | !!---------------------------------------------------------------------- |
---|
[10156] | 9 | #if defined key_top |
---|
[4058] | 10 | !!---------------------------------------------------------------------- |
---|
| 11 | !! 'key_top' TOP model |
---|
| 12 | !!---------------------------------------------------------------------- |
---|
[10156] | 13 | !! trc_bc : read and time interpolated tracer Boundary Conditions |
---|
[4058] | 14 | !!---------------------------------------------------------------------- |
---|
| 15 | USE par_trc ! passive tracers parameters |
---|
| 16 | USE oce_trc ! shared variables between ocean and passive tracers |
---|
| 17 | USE trc ! passive tracers common variables |
---|
| 18 | USE iom ! I/O manager |
---|
| 19 | USE lib_mpp ! MPP library |
---|
| 20 | USE fldread ! read input fields |
---|
[10156] | 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 |
---|
[4058] | 24 | |
---|
| 25 | IMPLICIT NONE |
---|
| 26 | PRIVATE |
---|
| 27 | |
---|
[4059] | 28 | PUBLIC trc_bc_init ! called in trcini.F90 |
---|
| 29 | PUBLIC trc_bc_read ! called in trcstp.F90 or within |
---|
[4058] | 30 | |
---|
[10156] | 31 | INTEGER , SAVE, PUBLIC :: nb_trcobc ! number of tracers with open BC |
---|
| 32 | INTEGER , SAVE, PUBLIC :: nb_trcsbc ! number of tracers with surface BC |
---|
| 33 | INTEGER , SAVE, PUBLIC :: nb_trccbc ! number of tracers with coastal BC |
---|
[4058] | 34 | INTEGER , SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:) :: n_trc_indobc ! index of tracer with OBC data |
---|
| 35 | INTEGER , SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:) :: n_trc_indsbc ! index of tracer with SBC data |
---|
| 36 | INTEGER , SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:) :: n_trc_indcbc ! index of tracer with CBC data |
---|
[10156] | 37 | REAL(wp) , SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:) :: rf_trsfac ! multiplicative factor for SBC tracer values |
---|
| 38 | TYPE(FLD), SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:) :: sf_trcsbc ! structure of data input SBC (file informations, fields read) |
---|
| 39 | REAL(wp) , SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:) :: rf_trcfac ! multiplicative factor for CBC tracer values |
---|
| 40 | TYPE(FLD), SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:) :: sf_trccbc ! structure of data input CBC (file informations, fields read) |
---|
| 41 | REAL(wp) , SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:,:) :: rf_trofac ! multiplicative factor for OBCtracer values |
---|
| 42 | TYPE(FLD), SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:,:), TARGET :: sf_trcobc ! structure of data input OBC (file informations, fields read) |
---|
| 43 | TYPE(MAP_POINTER), ALLOCATABLE, DIMENSION(:,:) :: nbmap_ptr ! array of pointers to nbmap |
---|
[4058] | 44 | |
---|
| 45 | !! * Substitutions |
---|
| 46 | # include "domzgr_substitute.h90" |
---|
| 47 | !!---------------------------------------------------------------------- |
---|
[10156] | 48 | !! NEMO/OPA 3.6 , NEMO Consortium (2015) |
---|
[8058] | 49 | !! $Id$ |
---|
[4058] | 50 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
| 51 | !!---------------------------------------------------------------------- |
---|
| 52 | CONTAINS |
---|
| 53 | |
---|
| 54 | SUBROUTINE trc_bc_init(ntrc) |
---|
| 55 | !!---------------------------------------------------------------------- |
---|
| 56 | !! *** ROUTINE trc_bc_init *** |
---|
| 57 | !! |
---|
| 58 | !! ** Purpose : initialisation of passive tracer BC data |
---|
| 59 | !! |
---|
| 60 | !! ** Method : - Read namtsd namelist |
---|
| 61 | !! - allocates passive tracer BC data structure |
---|
| 62 | !!---------------------------------------------------------------------- |
---|
| 63 | ! |
---|
| 64 | INTEGER,INTENT(IN) :: ntrc ! number of tracers |
---|
[10156] | 65 | INTEGER :: jl, jn , ib, ibd, ii, ij, ik ! dummy loop indices |
---|
[4058] | 66 | INTEGER :: ierr0, ierr1, ierr2, ierr3 ! temporary integers |
---|
[10156] | 67 | INTEGER :: ios ! Local integer output status for namelist read |
---|
| 68 | INTEGER :: nblen, igrd ! support arrays for BDY |
---|
[4058] | 69 | CHARACTER(len=100) :: clndta, clntrc |
---|
| 70 | ! |
---|
[10156] | 71 | CHARACTER(len=100) :: cn_dir_sbc, cn_dir_cbc, cn_dir_obc |
---|
| 72 | |
---|
[4058] | 73 | TYPE(FLD_N), ALLOCATABLE, DIMENSION(:) :: slf_i ! local array of namelist informations on the fields to read |
---|
[10156] | 74 | TYPE(FLD_N), DIMENSION(jpmaxtrc,2) :: sn_trcobc ! open |
---|
| 75 | TYPE(FLD_N), DIMENSION(jpmaxtrc) :: sn_trcobc2 ! to read in multiple (2) open bdy |
---|
[4058] | 76 | TYPE(FLD_N), DIMENSION(jpmaxtrc) :: sn_trcsbc ! surface |
---|
| 77 | TYPE(FLD_N), DIMENSION(jpmaxtrc) :: sn_trccbc ! coastal |
---|
| 78 | REAL(wp) , DIMENSION(jpmaxtrc) :: rn_trofac ! multiplicative factor for tracer values |
---|
| 79 | REAL(wp) , DIMENSION(jpmaxtrc) :: rn_trsfac ! multiplicative factor for tracer values |
---|
| 80 | REAL(wp) , DIMENSION(jpmaxtrc) :: rn_trcfac ! multiplicative factor for tracer values |
---|
| 81 | !! |
---|
[10156] | 82 | NAMELIST/namtrc_bc/ cn_dir_sbc, cn_dir_cbc, cn_dir_obc, sn_trcobc2, rn_trofac, sn_trcsbc, rn_trsfac, sn_trccbc, rn_trcfac |
---|
| 83 | #if defined key_bdy |
---|
| 84 | NAMELIST/namtrc_bdy/ cn_trc_dflt, cn_trc, nn_trcdmp_bdy |
---|
| 85 | #endif |
---|
[4058] | 86 | !!---------------------------------------------------------------------- |
---|
| 87 | IF( nn_timing == 1 ) CALL timing_start('trc_bc_init') |
---|
| 88 | ! |
---|
[10156] | 89 | IF( lwp ) THEN |
---|
| 90 | WRITE(numout,*) ' ' |
---|
| 91 | WRITE(numout,*) 'trc_bc_init : Tracers Boundary Conditions (BC)' |
---|
| 92 | WRITE(numout,*) '~~~~~~~~~~~ ' |
---|
| 93 | ENDIF |
---|
[4058] | 94 | ! Initialisation and local array allocation |
---|
| 95 | ierr0 = 0 ; ierr1 = 0 ; ierr2 = 0 ; ierr3 = 0 |
---|
| 96 | ALLOCATE( slf_i(ntrc), STAT=ierr0 ) |
---|
| 97 | IF( ierr0 > 0 ) THEN |
---|
| 98 | CALL ctl_stop( 'trc_bc_init: unable to allocate local slf_i' ) ; RETURN |
---|
| 99 | ENDIF |
---|
| 100 | |
---|
| 101 | ! Compute the number of tracers to be initialised with open, surface and boundary data |
---|
| 102 | ALLOCATE( n_trc_indobc(ntrc), STAT=ierr0 ) |
---|
| 103 | IF( ierr0 > 0 ) THEN |
---|
| 104 | CALL ctl_stop( 'trc_bc_init: unable to allocate n_trc_indobc' ) ; RETURN |
---|
| 105 | ENDIF |
---|
| 106 | nb_trcobc = 0 |
---|
| 107 | n_trc_indobc(:) = 0 |
---|
| 108 | ! |
---|
| 109 | ALLOCATE( n_trc_indsbc(ntrc), STAT=ierr0 ) |
---|
| 110 | IF( ierr0 > 0 ) THEN |
---|
| 111 | CALL ctl_stop( 'trc_bc_init: unable to allocate n_trc_indsbc' ) ; RETURN |
---|
| 112 | ENDIF |
---|
| 113 | nb_trcsbc = 0 |
---|
| 114 | n_trc_indsbc(:) = 0 |
---|
| 115 | ! |
---|
| 116 | ALLOCATE( n_trc_indcbc(ntrc), STAT=ierr0 ) |
---|
| 117 | IF( ierr0 > 0 ) THEN |
---|
| 118 | CALL ctl_stop( 'trc_bc_init: unable to allocate n_trc_indcbc' ) ; RETURN |
---|
| 119 | ENDIF |
---|
| 120 | nb_trccbc = 0 |
---|
| 121 | n_trc_indcbc(:) = 0 |
---|
| 122 | ! |
---|
[10156] | 123 | ! Read Boundary Conditions Namelists |
---|
| 124 | REWIND( numnat_ref ) ! Namelist namtrc_bc in reference namelist : Passive tracer data structure |
---|
| 125 | READ ( numnat_ref, namtrc_bc, IOSTAT = ios, ERR = 901) |
---|
| 126 | 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_bc in reference namelist', lwp ) |
---|
| 127 | |
---|
| 128 | REWIND( numnat_cfg ) ! Namelist namtrc_bc in configuration namelist : Passive tracer data structure |
---|
| 129 | #if defined key_bdy |
---|
| 130 | DO ib = 1, nb_bdy |
---|
| 131 | #endif |
---|
| 132 | READ ( numnat_cfg, namtrc_bc, IOSTAT = ios, ERR = 902 ) |
---|
| 133 | 902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_bc in configuration namelist', lwp ) |
---|
| 134 | IF(lwm) WRITE ( numont, namtrc_bc ) |
---|
| 135 | #if defined key_bdy |
---|
| 136 | sn_trcobc(:,ib)=sn_trcobc2(:) |
---|
| 137 | ENDDO |
---|
| 138 | #endif |
---|
| 139 | |
---|
| 140 | #if defined key_bdy |
---|
| 141 | REWIND( numnat_ref ) ! Namelist namtrc_bc in reference namelist : Passive tracer data structure |
---|
| 142 | READ ( numnat_ref, namtrc_bdy, IOSTAT = ios, ERR = 903) |
---|
| 143 | 903 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_bdy in reference namelist', lwp ) |
---|
| 144 | |
---|
| 145 | REWIND( numnat_cfg ) ! Namelist namtrc_bc in configuration namelist : Passive tracer data structure |
---|
| 146 | READ ( numnat_cfg, namtrc_bdy, IOSTAT = ios, ERR = 904 ) |
---|
| 147 | 904 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_bdy in configuration namelist', lwp ) |
---|
| 148 | IF(lwm) WRITE ( numont, namtrc_bdy ) |
---|
| 149 | ! setup up preliminary informations for BDY structure |
---|
[4058] | 150 | DO jn = 1, ntrc |
---|
[10156] | 151 | DO ib = 1, nb_bdy |
---|
| 152 | ! Set type of obc in BDY data structure (around here we may plug user override of obc type from nml) |
---|
| 153 | IF ( ln_trc_obc(jn) ) THEN |
---|
| 154 | trcdta_bdy(jn,ib)%cn_obc = TRIM( cn_trc(ib) ) |
---|
| 155 | ELSE |
---|
| 156 | trcdta_bdy(jn,ib)%cn_obc = TRIM( cn_trc_dflt(ib) ) |
---|
| 157 | ENDIF |
---|
| 158 | ! set damping use in BDY data structure |
---|
| 159 | trcdta_bdy(jn,ib)%dmp = .false. |
---|
| 160 | IF(nn_trcdmp_bdy(ib) .EQ. 1 .AND. ln_trc_obc(jn) ) trcdta_bdy(jn,ib)%dmp = .true. |
---|
| 161 | IF(nn_trcdmp_bdy(ib) .EQ. 2 ) trcdta_bdy(jn,ib)%dmp = .true. |
---|
| 162 | IF(trcdta_bdy(jn,ib)%cn_obc == 'frs' .AND. nn_trcdmp_bdy(ib) .NE. 0 ) & |
---|
| 163 | & CALL ctl_stop( 'Use FRS OR relaxation' ) |
---|
| 164 | IF (nn_trcdmp_bdy(ib) .LT. 0 .OR. nn_trcdmp_bdy(ib) .GT. 2) & |
---|
| 165 | & CALL ctl_stop( 'Not a valid option for nn_trcdmp_bdy. Allowed: 0,1,2.' ) |
---|
| 166 | ENDDO |
---|
| 167 | ENDDO |
---|
| 168 | |
---|
| 169 | #else |
---|
| 170 | ! Force all tracers OBC to false if bdy not used |
---|
| 171 | ln_trc_obc = .false. |
---|
| 172 | #endif |
---|
| 173 | ! compose BC data indexes |
---|
| 174 | DO jn = 1, ntrc |
---|
[4058] | 175 | IF( ln_trc_obc(jn) ) THEN |
---|
[10156] | 176 | nb_trcobc = nb_trcobc + 1 ; n_trc_indobc(jn) = nb_trcobc |
---|
[4058] | 177 | ENDIF |
---|
| 178 | IF( ln_trc_sbc(jn) ) THEN |
---|
[10156] | 179 | nb_trcsbc = nb_trcsbc + 1 ; n_trc_indsbc(jn) = nb_trcsbc |
---|
[4058] | 180 | ENDIF |
---|
| 181 | IF( ln_trc_cbc(jn) ) THEN |
---|
[10156] | 182 | nb_trccbc = nb_trccbc + 1 ; n_trc_indcbc(jn) = nb_trccbc |
---|
[4058] | 183 | ENDIF |
---|
| 184 | ENDDO |
---|
| 185 | ntra_obc = MAX( 1, nb_trcobc ) ! To avoid compilation error with bounds checking |
---|
| 186 | IF( lwp ) WRITE(numout,*) ' ' |
---|
| 187 | IF( lwp ) WRITE(numout,*) ' Number of passive tracers to be initialized with open boundary data :', nb_trcobc |
---|
| 188 | IF( lwp ) WRITE(numout,*) ' ' |
---|
| 189 | ntra_sbc = MAX( 1, nb_trcsbc ) ! To avoid compilation error with bounds checking |
---|
| 190 | IF( lwp ) WRITE(numout,*) ' ' |
---|
| 191 | IF( lwp ) WRITE(numout,*) ' Number of passive tracers to be initialized with surface boundary data :', nb_trcsbc |
---|
| 192 | IF( lwp ) WRITE(numout,*) ' ' |
---|
| 193 | ntra_cbc = MAX( 1, nb_trccbc ) ! To avoid compilation error with bounds checking |
---|
| 194 | IF( lwp ) WRITE(numout,*) ' ' |
---|
| 195 | IF( lwp ) WRITE(numout,*) ' Number of passive tracers to be initialized with coastal boundary data :', nb_trccbc |
---|
| 196 | IF( lwp ) WRITE(numout,*) ' ' |
---|
| 197 | |
---|
[10156] | 198 | ! Print summmary of Boundary Conditions |
---|
| 199 | IF( lwp ) THEN |
---|
| 200 | WRITE(numout,*) ' ' |
---|
| 201 | WRITE(numout,'(a,i3)') ' Total tracers to be initialized with SURFACE BCs data:', nb_trcsbc |
---|
| 202 | IF ( nb_trcsbc > 0 ) THEN |
---|
| 203 | WRITE(numout,*) ' #trc NAME Boundary Mult.Fact. ' |
---|
| 204 | DO jn = 1, ntrc |
---|
| 205 | IF ( ln_trc_sbc(jn) ) WRITE(numout,9001) jn, TRIM( sn_trcsbc(jn)%clvar ), 'SBC', rn_trsfac(jn) |
---|
| 206 | ENDDO |
---|
| 207 | ENDIF |
---|
| 208 | WRITE(numout,'(2a)') ' SURFACE BC data repository : ', TRIM(cn_dir_sbc) |
---|
[4058] | 209 | |
---|
[10156] | 210 | WRITE(numout,*) ' ' |
---|
| 211 | WRITE(numout,'(a,i3)') ' Total tracers to be initialized with COASTAL BCs data:', nb_trccbc |
---|
| 212 | IF ( nb_trccbc > 0 ) THEN |
---|
| 213 | WRITE(numout,*) ' #trc NAME Boundary Mult.Fact. ' |
---|
| 214 | DO jn = 1, ntrc |
---|
| 215 | IF ( ln_trc_cbc(jn) ) WRITE(numout, 9001) jn, TRIM( sn_trccbc(jn)%clvar ), 'CBC', rn_trcfac(jn) |
---|
| 216 | ENDDO |
---|
| 217 | ENDIF |
---|
| 218 | WRITE(numout,'(2a)') ' COASTAL BC data repository : ', TRIM(cn_dir_cbc) |
---|
[4230] | 219 | |
---|
[10156] | 220 | WRITE(numout,*) ' ' |
---|
| 221 | WRITE(numout,'(a,i3)') ' Total tracers to be initialized with OPEN BCs data:', nb_trcobc |
---|
| 222 | #if defined key_bdy |
---|
| 223 | IF ( nb_trcobc > 0 ) THEN |
---|
| 224 | WRITE(numout,*) ' #trc NAME Boundary Mult.Fact. OBC Settings' |
---|
| 225 | DO jn = 1, ntrc |
---|
| 226 | DO ib = 1, nb_bdy |
---|
| 227 | IF ( ln_trc_obc(jn) ) WRITE(numout, 9001) jn, TRIM( sn_trcobc(jn,ib)%clvar ), 'OBC', rn_trofac(jn), (trcdta_bdy(jn,ib)%cn_obc) |
---|
| 228 | ENDDO |
---|
| 229 | !IF ( ln_trc_obc(jn) ) WRITE(numout, 9001) jn, TRIM( sn_trcobc(jn,ib)%clvar ), 'OBC', rn_trofac(jn), (trcdta_bdy(jn,ib)%cn_obc,ib=1,nb_bdy) |
---|
| 230 | 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) |
---|
| 231 | ENDDO |
---|
| 232 | WRITE(numout,*) ' ' |
---|
| 233 | DO ib = 1, nb_bdy |
---|
| 234 | IF (nn_trcdmp_bdy(ib) .EQ. 0) WRITE(numout,9003) ' Boundary ',ib,' -> NO damping of tracers' |
---|
| 235 | IF (nn_trcdmp_bdy(ib) .EQ. 1) WRITE(numout,9003) ' Boundary ',ib,' -> damping ONLY for tracers with external data provided' |
---|
| 236 | IF (nn_trcdmp_bdy(ib) .EQ. 2) WRITE(numout,9003) ' Boundary ',ib,' -> damping of ALL tracers' |
---|
| 237 | IF (nn_trcdmp_bdy(ib) .GT. 0) THEN |
---|
| 238 | WRITE(numout,9003) ' USE damping parameters from nambdy for boundary ', ib,' : ' |
---|
| 239 | WRITE(numout,'(a,f10.2,a)') ' - Inflow damping time scale : ',rn_time_dmp(ib),' days' |
---|
| 240 | WRITE(numout,'(a,f10.2,a)') ' - Outflow damping time scale : ',rn_time_dmp_out(ib),' days' |
---|
| 241 | ENDIF |
---|
| 242 | ENDDO |
---|
| 243 | ENDIF |
---|
| 244 | #endif |
---|
| 245 | WRITE(numout,'(2a)') ' OPEN BC data repository : ', TRIM(cn_dir_obc) |
---|
[4058] | 246 | ENDIF |
---|
[10156] | 247 | 9001 FORMAT(2x,i5, 3x, a15, 3x, a5, 6x, e11.3, 4x, 10a13) |
---|
| 248 | 9002 FORMAT(2x,i5, 3x, a41, 3x, 10a13) |
---|
| 249 | 9003 FORMAT(a, i5, a) |
---|
| 250 | |
---|
[4058] | 251 | ! |
---|
[10156] | 252 | #if defined key_bdy |
---|
[4058] | 253 | ! OPEN Lateral boundary conditions |
---|
[10156] | 254 | IF( nb_trcobc > 0 ) THEN |
---|
| 255 | ALLOCATE ( sf_trcobc(nb_trcobc,nb_bdy), rf_trofac(nb_trcobc,nb_bdy), nbmap_ptr(nb_trcobc,nb_bdy), STAT=ierr1 ) |
---|
[4058] | 256 | IF( ierr1 > 0 ) THEN |
---|
[10156] | 257 | CALL ctl_stop( 'trc_bc_init: unable to allocate sf_trcobc structure' ) ; RETURN |
---|
[4058] | 258 | ENDIF |
---|
[10156] | 259 | |
---|
| 260 | igrd = 1 ! Everything is at T-points here |
---|
| 261 | |
---|
| 262 | DO ib = 1, nb_bdy |
---|
| 263 | DO jn = 1, ntrc |
---|
| 264 | |
---|
| 265 | nblen = idx_bdy(ib)%nblen(igrd) |
---|
| 266 | |
---|
| 267 | IF ( ln_trc_obc(jn) ) THEN |
---|
| 268 | ! Initialise from external data |
---|
| 269 | jl = n_trc_indobc(jn) |
---|
| 270 | slf_i(jl) = sn_trcobc(jn,ib) |
---|
| 271 | rf_trofac(jl,ib) = rn_trofac(jn) |
---|
| 272 | ALLOCATE( sf_trcobc(jl,ib)%fnow(nblen,1,jpk) , STAT=ierr2 ) |
---|
| 273 | IF( sn_trcobc(jn,ib)%ln_tint ) ALLOCATE( sf_trcobc(jl,ib)%fdta(nblen,1,jpk,2) , STAT=ierr3 ) |
---|
| 274 | IF( ierr2 + ierr3 > 0 ) THEN |
---|
| 275 | CALL ctl_stop( 'trc_bc_init : unable to allocate passive tracer OBC data arrays' ) ; RETURN |
---|
| 276 | ENDIF |
---|
| 277 | trcdta_bdy(jn,ib)%trc => sf_trcobc(jl,ib)%fnow(:,1,:) |
---|
| 278 | trcdta_bdy(jn,ib)%rn_fac = rf_trofac(jl,ib) |
---|
| 279 | ! create OBC mapping array |
---|
| 280 | nbmap_ptr(jl,ib)%ptr => idx_bdy(ib)%nbmap(:,igrd) |
---|
| 281 | nbmap_ptr(jl,ib)%ll_unstruc = ln_coords_file(igrd) |
---|
| 282 | ELSE |
---|
| 283 | ! Initialise obc arrays from initial conditions |
---|
| 284 | ALLOCATE ( trcdta_bdy(jn,ib)%trc(nblen,jpk) ) |
---|
| 285 | DO ibd = 1, nblen |
---|
| 286 | DO ik = 1, jpkm1 |
---|
| 287 | ii = idx_bdy(ib)%nbi(ibd,igrd) |
---|
| 288 | ij = idx_bdy(ib)%nbj(ibd,igrd) |
---|
| 289 | trcdta_bdy(jn,ib)%trc(ibd,ik) = trn(ii,ij,ik,jn) * tmask(ii,ij,ik) |
---|
| 290 | END DO |
---|
| 291 | END DO |
---|
| 292 | trcdta_bdy(jn,ib)%rn_fac = 1._wp |
---|
[4058] | 293 | ENDIF |
---|
[10156] | 294 | ENDDO |
---|
| 295 | CALL fld_fill( sf_trcobc(:,ib), slf_i, cn_dir_obc, 'trc_bc_init', 'Passive tracer OBC data', 'namtrc_bc' ) |
---|
[4058] | 296 | ENDDO |
---|
[10156] | 297 | |
---|
[4058] | 298 | ENDIF |
---|
[10156] | 299 | #endif |
---|
[4058] | 300 | ! SURFACE Boundary conditions |
---|
| 301 | IF( nb_trcsbc > 0 ) THEN ! allocate only if the number of tracer to initialise is greater than zero |
---|
| 302 | ALLOCATE( sf_trcsbc(nb_trcsbc), rf_trsfac(nb_trcsbc), STAT=ierr1 ) |
---|
| 303 | IF( ierr1 > 0 ) THEN |
---|
| 304 | CALL ctl_stop( 'trc_bc_init: unable to allocate sf_trcsbc structure' ) ; RETURN |
---|
| 305 | ENDIF |
---|
| 306 | ! |
---|
| 307 | DO jn = 1, ntrc |
---|
| 308 | IF( ln_trc_sbc(jn) ) THEN ! update passive tracers arrays with input data read from file |
---|
| 309 | jl = n_trc_indsbc(jn) |
---|
| 310 | slf_i(jl) = sn_trcsbc(jn) |
---|
| 311 | rf_trsfac(jl) = rn_trsfac(jn) |
---|
| 312 | ALLOCATE( sf_trcsbc(jl)%fnow(jpi,jpj,1) , STAT=ierr2 ) |
---|
| 313 | IF( sn_trcsbc(jn)%ln_tint ) ALLOCATE( sf_trcsbc(jl)%fdta(jpi,jpj,1,2) , STAT=ierr3 ) |
---|
| 314 | IF( ierr2 + ierr3 > 0 ) THEN |
---|
| 315 | CALL ctl_stop( 'trc_bc_init : unable to allocate passive tracer SBC data arrays' ) ; RETURN |
---|
| 316 | ENDIF |
---|
| 317 | ENDIF |
---|
| 318 | ! |
---|
| 319 | ENDDO |
---|
| 320 | ! ! fill sf_trcsbc with slf_i and control print |
---|
[10156] | 321 | CALL fld_fill( sf_trcsbc, slf_i, cn_dir_sbc, 'trc_bc_init', 'Passive tracer SBC data', 'namtrc_bc' ) |
---|
[4058] | 322 | ! |
---|
| 323 | ENDIF |
---|
| 324 | ! |
---|
| 325 | ! COSTAL Boundary conditions |
---|
| 326 | IF( nb_trccbc > 0 ) THEN ! allocate only if the number of tracer to initialise is greater than zero |
---|
| 327 | ALLOCATE( sf_trccbc(nb_trccbc), rf_trcfac(nb_trccbc), STAT=ierr1 ) |
---|
| 328 | IF( ierr1 > 0 ) THEN |
---|
| 329 | CALL ctl_stop( 'trc_bc_ini: unable to allocate sf_trccbc structure' ) ; RETURN |
---|
| 330 | ENDIF |
---|
| 331 | ! |
---|
| 332 | DO jn = 1, ntrc |
---|
| 333 | IF( ln_trc_cbc(jn) ) THEN ! update passive tracers arrays with input data read from file |
---|
| 334 | jl = n_trc_indcbc(jn) |
---|
| 335 | slf_i(jl) = sn_trccbc(jn) |
---|
| 336 | rf_trcfac(jl) = rn_trcfac(jn) |
---|
| 337 | ALLOCATE( sf_trccbc(jl)%fnow(jpi,jpj,1) , STAT=ierr2 ) |
---|
| 338 | IF( sn_trccbc(jn)%ln_tint ) ALLOCATE( sf_trccbc(jl)%fdta(jpi,jpj,1,2) , STAT=ierr3 ) |
---|
| 339 | IF( ierr2 + ierr3 > 0 ) THEN |
---|
| 340 | CALL ctl_stop( 'trc_bc_ini : unable to allocate passive tracer CBC data arrays' ) ; RETURN |
---|
| 341 | ENDIF |
---|
| 342 | ENDIF |
---|
| 343 | ! |
---|
| 344 | ENDDO |
---|
| 345 | ! ! fill sf_trccbc with slf_i and control print |
---|
[10156] | 346 | CALL fld_fill( sf_trccbc, slf_i, cn_dir_cbc, 'trc_bc_init', 'Passive tracer CBC data', 'namtrc_bc' ) |
---|
[4058] | 347 | ! |
---|
| 348 | ENDIF |
---|
| 349 | |
---|
| 350 | DEALLOCATE( slf_i ) ! deallocate local field structure |
---|
| 351 | IF( nn_timing == 1 ) CALL timing_stop('trc_bc_init') |
---|
| 352 | |
---|
| 353 | END SUBROUTINE trc_bc_init |
---|
| 354 | |
---|
| 355 | |
---|
[10156] | 356 | SUBROUTINE trc_bc_read(kt, jit) |
---|
[4058] | 357 | !!---------------------------------------------------------------------- |
---|
| 358 | !! *** ROUTINE trc_bc_init *** |
---|
| 359 | !! |
---|
| 360 | !! ** Purpose : Read passive tracer Boundary Conditions data |
---|
| 361 | !! |
---|
| 362 | !! ** Method : Read BC inputs and update data structures using fldread |
---|
| 363 | !! |
---|
| 364 | !!---------------------------------------------------------------------- |
---|
| 365 | |
---|
| 366 | ! NEMO |
---|
| 367 | USE fldread |
---|
| 368 | |
---|
| 369 | !! * Arguments |
---|
| 370 | INTEGER, INTENT( in ) :: kt ! ocean time-step index |
---|
[10156] | 371 | INTEGER, INTENT( in ), OPTIONAL :: jit ! subcycle time-step index (for timesplitting option) |
---|
| 372 | INTEGER :: ib |
---|
[4058] | 373 | !!--------------------------------------------------------------------- |
---|
| 374 | ! |
---|
| 375 | IF( nn_timing == 1 ) CALL timing_start('trc_bc_read') |
---|
| 376 | |
---|
[10156] | 377 | IF( kt == nit000 .AND. lwp) THEN |
---|
| 378 | WRITE(numout,*) |
---|
| 379 | WRITE(numout,*) 'trc_bc_read : Surface boundary conditions for passive tracers.' |
---|
| 380 | WRITE(numout,*) '~~~~~~~~~~~ ' |
---|
[4058] | 381 | ENDIF |
---|
| 382 | |
---|
[10156] | 383 | IF ( PRESENT(jit) ) THEN |
---|
[4058] | 384 | |
---|
[10156] | 385 | #ifdef key_bdy |
---|
| 386 | ! OPEN boundary conditions (use time_offset=+1 as they are applied at the end of the step) |
---|
| 387 | IF( nb_trcobc > 0 ) THEN |
---|
| 388 | if (lwp) write(numout,'(a,i5,a,i10)') ' reading OBC data for ', nb_trcobc ,' variable(s) at step ', kt |
---|
| 389 | DO ib = 1,nb_bdy |
---|
| 390 | CALL fld_read(kt=kt, kn_fsbc=1, sd=sf_trcobc(:,ib), map=nbmap_ptr(:,ib), kit=jit, kt_offset=+1) |
---|
| 391 | ENDDO |
---|
| 392 | ENDIF |
---|
| 393 | #endif |
---|
| 394 | |
---|
| 395 | ! SURFACE boundary conditions |
---|
| 396 | IF( nb_trcsbc > 0 ) THEN |
---|
| 397 | if (lwp) write(numout,'(a,i5,a,i10)') ' reading SBC data for ', nb_trcsbc ,' variable(s) at step ', kt |
---|
| 398 | CALL fld_read(kt=kt, kn_fsbc=1, sd=sf_trcsbc, kit=jit) |
---|
| 399 | ENDIF |
---|
| 400 | |
---|
| 401 | ! COASTAL boundary conditions |
---|
| 402 | IF( nb_trccbc > 0 ) THEN |
---|
| 403 | if (lwp) write(numout,'(a,i5,a,i10)') ' reading CBC data for ', nb_trccbc ,' variable(s) at step ', kt |
---|
| 404 | CALL fld_read(kt=kt, kn_fsbc=1, sd=sf_trccbc, kit=jit) |
---|
| 405 | ENDIF |
---|
| 406 | |
---|
| 407 | ELSE |
---|
| 408 | |
---|
| 409 | #ifdef key_bdy |
---|
| 410 | ! OPEN boundary conditions (use time_offset=+1 as they are applied at the end of the step) |
---|
| 411 | IF( nb_trcobc > 0 ) THEN |
---|
| 412 | if (lwp) write(numout,'(a,i5,a,i10)') ' reading OBC data for ', nb_trcobc ,' variable(s) at step ', kt |
---|
| 413 | DO ib = 1,nb_bdy |
---|
| 414 | CALL fld_read(kt=kt, kn_fsbc=1, sd=sf_trcobc(:,ib), map=nbmap_ptr(:,ib), kt_offset=+1) |
---|
| 415 | ENDDO |
---|
| 416 | ENDIF |
---|
| 417 | #endif |
---|
| 418 | |
---|
| 419 | ! SURFACE boundary conditions |
---|
| 420 | IF( nb_trcsbc > 0 ) THEN |
---|
| 421 | if (lwp) write(numout,'(a,i5,a,i10)') ' reading SBC data for ', nb_trcsbc ,' variable(s) at step ', kt |
---|
| 422 | CALL fld_read(kt=kt, kn_fsbc=1, sd=sf_trcsbc) |
---|
| 423 | ENDIF |
---|
| 424 | |
---|
| 425 | ! COASTAL boundary conditions |
---|
| 426 | IF( nb_trccbc > 0 ) THEN |
---|
| 427 | if (lwp) write(numout,'(a,i5,a,i10)') ' reading CBC data for ', nb_trccbc ,' variable(s) at step ', kt |
---|
| 428 | CALL fld_read(kt=kt, kn_fsbc=1, sd=sf_trccbc) |
---|
| 429 | ENDIF |
---|
| 430 | |
---|
[4058] | 431 | ENDIF |
---|
| 432 | |
---|
| 433 | ! COASTAL boundary conditions |
---|
| 434 | IF( nb_trccbc > 0 ) THEN |
---|
| 435 | if (lwp) write(numout,'(a,i5,a,i5)') ' reading CBC data for ', nb_trccbc ,' variables at step ', kt |
---|
| 436 | CALL fld_read(kt,1,sf_trccbc) |
---|
| 437 | ENDIF |
---|
| 438 | ! |
---|
| 439 | IF( nn_timing == 1 ) CALL timing_stop('trc_bc_read') |
---|
| 440 | ! |
---|
| 441 | |
---|
| 442 | END SUBROUTINE trc_bc_read |
---|
| 443 | #else |
---|
| 444 | !!---------------------------------------------------------------------- |
---|
| 445 | !! Dummy module NO 3D passive tracer data |
---|
| 446 | !!---------------------------------------------------------------------- |
---|
| 447 | CONTAINS |
---|
[10156] | 448 | |
---|
| 449 | SUBROUTINE trc_bc_init( ntrc ) ! Empty routine |
---|
| 450 | INTEGER,INTENT(IN) :: ntrc ! number of tracers |
---|
| 451 | WRITE(*,*) 'trc_bc_init: You should not have seen this print! error?', kt |
---|
| 452 | END SUBROUTINE trc_bc_init |
---|
| 453 | |
---|
[4058] | 454 | SUBROUTINE trc_bc_read( kt ) ! Empty routine |
---|
| 455 | WRITE(*,*) 'trc_bc_read: You should not have seen this print! error?', kt |
---|
| 456 | END SUBROUTINE trc_bc_read |
---|
| 457 | #endif |
---|
| 458 | |
---|
| 459 | !!====================================================================== |
---|
| 460 | END MODULE trcbc |
---|