@@ -217,7 +217,11 @@ subroutine li_calve_ice(domain, err)
217217 do while (associated(block))
218218 call mpas_pool_get_subpool(block % structs, ' geometry' , geometryPool)
219219 call mpas_pool_get_array(geometryPool, ' calvingThickness' , calvingThickness)
220+ call mpas_pool_get_array(geometryPool, ' groundedCalvingThickness' , groundedCalvingThickness)
221+ call mpas_pool_get_array(geometryPool, ' floatingCalvingThickness' , floatingCalvingThickness)
220222 calvingThickness(:) = 0.0_RKIND
223+ groundedCalvingThickness(:) = 0.0_RKIND
224+ floatingCalvingThickness(:) = 0.0_RKIND
221225
222226 block = > block % next
223227 end do
@@ -288,27 +292,7 @@ subroutine li_calve_ice(domain, err)
288292 ! now also remove any icebergs
289293 call remove_icebergs(domain)
290294
291- block = > domain % blocklist
292- do while (associated(block))
293- call mpas_pool_get_array(geometryPool, ' calvingThickness' , calvingThickness)
294- call mpas_pool_get_array(geometryPool, ' groundedCalvingThickness' , groundedCalvingThickness)
295- call mpas_pool_get_array(geometryPool, ' floatingCalvingThickness' , floatingCalvingThickness)
296- call mpas_pool_get_array(geometryPool, ' groundedMaskForMassBudget' , groundedMaskForMassBudget)
297- call mpas_pool_get_array(geometryPool, ' floatingMaskForMassBudget' , floatingMaskForMassBudget)
298-
299- groundedCalvingThickness(:) = 0.0_RKIND
300- floatingCalvingThickness(:) = 0.0_RKIND
301- where (groundedMaskForMassBudget .eq. 1 )
302- groundedCalvingThickness = calvingThickness
303- elsewhere (floatingMaskForMassBudget .eq. 1 )
304- floatingCalvingThickness = calvingThickness
305- elsewhere
306- groundedCalvingThickness = 0.0_RKIND
307- floatingCalvingThickness = 0.0_RKIND
308- end where
309-
310- block = > block % next
311- end do
295+ call update_calving_budget(domain)
312296
313297 ! Final operations after calving has been applied.
314298 block = > domain % blocklist
@@ -317,8 +301,6 @@ subroutine li_calve_ice(domain, err)
317301 call mpas_pool_get_subpool(block % structs, ' mesh' , meshPool)
318302 call mpas_pool_get_array(geometryPool, ' thickness' , thickness)
319303 call mpas_pool_get_array(geometryPool, ' calvingThickness' , calvingThickness)
320- call mpas_pool_get_array(geometryPool, ' groundedCalvingThickness' , groundedCalvingThickness)
321- call mpas_pool_get_array(geometryPool, ' floatingCalvingThickness' , floatingCalvingThickness)
322304 call mpas_pool_get_dimension(meshPool, ' nCells' , nCells)
323305
324306 ! In data calving mode we just calculate what should be calved but don' t actually calve it.
@@ -596,6 +578,7 @@ subroutine li_restore_calving_front(domain, err)
596578 block => block % next
597579 enddo
598580
581+ call update_calving_budget(domain)
599582 ! Update mask and geometry
600583 block => domain % blocklist
601584 do while (associated(block))
@@ -895,7 +878,9 @@ subroutine thickness_calving(domain, calvingFraction, err)
895878 ! === apply calving ===
896879 thickness(:) = thickness(:) - calvingThickness(:)
897880
881+ call update_calving_budget(domain)
898882 call remove_small_islands(meshPool, geometryPool)
883+ call update_calving_budget(domain)
899884
900885 block => block % next
901886 enddo
@@ -968,7 +953,9 @@ subroutine floating_calving(domain, calvingFraction, err)
968953 ! === apply calving ===
969954 thickness(:) = thickness(:) - calvingThickness(:)
970955
956+ call update_calving_budget(domain)
971957 call remove_small_islands(meshPool, geometryPool)
958+ call update_calving_budget(domain)
972959
973960 block => block % next
974961 enddo
@@ -1137,7 +1124,9 @@ subroutine topographic_calving(domain, calvingFraction, err)
11371124 ! === apply calving ===
11381125 thickness(:) = thickness(:) - calvingThickness(:)
11391126
1127+ call update_calving_budget(domain)
11401128 call remove_small_islands(meshPool, geometryPool)
1129+ call update_calving_budget(domain)
11411130
11421131 block => block % next
11431132 enddo
@@ -1316,6 +1305,7 @@ subroutine eigencalving(domain, err)
13161305 call mpas_timer_stop(" halo updates" )
13171306 ! === apply calving ===
13181307 thickness(:) = thickness(:) - calvingThickness(:)
1308+ call update_calving_budget(domain)
13191309
13201310 ! update mask
13211311 call li_calculate_mask(meshPool, velocityPool, geometryPool, domain, err_tmp)
@@ -1340,7 +1330,7 @@ subroutine eigencalving(domain, err)
13401330 endif
13411331 enddo
13421332 ! TODO: global reduce & reporting on amount of calving generated in this step
1343-
1333+ call update_calving_budget(domain)
13441334 ! update mask
13451335 call li_calculate_mask(meshPool, velocityPool, geometryPool, domain, err_tmp)
13461336 err = ior (err, err_tmp)
@@ -1365,8 +1355,9 @@ subroutine eigencalving(domain, err)
13651355 endif
13661356 enddo
13671357 ! TODO: global reduce & reporting on amount of calving generated in this step
1368-
1358+ call update_calving_budget(domain)
13691359 call remove_small_islands(meshPool, geometryPool)
1360+ call update_calving_budget(domain)
13701361
13711362 block => block % next
13721363 enddo
@@ -1494,7 +1485,7 @@ subroutine specified_calving_velocity(domain, err)
14941485
14951486 ! === apply calving ===
14961487 thickness(:) = thickness(:) - calvingThickness(:)
1497-
1488+ call update_calving_budget(domain)
14981489 ! update mask
14991490 call li_calculate_mask(meshPool, velocityPool, geometryPool, domain, err_tmp)
15001491 err = ior(err, err_tmp)
@@ -1518,7 +1509,7 @@ subroutine specified_calving_velocity(domain, err)
15181509 endif
15191510 enddo
15201511 ! TODO: global reduce & reporting on amount of calving generated in this step
1521-
1512+ call update_calving_budget(domain)
15221513 ! update mask
15231514 call li_calculate_mask(meshPool, velocityPool, geometryPool, domain, err_tmp)
15241515 err = ior(err, err_tmp)
@@ -1543,8 +1534,9 @@ subroutine specified_calving_velocity(domain, err)
15431534 endif
15441535 enddo
15451536 ! TODO: global reduce & reporting on amount of calving generated in this step
1546-
1537+ call update_calving_budget(domain)
15471538 call remove_small_islands(meshPool, geometryPool)
1539+ call update_calving_budget(domain)
15481540
15491541 block = > block % next
15501542 enddo
@@ -1821,13 +1813,14 @@ subroutine von_Mises_calving(domain, err)
18211813
18221814 ! === apply calving ===
18231815 thickness(:) = thickness(:) - calvingThickness(:)
1824-
1816+ call update_calving_budget(domain)
18251817 ! update mask
18261818 call li_calculate_mask(meshPool, velocityPool, geometryPool, domain, err_tmp)
18271819 err = ior (err, err_tmp)
18281820
18291821 call remove_small_islands(meshPool, geometryPool)
1830-
1822+ call update_calving_budget(domain)
1823+
18311824 block = > block % next
18321825
18331826 enddo ! associated(block)
@@ -2086,11 +2079,12 @@ subroutine ismip6_retreat(domain, err)
20862079
20872080 ! === apply calving ===
20882081 thickness(:) = thickness(:) - calvingThickness(:)
2089-
2082+ call update_calving_budget(domain)
20902083 ! update mask
20912084 call li_calculate_mask(meshPool, velocityPool, geometryPool, domain, err_tmp)
20922085 err = ior (err, err_tmp)
20932086 call remove_small_islands(meshPool, geometryPool)
2087+ call update_calving_budget(domain)
20942088
20952089 deallocate(submergedArea)
20962090
@@ -2999,7 +2993,7 @@ subroutine damage_calving(domain, err)
29992993
30002994 ! === apply calving ===
30012995 thickness(:) = thickness(:) - calvingThickness(:)
3002-
2996+ call update_calving_budget(domain)
30032997 ! update mask
30042998 call li_calculate_mask(meshPool, velocityPool, geometryPool, domain, err_tmp)
30052999 err = ior (err, err_tmp)
@@ -3015,7 +3009,7 @@ subroutine damage_calving(domain, err)
30153009 thickness(iCell) = 0.0_RKIND
30163010 endif
30173011 enddo
3018-
3012+ call update_calving_budget(domain)
30193013 ! update mask
30203014 call li_calculate_mask(meshPool, velocityPool, geometryPool, domain, err_tmp)
30213015 err = ior (err, err_tmp)
@@ -3040,9 +3034,9 @@ subroutine damage_calving(domain, err)
30403034 endif
30413035 enddo
30423036 ! TODO: global reduce & reporting on amount of calving generated in this step
3043-
3037+ call update_calving_budget(domain)
30443038 call remove_small_islands(meshPool, geometryPool)
3045-
3039+ call update_calving_budget(domain)
30463040 block => block % next
30473041
30483042 enddo
@@ -4063,6 +4057,50 @@ subroutine li_flood_fill(seedMask, growMask, domain)
40634057
40644058 end subroutine li_flood_fill
40654059
4060+
4061+ !|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
4062+ !
4063+ ! routine update_calving_budget
4064+ !
4065+ !> \brief Keep a running total of calving applied to grounded and floating
4066+ !> ice, respectively.
4067+ !> \author Trevor Hillebrand
4068+ !> \date May 2022
4069+ !> \details This routine should be called after each time time calvingThickness
4070+ !> is applied, but before masks are updated which often happens multiple times
4071+ !> in a timestep.
4072+ !-----------------------------------------------------------------------
4073+ subroutine update_calving_budget(domain)
4074+ !-----------------------------------------------------------------
4075+ ! input/output variables
4076+ !-----------------------------------------------------------------
4077+ type (domain_type), intent(inout) :: domain
4078+
4079+ !-----------------------------------------------------------------
4080+ ! local variables
4081+ !-----------------------------------------------------------------
4082+ type (mpas_pool_type), pointer :: meshPool, geometryPool
4083+ integer, dimension(:), pointer :: groundedMaskForMassBudget, & ! binary masks for mass budget
4084+ floatingMaskForMassBudget
4085+ real (kind=RKIND), dimension(:), pointer :: calvingThickness, &
4086+ groundedCalvingThickness, & ! Grounded and floating components for mass budget
4087+ floatingCalvingThickness
4088+
4089+ call mpas_pool_get_subpool(domain % blocklist % structs, ' geometry' , geometryPool)
4090+ call mpas_pool_get_array(geometryPool, ' groundedMaskForMassBudget' , groundedMaskForMassBudget)
4091+ call mpas_pool_get_array(geometryPool, ' floatingMaskForMassBudget' , groundedMaskForMassBudget)
4092+ call mpas_pool_get_array(geometryPool, ' groundedCalvingThickness' , groundedCalvingThickness)
4093+ call mpas_pool_get_array(geometryPool, ' floatingCalvingThickness' , floatingCalvingThickness)
4094+ call mpas_pool_get_array(geometryPool, ' calvingThickness' , calvingThickness)
4095+
4096+ where (groundedMaskForMassBudget .eq. 1)
4097+ groundedCalvingThickness = groundedCalvingThickness + calvingThickness
4098+ elsewhere (floatingMaskForMassBudget .eq. 1)
4099+ floatingCalvingThickness = floatingCalvingThickness + calvingThickness
4100+ end where
4101+
4102+ end subroutine update_calving_budget
4103+
40664104end module li_calving
40674105
40684106
0 commit comments