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/releases/release-4.0/src/TOP/TRP – NEMO

source: NEMO/releases/release-4.0/src/TOP/TRP/trcsbc.F90 @ 10780

Last change on this file since 10780 was 10780, checked in by aumont, 5 years ago

bug fixes corresponding to tickets #2262

  • Property svn:keywords set to Id
File size: 9.7 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   for k=1
52      !!         where emp, the surface freshwater budget (evaporation minus
53      !!         precipitation ) given in kg/m2/s is divided
54      !!         by 1035 kg/m3 (density of ocean water) to obtain m/s.
55      !!
56      !! ** Action  : - Update the 1st level of tra with the trend associated
57      !!                with the tracer surface boundary condition
58      !!
59      !!----------------------------------------------------------------------
60      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
61      !
62      INTEGER  ::   ji, jj, jn                      ! dummy loop indices
63      REAL(wp) ::   zse3t, zrtrn, zfact     ! local scalars
64      REAL(wp) ::   zftra, zdtra, ztfx, ztra   !   -      -
65      CHARACTER (len=22) :: charout
66      REAL(wp), DIMENSION(jpi,jpj)   ::   zsfx
67      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   ztrtrd
68      !!---------------------------------------------------------------------
69      !
70      IF( ln_timing )   CALL timing_start('trc_sbc')
71      !
72      ! Allocate temporary workspace
73      IF( l_trdtrc )  ALLOCATE( ztrtrd(jpi,jpj,jpk) )
74      !
75      zrtrn = 1.e-15_wp
76
77      IF( kt == nittrc000 ) THEN
78         IF(lwp) WRITE(numout,*)
79         IF(lwp) WRITE(numout,*) 'trc_sbc : Passive tracers surface boundary condition'
80         IF(lwp) WRITE(numout,*) '~~~~~~~ '
81         !
82         IF( ln_rsttr .AND. .NOT.ln_top_euler .AND.   &                     ! Restart: read in restart  file
83            iom_varid( numrtr, 'sbc_'//TRIM(ctrcnm(1))//'_b', ldstop = .FALSE. ) > 0 ) THEN
84            IF(lwp) WRITE(numout,*) '          nittrc000-nn_dttrc surface tracer content forcing fields red in the restart file'
85            zfact = 0.5_wp
86            DO jn = 1, jptra
87               CALL iom_get( numrtr, jpdom_autoglo, 'sbc_'//TRIM(ctrcnm(jn))//'_b', sbc_trc_b(:,:,jn) )   ! before tracer content sbc
88            END DO
89         ELSE                                         ! No restart or restart not found: Euler forward time stepping
90           zfact = 1._wp
91           sbc_trc_b(:,:,:) = 0._wp
92         ENDIF
93      ELSE                                         ! Swap of forcing fields
94         IF( ln_top_euler ) THEN
95            zfact = 1._wp
96            sbc_trc_b(:,:,:) = 0._wp
97         ELSE
98            zfact = 0.5_wp
99            sbc_trc_b(:,:,:) = sbc_trc(:,:,:)
100         ENDIF
101         !
102      ENDIF
103
104      ! Coupling online : river runoff is added to the horizontal divergence (hdivn) in the subroutine sbc_rnf_div
105      ! one only consider the concentration/dilution effect due to evaporation minus precipitation + freezing/melting of sea-ice
106      ! Coupling offline : runoff are in emp which contains E-P-R
107      !
108      IF( .NOT.ln_linssh ) THEN  ! online coupling with vvl
109         zsfx(:,:) = 0._wp
110      ELSE                                      ! online coupling free surface or offline with free surface
111         zsfx(:,:) = emp(:,:)
112      ENDIF
113
114      ! 0. initialization
115      SELECT CASE ( nn_ice_tr )
116
117      CASE ( -1 ) ! No tracers in sea ice (null concentration in sea ice)
118         !
119         DO jn = 1, jptra
120            DO jj = 2, jpj
121               DO ji = fs_2, fs_jpim1   ! vector opt.
122                  sbc_trc(ji,jj,jn) = zsfx(ji,jj) * r1_rau0 * trn(ji,jj,1,jn)
123               END DO
124            END DO
125         END DO
126         !
127      CASE ( 0 )  ! Same concentration in sea ice and in the ocean
128         !
129         DO jn = 1, jptra
130            DO jj = 2, jpj
131               DO ji = fs_2, fs_jpim1   ! vector opt.
132                  sbc_trc(ji,jj,jn) = ( zsfx(ji,jj) + fmmflx(ji,jj) ) * r1_rau0 * trn(ji,jj,1,jn)
133               END DO
134            END DO
135         END DO
136         !
137      CASE ( 1 )  ! Specific treatment of sea ice fluxes with an imposed concentration in sea ice
138         !
139         DO jn = 1, jptra
140            DO jj = 2, jpj
141               DO ji = fs_2, fs_jpim1   ! vector opt.
142                  zse3t = 1. / e3t_n(ji,jj,1)
143                  ! tracer flux at the ice/ocean interface (tracer/m2/s)
144                  zftra = - trc_i(ji,jj,jn) * fmmflx(ji,jj) ! uptake of tracer in the sea ice
145                  !                                         ! only used in the levitating sea ice case
146                  ! tracer flux only       : add concentration dilution term in net tracer flux, no F-M in volume flux
147                  ! tracer and mass fluxes : no concentration dilution term in net tracer flux, F-M term in volume flux
148                  ztfx  = zftra                        ! net tracer flux
149                  !
150                  zdtra = r1_rau0 * ( ztfx + ( zsfx(ji,jj) + fmmflx(ji,jj) ) * trn(ji,jj,1,jn) ) 
151                  IF ( zdtra < 0. ) THEN
152                     zdtra  = MAX(zdtra, -trn(ji,jj,1,jn) * e3t_n(ji,jj,1) / r2dttrc )   ! avoid negative concentrations to arise
153                  ENDIF
154                  sbc_trc(ji,jj,jn) =  zdtra 
155               END DO
156            END DO
157         END DO
158      END SELECT
159      !
160      CALL lbc_lnk( 'trcsbc', sbc_trc(:,:,:), 'T', 1. )
161      !                                       Concentration dilution effect on tracers due to evaporation & precipitation
162      DO jn = 1, jptra
163         !
164         IF( l_trdtrc )   ztrtrd(:,:,:) = tra(:,:,:,jn)  ! save trends
165         !
166         DO jj = 2, jpj
167            DO ji = fs_2, fs_jpim1   ! vector opt.
168               zse3t = zfact / e3t_n(ji,jj,1)
169               tra(ji,jj,1,jn) = tra(ji,jj,1,jn) + ( sbc_trc_b(ji,jj,jn) + sbc_trc(ji,jj,jn) ) * zse3t
170            END DO
171         END DO
172         !
173         IF( l_trdtrc ) THEN
174            ztrtrd(:,:,:) = tra(:,:,:,jn) - ztrtrd(:,:,:)
175            CALL trd_tra( kt, 'TRC', jn, jptra_nsr, ztrtrd )
176         END IF
177         !                                                       ! ===========
178      END DO                                                     ! tracer loop
179      !                                                          ! ===========
180      !
181      !                                           Write in the tracer restar  file
182      !                                          *******************************
183      IF( lrst_trc .AND. .NOT.ln_top_euler ) THEN
184         IF(lwp) WRITE(numout,*)
185         IF(lwp) WRITE(numout,*) 'sbc : ocean surface tracer content forcing fields written in tracer restart file ',   &
186            &                    'at it= ', kt,' date= ', ndastp
187         IF(lwp) WRITE(numout,*) '~~~~'
188         DO jn = 1, jptra
189            CALL iom_rstput( kt, nitrst, numrtw, 'sbc_'//TRIM(ctrcnm(jn))//'_b', sbc_trc(:,:,jn) )
190         END DO
191      ENDIF
192      !
193      IF( ln_ctl )   THEN
194         WRITE(charout, FMT="('sbc ')") ;  CALL prt_ctl_trc_info(charout)
195                                           CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
196      ENDIF
197      IF( l_trdtrc )  DEALLOCATE( ztrtrd )
198      !
199      IF( ln_timing )   CALL timing_stop('trc_sbc')
200      !
201   END SUBROUTINE trc_sbc
202
203#else
204   !!----------------------------------------------------------------------
205   !!   Dummy module :                      NO passive tracer
206   !!----------------------------------------------------------------------
207CONTAINS
208   SUBROUTINE trc_sbc (kt)              ! Empty routine
209      INTEGER, INTENT(in) :: kt
210      WRITE(*,*) 'trc_sbc: You should not have seen this print! error?', kt
211   END SUBROUTINE trc_sbc
212#endif
213   
214   !!======================================================================
215END MODULE trcsbc
Note: See TracBrowser for help on using the repository browser.