New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
trcbc.F90 in trunk/NEMOGCM/NEMO/TOP_SRC – NEMO

source: trunk/NEMOGCM/NEMO/TOP_SRC/trcbc.F90 @ 7953

Last change on this file since 7953 was 7646, checked in by timgraham, 7 years ago

Merge of dev_merge_2016 into trunk. UPDATE TO ARCHFILES NEEDED for XIOS2.
LIM_SRC_s/limrhg.F90 to follow in next commit due to change of kind (I'm unable to do it in this commit).
Merged using the following steps:

1) svn merge --reintegrate svn+ssh://forge.ipsl.jussieu.fr/ipsl/forge/projets/nemo/svn/trunk .
2) Resolve minor conflicts in sette.sh and namelist_cfg for ORCA2LIM3 (due to a change in trunk after branch was created)
3) svn commit
4) svn switch svn+ssh://forge.ipsl.jussieu.fr/ipsl/forge/projets/nemo/svn/trunk
5) svn merge svn+ssh://forge.ipsl.jussieu.fr/ipsl/forge/projets/nemo/svn/branches/2016/dev_merge_2016 .
6) At this stage I checked out a clean copy of the branch to compare against what is about to be committed to the trunk.
6) svn commit #Commit code to the trunk

In this commit I have also reverted a change to Fcheck_archfile.sh which was causing problems on the Paris machine.

  • Property svn:keywords set to Id
