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/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/TRP – NEMO

source: NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/TRP/trcsbc.F90 @ 14644

Last change on this file since 14644 was 14644, checked in by sparonuz, 3 years ago

Merge trunk -r14642:HEAD

  • Property svn:keywords set to Id
File size: 10.2 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 par_trc        ! need jptra, number of passive tracers
19   USE oce_trc         ! ocean dynamics and active tracers variables
20   USE trc             ! ocean  passive tracers variables
21   USE prtctl          ! Print control for debbuging
22   USE iom
23   USE trd_oce
24   USE trdtra
25
26   IMPLICIT NONE
27   PRIVATE
28
29   PUBLIC   trc_sbc   ! routine called by step.F90
30
31   !! * Substitutions
32#  include "do_loop_substitute.h90"
33#  include "domzgr_substitute.h90"
34#  include "single_precision_substitute.h90"
35   !!----------------------------------------------------------------------
36   !! NEMO/TOP 4.0 , NEMO Consortium (2018)
37   !! $Id$
38   !! Software governed by the CeCILL license (see ./LICENSE)
39   !!----------------------------------------------------------------------
40CONTAINS
41
42   SUBROUTINE trc_sbc ( kt, Kmm, ptr, Krhs )
43      !!----------------------------------------------------------------------
44      !!                  ***  ROUTINE trc_sbc  ***
45      !!                   
46      !! ** Purpose :   Compute the tracer surface boundary condition trend of
47      !!      (concentration/dilution effect) and add it to the general
48      !!       trend of tracer equations.
49      !!
50      !! ** Method :
51      !!      * concentration/dilution effect:
52      !!            The surface freshwater flux modify the ocean volume
53      !!         and thus the concentration of a tracer as :
54      !!            tr(Krhs) = tr(Krhs) + emp * tr(Kmm) / e3t_   for k=1
55      !!         where emp, the surface freshwater budget (evaporation minus
56      !!         precipitation ) given in kg/m2/s is divided
57      !!         by 1035 kg/m3 (density of ocean water) to obtain m/s.
58      !!
59      !! ** Action  : - Update the 1st level of tr(:,:,:,:,Krhs) with the trend associated
60      !!                with the tracer surface boundary condition
61      !!
62      !!----------------------------------------------------------------------
63      INTEGER,                                    INTENT(in   ) :: kt        ! ocean time-step index
64      INTEGER,                                    INTENT(in   ) :: Kmm, Krhs ! time level indices
65      REAL(dp), DIMENSION(jpi,jpj,jpk,jptra,jpt), INTENT(inout) :: ptr       ! passive tracers and RHS of tracer equation
66      !
67      INTEGER  ::   ji, jj, jn                      ! dummy loop indices
68      REAL(wp) ::   zse3t, zrtrn, zfact     ! local scalars
69      REAL(wp) ::   zftra, zdtra, ztfx, ztra   !   -      -
70      CHARACTER (len=22) :: charout
71      REAL(wp), DIMENSION(jpi,jpj)   ::   zsfx
72      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   ztrtrd
73      !!---------------------------------------------------------------------
74      !
75      IF( ln_timing )   CALL timing_start('trc_sbc')
76      !
77      ! Allocate temporary workspace
78      IF( l_trdtrc )  ALLOCATE( ztrtrd(jpi,jpj,jpk) )
79      !
80      zrtrn = 1.e-15_wp
81
82      IF( kt == nittrc000 ) THEN
83         IF(lwp) WRITE(numout,*)
84         IF(lwp) WRITE(numout,*) 'trc_sbc : Passive tracers surface boundary condition'
85         IF(lwp) WRITE(numout,*) '~~~~~~~ '
86         !
87         IF( ln_rsttr .AND. .NOT.ln_top_euler .AND.   &                     ! Restart: read in restart  file
88            iom_varid( numrtr, 'sbc_'//TRIM(ctrcnm(1))//'_b', ldstop = .FALSE. ) > 0 ) THEN
89            IF(lwp) WRITE(numout,*) '          nittrc000-1 surface tracer content forcing fields read in the restart file'
90            zfact = 0.5_wp
91            DO jn = 1, jptra
92               CALL iom_get( numrtr, jpdom_auto, 'sbc_'//TRIM(ctrcnm(jn))//'_b', sbc_trc_b(:,:,jn) )   ! before tracer content sbc
93            END DO
94         ELSE                                         ! No restart or restart not found: Euler forward time stepping
95           zfact = 1._wp
96           sbc_trc_b(:,:,:) = 0._wp
97         ENDIF
98      ELSE                                         ! Swap of forcing fields
99         IF( ln_top_euler ) THEN
100            zfact = 1._wp
101            sbc_trc_b(:,:,:) = 0._wp
102         ELSE
103            zfact = 0.5_wp
104            sbc_trc_b(:,:,:) = sbc_trc(:,:,:)
105         ENDIF
106         !
107      ENDIF
108
109      ! Coupling online : river runoff is added to the horizontal divergence (hdiv) in the subroutine sbc_rnf_div
110      ! one only consider the concentration/dilution effect due to evaporation minus precipitation + freezing/melting of sea-ice
111      ! Coupling offline : runoff are in emp which contains E-P-R
112      !
113      IF( .NOT.ln_linssh ) THEN  ! online coupling with vvl
114         zsfx(:,:) = 0._wp
115      ELSE                                      ! online coupling free surface or offline with free surface
116         zsfx(:,:) = emp(:,:)
117      ENDIF
118
119      ! 0. initialization
120      SELECT CASE ( nn_ice_tr )
121
122      CASE ( -1 ) ! No tracers in sea ice (null concentration in sea ice)
123         !
124         DO jn = 1, jptra
125            DO_2D( 0, 0, 0, 1 )
126               sbc_trc(ji,jj,jn) = zsfx(ji,jj) * r1_rho0 * ptr(ji,jj,1,jn,Kmm)
127            END_2D
128         END DO
129         !
130      CASE ( 0 )  ! Same concentration in sea ice and in the ocean
131         !
132         DO jn = 1, jptra
133            DO_2D( 0, 0, 0, 1 )
134               sbc_trc(ji,jj,jn) = ( zsfx(ji,jj) + fmmflx(ji,jj) ) * r1_rho0 * ptr(ji,jj,1,jn,Kmm)
135            END_2D
136         END DO
137         !
138      CASE ( 1 )  ! Specific treatment of sea ice fluxes with an imposed concentration in sea ice
139         !
140         DO jn = 1, jptra
141            DO_2D( 0, 0, 0, 1 )
142               zse3t = 1. / e3t(ji,jj,1,Kmm)
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_rho0 * ( ztfx + ( zsfx(ji,jj) + fmmflx(ji,jj) ) * ptr(ji,jj,1,jn,Kmm) ) 
151               IF ( zdtra < 0. ) THEN
152                  zdtra  = MAX(zdtra, -ptr(ji,jj,1,jn,Kmm) * e3t(ji,jj,1,Kmm) / rDt_trc )   ! avoid negative concentrations to arise
153               ENDIF
154               sbc_trc(ji,jj,jn) =  zdtra 
155            END_2D
156         END DO
157      END SELECT
158      !
159      CALL lbc_lnk( 'trcsbc', sbc_trc(:,:,:), 'T', 1.0_wp )
160      !                                       Concentration dilution effect on tracers due to evaporation & precipitation
161      DO jn = 1, jptra
162         !
163         IF( l_trdtrc )   ztrtrd(:,:,:) = ptr(:,:,:,jn,Krhs)  ! save trends
164         !
165         DO_2D( 0, 0, 0, 1 )
166            zse3t = zfact / e3t(ji,jj,1,Kmm)
167            ptr(ji,jj,1,jn,Krhs) = ptr(ji,jj,1,jn,Krhs) + ( sbc_trc_b(ji,jj,jn) + sbc_trc(ji,jj,jn) ) * zse3t
168         END_2D
169         !
170         IF( l_trdtrc ) THEN
171            ztrtrd(:,:,:) = ptr(:,:,:,jn,Krhs) - ztrtrd(:,:,:)
172            CALL trd_tra( kt, Kmm, Krhs, 'TRC', jn, jptra_nsr, ztrtrd )
173         END IF
174         !                                                       ! ===========
175      END DO                                                     ! tracer loop
176      !                                                          ! ===========
177      !
178      !                                           Write in the tracer restar  file
179      !                                          *******************************
180      IF( lrst_trc .AND. .NOT.ln_top_euler ) THEN
181         IF(lwp) WRITE(numout,*)
182         IF(lwp) WRITE(numout,*) 'sbc : ocean surface tracer content forcing fields written in tracer restart file ',   &
183            &                    'at it= ', kt,' date= ', ndastp
184         IF(lwp) WRITE(numout,*) '~~~~'
185         DO jn = 1, jptra
186            CALL iom_rstput( kt, nitrst, numrtw, 'sbc_'//TRIM(ctrcnm(jn))//'_b', sbc_trc(:,:,jn) )
187         END DO
188      ENDIF
189      !
190      IF( sn_cfctl%l_prttrc )   THEN
191         WRITE(charout, FMT="('sbc ')") ;  CALL prt_ctl_info( charout, cdcomp = 'top' )
192                                           CALL prt_ctl( tab4d_1=CASTWP(ptr(:,:,:,:,Krhs)), mask1=tmask, clinfo=ctrcnm, clinfo3='trd' )
193      ENDIF
194      IF( l_trdtrc )  DEALLOCATE( ztrtrd )
195      !
196      IF( ln_timing )   CALL timing_stop('trc_sbc')
197      !
198   END SUBROUTINE trc_sbc
199
200#else
201   !!----------------------------------------------------------------------
202   !!   Dummy module :                      NO passive tracer
203   !!----------------------------------------------------------------------
204   USE par_oce
205   USE par_trc
206CONTAINS
207   SUBROUTINE trc_sbc ( kt, Kmm, ptr, Krhs )      ! Empty routine
208      INTEGER,                                    INTENT(in   ) :: kt        ! ocean time-step index
209      INTEGER,                                    INTENT(in   ) :: Kmm, Krhs ! time level indices
210      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra,jpt), INTENT(inout) :: ptr       ! passive tracers and RHS of tracer equation
211      WRITE(*,*) 'trc_sbc: You should not have seen this print! error?', kt
212   END SUBROUTINE trc_sbc
213#endif
214   
215   !!======================================================================
216END MODULE trcsbc
Note: See TracBrowser for help on using the repository browser.