diahsb.F90 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. MODULE diahsb
  2. !!======================================================================
  3. !! *** MODULE diahsb ***
  4. !! Ocean diagnostics: Heat, salt and volume budgets
  5. !!======================================================================
  6. !! History : 3.3 ! 2010-09 (M. Leclair) Original code
  7. !! ! 2012-10 (C. Rousset) add iom_put
  8. !!----------------------------------------------------------------------
  9. !!----------------------------------------------------------------------
  10. !! dia_hsb : Diagnose the conservation of ocean heat and salt contents, and volume
  11. !! dia_hsb_rst : Read or write DIA file in restart file
  12. !! dia_hsb_init : Initialization of the conservation diagnostic
  13. !!----------------------------------------------------------------------
  14. USE oce ! ocean dynamics and tracers
  15. USE dom_oce ! ocean space and time domain
  16. USE phycst ! physical constants
  17. USE sbc_oce ! surface thermohaline fluxes
  18. USE sbcrnf ! river runoff
  19. USE sbcisf ! ice shelves
  20. USE domvvl ! vertical scale factors
  21. USE traqsr ! penetrative solar radiation
  22. USE trabbc ! bottom boundary condition
  23. USE trabbc ! bottom boundary condition
  24. USE bdy_par ! (for lk_bdy)
  25. USE restart ! ocean restart
  26. !
  27. USE iom ! I/O manager
  28. USE in_out_manager ! I/O manager
  29. USE lib_fortran ! glob_sum
  30. USE lib_mpp ! distributed memory computing library
  31. USE timing ! preformance summary
  32. USE wrk_nemo ! work arrays
  33. IMPLICIT NONE
  34. PRIVATE
  35. PUBLIC dia_hsb ! routine called by step.F90
  36. PUBLIC dia_hsb_init ! routine called by nemogcm.F90
  37. LOGICAL, PUBLIC :: ln_diahsb !: check the heat and salt budgets
  38. REAL(wp) :: surf_tot ! ocean surface
  39. REAL(wp) :: frc_t, frc_s, frc_v ! global forcing trends
  40. REAL(wp) :: frc_wn_t, frc_wn_s ! global forcing trends
  41. !
  42. REAL(wp), DIMENSION(:,:) , ALLOCATABLE :: surf , ssh_ini !
  43. REAL(wp), DIMENSION(:,:) , ALLOCATABLE :: ssh_hc_loc_ini, ssh_sc_loc_ini !
  44. REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: hc_loc_ini, sc_loc_ini, e3t_ini !
  45. !! * Substitutions
  46. # include "domzgr_substitute.h90"
  47. # include "vectopt_loop_substitute.h90"
  48. !!----------------------------------------------------------------------
  49. !! NEMO/OPA 3.3 , NEMO Consortium (2010)
  50. !! $Id: diahsb.F90 5628 2015-07-22 20:26:35Z mathiot $
  51. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  52. !!----------------------------------------------------------------------
  53. CONTAINS
  54. SUBROUTINE dia_hsb( kt )
  55. !!---------------------------------------------------------------------------
  56. !! *** ROUTINE dia_hsb ***
  57. !!
  58. !! ** Purpose: Compute the ocean global heat content, salt content and volume conservation
  59. !!
  60. !! ** Method : - Compute the deviation of heat content, salt content and volume
  61. !! at the current time step from their values at nit000
  62. !! - Compute the contribution of forcing and remove it from these deviations
  63. !!
  64. !!---------------------------------------------------------------------------
  65. INTEGER, INTENT(in) :: kt ! ocean time-step index
  66. !
  67. INTEGER :: ji, jj, jk ! dummy loop indice
  68. REAL(wp) :: zdiff_hc , zdiff_sc ! heat and salt content variations
  69. REAL(wp) :: zdiff_hc1 , zdiff_sc1 ! - - - -
  70. REAL(wp) :: zdiff_v1 , zdiff_v2 ! volume variation
  71. REAL(wp) :: zerr_hc1 , zerr_sc1 ! heat and salt content misfit
  72. REAL(wp) :: zvol_tot ! volume
  73. REAL(wp) :: z_frc_trd_t , z_frc_trd_s ! - -
  74. REAL(wp) :: z_frc_trd_v ! - -
  75. REAL(wp) :: z_wn_trd_t , z_wn_trd_s ! - -
  76. REAL(wp) :: z_ssh_hc , z_ssh_sc ! - -
  77. REAL(wp), DIMENSION(:,:), POINTER :: z2d0, z2d1
  78. !!---------------------------------------------------------------------------
  79. IF( nn_timing == 1 ) CALL timing_start('dia_hsb')
  80. !
  81. CALL wrk_alloc( jpi,jpj, z2d0, z2d1 )
  82. !
  83. tsn(:,:,:,1) = tsn(:,:,:,1) * tmask(:,:,:) ; tsb(:,:,:,1) = tsb(:,:,:,1) * tmask(:,:,:) ;
  84. tsn(:,:,:,2) = tsn(:,:,:,2) * tmask(:,:,:) ; tsb(:,:,:,2) = tsb(:,:,:,2) * tmask(:,:,:) ;
  85. ! ------------------------- !
  86. ! 1 - Trends due to forcing !
  87. ! ------------------------- !
  88. z_frc_trd_v = r1_rau0 * glob_sum( - ( emp(:,:) - rnf(:,:) + fwfisf(:,:) ) * surf(:,:) ) ! volume fluxes
  89. z_frc_trd_t = glob_sum( sbc_tsc(:,:,jp_tem) * surf(:,:) ) ! heat fluxes
  90. z_frc_trd_s = glob_sum( sbc_tsc(:,:,jp_sal) * surf(:,:) ) ! salt fluxes
  91. ! Add runoff heat & salt input
  92. IF( ln_rnf ) z_frc_trd_t = z_frc_trd_t + glob_sum( rnf_tsc(:,:,jp_tem) * surf(:,:) )
  93. IF( ln_rnf_sal) z_frc_trd_s = z_frc_trd_s + glob_sum( rnf_tsc(:,:,jp_sal) * surf(:,:) )
  94. ! Add ice shelf heat & salt input
  95. IF( nn_isf .GE. 1 ) THEN
  96. z_frc_trd_t = z_frc_trd_t + glob_sum( risf_tsc(:,:,jp_tem) * surf(:,:) )
  97. z_frc_trd_s = z_frc_trd_s + glob_sum( risf_tsc(:,:,jp_sal) * surf(:,:) )
  98. ENDIF
  99. ! Add penetrative solar radiation
  100. IF( ln_traqsr ) z_frc_trd_t = z_frc_trd_t + r1_rau0_rcp * glob_sum( qsr (:,:) * surf(:,:) )
  101. ! Add geothermal heat flux
  102. IF( ln_trabbc ) z_frc_trd_t = z_frc_trd_t + glob_sum( qgh_trd0(:,:) * surf(:,:) )
  103. !
  104. IF( .NOT. lk_vvl ) THEN
  105. IF ( ln_isfcav ) THEN
  106. DO ji=1,jpi
  107. DO jj=1,jpj
  108. z2d0(ji,jj) = surf(ji,jj) * wn(ji,jj,mikt(ji,jj)) * tsb(ji,jj,mikt(ji,jj),jp_tem)
  109. z2d1(ji,jj) = surf(ji,jj) * wn(ji,jj,mikt(ji,jj)) * tsb(ji,jj,mikt(ji,jj),jp_sal)
  110. ENDDO
  111. ENDDO
  112. ELSE
  113. z2d0(:,:) = surf(:,:) * wn(:,:,1) * tsb(:,:,1,jp_tem)
  114. z2d1(:,:) = surf(:,:) * wn(:,:,1) * tsb(:,:,1,jp_sal)
  115. END IF
  116. z_wn_trd_t = - glob_sum( z2d0 )
  117. z_wn_trd_s = - glob_sum( z2d1 )
  118. ENDIF
  119. frc_v = frc_v + z_frc_trd_v * rdt
  120. frc_t = frc_t + z_frc_trd_t * rdt
  121. frc_s = frc_s + z_frc_trd_s * rdt
  122. ! ! Advection flux through fixed surface (z=0)
  123. IF( .NOT. lk_vvl ) THEN
  124. frc_wn_t = frc_wn_t + z_wn_trd_t * rdt
  125. frc_wn_s = frc_wn_s + z_wn_trd_s * rdt
  126. ENDIF
  127. ! ------------------------ !
  128. ! 2 - Content variations !
  129. ! ------------------------ !
  130. zdiff_v2 = 0._wp
  131. zdiff_hc = 0._wp
  132. zdiff_sc = 0._wp
  133. ! volume variation (calculated with ssh)
  134. zdiff_v1 = glob_sum( surf(:,:) * ( sshn(:,:) - ssh_ini(:,:) ) )
  135. ! heat & salt content variation (associated with ssh)
  136. IF( .NOT. lk_vvl ) THEN
  137. IF ( ln_isfcav ) THEN
  138. DO ji = 1, jpi
  139. DO jj = 1, jpj
  140. z2d0(ji,jj) = surf(ji,jj) * ( tsn(ji,jj,mikt(ji,jj),jp_tem) * sshn(ji,jj) - ssh_hc_loc_ini(ji,jj) )
  141. z2d1(ji,jj) = surf(ji,jj) * ( tsn(ji,jj,mikt(ji,jj),jp_sal) * sshn(ji,jj) - ssh_sc_loc_ini(ji,jj) )
  142. END DO
  143. END DO
  144. ELSE
  145. z2d0(:,:) = surf(:,:) * ( tsn(:,:,1,jp_tem) * sshn(:,:) - ssh_hc_loc_ini(:,:) )
  146. z2d1(:,:) = surf(:,:) * ( tsn(:,:,1,jp_sal) * sshn(:,:) - ssh_sc_loc_ini(:,:) )
  147. END IF
  148. z_ssh_hc = glob_sum( z2d0 )
  149. z_ssh_sc = glob_sum( z2d1 )
  150. ENDIF
  151. DO jk = 1, jpkm1
  152. ! volume variation (calculated with scale factors)
  153. zdiff_v2 = zdiff_v2 + glob_sum( surf(:,:) * tmask(:,:,jk) &
  154. & * ( fse3t_n(:,:,jk) - e3t_ini(:,:,jk) ) )
  155. ! heat content variation
  156. zdiff_hc = zdiff_hc + glob_sum( surf(:,:) * tmask(:,:,jk) &
  157. & * ( fse3t_n(:,:,jk) * tsn(:,:,jk,jp_tem) - hc_loc_ini(:,:,jk) ) )
  158. ! salt content variation
  159. zdiff_sc = zdiff_sc + glob_sum( surf(:,:) * tmask(:,:,jk) &
  160. & * ( fse3t_n(:,:,jk) * tsn(:,:,jk,jp_sal) - sc_loc_ini(:,:,jk) ) )
  161. ENDDO
  162. ! ------------------------ !
  163. ! 3 - Drifts !
  164. ! ------------------------ !
  165. zdiff_v1 = zdiff_v1 - frc_v
  166. IF( lk_vvl ) zdiff_v2 = zdiff_v2 - frc_v
  167. zdiff_hc = zdiff_hc - frc_t
  168. zdiff_sc = zdiff_sc - frc_s
  169. IF( .NOT. lk_vvl ) THEN
  170. zdiff_hc1 = zdiff_hc + z_ssh_hc
  171. zdiff_sc1 = zdiff_sc + z_ssh_sc
  172. zerr_hc1 = z_ssh_hc - frc_wn_t
  173. zerr_sc1 = z_ssh_sc - frc_wn_s
  174. ENDIF
  175. ! ----------------------- !
  176. ! 4 - Diagnostics writing !
  177. ! ----------------------- !
  178. zvol_tot = 0._wp ! total ocean volume (calculated with scale factors)
  179. DO jk = 1, jpkm1
  180. zvol_tot = zvol_tot + glob_sum( surf(:,:) * tmask(:,:,jk) * fse3t_n(:,:,jk) )
  181. END DO
  182. !!gm to be added ?
  183. ! IF( .NOT. lk_vvl ) THEN ! fixed volume, add the ssh contribution
  184. ! zvol_tot = zvol_tot + glob_sum( surf(:,:) * sshn(:,:) )
  185. ! ENDIF
  186. !!gm end
  187. CALL iom_put( 'bgfrcvol' , frc_v * 1.e-9 ) ! vol - surface forcing (km3)
  188. CALL iom_put( 'bgfrctem' , frc_t * rau0 * rcp * 1.e-20 ) ! hc - surface forcing (1.e20 J)
  189. CALL iom_put( 'bgfrchfx' , frc_t * rau0 * rcp / & ! hc - surface forcing (W/m2)
  190. & ( surf_tot * kt * rdt ) )
  191. CALL iom_put( 'bgfrcsal' , frc_s * 1.e-9 ) ! sc - surface forcing (psu*km3)
  192. IF( lk_vvl ) THEN
  193. CALL iom_put( 'bgtemper' , zdiff_hc / zvol_tot ) ! Temperature drift (C)
  194. CALL iom_put( 'bgsaline' , zdiff_sc / zvol_tot ) ! Salinity drift (pss)
  195. CALL iom_put( 'bgheatco' , zdiff_hc * 1.e-20 * rau0 * rcp ) ! Heat content drift (1.e20 J)
  196. CALL iom_put( 'bgheatfx' , zdiff_hc * rau0 * rcp / & ! Heat flux drift (W/m2)
  197. & ( surf_tot * kt * rdt ) )
  198. CALL iom_put( 'bgsaltco' , zdiff_sc * 1.e-9 ) ! Salt content drift (psu*km3)
  199. CALL iom_put( 'bgvolssh' , zdiff_v1 * 1.e-9 ) ! volume ssh drift (km3)
  200. CALL iom_put( 'bgvole3t' , zdiff_v2 * 1.e-9 ) ! volume e3t drift (km3)
  201. ELSE
  202. CALL iom_put( 'bgtemper' , zdiff_hc1 / zvol_tot) ! Heat content drift (C)
  203. CALL iom_put( 'bgsaline' , zdiff_sc1 / zvol_tot) ! Salt content drift (pss)
  204. CALL iom_put( 'bgheatco' , zdiff_hc1 * 1.e-20 * rau0 * rcp ) ! Heat content drift (1.e20 J)
  205. CALL iom_put( 'bgheatfx' , zdiff_hc1 * rau0 * rcp / & ! Heat flux drift (W/m2)
  206. & ( surf_tot * kt * rdt ) )
  207. CALL iom_put( 'bgsaltco' , zdiff_sc1 * 1.e-9 ) ! Salt content drift (psu*km3)
  208. CALL iom_put( 'bgvolssh' , zdiff_v1 * 1.e-9 ) ! volume ssh drift (km3)
  209. CALL iom_put( 'bgmistem' , zerr_hc1 / zvol_tot ) ! hc - error due to free surface (C)
  210. CALL iom_put( 'bgmissal' , zerr_sc1 / zvol_tot ) ! sc - error due to free surface (psu)
  211. ENDIF
  212. !
  213. IF( lrst_oce ) CALL dia_hsb_rst( kt, 'WRITE' )
  214. CALL wrk_dealloc( jpi,jpj, z2d0, z2d1 )
  215. IF( nn_timing == 1 ) CALL timing_stop('dia_hsb')
  216. !
  217. END SUBROUTINE dia_hsb
  218. SUBROUTINE dia_hsb_rst( kt, cdrw )
  219. !!---------------------------------------------------------------------
  220. !! *** ROUTINE limdia_rst ***
  221. !!
  222. !! ** Purpose : Read or write DIA file in restart file
  223. !!
  224. !! ** Method : use of IOM library
  225. !!----------------------------------------------------------------------
  226. INTEGER , INTENT(in) :: kt ! ocean time-step
  227. CHARACTER(len=*), INTENT(in) :: cdrw ! "READ"/"WRITE" flag
  228. !
  229. INTEGER :: ji, jj, jk ! dummy loop indices
  230. !!----------------------------------------------------------------------
  231. !
  232. IF( TRIM(cdrw) == 'READ' ) THEN ! Read/initialise
  233. IF( ln_rstart ) THEN !* Read the restart file
  234. !
  235. IF(lwp) WRITE(numout,*) '~~~~~~~'
  236. IF(lwp) WRITE(numout,*) ' dia_hsb_rst at it= ', kt,' date= ', ndastp
  237. IF(lwp) WRITE(numout,*) '~~~~~~~'
  238. CALL iom_get( numror, 'frc_v', frc_v )
  239. CALL iom_get( numror, 'frc_t', frc_t )
  240. CALL iom_get( numror, 'frc_s', frc_s )
  241. IF( .NOT. lk_vvl ) THEN
  242. CALL iom_get( numror, 'frc_wn_t', frc_wn_t )
  243. CALL iom_get( numror, 'frc_wn_s', frc_wn_s )
  244. ENDIF
  245. CALL iom_get( numror, jpdom_autoglo, 'ssh_ini', ssh_ini(:,:) )
  246. CALL iom_get( numror, jpdom_autoglo, 'e3t_ini', e3t_ini(:,:,:) )
  247. CALL iom_get( numror, jpdom_autoglo, 'hc_loc_ini', hc_loc_ini(:,:,:) )
  248. CALL iom_get( numror, jpdom_autoglo, 'sc_loc_ini', sc_loc_ini(:,:,:) )
  249. IF( .NOT. lk_vvl ) THEN
  250. CALL iom_get( numror, jpdom_autoglo, 'ssh_hc_loc_ini', ssh_hc_loc_ini(:,:) )
  251. CALL iom_get( numror, jpdom_autoglo, 'ssh_sc_loc_ini', ssh_sc_loc_ini(:,:) )
  252. ENDIF
  253. ELSE
  254. IF(lwp) WRITE(numout,*) '~~~~~~~'
  255. IF(lwp) WRITE(numout,*) ' dia_hsb at initial state '
  256. IF(lwp) WRITE(numout,*) '~~~~~~~'
  257. ssh_ini(:,:) = sshn(:,:) ! initial ssh
  258. DO jk = 1, jpk
  259. e3t_ini (:,:,jk) = fse3t_n(:,:,jk) ! initial vertical scale factors
  260. hc_loc_ini(:,:,jk) = tsn(:,:,jk,jp_tem) * fse3t_n(:,:,jk) ! initial heat content
  261. sc_loc_ini(:,:,jk) = tsn(:,:,jk,jp_sal) * fse3t_n(:,:,jk) ! initial salt content
  262. END DO
  263. frc_v = 0._wp ! volume trend due to forcing
  264. frc_t = 0._wp ! heat content - - - -
  265. frc_s = 0._wp ! salt content - - - -
  266. IF( .NOT. lk_vvl ) THEN
  267. IF ( ln_isfcav ) THEN
  268. DO ji=1,jpi
  269. DO jj=1,jpj
  270. ssh_hc_loc_ini(ji,jj) = tsn(ji,jj,mikt(ji,jj),jp_tem) * sshn(ji,jj) ! initial heat content in ssh
  271. ssh_sc_loc_ini(ji,jj) = tsn(ji,jj,mikt(ji,jj),jp_sal) * sshn(ji,jj) ! initial salt content in ssh
  272. ENDDO
  273. ENDDO
  274. ELSE
  275. ssh_hc_loc_ini(:,:) = tsn(:,:,1,jp_tem) * sshn(:,:) ! initial heat content in ssh
  276. ssh_sc_loc_ini(:,:) = tsn(:,:,1,jp_sal) * sshn(:,:) ! initial salt content in ssh
  277. END IF
  278. frc_wn_t = 0._wp ! initial heat content misfit due to free surface
  279. frc_wn_s = 0._wp ! initial salt content misfit due to free surface
  280. ENDIF
  281. ENDIF
  282. ELSEIF( TRIM(cdrw) == 'WRITE' ) THEN ! Create restart file
  283. ! ! -------------------
  284. IF(lwp) WRITE(numout,*) '~~~~~~~'
  285. IF(lwp) WRITE(numout,*) ' dia_hsb_rst at it= ', kt,' date= ', ndastp
  286. IF(lwp) WRITE(numout,*) '~~~~~~~'
  287. CALL iom_rstput( kt, nitrst, numrow, 'frc_v' , frc_v )
  288. CALL iom_rstput( kt, nitrst, numrow, 'frc_t' , frc_t )
  289. CALL iom_rstput( kt, nitrst, numrow, 'frc_s' , frc_s )
  290. IF( .NOT. lk_vvl ) THEN
  291. CALL iom_rstput( kt, nitrst, numrow, 'frc_wn_t', frc_wn_t )
  292. CALL iom_rstput( kt, nitrst, numrow, 'frc_wn_s', frc_wn_s )
  293. ENDIF
  294. CALL iom_rstput( kt, nitrst, numrow, 'ssh_ini', ssh_ini(:,:) )
  295. CALL iom_rstput( kt, nitrst, numrow, 'e3t_ini', e3t_ini(:,:,:) )
  296. CALL iom_rstput( kt, nitrst, numrow, 'hc_loc_ini', hc_loc_ini(:,:,:) )
  297. CALL iom_rstput( kt, nitrst, numrow, 'sc_loc_ini', sc_loc_ini(:,:,:) )
  298. IF( .NOT. lk_vvl ) THEN
  299. CALL iom_rstput( kt, nitrst, numrow, 'ssh_hc_loc_ini', ssh_hc_loc_ini(:,:) )
  300. CALL iom_rstput( kt, nitrst, numrow, 'ssh_sc_loc_ini', ssh_sc_loc_ini(:,:) )
  301. ENDIF
  302. !
  303. ENDIF
  304. !
  305. END SUBROUTINE dia_hsb_rst
  306. SUBROUTINE dia_hsb_init
  307. !!---------------------------------------------------------------------------
  308. !! *** ROUTINE dia_hsb ***
  309. !!
  310. !! ** Purpose: Initialization for the heat salt volume budgets
  311. !!
  312. !! ** Method : Compute initial heat content, salt content and volume
  313. !!
  314. !! ** Action : - Compute initial heat content, salt content and volume
  315. !! - Initialize forcing trends
  316. !! - Compute coefficients for conversion
  317. !!---------------------------------------------------------------------------
  318. INTEGER :: ierror ! local integer
  319. INTEGER :: ios
  320. !
  321. NAMELIST/namhsb/ ln_diahsb
  322. !!----------------------------------------------------------------------
  323. REWIND( numnam_ref ) ! Namelist namhsb in reference namelist
  324. READ ( numnam_ref, namhsb, IOSTAT = ios, ERR = 901)
  325. 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namhsb in reference namelist', lwp )
  326. REWIND( numnam_cfg ) ! Namelist namhsb in configuration namelist
  327. READ ( numnam_cfg, namhsb, IOSTAT = ios, ERR = 902 )
  328. 902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namhsb in configuration namelist', lwp )
  329. IF(lwm) WRITE ( numond, namhsb )
  330. IF(lwp) THEN
  331. WRITE(numout,*)
  332. WRITE(numout,*) 'dia_hsb_init'
  333. WRITE(numout,*) '~~~~~~~~ '
  334. WRITE(numout,*) ' check the heat and salt budgets (T) or not (F) ln_diahsb = ', ln_diahsb
  335. ENDIF
  336. !
  337. IF( .NOT. ln_diahsb ) RETURN
  338. ! IF( .NOT. lk_mpp_rep ) &
  339. ! CALL ctl_stop (' Your global mpp_sum if performed in single precision - 64 bits -', &
  340. ! & ' whereas the global sum to be precise must be done in double precision ',&
  341. ! & ' please add key_mpp_rep')
  342. ! ------------------- !
  343. ! 1 - Allocate memory !
  344. ! ------------------- !
  345. ALLOCATE( hc_loc_ini(jpi,jpj,jpk), sc_loc_ini(jpi,jpj,jpk), &
  346. & e3t_ini(jpi,jpj,jpk), surf(jpi,jpj), ssh_ini(jpi,jpj), STAT=ierror )
  347. IF( ierror > 0 ) THEN
  348. CALL ctl_stop( 'dia_hsb: unable to allocate hc_loc_ini' )
  349. RETURN
  350. ENDIF
  351. IF( .NOT. lk_vvl ) THEN
  352. ALLOCATE( ssh_hc_loc_ini(jpi,jpj), ssh_sc_loc_ini(jpi,jpj), STAT=ierror )
  353. IF( ierror > 0 ) THEN
  354. CALL ctl_stop( 'dia_hsb: unable to allocate hc_loc_ini' )
  355. RETURN
  356. ENDIF
  357. ENDIF
  358. ! ----------------------------------------------- !
  359. ! 2 - Time independant variables and file opening !
  360. ! ----------------------------------------------- !
  361. surf(:,:) = e1t(:,:) * e2t(:,:) * tmask_i(:,:) ! masked surface grid cell area
  362. surf_tot = glob_sum( surf(:,:) ) ! total ocean surface area
  363. IF( lk_bdy ) CALL ctl_warn( 'dia_hsb does not take open boundary fluxes into account' )
  364. !
  365. ! ---------------------------------- !
  366. ! 4 - initial conservation variables !
  367. ! ---------------------------------- !
  368. CALL dia_hsb_rst( nit000, 'READ' ) !* read or initialize all required files
  369. !
  370. END SUBROUTINE dia_hsb_init
  371. !!======================================================================
  372. END MODULE diahsb