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.
isftbl.F90 in NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF – NEMO

source: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isftbl.F90 @ 11852

Last change on this file since 11852 was 11852, checked in by mathiot, 4 years ago

ENHANCE-02_ISF_nemo: fix WED025 restartability, finish removing useless USE, remove useless lbc_lnk

File size: 12.6 KB
RevLine 
[11395]1MODULE isftbl
[11403]2   !!======================================================================
3   !!                       ***  MODULE  isftbl  ***
4   !! isftbl module :  compute properties of top boundary layer
5   !!======================================================================
6   !! History :  4.1  !  2019-09  (P. Mathiot) original code
7   !!----------------------------------------------------------------------
[11395]8
[11403]9   !!----------------------------------------------------------------------
10   !!   isftbl       : routine to compute :
11   !!                  - geometry of the ice shelf tbl (isf_tbl_lvl, isftbl_ktop, isftbl_kbot)
12   !!                    (top and bottom level, thickness and fraction of deepest level affected)
13   !!                  - tbl averaged properties (isf_tbl, isf_tbl_avg)
14   !!----------------------------------------------------------------------
[11395]15
[11852]16   USE isf     ! ice shelf variables
17
[11403]18   USE dom_oce ! vertical scale factor
[11395]19
[11403]20   IMPLICIT NONE
[11395]21
[11403]22   PRIVATE
[11395]23
[11541]24   PUBLIC isf_tbl, isf_tbl_avg, isf_tbl_lvl, isf_tbl_ktop, isf_tbl_kbot
[11403]25
[11395]26CONTAINS
27
[11495]28   SUBROUTINE isf_tbl( pvarin, pvarout, cd_ptin, ktop, phtbl, kbot, pfrac )
[11403]29      !!--------------------------------------------------------------------
30      !!                  ***  SUBROUTINE isf_tbl  ***
[11395]31      !!
32      !! ** Purpose : compute mean T/S/U/V in the boundary layer at T- point
33      !!
[11541]34      !! ** Method : Average properties over a specific thickness
35      !!
36      !! ** Reference : inspired from : Losch, Modeling ice shelf cavities in a z coordinate ocean general circulation model
37      !!                https://doi.org/10.1029/2007JC004368 , 2008
38      !!
[11403]39      !!--------------------------------------------------------------------
[11395]40      !!-------------------------- OUT -------------------------------------
[11403]41      REAL(wp), DIMENSION(jpi,jpj)          , INTENT(  out) :: pvarout ! 2d average of pvarin
[11395]42      !!-------------------------- IN  -------------------------------------
[11403]43      CHARACTER(len=1)                      , INTENT(in   ) :: cd_ptin       ! point of variable in/out
44      REAL(wp), DIMENSION(jpi,jpj,jpk)      , INTENT(in   ) :: pvarin        ! 3d variable to average over the tbl
[11495]45      INTEGER,  DIMENSION(jpi,jpj)          , INTENT(in   ) :: ktop          ! top level
46      REAL(wp), DIMENSION(jpi,jpj)          , INTENT(in   ) :: phtbl         ! tbl thickness
[11403]47      !!-------------------------- IN OPTIONAL -----------------------------
[11495]48      INTEGER,  DIMENSION(jpi,jpj), OPTIONAL, INTENT(in   ) :: kbot          ! bottom level
49      REAL(wp), DIMENSION(jpi,jpj), OPTIONAL, INTENT(in   ) :: pfrac         ! fraction of bottom cell affected by tbl
[11395]50      !!--------------------------------------------------------------------
[11844]51      INTEGER ::   ji, jj                     ! loop index
52      INTEGER , DIMENSION(jpi,jpj) :: ikbot   ! bottom level of the tbl
53      REAL(wp), DIMENSION(jpi,jpj) :: zvarout ! 2d average of pvarin
54      REAL(wp), DIMENSION(jpi,jpj) :: zhtbl   ! thickness of the tbl
55      REAL(wp), DIMENSION(jpi,jpj) :: zfrac   ! thickness of the tbl
[11403]56      !!--------------------------------------------------------------------
[11395]57      !
58      SELECT CASE ( cd_ptin )
59      CASE ( 'U' )
60         !
[11495]61         ! copy phtbl (phtbl is INTENT in as we don't want to change it)
62         zhtbl = phtbl
[11395]63         !
[11495]64         ! compute tbl lvl and thickness
65         CALL isf_tbl_lvl( hu_n, e3u_n, ktop, ikbot, zhtbl, zfrac )
66         !
[11395]67         ! compute tbl property at U point
[11844]68         CALL isf_tbl_avg( miku, ikbot, zhtbl, zfrac, e3u_n, pvarin, zvarout )
[11395]69         !
70         ! compute tbl property at T point
[11844]71         pvarout(1,:) = 0._wp
[11395]72         DO jj = 1, jpj
73            DO ji = 2, jpi
[11844]74               pvarout(ji,jj) = 0.5_wp * (zvarout(ji,jj) + zvarout(ji-1,jj))
[11395]75            END DO
76         END DO
[11844]77         ! lbclnk not needed as a final communication is done after the computation of fwf
[11395]78         !
79      CASE ( 'V' )
80         !
[11495]81         ! copy phtbl (phtbl is INTENT in as we don't want to change it)
82         zhtbl = phtbl
[11395]83         !
[11495]84         ! compute tbl lvl and thickness
85         CALL isf_tbl_lvl( hv_n, e3v_n, ktop, ikbot, zhtbl, zfrac )
86         !
[11395]87         ! compute tbl property at V point
[11844]88         CALL isf_tbl_avg( mikv, ikbot, zhtbl, zfrac, e3v_n, pvarin, zvarout )
[11395]89         !
90         ! pvarout is an averaging of wet point
[11844]91         pvarout(:,1) = 0._wp
[11395]92         DO jj = 2, jpj
93            DO ji = 1, jpi
[11844]94               pvarout(ji,jj) = 0.5_wp * (zvarout(ji,jj) + zvarout(ji,jj-1))
[11395]95            END DO
96         END DO
[11844]97         ! lbclnk not needed as a final communication is done after the computation of fwf
[11395]98         !
99      CASE ( 'T' )
100         !
101         ! compute tbl property at T point
102         CALL isf_tbl_avg( ktop, kbot, phtbl, pfrac, e3t_n, pvarin, pvarout )
103         !
104      END SELECT
105      !
106   END SUBROUTINE isf_tbl
107
108   SUBROUTINE isf_tbl_avg( ktop, kbot, phtbl, pfrac, pe3, pvarin, pvarout )
[11403]109      !!--------------------------------------------------------------------
[11541]110      !!                  ***  ROUTINE isf_tbl_avg  ***
[11395]111      !!
112      !! ** Purpose : compute mean property in the boundary layer
113      !!
[11403]114      !! ** Method  : Depth average is made between the top level ktop and the bottom level kbot
115      !!              over a thickness phtbl. The bottom level is partially counted (pfrac).
116      !!
117      !!--------------------------------------------------------------------
[11395]118      !!-------------------------- OUT -------------------------------------
[11403]119      REAL(wp), DIMENSION(jpi,jpj)    , INTENT(  out) :: pvarout      ! tbl property averaged over phtbl between level ktop and kbot
[11395]120      !!-------------------------- IN  -------------------------------------
[11403]121      INTEGER,  DIMENSION(jpi,jpj)    , INTENT(in   ) :: ktop, kbot   ! top and bottom level of the top boundary layer
122      REAL(wp), DIMENSION(jpi,jpj)    , INTENT(in   ) :: phtbl, pfrac ! fraction of bottom level to be affected by the tbl
123      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) :: pe3          ! vertical scale factor
124      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) :: pvarin       ! tbl property to average between ktop, kbot over phtbl
125      !!--------------------------------------------------------------------
[11395]126      INTEGER  :: ji,jj,jk                    ! loop indices
127      INTEGER  :: ikt, ikb                    ! top and bottom levels
[11403]128      !!--------------------------------------------------------------------
[11395]129      !
130      ! compute tbl top.bottom level and thickness
131      DO jj = 1,jpj
132         DO ji = 1,jpi
133            !
134            ! tbl top/bottom indices initialisation
135            ikt = ktop(ji,jj) ; ikb = kbot(ji,jj)
136            !
137            ! level fully include in the ice shelf boundary layer
138            pvarout(ji,jj) = SUM( pvarin(ji,jj,ikt:ikb-1) * pe3(ji,jj,ikt:ikb-1) ) / phtbl(ji,jj)
139            !
140            ! level partially include in ice shelf boundary layer
141            pvarout(ji,jj) = pvarout(ji,jj) + pvarin(ji,jj,ikb) * pe3(ji,jj,ikb) / phtbl(ji,jj) * pfrac(ji,jj)
142            !
143         END DO
144      END DO
145
146   END SUBROUTINE isf_tbl_avg
147
148   SUBROUTINE isf_tbl_lvl( phw, pe3, ktop, kbot, phtbl, pfrac )
[11403]149      !!--------------------------------------------------------------------
[11395]150      !!                  ***  ROUTINE isf_tbl_lvl  ***
151      !!
[11541]152      !! ** Purpose : - compute bottom level off the top boundary layer
[11395]153      !!              - thickness of the top boundary layer
[11541]154      !!              - fraction of the bottom level affected by the tbl
[11395]155      !!
[11495]156      !!---------------------------------------------------------------------
157      !!-------------------------- OUT --------------------------------------
[11403]158      INTEGER,  DIMENSION(jpi,jpj)    , INTENT(  out) :: kbot   ! bottom level of the top boundary layer
[11495]159      REAL(wp), DIMENSION(jpi,jpj)    , INTENT(  out) :: pfrac  ! fraction of bottom level in the tbl
160      !!-------------------------- IN  --------------------------------------
[11403]161      INTEGER,  DIMENSION(jpi,jpj)    , INTENT(in   ) :: ktop   ! top level of the top boundary layer
162      REAL(wp), DIMENSION(jpi,jpj)    , INTENT(in   ) :: phw    ! water column thickness
163      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) :: pe3    ! vertical scale factor
[11495]164      !!-------------------------- INOUT ------------------------------------
165      REAL(wp), DIMENSION(jpi,jpj)    , INTENT(inout) :: phtbl  ! top boundary layer thickness
[11395]166      !!---------------------------------------------------------------------
167      INTEGER :: ji,jj,jk
168      INTEGER :: ikt, ikb
169      !!---------------------------------------------------------------------
170      !
171      ! get htbl
172      DO jj = 1,jpj
173         DO ji = 1,jpi
174            !
175            ! tbl top/bottom indices initialisation
176            ikt = ktop(ji,jj)
177            !
178            ! limit the tbl to water thickness.
179            phtbl(ji,jj) = MIN( phtbl(ji,jj), phw(ji,jj) )
180            !
181            ! thickness of boundary layer must be at least the top level thickness
182            phtbl(ji,jj) = MAX( phtbl(ji,jj), pe3(ji,jj,ikt) )
183            !
184         END DO
185      END DO
186      !
187      ! get ktbl
[11541]188      CALL isf_tbl_kbot(ktop, phtbl, pe3, kbot)
[11395]189      !
190      ! get pfrac
191      DO jj = 1,jpj
192         DO ji = 1,jpi
193            !
194            ! tbl top/bottom indices initialisation
195            ikt = ktop(ji,jj) ; ikb = kbot(ji,jj)
196            !
197            ! proportion of the bottom cell included in ice shelf boundary layer
198            pfrac(ji,jj) = ( phtbl(ji,jj) - SUM( pe3(ji,jj,ikt:ikb-1) ) ) / pe3(ji,jj,ikb)
199            !
200         END DO
201      END DO
202      !
203   END SUBROUTINE isf_tbl_lvl
204   !
[11541]205   SUBROUTINE isf_tbl_kbot(ktop, phtbl, pe3, kbot)
[11403]206      !!--------------------------------------------------------------------
[11541]207      !!                  ***  ROUTINE isf_tbl_bot  ***
[11403]208      !!
209      !! ** Purpose : compute bottom level of the isf top boundary layer
210      !!
211      !!--------------------------------------------------------------------
[11395]212      !!-------------------------- OUT -------------------------------------
[11403]213      INTEGER,  DIMENSION(jpi,jpj)    , INTENT(  out) :: kbot   ! bottom level of the top boundary layer
[11395]214      !!-------------------------- IN  -------------------------------------
[11403]215      REAL(wp), DIMENSION(jpi,jpj)    , INTENT(in   ) :: phtbl  ! top boundary layer thickness
216      INTEGER,  DIMENSION(jpi,jpj)    , INTENT(in   ) :: ktop   ! top level of the top boundary layer
217      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) :: pe3    ! vertical scale factor
218      !!--------------------------------------------------------------------
[11395]219      INTEGER :: ji, jj
220      INTEGER :: ikt, ikb
[11403]221      !!--------------------------------------------------------------------
[11395]222      !
223      ! phtbl need to be bounded by water column thickness before
[11494]224      ! test: if htbl = water column thickness, should return mbathy
225      ! test: if htbl = 0 should return ktop (phtbl cap to e3t(ji,jj,1))
[11403]226      !
[11395]227      ! get ktbl
228      DO jj = 1,jpj
229         DO ji = 1,jpi
230            !
231            ! determine the deepest level influenced by the boundary layer
232            ikt = ktop(ji,jj)
233            ikb = ikt
234            DO WHILE ( SUM(pe3(ji,jj,ikt:ikb-1)) < phtbl(ji,jj ) ) ;  ikb = ikb + 1 ;  END DO
235            kbot(ji,jj) = ikb - 1
236            !
237         END DO
238      END DO
239      !
[11541]240   END SUBROUTINE isf_tbl_kbot
[11395]241      !
[11541]242   SUBROUTINE isf_tbl_ktop(pdep, ktop)
[11403]243      !!--------------------------------------------------------------------
[11541]244      !!                  ***  ROUTINE isf_tbl_top  ***
[11395]245      !!
246      !! ** Purpose : compute top level of the isf top boundary layer in case of an ice shelf parametrisation
247      !!
[11403]248      !!--------------------------------------------------------------------
[11395]249      !!-------------------------- OUT -------------------------------------
[11403]250      INTEGER,  DIMENSION(jpi,jpj), INTENT(  out) :: ktop        ! top level affected by the ice shelf parametrisation
[11395]251      !!-------------------------- IN  -------------------------------------
[11403]252      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: pdep        ! top depth of the parametrisation influence
253      !!--------------------------------------------------------------------
[11395]254      INTEGER :: ji,jj
255      INTEGER :: ikt
[11403]256      !!--------------------------------------------------------------------
257      !
[11395]258      ! compute top level (need to be recomputed each time (z*, z~)
259      ! be sure pdep is already correctly bounded
260      ! test: this routine run on isfdraft should return mikt
261      ! test: this routine run with pdep = 0 should return 1
[11403]262      !
[11395]263      DO ji = 1, jpi
264         DO jj = 1, jpj
265            ikt = 2
266            DO WHILE ( gdepw_n(ji,jj,ikt) <= pdep(ji,jj ) ) ;  ikt = ikt + 1 ;  END DO
267            ktop(ji,jj) = ikt - 1
268         END DO
269      END DO
270      !
[11541]271   END SUBROUTINE isf_tbl_ktop
[11395]272
273END MODULE isftbl
Note: See TracBrowser for help on using the repository browser.