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/2017/dev_CNRS_2017/NEMOGCM/NEMO/OPA_SRC/TRD – NEMO

source: branches/2017/dev_CNRS_2017/NEMOGCM/NEMO/OPA_SRC/TRD/trdpen.F90 @ 8882

Last change on this file since 8882 was 8882, checked in by flavoni, 6 years ago

dev_CNRS_2017 branch: merged dev_r7881_ENHANCE09_RK3 with trunk r8864

  • Property svn:keywords set to Id
File size: 8.1 KB
Line 
1MODULE trdpen
2   !!======================================================================
3   !!                       ***  MODULE  trdpen  ***
4   !! Ocean diagnostics:  Potential Energy 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         ! lateral diffusion: eddy diffusivity & EIV coeff.
20   USE zdfddm         ! vertical physics: double diffusion
21   USE phycst         ! physical constants
22   !
23   USE in_out_manager ! I/O manager
24   USE iom            ! I/O manager library
25   USE lib_mpp        ! MPP library
26   USE wrk_nemo       ! Memory allocation
27
28   IMPLICIT NONE
29   PRIVATE
30
31   PUBLIC   trd_pen        ! called by all trdtra module
32   PUBLIC   trd_pen_init   ! called by all nemogcm module
33
34   INTEGER ::   nkstp   ! current time step
35
36   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) ::   rab_pe   ! partial derivatives of PE anomaly with respect to T and S
37
38   !! * Substitutions
39#  include "vectopt_loop_substitute.h90"
40   !!----------------------------------------------------------------------
41   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
42   !! $Id$
43   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
44   !!----------------------------------------------------------------------
45CONTAINS
46
47   INTEGER FUNCTION trd_pen_alloc()
48      !!---------------------------------------------------------------------
49      !!                  ***  FUNCTION trd_tra_alloc  ***
50      !!---------------------------------------------------------------------
51      ALLOCATE( rab_pe(jpi,jpj,jpk,jpts) , STAT= trd_pen_alloc )
52      !
53      IF( lk_mpp             )   CALL mpp_sum ( trd_pen_alloc )
54      IF( trd_pen_alloc /= 0 )   CALL ctl_warn( 'trd_pen_alloc: failed to allocate arrays' )
55   END FUNCTION trd_pen_alloc
56
57
58   SUBROUTINE trd_pen( ptrdx, ptrdy, ktrd, kt, pdt )
59      !!---------------------------------------------------------------------
60      !!                  ***  ROUTINE trd_tra_mng  ***
61      !!
62      !! ** Purpose :   Dispatch all trends computation, e.g. 3D output, integral
63      !!                constraints, barotropic vorticity, kinetic enrgy,
64      !!                potential energy, and/or mixed layer budget.
65      !!----------------------------------------------------------------------
66      REAL(wp), DIMENSION(:,:,:), INTENT(in) ::   ptrdx, ptrdy   ! Temperature & Salinity trends
67      INTEGER                   , INTENT(in) ::   ktrd           ! tracer trend index
68      INTEGER                   , INTENT(in) ::   kt             ! time step index
69      REAL(wp)                  , INTENT(in) ::   pdt            ! time step [s]
70      !
71      INTEGER ::   jk                                            ! dummy loop indices
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      zpe(:,:,:) = 0._wp
78      !
79      IF( kt /= nkstp ) THEN     ! full eos: set partial derivatives at the 1st call of kt time step
80         nkstp = kt
81         CALL eos_pen( tsn, rab_PE, zpe )
82         CALL iom_put( "alphaPE", rab_pe(:,:,:,jp_tem) )
83         CALL iom_put( "betaPE" , rab_pe(:,:,:,jp_sal) )
84         CALL iom_put( "PEanom" , zpe )
85      ENDIF
86      !
87      zpe(:,:,jpk) = 0._wp
88      DO jk = 1, jpkm1
89         zpe(:,:,jk) = ( - ( rab_n(:,:,jk,jp_tem) + rab_pe(:,:,jk,jp_tem) ) * ptrdx(:,:,jk)   &
90            &            + ( rab_n(:,:,jk,jp_sal) + rab_pe(:,:,jk,jp_sal) ) * ptrdy(:,:,jk)  )
91      END DO
92
93      SELECT CASE ( ktrd )
94      CASE ( jptra_xad  )   ;   CALL iom_put( "petrd_xad", zpe )   ! zonal    advection
95      CASE ( jptra_yad  )   ;   CALL iom_put( "petrd_yad", zpe )   ! merid.   advection
96      CASE ( jptra_zad  )   ;   CALL iom_put( "petrd_zad", zpe )   ! vertical advection
97                                IF( ln_linssh ) THEN                   ! cst volume : adv flux through z=0 surface
98                                   CALL wrk_alloc( jpi, jpj, z2d )
99                                   z2d(:,:) = wn(:,:,1) * ( &
100                                     &   - ( rab_n(:,:,1,jp_tem) + rab_pe(:,:,1,jp_tem) ) * tsn(:,:,1,jp_tem)    &
101                                     &   + ( rab_n(:,:,1,jp_sal) + rab_pe(:,:,1,jp_sal) ) * tsn(:,:,1,jp_sal)    &
102                                     & ) / e3t_n(:,:,1)
103                                   CALL iom_put( "petrd_sad" , z2d )
104                                   CALL wrk_dealloc( jpi, jpj, z2d )
105                                ENDIF
106      CASE ( jptra_ldf  )   ;   CALL iom_put( "petrd_ldf" , zpe )   ! lateral  diffusion
107      CASE ( jptra_zdf  )   ;   CALL iom_put( "petrd_zdf" , zpe )   ! lateral  diffusion (K_z)
108      CASE ( jptra_zdfp )   ;   CALL iom_put( "petrd_zdfp", zpe )   ! vertical diffusion (K_z)
109      CASE ( jptra_dmp  )   ;   CALL iom_put( "petrd_dmp" , zpe )   ! internal 3D restoring (tradmp)
110      CASE ( jptra_bbl  )   ;   CALL iom_put( "petrd_bbl" , zpe )   ! bottom boundary layer
111      CASE ( jptra_npc  )   ;   CALL iom_put( "petrd_npc" , zpe )   ! non penetr convect adjustment
112      CASE ( jptra_nsr  )   ;   CALL iom_put( "petrd_nsr" , zpe )   ! surface forcing + runoff (ln_rnf=T)
113      CASE ( jptra_qsr  )   ;   CALL iom_put( "petrd_qsr" , zpe )   ! air-sea : penetrative sol radiat
114      CASE ( jptra_bbc  )   ;   CALL iom_put( "petrd_bbc" , zpe )   ! bottom bound cond (geoth flux)
115      CASE ( jptra_atf  )   ;   CALL iom_put( "petrd_atf" , zpe )   ! asselin time filter (last trend)
116                                !IF( ln_linssh ) THEN                   ! cst volume : ssh term (otherwise include in e3t variation)
117                                !   CALL wrk_alloc( jpi, jpj, z2d )
118                                !   z2d(:,:) = ( ssha(:,:) - sshb(:,:) )                 &
119                                !      &     * (   dPE_dt(:,:,1) * tsn(:,:,1,jp_tem)    &
120                                !      &         + dPE_ds(:,:,1) * tsn(:,:,1,jp_sal)  ) / ( e3t_n(:,:,1) * pdt )
121                                !   CALL iom_put( "petrd_sad" , z2d )
122                                !   CALL wrk_dealloc( jpi, jpj, z2d )
123                                !ENDIF
124         !
125      END SELECT
126      !
127      CALL wrk_dealloc( jpi, jpj, jpk, zpe )
128      !
129   END SUBROUTINE trd_pen
130
131
132   SUBROUTINE trd_pen_init
133      !!---------------------------------------------------------------------
134      !!                  ***  ROUTINE trd_pen_init  ***
135      !!
136      !! ** Purpose :   initialisation of 3D Kinetic Energy trend diagnostic
137      !!----------------------------------------------------------------------
138      INTEGER  ::   ji, jj, jk   ! dummy loop indices
139      !!----------------------------------------------------------------------
140      !
141      IF(lwp) THEN
142         WRITE(numout,*)
143         WRITE(numout,*) 'trd_pen_init : 3D Potential ENergy trends'
144         WRITE(numout,*) '~~~~~~~~~~~~~'
145      ENDIF
146      !                           ! allocate box volume arrays
147      IF ( trd_pen_alloc() /= 0 )   CALL ctl_stop('trd_pen_alloc: failed to allocate arrays')
148      !
149      rab_pe(:,:,:,:) = 0._wp
150      !
151      IF( .NOT.ln_linssh )   CALL ctl_stop('trd_pen_init : PE trends not coded for variable volume')
152      !
153      nkstp     = nit000 - 1
154      !
155   END SUBROUTINE trd_pen_init
156
157   !!======================================================================
158END MODULE trdpen
Note: See TracBrowser for help on using the repository browser.