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.
trcbdy.F90 in branches/2016/dev_r6522_SIMPLIF_3/NEMOGCM/NEMO/TOP_SRC – NEMO

source: branches/2016/dev_r6522_SIMPLIF_3/NEMOGCM/NEMO/TOP_SRC/trcbdy.F90 @ 7058

Last change on this file since 7058 was 7058, checked in by lovato, 8 years ago

#1783 - trunk: Generalize the open boundary schemes and revise TRA and TRC BDY wrappers

File size: 6.4 KB
Line 
1MODULE trcbdy
2   !!======================================================================
3   !!                       ***  MODULE  bdytrc  ***
4   !! Ocean tracers:   Apply boundary conditions for tracers in TOP component
5   !!======================================================================
6   !! History :  1.0  !  2005-01  (J. Chanut, A. Sellar)  Original code
7   !!            3.0  !  2008-04  (NEMO team)  add in the reference version
8   !!            3.4  !  2011     (D. Storkey) rewrite in preparation for OBC-BDY merge
9   !!            3.5  !  2012     (S. Mocavero, I. Epicoco) Optimization of BDY communications
10   !!            3.6  !  2015     (T. Lovato) Adapt BDY for tracers in TOP component
11   !!            4.0  !  2016     (T. Lovato) Generalize OBC structure
12   !!----------------------------------------------------------------------
13#if defined key_top
14   !!----------------------------------------------------------------------
15   !!   trc_bdy       : Apply open boundary conditions & damping to tracers
16   !!----------------------------------------------------------------------
17   USE timing                       ! Timing
18   USE oce_trc                      ! ocean dynamics and tracers variables
19   USE par_trc
20   USE trc                          ! ocean space and time domain variables
21   USE bdylib                       ! for orlanski library routines
22   USE lbclnk                       ! ocean lateral boundary conditions (or mpp link)
23   USE in_out_manager               ! I/O manager
24   USE bdy_oce, only: idx_bdy       ! ocean open boundary conditions
25
26   IMPLICIT NONE
27   PRIVATE
28
29   ! Local structure to rearrange tracers data
30   TYPE, PUBLIC ::   ztrcbdy
31      REAL(wp), POINTER, DIMENSION(:,:) ::  trc
32      REAL(wp), POINTER                 ::  fac
33   END TYPE
34
35   PUBLIC trc_bdy      ! routine called in trcnxt.F90
36   PUBLIC trc_bdy_dmp  ! routine called in trcstp.F90
37
38   !!----------------------------------------------------------------------
39   !! NEMO/OPA 4.0 , NEMO Consortium (2016)
40   !! $Id$
41   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
42   !!----------------------------------------------------------------------
43CONTAINS
44
45   SUBROUTINE trc_bdy( kt )
46      !!----------------------------------------------------------------------
47      !!                  ***  SUBROUTINE trc_bdy  ***
48      !!
49      !! ** Purpose : - Apply open boundary conditions for TOP tracers
50      !!
51      !!----------------------------------------------------------------------
52      INTEGER, INTENT( in ) :: kt     ! Main time step counter
53      !!
54      INTEGER               :: ib_bdy, jn ! Loop indeces
55      TYPE(ztrcbdy)         :: zdta       ! Temporary data structure
56      !!----------------------------------------------------------------------
57      !
58      IF( nn_timing == 1 ) CALL timing_start('trc_bdy')
59      !
60      DO ib_bdy=1, nb_bdy
61         DO jn = 1, jptra
62            !
63            zdta%trc => trcdta_bdy(jn,ib_bdy)%trc 
64            zdta%fac => trcdta_bdy(jn,ib_bdy)%rn_fac
65            !
66            SELECT CASE( TRIM(trcdta_bdy(jn,ib_bdy)%cn_obc) )
67            CASE('none'        )   ;   CYCLE
68            CASE('frs'         )   ;   CALL bdy_frs( idx_bdy(ib_bdy),                tra(:,:,:,jn), zdta%trc*zdta%fac )
69            CASE('specified'   )   ;   CALL bdy_spe( idx_bdy(ib_bdy),                tra(:,:,:,jn), zdta%trc*zdta%fac )
70            CASE('neumann'     )   ;   CALL bdy_nmn( idx_bdy(ib_bdy),                tra(:,:,:,jn) )
71            CASE('orlanski'    )   ;   CALL bdy_orl( idx_bdy(ib_bdy), trb(:,:,:,jn), tra(:,:,:,jn), zdta%trc*zdta%fac, ll_npo=.false. )
72            CASE('orlanski_npo')   ;   CALL bdy_orl( idx_bdy(ib_bdy), trb(:,:,:,jn), tra(:,:,:,jn), zdta%trc*zdta%fac, ll_npo=.true. )
73            CASE DEFAULT           ;   CALL ctl_stop( 'trc_bdy : unrecognised option for open boundaries for passive tracers' )
74            END SELECT
75            ! Boundary points should be updated
76            CALL lbc_bdy_lnk( tra(:,:,:,jn), 'T', 1., ib_bdy )
77            !
78         END DO
79      END DO
80      !
81      IF( nn_timing == 1 ) CALL timing_stop('trc_bdy')
82
83   END SUBROUTINE trc_bdy
84
85   SUBROUTINE trc_bdy_dmp( kt )
86      !!----------------------------------------------------------------------
87      !!                 ***  SUBROUTINE trc_bdy_dmp  ***
88      !!                   
89      !! ** Purpose : Apply damping for tracers at open boundaries.
90      !!             It currently applies the damping to all tracers!!!
91      !!
92      !!----------------------------------------------------------------------
93      INTEGER,         INTENT(in) ::   kt
94      !!
95      INTEGER  ::   jn             ! Tracer index
96      REAL(wp) ::   zwgt           ! boundary weight
97      REAL(wp) ::   zta, zsa, ztime
98      INTEGER  ::   ib, ik, igrd   ! dummy loop indices
99      INTEGER  ::   ii, ij         ! 2D addresses
100      INTEGER  ::   ib_bdy         ! Loop index
101      !!----------------------------------------------------------------------
102      !
103      IF( nn_timing == 1 ) CALL timing_start('trc_bdy_dmp')
104      !
105      DO jn = 1, jptra
106         DO ib_bdy=1, nb_bdy
107            IF ( trcdta_bdy(jn, ib_bdy)%dmp ) THEN
108               igrd = 1                       ! Everything is at T-points here
109               DO ib = 1, idx_bdy(ib_bdy)%nblen(igrd)
110                  ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
111                  ij = idx_bdy(ib_bdy)%nbj(ib,igrd)
112                  zwgt = idx_bdy(ib_bdy)%nbd(ib,igrd)
113                  DO ik = 1, jpkm1
114                     zta = zwgt * ( trcdta_bdy(jn, ib_bdy)%trc(ib,ik) - trb(ii,ij,ik,jn) ) * tmask(ii,ij,ik)
115                     tra(ii,ij,ik,jn) = tra(ii,ij,ik,jn) + zta
116                  END DO
117               END DO
118            ENDIF
119         ENDDO
120      ENDDO
121      !
122      IF( nn_timing == 1 ) CALL timing_stop('trc_bdy_dmp')
123      !
124   END SUBROUTINE trc_bdy_dmp
125 
126#else
127   !!----------------------------------------------------------------------
128   !!   Dummy module                   NO Unstruct Open Boundary Conditions
129   !!----------------------------------------------------------------------
130CONTAINS
131   SUBROUTINE trc_bdy(kt)      ! Empty routine
132      WRITE(*,*) 'trc_bdy: You should not have seen this print! error?', kt
133   END SUBROUTINE trc_bdy
134
135   SUBROUTINE trc_bdy_dmp(kt)      ! Empty routine
136      WRITE(*,*) 'trc_bdy_dmp: You should not have seen this print! error?', kt
137   END SUBROUTINE trc_bdy_dmp
138
139#endif
140
141   !!======================================================================
142END MODULE trcbdy
Note: See TracBrowser for help on using the repository browser.