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.
trdmod.F90 in tags/nemo_v3_2/nemo_v3_2/NEMO/OPA_SRC/TRD – NEMO

source: tags/nemo_v3_2/nemo_v3_2/NEMO/OPA_SRC/TRD/trdmod.F90 @ 1878

Last change on this file since 1878 was 1878, checked in by flavoni, 14 years ago

initial test for nemogcm

File size: 17.3 KB
Line 
1MODULE trdmod
2   !!======================================================================
3   !!                       ***  MODULE  trdmod  ***
4   !! Ocean diagnostics:  ocean tracers and dynamic trends
5   !!=====================================================================
6   !! History :  9.0  !  04-08  (C. Talandier) Original code
7   !!                 !  05-04  (C. Deltel)    Add Asselin trend in the ML budget
8   !!----------------------------------------------------------------------
9#if  defined key_trdtra || defined key_trddyn || defined key_trdmld || defined key_trdvor || defined key_esopa
10   !!----------------------------------------------------------------------
11   !!   trd_mod          : Call the trend to be computed
12   !!   trd_mod_init     : Initialization step
13   !!----------------------------------------------------------------------
14   USE oce                     ! ocean dynamics and tracers variables
15   USE dom_oce                 ! ocean space and time domain variables
16   USE zdf_oce                 ! ocean vertical physics variables
17   USE trdmod_oce              ! ocean variables trends
18   USE ldftra_oce              ! ocean active tracers lateral physics
19   USE sbc_oce                 ! surface boundary condition: ocean
20   USE phycst                  ! physical constants
21   USE trdvor                  ! ocean vorticity trends
22   USE trdicp                  ! ocean bassin integral constraints properties
23   USE trdmld                  ! ocean active mixed layer tracers trends
24   USE in_out_manager          ! I/O manager
25
26   IMPLICIT NONE
27   PRIVATE
28
29   REAL(wp) ::   r2dt          ! time-step, = 2 rdttra except at nit000 (=rdttra) if neuler=0
30
31   PUBLIC trd_mod              ! called by all dynXX or traXX modules
32   PUBLIC trd_mod_init         ! called by opa.F90 module
33
34   !! * Substitutions
35#  include "domzgr_substitute.h90"
36#  include "vectopt_loop_substitute.h90"
37   !!----------------------------------------------------------------------
38   !!   OPA 9.0 , LOCEAN-IPSL (2005)
39   !! $Id: trdmod.F90 1708 2009-11-04 13:24:34Z rblod $
40   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
41   !!----------------------------------------------------------------------
42
43CONTAINS
44
45   SUBROUTINE trd_mod( ptrdx, ptrdy, ktrd, ctype, kt, cnbpas )
46      !!---------------------------------------------------------------------
47      !!                  ***  ROUTINE trd_mod  ***
48      !!
49      !! ** Purpose : Dispatch all trends computation, e.g. vorticity, mld or
50      !!              integral constraints
51      !!----------------------------------------------------------------------
52      INTEGER, INTENT( in ) ::   kt                                ! time step
53      INTEGER, INTENT( in ) ::   ktrd                              ! tracer trend index
54      CHARACTER(len=3), INTENT( in ) ::   ctype                    ! momentum or tracers trends type 'DYN'/'TRA'
55      CHARACTER(len=3), INTENT( in ), OPTIONAL ::   cnbpas         ! number of passage
56      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( inout ) ::   ptrdx ! Temperature or U trend
57      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( inout ) ::   ptrdy ! Salinity    or V trend
58      !!
59      INTEGER ::   ji, jj
60      CHARACTER(len=3) ::   ccpas                                  ! number of passage
61      REAL(wp), DIMENSION(jpi,jpj) ::   ztswu, ztswv               ! 2D workspace
62      REAL(wp), DIMENSION(jpi,jpj) ::   ztbfu, ztbfv               ! 2D workspace
63      REAL(wp), DIMENSION(jpi,jpj) ::   z2dx, z2dy                 ! workspace arrays
64      !!----------------------------------------------------------------------
65
66      z2dx(:,:)   = 0.e0   ;   z2dy(:,:)   = 0.e0                  ! initialization of workspace arrays
67
68      ! Control of optional arguments
69      ccpas = 'fst'
70      IF( PRESENT(cnbpas) )  ccpas = cnbpas
71
72      IF( neuler == 0 .AND. kt == nit000    ) THEN   ;   r2dt =      rdt      ! = rdtra (restarting with Euler time stepping)
73      ELSEIF(               kt <= nit000 + 1) THEN   ;   r2dt = 2. * rdt      ! = 2 rdttra (leapfrog)
74      ENDIF
75
76      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
77      ! I. Integral Constraints Properties for momentum and/or tracers trends
78      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
79
80      IF( ( mod(kt,nn_trd) == 0 .OR. kt == nit000 .OR. kt == nitend) )   THEN
81         !
82         IF( lk_trdtra .AND. ctype == 'TRA' )   THEN       ! active tracer trends
83            SELECT CASE ( ktrd )
84            CASE ( jptra_trd_ldf )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpt_ldf, ctype )   ! lateral diff
85            CASE ( jptra_trd_zdf )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpt_zdf, ctype )   ! vertical diff (Kz)
86            CASE ( jptra_trd_bbc )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpt_bbc, ctype )   ! bottom boundary cond
87            CASE ( jptra_trd_bbl )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpt_bbl, ctype )   ! bottom boundary layer
88            CASE ( jptra_trd_npc )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpt_npc, ctype )   ! static instability mixing
89            CASE ( jptra_trd_dmp )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpt_dmp, ctype )   ! damping
90            CASE ( jptra_trd_qsr )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpt_qsr, ctype )   ! penetrative solar radiat.
91            CASE ( jptra_trd_nsr )   
92               z2dx(:,:) = ptrdx(:,:,1)   ;   z2dy(:,:) = ptrdy(:,:,1)
93               CALL trd_icp( z2dx, z2dy, jpicpt_nsr, ctype )                               ! non solar radiation
94            CASE ( jptra_trd_xad )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpt_xad, ctype )   ! x- horiz adv
95            CASE ( jptra_trd_yad )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpt_yad, ctype )   ! y- horiz adv
96            CASE ( jptra_trd_zad )                                                         ! z- vertical adv
97               CALL trd_icp( ptrdx, ptrdy, jpicpt_zad, ctype, clpas=ccpas )   
98               ! compute the surface flux condition wn(:,:,1)*tn(:,:,1)
99               z2dx(:,:) = wn(:,:,1)*tn(:,:,1)/fse3t(:,:,1)
100               z2dy(:,:) = wn(:,:,1)*sn(:,:,1)/fse3t(:,:,1)
101               CALL trd_icp( z2dx , z2dy , jpicpt_zl1, ctype )                             ! 1st z- vertical adv
102            END SELECT
103         END IF
104
105         IF( lk_trddyn .AND. ctype == 'DYN' )   THEN       ! momentum trends
106            !
107            SELECT CASE ( ktrd )
108            CASE ( jpdyn_trd_hpg )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpd_hpg, ctype )   ! hydrost. pressure grad
109            CASE ( jpdyn_trd_keg )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpd_keg, ctype )   ! KE gradient
110            CASE ( jpdyn_trd_rvo )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpd_rvo, ctype )   ! relative vorticity
111            CASE ( jpdyn_trd_pvo )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpd_pvo, ctype )   ! planetary vorticity
112            CASE ( jpdyn_trd_ldf )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpd_ldf, ctype )   ! lateral diffusion
113            CASE ( jpdyn_trd_had )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpd_had, ctype )   ! horizontal advection
114            CASE ( jpdyn_trd_zad )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpd_zad, ctype )   ! vertical advection
115            CASE ( jpdyn_trd_spg )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpd_spg, ctype )   ! surface pressure grad.
116            CASE ( jpdyn_trd_dat )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpd_dat, ctype )   ! damping term
117            CASE ( jpdyn_trd_zdf )                                                         ! vertical diffusion
118               ! subtract surface forcing/bottom friction trends
119               ! from vertical diffusive momentum trends
120               ztswu(:,:) = 0.e0   ;   ztswv(:,:) = 0.e0
121               ztbfu(:,:) = 0.e0   ;   ztbfv(:,:) = 0.e0 
122               DO jj = 2, jpjm1   
123                  DO ji = fs_2, fs_jpim1   ! vector opt.
124                     ! save the surface forcing momentum fluxes
125                     ztswu(ji,jj) = utau(ji,jj) / ( fse3u(ji,jj,1)*rau0 )
126                     ztswv(ji,jj) = vtau(ji,jj) / ( fse3v(ji,jj,1)*rau0 )
127                     ! bottom friction contribution now handled explicitly
128                     !
129                     ptrdx(ji,jj,1     ) = ptrdx(ji,jj,1     ) - ztswu(ji,jj)
130                     ptrdy(ji,jj,1     ) = ptrdy(ji,jj,1     ) - ztswv(ji,jj)
131                  END DO
132               END DO
133               !
134               CALL trd_icp( ptrdx, ptrdy, jpicpd_zdf, ctype )   
135               CALL trd_icp( ztswu, ztswv, jpicpd_swf, ctype )                               ! wind stress forcing term
136               ! bottom friction contribution now handled explicitly
137            CASE ( jpdyn_trd_bfr )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpd_bfr, ctype )     ! bottom friction term
138            END SELECT
139            !
140         END IF
141         !
142      END IF
143
144      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
145      ! II. Vorticity trends
146      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
147
148      IF( lk_trdvor .AND. ctype == 'DYN' )   THEN
149         !
150         SELECT CASE ( ktrd ) 
151         CASE ( jpdyn_trd_hpg )   ;   CALL trd_vor_zint( ptrdx, ptrdy, jpvor_prg )   ! Hydrostatique Pressure Gradient
152         CASE ( jpdyn_trd_keg )   ;   CALL trd_vor_zint( ptrdx, ptrdy, jpvor_keg )   ! KE Gradient
153         CASE ( jpdyn_trd_rvo )   ;   CALL trd_vor_zint( ptrdx, ptrdy, jpvor_rvo )   ! Relative Vorticity
154         CASE ( jpdyn_trd_pvo )   ;   CALL trd_vor_zint( ptrdx, ptrdy, jpvor_pvo )   ! Planetary Vorticity Term
155         CASE ( jpdyn_trd_ldf )   ;   CALL trd_vor_zint( ptrdx, ptrdy, jpvor_ldf )   ! Horizontal Diffusion
156         CASE ( jpdyn_trd_had )   ;   CALL ctl_warn('Vorticity for horizontal advection trend never checked')   
157         CASE ( jpdyn_trd_zad )   ;   CALL trd_vor_zint( ptrdx, ptrdy, jpvor_zad )   ! Vertical Advection
158         CASE ( jpdyn_trd_spg )   ;   CALL trd_vor_zint( ptrdx, ptrdy, jpvor_spg )   ! Surface Pressure Grad.
159         CASE ( jpdyn_trd_dat )   ;   CALL trd_vor_zint( ptrdx, ptrdy, jpvor_bev )   ! Beta V 
160         CASE ( jpdyn_trd_zdf )                                                      ! Vertical Diffusion
161            ! subtract surface forcing/bottom friction trends
162            ! from vertical diffusive momentum trends
163            ztswu(:,:) = 0.e0   ;   ztswv(:,:) = 0.e0
164            ztbfu(:,:) = 0.e0   ;   ztbfv(:,:) = 0.e0 
165            DO jj = 2, jpjm1   
166               DO ji = fs_2, fs_jpim1   ! vector opt.
167                  ! save the surface forcing momentum fluxes
168                  ztswu(ji,jj) = utau(ji,jj) / ( fse3u(ji,jj,1)*rau0 )
169                  ztswv(ji,jj) = vtau(ji,jj) / ( fse3v(ji,jj,1)*rau0 )
170                  !
171                  ptrdx(ji,jj,1     ) = ptrdx(ji,jj,1     ) - ztswu(ji,jj)
172                  ptrdy(ji,jj,1     ) = ptrdy(ji,jj,1     ) - ztswv(ji,jj)
173               END DO
174            END DO
175            !
176            CALL trd_vor_zint( ptrdx, ptrdy, jpvor_zdf )   
177            CALL trd_vor_zint( ztswu, ztswv, jpvor_swf )                               ! Wind stress forcing term
178         CASE ( jpdyn_trd_bfr )
179            CALL trd_vor_zint( ptrdx, ptrdy, jpvor_bfr )                               ! Bottom friction term
180         END SELECT
181         !
182      ENDIF
183
184      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
185      ! III. Mixed layer trends for active tracers
186      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
187
188      IF( lk_trdmld .AND. ctype == 'TRA' )   THEN
189         
190         !-----------------------------------------------------------------------------------------------
191         ! W.A.R.N.I.N.G :
192         ! jptra_trd_ldf : called by traldf.F90
193         !                 at this stage we store:
194         !                  - the lateral geopotential diffusion (here, lateral = horizontal)
195         !                  - and the iso-neutral diffusion if activated
196         ! jptra_trd_zdf : called by trazdf.F90
197         !                 * in case of iso-neutral diffusion we store the vertical diffusion component in the
198         !                   lateral trend including the K_z contrib, which will be removed later (see trd_mld)
199         !-----------------------------------------------------------------------------------------------
200
201         SELECT CASE ( ktrd )
202         CASE ( jptra_trd_xad )   ;   CALL trd_mld_zint( ptrdx, ptrdy, jpmld_xad, '3D' )   ! merid. advection
203         CASE ( jptra_trd_yad )   ;   CALL trd_mld_zint( ptrdx, ptrdy, jpmld_yad, '3D' )   ! zonal  advection
204         CASE ( jptra_trd_zad )   ;   CALL trd_mld_zint( ptrdx, ptrdy, jpmld_zad, '3D' )   ! vertical advection
205         CASE ( jptra_trd_ldf )   ;   CALL trd_mld_zint( ptrdx, ptrdy, jpmld_ldf, '3D' )   ! lateral diffusive
206         CASE ( jptra_trd_bbl )   ;   CALL trd_mld_zint( ptrdx, ptrdy, jpmld_bbl, '3D' )   ! bottom boundary layer
207         CASE ( jptra_trd_zdf )
208            IF( ln_traldf_iso )   THEN
209               CALL trd_mld_zint( ptrdx, ptrdy, jpmld_ldf, '3D' )   ! vertical diffusion (K_z)
210            ELSE
211               CALL trd_mld_zint( ptrdx, ptrdy, jpmld_zdf, '3D' )   ! vertical diffusion (K_z)
212            ENDIF
213         CASE ( jptra_trd_dmp )   ;   CALL trd_mld_zint( ptrdx, ptrdy, jpmld_dmp, '3D' )   ! internal 3D restoring (tradmp)
214         CASE ( jptra_trd_qsr )   ;   CALL trd_mld_zint( ptrdx, ptrdy, jpmld_for, '3D' )   ! air-sea : penetrative sol radiat
215         CASE ( jptra_trd_nsr )
216            ptrdx(:,:,2:jpk) = 0.e0   ;   ptrdy(:,:,2:jpk) = 0.e0
217            CALL trd_mld_zint( ptrdx, ptrdy, jpmld_for, '2D' )                             ! air-sea : non penetr sol radiat
218         CASE ( jptra_trd_bbc )   ;   CALL trd_mld_zint( ptrdx, ptrdy, jpmld_bbc, '3D' )   ! bottom bound cond (geoth flux)
219         CASE ( jptra_trd_atf )   ;   CALL trd_mld_zint( ptrdx, ptrdy, jpmld_atf, '3D' )   ! asselin numerical
220         CASE ( jptra_trd_npc )   ;   CALL trd_mld_zint( ptrdx, ptrdy, jpmld_npc, '3D' )   ! non penetr convect adjustment
221         END SELECT
222
223      ENDIF
224
225   END SUBROUTINE trd_mod
226
227#   else
228   !!----------------------------------------------------------------------
229   !!   Default case :                                         Empty module
230   !!----------------------------------------------------------------------
231   USE trdmod_oce      ! ocean variables trends
232   USE trdvor          ! ocean vorticity trends
233   USE trdicp          ! ocean bassin integral constraints properties
234   USE trdmld          ! ocean active mixed layer tracers trends
235
236CONTAINS
237   SUBROUTINE trd_mod(ptrd3dx, ptrd3dy, ktrd , ctype, kt, cnbpas)   ! Empty routine
238      REAL, DIMENSION(:,:,:), INTENT( in ) ::   &
239          ptrd3dx,                     &                           ! Temperature or U trend
240          ptrd3dy                                                  ! Salinity    or V trend
241      INTEGER, INTENT( in ) ::   ktrd                              ! momentum or tracer trend index
242      INTEGER, INTENT( in ) ::   kt                                ! Time step
243      CHARACTER(len=3), INTENT( in ) ::  ctype                     ! momentum or tracers trends type
244      CHARACTER(len=3), INTENT( in ), OPTIONAL ::   cnbpas         ! number of passage
245      WRITE(*,*) 'trd_3d: You should not have seen this print! error ?', ptrd3dx(1,1,1)
246      WRITE(*,*) ' "   ": You should not have seen this print! error ?', ptrd3dy(1,1,1)
247      WRITE(*,*) ' "   ": You should not have seen this print! error ?', ktrd
248      WRITE(*,*) ' "   ": You should not have seen this print! error ?', ctype
249      WRITE(*,*) ' "   ": You should not have seen this print! error ?', kt
250      WRITE(*,*) ' "   ": You should not have seen this print! error ?', cnbpas
251   END SUBROUTINE trd_mod
252#   endif
253
254   SUBROUTINE trd_mod_init
255      !!----------------------------------------------------------------------
256      !!                  ***  ROUTINE trd_mod_init  ***
257      !!
258      !! ** Purpose :   Initialization of activated trends
259      !!----------------------------------------------------------------------
260      USE in_out_manager          ! I/O manager
261
262      NAMELIST/namtrd/ nn_trd, nn_ctls, cn_trdrst_in, cn_trdrst_out, ln_trdmld_restart, rn_ucf, ln_trdmld_instant
263      !!----------------------------------------------------------------------
264
265      IF( l_trdtra .OR. l_trddyn )   THEN
266         REWIND( numnam )
267         READ  ( numnam, namtrd )      ! namelist namtrd : trends diagnostic
268
269         IF(lwp) THEN
270            WRITE(numout,*)
271            WRITE(numout,*) ' trd_mod_init : Momentum/Tracers trends'
272            WRITE(numout,*) ' ~~~~~~~~~~~~~'
273            WRITE(numout,*) '   Namelist namtrd : set trends parameters'
274            WRITE(numout,*) '      frequency of trends diagnostics   nn_trd             = ', nn_trd
275            WRITE(numout,*) '      control surface type              nn_ctls            = ', nn_ctls
276            WRITE(numout,*) '      restart for ML diagnostics        ln_trdmld_restart  = ', ln_trdmld_restart
277            WRITE(numout,*) '      instantaneous or mean ML T/S      ln_trdmld_instant  = ', ln_trdmld_instant
278            WRITE(numout,*) '      unit conversion factor            rn_ucf             = ', rn_ucf
279        ENDIF
280      ENDIF
281      !
282      IF( lk_trddyn .OR. lk_trdtra )    CALL trd_icp_init       ! integral constraints trends
283      IF( lk_trdmld                )    CALL trd_mld_init       ! mixed-layer trends (active  tracers) 
284      IF( lk_trdvor                )    CALL trd_vor_init       ! vorticity trends       
285      !
286   END SUBROUTINE trd_mod_init
287
288   !!======================================================================
289END MODULE trdmod
Note: See TracBrowser for help on using the repository browser.