Skip to content

Commit

Permalink
A few fixes to displace_fl_bergs to ensure new child berg is calved o…
Browse files Browse the repository at this point in the history
…nto the computational domain. Added testing of the option to convert footloose bits to a new berg upon accumulating enough mass.
  • Loading branch information
alex-huth committed May 5, 2021
1 parent 7a3f267 commit 8c92a8c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
30 changes: 16 additions & 14 deletions src/icebergs.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2554,12 +2554,12 @@ subroutine footloose_calving(bergs, time)
type(iceberg), pointer :: this
type(icebergs_gridded), pointer :: grd
type(bond), pointer :: current_bond
real, save :: N_max, youngs, poisson, l_c, lw_c, B_c, exp_nlambda
real, save :: N_max, youngs, poisson, l_c, lw_c, B_c, exp_nlambda, rn
type(randomNumberStream),save :: rns ! Random numbers for stochastic tidal parameterization
logical, save :: Visited=.false.
integer :: grdi, grdj
integer, dimension(8) :: seed
real :: T, W, L, N_bonds, Ln, rn
real :: T, W, L, N_bonds, Ln
real :: IC, max_k, k, Lr_fl, l_w, l_b, pu
real :: fl_disp_x, fl_disp_y, interp_loc, dM_fl_bits

Expand All @@ -2586,7 +2586,7 @@ subroutine footloose_calving(bergs, time)
exp_nlambda=exp(-bergs%fl_r) !e^(-r*dt)
seed = constructSeed(mpp_pe(),mpp_pe(),time) !Seed random numbers for Poisson distribution
rns = initializeRandomNumberStream(seed)

call getRandomNumbers(rns, rn)
Visited=.true.
endif

Expand Down Expand Up @@ -2678,6 +2678,7 @@ subroutine footloose_calving(bergs, time)

if (bergs%fl_style.eq.'new_bergs') then
!calve and track footloose bergs
if (bergs%displace_fl_bergs .and. .not. bergs%fl_use_poisson_distribution) call getRandomNumbers(rns, rn)
call get_footloose_displacement
call calve_fl_icebergs(bergs,this,k,l_b,fl_disp_x,fl_disp_y)
bergs%nbergs_calved_fl=bergs%nbergs_calved_fl+1
Expand Down Expand Up @@ -2710,6 +2711,7 @@ subroutine footloose_calving(bergs, time)

!Optionally, create a new berg from the FL bits if their mass exceeds a threshold
if (this%mass_of_fl_bits*this%mass_scaling > bergs%new_berg_from_fl_bits_mass_thres) then
if (bergs%displace_fl_bergs .and. .not. bergs%fl_use_poisson_distribution) call getRandomNumbers(rns, rn)
call get_footloose_displacement
k=1
call calve_fl_icebergs(bergs,this,k,l_b,fl_disp_x,fl_disp_y,berg_from_bits=.true.)
Expand Down Expand Up @@ -6241,22 +6243,22 @@ subroutine calve_fl_icebergs(bergs,pberg,k,l_b,fl_disp_x,fl_disp_y,berg_from_bit
if (displace) then
cberg%lon = pberg%lon + fl_disp_x
cberg%lat = pberg%lat + fl_disp_y
lres= find_cell_wide(grd, cberg%lon, cberg%lat, cberg%ine, cberg%jne)
lres= find_cell(grd, cberg%lon, cberg%lat, cberg%ine, cberg%jne)

!If new berg is not on current PE, correct it so that it is.
!If new berg is not on current PE (computational domain), correct it so that it is.
if (.not. lres) then
!The choice of 75% and 25% weighting here is completely arbitrary...
if (cberg%lon > grd%lon(grd%ied,grd%jed)) then
cberg%lon = 0.75*grd%lon(grd%ied,grd%jed) + 0.25*pberg%lon
elseif (cberg%lon < grd%lon(grd%isd,grd%jsd)) then
cberg%lon = 0.75*grd%lon(grd%isd,grd%jsd) + 0.25*pberg%lon
if (cberg%lon > grd%lon(grd%iec,grd%jec)) then
cberg%lon = 0.75*grd%lon(grd%iec,grd%jec) + 0.25*pberg%lon
elseif (cberg%lon < grd%lon(grd%isc-1,grd%jsc-1)) then
cberg%lon = 0.75*grd%lon(grd%isc-1,grd%jsc-1) + 0.25*pberg%lon
endif
if (cberg%lat > grd%lat(grd%ied,grd%jed)) then
cberg%lat = 0.75*grd%lat(grd%ied,grd%jed) + 0.25*pberg%lat
elseif (cberg%lat < grd%lat(grd%isd,grd%jsd)) then
cberg%lat = 0.75*grd%lat(grd%isd,grd%jsd) + 0.25*pberg%lat
if (cberg%lat > grd%lat(grd%iec,grd%jec)) then
cberg%lat = 0.75*grd%lat(grd%iec,grd%jec) + 0.25*pberg%lat
elseif (cberg%lat < grd%lat(grd%isc-1,grd%jsc-1)) then
cberg%lat = 0.75*grd%lat(grd%isc-1,grd%jsc-1) + 0.25*pberg%lat
endif
lres= find_cell_wide(grd, cberg%lon, cberg%lat, cberg%ine, cberg%jne)
lres= find_cell(grd, cberg%lon, cberg%lat, cberg%ine, cberg%jne)
if (.not. lres) call error_mesg('KID, calve_fl_icebergs', &
'corrected new berg position still not on current PE!', FATAL)
fl_disp_x=pberg%lon-cberg%lon; fl_disp_y=pberg%lat-cberg%lat
Expand Down
4 changes: 3 additions & 1 deletion tests/footloose_no_bond_test/input.nml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@

fl_r=4 !(4) average number of footloose bergs to calve per fl_r_s seconds
fl_r_s=86400 !(86400) time in s over which to calve, on average, fl_r footloose bergs
displace_fl_bergs=.false. !(T) randomly assign FL berg positions to sides of parent berg
displace_fl_bergs=.true. !(T) randomly assign FL berg positions to sides of parent berg
fl_style='fl_bits' !('new_bergs'). Can also group FL bergs into 'fl_bits'
fl_melt_as_bergy_bits=.false.!true. !(F) If fl_style==fl_bits, melt the fl_bits as bergy bits
new_berg_from_fl_bits_mass_thres=8.e11
fl_use_poisson_distribution=.true.!.false.

mts=.false. !(F) for using the Multiple Time Stepping Velocity Verlet scheme
mts_sub_steps=1 !(-1) # of mts sub-steps (-1=automatically determine # from spring const)
Expand Down

0 comments on commit 8c92a8c

Please sign in to comment.