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.
bdydyn.F90 in branches/2013/dev_MERGE_2013/NEMOGCM/NEMO/OPA_SRC/BDY – NEMO

source: branches/2013/dev_MERGE_2013/NEMOGCM/NEMO/OPA_SRC/BDY/bdydyn.F90 @ 4354

Last change on this file since 4354 was 4354, checked in by jchanut, 10 years ago

Restore AGRIF and BDY compatibility, see ticket #1133

  • Property svn:keywords set to Id
File size: 7.1 KB
Line 
1MODULE bdydyn
2   !!======================================================================
3   !!                       ***  MODULE  bdydyn  ***
4   !! Unstructured Open Boundary Cond. :   Apply boundary conditions to velocities
5   !!======================================================================
6   !! History :  1.0  !  2005-02  (J. Chanut, A. Sellar)  Original code
7   !!             -   !  2007-07  (D. Storkey) Move Flather implementation to separate routine.
8   !!            3.0  !  2008-04  (NEMO team)  add in the reference version
9   !!            3.2  !  2008-04  (R. Benshila) consider velocity instead of transport
10   !!            3.3  !  2010-09  (E.O'Dea) modifications for Shelf configurations
11   !!            3.3  !  2010-09  (D.Storkey) add ice boundary conditions
12   !!            3.4  !  2011     (D. Storkey) rewrite in preparation for OBC-BDY merge
13   !!----------------------------------------------------------------------
14#if defined key_bdy 
15   !!----------------------------------------------------------------------
16   !!   'key_bdy' :                    Unstructured Open Boundary Condition
17   !!----------------------------------------------------------------------
18   !!   bdy_dyn        : split velocities into barotropic and baroclinic parts
19   !!                    and call bdy_dyn2d and bdy_dyn3d to apply boundary
20   !!                    conditions
21   !!----------------------------------------------------------------------
22   USE wrk_nemo        ! Memory Allocation
23   USE timing          ! Timing
24   USE oce             ! ocean dynamics and tracers
25   USE dom_oce         ! ocean space and time domain
26   USE dynspg_oce     
27   USE bdy_oce         ! ocean open boundary conditions
28   USE bdydyn2d        ! open boundary conditions for barotropic solution
29   USE bdydyn3d        ! open boundary conditions for baroclinic velocities
30   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
31   USE in_out_manager  !
32   USE domvvl
33
34   IMPLICIT NONE
35   PRIVATE
36
37   PUBLIC   bdy_dyn     ! routine called in dynspg_flt (if lk_dynspg_flt) or
38                        ! dyn_nxt (if lk_dynspg_ts or lk_dynspg_exp)
39
40#  include "domzgr_substitute.h90"
41   !!----------------------------------------------------------------------
42   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
43   !! $Id$
44   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
45   !!----------------------------------------------------------------------
46CONTAINS
47
48   SUBROUTINE bdy_dyn( kt, dyn3d_only )
49      !!----------------------------------------------------------------------
50      !!                  ***  SUBROUTINE bdy_dyn  ***
51      !!
52      !! ** Purpose : - Wrapper routine for bdy_dyn2d and bdy_dyn3d.
53      !!
54      !!----------------------------------------------------------------------
55      !!
56      INTEGER, INTENT( in )           :: kt               ! Main time step counter
57      LOGICAL, INTENT( in ), OPTIONAL :: dyn3d_only       ! T => only update baroclinic velocities
58      !!
59      INTEGER               :: jk,ii,ij,ib_bdy,ib,igrd     ! Loop counter
60      LOGICAL               :: ll_dyn2d, ll_dyn3d, ll_orlanski
61      !!
62      REAL(wp), POINTER, DIMENSION(:,:) :: pua2d, pva2d     ! after barotropic velocities
63      REAL(wp), POINTER, DIMENSION(:,:) :: phura, phvra     ! after inverse depth at u and v points
64
65      IF( nn_timing == 1 ) CALL timing_start('bdy_dyn')
66
67      ll_dyn2d = .true.
68      ll_dyn3d = .true.
69
70      IF( PRESENT(dyn3d_only) ) THEN
71         IF( dyn3d_only ) ll_dyn2d = .false.
72      ENDIF
73
74      ll_orlanski = .false.
75      DO ib_bdy = 1, nb_bdy
76         IF ( cn_dyn2d(ib_bdy) == 'orlanski' .or. cn_dyn2d(ib_bdy) == 'orlanski_npo' &
77     &   .or. cn_dyn3d(ib_bdy) == 'orlanski' .or. cn_dyn3d(ib_bdy) == 'orlanski_npo') ll_orlanski = .true.
78      ENDDO
79
80      !-------------------------------------------------------
81      ! Set pointers
82      !-------------------------------------------------------
83
84      CALL wrk_alloc(jpi,jpj,pua2d,pva2d,phura,phvra) 
85
86      !-------------------------------------------------------
87      ! Split velocities into barotropic and baroclinic parts
88      !-------------------------------------------------------
89
90      ! "After" velocities:
91
92      pua2d(:,:) = 0.e0
93      pva2d(:,:) = 0.e0
94     
95      IF (lk_vvl) THEN
96         phura(:,:) = 0.
97         phvra(:,:) = 0.
98         DO jk = 1, jpkm1
99            phura(:,:) = phura(:,:) + fse3u_a(:,:,jk) * umask(:,:,jk)
100            phvra(:,:) = phvra(:,:) + fse3v_a(:,:,jk) * vmask(:,:,jk)
101            pua2d(:,:) = pua2d(:,:) + fse3u_a(:,:,jk) * umask(:,:,jk) * ua(:,:,jk)
102            pva2d(:,:) = pva2d(:,:) + fse3v_a(:,:,jk) * vmask(:,:,jk) * va(:,:,jk)
103         END DO
104         phura(:,:) = umask(:,:,1) / ( phura(:,:) + 1. - umask(:,:,1) )
105         phvra(:,:) = vmask(:,:,1) / ( phvra(:,:) + 1. - vmask(:,:,1) )
106      ELSE
107         phura(:,:) = hur(:,:)
108         phvra(:,:) = hvr(:,:)
109         DO jk = 1, jpkm1
110            pua2d(:,:) = pua2d(:,:) + fse3u(:,:,jk) * umask(:,:,jk) * ua(:,:,jk)
111            pva2d(:,:) = pva2d(:,:) + fse3v(:,:,jk) * vmask(:,:,jk) * va(:,:,jk)
112         END DO
113      ENDIF
114      pua2d(:,:) = pua2d(:,:) * phura(:,:)
115      pva2d(:,:) = pva2d(:,:) * phvra(:,:)
116
117      DO jk = 1 , jpkm1
118         ua(:,:,jk) = (ua(:,:,jk) - pua2d(:,:)) * umask(:,:,jk)
119         va(:,:,jk) = (va(:,:,jk) - pva2d(:,:)) * vmask(:,:,jk)
120      END DO
121
122      ! "Before" velocities (required for Orlanski condition):
123
124      IF ( ll_orlanski ) THEN         
125         DO jk = 1 , jpkm1
126            ub(:,:,jk) = (ub(:,:,jk) - ub_b(:,:)) * umask(:,:,jk)
127            vb(:,:,jk) = (vb(:,:,jk) - vb_b(:,:)) * vmask(:,:,jk)
128         END DO
129      END IF
130
131      !-------------------------------------------------------
132      ! Apply boundary conditions to barotropic and baroclinic
133      ! parts separately
134      !-------------------------------------------------------
135
136      IF( ll_dyn2d ) CALL bdy_dyn2d( kt, pua2d, pva2d, ub_b, vb_b, phura, phvra, ssha )
137
138      IF( ll_dyn3d ) CALL bdy_dyn3d( kt )
139
140      !-------------------------------------------------------
141      ! Recombine velocities
142      !-------------------------------------------------------
143
144      DO jk = 1 , jpkm1
145         ua(:,:,jk) = ( ua(:,:,jk) + pua2d(:,:) ) * umask(:,:,jk)
146         va(:,:,jk) = ( va(:,:,jk) + pva2d(:,:) ) * vmask(:,:,jk)
147      END DO
148
149      IF ( ll_orlanski ) THEN
150         DO jk = 1 , jpkm1
151            ub(:,:,jk) = ( ub(:,:,jk) + ub_b(:,:) ) * umask(:,:,jk)
152            vb(:,:,jk) = ( vb(:,:,jk) + vb_b(:,:) ) * vmask(:,:,jk)
153         END DO
154      END IF
155
156      CALL wrk_dealloc(jpi,jpj,pua2d,pva2d,phura,phvra) 
157
158      IF( nn_timing == 1 ) CALL timing_stop('bdy_dyn')
159
160   END SUBROUTINE bdy_dyn
161
162#else
163   !!----------------------------------------------------------------------
164   !!   Dummy module                   NO Unstruct Open Boundary Conditions
165   !!----------------------------------------------------------------------
166CONTAINS
167   SUBROUTINE bdy_dyn( kt )      ! Empty routine
168      WRITE(*,*) 'bdy_dyn: You should not have seen this print! error?', kt
169   END SUBROUTINE bdy_dyn
170#endif
171
172   !!======================================================================
173END MODULE bdydyn
Note: See TracBrowser for help on using the repository browser.