sbcssm.F90 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. MODULE sbcssm
  2. !!======================================================================
  3. !! *** MODULE sbcssm ***
  4. !! Surface module : provide time-mean ocean surface variables
  5. !!======================================================================
  6. !! History : 9.0 ! 2006-07 (G. Madec) Original code
  7. !! 3.3 ! 2010-10 (C. Bricaud, G. Madec) add the Patm forcing for sea-ice
  8. !!----------------------------------------------------------------------
  9. !!----------------------------------------------------------------------
  10. !! sbc_ssm : calculate sea surface mean currents, temperature,
  11. !! and salinity over nn_fsbc time-step
  12. !!----------------------------------------------------------------------
  13. USE oce ! ocean dynamics and tracers
  14. USE dom_oce ! ocean space and time domain
  15. USE sbc_oce ! surface boundary condition: ocean fields
  16. USE sbcapr ! surface boundary condition: atmospheric pressure
  17. USE eosbn2 ! equation of state and related derivatives
  18. !
  19. USE in_out_manager ! I/O manager
  20. USE prtctl ! Print control
  21. USE iom ! IOM library
  22. IMPLICIT NONE
  23. PRIVATE
  24. PUBLIC sbc_ssm ! routine called by step.F90
  25. PUBLIC sbc_ssm_init ! routine called by sbcmod.F90
  26. LOGICAL, SAVE :: l_ssm_mean = .FALSE. ! keep track of whether means have been read
  27. ! from restart file
  28. !! * Substitutions
  29. # include "domzgr_substitute.h90"
  30. !!----------------------------------------------------------------------
  31. !! NEMO/OPA 3.3 , NEMO Consortium (2010)
  32. !! $Id: sbcssm.F90 4990 2014-12-15 16:42:49Z timgraham $
  33. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  34. !!----------------------------------------------------------------------
  35. CONTAINS
  36. SUBROUTINE sbc_ssm( kt )
  37. !!---------------------------------------------------------------------
  38. !! *** ROUTINE sbc_oce ***
  39. !!
  40. !! ** Purpose : provide ocean surface variable to sea-surface boundary
  41. !! condition computation
  42. !!
  43. !! ** Method : compute mean surface velocity (2 components at U and
  44. !! V-points) [m/s], temperature [Celcius] and salinity [psu] over
  45. !! the periode (kt - nn_fsbc) to kt
  46. !! Note that the inverse barometer ssh (i.e. ssh associated with Patm)
  47. !! is add to ssh_m when ln_apr_dyn = T. Required for sea-ice dynamics.
  48. !!---------------------------------------------------------------------
  49. INTEGER, INTENT(in) :: kt ! ocean time step
  50. !
  51. INTEGER :: ji, jj ! loop index
  52. REAL(wp) :: zcoef, zf_sbc ! local scalar
  53. REAL(wp), DIMENSION(jpi,jpj,jpts) :: zts
  54. !!---------------------------------------------------------------------
  55. ! !* surface T-, U-, V- ocean level variables (T, S, depth, velocity)
  56. DO jj = 1, jpj
  57. DO ji = 1, jpi
  58. zts(ji,jj,jp_tem) = tsn(ji,jj,mikt(ji,jj),jp_tem)
  59. zts(ji,jj,jp_sal) = tsn(ji,jj,mikt(ji,jj),jp_sal)
  60. END DO
  61. END DO
  62. !
  63. IF( nn_fsbc == 1 ) THEN ! Instantaneous surface fields !
  64. ! ! ---------------------------------------- !
  65. ssu_m(:,:) = ub(:,:,1)
  66. ssv_m(:,:) = vb(:,:,1)
  67. IF( ln_useCT ) THEN ; sst_m(:,:) = eos_pt_from_ct( zts(:,:,jp_tem), zts(:,:,jp_sal) )
  68. ELSE ; sst_m(:,:) = zts(:,:,jp_tem)
  69. ENDIF
  70. sss_m(:,:) = zts(:,:,jp_sal)
  71. ! ! removed inverse barometer ssh when Patm forcing is used (for sea-ice dynamics)
  72. IF( ln_apr_dyn ) THEN ; ssh_m(:,:) = sshn(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) )
  73. ELSE ; ssh_m(:,:) = sshn(:,:)
  74. ENDIF
  75. !
  76. IF( lk_vvl ) e3t_m(:,:) = fse3t_n(:,:,1)
  77. !
  78. frq_m(:,:) = fraqsr_1lev(:,:)
  79. !
  80. ELSE
  81. ! ! ----------------------------------------------- !
  82. IF( kt == nit000 .AND. .NOT. l_ssm_mean ) THEN ! Initialisation: 1st time-step, no input means !
  83. ! ! ----------------------------------------------- !
  84. IF(lwp) WRITE(numout,*)
  85. IF(lwp) WRITE(numout,*) '~~~~~~~ mean fields initialised to instantaneous values'
  86. zcoef = REAL( nn_fsbc - 1, wp )
  87. ssu_m(:,:) = zcoef * ub(:,:,1)
  88. ssv_m(:,:) = zcoef * vb(:,:,1)
  89. IF( ln_useCT ) THEN ; sst_m(:,:) = zcoef * eos_pt_from_ct( zts(:,:,jp_tem), zts(:,:,jp_sal) )
  90. ELSE ; sst_m(:,:) = zcoef * zts(:,:,jp_tem)
  91. ENDIF
  92. sss_m(:,:) = zcoef * zts(:,:,jp_sal)
  93. ! ! removed inverse barometer ssh when Patm forcing is used (for sea-ice dynamics)
  94. IF( ln_apr_dyn ) THEN ; ssh_m(:,:) = zcoef * ( sshn(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) ) )
  95. ELSE ; ssh_m(:,:) = zcoef * sshn(:,:)
  96. ENDIF
  97. !
  98. IF( lk_vvl ) e3t_m(:,:) = zcoef * fse3t_n(:,:,1)
  99. !
  100. frq_m(:,:) = zcoef * fraqsr_1lev(:,:)
  101. ! ! ---------------------------------------- !
  102. ELSEIF( MOD( kt - 2 , nn_fsbc ) == 0 ) THEN ! Initialisation: New mean computation !
  103. ! ! ---------------------------------------- !
  104. ssu_m(:,:) = 0.e0 ! reset to zero ocean mean sbc fields
  105. ssv_m(:,:) = 0.e0
  106. sst_m(:,:) = 0.e0
  107. sss_m(:,:) = 0.e0
  108. ssh_m(:,:) = 0.e0
  109. IF( lk_vvl ) e3t_m(:,:) = 0.e0
  110. frq_m(:,:) = 0.e0
  111. ENDIF
  112. ! ! ---------------------------------------- !
  113. ! ! Cumulate at each time step !
  114. ! ! ---------------------------------------- !
  115. ssu_m(:,:) = ssu_m(:,:) + ub(:,:,1)
  116. ssv_m(:,:) = ssv_m(:,:) + vb(:,:,1)
  117. IF( ln_useCT ) THEN ; sst_m(:,:) = sst_m(:,:) + eos_pt_from_ct( zts(:,:,jp_tem), zts(:,:,jp_sal) )
  118. ELSE ; sst_m(:,:) = sst_m(:,:) + zts(:,:,jp_tem)
  119. ENDIF
  120. sss_m(:,:) = sss_m(:,:) + zts(:,:,jp_sal)
  121. ! ! removed inverse barometer ssh when Patm forcing is used (for sea-ice dynamics)
  122. IF( ln_apr_dyn ) THEN ; ssh_m(:,:) = ssh_m(:,:) + sshn(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) )
  123. ELSE ; ssh_m(:,:) = ssh_m(:,:) + sshn(:,:)
  124. ENDIF
  125. !
  126. IF( lk_vvl ) e3t_m(:,:) = fse3t_m(:,:) + fse3t_n(:,:,1)
  127. !
  128. frq_m(:,:) = frq_m(:,:) + fraqsr_1lev(:,:)
  129. ! ! ---------------------------------------- !
  130. IF( MOD( kt - 1 , nn_fsbc ) == 0 ) THEN ! Mean value at each nn_fsbc time-step !
  131. ! ! ---------------------------------------- !
  132. zcoef = 1. / REAL( nn_fsbc, wp )
  133. sst_m(:,:) = sst_m(:,:) * zcoef ! mean SST [Celcius]
  134. sss_m(:,:) = sss_m(:,:) * zcoef ! mean SSS [psu]
  135. ssu_m(:,:) = ssu_m(:,:) * zcoef ! mean suface current [m/s]
  136. ssv_m(:,:) = ssv_m(:,:) * zcoef !
  137. ssh_m(:,:) = ssh_m(:,:) * zcoef ! mean SSH [m]
  138. IF( lk_vvl ) e3t_m(:,:) = fse3t_m(:,:) * zcoef ! mean vertical scale factor [m]
  139. frq_m(:,:) = frq_m(:,:) * zcoef ! mean fraction of solar net radiation absorbed in the 1st T level [-]
  140. !
  141. ENDIF
  142. ! ! ---------------------------------------- !
  143. IF( lrst_oce ) THEN ! Write in the ocean restart file !
  144. ! ! ---------------------------------------- !
  145. IF(lwp) WRITE(numout,*)
  146. IF(lwp) WRITE(numout,*) 'sbc_ssm : sea surface mean fields written in ocean restart file ', &
  147. & 'at it= ', kt,' date= ', ndastp
  148. IF(lwp) WRITE(numout,*) '~~~~~~~'
  149. zf_sbc = REAL( nn_fsbc, wp )
  150. CALL iom_rstput( kt, nitrst, numrow, 'nn_fsbc', zf_sbc ) ! sbc frequency
  151. CALL iom_rstput( kt, nitrst, numrow, 'ssu_m' , ssu_m ) ! sea surface mean fields
  152. CALL iom_rstput( kt, nitrst, numrow, 'ssv_m' , ssv_m )
  153. CALL iom_rstput( kt, nitrst, numrow, 'sst_m' , sst_m )
  154. CALL iom_rstput( kt, nitrst, numrow, 'sss_m' , sss_m )
  155. CALL iom_rstput( kt, nitrst, numrow, 'ssh_m' , ssh_m )
  156. IF( lk_vvl ) CALL iom_rstput( kt, nitrst, numrow, 'e3t_m' , e3t_m )
  157. CALL iom_rstput( kt, nitrst, numrow, 'frq_m' , frq_m )
  158. !
  159. ENDIF
  160. !
  161. ENDIF
  162. !
  163. IF( MOD( kt - 1 , nn_fsbc ) == 0 ) THEN ! Mean value at each nn_fsbc time-step !
  164. CALL iom_put( 'ssu_m', ssu_m )
  165. CALL iom_put( 'ssv_m', ssv_m )
  166. CALL iom_put( 'sst_m', sst_m )
  167. CALL iom_put( 'sss_m', sss_m )
  168. CALL iom_put( 'ssh_m', ssh_m )
  169. IF( lk_vvl ) CALL iom_put( 'e3t_m', e3t_m )
  170. CALL iom_put( 'frq_m', frq_m )
  171. ENDIF
  172. !
  173. END SUBROUTINE sbc_ssm
  174. SUBROUTINE sbc_ssm_init
  175. !!----------------------------------------------------------------------
  176. !! *** ROUTINE sbc_ssm_init ***
  177. !!
  178. !! ** Purpose : Initialisation of the sbc data
  179. !!
  180. !! ** Action : - read parameters
  181. !!----------------------------------------------------------------------
  182. REAL(wp) :: zcoef, zf_sbc ! local scalar
  183. !!----------------------------------------------------------------------
  184. IF( nn_fsbc == 1 ) THEN
  185. !
  186. IF(lwp) WRITE(numout,*)
  187. IF(lwp) WRITE(numout,*) 'sbc_ssm : sea surface mean fields, nn_fsbc=1 : instantaneous values'
  188. IF(lwp) WRITE(numout,*) '~~~~~~~ '
  189. !
  190. ELSE
  191. !
  192. IF(lwp) WRITE(numout,*)
  193. IF(lwp) WRITE(numout,*) 'sbc_ssm : sea surface mean fields'
  194. IF(lwp) WRITE(numout,*) '~~~~~~~ '
  195. !
  196. IF( ln_rstart .AND. iom_varid( numror, 'nn_fsbc', ldstop = .FALSE. ) > 0 ) THEN
  197. l_ssm_mean = .TRUE.
  198. CALL iom_get( numror , 'nn_fsbc', zf_sbc ) ! sbc frequency of previous run
  199. CALL iom_get( numror, jpdom_autoglo, 'ssu_m' , ssu_m ) ! sea surface mean velocity (T-point)
  200. CALL iom_get( numror, jpdom_autoglo, 'ssv_m' , ssv_m ) ! " " velocity (V-point)
  201. CALL iom_get( numror, jpdom_autoglo, 'sst_m' , sst_m ) ! " " temperature (T-point)
  202. CALL iom_get( numror, jpdom_autoglo, 'sss_m' , sss_m ) ! " " salinity (T-point)
  203. CALL iom_get( numror, jpdom_autoglo, 'ssh_m' , ssh_m ) ! " " height (T-point)
  204. IF( lk_vvl ) CALL iom_get( numror, jpdom_autoglo, 'e3t_m', e3t_m )
  205. ! fraction of solar net radiation absorbed in 1st T level
  206. IF( iom_varid( numror, 'frq_m', ldstop = .FALSE. ) > 0 ) THEN
  207. CALL iom_get( numror, jpdom_autoglo, 'frq_m' , frq_m )
  208. ELSE
  209. frq_m(:,:) = 1._wp ! default definition
  210. ENDIF
  211. !
  212. IF( zf_sbc /= REAL( nn_fsbc, wp ) ) THEN ! nn_fsbc has changed between 2 runs
  213. IF(lwp) WRITE(numout,*) '~~~~~~~ restart with a change in the frequency of mean ', &
  214. & 'from ', zf_sbc, ' to ', nn_fsbc
  215. zcoef = REAL( nn_fsbc - 1, wp ) / zf_sbc
  216. ssu_m(:,:) = zcoef * ssu_m(:,:)
  217. ssv_m(:,:) = zcoef * ssv_m(:,:)
  218. sst_m(:,:) = zcoef * sst_m(:,:)
  219. sss_m(:,:) = zcoef * sss_m(:,:)
  220. ssh_m(:,:) = zcoef * ssh_m(:,:)
  221. IF( lk_vvl ) e3t_m(:,:) = zcoef * fse3t_m(:,:)
  222. frq_m(:,:) = zcoef * frq_m(:,:)
  223. ELSE
  224. IF(lwp) WRITE(numout,*) '~~~~~~~ mean fields read in the ocean restart file'
  225. ENDIF
  226. ENDIF
  227. ENDIF
  228. !
  229. IF( .NOT. l_ssm_mean ) THEN ! default initialisation. needed by lim_istate
  230. !
  231. IF(lwp) WRITE(numout,*) ' default initialisation of ss?_m arrays'
  232. ssu_m(:,:) = ub(:,:,1)
  233. ssv_m(:,:) = vb(:,:,1)
  234. IF( ln_useCT ) THEN ; sst_m(:,:) = eos_pt_from_ct( tsn(:,:,1,jp_tem), tsn(:,:,1,jp_sal) )
  235. ELSE ; sst_m(:,:) = tsn(:,:,1,jp_tem)
  236. ENDIF
  237. sss_m(:,:) = tsn(:,:,1,jp_sal)
  238. ssh_m(:,:) = sshn(:,:)
  239. IF( lk_vvl ) e3t_m(:,:) = fse3t_n(:,:,1)
  240. frq_m(:,:) = 1._wp
  241. !
  242. ENDIF
  243. !
  244. END SUBROUTINE sbc_ssm_init
  245. !!======================================================================
  246. END MODULE sbcssm