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 branches/2015/nemo_v3_6_STABLE/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: branches/2015/nemo_v3_6_STABLE/NEMOGCM/NEMO/TOP_SRC/TRP/trcrad.F90 @ 7494

Last change on this file since 7494 was 7494, checked in by timgraham, 7 years ago

Addition of extra diagnostic outputs in CMIP6 data request. NB. Will require update to field_def file from shaconemo

  • Property svn:keywords set to Id
File size: 9.5 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 trc                 ! ocean passive tracers variables
17   USE trd_oce
18   USE trdtra
19   USE prtctl_trc          ! Print control for debbuging
20
21   IMPLICIT NONE
22   PRIVATE
23
24   PUBLIC trc_rad         ! routine called by trcstp.F90
25
26   !! * Substitutions
27#  include "top_substitute.h90"
28   !!----------------------------------------------------------------------
29   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
30   !! $Id$
31   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
32   !!----------------------------------------------------------------------
33   
34CONTAINS
35
36   SUBROUTINE trc_rad( kt )
37      !!----------------------------------------------------------------------
38      !!                  ***  ROUTINE trc_rad  ***
39      !!
40      !! ** Purpose :   "crappy" routine to correct artificial negative
41      !!              concentrations due to isopycnal scheme
42      !!
43      !! ** Method  : - PISCES or LOBSTER: Set negative concentrations to zero
44      !!                while computing the corresponding tracer content that
45      !!                is added to the tracers. Then, adjust the tracer
46      !!                concentration using a multiplicative factor so that
47      !!                the total tracer concentration is preserved.
48      !!              - CFC: simply set to zero the negative CFC concentration
49      !!                (the total CFC content is not strictly preserved)
50      !!----------------------------------------------------------------------
51      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index     
52      CHARACTER (len=22) :: charout
53      !!----------------------------------------------------------------------
54      !
55      IF( nn_timing == 1 )  CALL timing_start('trc_rad')
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_age     )   CALL trc_rad_sms( kt, trb, trn, jp_age0 , jp_age1               )  ! AGE tracer
64      IF( lk_cfc     )   CALL trc_rad_sms( kt, trb, trn, jp_cfc0 , jp_cfc1               )  ! CFC model
65      IF( lk_c14b    )   CALL trc_rad_sms( kt, trb, trn, jp_c14b0, jp_c14b1              )  ! bomb C14
66      IF( lk_pisces  )   CALL trc_rad_sms( kt, trb, trn, jp_pcs0 , jp_pcs1, cpreserv='Y' )  ! PISCES model
67      IF( lk_my_trc  )   CALL trc_rad_sms( kt, trb, trn, jp_myt0 , jp_myt1               )  ! MY_TRC model
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      IF( nn_timing == 1 )  CALL timing_stop('trc_rad')
77      !
78   END SUBROUTINE trc_rad
79
80   SUBROUTINE trc_rad_sms( kt, ptrb, ptrn, jp_sms0, jp_sms1, cpreserv )
81      !!-----------------------------------------------------------------------------
82      !!                  ***  ROUTINE trc_rad_sms  ***
83      !!
84      !! ** Purpose :   "crappy" routine to correct artificial negative
85      !!              concentrations due to isopycnal scheme
86      !!
87      !! ** Method  : 2 cases :
88      !!                - Set negative concentrations to zero while computing
89      !!                  the corresponding tracer content that is added to the
90      !!                  tracers. Then, adjust the tracer concentration using
91      !!                  a multiplicative factor so that the total tracer
92      !!                  concentration is preserved.
93      !!                - simply set to zero the negative CFC concentration
94      !!                  (the total content of concentration is not strictly preserved)
95      !!--------------------------------------------------------------------------------
96      !! Arguments
97      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
98      INTEGER  , INTENT( in ) ::  &
99         jp_sms0, &       !: First index of the passive tracer model
100         jp_sms1          !: Last  index of  the passive tracer model
101
102      REAL(wp), DIMENSION (jpi,jpj,jpk,jptra), INTENT( inout )  :: &
103         ptrb, ptrn       !: before and now traceur concentration
104
105      CHARACTER( len = 1) , INTENT(in), OPTIONAL  :: &
106         cpreserv          !: flag to preserve content or not
107     
108      ! Local declarations
109      INTEGER  :: ji, jj, jk, jn     ! dummy loop indices
110      REAL(wp) :: ztrcorb, ztrmasb   ! temporary scalars
111      REAL(wp) :: zcoef, ztrcorn, ztrmasn   !    "         "
112      REAL(wp), POINTER, DIMENSION(:,:,:) ::   ztrtrdb, ztrtrdn   ! workspace arrays
113      REAL(wp) :: zs2rdt
114      LOGICAL ::   lldebug = .FALSE.
115      !!----------------------------------------------------------------------
116
117 
118      IF( l_trdtrc )  CALL wrk_alloc( jpi, jpj, jpk, ztrtrdb, ztrtrdn )
119     
120      IF( PRESENT( cpreserv )  ) THEN   !  total tracer concentration is preserved
121     
122         DO jn = jp_sms0, jp_sms1
123            !                                                        ! ===========
124            ztrcorb = 0.e0   ;   ztrmasb = 0.e0
125            ztrcorn = 0.e0   ;   ztrmasn = 0.e0
126
127            IF( l_trdtrc ) THEN
128               ztrtrdb(:,:,:) = ptrb(:,:,:,jn)                        ! save input trb for trend computation
129               ztrtrdn(:,:,:) = ptrn(:,:,:,jn)                        ! save input trn for trend computation
130            ENDIF
131            !                                                         ! sum over the global domain
132            ztrcorb = glob_sum( MIN( 0., ptrb(:,:,:,jn) ) * cvol(:,:,:) )
133            ztrcorn = glob_sum( MIN( 0., ptrn(:,:,:,jn) ) * cvol(:,:,:) )
134
135            ztrmasb = glob_sum( MAX( 0., ptrb(:,:,:,jn) ) * cvol(:,:,:) )
136            ztrmasn = glob_sum( MAX( 0., ptrn(:,:,:,jn) ) * cvol(:,:,:) )
137
138            IF( ztrcorb /= 0 ) THEN
139               zcoef = 1. + ztrcorb / ztrmasb
140               DO jk = 1, jpkm1
141                  ptrb(:,:,jk,jn) = MAX( 0., ptrb(:,:,jk,jn) )
142                  ptrb(:,:,jk,jn) = ptrb(:,:,jk,jn) * zcoef * tmask(:,:,jk)
143               END DO
144            ENDIF
145
146            IF( ztrcorn /= 0 ) THEN
147               zcoef = 1. + ztrcorn / ztrmasn
148               DO jk = 1, jpkm1
149                  ptrn(:,:,jk,jn) = MAX( 0., ptrn(:,:,jk,jn) )
150                  ptrn(:,:,jk,jn) = ptrn(:,:,jk,jn) * zcoef * tmask(:,:,jk)
151               END DO
152            ENDIF
153            !
154            IF( l_trdtrc ) THEN
155               !
156               zs2rdt = 1. / ( 2. * rdt )
157               ztrtrdb(:,:,:) = ( ptrb(:,:,:,jn) - ztrtrdb(:,:,:) ) * zs2rdt
158               ztrtrdn(:,:,:) = ( ptrn(:,:,:,jn) - ztrtrdn(:,:,:) ) * zs2rdt 
159               CALL trd_tra( kt, 'TRC', jn, jptra_radb, ztrtrdb )       ! Asselin-like trend handling
160               CALL trd_tra( kt, 'TRC', jn, jptra_radn, ztrtrdn )       ! standard     trend handling
161              !
162            ENDIF
163
164         END DO
165         !
166         !
167      ELSE  ! total CFC content is not strictly preserved
168
169         DO jn = jp_sms0, jp_sms1 
170
171           IF( l_trdtrc ) THEN
172              ztrtrdb(:,:,:) = ptrb(:,:,:,jn)                        ! save input trb for trend computation
173              ztrtrdn(:,:,:) = ptrn(:,:,:,jn)                        ! save input trn for trend computation
174           ENDIF
175
176            DO jk = 1, jpkm1
177               DO jj = 1, jpj
178                  DO ji = 1, jpi
179                     ptrn(ji,jj,jk,jn) = MAX( 0. , ptrn(ji,jj,jk,jn) )
180                     ptrb(ji,jj,jk,jn) = MAX( 0. , ptrb(ji,jj,jk,jn) )
181                  END DO
182               END DO
183            END DO
184         
185            IF( l_trdtrc ) THEN
186               !
187               zs2rdt = 1. / ( 2. * rdt * FLOAT( nn_dttrc ) )
188               ztrtrdb(:,:,:) = ( ptrb(:,:,:,jn) - ztrtrdb(:,:,:) ) * zs2rdt
189               ztrtrdn(:,:,:) = ( ptrn(:,:,:,jn) - ztrtrdn(:,:,:) ) * zs2rdt 
190               CALL trd_tra( kt, 'TRC', jn, jptra_radb, ztrtrdb )       ! Asselin-like trend handling
191               CALL trd_tra( kt, 'TRC', jn, jptra_radn, ztrtrdn )       ! standard     trend handling
192              !
193            ENDIF
194            !
195         ENDDO
196
197      ENDIF
198
199      IF( l_trdtrc )  CALL wrk_dealloc( jpi, jpj, jpk, ztrtrdb, ztrtrdn )
200
201   END SUBROUTINE trc_rad_sms
202#else
203   !!----------------------------------------------------------------------
204   !!   Dummy module :                                         NO TOP model
205   !!----------------------------------------------------------------------
206CONTAINS
207   SUBROUTINE trc_rad( kt )              ! Empty routine
208      INTEGER, INTENT(in) ::   kt
209      WRITE(*,*) 'trc_rad: You should not have seen this print! error?', kt
210   END SUBROUTINE trc_rad
211#endif
212   
213   !!======================================================================
214END MODULE trcrad
Note: See TracBrowser for help on using the repository browser.