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.
trcrad.F90 in trunk/NEMO/TOP_SRC/TRP – NEMO

source: trunk/NEMO/TOP_SRC/TRP/trcrad.F90 @ 1193

Last change on this file since 1193 was 1193, checked in by cetlod, 16 years ago

Correction of transport module to ensure reproductibility for TOP configurations, see ticket:253

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 9.3 KB
Line 
1MODULE trcrad
2   !!======================================================================
3   !!                       ***  MODULE  trcrad  ***
4   !! Ocean passive tracers:  correction of negative concentrations
5   !!======================================================================
6   !! History :   -   !  01-01  (O. Aumont & E. Kestenare)  Original code
7   !!            1.0  !  04-03  (C. Ethe)  free form F90
8   !!----------------------------------------------------------------------
9#if defined key_top
10   !!----------------------------------------------------------------------
11   !!   'key_top'                                                TOP models
12   !!----------------------------------------------------------------------
13   !!   trc_rad    : correction of negative concentrations
14   !!----------------------------------------------------------------------
15   USE oce_trc             ! ocean dynamics and tracers variables
16   USE trp_trc             ! ocean passive tracers variables
17   USE trctrp_lec , ONLY : ln_trcadv_tvd, ln_trcadv_cen2
18   USE trdmld_trc
19   USE trdmld_trc_oce
20   USE lib_mpp
21   USE prtctl_trc          ! Print control for debbuging
22
23   IMPLICIT NONE
24   PRIVATE
25
26   PUBLIC trc_rad        ! routine called by trcstp.F90
27
28   !! * Substitutions
29#  include "top_substitute.h90"
30   !!----------------------------------------------------------------------
31   !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005)
32   !! $Id$
33   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
34   !!----------------------------------------------------------------------
35   
36CONTAINS
37
38   SUBROUTINE trc_rad( kt )
39      !!----------------------------------------------------------------------
40      !!                  ***  ROUTINE trc_rad  ***
41      !!
42      !! ** Purpose :   "crappy" routine to correct artificial negative
43      !!              concentrations due to isopycnal scheme
44      !!
45      !! ** Method  : - PISCES or LOBSTER: Set negative concentrations to zero
46      !!                while computing the corresponding tracer content that
47      !!                is added to the tracers. Then, adjust the tracer
48      !!                concentration using a multiplicative factor so that
49      !!                the total tracer concentration is preserved.
50      !!              - CFC: simply set to zero the negative CFC concentration
51      !!                (the total CFC content is not strictly preserved)
52      !!----------------------------------------------------------------------
53      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index     
54      CHARACTER (len=22) :: charout
55      !!----------------------------------------------------------------------
56
57      IF( kt == nittrc000 ) THEN
58         IF(lwp) WRITE(numout,*)
59         IF(lwp) WRITE(numout,*) 'trc_rad : Correct artificial negative concentrations '
60         IF(lwp) WRITE(numout,*) '~~~~~~~ '
61      ENDIF
62
63      IF( lk_cfc     )   CALL trc_rad_sms( kt, trb, trn, jp_cfc0, jp_cfc1               ) ! CFC model
64      IF( lk_lobster )   CALL trc_rad_sms( kt, trb, trn, jp_lob0, jp_lob1, cpreserv='Y' )  ! LOBSTER model
65      IF( lk_pisces  )   CALL trc_rad_sms( kt, trb, trn, jp_pcs0, jp_pcs1, cpreserv='Y' )  ! PISCES model
66      IF( lk_my_trc  )   CALL trc_rad_sms( kt, trb, trn, jp_myt0, jp_myt1               ) ! MY_TRC model
67
68
69      !
70      IF(ln_ctl) THEN      ! print mean trends (used for debugging)
71         WRITE(charout, FMT="('rad')")
72         CALL prt_ctl_trc_info( charout )
73         CALL prt_ctl_trc( tab4d=trn, mask=tmask, clinfo=ctrcnm )
74      ENDIF
75      !
76   END SUBROUTINE trc_rad
77
78   SUBROUTINE trc_rad_sms( kt, ptrb, ptrn, jp_sms0, jp_sms1, cpreserv )
79      !!-----------------------------------------------------------------------------
80      !!                  ***  ROUTINE trc_rad_sms  ***
81      !!
82      !! ** Purpose :   "crappy" routine to correct artificial negative
83      !!              concentrations due to isopycnal scheme
84      !!
85      !! ** Method  : 2 cases :
86      !!                - Set negative concentrations to zero while computing
87      !!                  the corresponding tracer content that is added to the
88      !!                  tracers. Then, adjust the tracer concentration using
89      !!                  a multiplicative factor so that the total tracer
90      !!                  concentration is preserved.
91      !!                - simply set to zero the negative CFC concentration
92      !!                  (the total content of concentration is not strictly preserved)
93      !!--------------------------------------------------------------------------------
94      !! Arguments
95      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
96      INTEGER  , INTENT( in ) ::  &
97         jp_sms0, &       !: First index of the passive tracer model
98         jp_sms1          !: Last  index of  the passive tracer model
99
100      REAL(wp), DIMENSION (jpi,jpj,jpk,jptra), INTENT( inout )  :: &
101         ptrb, ptrn       !: before and now traceur concentration
102
103      CHARACTER( len = 1) , INTENT(in), OPTIONAL  :: &
104         cpreserv          !: flag to preserve content or not
105     
106      ! Local declarations
107      INTEGER  ::  ji, jj, jk, jn     ! dummy loop indices
108      REAL(wp) :: zvolk, ztrcorb, ztrmasb   ! temporary scalars
109      REAL(wp) :: zcoef, ztrcorn, ztrmasn   !    "         "
110      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrtrdb  ! workspace arrays
111      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrtrdn  ! workspace arrays
112      LOGICAL ::   lldebug = .FALSE.
113
114      !!----------------------------------------------------------------------
115
116      IF( l_trdtrc ) THEN
117        !
118        ALLOCATE( ztrtrdb(jpi,jpj,jpk) )
119        ALLOCATE( ztrtrdn(jpi,jpj,jpk) )
120        !
121      ENDIF
122     
123      IF( PRESENT( cpreserv )  ) THEN   !  total tracer concentration is preserved
124     
125         DO jn = jp_sms0, jp_sms1
126         !                                                        ! ===========
127            ztrcorb = 0.e0   ;   ztrmasb = 0.e0
128            ztrcorn = 0.e0   ;   ztrmasn = 0.e0
129
130           IF( l_trdtrc ) THEN
131              ztrtrdb(:,:,:) = ptrb(:,:,:,jn)                        ! save input trb for trend computation
132              ztrtrdn(:,:,:) = ptrn(:,:,:,jn)                        ! save input trn for trend computation
133           ENDIF
134
135
136            DO jk = 1, jpkm1
137               DO jj = 1, jpj
138                  DO ji = 1, jpi
139                     zvolk  = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk)   &
140# if defined key_off_degrad
141                        &   * facvol(ji,jj,jk)   &
142# endif
143                        &   * tmask(ji,jj,jk) * tmask_i(ji,jj)
144
145                     ztrcorb = ztrcorb + MIN( 0., ptrb(ji,jj,jk,jn) )  * zvolk
146                     ztrcorn = ztrcorn + MIN( 0., ptrn(ji,jj,jk,jn) )  * zvolk
147
148                     ptrb(ji,jj,jk,jn) = MAX( 0. , ptrb(ji,jj,jk,jn) )
149                     ptrn(ji,jj,jk,jn) = MAX( 0. , ptrn(ji,jj,jk,jn) )
150
151                     ztrmasb = ztrmasb + ptrb(ji,jj,jk,jn) * zvolk
152                     ztrmasn = ztrmasn + ptrn(ji,jj,jk,jn) * zvolk
153                  END DO
154               END DO
155            END DO
156
157            IF( lk_mpp ) THEN
158               CALL mpp_sum( ztrcorb )      ! sum over the global domain
159               CALL mpp_sum( ztrcorn )      ! sum over the global domain
160               CALL mpp_sum( ztrmasb )      ! sum over the global domain
161               CALL mpp_sum( ztrmasn )      ! sum over the global domain
162            ENDIF
163
164            IF( ztrcorb /= 0 ) THEN
165               zcoef = 1. + ztrcorb / ztrmasb
166               DO jk = 1, jpkm1
167                  ptrb(:,:,jk,jn) = ptrb(:,:,jk,jn) * zcoef * tmask(:,:,jk)
168               END DO
169            ENDIF
170
171            IF( ztrcorn /= 0 ) THEN
172               zcoef = 1. + ztrcorn / ztrmasn
173               DO jk = 1, jpkm1
174                  ptrn(:,:,jk,jn) = ptrn(:,:,jk,jn) * zcoef * tmask(:,:,jk)
175               END DO
176            ENDIF
177            !
178            IF( l_trdtrc ) THEN
179               !
180               ztrtrdb(:,:,:) = ( ptrb(:,:,:,jn) - ztrtrdb(:,:,:) ) / (2.*rdt)
181               ztrtrdn(:,:,:) = ( ptrn(:,:,:,jn) - ztrtrdn(:,:,:) ) / (2.*rdt)
182               IF (luttrd(jn)) CALL trd_mod_trc( ztrtrdb, jn, jptrc_trd_radb, kt )       ! Asselin-like trend handling
183               IF (luttrd(jn)) CALL trd_mod_trc( ztrtrdn, jn, jptrc_trd_radn, kt )       ! standard     trend handling
184              !
185            ENDIF
186
187         END DO
188         !
189         !
190      ELSE  ! total CFC content is not strictly preserved
191
192         DO jn = jp_sms0, jp_sms1 
193            DO jk = 1, jpkm1
194               DO jj = 1, jpj
195                  DO ji = 1, jpi
196                     ptrn(ji,jj,jk,jn) = MAX( 0. , ptrn(ji,jj,jk,jn) )
197                     ptrb(ji,jj,jk,jn) = MAX( 0. , ptrb(ji,jj,jk,jn) )
198                  END DO
199               END DO
200            END DO
201         END DO
202
203      ENDIF
204
205      IF( l_trdtrc )   DEALLOCATE( ztrtrdb, ztrtrdn )
206
207   END SUBROUTINE trc_rad_sms
208#else
209   !!----------------------------------------------------------------------
210   !!   Dummy module :                                         NO TOP model
211   !!----------------------------------------------------------------------
212CONTAINS
213   SUBROUTINE trc_rad( kt )              ! Empty routine
214      INTEGER, INTENT(in) ::   kt
215      WRITE(*,*) 'trc_rad: You should not have seen this print! error?', kt
216   END SUBROUTINE trc_rad
217#endif
218   
219   !!======================================================================
220END MODULE trcrad
Note: See TracBrowser for help on using the repository browser.