trdmxl_oce.F90 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. MODULE trdmxl_oce
  2. !!======================================================================
  3. !! *** MODULE trdmxl_oce ***
  4. !! Ocean trends : set tracer and momentum trend variables
  5. !!======================================================================
  6. !! History : 1.0 ! 2004-08 (C. Talandier) New trends organization
  7. !! 3.5 ! 2012-02 (G. Madec) suppress the trend keys + new trdmxl formulation
  8. !!----------------------------------------------------------------------
  9. USE par_oce ! ocean parameters
  10. IMPLICIT NONE
  11. PRIVATE
  12. PUBLIC trdmxl_oce_alloc ! Called in trdmxl.F90
  13. ! !* mixed layer trend indices
  14. INTEGER, PUBLIC, PARAMETER :: jpltrd = 12 !: number of mixed-layer trends arrays
  15. INTEGER, PUBLIC :: jpktrd !: max level for mixed-layer trends diag.
  16. !
  17. INTEGER, PUBLIC, PARAMETER :: jpmxl_xad = 1 !: i-componant of advection
  18. INTEGER, PUBLIC, PARAMETER :: jpmxl_yad = 2 !: j-componant of advection
  19. INTEGER, PUBLIC, PARAMETER :: jpmxl_zad = 3 !: k-component of advection
  20. INTEGER, PUBLIC, PARAMETER :: jpmxl_ldf = 4 !: lateral diffusion (geopot. or iso-neutral)
  21. INTEGER, PUBLIC, PARAMETER :: jpmxl_zdf = 5 !: vertical diffusion
  22. INTEGER, PUBLIC, PARAMETER :: jpmxl_npc = 6 !: non penetrative convective adjustment
  23. INTEGER, PUBLIC, PARAMETER :: jpmxl_bbc = 7 !: geothermal flux
  24. INTEGER, PUBLIC, PARAMETER :: jpmxl_bbl = 8 !: bottom boundary layer (advective/diffusive)
  25. INTEGER, PUBLIC, PARAMETER :: jpmxl_for = 9 !: forcing
  26. INTEGER, PUBLIC, PARAMETER :: jpmxl_dmp = 10 !: internal restoring trend
  27. INTEGER, PUBLIC, PARAMETER :: jpmxl_zdfp = 11 !: iso-neutral diffusion:"pure" vertical diffusion
  28. INTEGER, PUBLIC, PARAMETER :: jpmxl_atf = 12 !: asselin trend (**MUST BE THE LAST ONE**)
  29. ! !!* Namelist namtrd_mxl: trend diagnostics in the mixed layer *
  30. INTEGER , PUBLIC :: nn_ctls = 0 !: control surface type for trends vertical integration
  31. REAL(wp) , PUBLIC :: rn_rho_c = 0.01 !: density criteria for MLD definition
  32. REAL(wp) , PUBLIC :: rn_ucf = 1. !: unit conversion factor (for netCDF trends outputs)
  33. ! =1. (=86400.) for degC/s (degC/day) and psu/s (psu/day)
  34. CHARACTER(len=32), PUBLIC :: cn_trdrst_in = "restart_mxl" !: suffix of ocean restart name (input)
  35. CHARACTER(len=32), PUBLIC :: cn_trdrst_out = "restart_mxl" !: suffix of ocean restart name (output)
  36. LOGICAL , PUBLIC :: ln_trdmxl_instant = .FALSE. !: flag to diagnose inst./mean ML T/S trends
  37. LOGICAL , PUBLIC :: ln_trdmxl_restart = .FALSE. !: flag to restart mixed-layer diagnostics
  38. !! Arrays used for diagnosing mixed-layer trends
  39. !!---------------------------------------------------------------------
  40. CHARACTER(LEN=80) , PUBLIC :: clname, ctrd(jpltrd+1,2)
  41. INTEGER , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: nmxl !: mixed layer depth indexes
  42. INTEGER , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: nbol !: mixed-layer depth indexes when read from file
  43. REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: wkx !:
  44. REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: &
  45. hmxl , & !: mixed layer depth (m) corresponding to nmld
  46. tml , sml , & !: \ "now" mixed layer temperature/salinity
  47. tmlb , smlb , & !: / and associated "before" fields
  48. tmlbb , smlbb, & !: \ idem, but valid at the 1rst time step of the
  49. tmlbn , smlbn, & !: / current analysis window
  50. tmltrdm, smltrdm, & !: total cumulative trends over the analysis window
  51. tml_sum, & !: mixed layer T, summed over the current analysis period
  52. tml_sumb, & !: idem, but from the previous analysis period
  53. tmltrd_atf_sumb, & !: Asselin trends, summed over the previous analysis period
  54. sml_sum, & !:
  55. sml_sumb, & !: ( idem for salinity )
  56. smltrd_atf_sumb, & !:
  57. hmxl_sum, hmxlbn !: needed to compute the leap-frog time mean of the ML depth
  58. REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: &
  59. tmlatfb, tmlatfn , & !: "before" Asselin contribution at begining of the averaging
  60. smlatfb, smlatfn, & !: period (i.e. last contrib. from previous such period) and
  61. !: "now" Asselin contribution to the ML temp. & salinity trends
  62. tmlatfm, smlatfm !: accumulator for Asselin trends (needed for storage only)
  63. REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:,:) :: &
  64. tmltrd, & !: \ physical contributions to the total trend (for T/S),
  65. smltrd, & !: / cumulated over the current analysis window
  66. tmltrd_sum, & !: sum of these trends over the analysis period
  67. tmltrd_csum_ln, & !: now cumulated sum of the trends over the "lower triangle"
  68. tmltrd_csum_ub, & !: before (prev. analysis period) cumulated sum over the upper triangle
  69. smltrd_sum, & !:
  70. smltrd_csum_ln, & !: ( idem for salinity )
  71. smltrd_csum_ub !:
  72. !!----------------------------------------------------------------------
  73. !! NEMO/OPA 4.0 , NEMO Consortium (2011)
  74. !! $Id: trdmxl_oce.F90 2750 2016-01-12 10:42:05Z ufla $
  75. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  76. !!----------------------------------------------------------------------
  77. CONTAINS
  78. INTEGER FUNCTION trdmxl_oce_alloc()
  79. !!----------------------------------------------------------------------
  80. !! *** FUNCTION trdmxl_oce_alloc ***
  81. !!----------------------------------------------------------------------
  82. USE lib_mpp
  83. INTEGER :: ierr(5)
  84. !!----------------------------------------------------------------------
  85. ! Initialise jpktrd here as can no longer do it in MODULE body since
  86. ! jpk is now a variable.
  87. jpktrd = jpk !: max level for mixed-layer trends diag.
  88. ierr(:) = 0
  89. ALLOCATE( nmxl (jpi,jpj) , nbol (jpi,jpj), &
  90. & wkx (jpi,jpj,jpk), hmxl (jpi,jpj), &
  91. & tml (jpi,jpj) , sml (jpi,jpj), &
  92. & tmlb (jpi,jpj) , smlb (jpi,jpj), &
  93. & tmlbb(jpi,jpj) , smlbb(jpi,jpj), STAT = ierr(1) )
  94. ALLOCATE( tmlbn(jpi,jpj) , smlbn(jpi,jpj), &
  95. & tmltrdm(jpi,jpj), smltrdm(jpi,jpj), &
  96. & tml_sum(jpi,jpj), tml_sumb(jpi,jpj),&
  97. & tmltrd_atf_sumb(jpi,jpj) , STAT=ierr(2) )
  98. ALLOCATE( sml_sum(jpi,jpj), sml_sumb(jpi,jpj), &
  99. & smltrd_atf_sumb(jpi,jpj), &
  100. & hmxl_sum(jpi,jpj), hmxlbn(jpi,jpj), &
  101. & tmlatfb(jpi,jpj), tmlatfn(jpi,jpj), STAT = ierr(3) )
  102. ALLOCATE( smlatfb(jpi,jpj), smlatfn(jpi,jpj), &
  103. & tmlatfm(jpi,jpj), smlatfm(jpi,jpj), &
  104. & tmltrd(jpi,jpj,jpltrd), smltrd(jpi,jpj,jpltrd), STAT=ierr(4))
  105. ALLOCATE( tmltrd_sum(jpi,jpj,jpltrd),tmltrd_csum_ln(jpi,jpj,jpltrd), &
  106. & tmltrd_csum_ub(jpi,jpj,jpltrd), smltrd_sum(jpi,jpj,jpltrd), &
  107. & smltrd_csum_ln(jpi,jpj,jpltrd), smltrd_csum_ub(jpi,jpj,jpltrd), STAT=ierr(5) )
  108. !
  109. trdmxl_oce_alloc = MAXVAL( ierr )
  110. IF( lk_mpp ) CALL mpp_sum ( trdmxl_oce_alloc )
  111. IF( trdmxl_oce_alloc /= 0 ) CALL ctl_warn('trdmxl_oce_alloc: failed to allocate arrays')
  112. !
  113. END FUNCTION trdmxl_oce_alloc
  114. !!======================================================================
  115. END MODULE trdmxl_oce