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.
trcsbc.F90 in NEMO/branches/2021/dev_r14318_RK3_stage1/src/TOP/TRP – NEMO

source: NEMO/branches/2021/dev_r14318_RK3_stage1/src/TOP/TRP/trcsbc.F90 @ 15574

Last change on this file since 15574 was 15574, checked in by techene, 3 years ago

#2605 #2715 trunk merged into dev_r14318_RK3_stage1

  • Property svn:keywords set to Id
File size: 19.4 KB
Line 
1MODULE trcsbc
2   !!==============================================================================
3   !!                       ***  MODULE  trcsbc  ***
4   !! Ocean passive tracers:  surface boundary condition
5   !!======================================================================
6   !! History :  8.2  !  1998-10  (G. Madec, G. Roullet, M. Imbard)  Original code
7   !!            8.2  !  2001-02  (D. Ludicone)  sea ice and free surface
8   !!            8.5  !  2002-06  (G. Madec)  F90: Free form and module
9   !!            9.0  !  2004-03  (C. Ethe)  adapted for passive tracers
10   !!                 !  2006-08  (C. Deltel) Diagnose ML trends for passive tracers
11   !!==============================================================================
12#if defined key_top
13   !!----------------------------------------------------------------------
14   !!   'key_top'                                                TOP models
15   !!----------------------------------------------------------------------
16   !!   trc_sbc      : update the tracer trend at ocean surface
17   !!----------------------------------------------------------------------
18   USE par_trc        ! need jptra, number of passive tracers
19   USE oce_trc        ! ocean dynamics and active tracers variables
20   USE trc            ! ocean  passive tracers variables
21   USE prtctl         ! Print control for debbuging
22   USE iom
23   USE trd_oce
24   USE trdtra
25
26   IMPLICIT NONE
27   PRIVATE
28
29   PUBLIC   trc_sbc       ! routine called by trctrp.F90
30   PUBLIC   trc_sbc_RK3   ! routine called by stprk3_stg.F90
31
32   !! * Substitutions
33#  include "do_loop_substitute.h90"
34#  include "domzgr_substitute.h90"
35   !!----------------------------------------------------------------------
36   !! NEMO/TOP 4.0 , NEMO Consortium (2018)
37   !! $Id$
38   !! Software governed by the CeCILL license (see ./LICENSE)
39   !!----------------------------------------------------------------------
40CONTAINS
41
42   SUBROUTINE trc_sbc ( kt, Kmm, ptr, Krhs )
43      !!----------------------------------------------------------------------
44      !!                  ***  ROUTINE trc_sbc  ***
45      !!                   
46      !! ** Purpose :   Compute the tracer surface boundary condition trend of
47      !!      (concentration/dilution effect) and add it to the general
48      !!       trend of tracer equations.
49      !!
50      !! ** Method :
51      !!      * concentration/dilution effect:
52      !!            The surface freshwater flux modify the ocean volume
53      !!         and thus the concentration of a tracer as :
54      !!            tr(Krhs) = tr(Krhs) + emp * tr(Kmm) / e3t_ + fmmflx * tri / e3t   for k=1
55      !!          - tr(Kmm) , the concentration of tracer in the ocean
56      !!          - tri, the concentration of tracer in the sea-ice
57      !!          - emp, the surface freshwater budget (evaporation minus precipitation + fmmflx)
58      !!            given in kg/m2/s is divided by 1035 kg/m3 (density of ocean water) to obtain m/s.
59      !!          - fmmflx, the flux asscociated to freezing-melting of sea-ice
60      !!            In linear free surface case (ln_linssh=T), the volume of the
61      !!            ocean does not change with the water exchanges at the (air+ice)-sea
62      !!
63      !! ** Action  : - Update the 1st level of tr(:,:,:,:,Krhs) with the trend associated
64      !!                with the tracer surface boundary condition
65      !!
66      !!----------------------------------------------------------------------
67      INTEGER,                                    INTENT(in   ) :: kt        ! ocean time-step index
68      INTEGER,                                    INTENT(in   ) :: Kmm, Krhs ! time level indices
69      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra,jpt), INTENT(inout) :: ptr       ! passive tracers and RHS of tracer equation
70      !
71      INTEGER  ::   ji, jj, jn                      ! dummy loop indices
72      REAL(wp) ::   zse3t, zrtrn, zfact     ! local scalars
73      REAL(wp) ::   zdtra          !   -      -
74      CHARACTER (len=22) :: charout
75      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   ztrtrd
76      !!---------------------------------------------------------------------
77      !
78      IF( ln_timing )   CALL timing_start('trc_sbc')
79      !
80      ! Allocate temporary workspace
81      IF( l_trdtrc )  ALLOCATE( ztrtrd(jpi,jpj,jpk) )
82      !
83      zrtrn = 1.e-15_wp
84
85      IF( kt == nittrc000 ) THEN
86         IF(lwp) WRITE(numout,*)
87         IF(lwp) WRITE(numout,*) 'trc_sbc : Passive tracers surface boundary condition'
88         IF(lwp) WRITE(numout,*) '~~~~~~~ '
89         !
90         IF( ln_rsttr .AND. .NOT.ln_top_euler .AND.   &                     ! Restart: read in restart  file
91            iom_varid( numrtr, 'sbc_'//TRIM(ctrcnm(1))//'_b', ldstop = .FALSE. ) > 0 ) THEN
92            IF(lwp) WRITE(numout,*) '          nittrc000-1 surface tracer content forcing fields read in the restart file'
93            zfact = 0.5_wp
94            DO jn = 1, jptra
95               CALL iom_get( numrtr, jpdom_auto, 'sbc_'//TRIM(ctrcnm(jn))//'_b', sbc_trc_b(:,:,jn) )   ! before tracer content sbc
96            END DO
97         ELSE                                         ! No restart or restart not found: Euler forward time stepping
98           zfact = 1._wp
99           sbc_trc_b(:,:,:) = 0._wp
100         ENDIF
101      ELSE                                         ! Swap of forcing fields
102         IF( ln_top_euler ) THEN
103            zfact = 1._wp
104            sbc_trc_b(:,:,:) = 0._wp
105         ELSE
106            zfact = 0.5_wp
107            sbc_trc_b(:,:,:) = sbc_trc(:,:,:)
108         ENDIF
109         !
110      ENDIF
111
112      ! 0. initialization
113      SELECT CASE ( nn_ice_tr )
114
115      CASE ( -1 ) ! ! No tracers in sea ice ( trc_i = 0 )
116         !
117         DO jn = 1, jptra
118            DO_2D( 0, 0, 0, 1 )
119               sbc_trc(ji,jj,jn) = 0._wp
120            END_2D
121         END DO
122         !
123         IF( ln_linssh ) THEN  !* linear free surface 
124            DO jn = 1, jptra
125               DO_2D( 0, 0, 0, 1 )
126                  sbc_trc(ji,jj,jn) = sbc_trc(ji,jj,jn) + r1_rho0 * emp(ji,jj) * ptr(ji,jj,1,jn,Kmm) !==>> add concentration/dilution effect due to constant volume cell
127               END_2D
128            END DO
129         ENDIF
130         !
131      CASE ( 0 )  ! Same concentration in sea ice and in the ocean ( trc_i = ptr(...,Kmm)  )
132         !
133         DO jn = 1, jptra
134            DO_2D( 0, 0, 0, 1 )
135               sbc_trc(ji,jj,jn) = - fmmflx(ji,jj) * r1_rho0 * ptr(ji,jj,1,jn,Kmm)
136            END_2D
137         END DO
138         !
139         IF( ln_linssh ) THEN  !* linear free surface 
140            DO jn = 1, jptra
141               DO_2D( 0, 0, 0, 1 )
142                  sbc_trc(ji,jj,jn) = sbc_trc(ji,jj,jn) + r1_rho0 * emp(ji,jj) * ptr(ji,jj,1,jn,Kmm) !==>> add concentration/dilution effect due to constant volume cell
143               END_2D
144            END DO
145         ENDIF
146         !
147      CASE ( 1 )  ! Specific treatment of sea ice fluxes with an imposed concentration in sea ice
148         !
149         DO jn = 1, jptra
150            DO_2D( 0, 0, 0, 1 )
151               sbc_trc(ji,jj,jn) = - fmmflx(ji,jj) * r1_rho0 * trc_i(ji,jj,jn)
152            END_2D
153         END DO
154         !
155         IF( ln_linssh ) THEN  !* linear free surface 
156            DO jn = 1, jptra
157               DO_2D( 0, 0, 0, 1 )
158                  sbc_trc(ji,jj,jn) = sbc_trc(ji,jj,jn) + r1_rho0 * emp(ji,jj) * ptr(ji,jj,1,jn,Kmm) !==>> add concentration/dilution effect due to constant volume cell
159               END_2D
160            END DO
161         ENDIF
162         !
163         DO jn = 1, jptra
164            DO_2D( 0, 0, 0, 1 )
165               zse3t = rDt_trc / e3t(ji,jj,1,Kmm)
166               zdtra = ptr(ji,jj,1,jn,Kmm) + sbc_trc(ji,jj,jn) * zse3t 
167               IF( zdtra < 0. ) sbc_trc(ji,jj,jn) = MAX( zdtra, -ptr(ji,jj,1,jn,Kmm) / zse3t  ) ! avoid negative concentration that can occurs if trc_i > ptr
168            END_2D
169         END DO
170         !                             
171      END SELECT
172      !
173      CALL lbc_lnk( 'trcsbc', sbc_trc(:,:,:), 'T', 1.0_wp )
174      !                                       Concentration dilution effect on tracers due to evaporation & precipitation
175      DO jn = 1, jptra
176         !
177         IF( l_trdtrc )   ztrtrd(:,:,:) = ptr(:,:,:,jn,Krhs)  ! save trends
178         !
179         DO_2D( 0, 0, 0, 1 )
180            zse3t = zfact / e3t(ji,jj,1,Kmm)
181            ptr(ji,jj,1,jn,Krhs) = ptr(ji,jj,1,jn,Krhs) + ( sbc_trc_b(ji,jj,jn) + sbc_trc(ji,jj,jn) ) * zse3t
182         END_2D
183         !
184         IF( l_trdtrc ) THEN
185            ztrtrd(:,:,:) = ptr(:,:,:,jn,Krhs) - ztrtrd(:,:,:)
186            CALL trd_tra( kt, Kmm, Krhs, 'TRC', jn, jptra_nsr, ztrtrd )
187         END IF
188         !                                                       ! ===========
189      END DO                                                     ! tracer loop
190      !                                                          ! ===========
191      !
192      !                                           Write in the tracer restar  file
193      !                                          *******************************
194      IF( lrst_trc .AND. .NOT.ln_top_euler ) THEN
195         IF(lwp) WRITE(numout,*)
196         IF(lwp) WRITE(numout,*) 'sbc : ocean surface tracer content forcing fields written in tracer restart file ',   &
197            &                    'at it= ', kt,' date= ', ndastp
198         IF(lwp) WRITE(numout,*) '~~~~'
199         DO jn = 1, jptra
200            CALL iom_rstput( kt, nitrst, numrtw, 'sbc_'//TRIM(ctrcnm(jn))//'_b', sbc_trc(:,:,jn) )
201         END DO
202      ENDIF
203      !
204      IF( sn_cfctl%l_prttrc )   THEN
205         WRITE(charout, FMT="('sbc ')") ;  CALL prt_ctl_info( charout, cdcomp = 'top' )
206                                           CALL prt_ctl( tab4d_1=ptr(:,:,:,:,Krhs), mask1=tmask, clinfo=ctrcnm, clinfo3='trd' )
207      ENDIF
208      IF( l_trdtrc )  DEALLOCATE( ztrtrd )
209      !
210      IF( ln_timing )   CALL timing_stop('trc_sbc')
211      !
212   END SUBROUTINE trc_sbc
213
214
215   SUBROUTINE trc_sbc_RK3 ( kt, Kmm, ptr, Krhs, kstg )
216      !!----------------------------------------------------------------------
217      !!                  ***  ROUTINE trc_sbc_RK3  ***
218      !!                   
219      !! ** Purpose :   Compute the tracer surface boundary condition trend of
220      !!      (concentration/dilution effect) and add it to the general
221      !!       trend of tracer equations.
222      !!
223      !! ** Method :
224      !!      * concentration/dilution effect:
225      !!            The surface freshwater flux modify the ocean volume
226      !!         and thus the concentration of a tracer as :
227      !!            tr(Krhs) = tr(Krhs) + emp * tr(Kmm) / e3t_   for k=1
228      !!         where emp, the surface freshwater budget (evaporation minus
229      !!         precipitation ) given in kg/m2/s is divided
230      !!         by 1035 kg/m3 (density of ocean water) to obtain m/s.
231      !!
232      !! ** Action  : - Update the 1st level of tr(:,:,:,:,Krhs) with the trend associated
233      !!                with the tracer surface boundary condition
234      !!
235      !!----------------------------------------------------------------------
236      INTEGER                                   , INTENT(in   ) ::   kt, Kmm, Krhs   ! ocean time-step and time-level indices
237      INTEGER                                   , INTENT(in   ) ::   kstg            ! RK3 stage index
238      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra,jpt), INTENT(inout) ::   ptr       ! passive tracers and RHS of tracer equation
239      !
240      INTEGER  ::   ji, jj, jn           ! dummy loop indices
241      REAL(wp) ::   z1_rho0_e3t          ! local scalars
242      REAL(wp) ::   zftra, zdtra, ztfx   !   -      -
243      CHARACTER (len=22) :: charout
244      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   ztrtrd
245      !!---------------------------------------------------------------------
246      !
247      IF( ln_timing )   CALL timing_start('trc_sbc_RK3')
248      !
249      IF( kt == nittrc000 ) THEN
250         IF(lwp) WRITE(numout,*)
251         IF(lwp) WRITE(numout,*) 'trc_sbc_RK3 : Passive tracers surface boundary condition'
252         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ '
253      ENDIF
254      !
255!!st note that trc_sbc can be removed only re-use in atf (not relevant for RK3)
256      SELECT CASE( kstg )
257         !
258      CASE( 1 , 2 )                       !=  stage 1 and 2  =!   only in non linear ssh
259         !
260         IF( .NOT.ln_linssh ) THEN           !* only passive tracer fluxes associated with mass fluxes
261            !                                        ! no passive tracer concentration modification due to ssh variation
262!!st emp includes fmm see iceupdate.F90
263!!not sure about trc_i case... (1)
264            DO jn = 1, jptra
265               DO_2D( 0, 0, 0, 0 )              !!st WHY 1 : exterior here ?
266                  z1_rho0_e3t = r1_rho0 / e3t(ji,jj,1,Kmm)
267                  ptr(ji,jj,1,jn,Krhs) = ptr(ji,jj,1,jn,Krhs) - emp(ji,jj) * ptr(ji,jj,1,jn,Kmm) * z1_rho0_e3t
268               END_2D
269            END DO
270            !
271         ENDIF
272         !
273      CASE( 3 )
274         !
275         ! Allocate temporary workspace
276         IF( l_trdtrc )  ALLOCATE( ztrtrd(jpi,jpj,jpk) )
277         !
278         DO jn = 1, jptra
279            IF( l_trdtrc )   ztrtrd(:,:,:) = ptr(:,:,:,jn,Krhs)  ! save trends
280         END DO
281         !
282         IF( ln_linssh ) THEN                !* linear free surface (add concentration/dilution effect artificially since no volume variation)
283            !
284            SELECT CASE ( nn_ice_tr )
285               !
286            CASE ( -1 ) ! No tracers in sea ice (null concentration in sea ice)
287               !
288               DO jn = 1, jptra
289                  DO_2D( 0, 0, 0, 0 )
290                     z1_rho0_e3t = r1_rho0  / e3t(ji,jj,1,Kmm)
291                     ptr(ji,jj,1,jn,Krhs) = ptr(ji,jj,1,jn,Krhs) + emp(ji,jj) * r1_rho0 * ptr(ji,jj,1,jn,Kmm)
292                  END_2D
293               END DO
294               !
295            CASE ( 0 )  ! Same concentration in sea ice and in the ocean fmm contribution to concentration/dilution effect has to be removed
296               !
297               DO jn = 1, jptra
298                  DO_2D( 0, 0, 0, 1 )
299                     z1_rho0_e3t = r1_rho0  / e3t(ji,jj,1,Kmm)
300                     ptr(ji,jj,1,jn,Krhs) = ptr(ji,jj,1,jn,Krhs) + ( emp(ji,jj) - fmmflx(ji,jj) ) * r1_rho0 * ptr(ji,jj,1,jn,Kmm)
301                  END_2D
302               END DO
303               !
304            CASE ( 1 )  ! Specific treatment of sea ice fluxes with an imposed concentration in sea ice !!st TODO : check Christian new implementation
305               !
306               DO jn = 1, jptra
307                  DO_2D( 0, 0, 0, 0 )
308                     z1_rho0_e3t = r1_rho0  / e3t(ji,jj,1,Kmm)
309                     ! tracer flux at the ice/ocean interface (tracer/m2/s)
310                     zftra = - trc_i(ji,jj,jn) * fmmflx(ji,jj) ! uptake of tracer in the sea ice
311                     !                                         ! only used in the levitating sea ice case
312                     ! tracer flux only       : add concentration dilution term in net tracer flux, no F-M in volume flux
313                     ! tracer and mass fluxes : no concentration dilution term in net tracer flux, F-M term in volume flux
314                     ztfx  = zftra                        ! net tracer flux
315                     !
316                     zdtra = r1_rho0 * ( ztfx +  ( emp(ji,jj) - fmmflx(ji,jj) ) * ptr(ji,jj,1,jn,Kmm) ) 
317                     IF ( zdtra < 0. ) THEN
318                        zdtra  = MAX(zdtra, -ptr(ji,jj,1,jn,Kmm) * e3t(ji,jj,1,Kmm) / rDt_trc )   ! avoid negative concentrations to arise
319                     ENDIF
320                     ptr(ji,jj,1,jn,Krhs) = ptr(ji,jj,1,jn,Krhs) + zdtra
321                  END_2D
322               END DO
323               !
324            END SELECT
325            !
326         ELSE                                !* non linear free surface (concentration/dilution effect due to volume variation)
327            !
328            SELECT CASE ( nn_ice_tr )
329            ! CASE ( -1 ) natural concentration/dilution effect due to volume variation : nothing to do
330            !
331            CASE ( 0 )  ! Same concentration in sea ice and in the ocean : correct concentration/dilution effect due to "freezing - melting"
332               !
333               DO jn = 1, jptra
334                  DO_2D( 0, 0, 0, 1 )
335                     z1_rho0_e3t = r1_rho0  / e3t(ji,jj,1,Kmm)
336                     ptr(ji,jj,1,jn,Krhs) = ptr(ji,jj,1,jn,Krhs) - fmmflx(ji,jj) * r1_rho0 * ptr(ji,jj,1,jn,Kmm)
337                  END_2D
338               END DO
339               !
340            CASE ( 1 )  ! Specific treatment of sea ice fluxes with an imposed concentration in sea ice
341               !
342               DO jn = 1, jptra
343                  DO_2D( 0, 0, 0, 0 )
344                     ! tracer flux at the ice/ocean interface (tracer/m2/s)
345                     zftra = - trc_i(ji,jj,jn) * fmmflx(ji,jj) ! uptake of tracer in the sea ice
346                     !                                         ! only used in the levitating sea ice case
347                     ! tracer flux only       : add concentration dilution term in net tracer flux, no F-M in volume flux
348                     ! tracer and mass fluxes : no concentration dilution term in net tracer flux, F-M term in volume flux
349                     ztfx  = zftra                        ! net tracer flux
350                     !
351                     zdtra = r1_rho0 * ( ztfx -  fmmflx(ji,jj) * ptr(ji,jj,1,jn,Kmm) ) 
352                     IF ( zdtra < 0. ) THEN
353                        zdtra  = MAX(zdtra, -ptr(ji,jj,1,jn,Kmm) * e3t(ji,jj,1,Kmm) / rDt_trc )   ! avoid negative concentrations to arise
354                     ENDIF
355                     ptr(ji,jj,1,jn,Krhs) = ptr(ji,jj,1,jn,Krhs) + zdtra
356                  END_2D
357               END DO
358               !
359            END SELECT
360            !
361         ENDIF
362         !
363         !
364!!st useless trc_sbc only in the interior even in MLF case         CALL lbc_lnk( 'trcsbc', sbc_trc(:,:,:), 'T', 1.0_wp )
365         !                                       Concentration dilution effect on tracers due to evaporation & precipitation
366         DO jn = 1, jptra
367            !
368            IF(lwp) WRITE(numout,*)
369            IF(lwp) WRITE(numout,*) 'trc_sbc_RK3 : Runge Kutta 3rd order at stage ', kstg, jn
370            IF(lwp) WRITE(numout,*)
371            !
372            IF( l_trdtrc ) THEN
373               ztrtrd(:,:,:) = ptr(:,:,:,jn,Krhs) - ztrtrd(:,:,:)
374               CALL trd_tra( kt, Kmm, Krhs, 'TRC', jn, jptra_nsr, ztrtrd )
375            END IF
376            !
377         END DO
378         !
379         IF( l_trdtrc )  DEALLOCATE( ztrtrd )
380         !
381      END SELECT
382      !
383      IF( sn_cfctl%l_prttrc )   THEN
384         WRITE(charout, FMT="('sbc ')") ;  CALL prt_ctl_info( charout, cdcomp = 'top' )
385                                           CALL prt_ctl( tab4d_1=ptr(:,:,:,:,Krhs), mask1=tmask, clinfo=ctrcnm, clinfo3='trd' )
386      ENDIF
387      !
388      IF( ln_timing )   CALL timing_stop('trc_sbc_RK3')
389      !
390   END SUBROUTINE trc_sbc_RK3
391
392
393#else
394   !!----------------------------------------------------------------------
395   !!   Dummy module :                      NO passive tracer
396   !!----------------------------------------------------------------------
397   USE par_oce
398   USE par_trc
399CONTAINS
400   SUBROUTINE trc_sbc ( kt, Kmm, ptr, Krhs )      ! Empty routine
401      INTEGER,                                    INTENT(in   ) :: kt        ! ocean time-step index
402      INTEGER,                                    INTENT(in   ) :: Kmm, Krhs ! time level indices
403      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra,jpt), INTENT(inout) :: ptr       ! passive tracers and RHS of tracer equation
404      WRITE(*,*) 'trc_sbc: You should not have seen this print! error?', kt
405   END SUBROUTINE trc_sbc
406#endif
407   
408   !!======================================================================
409END MODULE trcsbc
Note: See TracBrowser for help on using the repository browser.