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.
trdpen.F90 in branches/2012/dev_r3309_LOCEAN12_Ediag/NEMOGCM/NEMO/OPA_SRC/TRD – NEMO

source: branches/2012/dev_r3309_LOCEAN12_Ediag/NEMOGCM/NEMO/OPA_SRC/TRD/trdpen.F90 @ 3326

Last change on this file since 3326 was 3326, checked in by gm, 12 years ago

Ediag branche: #927 add Potential Energy trend diagnostics (trdpen.F90)

File size: 7.7 KB
Line 
1MODULE trdpen
2   !!======================================================================
3   !!                       ***  MODULE  trdpen  ***
4   !! Ocean diagnostics:  Potential ENnergy trends
5   !!=====================================================================
6   !! History :  3.5  !  2012-02  (G. Madec) original code
7   !!----------------------------------------------------------------------
8
9   !!----------------------------------------------------------------------
10   !!   trd_pen       : compute and output Potential Energy trends from T & S trends
11   !!   trd_pen_init  : initialisation of PE trends
12   !!----------------------------------------------------------------------
13   USE oce            ! ocean dynamics and tracers variables
14   USE dom_oce        ! ocean domain
15   USE sbc_oce        ! surface boundary condition: ocean
16   USE zdf_oce        ! ocean vertical physics
17   USE trd_oce        ! trends: ocean variables
18   USE eosbn2         ! equation of state and related derivatives
19   USE ldftra_oce     ! ocean active tracers lateral physics
20   USE zdfddm         ! vertical physics: double diffusion
21   USE phycst         ! physical constants
22   USE in_out_manager ! I/O manager
23   USE iom            ! I/O manager library
24   USE lib_mpp        ! MPP library
25   USE wrk_nemo       ! Memory allocation
26
27   IMPLICIT NONE
28   PRIVATE
29
30   PUBLIC   trd_pen        ! called by all trdtra module
31   PUBLIC   trd_pen_init   ! called by all nemogcm module
32
33   INTEGER ::   nkstp   ! current time step
34
35   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   drau_dt, drau_ds   ! partial derivative of rau with respect to T and S
36
37   !! * Substitutions
38#  include "domzgr_substitute.h90"
39#  include "zdfddm_substitute.h90"
40#  include "vectopt_loop_substitute.h90"
41   !!----------------------------------------------------------------------
42   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
43   !! $Id: trdtra.F90 3318 2012-02-25 15:50:01Z gm $
44   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
45   !!----------------------------------------------------------------------
46CONTAINS
47
48   INTEGER FUNCTION trd_pen_alloc()
49      !!---------------------------------------------------------------------
50      !!                  ***  FUNCTION trd_tra_alloc  ***
51      !!---------------------------------------------------------------------
52      ALLOCATE( drau_dt(jpi,jpj,jpk) , drau_ds(jpi,jpj,jpk) , STAT= trd_pen_alloc )
53      !
54      IF( lk_mpp             )   CALL mpp_sum ( trd_pen_alloc )
55      IF( trd_pen_alloc /= 0 )   CALL ctl_warn('trd_pen_alloc: failed to allocate arrays')
56   END FUNCTION trd_pen_alloc
57
58
59   SUBROUTINE trd_pen( ptrdx, ptrdy, ktrd, kt, pdt )
60      !!---------------------------------------------------------------------
61      !!                  ***  ROUTINE trd_tra_mng  ***
62      !!
63      !! ** Purpose :   Dispatch all trends computation, e.g. 3D output, integral
64      !!                constraints, barotropic vorticity, kinetic enrgy,
65      !!                potential energy, and/or mixed layer budget.
66      !!----------------------------------------------------------------------
67      REAL(wp), DIMENSION(:,:,:), INTENT(in) ::   ptrdx, ptrdy   ! Temperature & Salinity trends
68      INTEGER                   , INTENT(in) ::   ktrd           ! tracer trend index
69      INTEGER                   , INTENT(in) ::   kt             ! time step index
70      REAL(wp)                  , INTENT(in) ::   pdt            ! time step [s]
71      !
72      REAL(wp), POINTER, DIMENSION(:,:)   ::   z2d   ! 2D workspace
73      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zpe   ! 3D workspace
74      !!----------------------------------------------------------------------
75      !
76      CALL wrk_alloc( jpi, jpj, jpk, zpe )
77      !
78      IF ( nn_eos == 0 .AND.  kt /= nkstp ) THEN   ! full eos: set partial derivatives at the 1st call of kt time step
79         nkstp = kt
80         CALL eos_drau_dtds( tsn, drau_dt, drau_ds )
81      ENDIF
82      !
83      DO jk = 1, jpkm1
84         zpe(:,:,jk) = grav * fsde3w(:,:,jk) * (  drau_dt(:,:,jk) * ptrdx(:,:,jk)   &
85            &                                   + drau_ds(:,:,jk) * ptrdx(:,:,jk)  )
86      END DO
87
88      SELECT CASE ( ktrd )
89      CASE ( jptra_xad  )   ;   CALL iom_put( "petrd_xad", zke )   ! zonal    advection
90      CASE ( jptra_yad  )   ;   CALL iom_put( "petrd_yad", zke )   ! merid.   advection
91      CASE ( jptra_zad  )   ;   CALL iom_put( "petrd_zad", zke )   ! vertical advection
92                                IF( .NOT.lk_vvl ) THEN                   ! cst volume : adv flux through z=0 surface
93                                   CALL wrk_alloc( jpi, jpj, z2d )
94                                   z2d(:,:) = wn(:,:,1) * (   drau_dt(:,:,1) * tsn(:,:,1,jp_tem) 
95                                      &                     + drau_ds(:,:,1) * tsn(:,:,1,jp_sal)  ) / fse3t(:,:,1)
96                                   CALL iom_put( "petrd_sad" , z2d )
97                                   CALL wrk_dealloc( jpi, jpj, z2d )
98                                ENDIF
99      CASE ( jptra_ldf  )   ;   CALL iom_put( "petrd_ldf" , zpe )   ! lateral  diffusion
100      CASE ( jptra_zdf  )   ;   CALL iom_put( "petrd_ldf" , zpe )   ! lateral  diffusion (K_z)
101      CASE ( jptra_zdfp )   ;   CALL iom_put( "petrd_zdfp", zpe )   ! vertical diffusion (K_z)
102      CASE ( jptra_dmp  )   ;   CALL iom_put( "petrd_dmp" , zpe )   ! internal 3D restoring (tradmp)
103      CASE ( jptra_bbl  )   ;   CALL iom_put( "petrd_bbl" , zpe )   ! bottom boundary layer
104      CASE ( jptra_npc  )   ;   CALL iom_put( "petrd_npc" , zpe )   ! non penetr convect adjustment
105      CASE ( jptra_nsr  )   ;   CALL iom_put( "petrd_for" , zpe )   ! surface forcing + runoff (ln_rnf=T)
106      CASE ( jptra_qsr  )   ;   CALL iom_put( "petrd_qsr" , zke )   ! air-sea : penetrative sol radiat
107      CASE ( jptra_bbc  )   ;   CALL iom_put( "petrd_bbc", zke )   ! bottom bound cond (geoth flux)
108      CASE ( jptra_atf  )   ;   CALL iom_put( "petrd_atf", zke )   ! asselin time filter (last trend)
109                                IF( .NOT.lk_vvl ) THEN                   ! cst volume : ssh term (otherwise include in e3t variation)
110                                   CALL wrk_alloc( jpi, jpj, z2d )
111                                   z2d(:,:) = ( ssha(:,:) - sshb(:,:) )   &
112                                      &     * (   drau_dt(:,:,1) * tsn(:,:,1,jp_tem) 
113                                      &         + drau_ds(:,:,1) * tsn(:,:,1,jp_sal)  ) / ( fse3t(:,:,1) * pdt )
114                                   CALL iom_put( "petrd_sad" , z2d )
115                                   CALL wrk_dealloc( jpi, jpj, z2d )
116                                ENDIF
117      END SELECT
118      !
119      CALL wrk_dealloc( jpi, jpj, jpk, zpe )
120      !
121   END SUBROUTINE trd_pen
122
123
124   SUBROUTINE trd_pen_init
125      !!---------------------------------------------------------------------
126      !!                  ***  ROUTINE trd_pen_init  ***
127      !!
128      !! ** Purpose :   initialisation of 3D Kinetic Energy trend diagnostic
129      !!----------------------------------------------------------------------
130      INTEGER  ::   ji, jj, jk   ! dummy loop indices
131      !!----------------------------------------------------------------------
132      !
133      IF(lwp) THEN
134         WRITE(numout,*)
135         WRITE(numout,*) 'trd_pen_init : 3D Potential ENergy trends'
136         WRITE(numout,*) '~~~~~~~~~~~~~'
137      ENDIF
138      !                           ! allocate box volume arrays
139      IF ( trd_pen_alloc() /= 0 )   CALL ctl_stop('trd_pen_alloc: failed to allocate arrays')
140      !
141      IF ( lk_vvl               )   CALL ctl_stop('trd_pen_init : PE trends not coded for variable volume')
142      !
143      r1_2_rau0 = 0.5_wp / rau0
144      !
145   END SUBROUTINE trd_pen_init
146
147   !!======================================================================
148END MODULE trdtra
Note: See TracBrowser for help on using the repository browser.