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/2017/dev_merge_2017/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: branches/2017/dev_merge_2017/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc.F90 @ 9019

Last change on this file since 9019 was 9019, checked in by timgraham, 6 years ago

Merge of dev_CNRS_2017 into branch

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