crsfld.F90 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. MODULE crsfld
  2. !!======================================================================
  3. !! *** MODULE crsdfld ***
  4. !! Ocean coarsening : coarse ocean fields
  5. !!=====================================================================
  6. !! 2012-07 (J. Simeon, C. Calone, G. Madec, C. Ethe)
  7. !!----------------------------------------------------------------------
  8. !!----------------------------------------------------------------------
  9. !! crs_fld : create the standard output files for coarse grid and prep
  10. !! other variables needed to be passed to TOP
  11. !!----------------------------------------------------------------------
  12. USE oce ! ocean dynamics and tracers
  13. USE dom_oce ! ocean space and time domain
  14. USE ldftra_oce ! ocean active tracers: lateral physics
  15. USE sbc_oce ! Surface boundary condition: ocean fields
  16. USE zdf_oce ! vertical physics: ocean fields
  17. USE zdfddm ! vertical physics: double diffusion
  18. USE lbclnk ! ocean lateral boundary conditions (or mpp link)
  19. USE in_out_manager ! I/O manager
  20. USE timing ! preformance summary
  21. USE wrk_nemo ! working array
  22. USE crs
  23. USE crsdom
  24. USE crslbclnk
  25. USE iom
  26. IMPLICIT NONE
  27. PRIVATE
  28. PUBLIC crs_fld ! routines called by step.F90
  29. !! * Substitutions
  30. # include "zdfddm_substitute.h90"
  31. # include "domzgr_substitute.h90"
  32. # include "vectopt_loop_substitute.h90"
  33. !!----------------------------------------------------------------------
  34. !! NEMO/OPA 3.3 , NEMO Consortium (2010)
  35. !! $Id: crsfld.F90 2355 2015-05-20 07:11:50Z ufla $
  36. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  37. !!----------------------------------------------------------------------
  38. CONTAINS
  39. SUBROUTINE crs_fld( kt )
  40. !!---------------------------------------------------------------------
  41. !! *** ROUTINE crs_fld ***
  42. !!
  43. !! ** Purpose : Basic output of coarsened dynamics and tracer fields
  44. !! NETCDF format is used by default
  45. !! 1. Accumulate in time the dimensionally-weighted fields
  46. !! 2. At time of output, rescale [1] by dimension and time
  47. !! to yield the spatial and temporal average.
  48. !! See. diawri_dimg.h90, sbcmod.F90
  49. !!
  50. !! ** Method :
  51. !!----------------------------------------------------------------------
  52. !!
  53. INTEGER, INTENT( in ) :: kt ! ocean time-step index
  54. !!
  55. INTEGER :: ji, jj, jk ! dummy loop indices
  56. !!
  57. REAL(wp), POINTER, DIMENSION(:,:,:) :: zfse3t, zfse3u, zfse3v, zfse3w ! 3D workspace for e3
  58. REAL(wp), POINTER, DIMENSION(:,:,:) :: zt, zs
  59. REAL(wp), POINTER, DIMENSION(:,:,:) :: zt_crs, zs_crs !
  60. REAL(wp) :: z2dcrsu, z2dcrsv
  61. !!
  62. !!----------------------------------------------------------------------
  63. !
  64. IF( nn_timing == 1 ) CALL timing_start('crs_fld')
  65. ! Initialize arrays
  66. CALL wrk_alloc( jpi, jpj, jpk, zfse3t, zfse3w )
  67. CALL wrk_alloc( jpi, jpj, jpk, zfse3u, zfse3v )
  68. CALL wrk_alloc( jpi, jpj, jpk, zt, zs )
  69. !
  70. CALL wrk_alloc( jpi_crs, jpj_crs, jpk, zt_crs, zs_crs )
  71. ! Depth work arrrays
  72. zfse3t(:,:,:) = fse3t(:,:,:)
  73. zfse3u(:,:,:) = fse3u(:,:,:)
  74. zfse3v(:,:,:) = fse3v(:,:,:)
  75. zfse3w(:,:,:) = fse3w(:,:,:)
  76. IF( kt == nit000 ) THEN
  77. tsn_crs (:,:,:,:) = 0._wp ! temp/sal array, now
  78. un_crs (:,:,: ) = 0._wp ! u-velocity
  79. vn_crs (:,:,: ) = 0._wp ! v-velocity
  80. wn_crs (:,:,: ) = 0._wp ! w
  81. avt_crs (:,:,: ) = 0._wp ! avt
  82. hdivn_crs(:,:,: ) = 0._wp ! hdiv
  83. rke_crs (:,:,: ) = 0._wp ! rke
  84. sshn_crs (:,: ) = 0._wp ! ssh
  85. utau_crs (:,: ) = 0._wp ! taux
  86. vtau_crs (:,: ) = 0._wp ! tauy
  87. wndm_crs (:,: ) = 0._wp ! wind speed
  88. qsr_crs (:,: ) = 0._wp ! qsr
  89. emp_crs (:,: ) = 0._wp ! emp
  90. emp_b_crs(:,: ) = 0._wp ! emp
  91. rnf_crs (:,: ) = 0._wp ! runoff
  92. fr_i_crs (:,: ) = 0._wp ! ice cover
  93. ENDIF
  94. CALL iom_swap( "nemo_crs" ) ! swap on the coarse grid
  95. ! 2. Coarsen fields at each time step
  96. ! --------------------------------------------------------
  97. ! Temperature
  98. zt(:,:,:) = tsn(:,:,:,jp_tem) ; zt_crs(:,:,:) = 0._wp
  99. CALL crs_dom_ope( zt, 'VOL', 'T', tmask, zt_crs, p_e12=e1e2t, p_e3=zfse3t, psgn=1.0 )
  100. tsn_crs(:,:,:,jp_tem) = zt_crs(:,:,:)
  101. CALL iom_put( "toce", tsn_crs(:,:,:,jp_tem) ) ! temp
  102. CALL iom_put( "sst" , tsn_crs(:,:,1,jp_tem) ) ! sst
  103. ! Salinity
  104. zs(:,:,:) = tsn(:,:,:,jp_sal) ; zs_crs(:,:,:) = 0._wp
  105. CALL crs_dom_ope( zs, 'VOL', 'T', tmask, zs_crs, p_e12=e1e2t, p_e3=zfse3t, psgn=1.0 )
  106. tsn_crs(:,:,:,jp_sal) = zt_crs(:,:,:)
  107. CALL iom_put( "soce" , tsn_crs(:,:,:,jp_sal) ) ! sal
  108. CALL iom_put( "sss" , tsn_crs(:,:,1,jp_sal) ) ! sss
  109. ! U-velocity
  110. CALL crs_dom_ope( un, 'SUM', 'U', umask, un_crs, p_e12=e2u, p_e3=zfse3u, p_surf_crs=e2e3u_msk, psgn=-1.0 )
  111. !
  112. zt(:,:,:) = 0._wp ; zs(:,:,:) = 0._wp ; zt_crs(:,:,:) = 0._wp ; zs_crs(:,:,:) = 0._wp
  113. DO jk = 1, jpkm1
  114. DO jj = 2, jpjm1
  115. DO ji = 2, jpim1
  116. zt(ji,jj,jk) = un(ji,jj,jk) * 0.5 * ( tsn(ji,jj,jk,jp_tem) + tsn(ji+1,jj,jk,jp_tem) )
  117. zs(ji,jj,jk) = un(ji,jj,jk) * 0.5 * ( tsn(ji,jj,jk,jp_sal) + tsn(ji+1,jj,jk,jp_sal) )
  118. END DO
  119. END DO
  120. END DO
  121. CALL crs_dom_ope( zt, 'SUM', 'U', umask, zt_crs, p_e12=e2u, p_e3=zfse3u, p_surf_crs=e2e3u_msk, psgn=-1.0 )
  122. CALL crs_dom_ope( zs, 'SUM', 'U', umask, zs_crs, p_e12=e2u, p_e3=zfse3u, p_surf_crs=e2e3u_msk, psgn=-1.0 )
  123. CALL iom_put( "uoce" , un_crs ) ! i-current
  124. CALL iom_put( "uocet" , zt_crs ) ! uT
  125. CALL iom_put( "uoces" , zs_crs ) ! uS
  126. ! V-velocity
  127. CALL crs_dom_ope( vn, 'SUM', 'V', vmask, vn_crs, p_e12=e1v, p_e3=zfse3v, p_surf_crs=e1e3v_msk, psgn=-1.0 )
  128. !
  129. zt(:,:,:) = 0._wp ; zs(:,:,:) = 0._wp ; zt_crs(:,:,:) = 0._wp ; zs_crs(:,:,:) = 0._wp
  130. DO jk = 1, jpkm1
  131. DO jj = 2, jpjm1
  132. DO ji = 2, jpim1
  133. zt(ji,jj,jk) = vn(ji,jj,jk) * 0.5 * ( tsn(ji,jj,jk,jp_tem) + tsn(ji,jj+1,jk,jp_tem) )
  134. zs(ji,jj,jk) = vn(ji,jj,jk) * 0.5 * ( tsn(ji,jj,jk,jp_sal) + tsn(ji,jj+1,jk,jp_sal) )
  135. END DO
  136. END DO
  137. END DO
  138. CALL crs_dom_ope( zt, 'SUM', 'V', vmask, zt_crs, p_e12=e1v, p_e3=zfse3v, p_surf_crs=e1e3v_msk, psgn=-1.0 )
  139. CALL crs_dom_ope( zs, 'SUM', 'V', vmask, zs_crs, p_e12=e1v, p_e3=zfse3v, p_surf_crs=e1e3v_msk, psgn=-1.0 )
  140. CALL iom_put( "voce" , vn_crs ) ! i-current
  141. CALL iom_put( "vocet" , zt_crs ) ! vT
  142. CALL iom_put( "voces" , zs_crs ) ! vS
  143. ! Kinetic energy
  144. CALL crs_dom_ope( rke, 'VOL', 'T', tmask, rke_crs, p_e12=e1e2t, p_e3=zfse3t, psgn=1.0 )
  145. CALL iom_put( "eken", rke_crs )
  146. ! Horizontal divergence ( following OPA_SRC/DYN/divcur.F90 )
  147. DO jk = 1, jpkm1
  148. DO ji = 2, jpi_crsm1
  149. DO jj = 2, jpj_crsm1
  150. IF( tmask_crs(ji,jj,jk ) > 0 ) THEN
  151. z2dcrsu = ( un_crs(ji ,jj ,jk) * crs_surfu_wgt(ji ,jj ,jk) ) &
  152. & - ( un_crs(ji-1,jj ,jk) * crs_surfu_wgt(ji-1,jj ,jk) )
  153. z2dcrsv = ( vn_crs(ji ,jj ,jk) * crs_surfv_wgt(ji ,jj ,jk) ) &
  154. & - ( vn_crs(ji ,jj-1,jk) * crs_surfv_wgt(ji ,jj-1,jk) )
  155. !
  156. hdivn_crs(ji,jj,jk) = ( z2dcrsu + z2dcrsv ) / crs_volt_wgt(ji,jj,jk)
  157. ENDIF
  158. ENDDO
  159. ENDDO
  160. ENDDO
  161. CALL crs_lbc_lnk( hdivn_crs, 'T', 1.0 )
  162. !
  163. CALL iom_put( "hdiv", hdivn_crs )
  164. ! W-velocity
  165. IF( ln_crs_wn ) THEN
  166. CALL crs_dom_ope( wn, 'SUM', 'W', tmask, wn_crs, p_e12=e1e2t, p_surf_crs=e1e2w_msk, psgn=1.0 )
  167. ! CALL crs_dom_ope( wn, 'VOL', 'W', tmask, wn_crs, p_e12=e1e2t, p_e3=zfse3w )
  168. ELSE
  169. wn_crs(:,:,jpk) = 0._wp
  170. DO jk = jpkm1, 1, -1
  171. wn_crs(:,:,jk) = wn_crs(:,:,jk+1) - e3t_crs(:,:,jk) * hdivn_crs(:,:,jk)
  172. ENDDO
  173. ENDIF
  174. CALL iom_put( "woce", wn_crs ) ! vertical velocity
  175. ! free memory
  176. ! avt, avs
  177. SELECT CASE ( nn_crs_kz )
  178. CASE ( 0 )
  179. CALL crs_dom_ope( avt, 'VOL', 'W', tmask, avt_crs, p_e12=e1e2t, p_e3=zfse3w, psgn=1.0 )
  180. CASE ( 1 )
  181. CALL crs_dom_ope( avt, 'MAX', 'W', tmask, avt_crs, p_e12=e1e2t, p_e3=zfse3w, psgn=1.0 )
  182. CASE ( 2 )
  183. CALL crs_dom_ope( avt, 'MIN', 'W', tmask, avt_crs, p_e12=e1e2t, p_e3=zfse3w, psgn=1.0 )
  184. END SELECT
  185. !
  186. CALL iom_put( "avt", avt_crs ) ! Kz
  187. ! sbc fields
  188. CALL crs_dom_ope( sshn , 'VOL', 'T', tmask, sshn_crs , p_e12=e1e2t, p_e3=zfse3t , psgn=1.0 )
  189. CALL crs_dom_ope( utau , 'SUM', 'U', umask, utau_crs , p_e12=e2u , p_surf_crs=e2u_crs , psgn=1.0 )
  190. CALL crs_dom_ope( vtau , 'SUM', 'V', vmask, vtau_crs , p_e12=e1v , p_surf_crs=e1v_crs , psgn=1.0 )
  191. CALL crs_dom_ope( wndm , 'SUM', 'T', tmask, wndm_crs , p_e12=e1e2t, p_surf_crs=e1e2t_crs, psgn=1.0 )
  192. CALL crs_dom_ope( rnf , 'MAX', 'T', tmask, rnf_crs , psgn=1.0 )
  193. CALL crs_dom_ope( qsr , 'SUM', 'T', tmask, qsr_crs , p_e12=e1e2t, p_surf_crs=e1e2t_crs, psgn=1.0 )
  194. CALL crs_dom_ope( emp_b, 'SUM', 'T', tmask, emp_b_crs, p_e12=e1e2t, p_surf_crs=e1e2t_crs, psgn=1.0 )
  195. CALL crs_dom_ope( emp , 'SUM', 'T', tmask, emp_crs , p_e12=e1e2t, p_surf_crs=e1e2t_crs, psgn=1.0 )
  196. CALL crs_dom_ope( sfx , 'SUM', 'T', tmask, sfx_crs , p_e12=e1e2t, p_surf_crs=e1e2t_crs, psgn=1.0 )
  197. CALL crs_dom_ope( fr_i , 'SUM', 'T', tmask, fr_i_crs , p_e12=e1e2t, p_surf_crs=e1e2t_crs, psgn=1.0 )
  198. CALL iom_put( "ssh" , sshn_crs ) ! ssh output
  199. CALL iom_put( "utau" , utau_crs ) ! i-tau output
  200. CALL iom_put( "vtau" , vtau_crs ) ! j-tau output
  201. CALL iom_put( "wspd" , wndm_crs ) ! wind speed output
  202. CALL iom_put( "runoffs" , rnf_crs ) ! runoff output
  203. CALL iom_put( "qsr" , qsr_crs ) ! qsr output
  204. CALL iom_put( "empmr" , emp_crs ) ! water flux output
  205. CALL iom_put( "saltflx" , sfx_crs ) ! salt flux output
  206. CALL iom_put( "ice_cover", fr_i_crs ) ! ice cover output
  207. ! free memory
  208. CALL wrk_dealloc( jpi, jpj, jpk, zfse3t, zfse3w )
  209. CALL wrk_dealloc( jpi, jpj, jpk, zfse3u, zfse3v )
  210. CALL wrk_dealloc( jpi, jpj, jpk, zt, zs )
  211. CALL wrk_dealloc( jpi_crs, jpj_crs, jpk, zt_crs, zs_crs )
  212. !
  213. CALL iom_swap( "nemo" ) ! return back on high-resolution grid
  214. !
  215. IF( nn_timing == 1 ) CALL timing_stop('crs_fld')
  216. !
  217. END SUBROUTINE crs_fld
  218. !!======================================================================
  219. END MODULE crsfld