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/2020/ticket2487/src/TOP/TRP – NEMO

source: NEMO/branches/2020/ticket2487/src/TOP/TRP/trcsbc.F90 @ 15410

Last change on this file since 15410 was 15410, checked in by smueller, 3 years ago

Synchronizing with /NEMO/releases/r4.0/r4.0-HEAD@15405 (ticket #2487)

  • Property svn:keywords set to Id
File size: 10.3 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 oce_trc         ! ocean dynamics and active tracers variables
19   USE trc             ! ocean  passive tracers variables
20   USE prtctl_trc      ! Print control for debbuging
21   USE iom
22   USE trd_oce
23   USE trdtra
24
25   IMPLICIT NONE
26   PRIVATE
27
28   PUBLIC   trc_sbc   ! routine called by step.F90
29
30   !! * Substitutions
31#  include "vectopt_loop_substitute.h90"
32   !!----------------------------------------------------------------------
33   !! NEMO/TOP 4.0 , NEMO Consortium (2018)
34   !! $Id$
35   !! Software governed by the CeCILL license (see ./LICENSE)
36   !!----------------------------------------------------------------------
37CONTAINS
38
39   SUBROUTINE trc_sbc ( kt )
40      !!----------------------------------------------------------------------
41      !!                  ***  ROUTINE trc_sbc  ***
42      !!                   
43      !! ** Purpose :   Compute the tracer surface boundary condition trend of
44      !!      (concentration/dilution effect) and add it to the general
45      !!       trend of tracer equations.
46      !!
47      !! ** Method :
48      !!      * concentration/dilution effect:
49      !!            The surface freshwater flux modify the ocean volume
50      !!         and thus the concentration of a tracer as :
51      !!            tra = tra + emp * trn / e3t + fmmflx * tri / e3t  for k=1
52      !!         where :
53      !!          - trn, the concentration of tracer in the ocean
54      !!          - tri, the concentration of tracer in the sea-ice
55      !!          - emp, the surface freshwater budget (evaporation minus precipitation + fmmflx)
56      !!            given in kg/m2/s is divided by 1035 kg/m3 (density of ocean water) to obtain m/s.
57      !!          - fmmflx, the flux asscociated to freezing-melting of sea-ice
58      !!            In linear free surface case (ln_linssh=T), the volume of the
59      !!            ocean does not change with the water exchanges at the (air+ice)-sea
60      !!
61      !! ** Action  : - Update the 1st level of tra with the trend associated
62      !!                with the tracer surface boundary condition
63      !!
64      !!----------------------------------------------------------------------
65      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
66      !
67      INTEGER  ::   ji, jj, jn                      ! dummy loop indices
68      REAL(wp) ::   zse3t, zrtrn, zfact     ! local scalars
69      REAL(wp) ::   zdtra          !   -      -
70      CHARACTER (len=22) :: charout
71      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   ztrtrd
72      !!---------------------------------------------------------------------
73      !
74      IF( ln_timing )   CALL timing_start('trc_sbc')
75      !
76      ! Allocate temporary workspace
77      IF( l_trdtrc )  ALLOCATE( ztrtrd(jpi,jpj,jpk) )
78      !
79      zrtrn = 1.e-15_wp
80
81      IF( kt == nittrc000 ) THEN
82         IF(lwp) WRITE(numout,*)
83         IF(lwp) WRITE(numout,*) 'trc_sbc : Passive tracers surface boundary condition'
84         IF(lwp) WRITE(numout,*) '~~~~~~~ '
85         !
86         IF( ln_rsttr .AND. .NOT.ln_top_euler .AND.   &                     ! Restart: read in restart  file
87            iom_varid( numrtr, 'sbc_'//TRIM(ctrcnm(1))//'_b', ldstop = .FALSE. ) > 0 ) THEN
88            IF(lwp) WRITE(numout,*) '          nittrc000-nn_dttrc surface tracer content forcing fields red in the restart file'
89            zfact = 0.5_wp
90            DO jn = 1, jptra
91               CALL iom_get( numrtr, jpdom_autoglo, 'sbc_'//TRIM(ctrcnm(jn))//'_b', sbc_trc_b(:,:,jn) )   ! before tracer content sbc
92            END DO
93         ELSE                                         ! No restart or restart not found: Euler forward time stepping
94           zfact = 1._wp
95           sbc_trc_b(:,:,:) = 0._wp
96         ENDIF
97      ELSE                                         ! Swap of forcing fields
98         IF( ln_top_euler ) THEN
99            zfact = 1._wp
100            sbc_trc_b(:,:,:) = 0._wp
101         ELSE
102            zfact = 0.5_wp
103            sbc_trc_b(:,:,:) = sbc_trc(:,:,:)
104         ENDIF
105         !
106      ENDIF
107
108      ! 0. initialization
109      SELECT CASE ( nn_ice_tr )
110
111      CASE ( -1 ) ! No tracers in sea ice ( trc_i = 0 )
112         !
113         DO jn = 1, jptra
114            DO jj = 2, jpj
115               DO ji = fs_2, fs_jpim1   ! vector opt.
116                  sbc_trc(ji,jj,jn) = 0._wp
117               END DO
118            END DO
119         END DO
120         !
121         IF( ln_linssh ) THEN  !* linear free surface 
122            DO jn = 1, jptra
123               DO jj = 2, jpj
124                  DO ji = fs_2, fs_jpim1   ! vector opt.
125                     sbc_trc(ji,jj,jn) = sbc_trc(ji,jj,jn) + r1_rau0 * emp(ji,jj) * trn(ji,jj,1,jn) !==>> add concentration/dilution effect due to constant volume cell
126                  END DO
127               END DO
128            END DO
129         ENDIF
130         !
131      CASE ( 0 )  ! Same concentration in sea ice and in the ocean ( trc_i = trn )
132         !
133         DO jn = 1, jptra
134            DO jj = 2, jpj
135               DO ji = fs_2, fs_jpim1   ! vector opt.
136                  sbc_trc(ji,jj,jn) = - fmmflx(ji,jj) * r1_rau0 * trn(ji,jj,1,jn)
137               END DO
138            END DO
139         END DO
140         !
141         IF( ln_linssh ) THEN  !* linear free surface 
142            DO jn = 1, jptra
143               DO jj = 2, jpj
144                  DO ji = fs_2, fs_jpim1   ! vector opt.
145                     sbc_trc(ji,jj,jn) = sbc_trc(ji,jj,jn) + r1_rau0 * emp(ji,jj) * trn(ji,jj,1,jn) !==>> add concentration/dilution effect due to constant volume cell
146                  END DO
147               END DO
148            END DO
149         ENDIF
150
151      CASE ( 1 )  ! Specific treatment of sea ice fluxes with an imposed concentration in sea ice
152         !
153         DO jn = 1, jptra
154            DO jj = 2, jpj
155               DO ji = fs_2, fs_jpim1   ! vector opt.
156                  sbc_trc(ji,jj,jn)  = - fmmflx(ji,jj) * r1_rau0 * trc_i(ji,jj,jn)
157               END DO
158            END DO
159         END DO
160         !
161         IF( ln_linssh ) THEN  !* linear free surface 
162            DO jn = 1, jptra
163               DO jj = 2, jpj
164                  DO ji = fs_2, fs_jpim1   ! vector opt.
165                     sbc_trc(ji,jj,jn) = sbc_trc(ji,jj,jn) + r1_rau0 * emp(ji,jj) * trn(ji,jj,1,jn) !==>> add concentration/dilution effect due to constant volume cell
166                  END DO
167               END DO
168            END DO
169         ENDIF
170         !
171         DO jn = 1, jptra
172            DO jj = 2, jpj
173               DO ji = fs_2, fs_jpim1   ! vector opt.
174                  zse3t = r2dttrc / e3t_n(ji,jj,1)
175                  zdtra = trn(ji,jj,1,jn) + sbc_trc(ji,jj,jn) * zse3t 
176                  IF( zdtra < 0. ) sbc_trc(ji,jj,jn) = MAX( zdtra, -trn(ji,jj,1,jn) / zse3t  ) ! avoid negative concentration that can occurs if trc_i > trn                   
177               END DO
178            END DO
179         END DO
180         !                                                       ! ===========
181      END SELECT
182
183      !
184      CALL lbc_lnk( 'trcsbc', sbc_trc(:,:,:), 'T', 1. )
185      !                                       Concentration dilution effect on tracers due to evaporation & precipitation
186      DO jn = 1, jptra
187         !
188         IF( l_trdtrc )   ztrtrd(:,:,:) = tra(:,:,:,jn)  ! save trends
189         !
190         DO jj = 2, jpj
191            DO ji = fs_2, fs_jpim1   ! vector opt.
192               zse3t = zfact / e3t_n(ji,jj,1)
193               tra(ji,jj,1,jn) = tra(ji,jj,1,jn) + ( sbc_trc_b(ji,jj,jn) + sbc_trc(ji,jj,jn) ) * zse3t
194            END DO
195         END DO
196         !
197         IF( l_trdtrc ) THEN
198            ztrtrd(:,:,:) = tra(:,:,:,jn) - ztrtrd(:,:,:)
199            CALL trd_tra( kt, 'TRC', jn, jptra_nsr, ztrtrd )
200         END IF
201         !
202      END DO                                                     ! tracer loop
203      !                                                          ! ===========
204      !
205      !                                           Write in the tracer restar  file
206      !                                          *******************************
207      IF( lrst_trc .AND. .NOT.ln_top_euler ) THEN
208         IF(lwp) WRITE(numout,*)
209         IF(lwp) WRITE(numout,*) 'sbc : ocean surface tracer content forcing fields written in tracer restart file ',   &
210            &                    'at it= ', kt,' date= ', ndastp
211         IF(lwp) WRITE(numout,*) '~~~~'
212         DO jn = 1, jptra
213            CALL iom_rstput( kt, nitrst, numrtw, 'sbc_'//TRIM(ctrcnm(jn))//'_b', sbc_trc(:,:,jn) )
214         END DO
215      ENDIF
216      !
217      IF( ln_ctl )   THEN
218         WRITE(charout, FMT="('sbc ')") ;  CALL prt_ctl_trc_info(charout)
219                                           CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
220      ENDIF
221      IF( l_trdtrc )  DEALLOCATE( ztrtrd )
222      !
223      IF( ln_timing )   CALL timing_stop('trc_sbc')
224      !
225   END SUBROUTINE trc_sbc
226
227#else
228   !!----------------------------------------------------------------------
229   !!   Dummy module :                      NO passive tracer
230   !!----------------------------------------------------------------------
231CONTAINS
232   SUBROUTINE trc_sbc (kt)              ! Empty routine
233      INTEGER, INTENT(in) :: kt
234      WRITE(*,*) 'trc_sbc: You should not have seen this print! error?', kt
235   END SUBROUTINE trc_sbc
236#endif
237   
238   !!======================================================================
239END MODULE trcsbc
Note: See TracBrowser for help on using the repository browser.