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