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.
dynldf.F90 in branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/OPA_SRC/DYN – NEMO

source: branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf.F90

Last change on this file was 11101, checked in by frrh, 5 years ago

Merge changes from Met Office GMED ticket 450 to reduce unnecessary
text output from NEMO.
This output, which is typically not switchable, is rarely of interest
in normal (non-debugging) runs and simply redunantley consumes extra
file space.
Further, the presence of this text output has been shown to
significantly degrade performance of models which are run during
Met Office HPC RAID (disk) checks.
The new code introduces switches which are configurable via the
changes made in the associated Met Office MOCI ticket 399.

File size: 12.6 KB
Line 
1MODULE dynldf
2   !!======================================================================
3   !!                       ***  MODULE  dynldf  ***
4   !! Ocean physics:  lateral diffusivity trends
5   !!=====================================================================
6   !! History :  9.0  !  05-11  (G. Madec)  Original code (new step architecture)
7   !!----------------------------------------------------------------------
8
9   !!----------------------------------------------------------------------
10   !!   dyn_ldf      : update the dynamics trend with the lateral diffusion
11   !!   dyn_ldf_init : initialization, namelist read, and parameters control
12   !!----------------------------------------------------------------------
13   USE oce            ! ocean dynamics and tracers
14   USE dom_oce        ! ocean space and time domain
15   USE phycst         ! physical constants
16   USE ldfdyn_oce     ! ocean dynamics lateral physics
17   USE ldftra_oce     ! ocean tracers  lateral physics
18   USE ldfslp         ! lateral mixing: slopes of mixing orientation
19   USE dynldf_bilapg  ! lateral mixing            (dyn_ldf_bilapg routine)
20   USE dynldf_bilap   ! lateral mixing            (dyn_ldf_bilap  routine)
21   USE dynldf_iso     ! lateral mixing            (dyn_ldf_iso    routine)
22   USE dynldf_lap     ! lateral mixing            (dyn_ldf_lap    routine)
23   USE trd_oce        ! trends: ocean variables
24   USE trddyn         ! trend manager: dynamics   (trd_dyn        routine)
25   !
26   USE prtctl         ! Print control
27   USE in_out_manager ! I/O manager
28   USE lib_mpp        ! distribued memory computing library
29   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
30   USE wrk_nemo        ! Memory Allocation
31   USE timing          ! Timing
32
33   IMPLICIT NONE
34   PRIVATE
35
36   PUBLIC   dyn_ldf       ! called by step module
37   PUBLIC   dyn_ldf_init  ! called by opa  module
38
39   INTEGER ::   nldf = -2   ! type of lateral diffusion used defined from ln_dynldf_... namlist logicals)
40
41   !! * Substitutions
42#  include "domzgr_substitute.h90"
43#  include "vectopt_loop_substitute.h90"
44   !!----------------------------------------------------------------------
45   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
46   !! $Id$
47   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
48   !!----------------------------------------------------------------------
49CONTAINS
50
51   SUBROUTINE dyn_ldf( kt )
52      !!----------------------------------------------------------------------
53      !!                  ***  ROUTINE dyn_ldf  ***
54      !!
55      !! ** Purpose :   compute the lateral ocean dynamics physics.
56      !!----------------------------------------------------------------------
57      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
58      !
59      REAL(wp), POINTER, DIMENSION(:,:,:) ::  ztrdu, ztrdv
60      !!----------------------------------------------------------------------
61      !
62      IF( nn_timing == 1 )  CALL timing_start('dyn_ldf')
63      !
64      IF( l_trddyn )   THEN                      ! temporary save of ta and sa trends
65         CALL wrk_alloc( jpi, jpj, jpk, ztrdu, ztrdv )
66         ztrdu(:,:,:) = ua(:,:,:) 
67         ztrdv(:,:,:) = va(:,:,:) 
68      ENDIF
69
70      SELECT CASE ( nldf )                       ! compute lateral mixing trend and add it to the general trend
71      !
72      CASE ( 0 )    ;   CALL dyn_ldf_lap    ( kt )      ! iso-level laplacian
73      CASE ( 1 )    ;   CALL dyn_ldf_iso    ( kt )      ! rotated laplacian (except dk[ dk[.] ] part)
74      CASE ( 2 )    ;   CALL dyn_ldf_bilap  ( kt )      ! iso-level bilaplacian
75      CASE ( 3 )    ;   CALL dyn_ldf_bilapg ( kt )      ! s-coord. horizontal bilaplacian
76      CASE ( 4 )                                        ! iso-level laplacian + bilaplacian
77         CALL dyn_ldf_lap    ( kt )
78         CALL dyn_ldf_bilap  ( kt )
79      CASE ( 5 )                                        ! rotated laplacian + bilaplacian (s-coord)
80         CALL dyn_ldf_iso    ( kt )
81         CALL dyn_ldf_bilapg ( kt )
82      !
83      CASE ( -1 )                                       ! esopa: test all possibility with control print
84                        CALL dyn_ldf_lap    ( kt )
85                        CALL prt_ctl( tab3d_1=ua, clinfo1=' ldf0 - Ua: ', mask1=umask,   &
86            &                         tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
87                        CALL dyn_ldf_iso    ( kt )
88                        CALL prt_ctl( tab3d_1=ua, clinfo1=' ldf1 - Ua: ', mask1=umask,   &
89            &                         tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
90                        CALL dyn_ldf_bilap  ( kt )
91                        CALL prt_ctl( tab3d_1=ua, clinfo1=' ldf2 - Ua: ', mask1=umask,   &
92            &                         tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
93                        CALL dyn_ldf_bilapg ( kt )
94                        CALL prt_ctl( tab3d_1=ua, clinfo1=' ldf3 - Ua: ', mask1=umask,   &
95            &                         tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
96      !
97      CASE ( -2 )                                       ! neither laplacian nor bilaplacian schemes used
98         IF( kt == nit000 ) THEN
99            IF(lwp) WRITE(numout,*)
100            IF(lwp) WRITE(numout,*) 'dyn_ldf : no lateral diffusion on momentum setup'
101            IF(lwp) WRITE(numout,*) '~~~~~~~ '
102            IF(lflush) CALL flush(numout)
103         ENDIF
104      END SELECT
105
106      IF( l_trddyn ) THEN                        ! save the horizontal diffusive trends for further diagnostics
107         ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
108         ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
109         CALL trd_dyn( ztrdu, ztrdv, jpdyn_ldf, kt )
110         CALL wrk_dealloc( jpi, jpj, jpk, ztrdu, ztrdv )
111      ENDIF
112      !                                          ! print sum trends (used for debugging)
113      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' ldf  - Ua: ', mask1=umask,   &
114         &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
115      !
116      IF( nn_timing == 1 )  CALL timing_stop('dyn_ldf')
117      !
118   END SUBROUTINE dyn_ldf
119
120
121   SUBROUTINE dyn_ldf_init
122      !!----------------------------------------------------------------------
123      !!                  ***  ROUTINE dyn_ldf_init  ***
124      !!
125      !! ** Purpose :   initializations of the horizontal ocean dynamics physics
126      !!----------------------------------------------------------------------
127      INTEGER ::   ioptio, ierr         ! temporary integers
128      !!----------------------------------------------------------------------
129   
130      !                                   ! Namelist nam_dynldf: already read in ldfdyn module
131
132      IF(lwp) THEN                        ! Namelist print
133         WRITE(numout,*)
134         WRITE(numout,*) 'dyn_ldf_init : Choice of the lateral diffusive operator on dynamics'
135         WRITE(numout,*) '~~~~~~~~~~~'
136         WRITE(numout,*) '       Namelist nam_dynldf : set lateral mixing parameters (type, direction, coefficients)'
137         WRITE(numout,*) '          laplacian operator          ln_dynldf_lap   = ', ln_dynldf_lap
138         WRITE(numout,*) '          bilaplacian operator        ln_dynldf_bilap = ', ln_dynldf_bilap
139         WRITE(numout,*) '          iso-level                   ln_dynldf_level = ', ln_dynldf_level
140         WRITE(numout,*) '          horizontal (geopotential)   ln_dynldf_hor   = ', ln_dynldf_hor
141         WRITE(numout,*) '          iso-neutral                 ln_dynldf_iso   = ', ln_dynldf_iso
142         IF(lflush) CALL flush(numout)
143      ENDIF
144
145      !                                   ! control the consistency
146      ioptio = 0
147      IF( ln_dynldf_lap   )   ioptio = ioptio + 1
148      IF( ln_dynldf_bilap )   ioptio = ioptio + 1
149      IF( ioptio <  1 ) CALL ctl_warn( '          neither laplacian nor bilaplacian operator set for dynamics' )
150      ioptio = 0
151      IF( ln_dynldf_level )   ioptio = ioptio + 1
152      IF( ln_dynldf_hor   )   ioptio = ioptio + 1
153      IF( ln_dynldf_iso   )   ioptio = ioptio + 1
154      IF( ioptio >  1 ) CALL ctl_stop( '          use only ONE direction (level/hor/iso)' )
155
156      IF( ln_dynldf_iso .AND. ln_traldf_hor ) CALL ctl_stop &
157      &   ( 'Not sensible to use geopotential diffusion for tracers with isoneutral diffusion for dynamics' )
158
159      !                                   ! Set nldf, the type of lateral diffusion, from ln_dynldf_... logicals
160      ierr = 0
161      IF ( ln_dynldf_lap ) THEN      ! laplacian operator
162         IF ( ln_zco ) THEN                ! z-coordinate
163            IF ( ln_dynldf_level )   nldf = 0      ! iso-level  (no rotation)
164            IF ( ln_dynldf_hor   )   nldf = 0      ! horizontal (no rotation)
165            IF ( ln_dynldf_iso   )   nldf = 1      ! isoneutral (   rotation)
166         ENDIF
167         IF ( ln_zps ) THEN             ! z-coordinate
168            IF ( ln_dynldf_level )   ierr = 1      ! iso-level not allowed
169            IF ( ln_dynldf_hor   )   nldf = 0      ! horizontal (no rotation)
170            IF ( ln_dynldf_iso   )   nldf = 1      ! isoneutral (   rotation)
171         ENDIF
172         IF ( ln_sco ) THEN             ! s-coordinate
173            IF ( ln_dynldf_level )   nldf = 0      ! iso-level  (no rotation)
174            IF ( ln_dynldf_hor   )   nldf = 1      ! horizontal (   rotation)
175            IF ( ln_dynldf_iso   )   nldf = 1      ! isoneutral (   rotation)
176         ENDIF
177      ENDIF
178
179      IF( ln_dynldf_bilap ) THEN      ! bilaplacian operator
180         IF ( ln_zco ) THEN                ! z-coordinate
181            IF ( ln_dynldf_level )   nldf = 2      ! iso-level  (no rotation)
182            IF ( ln_dynldf_hor   )   nldf = 2      ! horizontal (no rotation)
183            IF ( ln_dynldf_iso   )   ierr = 2      ! isoneutral (   rotation)
184         ENDIF
185         IF ( ln_zps ) THEN             ! z-coordinate
186            IF ( ln_dynldf_level )   ierr = 1      ! iso-level not allowed
187            IF ( ln_dynldf_hor   )   nldf = 2      ! horizontal (no rotation)
188            IF ( ln_dynldf_iso   )   ierr = 2      ! isoneutral (   rotation)
189         ENDIF
190         IF ( ln_sco ) THEN             ! s-coordinate
191            IF ( ln_dynldf_level )   nldf = 2      ! iso-level  (no rotation)
192            IF ( ln_dynldf_hor   )   nldf = 3      ! horizontal (   rotation)
193            IF ( ln_dynldf_iso   )   ierr = 2      ! isoneutral (   rotation)
194         ENDIF
195      ENDIF
196     
197      IF( ln_dynldf_lap .AND. ln_dynldf_bilap ) THEN  ! mixed laplacian and bilaplacian operators
198         IF ( ln_zco ) THEN                ! z-coordinate
199            IF ( ln_dynldf_level )   nldf = 4      ! iso-level  (no rotation)
200            IF ( ln_dynldf_hor   )   nldf = 4      ! horizontal (no rotation)
201            IF ( ln_dynldf_iso   )   ierr = 2      ! isoneutral (   rotation)
202         ENDIF
203         IF ( ln_zps ) THEN             ! z-coordinate
204            IF ( ln_dynldf_level )   ierr = 1      ! iso-level not allowed
205            IF ( ln_dynldf_hor   )   nldf = 4      ! horizontal (no rotation)
206            IF ( ln_dynldf_iso   )   ierr = 2      ! isoneutral (   rotation)
207         ENDIF
208         IF ( ln_sco ) THEN             ! s-coordinate
209            IF ( ln_dynldf_level )   nldf = 4      ! iso-level  (no rotation)
210            IF ( ln_dynldf_hor   )   nldf = 5      ! horizontal (   rotation)
211            IF ( ln_dynldf_iso   )   ierr = 2      ! isoneutral (   rotation)
212         ENDIF
213      ENDIF
214
215      IF( lk_esopa )                 nldf = -1     ! esopa test
216
217      IF( ierr == 1 )   CALL ctl_stop( 'iso-level in z-coordinate - partial step, not allowed' )
218      IF( ierr == 2 )   CALL ctl_stop( 'isoneutral bilaplacian operator does not exist' )
219      IF( nldf == 1 .OR. nldf == 3 ) THEN      ! rotation
220         IF( .NOT.lk_ldfslp )   CALL ctl_stop( 'the rotation of the diffusive tensor require key_ldfslp' )
221      ENDIF
222
223      IF(lwp) THEN
224         WRITE(numout,*)
225         IF( nldf == -2 )   WRITE(numout,*) '              neither laplacian nor bilaplacian schemes used'
226         IF( nldf == -1 )   WRITE(numout,*) '              ESOPA test All scheme used'
227         IF( nldf ==  0 )   WRITE(numout,*) '              laplacian operator'
228         IF( nldf ==  1 )   WRITE(numout,*) '              rotated laplacian operator'
229         IF( nldf ==  2 )   WRITE(numout,*) '              bilaplacian operator'
230         IF( nldf ==  3 )   WRITE(numout,*) '              rotated bilaplacian'
231         IF( nldf ==  4 )   WRITE(numout,*) '              laplacian and bilaplacian operators'
232         IF( nldf ==  5 )   WRITE(numout,*) '              rotated laplacian and bilaplacian operators'
233         IF(lflush) CALL flush(numout)
234      ENDIF
235      !
236   END SUBROUTINE dyn_ldf_init
237
238   !!======================================================================
239END MODULE dynldf
Note: See TracBrowser for help on using the repository browser.