source: branches/2013/dev_r3858_NOC_ZTC/NEMOGCM/NEMO/OPA_SRC/BDY/bdydyn.F90 @ 4105

Last change on this file since 4105 was 4105, checked in by acc, 8 years ago

Branch 2013/dev_r3858_NOC_ZTC, #863. Port across time-stepping changes from dev_r3867_MERCATOR1_DYN branch. Part 1: modules totally independent of ztilde changes (chiefly BDY stuff).

  • Property svn:keywords set to Id
File size: 6.0 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          ! variable volume
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,igrd     ! Loop counter
60      LOGICAL               :: ll_dyn2d, ll_dyn3d 
61      !!
62
63      IF( nn_timing == 1 ) CALL timing_start('bdy_dyn')
64
65      ll_dyn2d = .true.
66      ll_dyn3d = .true.
67
68      IF( PRESENT(dyn3d_only) ) THEN
69         IF( dyn3d_only ) ll_dyn2d = .false.
70      ENDIF
71
72      !-------------------------------------------------------
73      ! Set pointers
74      !-------------------------------------------------------
75
76      pssh => sshn
77      phur => hur
78      phvr => hvr
79      CALL wrk_alloc(jpi,jpj,pu2d,pv2d) 
80
81      !-------------------------------------------------------
82      ! Split velocities into barotropic and baroclinic parts
83      !-------------------------------------------------------
84
85      pu2d(:,:) = 0._wp
86      pv2d(:,:) = 0._wp
87      ! bg jchanut tschanges (not specifically related to ts; this is a bug)
88      IF (lk_vvl) THEN
89         DO jk = 1, jpkm1   !! Vertically integrated momentum trends
90            pu2d(:,:) = pu2d(:,:) + fse3u_a(:,:,jk) * umask(:,:,jk) * ua(:,:,jk)
91            pv2d(:,:) = pv2d(:,:) + fse3v_a(:,:,jk) * vmask(:,:,jk) * va(:,:,jk)
92         END DO
93         pu2d(:,:) = pu2d(:,:) / ( hu_0(:,:) + sshu_a(:,:) + 1._wp - umask(:,:,1) )
94         pv2d(:,:) = pv2d(:,:) / ( hv_0(:,:) + sshv_a(:,:) + 1._wp - vmask(:,:,1) )
95      ! end jchanut tschanges
96      ELSE
97         DO jk = 1, jpkm1   !! Vertically integrated momentum trends
98            pu2d(:,:) = pu2d(:,:) + fse3u(:,:,jk) * umask(:,:,jk) * ua(:,:,jk)
99            pv2d(:,:) = pv2d(:,:) + fse3v(:,:,jk) * vmask(:,:,jk) * va(:,:,jk)
100         END DO
101         pu2d(:,:) = pu2d(:,:) * phur(:,:)
102         pv2d(:,:) = pv2d(:,:) * phvr(:,:)
103      ENDIF
104
105      DO jk = 1 , jpkm1
106         ua(:,:,jk) = ua(:,:,jk) - pu2d(:,:) * umask(:,:,jk)
107         va(:,:,jk) = va(:,:,jk) - pv2d(:,:) * vmask(:,:,jk)
108      END DO
109
110      !-------------------------------------------------------
111      ! Apply boundary conditions to barotropic and baroclinic
112      ! parts separately
113      !-------------------------------------------------------
114
115      IF( ll_dyn2d ) CALL bdy_dyn2d( kt )
116
117      IF( ll_dyn3d ) CALL bdy_dyn3d( kt )
118
119      !-------------------------------------------------------
120      ! Recombine velocities
121      !-------------------------------------------------------
122
123      DO jk = 1 , jpkm1
124         ua(:,:,jk) = ( ua(:,:,jk) + pu2d(:,:) ) * umask(:,:,jk)
125         va(:,:,jk) = ( va(:,:,jk) + pv2d(:,:) ) * vmask(:,:,jk)
126      END DO
127
128      CALL wrk_dealloc(jpi,jpj,pu2d,pv2d) 
129
130      IF( nn_timing == 1 ) CALL timing_stop('bdy_dyn')
131
132   END SUBROUTINE bdy_dyn
133
134#else
135   !!----------------------------------------------------------------------
136   !!   Dummy module                   NO Unstruct Open Boundary Conditions
137   !!----------------------------------------------------------------------
138CONTAINS
139   SUBROUTINE bdy_dyn( kt )      ! Empty routine
140      WRITE(*,*) 'bdy_dyn: You should not have seen this print! error?', kt
141   END SUBROUTINE bdy_dyn
142#endif
143
144   !!======================================================================
145END MODULE bdydyn
Note: See TracBrowser for help on using the repository browser.