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_r13296_HPC-07_mocavero_mpi3/src/OCE/DOM – NEMO

source: NEMO/branches/2020/dev_r13296_HPC-07_mocavero_mpi3/src/OCE/DOM/domqco.F90 @ 13630

Last change on this file since 13630 was 13630, checked in by mocavero, 4 years ago

Add neighborhood collectives calls in the NEMO src - ticket #2496

File size: 19.4 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( 0, 0, 0, 0 )
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( 0, 0, 0, 0 )
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#if defined key_mpi3
166         CALL lbc_lnk_nc_multi( 'dom_qco_r3c', pr3u, 'U', 1._wp, pr3v, 'V', 1._wp )
167#else
168         CALL lbc_lnk_multi( 'dom_qco_r3c', pr3u, 'U', 1._wp, pr3v, 'V', 1._wp )
169#endif
170         !
171         !
172      ELSE                                   !==  ratio at f-point  ==!
173         !
174         IF( ln_dynadv_vec )   THEN                !- Vector Form   (thickness weighted averaging)
175            DO_2D( 1, 0, 1, 0 )                               ! start from 1 since lbc_lnk('F') doesn't update the 1st row/line
176               pr3f(ji,jj) = 0.25_wp * (  e1e2t(ji  ,jj  ) * pssh(ji  ,jj  )  &
177                  &                     + e1e2t(ji+1,jj  ) * pssh(ji+1,jj  )  &
178                  &                     + e1e2t(ji  ,jj+1) * pssh(ji  ,jj+1)  &
179                  &                     + e1e2t(ji+1,jj+1) * pssh(ji+1,jj+1)  ) * r1_hf_0(ji,jj) * r1_e1e2f(ji,jj)
180            END_2D
181         ELSE                                      !- Flux Form   (simple averaging)
182            DO_2D( 1, 0, 1, 0 )                               ! start from 1 since lbc_lnk('F') doesn't update the 1st row/line
183               pr3f(ji,jj) = 0.25_wp * (  pssh(ji  ,jj  ) + pssh(ji+1,jj  )  &
184                  &                     + pssh(ji  ,jj+1) + pssh(ji+1,jj+1)  ) * r1_hf_0(ji,jj)
185            END_2D
186         ENDIF
187         !                                                 ! lbc on ratio at u-,v-,f-points
188#if defined key_mpi3
189         CALL lbc_lnk_nc_multi( 'dom_qco_r3c', pr3u, 'U', 1._wp, pr3v, 'V', 1._wp, pr3f, 'F', 1._wp )
190#else
191         CALL lbc_lnk_multi( 'dom_qco_r3c', pr3u, 'U', 1._wp, pr3v, 'V', 1._wp, pr3f, 'F', 1._wp )
192#endif
193         !
194      ENDIF
195      !
196   END SUBROUTINE dom_qco_r3c
197
198
199   SUBROUTINE qe_rst_read( kt, Kbb, Kmm )
200      !!---------------------------------------------------------------------
201      !!                   ***  ROUTINE qe_rst_read  ***
202      !!
203      !! ** Purpose :   Read ssh in restart file
204      !!
205      !! ** Method  :   use of IOM library
206      !!                if the restart does not contain ssh,
207      !!                it is set to the _0 values.
208      !!----------------------------------------------------------------------
209      INTEGER         , INTENT(in) ::   kt        ! ocean time-step
210      INTEGER         , INTENT(in) ::   Kbb, Kmm  ! ocean time level indices
211      !
212      INTEGER ::   ji, jj, jk
213      INTEGER ::   id1, id2     ! local integers
214      !!----------------------------------------------------------------------
215      !
216         IF( ln_rstart ) THEN                   !* Read the restart file
217            CALL rst_read_open                  !  open the restart file if necessary
218            !
219            id1 = iom_varid( numror, 'sshb', ldstop = .FALSE. )
220            id2 = iom_varid( numror, 'sshn', ldstop = .FALSE. )
221            !
222            !                             ! --------- !
223            !                             ! all cases !
224            !                             ! --------- !
225            !
226            IF( MIN( id1, id2 ) > 0 ) THEN       ! all required arrays exist
227               CALL iom_get( numror, jpdom_auto, 'sshb'   , ssh(:,:,Kbb), ldxios = lrxios    )
228               CALL iom_get( numror, jpdom_auto, 'sshn'   , ssh(:,:,Kmm), ldxios = lrxios    )
229               ! needed to restart if land processor not computed
230               IF(lwp) write(numout,*) 'qe_rst_read : ssh(:,:,Kbb) and ssh(:,:,Kmm) found in restart files'
231               WHERE ( ssmask(:,:) == 0.0_wp )   !!gm/st ==> sm should not be necessary on ssh when it was required on e3
232                  ssh(:,:,Kmm) = 0._wp
233                  ssh(:,:,Kbb) = 0._wp
234               END WHERE
235               IF( l_1st_euler ) THEN
236                  ssh(:,:,Kbb) = ssh(:,:,Kmm)
237               ENDIF
238            ELSE IF( id1 > 0 ) THEN
239               IF(lwp) write(numout,*) 'qe_rst_read WARNING : ssh(:,:,Kmm) not found in restart files'
240               IF(lwp) write(numout,*) 'sshn set equal to sshb.'
241               IF(lwp) write(numout,*) 'neuler is forced to 0'
242               CALL iom_get( numror, jpdom_auto, 'sshb', ssh(:,:,Kbb), ldxios = lrxios )
243               ssh(:,:,Kmm) = ssh(:,:,Kbb)
244               l_1st_euler = .TRUE.
245            ELSE IF( id2 > 0 ) THEN
246               IF(lwp) write(numout,*) 'qe_rst_read WARNING : ssh(:,:,Kbb) not found in restart files'
247               IF(lwp) write(numout,*) 'sshb set equal to sshn.'
248               IF(lwp) write(numout,*) 'neuler is forced to 0'
249               CALL iom_get( numror, jpdom_auto, 'sshn', ssh(:,:,Kmm), ldxios = lrxios )
250               ssh(:,:,Kbb) = ssh(:,:,Kmm)
251               l_1st_euler = .TRUE.
252            ELSE
253               IF(lwp) write(numout,*) 'qe_rst_read WARNING : ssh(:,:,Kmm) not found in restart file'
254               IF(lwp) write(numout,*) 'ssh_b and ssh_n set to zero'
255               IF(lwp) write(numout,*) 'neuler is forced to 0'
256               ssh(:,:,:) = 0._wp
257               l_1st_euler = .TRUE.
258            ENDIF
259            !
260         ELSE                                   !* Initialize at "rest"
261            !
262            IF( ll_wd ) THEN   ! MJB ll_wd edits start here - these are essential
263               !
264               IF( cn_cfg == 'wad' ) THEN            ! Wetting and drying test case
265                  CALL usr_def_istate( gdept(:,:,:,Kbb), tmask, ts(:,:,:,:,Kbb), uu(:,:,:,Kbb), vv(:,:,:,Kbb), ssh(:,:,Kbb)  )
266                  ts (:,:,:,:,Kmm) = ts (:,:,:,:,Kbb)       ! set now values from to before ones
267                  ssh(:,:    ,Kmm) = ssh(:,:    ,Kbb)
268                  uu (:,:,:  ,Kmm) = uu (:,:,:  ,Kbb)
269                  vv (:,:,:  ,Kmm) = vv (:,:,:  ,Kbb)
270               ELSE                                  ! if not test case
271                  ssh(:,:,Kmm) = -ssh_ref
272                  ssh(:,:,Kbb) = -ssh_ref
273                  !
274                  DO_2D( 1, 1, 1, 1 )
275                     IF( ht_0(ji,jj)-ssh_ref <  rn_wdmin1 ) THEN ! if total depth is less than min depth
276                        ssh(ji,jj,Kbb) = rn_wdmin1 - (ht_0(ji,jj) )
277                        ssh(ji,jj,Kmm) = rn_wdmin1 - (ht_0(ji,jj) )
278                     ENDIF
279                  END_2D
280               ENDIF
281
282               DO ji = 1, jpi
283                  DO jj = 1, jpj
284                     IF ( ht_0(ji,jj) .LE. 0.0 .AND. NINT( ssmask(ji,jj) ) .EQ. 1) THEN
285                       CALL ctl_stop( 'qe_rst_read: ht_0 must be positive at potentially wet points' )
286                     ENDIF
287                  END DO
288               END DO
289               !
290            ELSE
291               !
292               ! Just to read set ssh in fact, called latter once vertical grid
293               ! is set up:
294!               CALL usr_def_istate( gdept_0, tmask, ts(:,:,:,:,Kbb), uu(:,:,:,Kbb), vv(:,:,:,Kbb), ssh(:,:,Kbb)  )
295!               !
296                ssh(:,:,:) = 0._wp
297               !
298            ENDIF           ! end of ll_wd edits
299            !
300         ENDIF
301      !
302   END SUBROUTINE qe_rst_read
303
304
305   SUBROUTINE dom_qco_ctl
306      !!---------------------------------------------------------------------
307      !!                  ***  ROUTINE dom_qco_ctl  ***
308      !!
309      !! ** Purpose :   Control the consistency between namelist options
310      !!                for vertical coordinate
311      !!----------------------------------------------------------------------
312      INTEGER ::   ioptio, ios
313      !!
314      NAMELIST/nam_vvl/ ln_vvl_zstar, ln_vvl_ztilde, ln_vvl_layer, ln_vvl_ztilde_as_zstar, &
315         &              ln_vvl_zstar_at_eqtor      , rn_ahe3     , rn_rst_e3t            , &
316         &              rn_lf_cutoff               , rn_zdef_max , ln_vvl_dbg                ! not yet implemented: ln_vvl_kepe
317      !!----------------------------------------------------------------------
318      !
319      READ  ( numnam_ref, nam_vvl, IOSTAT = ios, ERR = 901)
320901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nam_vvl in reference namelist' )
321      READ  ( numnam_cfg, nam_vvl, IOSTAT = ios, ERR = 902 )
322902   IF( ios >  0 ) CALL ctl_nam ( ios , 'nam_vvl in configuration namelist' )
323      IF(lwm) WRITE ( numond, nam_vvl )
324      !
325      IF(lwp) THEN                    ! Namelist print
326         WRITE(numout,*)
327         WRITE(numout,*) 'dom_qco_ctl : choice/control of the variable vertical coordinate'
328         WRITE(numout,*) '~~~~~~~~~~~'
329         WRITE(numout,*) '   Namelist nam_vvl : chose a vertical coordinate'
330         WRITE(numout,*) '      zstar                      ln_vvl_zstar   = ', ln_vvl_zstar
331         WRITE(numout,*) '      ztilde                     ln_vvl_ztilde  = ', ln_vvl_ztilde
332         WRITE(numout,*) '      layer                      ln_vvl_layer   = ', ln_vvl_layer
333         WRITE(numout,*) '      ztilde as zstar   ln_vvl_ztilde_as_zstar  = ', ln_vvl_ztilde_as_zstar
334         WRITE(numout,*) '      ztilde near the equator    ln_vvl_zstar_at_eqtor  = ', ln_vvl_zstar_at_eqtor
335         WRITE(numout,*) '      !'
336         WRITE(numout,*) '      thickness diffusion coefficient                      rn_ahe3      = ', rn_ahe3
337         WRITE(numout,*) '      maximum e3t deformation fractional change            rn_zdef_max  = ', rn_zdef_max
338         IF( ln_vvl_ztilde_as_zstar ) THEN
339            WRITE(numout,*) '      ztilde running in zstar emulation mode (ln_vvl_ztilde_as_zstar=T) '
340            WRITE(numout,*) '         ignoring namelist timescale parameters and using:'
341            WRITE(numout,*) '            hard-wired : z-tilde to zstar restoration timescale (days)'
342            WRITE(numout,*) '                         rn_rst_e3t     = 0.e0'
343            WRITE(numout,*) '            hard-wired : z-tilde cutoff frequency of low-pass filter (days)'
344            WRITE(numout,*) '                         rn_lf_cutoff   = 1.0/rn_Dt'
345         ELSE
346            WRITE(numout,*) '      z-tilde to zstar restoration timescale (days)        rn_rst_e3t   = ', rn_rst_e3t
347            WRITE(numout,*) '      z-tilde cutoff frequency of low-pass filter (days)   rn_lf_cutoff = ', rn_lf_cutoff
348         ENDIF
349         WRITE(numout,*) '         debug prints flag                                 ln_vvl_dbg   = ', ln_vvl_dbg
350      ENDIF
351      !
352      ioptio = 0                      ! Parameter control
353      IF( ln_vvl_ztilde_as_zstar )   ln_vvl_ztilde = .true.
354      IF( ln_vvl_zstar           )   ioptio = ioptio + 1
355      IF( ln_vvl_ztilde          )   ioptio = ioptio + 1
356      IF( ln_vvl_layer           )   ioptio = ioptio + 1
357      !
358      IF( ioptio /= 1 )   CALL ctl_stop( 'Choose ONE vertical coordinate in namelist nam_vvl' )
359      !
360      IF(lwp) THEN                   ! Print the choice
361         WRITE(numout,*)
362         IF( ln_vvl_zstar           ) WRITE(numout,*) '      ==>>>   zstar vertical coordinate is used'
363         IF( ln_vvl_ztilde          ) WRITE(numout,*) '      ==>>>   ztilde vertical coordinate is used'
364         IF( ln_vvl_layer           ) WRITE(numout,*) '      ==>>>   layer vertical coordinate is used'
365         IF( ln_vvl_ztilde_as_zstar ) WRITE(numout,*) '      ==>>>   to emulate a zstar coordinate'
366      ENDIF
367      !
368#if defined key_agrif
369      IF( (.NOT.Agrif_Root()).AND.(.NOT.ln_vvl_zstar) )   CALL ctl_stop( 'AGRIF is implemented with zstar coordinate only' )
370#endif
371      !
372   END SUBROUTINE dom_qco_ctl
373
374   !!======================================================================
375END MODULE domqco
Note: See TracBrowser for help on using the repository browser.