Skip to content

Commit

Permalink
enable icebergs with cavities
Browse files Browse the repository at this point in the history
  • Loading branch information
ackerlar committed Sep 27, 2024
1 parent 361b9b9 commit ca9b39a
Show file tree
Hide file tree
Showing 17 changed files with 522 additions and 784 deletions.
6 changes: 4 additions & 2 deletions src/gen_modules_config.F90
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ module g_config
logical :: turn_off_fw=.false.
logical :: use_icesheet_coupling=.false.
logical :: lbalance_fw=.true.
logical :: lcell_saturation=.true.
integer :: cell_saturation=2 ! 0=no cell saturation, 1=one additional iceberg allowed, 2=no daddtional iceberg allowed
logical :: lmin_latent_hf=.true.
logical :: lverbose_icb=.false.
integer :: ib_num=0
integer :: steps_per_ib_step=8

Expand All @@ -135,7 +136,8 @@ module g_config
integer :: ib_async_mode=0
integer :: thread_support_level_required=3 ! 2 = MPI_THREAD_SERIALIZED, 3 = MPI_THREAD_MULTIPLE

namelist /icebergs/ use_icebergs, turn_off_hf, turn_off_fw, use_icesheet_coupling, lbalance_fw, lcell_saturation, lmin_latent_hf, ib_num, steps_per_ib_step, ib_async_mode, thread_support_level_required
namelist /icebergs/ use_icebergs, turn_off_hf, turn_off_fw, use_icesheet_coupling, lbalance_fw, cell_saturation, lmin_latent_hf, &
ib_num, steps_per_ib_step, ib_async_mode, thread_support_level_required, lverbose_icb

!wiso-code!!!
logical :: lwiso =.false. ! enable isotope?
Expand Down
4 changes: 2 additions & 2 deletions src/icb_allocate.F90
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ subroutine allocate_icb(partit, mesh)
allocate(fwb_flux_ib(ib_num))
allocate(fwbv_flux_ib(ib_num))
allocate(hfe_flux_ib(ib_num))
allocate(hfl_flux_ib(ib_num))
allocate(hfl_flux_ib(ib_num,mesh%nl))
allocate(hfb_flux_ib(ib_num))
allocate(hfbv_flux_ib(ib_num))
allocate(hfbv_flux_ib(ib_num,mesh%nl))
allocate(lhfb_flux_ib(ib_num))
fwe_flux_ib = 0.0
fwl_flux_ib = 0.0
Expand Down
55 changes: 40 additions & 15 deletions src/icb_coupling.F90
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ subroutine reset_ib_fluxes()
end subroutine


subroutine prepare_icb2fesom(mesh, partit, ib,i_have_element,localelement,depth_ib)
subroutine prepare_icb2fesom(mesh, partit, ib,i_have_element,localelement,depth_ib,height_ib_single)
!transmits the relevant fields from the iceberg to the ocean model
!Lars Ackermann, 17.03.2020

