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/2016/dev_r6519_HPC_4/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: branches/2016/dev_r6519_HPC_4/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc.F90 @ 7037

Last change on this file since 7037 was 7037, checked in by mocavero, 8 years ago

ORCA2_LIM_PISCES hybrid version update

  • Property svn:keywords set to Id
File size: 10.9 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 3.3 , NEMO Consortium (2010)
34   !! $Id$
35   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
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      !
61      INTEGER, INTENT( in ) ::   kt          ! ocean time-step index
62      !
63      INTEGER  ::   ji, jj, jn                                     ! dummy loop indices
64      REAL(wp) ::   zse3t, zrtrn, zratio, zfact                    ! temporary scalars
65      REAL(wp) ::   zswitch, zftra, zcd, zdtra, ztfx, ztra         ! temporary scalars
66      CHARACTER (len=22) :: charout
67      REAL(wp), POINTER, DIMENSION(:,:  ) :: zsfx
68      REAL(wp), POINTER, DIMENSION(:,:,:) :: ztrtrd
69
70      !!---------------------------------------------------------------------
71      !
72      IF( nn_timing == 1 )  CALL timing_start('trc_sbc')
73      !
74      ! Allocate temporary workspace
75                      CALL wrk_alloc( jpi,jpj,       zsfx   )
76      IF( l_trdtrc )  CALL wrk_alloc( jpi,jpj,jpk,   ztrtrd )
77      !
78      zrtrn = 1.e-15_wp
79
80      SELECT CASE( nn_ice_embd )         ! levitating or embedded sea-ice option
81         CASE( 0    )   ;   zswitch = 1  ! (0) standard levitating sea-ice : salt exchange only
82         CASE( 1, 2 )   ;   zswitch = 0  ! (1) levitating sea-ice: salt and volume exchange but no pressure effect                               
83      !                                  ! (2) embedded sea-ice : salt and volume fluxes and pressure
84      END SELECT
85
86      IF( ln_top_euler) THEN
87         r2dt =  rdttrc              ! = rdttrc (use Euler time stepping)
88      ELSE
89         IF( neuler == 0 .AND. kt == nittrc000 ) THEN     ! at nittrc000
90            r2dt = rdttrc            ! = rdttrc (restarting with Euler time stepping)
91         ELSEIF( kt <= nittrc000 + nn_dttrc ) THEN          ! at nittrc000 or nittrc000+1
92            r2dt = 2. * rdttrc       ! = 2 rdttrc (leapfrog)
93         ENDIF
94      ENDIF
95
96
97      IF( kt == nittrc000 ) THEN
98         IF(lwp) WRITE(numout,*)
99         IF(lwp) WRITE(numout,*) 'trc_sbc : Passive tracers surface boundary condition'
100         IF(lwp) WRITE(numout,*) '~~~~~~~ '
101
102         IF( ln_rsttr .AND.    &                     ! Restart: read in restart  file
103            iom_varid( numrtr, 'sbc_'//TRIM(ctrcnm(1))//'_b', ldstop = .FALSE. ) > 0 ) THEN
104            IF(lwp) WRITE(numout,*) '          nittrc000-nn_dttrc surface tracer content forcing fields red in the restart file'
105            zfact = 0.5_wp
106            DO jn = 1, jptra
107               CALL iom_get( numrtr, jpdom_autoglo, 'sbc_'//TRIM(ctrcnm(jn))//'_b', sbc_trc_b(:,:,jn) )   ! before tracer content sbc
108            END DO
109         ELSE                                         ! No restart or restart not found: Euler forward time stepping
110           zfact = 1._wp
111!$OMP PARALLEL WORKSHARE
112           sbc_trc_b(:,:,:) = 0._wp
113!$OMP END PARALLEL WORKSHARE
114         ENDIF
115      ELSE                                         ! Swap of forcing fields
116         IF( ln_top_euler ) THEN
117            zfact = 1._wp
118!$OMP PARALLEL WORKSHARE
119            sbc_trc_b(:,:,:) = 0._wp
120!$OMP END PARALLEL WORKSHARE
121         ELSE
122            zfact = 0.5_wp
123!$OMP PARALLEL WORKSHARE
124            sbc_trc_b(:,:,:) = sbc_trc(:,:,:)
125!$OMP END PARALLEL WORKSHARE
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( .NOT. lk_offline .AND. .NOT.ln_linssh ) THEN  ! online coupling with vvl
135!$OMP PARALLEL WORKSHARE
136         zsfx(:,:) = 0._wp
137!$OMP END PARALLEL WORKSHARE
138      ELSE                                      ! online coupling free surface or offline with free surface
139!$OMP PARALLEL WORKSHARE
140         zsfx(:,:) = emp(:,:)
141!$OMP END PARALLEL WORKSHARE
142      ENDIF
143
144      ! 0. initialization
145      DO jn = 1, jptra
146         !
147         IF( l_trdtrc ) THEN
148!$OMP PARALLEL WORKSHARE
149            ztrtrd(:,:,:) = tra(:,:,:,jn)  ! save trends
150!$OMP END PARALLEL WORKSHARE
151         END IF
152         IF ( nn_ice_tr == -1 ) THEN  ! No tracers in sea ice (null concentration in sea ice)
153
154!$OMP PARALLEL DO schedule(static) private(jj, ji)
155            DO jj = 2, jpj
156               DO ji = fs_2, fs_jpim1   ! vector opt.
157                  sbc_trc(ji,jj,jn) = zsfx(ji,jj) * r1_rau0 * trn(ji,jj,1,jn)
158               END DO
159            END DO
160
161         ELSE
162!$OMP PARALLEL DO schedule(static) private(jj,ji,zse3t,zftra,zcd,ztfx,zdtra,zratio)
163            DO jj = 2, jpj
164               DO ji = fs_2, fs_jpim1   ! vector opt.
165                  zse3t = 1. / e3t_n(ji,jj,1)
166                  ! tracer flux at the ice/ocean interface (tracer/m2/s)
167                  zftra = - trc_i(ji,jj,jn) * fmmflx(ji,jj) ! uptake of tracer in the sea ice
168                  zcd   =   trc_o(ji,jj,jn) * fmmflx(ji,jj) ! concentration dilution due to freezing-melting,
169                                                               ! only used in the levitating sea ice case
170                  ! tracer flux only       : add concentration dilution term in net tracer flux, no F-M in volume flux
171                  ! tracer and mass fluxes : no concentration dilution term in net tracer flux, F-M term in volume flux
172                  ztfx  = zftra + zswitch * zcd                ! net tracer flux (+C/D if no ice/ocean mass exchange)
173   
174                  zdtra = r1_rau0 * ( ztfx + zsfx(ji,jj) * trn(ji,jj,1,jn) ) 
175                  IF ( zdtra < 0. ) THEN
176                     zratio = -zdtra * zse3t * r2dt / ( trn(ji,jj,1,jn) + zrtrn )
177                     zdtra = MIN(1.0, zratio) * zdtra ! avoid negative concentrations to arise
178                  ENDIF
179                  sbc_trc(ji,jj,jn) =  zdtra 
180               END DO
181            END DO
182         ENDIF
183         !
184         CALL lbc_lnk( sbc_trc(:,:,jn), 'T', 1. )
185         !                                       Concentration dilution effect on tracers due to evaporation & precipitation
186!$OMP PARALLEL DO schedule(static) private(jj,ji,zse3t)
187         DO jj = 2, jpj
188            DO ji = fs_2, fs_jpim1   ! vector opt.
189               zse3t = zfact / e3t_n(ji,jj,1)
190               tra(ji,jj,1,jn) = tra(ji,jj,1,jn) + ( sbc_trc_b(ji,jj,jn) + sbc_trc(ji,jj,jn) ) * zse3t
191            END DO
192         END DO
193         !
194         IF( l_trdtrc ) THEN
195!$OMP PARALLEL WORKSHARE
196            ztrtrd(:,:,:) = tra(:,:,:,jn) - ztrtrd(:,:,:)
197!$OMP END PARALLEL WORKSHARE
198            CALL trd_tra( kt, 'TRC', jn, jptra_nsr, ztrtrd )
199         END IF
200         !                                                       ! ===========
201      END DO                                                     ! tracer loop
202      !                                                          ! ===========
203
204      !                                           Write in the tracer restar  file
205      !                                          *******************************
206      IF( lrst_trc ) THEN
207         IF(lwp) WRITE(numout,*)
208         IF(lwp) WRITE(numout,*) 'sbc : ocean surface tracer content forcing fields written in tracer restart file ',   &
209            &                    'at it= ', kt,' date= ', ndastp
210         IF(lwp) WRITE(numout,*) '~~~~'
211         DO jn = 1, jptra
212            CALL iom_rstput( kt, nitrst, numrtw, 'sbc_'//TRIM(ctrcnm(jn))//'_b', sbc_trc(:,:,jn) )
213         END DO
214      ENDIF
215      !
216      IF( ln_ctl )   THEN
217         WRITE(charout, FMT="('sbc ')") ;  CALL prt_ctl_trc_info(charout)
218                                           CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
219      ENDIF
220                      CALL wrk_dealloc( jpi,jpj,       zsfx   )
221      IF( l_trdtrc )  CALL wrk_dealloc( jpi,jpj,jpk,   ztrtrd )
222      !
223      IF( nn_timing == 1 )  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.