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/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/DOM – NEMO

source: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/DOM/domqco.F90 @ 13248

Last change on this file since 13248 was 13248, checked in by francesca, 4 years ago

dev_r12558_HPC-08_epico_Extra_Halo: merge with trunk@13237, see #2366

File size: 19.1 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      ! IF(lwxios) THEN   ! define variables in restart file when writing with XIOS
95      !    CALL iom_set_rstw_var_active('e3t_b')
96      !    CALL iom_set_rstw_var_active('e3t_n')
97      ! ENDIF
98      !
99   END SUBROUTINE dom_qco_init
100
101
102   SUBROUTINE dom_qco_zgr(Kbb, Kmm, Kaa)
103      !!----------------------------------------------------------------------
104      !!                ***  ROUTINE dom_qco_init  ***
105      !!
106      !! ** Purpose :  Initialization of all ssh. to h._0 ratio
107      !!
108      !! ** Method  :  - interpolate scale factors
109      !!
110      !! ** Action  : - r3(t/u/v)_b
111      !!              - r3(t/u/v/f)_n
112      !!
113      !! Reference  : Leclair, M., and G. Madec, 2011, Ocean Modelling.
114      !!----------------------------------------------------------------------
115      INTEGER, INTENT(in) :: Kbb, Kmm, Kaa
116      !!----------------------------------------------------------------------
117      !
118      !                    !== Set of all other vertical scale factors  ==!  (now and before)
119      !                                ! Horizontal interpolation of e3t
120      CALL dom_qco_r3c( ssh(:,:,Kbb), r3t(:,:,Kbb), r3u(:,:,Kbb), r3v(:,:,Kbb) )
121      CALL dom_qco_r3c( ssh(:,:,Kmm), r3t(:,:,Kmm), r3u(:,:,Kmm), r3v(:,:,Kmm), r3f(:,:) )
122      !
123   END SUBROUTINE dom_qco_zgr
124
125
126   SUBROUTINE dom_qco_r3c( pssh, pr3t, pr3u, pr3v, pr3f )
127      !!---------------------------------------------------------------------
128      !!                   ***  ROUTINE r3c  ***
129      !!
130      !! ** Purpose :   compute the filtered ratio ssh/h_0 at t-,u-,v-,f-points
131      !!
132      !! ** Method  : - compute the ssh at u- and v-points (f-point optional)
133      !!                   Vector Form : surface weighted averaging
134      !!                   Flux   Form : simple           averaging
135      !!              - compute the ratio ssh/h_0 at t-,u-,v-pts, (f-pt optional)
136      !!----------------------------------------------------------------------
137      REAL(wp), DIMENSION(:,:)          , INTENT(in   )  ::   pssh               ! sea surface height   [m]
138      REAL(wp), DIMENSION(:,:)          , INTENT(  out)  ::   pr3t, pr3u, pr3v   ! ssh/h0 ratio at t-, u-, v-,points  [-]
139      REAL(wp), DIMENSION(:,:), OPTIONAL, INTENT(  out)  ::   pr3f               ! ssh/h0 ratio at f-point   [-]
140      !
141      INTEGER ::   ji, jj   ! dummy loop indices
142      !!----------------------------------------------------------------------
143      !
144      !
145      pr3t(:,:) = pssh(:,:) * r1_ht_0(:,:)   !==  ratio at t-point  ==!
146      !
147      !
148      !                                      !==  ratio at u-,v-point  ==!
149      !
150      IF( ln_dynadv_vec ) THEN                     !- Vector Form   (thickness weighted averaging)
151         DO_2D_00_00
152            pr3u(ji,jj) = 0.5_wp * (  e1e2t(ji  ,jj) * pssh(ji  ,jj)  &
153               &                    + e1e2t(ji+1,jj) * pssh(ji+1,jj)  ) * r1_hu_0(ji,jj) * r1_e1e2u(ji,jj)
154            pr3v(ji,jj) = 0.5_wp * (  e1e2t(ji,jj  ) * pssh(ji,jj  )  &
155               &                    + e1e2t(ji,jj+1) * pssh(ji,jj+1)  ) * r1_hv_0(ji,jj) * r1_e1e2v(ji,jj)
156         END_2D
157      ELSE                                         !- Flux Form   (simple averaging)
158         DO_2D_00_00
159            pr3u(ji,jj) = 0.5_wp * (  pssh(ji  ,jj) + pssh(ji+1,jj)  ) * r1_hu_0(ji,jj)
160            pr3v(ji,jj) = 0.5_wp * (  pssh(ji,jj  ) + pssh(ji,jj+1)  ) * r1_hv_0(ji,jj)
161         END_2D
162      ENDIF
163      !
164      IF( .NOT.PRESENT( pr3f ) ) THEN              !- lbc on ratio at u-, v-points only
165         CALL lbc_lnk_multi( 'dom_qco_r3c', pr3u, 'U', 1._wp, pr3v, 'V', 1._wp )
166         !
167         !
168      ELSE                                   !==  ratio at f-point  ==!
169         !
170         IF( ln_dynadv_vec )   THEN                !- Vector Form   (thickness weighted averaging)
171            DO_2D_10_10                               ! start from 1 since lbc_lnk('F') doesn't update the 1st row/line
172               pr3f(ji,jj) = 0.25_wp * (  e1e2t(ji  ,jj  ) * pssh(ji  ,jj  )  &
173                  &                     + e1e2t(ji+1,jj  ) * pssh(ji+1,jj  )  &
174                  &                     + e1e2t(ji  ,jj+1) * pssh(ji  ,jj+1)  &
175                  &                     + e1e2t(ji+1,jj+1) * pssh(ji+1,jj+1)  ) * r1_hf_0(ji,jj) * r1_e1e2f(ji,jj)
176            END_2D
177         ELSE                                      !- Flux Form   (simple averaging)
178            DO_2D_10_10                               ! start from 1 since lbc_lnk('F') doesn't update the 1st row/line
179               pr3f(ji,jj) = 0.25_wp * (  pssh(ji  ,jj  ) + pssh(ji+1,jj  )  &
180                  &                     + pssh(ji  ,jj+1) + pssh(ji+1,jj+1)  ) * r1_hf_0(ji,jj)
181            END_2D
182         ENDIF
183         !                                                 ! lbc on ratio at u-,v-,f-points
184         CALL lbc_lnk_multi( 'dom_qco_r3c', pr3u, 'U', 1._wp, pr3v, 'V', 1._wp, pr3f, 'F', 1._wp )
185         !
186      ENDIF
187      !
188   END SUBROUTINE dom_qco_r3c
189
190
191   SUBROUTINE qe_rst_read( kt, Kbb, Kmm )
192      !!---------------------------------------------------------------------
193      !!                   ***  ROUTINE qe_rst_read  ***
194      !!
195      !! ** Purpose :   Read ssh in restart file
196      !!
197      !! ** Method  :   use of IOM library
198      !!                if the restart does not contain ssh,
199      !!                it is set to the _0 values.
200      !!----------------------------------------------------------------------
201      INTEGER         , INTENT(in) ::   kt        ! ocean time-step
202      INTEGER         , INTENT(in) ::   Kbb, Kmm  ! ocean time level indices
203      !
204      INTEGER ::   ji, jj, jk
205      INTEGER ::   id1, id2     ! local integers
206      !!----------------------------------------------------------------------
207      !
208         IF( ln_rstart ) THEN                   !* Read the restart file
209            CALL rst_read_open                  !  open the restart file if necessary
210            !
211            id1 = iom_varid( numror, 'sshb', ldstop = .FALSE. )
212            id2 = iom_varid( numror, 'sshn', ldstop = .FALSE. )
213            !
214            !                             ! --------- !
215            !                             ! all cases !
216            !                             ! --------- !
217            !
218            IF( MIN( id1, id2 ) > 0 ) THEN       ! all required arrays exist
219               CALL iom_get( numror, jpdom_auto, 'sshb'   , ssh(:,:,Kbb), ldxios = lrxios    )
220               CALL iom_get( numror, jpdom_auto, 'sshn'   , ssh(:,:,Kmm), ldxios = lrxios    )
221               ! needed to restart if land processor not computed
222               IF(lwp) write(numout,*) 'qe_rst_read : ssh(:,:,Kbb) and ssh(:,:,Kmm) found in restart files'
223               WHERE ( ssmask(:,:) == 0.0_wp )   !!gm/st ==> sm should not be necessary on ssh when it was required on e3
224                  ssh(:,:,Kmm) = 0._wp
225                  ssh(:,:,Kbb) = 0._wp
226               END WHERE
227               IF( l_1st_euler ) THEN
228                  ssh(:,:,Kbb) = ssh(:,:,Kmm)
229               ENDIF
230            ELSE IF( id1 > 0 ) THEN
231               IF(lwp) write(numout,*) 'qe_rst_read WARNING : ssh(:,:,Kmm) not found in restart files'
232               IF(lwp) write(numout,*) 'sshn set equal to sshb.'
233               IF(lwp) write(numout,*) 'neuler is forced to 0'
234               CALL iom_get( numror, jpdom_auto, 'sshb', ssh(:,:,Kbb), ldxios = lrxios )
235               ssh(:,:,Kmm) = ssh(:,:,Kbb)
236               l_1st_euler = .TRUE.
237            ELSE IF( id2 > 0 ) THEN
238               IF(lwp) write(numout,*) 'qe_rst_read WARNING : ssh(:,:,Kbb) not found in restart files'
239               IF(lwp) write(numout,*) 'sshb set equal to sshn.'
240               IF(lwp) write(numout,*) 'neuler is forced to 0'
241               CALL iom_get( numror, jpdom_auto, 'sshn', ssh(:,:,Kmm), ldxios = lrxios )
242               ssh(:,:,Kbb) = ssh(:,:,Kmm)
243               l_1st_euler = .TRUE.
244            ELSE
245               IF(lwp) write(numout,*) 'qe_rst_read WARNING : ssh(:,:,Kmm) not found in restart file'
246               IF(lwp) write(numout,*) 'ssh_b and ssh_n set to zero'
247               IF(lwp) write(numout,*) 'neuler is forced to 0'
248               ssh(:,:,:) = 0._wp
249               l_1st_euler = .TRUE.
250            ENDIF
251            !
252         ELSE                                   !* Initialize at "rest"
253            !
254            IF( ll_wd ) THEN   ! MJB ll_wd edits start here - these are essential
255               !
256               IF( cn_cfg == 'wad' ) THEN            ! Wetting and drying test case
257                  CALL usr_def_istate( gdept(:,:,:,Kbb), tmask, ts(:,:,:,:,Kbb), uu(:,:,:,Kbb), vv(:,:,:,Kbb), ssh(:,:,Kbb)  )
258                  ts (:,:,:,:,Kmm) = ts (:,:,:,:,Kbb)       ! set now values from to before ones
259                  ssh(:,:    ,Kmm) = ssh(:,:    ,Kbb)
260                  uu (:,:,:  ,Kmm) = uu (:,:,:  ,Kbb)
261                  vv (:,:,:  ,Kmm) = vv (:,:,:  ,Kbb)
262               ELSE                                  ! if not test case
263                  ssh(:,:,Kmm) = -ssh_ref
264                  ssh(:,:,Kbb) = -ssh_ref
265                  !
266                  DO_2D_11_11
267                     IF( ht_0(ji,jj)-ssh_ref <  rn_wdmin1 ) THEN ! if total depth is less than min depth
268                        ssh(ji,jj,Kbb) = rn_wdmin1 - (ht_0(ji,jj) )
269                        ssh(ji,jj,Kmm) = rn_wdmin1 - (ht_0(ji,jj) )
270                     ENDIF
271                  END_2D
272               ENDIF
273
274               DO ji = 1, jpi
275                  DO jj = 1, jpj
276                     IF ( ht_0(ji,jj) .LE. 0.0 .AND. NINT( ssmask(ji,jj) ) .EQ. 1) THEN
277                       CALL ctl_stop( 'qe_rst_read: ht_0 must be positive at potentially wet points' )
278                     ENDIF
279                  END DO
280               END DO
281               !
282            ELSE
283               !
284               ! Just to read set ssh in fact, called latter once vertical grid
285               ! is set up:
286!               CALL usr_def_istate( gdept_0, tmask, ts(:,:,:,:,Kbb), uu(:,:,:,Kbb), vv(:,:,:,Kbb), ssh(:,:,Kbb)  )
287!               !
288                ssh(:,:,:) = 0._wp
289               !
290            ENDIF           ! end of ll_wd edits
291            !
292         ENDIF
293      !
294   END SUBROUTINE qe_rst_read
295
296
297   SUBROUTINE dom_qco_ctl
298      !!---------------------------------------------------------------------
299      !!                  ***  ROUTINE dom_qco_ctl  ***
300      !!
301      !! ** Purpose :   Control the consistency between namelist options
302      !!                for vertical coordinate
303      !!----------------------------------------------------------------------
304      INTEGER ::   ioptio, ios
305      !!
306      NAMELIST/nam_vvl/ ln_vvl_zstar, ln_vvl_ztilde, ln_vvl_layer, ln_vvl_ztilde_as_zstar, &
307         &              ln_vvl_zstar_at_eqtor      , rn_ahe3     , rn_rst_e3t            , &
308         &              rn_lf_cutoff               , rn_zdef_max , ln_vvl_dbg                ! not yet implemented: ln_vvl_kepe
309      !!----------------------------------------------------------------------
310      !
311      READ  ( numnam_ref, nam_vvl, IOSTAT = ios, ERR = 901)
312901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nam_vvl in reference namelist' )
313      READ  ( numnam_cfg, nam_vvl, IOSTAT = ios, ERR = 902 )
314902   IF( ios >  0 ) CALL ctl_nam ( ios , 'nam_vvl in configuration namelist' )
315      IF(lwm) WRITE ( numond, nam_vvl )
316      !
317      IF(lwp) THEN                    ! Namelist print
318         WRITE(numout,*)
319         WRITE(numout,*) 'dom_qco_ctl : choice/control of the variable vertical coordinate'
320         WRITE(numout,*) '~~~~~~~~~~~'
321         WRITE(numout,*) '   Namelist nam_vvl : chose a vertical coordinate'
322         WRITE(numout,*) '      zstar                      ln_vvl_zstar   = ', ln_vvl_zstar
323         WRITE(numout,*) '      ztilde                     ln_vvl_ztilde  = ', ln_vvl_ztilde
324         WRITE(numout,*) '      layer                      ln_vvl_layer   = ', ln_vvl_layer
325         WRITE(numout,*) '      ztilde as zstar   ln_vvl_ztilde_as_zstar  = ', ln_vvl_ztilde_as_zstar
326         WRITE(numout,*) '      ztilde near the equator    ln_vvl_zstar_at_eqtor  = ', ln_vvl_zstar_at_eqtor
327         WRITE(numout,*) '      !'
328         WRITE(numout,*) '      thickness diffusion coefficient                      rn_ahe3      = ', rn_ahe3
329         WRITE(numout,*) '      maximum e3t deformation fractional change            rn_zdef_max  = ', rn_zdef_max
330         IF( ln_vvl_ztilde_as_zstar ) THEN
331            WRITE(numout,*) '      ztilde running in zstar emulation mode (ln_vvl_ztilde_as_zstar=T) '
332            WRITE(numout,*) '         ignoring namelist timescale parameters and using:'
333            WRITE(numout,*) '            hard-wired : z-tilde to zstar restoration timescale (days)'
334            WRITE(numout,*) '                         rn_rst_e3t     = 0.e0'
335            WRITE(numout,*) '            hard-wired : z-tilde cutoff frequency of low-pass filter (days)'
336            WRITE(numout,*) '                         rn_lf_cutoff   = 1.0/rn_Dt'
337         ELSE
338            WRITE(numout,*) '      z-tilde to zstar restoration timescale (days)        rn_rst_e3t   = ', rn_rst_e3t
339            WRITE(numout,*) '      z-tilde cutoff frequency of low-pass filter (days)   rn_lf_cutoff = ', rn_lf_cutoff
340         ENDIF
341         WRITE(numout,*) '         debug prints flag                                 ln_vvl_dbg   = ', ln_vvl_dbg
342      ENDIF
343      !
344      ioptio = 0                      ! Parameter control
345      IF( ln_vvl_ztilde_as_zstar )   ln_vvl_ztilde = .true.
346      IF( ln_vvl_zstar           )   ioptio = ioptio + 1
347      IF( ln_vvl_ztilde          )   ioptio = ioptio + 1
348      IF( ln_vvl_layer           )   ioptio = ioptio + 1
349      !
350      IF( ioptio /= 1 )   CALL ctl_stop( 'Choose ONE vertical coordinate in namelist nam_vvl' )
351      !
352      IF(lwp) THEN                   ! Print the choice
353         WRITE(numout,*)
354         IF( ln_vvl_zstar           ) WRITE(numout,*) '      ==>>>   zstar vertical coordinate is used'
355         IF( ln_vvl_ztilde          ) WRITE(numout,*) '      ==>>>   ztilde vertical coordinate is used'
356         IF( ln_vvl_layer           ) WRITE(numout,*) '      ==>>>   layer vertical coordinate is used'
357         IF( ln_vvl_ztilde_as_zstar ) WRITE(numout,*) '      ==>>>   to emulate a zstar coordinate'
358      ENDIF
359      !
360#if defined key_agrif
361      IF( (.NOT.Agrif_Root()).AND.(.NOT.ln_vvl_zstar) )   CALL ctl_stop( 'AGRIF is implemented with zstar coordinate only' )
362#endif
363      !
364   END SUBROUTINE dom_qco_ctl
365
366   !!======================================================================
367END MODULE domqco
Note: See TracBrowser for help on using the repository browser.