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 branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc.F90 @ 8754

Last change on this file since 8754 was 8754, checked in by cbricaud, 6 years ago

bugfix for coarsening branch

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