Expand All @@ -27,7 +27,7 @@ subroutine prepare_icb2fesom(mesh, partit, ib,i_have_element,localelement,depth_
implicit none

logical :: i_have_element
real, intent(in) :: depth_ib
real, intent(in) :: depth_ib, height_ib_single
real :: lev_low, lev_up
integer :: localelement
integer :: iceberg_node
Expand All @@ -44,7 +44,7 @@ subroutine prepare_icb2fesom(mesh, partit, ib,i_have_element,localelement,depth_
#include "associate_part_ass.h"
#include "associate_mesh_ass.h"

if(i_have_element) then
if(i_have_element) then
dz = 0.0
allocate(tot_area_nods_in_ib_elem(mesh%nl))

Expand Down Expand Up @@ -89,6 +89,7 @@ subroutine prepare_icb2fesom(mesh, partit, ib,i_have_element,localelement,depth_

do i=1, 3
iceberg_node=ib_nods_in_ib_elem(i)
if (use_cavity .and. ulevels_nod2d(iceberg_node) > 1) cycle

if (iceberg_node>0) then
ibfwbv(iceberg_node) = ibfwbv(iceberg_node) - fwbv_flux_ib(ib) / tot_area_nods_in_ib_elem(1)
Expand All @@ -105,23 +106,34 @@ subroutine prepare_icb2fesom(mesh, partit, ib,i_have_element,localelement,depth_
lev_low = mesh%zbar_3d_n(j+1, iceberg_node)
end if
dz = abs( lev_low - lev_up )
if( (abs(lev_low)>=abs(depth_ib)) .and. (abs(lev_up)<abs(depth_ib)) ) then
dz = abs( lev_up - depth_ib )
end if

if( (abs(lev_low)>=abs(depth_ib)) .and. (abs(lev_up)<abs(depth_ib)) ) then
dz = abs( lev_up - abs(depth_ib) )
end if
if( depth_ib==0.0 ) then
ibhf_n(j,iceberg_node) = ibhf_n(j,iceberg_node) &
- ((hfbv_flux_ib(ib)+hfl_flux_ib(ib)) &
+ hfe_flux_ib(ib)) / tot_area_nods_in_ib_elem(j)
ibhf_n(j,iceberg_node) = ibhf_n(j,iceberg_node) &
- (hfbv_flux_ib(ib,j)+hfl_flux_ib(ib,j)) &
/ tot_area_nods_in_ib_elem(j)
else
ibhf_n(j,iceberg_node) = ibhf_n(j,iceberg_node) &
- ((hfbv_flux_ib(ib)+hfl_flux_ib(ib)) * (dz / abs(depth_ib)) &
+ hfe_flux_ib(ib) * (dz / abs(height_ib(ib)))) &
ibhf_n(j,iceberg_node) = ibhf_n(j,iceberg_node) &
- ((hfbv_flux_ib(ib,j)+hfl_flux_ib(ib,j)) * (dz / abs(depth_ib)) &
+ hfe_flux_ib(ib) * (dz / abs(height_ib_single))) &
/ tot_area_nods_in_ib_elem(j)
end if
end do
ibhf_n(idx_d(i),iceberg_node) = ibhf_n(idx_d(i),iceberg_node) - hfb_flux_ib(ib) / tot_area_nods_in_ib_elem(idx_d(i))
ibhf_n(1,iceberg_node) = ibhf_n(1,iceberg_node) - hfe_flux_ib(ib) * ((abs(height_ib(ib))-abs(depth_ib))/abs(height_ib(ib))) / tot_area_nods_in_ib_elem(1)

if( idx_d(i) > 1 ) then
ibhf_n(idx_d(i),iceberg_node) = ibhf_n(idx_d(i),iceberg_node) - 0.5 * hfb_flux_ib(ib) / tot_area_nods_in_ib_elem(idx_d(i))
ibhf_n(idx_d(i)-1,iceberg_node) = ibhf_n(idx_d(i)-1,iceberg_node) - 0.5 * hfb_flux_ib(ib) / tot_area_nods_in_ib_elem(idx_d(i)-1)
else
ibhf_n(idx_d(i),iceberg_node) = ibhf_n(idx_d(i),iceberg_node) - hfb_flux_ib(ib) / tot_area_nods_in_ib_elem(idx_d(i))
end if

if( height_ib_single .ne. 0.0 ) then
ibhf_n(1,iceberg_node) = ibhf_n(1,iceberg_node) - hfe_flux_ib(ib) &
* ((abs(height_ib_single)-abs(depth_ib))/abs(height_ib_single)) &
/ tot_area_nods_in_ib_elem(1)
end if
end if
end do
end if
Expand Down Expand Up @@ -150,11 +162,24 @@ subroutine icb2fesom(mesh, partit, ice)
#include "associate_part_ass.h"
#include "associate_mesh_ass.h"

if (use_cavity) then
!$OMP PARALLEL DO
do n=1, myDim_nod2d+eDim_nod2D
if (ulevels_nod2d(n) > 1) cycle
if (.not.turn_off_fw) then
water_flux(n) = water_flux(n) - (ibfwb(n)+ibfwl(n)+ibfwe(n)+ibfwbv(n)) !* steps_per_ib_step
end if
end do
!$OMP END PARALLEL DO
else
!$OMP PARALLEL DO
do n=1, myDim_nod2d+eDim_nod2D
if (.not.turn_off_fw) then
water_flux(n) = water_flux(n) - (ibfwb(n)+ibfwl(n)+ibfwe(n)+ibfwbv(n)) !* steps_per_ib_step
end if
end do
!$OMP END PARALLEL DO
end if
!---wiso-code-begin
if(lwiso) then
do n=1, myDim_nod2D+eDim_nod2D
Expand Down
22 changes: 0 additions & 22 deletions src/icb_coupling.F90.rej

This file was deleted.

Loading

0 comments on commit ca9b39a

Please sign in to comment.