[4058] | 1 | MODULE trcbc |
---|
| 2 | !!====================================================================== |
---|
| 3 | !! *** MODULE trcdta *** |
---|
| 4 | !! TOP : module for passive tracer boundary conditions |
---|
| 5 | !!===================================================================== |
---|
[10162] | 6 | !! History : 3.5 ! 2014-04 (M. Vichi, T. Lovato) Original |
---|
| 7 | !! 3.6 ! 2015-03 (T . Lovato) Revision and BDY support |
---|
[4058] | 8 | !!---------------------------------------------------------------------- |
---|
[10162] | 9 | #if defined key_top |
---|
[4058] | 10 | !!---------------------------------------------------------------------- |
---|
| 11 | !! 'key_top' TOP model |
---|
| 12 | !!---------------------------------------------------------------------- |
---|
[10162] | 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 |
---|
[10162] | 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 | |
---|
[10162] | 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 |
---|
[10162] | 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 | !!---------------------------------------------------------------------- |
---|
[10390] | 48 | !! NEMO/OPA 3.3 , NEMO Consortium (2010) |
---|
[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 |
---|
[10162] | 65 | INTEGER :: jl, jn , ib, ibd, ii, ij, ik ! dummy loop indices |
---|
[4058] | 66 | INTEGER :: ierr0, ierr1, ierr2, ierr3 ! temporary integers |
---|
[10162] | 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 | ! |
---|
[10162] | 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 |
---|
[10162] | 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 | !! |
---|
[10162] | 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 | ! |
---|
[10162] | 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 | ! |
---|
[10162] | 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 |
---|
[10162] | 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 |
---|
[10162] | 176 | nb_trcobc = nb_trcobc + 1 ; n_trc_indobc(jn) = nb_trcobc |
---|
[4058] | 177 | ENDIF |
---|
| 178 | IF( ln_trc_sbc(jn) ) THEN |
---|
[10162] | 179 | nb_trcsbc = nb_trcsbc + 1 ; n_trc_indsbc(jn) = nb_trcsbc |
---|
[4058] | 180 | ENDIF |
---|
| 181 | IF( ln_trc_cbc(jn) ) THEN |
---|
[10162] | 182 | nb_trccbc = nb_trccbc + 1 ; n_trc_indcbc(jn) = nb_trccbc |
---|
[4058] | 183 | ENDIF |
---|
| 184 | ENDDO |
---|
| 185 | |
---|
[10162] | 186 | ! Print summmary of Boundary Conditions |
---|
| 187 | IF( lwp ) THEN |
---|
| 188 | WRITE(numout,*) ' ' |
---|
| 189 | WRITE(numout,'(a,i3)') ' Total tracers to be initialized with SURFACE BCs data:', nb_trcsbc |
---|
| 190 | IF ( nb_trcsbc > 0 ) THEN |
---|
| 191 | WRITE(numout,*) ' #trc NAME Boundary Mult.Fact. ' |
---|
| 192 | DO jn = 1, ntrc |
---|
| 193 | IF ( ln_trc_sbc(jn) ) WRITE(numout,9001) jn, TRIM( sn_trcsbc(jn)%clvar ), 'SBC', rn_trsfac(jn) |
---|
| 194 | ENDDO |
---|
| 195 | ENDIF |
---|
| 196 | WRITE(numout,'(2a)') ' SURFACE BC data repository : ', TRIM(cn_dir_sbc) |
---|
[4058] | 197 | |
---|
[10162] | 198 | WRITE(numout,*) ' ' |
---|
| 199 | WRITE(numout,'(a,i3)') ' Total tracers to be initialized with COASTAL BCs data:', nb_trccbc |
---|
| 200 | IF ( nb_trccbc > 0 ) THEN |
---|
| 201 | WRITE(numout,*) ' #trc NAME Boundary Mult.Fact. ' |
---|
| 202 | DO jn = 1, ntrc |
---|
| 203 | IF ( ln_trc_cbc(jn) ) WRITE(numout, 9001) jn, TRIM( sn_trccbc(jn)%clvar ), 'CBC', rn_trcfac(jn) |
---|
| 204 | ENDDO |
---|
| 205 | ENDIF |
---|
| 206 | WRITE(numout,'(2a)') ' COASTAL BC data repository : ', TRIM(cn_dir_cbc) |
---|
[4230] | 207 | |
---|
[10162] | 208 | WRITE(numout,*) ' ' |
---|
| 209 | WRITE(numout,'(a,i3)') ' Total tracers to be initialized with OPEN BCs data:', nb_trcobc |
---|
| 210 | #if defined key_bdy |
---|
| 211 | IF ( nb_trcobc > 0 ) THEN |
---|
| 212 | WRITE(numout,*) ' #trc NAME Boundary Mult.Fact. OBC Settings' |
---|
| 213 | DO jn = 1, ntrc |
---|
| 214 | DO ib = 1, nb_bdy |
---|
| 215 | 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) |
---|
| 216 | ENDDO |
---|
| 217 | !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) |
---|
| 218 | 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) |
---|
| 219 | ENDDO |
---|
| 220 | WRITE(numout,*) ' ' |
---|
| 221 | DO ib = 1, nb_bdy |
---|
| 222 | IF (nn_trcdmp_bdy(ib) .EQ. 0) WRITE(numout,9003) ' Boundary ',ib,' -> NO damping of tracers' |
---|
| 223 | IF (nn_trcdmp_bdy(ib) .EQ. 1) WRITE(numout,9003) ' Boundary ',ib,' -> damping ONLY for tracers with external data provided' |
---|
| 224 | IF (nn_trcdmp_bdy(ib) .EQ. 2) WRITE(numout,9003) ' Boundary ',ib,' -> damping of ALL tracers' |
---|
| 225 | IF (nn_trcdmp_bdy(ib) .GT. 0) THEN |
---|
| 226 | WRITE(numout,9003) ' USE damping parameters from nambdy for boundary ', ib,' : ' |
---|
| 227 | WRITE(numout,'(a,f10.2,a)') ' - Inflow damping time scale : ',rn_time_dmp(ib),' days' |
---|
| 228 | WRITE(numout,'(a,f10.2,a)') ' - Outflow damping time scale : ',rn_time_dmp_out(ib),' days' |
---|
| 229 | ENDIF |
---|
| 230 | ENDDO |
---|
| 231 | ENDIF |
---|
| 232 | #endif |
---|
| 233 | WRITE(numout,'(2a)') ' OPEN BC data repository : ', TRIM(cn_dir_obc) |
---|
[4058] | 234 | ENDIF |
---|
[10162] | 235 | 9001 FORMAT(2x,i5, 3x, a15, 3x, a5, 6x, e11.3, 4x, 10a13) |
---|
| 236 | 9002 FORMAT(2x,i5, 3x, a41, 3x, 10a13) |
---|
| 237 | 9003 FORMAT(a, i5, a) |
---|
| 238 | |
---|
[4058] | 239 | ! |
---|
[10162] | 240 | #if defined key_bdy |
---|
[4058] | 241 | ! OPEN Lateral boundary conditions |
---|
[10162] | 242 | IF( nb_trcobc > 0 ) THEN |
---|
| 243 | ALLOCATE ( sf_trcobc(nb_trcobc,nb_bdy), rf_trofac(nb_trcobc,nb_bdy), nbmap_ptr(nb_trcobc,nb_bdy), STAT=ierr1 ) |
---|
[4058] | 244 | IF( ierr1 > 0 ) THEN |
---|
[10162] | 245 | CALL ctl_stop( 'trc_bc_init: unable to allocate sf_trcobc structure' ) ; RETURN |
---|
[4058] | 246 | ENDIF |
---|
[10162] | 247 | |
---|
| 248 | igrd = 1 ! Everything is at T-points here |
---|
| 249 | |
---|
| 250 | DO ib = 1, nb_bdy |
---|
| 251 | DO jn = 1, ntrc |
---|
| 252 | |
---|
| 253 | nblen = idx_bdy(ib)%nblen(igrd) |
---|
| 254 | |
---|
| 255 | IF ( ln_trc_obc(jn) ) THEN |
---|
| 256 | ! Initialise from external data |
---|
| 257 | jl = n_trc_indobc(jn) |
---|
| 258 | slf_i(jl) = sn_trcobc(jn,ib) |
---|
| 259 | rf_trofac(jl,ib) = rn_trofac(jn) |
---|
| 260 | ALLOCATE( sf_trcobc(jl,ib)%fnow(nblen,1,jpk) , STAT=ierr2 ) |
---|
| 261 | IF( sn_trcobc(jn,ib)%ln_tint ) ALLOCATE( sf_trcobc(jl,ib)%fdta(nblen,1,jpk,2) , STAT=ierr3 ) |
---|
| 262 | IF( ierr2 + ierr3 > 0 ) THEN |
---|
| 263 | CALL ctl_stop( 'trc_bc_init : unable to allocate passive tracer OBC data arrays' ) ; RETURN |
---|
| 264 | ENDIF |
---|
| 265 | trcdta_bdy(jn,ib)%trc => sf_trcobc(jl,ib)%fnow(:,1,:) |
---|
| 266 | trcdta_bdy(jn,ib)%rn_fac = rf_trofac(jl,ib) |
---|
| 267 | ! create OBC mapping array |
---|
| 268 | nbmap_ptr(jl,ib)%ptr => idx_bdy(ib)%nbmap(:,igrd) |
---|
| 269 | nbmap_ptr(jl,ib)%ll_unstruc = ln_coords_file(igrd) |
---|
| 270 | ELSE |
---|
| 271 | ! Initialise obc arrays from initial conditions |
---|
| 272 | ALLOCATE ( trcdta_bdy(jn,ib)%trc(nblen,jpk) ) |
---|
| 273 | DO ibd = 1, nblen |
---|
| 274 | DO ik = 1, jpkm1 |
---|
| 275 | ii = idx_bdy(ib)%nbi(ibd,igrd) |
---|
| 276 | ij = idx_bdy(ib)%nbj(ibd,igrd) |
---|
| 277 | trcdta_bdy(jn,ib)%trc(ibd,ik) = trn(ii,ij,ik,jn) * tmask(ii,ij,ik) |
---|
| 278 | END DO |
---|
| 279 | END DO |
---|
| 280 | trcdta_bdy(jn,ib)%rn_fac = 1._wp |
---|
[4058] | 281 | ENDIF |
---|
[10162] | 282 | ENDDO |
---|
| 283 | CALL fld_fill( sf_trcobc(:,ib), slf_i, cn_dir_obc, 'trc_bc_init', 'Passive tracer OBC data', 'namtrc_bc' ) |
---|
[4058] | 284 | ENDDO |
---|
[10162] | 285 | |
---|
[4058] | 286 | ENDIF |
---|
[10162] | 287 | #endif |
---|
[4058] | 288 | ! SURFACE Boundary conditions |
---|
| 289 | IF( nb_trcsbc > 0 ) THEN ! allocate only if the number of tracer to initialise is greater than zero |
---|
| 290 | ALLOCATE( sf_trcsbc(nb_trcsbc), rf_trsfac(nb_trcsbc), STAT=ierr1 ) |
---|
| 291 | IF( ierr1 > 0 ) THEN |
---|
| 292 | CALL ctl_stop( 'trc_bc_init: unable to allocate sf_trcsbc structure' ) ; RETURN |
---|
| 293 | ENDIF |
---|
| 294 | ! |
---|
| 295 | DO jn = 1, ntrc |
---|
| 296 | IF( ln_trc_sbc(jn) ) THEN ! update passive tracers arrays with input data read from file |
---|
| 297 | jl = n_trc_indsbc(jn) |
---|
| 298 | slf_i(jl) = sn_trcsbc(jn) |
---|
| 299 | rf_trsfac(jl) = rn_trsfac(jn) |
---|
| 300 | ALLOCATE( sf_trcsbc(jl)%fnow(jpi,jpj,1) , STAT=ierr2 ) |
---|
| 301 | IF( sn_trcsbc(jn)%ln_tint ) ALLOCATE( sf_trcsbc(jl)%fdta(jpi,jpj,1,2) , STAT=ierr3 ) |
---|
| 302 | IF( ierr2 + ierr3 > 0 ) THEN |
---|
| 303 | CALL ctl_stop( 'trc_bc_init : unable to allocate passive tracer SBC data arrays' ) ; RETURN |
---|
| 304 | ENDIF |
---|
| 305 | ENDIF |
---|
| 306 | ! |
---|
| 307 | ENDDO |
---|
| 308 | ! ! fill sf_trcsbc with slf_i and control print |
---|
[10162] | 309 | CALL fld_fill( sf_trcsbc, slf_i, cn_dir_sbc, 'trc_bc_init', 'Passive tracer SBC data', 'namtrc_bc' ) |
---|
[4058] | 310 | ! |
---|
| 311 | ENDIF |
---|
| 312 | ! |
---|
| 313 | ! COSTAL Boundary conditions |
---|
| 314 | IF( nb_trccbc > 0 ) THEN ! allocate only if the number of tracer to initialise is greater than zero |
---|
| 315 | ALLOCATE( sf_trccbc(nb_trccbc), rf_trcfac(nb_trccbc), STAT=ierr1 ) |
---|
| 316 | IF( ierr1 > 0 ) THEN |
---|
| 317 | CALL ctl_stop( 'trc_bc_ini: unable to allocate sf_trccbc structure' ) ; RETURN |
---|
| 318 | ENDIF |
---|
| 319 | ! |
---|
| 320 | DO jn = 1, ntrc |
---|
| 321 | IF( ln_trc_cbc(jn) ) THEN ! update passive tracers arrays with input data read from file |
---|
| 322 | jl = n_trc_indcbc(jn) |
---|
| 323 | slf_i(jl) = sn_trccbc(jn) |
---|
| 324 | rf_trcfac(jl) = rn_trcfac(jn) |
---|
| 325 | ALLOCATE( sf_trccbc(jl)%fnow(jpi,jpj,1) , STAT=ierr2 ) |
---|
| 326 | IF( sn_trccbc(jn)%ln_tint ) ALLOCATE( sf_trccbc(jl)%fdta(jpi,jpj,1,2) , STAT=ierr3 ) |
---|
| 327 | IF( ierr2 + ierr3 > 0 ) THEN |
---|
| 328 | CALL ctl_stop( 'trc_bc_ini : unable to allocate passive tracer CBC data arrays' ) ; RETURN |
---|
| 329 | ENDIF |
---|
| 330 | ENDIF |
---|
| 331 | ! |
---|
| 332 | ENDDO |
---|
| 333 | ! ! fill sf_trccbc with slf_i and control print |
---|
[10162] | 334 | CALL fld_fill( sf_trccbc, slf_i, cn_dir_cbc, 'trc_bc_init', 'Passive tracer CBC data', 'namtrc_bc' ) |
---|
[4058] | 335 | ! |
---|
| 336 | ENDIF |
---|
| 337 | |
---|
| 338 | DEALLOCATE( slf_i ) ! deallocate local field structure |
---|
| 339 | IF( nn_timing == 1 ) CALL timing_stop('trc_bc_init') |
---|
| 340 | |
---|
| 341 | END SUBROUTINE trc_bc_init |
---|
| 342 | |
---|
| 343 | |
---|
[10162] | 344 | SUBROUTINE trc_bc_read(kt, jit) |
---|
[4058] | 345 | !!---------------------------------------------------------------------- |
---|
| 346 | !! *** ROUTINE trc_bc_init *** |
---|
| 347 | !! |
---|
| 348 | !! ** Purpose : Read passive tracer Boundary Conditions data |
---|
| 349 | !! |
---|
| 350 | !! ** Method : Read BC inputs and update data structures using fldread |
---|
| 351 | !! |
---|
| 352 | !!---------------------------------------------------------------------- |
---|
| 353 | |
---|
| 354 | ! NEMO |
---|
| 355 | USE fldread |
---|
| 356 | |
---|
| 357 | !! * Arguments |
---|
| 358 | INTEGER, INTENT( in ) :: kt ! ocean time-step index |
---|
[10162] | 359 | INTEGER, INTENT( in ), OPTIONAL :: jit ! subcycle time-step index (for timesplitting option) |
---|
| 360 | INTEGER :: ib |
---|
[4058] | 361 | !!--------------------------------------------------------------------- |
---|
| 362 | ! |
---|
| 363 | IF( nn_timing == 1 ) CALL timing_start('trc_bc_read') |
---|
| 364 | |
---|
[10162] | 365 | IF( kt == nit000 .AND. lwp) THEN |
---|
| 366 | WRITE(numout,*) |
---|
| 367 | WRITE(numout,*) 'trc_bc_read : Surface boundary conditions for passive tracers.' |
---|
| 368 | WRITE(numout,*) '~~~~~~~~~~~ ' |
---|
[4058] | 369 | ENDIF |
---|
| 370 | |
---|
[10162] | 371 | IF ( PRESENT(jit) ) THEN |
---|
[4058] | 372 | |
---|
[10162] | 373 | #ifdef key_bdy |
---|
| 374 | ! OPEN boundary conditions (use time_offset=+1 as they are applied at the end of the step) |
---|
| 375 | IF( nb_trcobc > 0 ) THEN |
---|
| 376 | if (lwp) write(numout,'(a,i5,a,i10)') ' reading OBC data for ', nb_trcobc ,' variable(s) at step ', kt |
---|
| 377 | DO ib = 1,nb_bdy |
---|
| 378 | CALL fld_read(kt=kt, kn_fsbc=1, sd=sf_trcobc(:,ib), map=nbmap_ptr(:,ib), kit=jit, kt_offset=+1) |
---|
| 379 | ENDDO |
---|
| 380 | ENDIF |
---|
| 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, kit=jit) |
---|
| 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, kit=jit) |
---|
| 393 | ENDIF |
---|
| 394 | |
---|
| 395 | ELSE |
---|
| 396 | |
---|
| 397 | #ifdef key_bdy |
---|
| 398 | ! OPEN boundary conditions (use time_offset=+1 as they are applied at the end of the step) |
---|
| 399 | IF( nb_trcobc > 0 ) THEN |
---|
| 400 | if (lwp) write(numout,'(a,i5,a,i10)') ' reading OBC data for ', nb_trcobc ,' variable(s) at step ', kt |
---|
| 401 | DO ib = 1,nb_bdy |
---|
| 402 | CALL fld_read(kt=kt, kn_fsbc=1, sd=sf_trcobc(:,ib), map=nbmap_ptr(:,ib), kt_offset=+1) |
---|
| 403 | ENDDO |
---|
| 404 | ENDIF |
---|
| 405 | #endif |
---|
| 406 | |
---|
| 407 | ! SURFACE boundary conditions |
---|
| 408 | IF( nb_trcsbc > 0 ) THEN |
---|
| 409 | if (lwp) write(numout,'(a,i5,a,i10)') ' reading SBC data for ', nb_trcsbc ,' variable(s) at step ', kt |
---|
| 410 | CALL fld_read(kt=kt, kn_fsbc=1, sd=sf_trcsbc) |
---|
| 411 | ENDIF |
---|
| 412 | |
---|
| 413 | ! COASTAL boundary conditions |
---|
| 414 | IF( nb_trccbc > 0 ) THEN |
---|
| 415 | if (lwp) write(numout,'(a,i5,a,i10)') ' reading CBC data for ', nb_trccbc ,' variable(s) at step ', kt |
---|
| 416 | CALL fld_read(kt=kt, kn_fsbc=1, sd=sf_trccbc) |
---|
| 417 | ENDIF |
---|
| 418 | |
---|
[4058] | 419 | ENDIF |
---|
| 420 | |
---|
| 421 | ! |
---|
| 422 | IF( nn_timing == 1 ) CALL timing_stop('trc_bc_read') |
---|
| 423 | ! |
---|
| 424 | |
---|
| 425 | END SUBROUTINE trc_bc_read |
---|
| 426 | #else |
---|
| 427 | !!---------------------------------------------------------------------- |
---|
| 428 | !! Dummy module NO 3D passive tracer data |
---|
| 429 | !!---------------------------------------------------------------------- |
---|
| 430 | CONTAINS |
---|
[10162] | 431 | |
---|
| 432 | SUBROUTINE trc_bc_init( ntrc ) ! Empty routine |
---|
| 433 | INTEGER,INTENT(IN) :: ntrc ! number of tracers |
---|
| 434 | WRITE(*,*) 'trc_bc_init: You should not have seen this print! error?', kt |
---|
| 435 | END SUBROUTINE trc_bc_init |
---|
| 436 | |
---|
[4058] | 437 | SUBROUTINE trc_bc_read( kt ) ! Empty routine |
---|
| 438 | WRITE(*,*) 'trc_bc_read: You should not have seen this print! error?', kt |
---|
| 439 | END SUBROUTINE trc_bc_read |
---|
| 440 | #endif |
---|
| 441 | |
---|
| 442 | !!====================================================================== |
---|
| 443 | END MODULE trcbc |
---|