icbdia.F90 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. MODULE icbdia
  2. !!======================================================================
  3. !! *** MODULE icbdia ***
  4. !! Icebergs: initialise variables for iceberg budgets and diagnostics
  5. !!======================================================================
  6. !! History : 3.3 ! 2010-01 (Martin, Adcroft) Original code
  7. !! - ! 2011-03 (Madec) Part conversion to NEMO form
  8. !! - ! Removal of mapping from another grid
  9. !! - ! 2011-04 (Alderson) Split into separate modules
  10. !! - ! 2011-05 (Alderson) Budgets are now all here with lots
  11. !! - ! of silly routines to call to get values in
  12. !! - ! from the right points in the code
  13. !!----------------------------------------------------------------------
  14. !!----------------------------------------------------------------------
  15. !! icb_dia_init : initialise iceberg budgeting
  16. !!----------------------------------------------------------------------
  17. USE par_oce ! ocean parameters
  18. USE dom_oce ! ocean domain
  19. USE in_out_manager ! nemo IO
  20. USE lib_mpp ! MPP library
  21. USE iom ! I/O library
  22. USE icb_oce ! iceberg variables
  23. USE icbutl ! iceberg utility routines
  24. IMPLICIT NONE
  25. PRIVATE
  26. PUBLIC icb_dia_init ! routine called in icbini.F90 module
  27. PUBLIC icb_dia ! routine called in icbstp.F90 module
  28. PUBLIC icb_dia_step ! routine called in icbstp.F90 module
  29. PUBLIC icb_dia_put ! routine called in icbstp.F90 module
  30. PUBLIC icb_dia_melt ! routine called in icbthm.F90 module
  31. PUBLIC icb_dia_size ! routine called in icbthm.F90 module
  32. PUBLIC icb_dia_speed ! routine called in icbdyn.F90 module
  33. PUBLIC icb_dia_calve ! routine called in icbclv.F90 module
  34. PUBLIC icb_dia_income ! routine called in icbclv.F90 module
  35. REAL(wp), DIMENSION(:,:) , ALLOCATABLE, PUBLIC :: berg_melt ! Melting+erosion rate of icebergs [kg/s/m2]
  36. REAL(wp), DIMENSION(:,:) , ALLOCATABLE, PUBLIC :: buoy_melt ! Buoyancy component of melting rate [kg/s/m2]
  37. REAL(wp), DIMENSION(:,:) , ALLOCATABLE, PUBLIC :: eros_melt ! Erosion component of melting rate [kg/s/m2]
  38. REAL(wp), DIMENSION(:,:) , ALLOCATABLE, PUBLIC :: conv_melt ! Convective component of melting rate [kg/s/m2]
  39. REAL(wp), DIMENSION(:,:) , ALLOCATABLE, PUBLIC :: bits_src ! Mass flux from berg erosion into bergy bits [kg/s/m2]
  40. REAL(wp), DIMENSION(:,:) , ALLOCATABLE, PUBLIC :: bits_melt ! Melting rate of bergy bits [kg/s/m2]
  41. REAL(wp), DIMENSION(:,:) , ALLOCATABLE, PUBLIC :: bits_mass ! Mass distribution of bergy bits [kg/s/m2]
  42. REAL(wp), DIMENSION(:,:) , ALLOCATABLE, PUBLIC :: virtual_area ! Virtual surface coverage by icebergs [m2]
  43. REAL(wp), DIMENSION(:,:) , ALLOCATABLE, PUBLIC :: berg_mass ! Mass distribution [kg/m2]
  44. REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, PUBLIC :: real_calving ! Calving rate into iceberg class at
  45. ! ! calving locations [kg/s]
  46. REAL(wp), DIMENSION(:,:) , ALLOCATABLE :: tmpc ! Temporary work space
  47. REAL(wp), DIMENSION(:) , ALLOCATABLE :: rsumbuf ! Temporary work space to reduce mpp exchanges
  48. INTEGER , DIMENSION(:) , ALLOCATABLE :: nsumbuf ! Temporary work space to reduce mpp exchanges
  49. REAL(wp) :: berg_melt_net
  50. REAL(wp) :: bits_src_net
  51. REAL(wp) :: bits_melt_net
  52. REAL(wp) :: bits_mass_start , bits_mass_end
  53. REAL(wp) :: floating_heat_start , floating_heat_end
  54. REAL(wp) :: floating_mass_start , floating_mass_end
  55. REAL(wp) :: bergs_mass_start , bergs_mass_end
  56. REAL(wp) :: stored_start , stored_heat_start
  57. REAL(wp) :: stored_end , stored_heat_end
  58. REAL(wp) :: calving_src_net , calving_out_net
  59. REAL(wp) :: calving_src_heat_net, calving_out_heat_net
  60. REAL(wp) :: calving_src_heat_used_net
  61. REAL(wp) :: calving_rcv_net , calving_ret_net , calving_used_net
  62. REAL(wp) :: heat_to_bergs_net, heat_to_ocean_net, melt_net
  63. REAL(wp) :: calving_to_bergs_net
  64. INTEGER :: nbergs_start, nbergs_end, nbergs_calved
  65. INTEGER :: nbergs_melted
  66. INTEGER :: nspeeding_tickets
  67. INTEGER , DIMENSION(nclasses) :: nbergs_calved_by_class
  68. !!----------------------------------------------------------------------
  69. !! NEMO/OPA 3.3 , NEMO Consortium (2011)
  70. !! $Id: icbdia.F90 2355 2015-05-20 07:11:50Z ufla $
  71. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  72. !!----------------------------------------------------------------------
  73. CONTAINS
  74. SUBROUTINE icb_dia_init( )
  75. !!----------------------------------------------------------------------
  76. !!----------------------------------------------------------------------
  77. !
  78. IF( .NOT. ln_bergdia ) RETURN
  79. ALLOCATE( berg_melt (jpi,jpj) ) ; berg_melt (:,:) = 0._wp
  80. ALLOCATE( buoy_melt (jpi,jpj) ) ; buoy_melt (:,:) = 0._wp
  81. ALLOCATE( eros_melt (jpi,jpj) ) ; eros_melt (:,:) = 0._wp
  82. ALLOCATE( conv_melt (jpi,jpj) ) ; conv_melt (:,:) = 0._wp
  83. ALLOCATE( bits_src (jpi,jpj) ) ; bits_src (:,:) = 0._wp
  84. ALLOCATE( bits_melt (jpi,jpj) ) ; bits_melt (:,:) = 0._wp
  85. ALLOCATE( bits_mass (jpi,jpj) ) ; bits_mass (:,:) = 0._wp
  86. ALLOCATE( virtual_area (jpi,jpj) ) ; virtual_area(:,:) = 0._wp
  87. ALLOCATE( berg_mass (jpi,jpj) ) ; berg_mass (:,:) = 0._wp
  88. ALLOCATE( real_calving (jpi,jpj,nclasses) ) ; real_calving(:,:,:) = 0._wp
  89. ALLOCATE( tmpc(jpi,jpj) ) ; tmpc (:,:) = 0._wp
  90. nbergs_start = 0
  91. nbergs_end = 0
  92. stored_end = 0._wp
  93. nbergs_start = 0._wp
  94. stored_start = 0._wp
  95. nbergs_melted = 0
  96. nbergs_calved = 0
  97. nbergs_calved_by_class(:) = 0
  98. nspeeding_tickets = 0
  99. stored_heat_end = 0._wp
  100. floating_heat_end = 0._wp
  101. floating_mass_end = 0._wp
  102. bergs_mass_end = 0._wp
  103. bits_mass_end = 0._wp
  104. stored_heat_start = 0._wp
  105. floating_heat_start = 0._wp
  106. floating_mass_start = 0._wp
  107. bergs_mass_start = 0._wp
  108. bits_mass_start = 0._wp
  109. bits_mass_end = 0._wp
  110. calving_used_net = 0._wp
  111. calving_to_bergs_net = 0._wp
  112. heat_to_bergs_net = 0._wp
  113. heat_to_ocean_net = 0._wp
  114. calving_rcv_net = 0._wp
  115. calving_ret_net = 0._wp
  116. calving_src_net = 0._wp
  117. calving_out_net = 0._wp
  118. calving_src_heat_net = 0._wp
  119. calving_src_heat_used_net = 0._wp
  120. calving_out_heat_net = 0._wp
  121. melt_net = 0._wp
  122. berg_melt_net = 0._wp
  123. bits_melt_net = 0._wp
  124. bits_src_net = 0._wp
  125. floating_mass_start = icb_utl_mass( first_berg )
  126. bergs_mass_start = icb_utl_mass( first_berg, justbergs=.true. )
  127. bits_mass_start = icb_utl_mass( first_berg, justbits=.true. )
  128. IF( lk_mpp ) THEN
  129. ALLOCATE( rsumbuf(23) ) ; rsumbuf(:) = 0._wp
  130. ALLOCATE( nsumbuf(4+nclasses) ) ; nsumbuf(:) = 0
  131. rsumbuf(1) = floating_mass_start
  132. rsumbuf(2) = bergs_mass_start
  133. rsumbuf(3) = bits_mass_start
  134. CALL mpp_sum( rsumbuf(1:3), 3 )
  135. floating_mass_start = rsumbuf(1)
  136. bergs_mass_start = rsumbuf(2)
  137. bits_mass_start = rsumbuf(3)
  138. ENDIF
  139. !
  140. END SUBROUTINE icb_dia_init
  141. SUBROUTINE icb_dia( ld_budge )
  142. !!----------------------------------------------------------------------
  143. !! sum all the things we've accumulated so far in the current processor
  144. !! in MPP case then add these sums across all processors
  145. !! for this we pack variables into buffer so we only need one mpp_sum
  146. !!----------------------------------------------------------------------
  147. LOGICAL, INTENT(in) :: ld_budge
  148. !
  149. INTEGER :: ik
  150. REAL(wp) :: zunused_calving, ztmpsum, zgrdd_berg_mass, zgrdd_bits_mass
  151. !!----------------------------------------------------------------------
  152. !
  153. IF( .NOT. ln_bergdia ) RETURN
  154. zunused_calving = SUM( berg_grid%calving(:,:) )
  155. ztmpsum = SUM( berg_grid%floating_melt(:,:) * e1e2t(:,:) * tmask_i(:,:) )
  156. melt_net = melt_net + ztmpsum * berg_dt
  157. calving_out_net = calving_out_net + ( zunused_calving + ztmpsum ) * berg_dt
  158. ztmpsum = SUM( berg_melt(:,:) * e1e2t(:,:) * tmask_i(:,:) )
  159. berg_melt_net = berg_melt_net + ztmpsum * berg_dt
  160. ztmpsum = SUM( bits_src(:,:) * e1e2t(:,:) * tmask_i(:,:) )
  161. bits_src_net = bits_src_net + ztmpsum * berg_dt
  162. ztmpsum = SUM( bits_melt(:,:) * e1e2t(:,:) * tmask_i(:,:) )
  163. bits_melt_net = bits_melt_net + ztmpsum * berg_dt
  164. ztmpsum = SUM( src_calving(:,:) * tmask_i(:,:) )
  165. calving_ret_net = calving_ret_net + ztmpsum * berg_dt
  166. ztmpsum = SUM( berg_grid%calving_hflx(:,:) * e1e2t(:,:) * tmask_i(:,:) )
  167. calving_out_heat_net = calving_out_heat_net + ztmpsum * berg_dt ! Units of J
  168. IF( ld_budge ) THEN
  169. stored_end = SUM( berg_grid%stored_ice(:,:,:) )
  170. stored_heat_end = SUM( berg_grid%stored_heat(:,:) )
  171. floating_mass_end = icb_utl_mass( first_berg )
  172. bergs_mass_end = icb_utl_mass( first_berg,justbergs=.true. )
  173. bits_mass_end = icb_utl_mass( first_berg,justbits=.true. )
  174. floating_heat_end = icb_utl_heat( first_berg )
  175. nbergs_end = icb_utl_count()
  176. zgrdd_berg_mass = SUM( berg_mass (:,:)*e1e2t(:,:)*tmask_i(:,:) )
  177. zgrdd_bits_mass = SUM( bits_mass(:,:)*e1e2t(:,:)*tmask_i(:,:) )
  178. IF( lk_mpp ) THEN
  179. rsumbuf( 1) = stored_end
  180. rsumbuf( 2) = stored_heat_end
  181. rsumbuf( 3) = floating_mass_end
  182. rsumbuf( 4) = bergs_mass_end
  183. rsumbuf( 5) = bits_mass_end
  184. rsumbuf( 6) = floating_heat_end
  185. rsumbuf( 7) = calving_ret_net
  186. rsumbuf( 8) = calving_out_net
  187. rsumbuf( 9) = calving_rcv_net
  188. rsumbuf(10) = calving_src_net
  189. rsumbuf(11) = calving_src_heat_net
  190. rsumbuf(12) = calving_src_heat_used_net
  191. rsumbuf(13) = calving_out_heat_net
  192. rsumbuf(14) = calving_used_net
  193. rsumbuf(15) = calving_to_bergs_net
  194. rsumbuf(16) = heat_to_bergs_net
  195. rsumbuf(17) = heat_to_ocean_net
  196. rsumbuf(18) = melt_net
  197. rsumbuf(19) = berg_melt_net
  198. rsumbuf(20) = bits_src_net
  199. rsumbuf(21) = bits_melt_net
  200. rsumbuf(22) = zgrdd_berg_mass
  201. rsumbuf(23) = zgrdd_bits_mass
  202. CALL mpp_sum( rsumbuf(1:23), 23)
  203. stored_end = rsumbuf( 1)
  204. stored_heat_end = rsumbuf( 2)
  205. floating_mass_end = rsumbuf( 3)
  206. bergs_mass_end = rsumbuf( 4)
  207. bits_mass_end = rsumbuf( 5)
  208. floating_heat_end = rsumbuf( 6)
  209. calving_ret_net = rsumbuf( 7)
  210. calving_out_net = rsumbuf( 8)
  211. calving_rcv_net = rsumbuf( 9)
  212. calving_src_net = rsumbuf(10)
  213. calving_src_heat_net = rsumbuf(11)
  214. calving_src_heat_used_net = rsumbuf(12)
  215. calving_out_heat_net = rsumbuf(13)
  216. calving_used_net = rsumbuf(14)
  217. calving_to_bergs_net = rsumbuf(15)
  218. heat_to_bergs_net = rsumbuf(16)
  219. heat_to_ocean_net = rsumbuf(17)
  220. melt_net = rsumbuf(18)
  221. berg_melt_net = rsumbuf(19)
  222. bits_src_net = rsumbuf(20)
  223. bits_melt_net = rsumbuf(21)
  224. zgrdd_berg_mass = rsumbuf(22)
  225. zgrdd_bits_mass = rsumbuf(23)
  226. nsumbuf(1) = nbergs_end
  227. nsumbuf(2) = nbergs_calved
  228. nsumbuf(3) = nbergs_melted
  229. nsumbuf(4) = nspeeding_tickets
  230. DO ik = 1, nclasses
  231. nsumbuf(4+ik) = nbergs_calved_by_class(ik)
  232. END DO
  233. CALL mpp_sum( nsumbuf(1:nclasses+4), nclasses+4 )
  234. nbergs_end = nsumbuf(1)
  235. nbergs_calved = nsumbuf(2)
  236. nbergs_melted = nsumbuf(3)
  237. nspeeding_tickets = nsumbuf(4)
  238. DO ik = 1,nclasses
  239. nbergs_calved_by_class(ik)= nsumbuf(4+ik)
  240. ENDDO
  241. ENDIF
  242. CALL report_state( 'stored ice','kg','',stored_start,'',stored_end,'')
  243. CALL report_state( 'floating','kg','',floating_mass_start,'',floating_mass_end,'',nbergs_end)
  244. CALL report_state( 'icebergs','kg','',bergs_mass_start,'',bergs_mass_end,'')
  245. CALL report_state( 'bits','kg','',bits_mass_start,'',bits_mass_end,'')
  246. CALL report_istate( 'berg #','',nbergs_start,'',nbergs_end,'')
  247. CALL report_ibudget( 'berg #','calved',nbergs_calved, &
  248. 'melted',nbergs_melted, &
  249. '#',nbergs_start,nbergs_end)
  250. CALL report_budget( 'stored mass','kg','calving used',calving_used_net, &
  251. 'bergs',calving_to_bergs_net, &
  252. 'stored mass',stored_start,stored_end)
  253. CALL report_budget( 'floating mass','kg','calving used',calving_to_bergs_net, &
  254. 'bergs',melt_net, &
  255. 'stored mass',floating_mass_start,floating_mass_end)
  256. CALL report_budget( 'berg mass','kg','calving',calving_to_bergs_net, &
  257. 'melt+eros',berg_melt_net, &
  258. 'berg mass',bergs_mass_start,bergs_mass_end)
  259. CALL report_budget( 'bits mass','kg','eros used',bits_src_net, &
  260. 'bergs',bits_melt_net, &
  261. 'stored mass',bits_mass_start,bits_mass_end)
  262. CALL report_budget( 'net mass','kg','recvd',calving_rcv_net, &
  263. 'rtrnd',calving_ret_net, &
  264. 'net mass',stored_start+floating_mass_start, &
  265. stored_end+floating_mass_end)
  266. CALL report_consistant( 'iceberg mass','kg','gridded',zgrdd_berg_mass,'bergs',bergs_mass_end)
  267. CALL report_consistant( 'bits mass','kg','gridded',zgrdd_bits_mass,'bits',bits_mass_end)
  268. CALL report_state( 'net heat','J','',stored_heat_start+floating_heat_start,'', &
  269. stored_heat_end+floating_heat_end,'')
  270. CALL report_state( 'stored heat','J','',stored_heat_start,'',stored_heat_end,'')
  271. CALL report_state( 'floating heat','J','',floating_heat_start,'',floating_heat_end,'')
  272. CALL report_budget( 'net heat','J','net heat',calving_src_heat_net, &
  273. 'net heat',calving_out_heat_net, &
  274. 'net heat',stored_heat_start+floating_heat_start, &
  275. stored_heat_end+floating_heat_end)
  276. CALL report_budget( 'stored heat','J','calving used',calving_src_heat_used_net, &
  277. 'bergs',heat_to_bergs_net, &
  278. 'net heat',stored_heat_start,stored_heat_end)
  279. CALL report_budget( 'flting heat','J','calved',heat_to_bergs_net, &
  280. 'melt',heat_to_ocean_net, &
  281. 'net heat',floating_heat_start,floating_heat_end)
  282. IF (nn_verbose_level >= 1) THEN
  283. CALL report_consistant( 'top interface','kg','from SIS',calving_src_net, &
  284. 'received',calving_rcv_net)
  285. CALL report_consistant( 'bot interface','kg','sent',calving_out_net, &
  286. 'returned',calving_ret_net)
  287. ENDIF
  288. WRITE( numicb, '("calved by class = ",i6,20(",",i6))') (nbergs_calved_by_class(ik),ik=1,nclasses)
  289. IF ( nspeeding_tickets > 0 ) WRITE( numicb, '("speeding tickets issued = ",i6)') nspeeding_tickets
  290. nbergs_start = nbergs_end
  291. stored_start = stored_end
  292. nbergs_melted = 0
  293. nbergs_calved = 0
  294. nbergs_calved_by_class(:) = 0
  295. nspeeding_tickets = 0
  296. stored_heat_start = stored_heat_end
  297. floating_heat_start = floating_heat_end
  298. floating_mass_start = floating_mass_end
  299. bergs_mass_start = bergs_mass_end
  300. bits_mass_start = bits_mass_end
  301. calving_used_net = 0._wp
  302. calving_to_bergs_net = 0._wp
  303. heat_to_bergs_net = 0._wp
  304. heat_to_ocean_net = 0._wp
  305. calving_rcv_net = 0._wp
  306. calving_ret_net = 0._wp
  307. calving_src_net = 0._wp
  308. calving_out_net = 0._wp
  309. calving_src_heat_net = 0._wp
  310. calving_src_heat_used_net = 0._wp
  311. calving_out_heat_net = 0._wp
  312. melt_net = 0._wp
  313. berg_melt_net = 0._wp
  314. bits_melt_net = 0._wp
  315. bits_src_net = 0._wp
  316. ENDIF
  317. !
  318. END SUBROUTINE icb_dia
  319. SUBROUTINE icb_dia_step
  320. !!----------------------------------------------------------------------
  321. !! things to reset at the beginning of each timestep
  322. !!----------------------------------------------------------------------
  323. !
  324. IF( .NOT. ln_bergdia ) RETURN
  325. berg_melt (:,:) = 0._wp
  326. buoy_melt (:,:) = 0._wp
  327. eros_melt (:,:) = 0._wp
  328. conv_melt (:,:) = 0._wp
  329. bits_src (:,:) = 0._wp
  330. bits_melt (:,:) = 0._wp
  331. bits_mass (:,:) = 0._wp
  332. berg_mass (:,:) = 0._wp
  333. virtual_area (:,:) = 0._wp
  334. real_calving (:,:,:) = 0._wp
  335. !
  336. END SUBROUTINE icb_dia_step
  337. SUBROUTINE icb_dia_put
  338. !!----------------------------------------------------------------------
  339. !!----------------------------------------------------------------------
  340. !
  341. IF( .NOT. ln_bergdia ) RETURN !!gm useless iom will control whether it is output or not
  342. !
  343. CALL iom_put( "berg_melt" , berg_melt (:,:) ) ! Melt rate of icebergs [kg/m2/s]
  344. CALL iom_put( "berg_buoy_melt" , buoy_melt (:,:) ) ! Buoyancy component of iceberg melt rate [kg/m2/s]
  345. CALL iom_put( "berg_eros_melt" , eros_melt (:,:) ) ! Erosion component of iceberg melt rate [kg/m2/s]
  346. CALL iom_put( "berg_conv_melt" , conv_melt (:,:) ) ! Convective component of iceberg melt rate [kg/m2/s]
  347. CALL iom_put( "berg_virtual_area", virtual_area(:,:) ) ! Virtual coverage by icebergs [m2]
  348. CALL iom_put( "bits_src" , bits_src (:,:) ) ! Mass source of bergy bits [kg/m2/s]
  349. CALL iom_put( "bits_melt" , bits_melt (:,:) ) ! Melt rate of bergy bits [kg/m2/s]
  350. CALL iom_put( "bits_mass" , bits_mass (:,:) ) ! Bergy bit density field [kg/m2]
  351. CALL iom_put( "berg_mass" , berg_mass (:,:) ) ! Iceberg density field [kg/m2]
  352. CALL iom_put( "berg_real_calving", real_calving(:,:,:) ) ! Calving into iceberg class [kg/s]
  353. !
  354. END SUBROUTINE icb_dia_put
  355. SUBROUTINE icb_dia_calve( ki, kj, kn, pcalved, pheated )
  356. !!----------------------------------------------------------------------
  357. !!----------------------------------------------------------------------
  358. INTEGER, INTENT(in) :: ki, kj, kn
  359. REAL(wp), INTENT(in) :: pcalved
  360. REAL(wp), INTENT(in) :: pheated
  361. !!----------------------------------------------------------------------
  362. !
  363. IF( .NOT. ln_bergdia ) RETURN
  364. real_calving(ki,kj,kn) = real_calving(ki,kj,kn) + pcalved / berg_dt
  365. nbergs_calved = nbergs_calved + 1
  366. nbergs_calved_by_class(kn) = nbergs_calved_by_class(kn) + 1
  367. calving_to_bergs_net = calving_to_bergs_net + pcalved
  368. heat_to_bergs_net = heat_to_bergs_net + pheated
  369. !
  370. END SUBROUTINE icb_dia_calve
  371. SUBROUTINE icb_dia_income( kt, pcalving_used, pheat_used )
  372. !!----------------------------------------------------------------------
  373. !!----------------------------------------------------------------------
  374. INTEGER , INTENT(in) :: kt
  375. REAL(wp), INTENT(in) :: pcalving_used
  376. REAL(wp), DIMENSION(:,:), INTENT(in) :: pheat_used
  377. !!----------------------------------------------------------------------
  378. !
  379. IF( .NOT. ln_bergdia ) RETURN
  380. !
  381. IF( kt == nit000 ) THEN
  382. stored_start = SUM( berg_grid%stored_ice(:,:,:) )
  383. IF( lk_mpp ) CALL mpp_sum( stored_start )
  384. WRITE(numicb,'(a,es13.6,a)') 'icb_dia_income: initial stored mass=',stored_start,' kg'
  385. !
  386. stored_heat_start = SUM( berg_grid%stored_heat(:,:) )
  387. IF( lk_mpp ) CALL mpp_sum( stored_heat_start )
  388. WRITE(numicb,'(a,es13.6,a)') 'icb_dia_income: initial stored heat=',stored_heat_start,' J'
  389. ENDIF
  390. !
  391. calving_rcv_net = calving_rcv_net + SUM( berg_grid%calving(:,:) ) * berg_dt
  392. calving_src_net = calving_rcv_net
  393. calving_src_heat_net = calving_src_heat_net + &
  394. & SUM( berg_grid%calving_hflx(:,:) * e1e2t(:,:) ) * berg_dt ! Units of J
  395. calving_used_net = calving_used_net + pcalving_used * berg_dt
  396. calving_src_heat_used_net = calving_src_heat_used_net + SUM( pheat_used(:,:) )
  397. !
  398. END SUBROUTINE icb_dia_income
  399. SUBROUTINE icb_dia_size(ki, kj, pWn, pLn, pAbits, &
  400. & pmass_scale, pMnew, pnMbits, pz1_e1e2)
  401. !!----------------------------------------------------------------------
  402. !!----------------------------------------------------------------------
  403. INTEGER, INTENT(in) :: ki, kj
  404. REAL(wp), INTENT(in) :: pWn, pLn, pAbits, pmass_scale, pMnew, pnMbits, pz1_e1e2
  405. !!----------------------------------------------------------------------
  406. !
  407. IF( .NOT. ln_bergdia ) RETURN
  408. virtual_area(ki,kj) = virtual_area(ki,kj) + ( pWn * pLn + pAbits ) * pmass_scale ! m^2
  409. berg_mass(ki,kj) = berg_mass(ki,kj) + pMnew * pz1_e1e2 ! kg/m2
  410. bits_mass(ki,kj) = bits_mass(ki,kj) + pnMbits * pz1_e1e2 ! kg/m2
  411. !
  412. END SUBROUTINE icb_dia_size
  413. SUBROUTINE icb_dia_speed()
  414. !!----------------------------------------------------------------------
  415. !!----------------------------------------------------------------------
  416. !
  417. IF( .NOT. ln_bergdia ) RETURN
  418. nspeeding_tickets = nspeeding_tickets + 1
  419. !
  420. END SUBROUTINE icb_dia_speed
  421. SUBROUTINE icb_dia_melt(ki, kj, pmnew, pheat, pmass_scale, &
  422. & pdM, pdMbitsE, pdMbitsM, pdMb, pdMe, &
  423. & pdMv, pz1_dt_e1e2 )
  424. !!----------------------------------------------------------------------
  425. !!----------------------------------------------------------------------
  426. INTEGER , INTENT(in) :: ki, kj
  427. REAL(wp), INTENT(in) :: pmnew, pheat, pmass_scale
  428. REAL(wp), INTENT(in) :: pdM, pdMbitsE, pdMbitsM, pdMb, pdMe, pdMv, pz1_dt_e1e2
  429. !!----------------------------------------------------------------------
  430. !
  431. IF( .NOT. ln_bergdia ) RETURN
  432. berg_melt (ki,kj) = berg_melt (ki,kj) + pdM * pz1_dt_e1e2 ! kg/m2/s
  433. bits_src (ki,kj) = bits_src (ki,kj) + pdMbitsE * pz1_dt_e1e2 ! mass flux into bergy bitskg/m2/s
  434. bits_melt (ki,kj) = bits_melt (ki,kj) + pdMbitsM * pz1_dt_e1e2 ! melt rate of bergy bits kg/m2/s
  435. buoy_melt (ki,kj) = buoy_melt (ki,kj) + pdMb * pz1_dt_e1e2 ! kg/m2/s
  436. eros_melt (ki,kj) = eros_melt (ki,kj) + pdMe * pz1_dt_e1e2 ! erosion rate kg/m2/s
  437. conv_melt (ki,kj) = conv_melt (ki,kj) + pdMv * pz1_dt_e1e2 ! kg/m2/s
  438. heat_to_ocean_net = heat_to_ocean_net + pheat * pmass_scale * berg_dt ! J
  439. IF( pmnew <= 0._wp ) nbergs_melted = nbergs_melted + 1 ! Delete the berg if completely melted
  440. !
  441. END SUBROUTINE icb_dia_melt
  442. SUBROUTINE report_state( cd_budgetstr, cd_budgetunits, cd_startstr, pstartval, cd_endstr, &
  443. & pendval, cd_delstr, kbergs )
  444. !!----------------------------------------------------------------------
  445. !!----------------------------------------------------------------------
  446. CHARACTER*(*), INTENT(in) :: cd_budgetstr, cd_budgetunits, cd_startstr, cd_endstr, cd_delstr
  447. REAL(wp), INTENT(in) :: pstartval, pendval
  448. INTEGER, INTENT(in), OPTIONAL :: kbergs
  449. !!----------------------------------------------------------------------
  450. !
  451. IF ( PRESENT(kbergs) ) THEN
  452. WRITE(numicb,100) cd_budgetstr // ' state:', &
  453. cd_startstr // ' start', pstartval, cd_budgetunits, &
  454. cd_endstr // ' end', pendval, cd_budgetunits, &
  455. 'Delta ' // cd_delstr, pendval-pstartval, cd_budgetunits, &
  456. '# of bergs', kbergs
  457. ELSE
  458. WRITE(numicb,100) cd_budgetstr // ' state:', &
  459. cd_startstr // ' start', pstartval, cd_budgetunits, &
  460. cd_endstr // ' end', pendval, cd_budgetunits, &
  461. cd_delstr // 'Delta', pendval-pstartval, cd_budgetunits
  462. ENDIF
  463. 100 FORMAT(a19,3(a18,"=",es14.7,x,a2,:,","),a12,i8)
  464. END SUBROUTINE report_state
  465. SUBROUTINE report_consistant( cd_budgetstr, cd_budgetunits, cd_startstr, pstartval, cd_endstr, pendval)
  466. !!----------------------------------------------------------------------
  467. !!----------------------------------------------------------------------
  468. CHARACTER*(*), INTENT(in) :: cd_budgetstr, cd_budgetunits, cd_startstr, cd_endstr
  469. REAL(wp), INTENT(in) :: pstartval, pendval
  470. !!----------------------------------------------------------------------
  471. !
  472. WRITE(numicb,200) cd_budgetstr // ' check:', &
  473. cd_startstr, pstartval, cd_budgetunits, &
  474. cd_endstr, pendval, cd_budgetunits, &
  475. 'error', (pendval-pstartval)/((pendval+pstartval)+1e-30), 'nd'
  476. 200 FORMAT(a19,10(a18,"=",es14.7,x,a2,:,","))
  477. END SUBROUTINE report_consistant
  478. SUBROUTINE report_budget( cd_budgetstr, cd_budgetunits, cd_instr, pinval, cd_outstr, &
  479. & poutval, cd_delstr, pstartval, pendval)
  480. !!----------------------------------------------------------------------
  481. !!----------------------------------------------------------------------
  482. CHARACTER*(*), INTENT(in) :: cd_budgetstr, cd_budgetunits, cd_instr, cd_outstr, cd_delstr
  483. REAL(wp), INTENT(in) :: pinval, poutval, pstartval, pendval
  484. !
  485. REAL(wp) :: zval
  486. !!----------------------------------------------------------------------
  487. !
  488. zval = ( ( pendval - pstartval ) - ( pinval - poutval ) ) / &
  489. & MAX( 1.e-30, MAX( abs( pendval - pstartval ) , ABS( pinval - poutval ) ) )
  490. WRITE(numicb,200) cd_budgetstr // ' budget:', &
  491. & cd_instr // ' in', pinval, cd_budgetunits, &
  492. & cd_outstr // ' out', poutval, cd_budgetunits, &
  493. & 'Delta ' // cd_delstr, pinval-poutval, cd_budgetunits, &
  494. & 'error', zval, 'nd'
  495. 200 FORMAT(a19,3(a18,"=",es14.7,x,a2,:,","),a8,"=",es10.3,x,a2)
  496. !
  497. END SUBROUTINE report_budget
  498. SUBROUTINE report_istate( cd_budgetstr, cd_startstr, pstartval, cd_endstr, pendval, cd_delstr)
  499. !!----------------------------------------------------------------------
  500. !!----------------------------------------------------------------------
  501. CHARACTER*(*), INTENT(in) :: cd_budgetstr, cd_startstr, cd_endstr, cd_delstr
  502. INTEGER, INTENT(in) :: pstartval, pendval
  503. !
  504. WRITE(numicb,100) cd_budgetstr // ' state:', &
  505. & cd_startstr // ' start', pstartval, &
  506. & cd_endstr // ' end', pendval, &
  507. & cd_delstr // 'Delta', pendval-pstartval
  508. 100 FORMAT(a19,3(a18,"=",i14,x,:,","))
  509. !
  510. END SUBROUTINE report_istate
  511. SUBROUTINE report_ibudget( cd_budgetstr, cd_instr, pinval, cd_outstr, poutval, &
  512. & cd_delstr, pstartval, pendval)
  513. !!----------------------------------------------------------------------
  514. !!----------------------------------------------------------------------
  515. CHARACTER*(*), INTENT(in) :: cd_budgetstr, cd_instr, cd_outstr, cd_delstr
  516. INTEGER, INTENT(in) :: pinval, poutval, pstartval, pendval
  517. !!----------------------------------------------------------------------
  518. !
  519. WRITE(numicb,200) cd_budgetstr // ' budget:', &
  520. cd_instr // ' in', pinval, &
  521. cd_outstr // ' out', poutval, &
  522. 'Delta ' // cd_delstr, pinval-poutval, &
  523. 'error', ( ( pendval - pstartval ) - ( pinval - poutval ) )
  524. 200 FORMAT(a19,10(a18,"=",i14,x,:,","))
  525. END SUBROUTINE report_ibudget
  526. !!======================================================================
  527. END MODULE icbdia