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
RevLine 
[941]1MODULE trcsbc
2   !!==============================================================================
3   !!                       ***  MODULE  trcsbc  ***
4   !! Ocean passive tracers:  surface boundary condition
[1175]5   !!======================================================================
[2528]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
[941]11   !!==============================================================================
12#if defined key_top
13   !!----------------------------------------------------------------------
14   !!   'key_top'                                                TOP models
15   !!----------------------------------------------------------------------
16   !!   trc_sbc      : update the tracer trend at ocean surface
17   !!----------------------------------------------------------------------
[14086]18   USE par_trc        ! need jptra, number of passive tracers
[2715]19   USE oce_trc         ! ocean dynamics and active tracers variables
20   USE trc             ! ocean  passive tracers variables
[13286]21   USE prtctl          ! Print control for debbuging
[5385]22   USE iom
[4990]23   USE trd_oce
[2528]24   USE trdtra
[941]25
26   IMPLICIT NONE
27   PRIVATE
28
[2715]29   PUBLIC   trc_sbc   ! routine called by step.F90
[941]30
31   !! * Substitutions
[12377]32#  include "do_loop_substitute.h90"
[13237]33#  include "domzgr_substitute.h90"
[14219]34#  include "single_precision_substitute.h90"
[941]35   !!----------------------------------------------------------------------
[10067]36   !! NEMO/TOP 4.0 , NEMO Consortium (2018)
[7753]37   !! $Id$
[10068]38   !! Software governed by the CeCILL license (see ./LICENSE)
[941]39   !!----------------------------------------------------------------------
40CONTAINS
41
[12377]42   SUBROUTINE trc_sbc ( kt, Kmm, ptr, Krhs )
[941]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 :
[13237]54      !!            tr(Krhs) = tr(Krhs) + emp * tr(Kmm) / e3t_   for k=1
[941]55      !!         where emp, the surface freshwater budget (evaporation minus
[3680]56      !!         precipitation ) given in kg/m2/s is divided
[1739]57      !!         by 1035 kg/m3 (density of ocean water) to obtain m/s.
[941]58      !!
[12377]59      !! ** Action  : - Update the 1st level of tr(:,:,:,:,Krhs) with the trend associated
[941]60      !!                with the tracer surface boundary condition
61      !!
62      !!----------------------------------------------------------------------
[12377]63      INTEGER,                                    INTENT(in   ) :: kt        ! ocean time-step index
64      INTEGER,                                    INTENT(in   ) :: Kmm, Krhs ! time level indices
[14219]65      REAL(dp), DIMENSION(jpi,jpj,jpk,jptra,jpt), INTENT(inout) :: ptr       ! passive tracers and RHS of tracer equation
[2715]66      !
[9019]67      INTEGER  ::   ji, jj, jn                      ! dummy loop indices
[10788]68      REAL(wp) ::   zse3t, zrtrn, zfact     ! local scalars
69      REAL(wp) ::   zftra, zdtra, ztfx, ztra   !   -      -
[941]70      CHARACTER (len=22) :: charout
[9125]71      REAL(wp), DIMENSION(jpi,jpj)   ::   zsfx
72      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   ztrtrd
[3294]73      !!---------------------------------------------------------------------
74      !
[9124]75      IF( ln_timing )   CALL timing_start('trc_sbc')
[3294]76      !
77      ! Allocate temporary workspace
[9125]78      IF( l_trdtrc )  ALLOCATE( ztrtrd(jpi,jpj,jpk) )
[5385]79      !
80      zrtrn = 1.e-15_wp
[941]81
[3294]82      IF( kt == nittrc000 ) THEN
[941]83         IF(lwp) WRITE(numout,*)
84         IF(lwp) WRITE(numout,*) 'trc_sbc : Passive tracers surface boundary condition'
85         IF(lwp) WRITE(numout,*) '~~~~~~~ '
[9019]86         !
[6942]87         IF( ln_rsttr .AND. .NOT.ln_top_euler .AND.   &                     ! Restart: read in restart  file
[5385]88            iom_varid( numrtr, 'sbc_'//TRIM(ctrcnm(1))//'_b', ldstop = .FALSE. ) > 0 ) THEN
[12377]89            IF(lwp) WRITE(numout,*) '          nittrc000-1 surface tracer content forcing fields read in the restart file'
[5385]90            zfact = 0.5_wp
91            DO jn = 1, jptra
[13286]92               CALL iom_get( numrtr, jpdom_auto, 'sbc_'//TRIM(ctrcnm(jn))//'_b', sbc_trc_b(:,:,jn) )   ! before tracer content sbc
[5385]93            END DO
94         ELSE                                         ! No restart or restart not found: Euler forward time stepping
95           zfact = 1._wp
[7753]96           sbc_trc_b(:,:,:) = 0._wp
[5385]97         ENDIF
98      ELSE                                         ! Swap of forcing fields
99         IF( ln_top_euler ) THEN
100            zfact = 1._wp
[7753]101            sbc_trc_b(:,:,:) = 0._wp
[5385]102         ELSE
103            zfact = 0.5_wp
[7753]104            sbc_trc_b(:,:,:) = sbc_trc(:,:,:)
[5385]105         ENDIF
106         !
[941]107      ENDIF
108
[12377]109      ! Coupling online : river runoff is added to the horizontal divergence (hdiv) in the subroutine sbc_rnf_div
[3680]110      ! one only consider the concentration/dilution effect due to evaporation minus precipitation + freezing/melting of sea-ice
[3719]111      ! Coupling offline : runoff are in emp which contains E-P-R
112      !
[7646]113      IF( .NOT.ln_linssh ) THEN  ! online coupling with vvl
[7753]114         zsfx(:,:) = 0._wp
[3719]115      ELSE                                      ! online coupling free surface or offline with free surface
[7753]116         zsfx(:,:) = emp(:,:)
[3680]117      ENDIF
[2528]118
[941]119      ! 0. initialization
[10788]120      SELECT CASE ( nn_ice_tr )
121
122      CASE ( -1 ) ! No tracers in sea ice (null concentration in sea ice)
[2528]123         !
[10425]124         DO jn = 1, jptra
[14644]125            DO_2D( 0, 0, 0, 1 )
[12489]126               sbc_trc(ji,jj,jn) = zsfx(ji,jj) * r1_rho0 * ptr(ji,jj,1,jn,Kmm)
[12377]127            END_2D
[10425]128         END DO
129         !
[10788]130      CASE ( 0 )  ! Same concentration in sea ice and in the ocean
[10425]131         !
132         DO jn = 1, jptra
[14644]133            DO_2D( 0, 0, 0, 1 )
[12489]134               sbc_trc(ji,jj,jn) = ( zsfx(ji,jj) + fmmflx(ji,jj) ) * r1_rho0 * ptr(ji,jj,1,jn,Kmm)
[12377]135            END_2D
[10788]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
[14644]141            DO_2D( 0, 0, 0, 1 )
[12377]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               !
[12489]150               zdtra = r1_rho0 * ( ztfx + ( zsfx(ji,jj) + fmmflx(ji,jj) ) * ptr(ji,jj,1,jn,Kmm) ) 
[12377]151               IF ( zdtra < 0. ) THEN
[12489]152                  zdtra  = MAX(zdtra, -ptr(ji,jj,1,jn,Kmm) * e3t(ji,jj,1,Kmm) / rDt_trc )   ! avoid negative concentrations to arise
[12377]153               ENDIF
154               sbc_trc(ji,jj,jn) =  zdtra 
155            END_2D
[10425]156         END DO
[10788]157      END SELECT
[10425]158      !
[13226]159      CALL lbc_lnk( 'trcsbc', sbc_trc(:,:,:), 'T', 1.0_wp )
[10425]160      !                                       Concentration dilution effect on tracers due to evaporation & precipitation
161      DO jn = 1, jptra
[6309]162         !
[12377]163         IF( l_trdtrc )   ztrtrd(:,:,:) = ptr(:,:,:,jn,Krhs)  ! save trends
[10425]164         !
[14644]165         DO_2D( 0, 0, 0, 1 )
[12377]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
[5385]169         !
[1175]170         IF( l_trdtrc ) THEN
[12377]171            ztrtrd(:,:,:) = ptr(:,:,:,jn,Krhs) - ztrtrd(:,:,:)
172            CALL trd_tra( kt, Kmm, Krhs, 'TRC', jn, jptra_nsr, ztrtrd )
[1175]173         END IF
174         !                                                       ! ===========
175      END DO                                                     ! tracer loop
176      !                                                          ! ===========
[9019]177      !
[5385]178      !                                           Write in the tracer restar  file
179      !                                          *******************************
[6942]180      IF( lrst_trc .AND. .NOT.ln_top_euler ) THEN
[5385]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      !
[12377]190      IF( sn_cfctl%l_prttrc )   THEN
[13286]191         WRITE(charout, FMT="('sbc ')") ;  CALL prt_ctl_info( charout, cdcomp = 'top' )
[14219]192                                           CALL prt_ctl( tab4d_1=CASTWP(ptr(:,:,:,:,Krhs)), mask1=tmask, clinfo=ctrcnm, clinfo3='trd' )
[941]193      ENDIF
[9125]194      IF( l_trdtrc )  DEALLOCATE( ztrtrd )
[3294]195      !
[9124]196      IF( ln_timing )   CALL timing_stop('trc_sbc')
[3294]197      !
[941]198   END SUBROUTINE trc_sbc
199
200#else
201   !!----------------------------------------------------------------------
202   !!   Dummy module :                      NO passive tracer
203   !!----------------------------------------------------------------------
[12377]204   USE par_oce
205   USE par_trc
[941]206CONTAINS
[12377]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
[941]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.