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.
domqco.F90 in NEMO/trunk/src/OCE/DOM – NEMO

source: NEMO/trunk/src/OCE/DOM/domqco.F90 @ 13970

Last change on this file since 13970 was 13970, checked in by andmirek, 3 years ago

Ticket #2462 into the trunk

File size: 18.8 KB
Line 
1MODULE domqco
2   !!======================================================================
3   !!                       ***  MODULE domqco   ***
4   !! Ocean :
5   !!======================================================================
6   !! History :  2.0  !  2006-06  (B. Levier, L. Marie)  original code
7   !!            3.1  !  2009-02  (G. Madec, M. Leclair, R. Benshila)  pure z* coordinate
8   !!            3.3  !  2011-10  (M. Leclair) totally rewrote domvvl: vvl option includes z_star and z_tilde coordinates
9   !!            3.6  !  2014-11  (P. Mathiot) add ice shelf capability
10   !!            4.1  !  2019-08  (A. Coward, D. Storkey) rename dom_vvl_sf_swp -> dom_vvl_sf_update for new timestepping
11   !!            4.x  !  2020-02  (G. Madec, S. Techene) pure z* (quasi-eulerian) coordinate
12   !!----------------------------------------------------------------------
13
14   !!----------------------------------------------------------------------
15   !!   dom_qe_init   : define initial vertical scale factors, depths and column thickness
16   !!   dom_qe_r3c    : Compute ssh/h_0 ratioat t-, u-, v-, and optionally f-points
17   !!       qe_rst_read : read/write restart file
18   !!   dom_qe_ctl    : Check the vvl options
19   !!----------------------------------------------------------------------
20   USE oce            ! ocean dynamics and tracers
21   USE phycst         ! physical constant
22   USE dom_oce        ! ocean space and time domain
23   USE dynadv  , ONLY : ln_dynadv_vec
24   USE isf_oce        ! iceshelf cavities
25   USE sbc_oce        ! ocean surface boundary condition
26   USE wet_dry        ! wetting and drying
27   USE usrdef_istate  ! user defined initial state (wad only)
28   USE restart        ! ocean restart
29   !
30   USE in_out_manager ! I/O manager
31   USE iom            ! I/O manager library
32   USE lib_mpp        ! distributed memory computing library
33   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
34   USE timing         ! Timing
35
36   IMPLICIT NONE
37   PRIVATE
38
39   PUBLIC  dom_qco_init       ! called by domain.F90
40   PUBLIC  dom_qco_zgr        ! called by isfcpl.F90
41   PUBLIC  dom_qco_r3c        ! called by steplf.F90
42
43   !                                                      !!* Namelist nam_vvl
44   LOGICAL , PUBLIC :: ln_vvl_zstar           = .FALSE.    ! zstar  vertical coordinate
45   LOGICAL , PUBLIC :: ln_vvl_ztilde          = .FALSE.    ! ztilde vertical coordinate
46   LOGICAL , PUBLIC :: ln_vvl_layer           = .FALSE.    ! level  vertical coordinate
47   LOGICAL , PUBLIC :: ln_vvl_ztilde_as_zstar = .FALSE.    ! ztilde vertical coordinate
48   LOGICAL , PUBLIC :: ln_vvl_zstar_at_eqtor  = .FALSE.    ! ztilde vertical coordinate
49   LOGICAL , PUBLIC :: ln_vvl_kepe            = .FALSE.    ! kinetic/potential energy transfer
50   !                                                       ! conservation: not used yet
51   REAL(wp)         :: rn_ahe3                             ! thickness diffusion coefficient
52   REAL(wp)         :: rn_rst_e3t                          ! ztilde to zstar restoration timescale [days]
53   REAL(wp)         :: rn_lf_cutoff                        ! cutoff frequency for low-pass filter  [days]
54   REAL(wp)         :: rn_zdef_max                         ! maximum fractional e3t deformation
55   LOGICAL , PUBLIC :: ln_vvl_dbg = .FALSE.                ! debug control prints
56
57   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: un_td, vn_td                ! thickness diffusion transport
58
59   !! * Substitutions
60#  include "do_loop_substitute.h90"
61   !!----------------------------------------------------------------------
62   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
63   !! $Id: domvvl.F90 12377 2020-02-12 14:39:06Z acc $
64   !! Software governed by the CeCILL license (see ./LICENSE)
65   !!----------------------------------------------------------------------
66CONTAINS
67
68   SUBROUTINE dom_qco_init( Kbb, Kmm, Kaa )
69      !!----------------------------------------------------------------------
70      !!                ***  ROUTINE dom_qco_init  ***
71      !!
72      !! ** Purpose :  Initialization of all ssh. to h._0 ratio
73      !!
74      !! ** Method  :  - use restart file and/or initialize
75      !!               - compute ssh. to h._0 ratio
76      !!
77      !! ** Action  : - r3(t/u/v)_b
78      !!              - r3(t/u/v/f)_n
79      !!
80      !!----------------------------------------------------------------------
81      INTEGER, INTENT(in) :: Kbb, Kmm, Kaa
82      !
83      IF(lwp) WRITE(numout,*)
84      IF(lwp) WRITE(numout,*) 'dom_qco_init : Variable volume activated'
85      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~'
86      !
87      CALL dom_qco_ctl     ! choose vertical coordinate (z_star, z_tilde or layer)
88      !
89      !                    ! Read or initialize e3t_(b/n), tilde_e3t_(b/n) and hdiv_lf
90      CALL qe_rst_read( nit000, Kbb, Kmm )
91      !
92      CALL dom_qco_zgr(Kbb, Kmm, Kaa) ! interpolation scale factor, depth and water column
93      !
94   END SUBROUTINE dom_qco_init
95
96
97   SUBROUTINE dom_qco_zgr(Kbb, Kmm, Kaa)
98      !!----------------------------------------------------------------------
99      !!                ***  ROUTINE dom_qco_init  ***
100      !!
101      !! ** Purpose :  Initialization of all ssh. to h._0 ratio
102      !!
103      !! ** Method  :  - interpolate scale factors
104      !!
105      !! ** Action  : - r3(t/u/v)_b
106      !!              - r3(t/u/v/f)_n
107      !!
108      !! Reference  : Leclair, M., and G. Madec, 2011, Ocean Modelling.
109      !!----------------------------------------------------------------------
110      INTEGER, INTENT(in) :: Kbb, Kmm, Kaa
111      !!----------------------------------------------------------------------
112      !
113      !                    !== Set of all other vertical scale factors  ==!  (now and before)
114      !                                ! Horizontal interpolation of e3t
115      CALL dom_qco_r3c( ssh(:,:,Kbb), r3t(:,:,Kbb), r3u(:,:,Kbb), r3v(:,:,Kbb) )
116      CALL dom_qco_r3c( ssh(:,:,Kmm), r3t(:,:,Kmm), r3u(:,:,Kmm), r3v(:,:,Kmm), r3f(:,:) )
117      !
118   END SUBROUTINE dom_qco_zgr
119
120
121   SUBROUTINE dom_qco_r3c( pssh, pr3t, pr3u, pr3v, pr3f )
122      !!---------------------------------------------------------------------
123      !!                   ***  ROUTINE r3c  ***
124      !!
125      !! ** Purpose :   compute the filtered ratio ssh/h_0 at t-,u-,v-,f-points
126      !!
127      !! ** Method  : - compute the ssh at u- and v-points (f-point optional)
128      !!                   Vector Form : surface weighted averaging
129      !!                   Flux   Form : simple           averaging
130      !!              - compute the ratio ssh/h_0 at t-,u-,v-pts, (f-pt optional)
131      !!----------------------------------------------------------------------
132      REAL(wp), DIMENSION(:,:)          , INTENT(in   )  ::   pssh               ! sea surface height   [m]
133      REAL(wp), DIMENSION(:,:)          , INTENT(  out)  ::   pr3t, pr3u, pr3v   ! ssh/h0 ratio at t-, u-, v-,points  [-]
134      REAL(wp), DIMENSION(:,:), OPTIONAL, INTENT(  out)  ::   pr3f               ! ssh/h0 ratio at f-point   [-]
135      !
136      INTEGER ::   ji, jj   ! dummy loop indices
137      !!----------------------------------------------------------------------
138      !
139      !
140      pr3t(:,:) = pssh(:,:) * r1_ht_0(:,:)   !==  ratio at t-point  ==!
141      !
142      !
143      !                                      !==  ratio at u-,v-point  ==!
144      !
145      IF( ln_dynadv_vec ) THEN                     !- Vector Form   (thickness weighted averaging)
146         DO_2D( 0, 0, 0, 0 )
147            pr3u(ji,jj) = 0.5_wp * (  e1e2t(ji  ,jj) * pssh(ji  ,jj)  &
148               &                    + e1e2t(ji+1,jj) * pssh(ji+1,jj)  ) * r1_hu_0(ji,jj) * r1_e1e2u(ji,jj)
149            pr3v(ji,jj) = 0.5_wp * (  e1e2t(ji,jj  ) * pssh(ji,jj  )  &
150               &                    + e1e2t(ji,jj+1) * pssh(ji,jj+1)  ) * r1_hv_0(ji,jj) * r1_e1e2v(ji,jj)
151         END_2D
152      ELSE                                         !- Flux Form   (simple averaging)
153         DO_2D( 0, 0, 0, 0 )
154            pr3u(ji,jj) = 0.5_wp * (  pssh(ji  ,jj) + pssh(ji+1,jj)  ) * r1_hu_0(ji,jj)
155            pr3v(ji,jj) = 0.5_wp * (  pssh(ji,jj  ) + pssh(ji,jj+1)  ) * r1_hv_0(ji,jj)
156         END_2D
157      ENDIF
158      !
159      IF( .NOT.PRESENT( pr3f ) ) THEN              !- lbc on ratio at u-, v-points only
160         CALL lbc_lnk_multi( 'dom_qco_r3c', pr3u, 'U', 1._wp, pr3v, 'V', 1._wp )
161         !
162         !
163      ELSE                                   !==  ratio at f-point  ==!
164         !
165         IF( ln_dynadv_vec )   THEN                !- Vector Form   (thickness weighted averaging)
166            DO_2D( 1, 0, 1, 0 )                               ! start from 1 since lbc_lnk('F') doesn't update the 1st row/line
167               pr3f(ji,jj) = 0.25_wp * (  e1e2t(ji  ,jj  ) * pssh(ji  ,jj  )  &
168                  &                     + e1e2t(ji+1,jj  ) * pssh(ji+1,jj  )  &
169                  &                     + e1e2t(ji  ,jj+1) * pssh(ji  ,jj+1)  &
170                  &                     + e1e2t(ji+1,jj+1) * pssh(ji+1,jj+1)  ) * r1_hf_0(ji,jj) * r1_e1e2f(ji,jj)
171            END_2D
172         ELSE                                      !- Flux Form   (simple averaging)
173            DO_2D( 1, 0, 1, 0 )                               ! start from 1 since lbc_lnk('F') doesn't update the 1st row/line
174               pr3f(ji,jj) = 0.25_wp * (  pssh(ji  ,jj  ) + pssh(ji+1,jj  )  &
175                  &                     + pssh(ji  ,jj+1) + pssh(ji+1,jj+1)  ) * r1_hf_0(ji,jj)
176            END_2D
177         ENDIF
178         !                                                 ! lbc on ratio at u-,v-,f-points
179         CALL lbc_lnk_multi( 'dom_qco_r3c', pr3u, 'U', 1._wp, pr3v, 'V', 1._wp, pr3f, 'F', 1._wp )
180         !
181      ENDIF
182      !
183   END SUBROUTINE dom_qco_r3c
184
185
186   SUBROUTINE qe_rst_read( kt, Kbb, Kmm )
187      !!---------------------------------------------------------------------
188      !!                   ***  ROUTINE qe_rst_read  ***
189      !!
190      !! ** Purpose :   Read ssh in restart file
191      !!
192      !! ** Method  :   use of IOM library
193      !!                if the restart does not contain ssh,
194      !!                it is set to the _0 values.
195      !!----------------------------------------------------------------------
196      INTEGER         , INTENT(in) ::   kt        ! ocean time-step
197      INTEGER         , INTENT(in) ::   Kbb, Kmm  ! ocean time level indices
198      !
199      INTEGER ::   ji, jj, jk
200      INTEGER ::   id1, id2     ! local integers
201      !!----------------------------------------------------------------------
202      !
203         IF( ln_rstart ) THEN                   !* Read the restart file
204            CALL rst_read_open                  !  open the restart file if necessary
205            !
206            id1 = iom_varid( numror, 'sshb', ldstop = .FALSE. )
207            id2 = iom_varid( numror, 'sshn', ldstop = .FALSE. )
208            !
209            !                             ! --------- !
210            !                             ! all cases !
211            !                             ! --------- !
212            !
213            IF( MIN( id1, id2 ) > 0 ) THEN       ! all required arrays exist
214               CALL iom_get( numror, jpdom_auto, 'sshb'   , ssh(:,:,Kbb)    )
215               CALL iom_get( numror, jpdom_auto, 'sshn'   , ssh(:,:,Kmm)    )
216               ! needed to restart if land processor not computed
217               IF(lwp) write(numout,*) 'qe_rst_read : ssh(:,:,Kbb) and ssh(:,:,Kmm) found in restart files'
218               WHERE ( ssmask(:,:) == 0.0_wp )   !!gm/st ==> sm should not be necessary on ssh when it was required on e3
219                  ssh(:,:,Kmm) = 0._wp
220                  ssh(:,:,Kbb) = 0._wp
221               END WHERE
222               IF( l_1st_euler ) THEN
223                  ssh(:,:,Kbb) = ssh(:,:,Kmm)
224               ENDIF
225            ELSE IF( id1 > 0 ) THEN
226               IF(lwp) write(numout,*) 'qe_rst_read WARNING : ssh(:,:,Kmm) not found in restart files'
227               IF(lwp) write(numout,*) 'sshn set equal to sshb.'
228               IF(lwp) write(numout,*) 'neuler is forced to 0'
229               CALL iom_get( numror, jpdom_auto, 'sshb', ssh(:,:,Kbb) )
230               ssh(:,:,Kmm) = ssh(:,:,Kbb)
231               l_1st_euler = .TRUE.
232            ELSE IF( id2 > 0 ) THEN
233               IF(lwp) write(numout,*) 'qe_rst_read WARNING : ssh(:,:,Kbb) not found in restart files'
234               IF(lwp) write(numout,*) 'sshb set equal to sshn.'
235               IF(lwp) write(numout,*) 'neuler is forced to 0'
236               CALL iom_get( numror, jpdom_auto, 'sshn', ssh(:,:,Kmm) )
237               ssh(:,:,Kbb) = ssh(:,:,Kmm)
238               l_1st_euler = .TRUE.
239            ELSE
240               IF(lwp) write(numout,*) 'qe_rst_read WARNING : ssh(:,:,Kmm) not found in restart file'
241               IF(lwp) write(numout,*) 'ssh_b and ssh_n set to zero'
242               IF(lwp) write(numout,*) 'neuler is forced to 0'
243               ssh(:,:,:) = 0._wp
244               l_1st_euler = .TRUE.
245            ENDIF
246            !
247         ELSE                                   !* Initialize at "rest"
248            !
249            IF( ll_wd ) THEN   ! MJB ll_wd edits start here - these are essential
250               !
251               IF( cn_cfg == 'wad' ) THEN            ! Wetting and drying test case
252                  CALL usr_def_istate( gdept(:,:,:,Kbb), tmask, ts(:,:,:,:,Kbb), uu(:,:,:,Kbb), vv(:,:,:,Kbb), ssh(:,:,Kbb)  )
253                  ts (:,:,:,:,Kmm) = ts (:,:,:,:,Kbb)       ! set now values from to before ones
254                  ssh(:,:    ,Kmm) = ssh(:,:    ,Kbb)
255                  uu (:,:,:  ,Kmm) = uu (:,:,:  ,Kbb)
256                  vv (:,:,:  ,Kmm) = vv (:,:,:  ,Kbb)
257               ELSE                                  ! if not test case
258                  ssh(:,:,Kmm) = -ssh_ref
259                  ssh(:,:,Kbb) = -ssh_ref
260                  !
261                  DO_2D( 1, 1, 1, 1 )
262                     IF( ht_0(ji,jj)-ssh_ref <  rn_wdmin1 ) THEN ! if total depth is less than min depth
263                        ssh(ji,jj,Kbb) = rn_wdmin1 - (ht_0(ji,jj) )
264                        ssh(ji,jj,Kmm) = rn_wdmin1 - (ht_0(ji,jj) )
265                     ENDIF
266                  END_2D
267               ENDIF
268
269               DO ji = 1, jpi
270                  DO jj = 1, jpj
271                     IF ( ht_0(ji,jj) .LE. 0.0 .AND. NINT( ssmask(ji,jj) ) .EQ. 1) THEN
272                       CALL ctl_stop( 'qe_rst_read: ht_0 must be positive at potentially wet points' )
273                     ENDIF
274                  END DO
275               END DO
276               !
277            ELSE
278               !
279               ! Just to read set ssh in fact, called latter once vertical grid
280               ! is set up:
281!               CALL usr_def_istate( gdept_0, tmask, ts(:,:,:,:,Kbb), uu(:,:,:,Kbb), vv(:,:,:,Kbb), ssh(:,:,Kbb)  )
282!               !
283                ssh(:,:,:) = 0._wp
284               !
285            ENDIF           ! end of ll_wd edits
286            !
287         ENDIF
288      !
289   END SUBROUTINE qe_rst_read
290
291
292   SUBROUTINE dom_qco_ctl
293      !!---------------------------------------------------------------------
294      !!                  ***  ROUTINE dom_qco_ctl  ***
295      !!
296      !! ** Purpose :   Control the consistency between namelist options
297      !!                for vertical coordinate
298      !!----------------------------------------------------------------------
299      INTEGER ::   ioptio, ios
300      !!
301      NAMELIST/nam_vvl/ ln_vvl_zstar, ln_vvl_ztilde, ln_vvl_layer, ln_vvl_ztilde_as_zstar, &
302         &              ln_vvl_zstar_at_eqtor      , rn_ahe3     , rn_rst_e3t            , &
303         &              rn_lf_cutoff               , rn_zdef_max , ln_vvl_dbg                ! not yet implemented: ln_vvl_kepe
304      !!----------------------------------------------------------------------
305      !
306      READ  ( numnam_ref, nam_vvl, IOSTAT = ios, ERR = 901)
307901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nam_vvl in reference namelist' )
308      READ  ( numnam_cfg, nam_vvl, IOSTAT = ios, ERR = 902 )
309902   IF( ios >  0 ) CALL ctl_nam ( ios , 'nam_vvl in configuration namelist' )
310      IF(lwm) WRITE ( numond, nam_vvl )
311      !
312      IF(lwp) THEN                    ! Namelist print
313         WRITE(numout,*)
314         WRITE(numout,*) 'dom_qco_ctl : choice/control of the variable vertical coordinate'
315         WRITE(numout,*) '~~~~~~~~~~~'
316         WRITE(numout,*) '   Namelist nam_vvl : chose a vertical coordinate'
317         WRITE(numout,*) '      zstar                      ln_vvl_zstar   = ', ln_vvl_zstar
318         WRITE(numout,*) '      ztilde                     ln_vvl_ztilde  = ', ln_vvl_ztilde
319         WRITE(numout,*) '      layer                      ln_vvl_layer   = ', ln_vvl_layer
320         WRITE(numout,*) '      ztilde as zstar   ln_vvl_ztilde_as_zstar  = ', ln_vvl_ztilde_as_zstar
321         WRITE(numout,*) '      ztilde near the equator    ln_vvl_zstar_at_eqtor  = ', ln_vvl_zstar_at_eqtor
322         WRITE(numout,*) '      !'
323         WRITE(numout,*) '      thickness diffusion coefficient                      rn_ahe3      = ', rn_ahe3
324         WRITE(numout,*) '      maximum e3t deformation fractional change            rn_zdef_max  = ', rn_zdef_max
325         IF( ln_vvl_ztilde_as_zstar ) THEN
326            WRITE(numout,*) '      ztilde running in zstar emulation mode (ln_vvl_ztilde_as_zstar=T) '
327            WRITE(numout,*) '         ignoring namelist timescale parameters and using:'
328            WRITE(numout,*) '            hard-wired : z-tilde to zstar restoration timescale (days)'
329            WRITE(numout,*) '                         rn_rst_e3t     = 0.e0'
330            WRITE(numout,*) '            hard-wired : z-tilde cutoff frequency of low-pass filter (days)'
331            WRITE(numout,*) '                         rn_lf_cutoff   = 1.0/rn_Dt'
332         ELSE
333            WRITE(numout,*) '      z-tilde to zstar restoration timescale (days)        rn_rst_e3t   = ', rn_rst_e3t
334            WRITE(numout,*) '      z-tilde cutoff frequency of low-pass filter (days)   rn_lf_cutoff = ', rn_lf_cutoff
335         ENDIF
336         WRITE(numout,*) '         debug prints flag                                 ln_vvl_dbg   = ', ln_vvl_dbg
337      ENDIF
338      !
339      ioptio = 0                      ! Parameter control
340      IF( ln_vvl_ztilde_as_zstar )   ln_vvl_ztilde = .true.
341      IF( ln_vvl_zstar           )   ioptio = ioptio + 1
342      IF( ln_vvl_ztilde          )   ioptio = ioptio + 1
343      IF( ln_vvl_layer           )   ioptio = ioptio + 1
344      !
345      IF( ioptio /= 1 )   CALL ctl_stop( 'Choose ONE vertical coordinate in namelist nam_vvl' )
346      !
347      IF(lwp) THEN                   ! Print the choice
348         WRITE(numout,*)
349         IF( ln_vvl_zstar           ) WRITE(numout,*) '      ==>>>   zstar vertical coordinate is used'
350         IF( ln_vvl_ztilde          ) WRITE(numout,*) '      ==>>>   ztilde vertical coordinate is used'
351         IF( ln_vvl_layer           ) WRITE(numout,*) '      ==>>>   layer vertical coordinate is used'
352         IF( ln_vvl_ztilde_as_zstar ) WRITE(numout,*) '      ==>>>   to emulate a zstar coordinate'
353      ENDIF
354      !
355#if defined key_agrif
356      IF( (.NOT.Agrif_Root()).AND.(.NOT.ln_vvl_zstar) )   CALL ctl_stop( 'AGRIF is implemented with zstar coordinate only' )
357#endif
358      !
359   END SUBROUTINE dom_qco_ctl
360
361   !!======================================================================
362END MODULE domqco
Note: See TracBrowser for help on using the repository browser.