File size: 22.5 KB
RevLine 
[4058]1MODULE trcbc
2   !!======================================================================
[6140]3   !!                     ***  MODULE  trcbc  ***
[4058]4   !! TOP :  module for passive tracer boundary conditions
5   !!=====================================================================
[7646]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
[4058]9   !!----------------------------------------------------------------------
[6140]10#if defined key_top
[4058]11   !!----------------------------------------------------------------------
12   !!   'key_top'                                                TOP model
13   !!----------------------------------------------------------------------
[7646]14   !!   trc_bc       :  Apply tracer Boundary Conditions
[4058]15   !!----------------------------------------------------------------------
16   USE par_trc       !  passive tracers parameters
17   USE oce_trc       !  shared variables between ocean and passive tracers
18   USE trc           !  passive tracers common variables
19   USE iom           !  I/O manager
20   USE lib_mpp       !  MPP library
21   USE fldread       !  read input fields
[7646]22   USE bdy_oce,  ONLY: ln_bdy, nb_bdy , idx_bdy, ln_coords_file, rn_time_dmp, rn_time_dmp_out
[4058]23
24   IMPLICIT NONE
25   PRIVATE
26
[7646]27   PUBLIC   trc_bc         ! called in trcstp.F90 or within TOP modules
28   PUBLIC   trc_bc_ini     ! called in trcini.F90
[4058]29
[6140]30   INTEGER  , SAVE, PUBLIC                             :: nb_trcobc    ! number of tracers with open BC
31   INTEGER  , SAVE, PUBLIC                             :: nb_trcsbc    ! number of tracers with surface BC
32   INTEGER  , SAVE, PUBLIC                             :: nb_trccbc    ! number of tracers with coastal BC
[4058]33   INTEGER  , SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:)  :: n_trc_indobc ! index of tracer with OBC data
34   INTEGER  , SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:)  :: n_trc_indsbc ! index of tracer with SBC data
35   INTEGER  , SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:)  :: n_trc_indcbc ! index of tracer with CBC data
[6140]36   REAL(wp) , SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:)  :: rf_trsfac    ! multiplicative factor for SBC tracer values
37   TYPE(FLD), SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:)  :: sf_trcsbc    ! structure of data input SBC (file informations, fields read)
38   REAL(wp) , SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:)  :: rf_trcfac    ! multiplicative factor for CBC tracer values
39   TYPE(FLD), SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:)  :: sf_trccbc    ! structure of data input CBC (file informations, fields read)
40   REAL(wp) , SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:)  :: rf_trofac    ! multiplicative factor for OBCtracer values
41   TYPE(FLD), SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:), TARGET  :: sf_trcobc    ! structure of data input OBC (file informations, fields read)
42   TYPE(MAP_POINTER), ALLOCATABLE, DIMENSION(:) :: nbmap_ptr   ! array of pointers to nbmap
[4058]43
[7646]44   !! * Substitutions
45#  include "vectopt_loop_substitute.h90"
[4058]46   !!----------------------------------------------------------------------
[7646]47   !! NEMO/TOP 4.0 , NEMO Consortium (2016)
[6140]48   !! $Id$
[4058]49   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
50   !!----------------------------------------------------------------------
51CONTAINS
52
[7646]53   SUBROUTINE trc_bc_ini( ntrc )
[4058]54      !!----------------------------------------------------------------------
[7646]55      !!                   ***  ROUTINE trc_bc_ini  ***
[4058]56      !!                   
57      !! ** Purpose :   initialisation of passive tracer BC data
58      !!
59      !! ** Method  : - Read namtsd namelist
60      !!              - allocates passive tracer BC data structure
61      !!----------------------------------------------------------------------
62      !
63      INTEGER,INTENT(IN) :: ntrc                           ! number of tracers
[6140]64      INTEGER            :: jl, jn , ib, ibd, ii, ij, ik   ! dummy loop indices
[4058]65      INTEGER            :: ierr0, ierr1, ierr2, ierr3     ! temporary integers
[6140]66      INTEGER            :: ios                            ! Local integer output status for namelist read
67      INTEGER            :: nblen, igrd                    ! support arrays for BDY
[4058]68      CHARACTER(len=100) :: clndta, clntrc
69      !
[6140]70      CHARACTER(len=100) :: cn_dir_sbc, cn_dir_cbc, cn_dir_obc
71
[4058]72      TYPE(FLD_N), ALLOCATABLE, DIMENSION(:) :: slf_i  ! local array of namelist informations on the fields to read
73      TYPE(FLD_N), DIMENSION(jpmaxtrc) :: sn_trcobc    ! open
74      TYPE(FLD_N), DIMENSION(jpmaxtrc) :: sn_trcsbc    ! surface
75      TYPE(FLD_N), DIMENSION(jpmaxtrc) :: sn_trccbc    ! coastal
76      REAL(wp)   , DIMENSION(jpmaxtrc) :: rn_trofac    ! multiplicative factor for tracer values
77      REAL(wp)   , DIMENSION(jpmaxtrc) :: rn_trsfac    ! multiplicative factor for tracer values
78      REAL(wp)   , DIMENSION(jpmaxtrc) :: rn_trcfac    ! multiplicative factor for tracer values
79      !!
[7646]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
[6140]82      NAMELIST/namtrc_bdy/ cn_trc_dflt, cn_trc, nn_trcdmp_bdy
[7646]83
[4058]84      !!----------------------------------------------------------------------
[7646]85      IF( nn_timing == 1 )  CALL timing_start('trc_bc_ini')
[4058]86      !
[6140]87      IF( lwp ) THEN
88         WRITE(numout,*) ' '
[7646]89         WRITE(numout,*) 'trc_bc_ini : Tracers Boundary Conditions (BC)'
[6140]90         WRITE(numout,*) '~~~~~~~~~~~ '
91      ENDIF
[4058]92      !  Initialisation and local array allocation
93      ierr0 = 0  ;  ierr1 = 0  ;  ierr2 = 0  ;  ierr3 = 0 
94      ALLOCATE( slf_i(ntrc), STAT=ierr0 )
95      IF( ierr0 > 0 ) THEN
[7646]96         CALL ctl_stop( 'trc_bc_ini: unable to allocate local slf_i' )   ;   RETURN
[4058]97      ENDIF
98
99      ! Compute the number of tracers to be initialised with open, surface and boundary data
100      ALLOCATE( n_trc_indobc(ntrc), STAT=ierr0 )
101      IF( ierr0 > 0 ) THEN
[7646]102         CALL ctl_stop( 'trc_bc_ini: unable to allocate n_trc_indobc' )   ;   RETURN
[4058]103      ENDIF
104      nb_trcobc      = 0
105      n_trc_indobc(:) = 0
106      !
107      ALLOCATE( n_trc_indsbc(ntrc), STAT=ierr0 )
108      IF( ierr0 > 0 ) THEN
[7646]109         CALL ctl_stop( 'trc_bc_ini: unable to allocate n_trc_indsbc' )   ;   RETURN
[4058]110      ENDIF
111      nb_trcsbc      = 0
112      n_trc_indsbc(:) = 0
113      !
114      ALLOCATE( n_trc_indcbc(ntrc), STAT=ierr0 )
115      IF( ierr0 > 0 ) THEN
[7646]116         CALL ctl_stop( 'trc_bc_ini: unable to allocate n_trc_indcbc' )   ;   RETURN
[4058]117      ENDIF
118      nb_trccbc      = 0
119      n_trc_indcbc(:) = 0
120      !
[6140]121      ! Read Boundary Conditions Namelists
122      REWIND( numnat_ref )              ! Namelist namtrc_bc in reference namelist : Passive tracer data structure
123      READ  ( numnat_ref, namtrc_bc, IOSTAT = ios, ERR = 901)
124901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_bc in reference namelist', lwp )
125
126      REWIND( numnat_cfg )              ! Namelist namtrc_bc in configuration namelist : Passive tracer data structure
127      READ  ( numnat_cfg, namtrc_bc, IOSTAT = ios, ERR = 902 )
128902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_bc in configuration namelist', lwp )
129      IF(lwm) WRITE ( numont, namtrc_bc )
130
[7646]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)
134903      IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_bdy in reference namelist', lwp )
[6140]135
[7646]136         REWIND( numnat_cfg )              ! Namelist namtrc_bdy in configuration namelist : Passive tracer data structure
137         READ  ( numnat_cfg, namtrc_bdy, IOSTAT = ios, ERR = 904 )
138904      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
[6140]159         ENDDO
[7646]160      ELSE
161         ! Force all tracers OBC to false if bdy not used
162         ln_trc_obc = .false.
163      ENDIF
[6140]164
165      ! compose BC data indexes
166      DO jn = 1, ntrc
[4058]167         IF( ln_trc_obc(jn) ) THEN
[6140]168             nb_trcobc       = nb_trcobc + 1  ; n_trc_indobc(jn) = nb_trcobc
[4058]169         ENDIF
170         IF( ln_trc_sbc(jn) ) THEN
[6140]171             nb_trcsbc       = nb_trcsbc + 1  ; n_trc_indsbc(jn) = nb_trcsbc
[4058]172         ENDIF
173         IF( ln_trc_cbc(jn) ) THEN
[6140]174             nb_trccbc       = nb_trccbc + 1  ; n_trc_indcbc(jn) = nb_trccbc
[4058]175         ENDIF
176      ENDDO
177
[6140]178      ! Print summmary of Boundary Conditions
179      IF( lwp ) THEN
180         WRITE(numout,*) ' '
181         WRITE(numout,'(a,i3)') '   Total tracers to be initialized with SURFACE BCs data:', nb_trcsbc
182         IF ( nb_trcsbc > 0 ) THEN
183            WRITE(numout,*) '   #trc        NAME        Boundary     Mult.Fact. '
184            DO jn = 1, ntrc
185               IF ( ln_trc_sbc(jn) ) WRITE(numout,9001) jn, TRIM( sn_trcsbc(jn)%clvar ), 'SBC', rn_trsfac(jn)
186            ENDDO
187         ENDIF
188         WRITE(numout,'(2a)') '   SURFACE BC data repository : ', TRIM(cn_dir_sbc)
[4058]189
[6140]190         WRITE(numout,*) ' '
191         WRITE(numout,'(a,i3)') '   Total tracers to be initialized with COASTAL BCs data:', nb_trccbc
[7646]192         IF( nb_trccbc > 0 ) THEN
[6140]193            WRITE(numout,*) '   #trc        NAME        Boundary     Mult.Fact. '
194            DO jn = 1, ntrc
195               IF ( ln_trc_cbc(jn) ) WRITE(numout, 9001) jn, TRIM( sn_trccbc(jn)%clvar ), 'CBC', rn_trcfac(jn)
196            ENDDO
197         ENDIF
198         WRITE(numout,'(2a)') '   COASTAL BC data repository : ', TRIM(cn_dir_cbc)
[7646]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.)' 
[6140]201         WRITE(numout,*) ' '
202         WRITE(numout,'(a,i3)') '   Total tracers to be initialized with OPEN BCs data:', nb_trcobc
[7646]203
204         IF( ln_bdy .AND. nb_trcobc > 0 ) THEN
[6140]205            WRITE(numout,*) '   #trc        NAME        Boundary     Mult.Fact.   OBC Settings'
206            DO jn = 1, ntrc
[7646]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)
[6140]209            ENDDO
210            WRITE(numout,*) ' '
211            DO ib = 1, nb_bdy
[7646]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
[6140]216                   WRITE(numout,9003) '     USE damping parameters from nambdy for boundary ', ib,' : '
217                   WRITE(numout,'(a,f10.2,a)') '     - Inflow damping time scale  : ',rn_time_dmp(ib),' days'
218                   WRITE(numout,'(a,f10.2,a)') '     - Outflow damping time scale : ',rn_time_dmp_out(ib),' days'
219                ENDIF
220            ENDDO
221         ENDIF
[7646]222
[6140]223         WRITE(numout,'(2a)') '   OPEN BC data repository : ', TRIM(cn_dir_obc)
[4058]224      ENDIF
[6140]2259001  FORMAT(2x,i5, 3x, a15, 3x, a5, 6x, e11.3, 4x, 10a13)
2269002  FORMAT(2x,i5, 3x, a41, 3x, 10a13)
2279003  FORMAT(a, i5, a)
228
[4058]229      !
230      ! OPEN Lateral boundary conditions
[7646]231      IF( ln_bdy .AND. nb_trcobc > 0 ) THEN
[6140]232         ALLOCATE ( sf_trcobc(nb_trcobc), rf_trofac(nb_trcobc), nbmap_ptr(nb_trcobc), STAT=ierr1 )
[4058]233         IF( ierr1 > 0 ) THEN
[7646]234            CALL ctl_stop( 'trc_bc_ini: unable to allocate sf_trcobc structure' )   ;   RETURN
[4058]235         ENDIF
[6140]236
237         igrd = 1                       ! Everything is at T-points here
238
[4058]239         DO jn = 1, ntrc
[6140]240            DO ib = 1, nb_bdy
241
242               nblen = idx_bdy(ib)%nblen(igrd)
243
244               IF ( ln_trc_obc(jn) ) THEN
245               ! Initialise from external data
246                  jl = n_trc_indobc(jn)
247                  slf_i(jl)    = sn_trcobc(jn)
248                  rf_trofac(jl) = rn_trofac(jn)
249                                               ALLOCATE( sf_trcobc(jl)%fnow(nblen,1,jpk)   , STAT=ierr2 )
250                  IF( sn_trcobc(jn)%ln_tint )  ALLOCATE( sf_trcobc(jl)%fdta(nblen,1,jpk,2) , STAT=ierr3 )
251                  IF( ierr2 + ierr3 > 0 ) THEN
[7646]252                    CALL ctl_stop( 'trc_bc_ini : unable to allocate passive tracer OBC data arrays' )   ;   RETURN
[6140]253                  ENDIF
254                  trcdta_bdy(jn,ib)%trc => sf_trcobc(jl)%fnow(:,1,:)
255                  trcdta_bdy(jn,ib)%rn_fac = rf_trofac(jl)
256                  ! create OBC mapping array
257                  nbmap_ptr(jl)%ptr => idx_bdy(ib)%nbmap(:,igrd)
258                  nbmap_ptr(jl)%ll_unstruc = ln_coords_file(igrd)
259               ELSE
260               ! Initialise obc arrays from initial conditions
261                  ALLOCATE ( trcdta_bdy(jn,ib)%trc(nblen,jpk) )
262                  DO ibd = 1, nblen
263                     DO ik = 1, jpkm1
264                        ii = idx_bdy(ib)%nbi(ibd,igrd)
265                        ij = idx_bdy(ib)%nbj(ibd,igrd)
266                        trcdta_bdy(jn,ib)%trc(ibd,ik) = trn(ii,ij,ik,jn) * tmask(ii,ij,ik)
267                     END DO
268                  END DO
269                  trcdta_bdy(jn,ib)%rn_fac = 1._wp
[4058]270               ENDIF
[6140]271            ENDDO
[4058]272         ENDDO
[6140]273
[7646]274         CALL fld_fill( sf_trcobc, slf_i, cn_dir_obc, 'trc_bc_ini', 'Passive tracer OBC data', 'namtrc_bc' )
[4058]275      ENDIF
[7646]276
[4058]277      ! SURFACE Boundary conditions
278      IF( nb_trcsbc > 0 ) THEN       !  allocate only if the number of tracer to initialise is greater than zero
279         ALLOCATE( sf_trcsbc(nb_trcsbc), rf_trsfac(nb_trcsbc), STAT=ierr1 )
280         IF( ierr1 > 0 ) THEN
[7646]281            CALL ctl_stop( 'trc_bc_ini: unable to allocate  sf_trcsbc structure' )   ;   RETURN
[4058]282         ENDIF
283         !
284         DO jn = 1, ntrc
285            IF( ln_trc_sbc(jn) ) THEN      ! update passive tracers arrays with input data read from file
286               jl = n_trc_indsbc(jn)
287               slf_i(jl)    = sn_trcsbc(jn)
288               rf_trsfac(jl) = rn_trsfac(jn)
289                                            ALLOCATE( sf_trcsbc(jl)%fnow(jpi,jpj,1)   , STAT=ierr2 )
290               IF( sn_trcsbc(jn)%ln_tint )  ALLOCATE( sf_trcsbc(jl)%fdta(jpi,jpj,1,2) , STAT=ierr3 )
291               IF( ierr2 + ierr3 > 0 ) THEN
[7646]292                 CALL ctl_stop( 'trc_bc_ini : unable to allocate passive tracer SBC data arrays' )   ;   RETURN
[4058]293               ENDIF
294            ENDIF
295            !   
296         ENDDO
297         !                         ! fill sf_trcsbc with slf_i and control print
[7646]298         CALL fld_fill( sf_trcsbc, slf_i, cn_dir_sbc, 'trc_bc_ini', 'Passive tracer SBC data', 'namtrc_bc' )
[4058]299         !
300      ENDIF
301      !
302      ! COSTAL Boundary conditions
303      IF( nb_trccbc > 0 ) THEN       !  allocate only if the number of tracer to initialise is greater than zero
304         ALLOCATE( sf_trccbc(nb_trccbc), rf_trcfac(nb_trccbc), STAT=ierr1 )
305         IF( ierr1 > 0 ) THEN
306            CALL ctl_stop( 'trc_bc_ini: unable to allocate  sf_trccbc structure' )   ;   RETURN
307         ENDIF
308         !
309         DO jn = 1, ntrc
310            IF( ln_trc_cbc(jn) ) THEN      ! update passive tracers arrays with input data read from file
311               jl = n_trc_indcbc(jn)
312               slf_i(jl)    = sn_trccbc(jn)
313               rf_trcfac(jl) = rn_trcfac(jn)
314                                            ALLOCATE( sf_trccbc(jl)%fnow(jpi,jpj,1)   , STAT=ierr2 )
315               IF( sn_trccbc(jn)%ln_tint )  ALLOCATE( sf_trccbc(jl)%fdta(jpi,jpj,1,2) , STAT=ierr3 )
316               IF( ierr2 + ierr3 > 0 ) THEN
317                 CALL ctl_stop( 'trc_bc_ini : unable to allocate passive tracer CBC data arrays' )   ;   RETURN
318               ENDIF
319            ENDIF
320            !   
321         ENDDO
322         !                         ! fill sf_trccbc with slf_i and control print
[7646]323         CALL fld_fill( sf_trccbc, slf_i, cn_dir_cbc, 'trc_bc_ini', 'Passive tracer CBC data', 'namtrc_bc' )
[4058]324         !
325      ENDIF
[6140]326      !
[4058]327      DEALLOCATE( slf_i )          ! deallocate local field structure
[7646]328      IF( nn_timing == 1 )  CALL timing_stop('trc_bc_ini')
[6140]329      !
[7646]330   END SUBROUTINE trc_bc_ini
[4058]331
332
[7646]333   SUBROUTINE trc_bc(kt, jit)
[4058]334      !!----------------------------------------------------------------------
[7646]335      !!                   ***  ROUTINE trc_bc  ***
[4058]336      !!
[7646]337      !! ** Purpose :  Apply Boundary Conditions data to tracers
[4058]338      !!
[7646]339      !! ** Method  :  1) Read BC inputs and update data structures using fldread
340      !!               2) Apply Boundary Conditions to tracers
[4058]341      !!             
342      !!----------------------------------------------------------------------
343      USE fldread
344     
345      !! * Arguments
[7646]346      INTEGER, INTENT( in ) ::   kt              ! ocean time-step index
[6140]347      INTEGER, INTENT( in ), OPTIONAL ::   jit   ! subcycle time-step index (for timesplitting option)
[7646]348      !!
349      INTEGER  :: ji, jj, jk, jn, jl             ! Loop index
350      REAL(wp) :: zfact, zrnf
[4058]351      !!---------------------------------------------------------------------
352      !
[7646]353      IF( nn_timing == 1 )  CALL timing_start('trc_bc')
[4058]354
[6140]355      IF( kt == nit000 .AND. lwp) THEN
356         WRITE(numout,*)
[7646]357         WRITE(numout,*) 'trc_bc : Surface boundary conditions for passive tracers.'
[6140]358         WRITE(numout,*) '~~~~~~~~~~~ '
[4058]359      ENDIF
360
[7646]361      ! 1. Update Boundary conditions data
[6140]362      IF ( PRESENT(jit) ) THEN 
[4058]363
[6140]364         ! OPEN boundary conditions (use time_offset=+1 as they are applied at the end of the step)
365         IF( nb_trcobc > 0 ) THEN
366           if (lwp) write(numout,'(a,i5,a,i10)') '   reading OBC data for ', nb_trcobc ,' variable(s) at step ', kt
367           CALL fld_read(kt=kt, kn_fsbc=1, sd=sf_trcobc, map=nbmap_ptr, kit=jit, kt_offset=+1)
368         ENDIF
369
370         ! SURFACE boundary conditions
371         IF( nb_trcsbc > 0 ) THEN
372           if (lwp) write(numout,'(a,i5,a,i10)') '   reading SBC data for ', nb_trcsbc ,' variable(s) at step ', kt
373           CALL fld_read(kt=kt, kn_fsbc=1, sd=sf_trcsbc, kit=jit)
374         ENDIF
375
376         ! COASTAL boundary conditions
377         IF( nb_trccbc > 0 ) THEN
378           if (lwp) write(numout,'(a,i5,a,i10)') '   reading CBC data for ', nb_trccbc ,' variable(s) at step ', kt
379           CALL fld_read(kt=kt, kn_fsbc=1, sd=sf_trccbc, kit=jit)
380         ENDIF
381
382      ELSE
383
384         ! OPEN boundary conditions (use time_offset=+1 as they are applied at the end of the step)
385         IF( nb_trcobc > 0 ) THEN
386           if (lwp) write(numout,'(a,i5,a,i10)') '   reading OBC data for ', nb_trcobc ,' variable(s) at step ', kt
387           CALL fld_read(kt=kt, kn_fsbc=1, sd=sf_trcobc, map=nbmap_ptr, kt_offset=+1)
388         ENDIF
389
390         ! SURFACE boundary conditions
391         IF( nb_trcsbc > 0 ) THEN
392           if (lwp) write(numout,'(a,i5,a,i10)') '   reading SBC data for ', nb_trcsbc ,' variable(s) at step ', kt
393           CALL fld_read(kt=kt, kn_fsbc=1, sd=sf_trcsbc)
394         ENDIF
395
396         ! COASTAL boundary conditions
397         IF( nb_trccbc > 0 ) THEN
398           if (lwp) write(numout,'(a,i5,a,i10)') '   reading CBC data for ', nb_trccbc ,' variable(s) at step ', kt
399           CALL fld_read(kt=kt, kn_fsbc=1, sd=sf_trccbc)
400         ENDIF
401
[4058]402      ENDIF
403
[7646]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      !                                                          ! ===========
[4058]448      !
[7646]449      IF( nn_timing == 1 )  CALL timing_stop('trc_bc')
[6140]450      !
[7646]451   END SUBROUTINE trc_bc
[4058]452
453#else
454   !!----------------------------------------------------------------------
455   !!   Dummy module                              NO 3D passive tracer data
456   !!----------------------------------------------------------------------
457CONTAINS
[6140]458
[7646]459   SUBROUTINE trc_bc_ini( ntrc )        ! Empty routine
[6140]460      INTEGER,INTENT(IN) :: ntrc                           ! number of tracers
[7646]461      WRITE(*,*) 'trc_bc_ini: You should not have seen this print! error?', kt
462   END SUBROUTINE trc_bc_ini
[6140]463
[7646]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
[4058]467#endif
468
469   !!======================================================================
470END MODULE trcbc
Note: See TracBrowser for help on using the repository browser.