trdpen.F90 8.2 KB

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