diaprod.F90 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. MODULE diaprod
  2. ! Requires key_iom_put
  3. # if defined key_iomput
  4. !!======================================================================
  5. !! *** MODULE diaprod ***
  6. !! Ocean diagnostics : write ocean product diagnostics
  7. !!=====================================================================
  8. !! History : 3.4 ! 2012 (D. Storkey) Original code
  9. !!----------------------------------------------------------------------
  10. !!----------------------------------------------------------------------
  11. !! dia_prod : calculate and write out product diagnostics
  12. !!----------------------------------------------------------------------
  13. USE oce ! ocean dynamics and tracers
  14. USE dom_oce ! ocean space and time domain
  15. USE domvvl ! for thickness weighted diagnostics if key_vvl
  16. USE eosbn2 ! equation of state (eos call)
  17. USE phycst ! physical constants
  18. USE lbclnk ! ocean lateral boundary conditions (or mpp link)
  19. USE in_out_manager ! I/O manager
  20. USE diadimg ! dimg direct access file format output
  21. USE iom
  22. USE ioipsl
  23. USE lib_mpp ! MPP library
  24. USE timing ! preformance summary
  25. USE wrk_nemo ! working array
  26. USE diaptr
  27. IMPLICIT NONE
  28. PRIVATE
  29. PUBLIC dia_prod ! routines called by step.F90
  30. !! * Substitutions
  31. # include "zdfddm_substitute.h90"
  32. # include "domzgr_substitute.h90"
  33. # include "vectopt_loop_substitute.h90"
  34. !!----------------------------------------------------------------------
  35. !! NEMO/OPA 3.4 , NEMO Consortium (2012)
  36. !! $Id $
  37. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  38. !!----------------------------------------------------------------------
  39. CONTAINS
  40. SUBROUTINE dia_prod( kt )
  41. !!---------------------------------------------------------------------
  42. !! *** ROUTINE dia_prod ***
  43. !!
  44. !! ** Purpose : Write out product diagnostics (uT, vS etc.)
  45. !!
  46. !! ** Method : use iom_put
  47. !! Product diagnostics are not thickness-weighted in this routine.
  48. !! They should be thickness-weighted using XIOS if key_vvl is set.
  49. !!----------------------------------------------------------------------
  50. !!
  51. INTEGER, INTENT( in ) :: kt ! ocean time-step index
  52. !!
  53. INTEGER :: ji, jj, jk ! dummy loop indices
  54. REAL(wp) :: zztmp, zztmpx, zztmpy !
  55. !!
  56. REAL(wp), POINTER, DIMENSION(:,:) :: z2d ! 2D workspace
  57. REAL(wp), POINTER, DIMENSION(:,:,:) :: z3d ! 3D workspace
  58. REAL(wp), POINTER, DIMENSION(:,:,:) :: zrhop ! potential density
  59. !!----------------------------------------------------------------------
  60. !
  61. IF( nn_timing == 1 ) CALL timing_start('dia_prod')
  62. !
  63. CALL wrk_alloc( jpi , jpj , z2d )
  64. CALL wrk_alloc( jpi , jpj, jpk , z3d )
  65. CALL wrk_alloc( jpi , jpj, jpk , zrhop )
  66. !
  67. IF( iom_use("urhop") .OR. iom_use("vrhop") .OR. iom_use("wrhop") &
  68. #if ! defined key_diaar5
  69. & .OR. iom_use("rhop") &
  70. #endif
  71. & ) THEN
  72. CALL eos( tsn, z3d, zrhop ) ! now in situ and potential density
  73. zrhop(:,:,:) = zrhop(:,:,:)-1000.e0 ! reference potential density to 1000 to avoid precision issues in rhop2 calculation
  74. zrhop(:,:,jpk) = 0._wp
  75. #if ! defined key_diaar5
  76. CALL iom_put( 'rhop', zrhop )
  77. #else
  78. ! If key_diaar5 set then there is already an iom_put call to output rhop.
  79. ! Really should be a standard diagnostics option?
  80. #endif
  81. ENDIF
  82. IF( iom_use("ut") ) THEN
  83. z3d(:,:,:) = 0.e0
  84. DO jk = 1, jpkm1
  85. DO jj = 2, jpjm1
  86. DO ji = fs_2, fs_jpim1 ! vector opt.
  87. z3d(ji,jj,jk) = un(ji,jj,jk) * 0.5 * ( tsn(ji,jj,jk,jp_tem) + tsn(ji+1,jj,jk,jp_tem) )
  88. END DO
  89. END DO
  90. END DO
  91. CALL iom_put( "ut", z3d ) ! product of temperature and zonal velocity at U points
  92. ENDIF
  93. IF( iom_use("vt") .OR. ln_diaptr ) THEN
  94. z3d(:,:,:) = 0.e0
  95. DO jk = 1, jpkm1
  96. DO jj = 2, jpjm1
  97. DO ji = fs_2, fs_jpim1 ! vector opt.
  98. z3d(ji,jj,jk) = vn(ji,jj,jk) * 0.5 * ( tsn(ji,jj,jk,jp_tem) + tsn(ji,jj+1,jk,jp_tem) )
  99. END DO
  100. END DO
  101. END DO
  102. CALL iom_put( "vt", z3d ) ! product of temperature and meridional velocity at V points
  103. DO jk = 1, jpkm1
  104. DO jj = 2, jpjm1
  105. DO ji = fs_2, fs_jpim1 ! vector opt.
  106. z3d(ji,jj,jk) = z3d(ji,jj,jk) * fse3v(ji,jj,jk) * e1v(ji,jj)
  107. END DO
  108. END DO
  109. END DO
  110. IF(ln_diaptr) CALL dia_ptr_ohst_components( jp_tem, 'vts', z3d)
  111. ENDIF
  112. IF( iom_use("wt") ) THEN
  113. z3d(:,:,:) = 0.e0
  114. DO jj = 2, jpjm1
  115. DO ji = fs_2, fs_jpim1 ! vector opt.
  116. z3d(ji,jj,1) = wn(ji,jj,1) * tsn(ji,jj,1,jp_tem)
  117. END DO
  118. END DO
  119. DO jk = 2, jpkm1
  120. DO jj = 2, jpjm1
  121. DO ji = fs_2, fs_jpim1 ! vector opt.
  122. z3d(ji,jj,jk) = wn(ji,jj,jk) * 0.5 * ( tsn(ji,jj,jk-1,jp_tem) + tsn(ji,jj,jk,jp_tem) )
  123. END DO
  124. END DO
  125. END DO
  126. CALL iom_put( "wt", z3d ) ! product of temperature and vertical velocity at W points
  127. ENDIF
  128. IF( iom_use("us") ) THEN
  129. z3d(:,:,:) = 0.e0
  130. DO jk = 1, jpkm1
  131. DO jj = 2, jpjm1
  132. DO ji = fs_2, fs_jpim1 ! vector opt.
  133. z3d(ji,jj,jk) = un(ji,jj,jk) * 0.5 * ( tsn(ji,jj,jk,jp_sal) + tsn(ji+1,jj,jk,jp_sal) )
  134. END DO
  135. END DO
  136. END DO
  137. CALL iom_put( "us", z3d ) ! product of salinity and zonal velocity at U points
  138. ENDIF
  139. IF( iom_use("vs") .OR. ln_diaptr ) THEN
  140. z3d(:,:,:) = 0.e0
  141. DO jk = 1, jpkm1
  142. DO jj = 2, jpjm1
  143. DO ji = fs_2, fs_jpim1 ! vector opt.
  144. z3d(ji,jj,jk) = vn(ji,jj,jk) * 0.5 * ( tsn(ji,jj,jk,jp_sal) + tsn(ji,jj+1,jk,jp_sal) )
  145. END DO
  146. END DO
  147. END DO
  148. CALL iom_put( "vs", z3d ) ! product of salinity and meridional velocity at V points
  149. DO jk = 1, jpkm1
  150. DO jj = 2, jpjm1
  151. DO ji = fs_2, fs_jpim1 ! vector opt.
  152. z3d(ji,jj,jk) = z3d(ji,jj,jk) * fse3v(ji,jj,jk) * e1v(ji,jj)
  153. END DO
  154. END DO
  155. END DO
  156. IF(ln_diaptr) CALL dia_ptr_ohst_components( jp_sal, 'vts', z3d)
  157. ENDIF
  158. IF( iom_use("ws") ) THEN
  159. z3d(:,:,:) = 0.e0
  160. DO jj = 2, jpjm1
  161. DO ji = fs_2, fs_jpim1 ! vector opt.
  162. z3d(ji,jj,1) = wn(ji,jj,1) * tsn(ji,jj,1,jp_sal)
  163. END DO
  164. END DO
  165. DO jk = 2, jpkm1
  166. DO jj = 2, jpjm1
  167. DO ji = fs_2, fs_jpim1 ! vector opt.
  168. z3d(ji,jj,jk) = wn(ji,jj,jk) * 0.5 * ( tsn(ji,jj,jk-1,jp_sal) + tsn(ji,jj,jk,jp_sal) )
  169. END DO
  170. END DO
  171. END DO
  172. CALL iom_put( "ws", z3d ) ! product of salinity and vertical velocity at W points
  173. ENDIF
  174. IF( iom_use("urhop") ) THEN
  175. z3d(:,:,:) = 0.e0
  176. DO jk = 1, jpkm1
  177. DO jj = 2, jpjm1
  178. DO ji = fs_2, fs_jpim1 ! vector opt.
  179. z3d(ji,jj,jk) = un(ji,jj,jk) * 0.5 * ( zrhop(ji,jj,jk) + zrhop(ji+1,jj,jk) )
  180. END DO
  181. END DO
  182. END DO
  183. CALL iom_put( "urhop", z3d ) ! product of density and zonal velocity at U points
  184. ENDIF
  185. IF( iom_use("vrhop") ) THEN
  186. z3d(:,:,:) = 0.e0
  187. DO jk = 1, jpkm1
  188. DO jj = 2, jpjm1
  189. DO ji = fs_2, fs_jpim1 ! vector opt.
  190. z3d(ji,jj,jk) = vn(ji,jj,jk) * 0.5 * ( zrhop(ji,jj,jk) + zrhop(ji,jj+1,jk) )
  191. END DO
  192. END DO
  193. END DO
  194. CALL iom_put( "vrhop", z3d ) ! product of density and meridional velocity at V points
  195. ENDIF
  196. IF( iom_use("wrhop") ) THEN
  197. z3d(:,:,:) = 0.e0
  198. DO jj = 2, jpjm1
  199. DO ji = fs_2, fs_jpim1 ! vector opt.
  200. z3d(ji,jj,1) = wn(ji,jj,1) * zrhop(ji,jj,1)
  201. END DO
  202. END DO
  203. DO jk = 2, jpkm1
  204. DO jj = 2, jpjm1
  205. DO ji = fs_2, fs_jpim1 ! vector opt.
  206. z3d(ji,jj,jk) = wn(ji,jj,jk) * 0.5 * ( zrhop(ji,jj,jk-1) + zrhop(ji,jj,jk) )
  207. END DO
  208. END DO
  209. END DO
  210. CALL iom_put( "wrhop", z3d ) ! product of density and vertical velocity at W points
  211. ENDIF
  212. !
  213. CALL wrk_dealloc( jpi , jpj , z2d )
  214. CALL wrk_dealloc( jpi , jpj, jpk , z3d )
  215. CALL wrk_dealloc( jpi , jpj, jpk , zrhop )
  216. !
  217. IF( nn_timing == 1 ) CALL timing_stop('dia_prod')
  218. !
  219. END SUBROUTINE dia_prod
  220. #else
  221. !!----------------------------------------------------------------------
  222. !! Default option : NO diaprod
  223. !!----------------------------------------------------------------------
  224. USE in_out_manager ! I/O manager
  225. LOGICAL, PUBLIC, PARAMETER :: lk_diaprod = .FALSE. ! coupled flag
  226. CONTAINS
  227. SUBROUTINE dia_prod( kt ) ! Empty routine
  228. INTEGER :: kt
  229. IF( kt == nit000 .AND. lwp ) &
  230. WRITE(*,*) 'dia_prod: You should not have seen this print! error?', kt
  231. END SUBROUTINE dia_prod
  232. #endif
  233. !!======================================================================
  234. END MODULE diaprod