Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FSD fixes for conservation #495

Merged
merged 40 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
28d8396
Fixes for freshwater and salt conservation
dabail10 May 30, 2024
3f9b25f
Fix heat conservation and rearrange rside computation
dabail10 Jul 24, 2024
d0334c8
Also fix tracer vicen_init
dabail10 Jul 24, 2024
f66423a
One more fix for the FSD and update the driver.
dabail10 Jul 29, 2024
1cd7f7f
The character array does not need to be different at each point. Fixe…
dabail10 Jul 30, 2024
fed338c
Change the floe boundaries to be the same for all points
dabail10 Jul 30, 2024
77e43af
Clean up some comments
dabail10 Jul 30, 2024
c9ad3bc
Use ktherm=1 when sw is ccsm3
dabail10 Aug 15, 2024
b82474e
Remove spatial index on wavefreq and dwavefreq
dabail10 Aug 21, 2024
4104292
fix some spaces
dabail10 Aug 21, 2024
88a417b
Remove spatial index for local wave_spectrum_profile
dabail10 Aug 21, 2024
003aa6f
Remove spatial index for local wave_spectrum_profile
dabail10 Aug 21, 2024
c4f2f9c
Remove spatial index for local wave_spectrum_profile
dabail10 Aug 21, 2024
3c07803
Remove spatial index for local wave_spectrum_profile
dabail10 Aug 21, 2024
8925988
clean up driver code
dabail10 Aug 21, 2024
a3f6fbd
clean up driver code
dabail10 Aug 21, 2024
bfbc456
clean up driver code
dabail10 Aug 21, 2024
896190d
clean up driver code
dabail10 Aug 21, 2024
b6f35ad
clean up driver code
dabail10 Aug 21, 2024
1dbe211
Fix heat conservation and rearrange rside computation
dabail10 Jul 24, 2024
6daa191
One more fix for the FSD and update the driver.
dabail10 Jul 29, 2024
6732ac3
The character array does not need to be different at each point. Fixe…
dabail10 Jul 30, 2024
901b259
Change the floe boundaries to be the same for all points
dabail10 Jul 30, 2024
8c32f9f
Clean up some comments
dabail10 Jul 30, 2024
65910c0
Remove spatial index on wavefreq and dwavefreq
dabail10 Aug 21, 2024
664436d
clean up driver code
dabail10 Aug 21, 2024
19be00b
clean up driver code
dabail10 Aug 21, 2024
54dc9a1
clean up driver code
dabail10 Aug 21, 2024
b7270c6
Fix up some more nx related stuff
dabail10 Sep 20, 2024
7cde537
Bug fix from the BGC merge
dabail10 Sep 23, 2024
44f71bb
Some more fixes resulting from the BGC merge
dabail10 Sep 24, 2024
2258ead
Merge branch 'CICE-Consortium:main' into fsdfixes
dabail10 Oct 2, 2024
d8c458d
Change all of the floe_ variables to be public module variables in ic…
dabail10 Oct 3, 2024
a8911c3
Add checks for optional afsdn and allocate l_afsdn
dabail10 Oct 9, 2024
07ded3b
Merge branch 'CICE-Consortium:main' into fsdfixes
dabail10 Oct 25, 2024
9a745f0
Add output arguments for floe_rad_l, floe_rad_c, floe_binwidth, and
apcraig Oct 25, 2024
5a703ba
Merge pull request #1 from apcraig/fsdfixes_tc02
dabail10 Oct 25, 2024
1bff0fb
Code cleanup in icepack_therm_itd.F90
dabail10 Oct 25, 2024
65ec921
Additional bug fix to floe_area_c
dabail10 Oct 25, 2024
a2c5bca
Delete some comments to clean up the code
dabail10 Oct 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 82 additions & 57 deletions columnphysics/icepack_fsd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,19 @@ module icepack_fsd
public :: icepack_init_fsd_bounds, icepack_init_fsd, icepack_cleanup_fsd, &
fsd_lateral_growth, fsd_add_new_ice, fsd_weld_thermo, get_subdt_fsd

real(kind=dbl_kind), dimension(:), allocatable :: &
real(kind=dbl_kind), dimension(:), allocatable, public :: &
floe_rad_h, & ! fsd size higher bound in m (radius)
floe_rad_c, & ! fsd size center in m (radius)
floe_rad_l, & ! fsd size lower bound in m (radius)
floe_binwidth, & ! fsd size binwidth in m (radius)
floe_area_l, & ! fsd area at lower bound (m^2)
floe_area_h, & ! fsd area at higher bound (m^2)
floe_area_c, & ! fsd area at bin centre (m^2)
floe_area_binwidth ! floe area bin width (m^2)

character (len=35), dimension(:), allocatable, public :: &
c_fsd_range ! string for history output

integer(kind=int_kind), dimension(:,:), allocatable, public :: &
iweld ! floe size categories that can combine
! during welding (dimensionless)
Expand All @@ -85,22 +91,22 @@ module icepack_fsd
! authors: Lettie Roach, NIWA/VUW and C. M. Bitz, UW

subroutine icepack_init_fsd_bounds( &
floe_rad_l, & ! fsd size lower bound in m (radius)
floe_rad_c, & ! fsd size bin centre in m (radius)
floe_binwidth, & ! fsd size bin width in m (radius)
c_fsd_range, & ! string for history output
write_diags ) ! flag for writing diagnostics
floe_rad_l_out, & ! fsd size lower bound in m (radius)
floe_rad_c_out, & ! fsd size bin centre in m (radius)
floe_binwidth_out, & ! fsd size bin width in m (radius)
c_fsd_range_out, & ! string for history output
write_diags) ! flag for writing diagnostics

real(kind=dbl_kind), dimension(:), intent(inout) :: &
floe_rad_l, & ! fsd size lower bound in m (radius)
floe_rad_c, & ! fsd size bin centre in m (radius)
floe_binwidth ! fsd size bin width in m (radius)
real(kind=dbl_kind), dimension(:), intent(out), optional :: &
floe_rad_l_out, & ! fsd size lower bound in m (radius)
floe_rad_c_out, & ! fsd size bin centre in m (radius)
floe_binwidth_out ! fsd size bin width in m (radius)

character (len=35), intent(out) :: &
c_fsd_range(nfsd) ! string for history output
character (len=35), dimension(:), intent(out), optional :: &
c_fsd_range_out ! string for history output

logical (kind=log_kind), intent(in), optional :: &
write_diags ! write diags flag
write_diags ! write diags flag

!autodocument_end

Expand All @@ -111,11 +117,8 @@ subroutine icepack_init_fsd_bounds( &

real (kind=dbl_kind) :: test

real (kind=dbl_kind), dimension (0:nfsd) :: &
floe_rad

real (kind=dbl_kind), dimension(:), allocatable :: &
lims
lims, floe_rad

character(len=8) :: c_fsd1,c_fsd2
character(len=2) :: c_nf
Expand Down Expand Up @@ -169,10 +172,15 @@ subroutine icepack_init_fsd_bounds( &

allocate( &
floe_rad_h (nfsd), & ! fsd size higher bound in m (radius)
floe_rad_l (nfsd), & ! fsd size lower bound in m (radius)
floe_rad_c (nfsd), & ! fsd size center in m (radius)
floe_rad (0:nfsd), & ! fsd bounds in m (radius)
floe_area_l (nfsd), & ! fsd area at lower bound (m^2)
floe_area_h (nfsd), & ! fsd area at higher bound (m^2)
floe_area_c (nfsd), & ! fsd area at bin centre (m^2)
floe_area_binwidth (nfsd), & ! floe area bin width (m^2)
floe_binwidth (nfsd), & ! floe bin width (m)
c_fsd_range (nfsd), & !
iweld (nfsd, nfsd), & ! fsd categories that can weld
stat=ierr)
if (ierr/=0) then
Expand All @@ -186,8 +194,11 @@ subroutine icepack_init_fsd_bounds( &
floe_rad_c = (floe_rad_h+floe_rad_l)/c2

floe_area_l = c4*floeshape*floe_rad_l**2
floe_area_c = c4*floeshape*floe_rad_c**2
floe_area_h = c4*floeshape*floe_rad_h**2
! floe_area_c = c4*floeshape*floe_rad_c**2
! This is exactly in the middle of floe_area_h and floe_area_l
! Whereas the above calculation is closer to floe_area_l.
floe_area_c = (floe_area_h+floe_area_l)/c2

floe_binwidth = floe_rad_h - floe_rad_l

Expand Down Expand Up @@ -220,20 +231,56 @@ subroutine icepack_init_fsd_bounds( &
enddo

if (present(write_diags)) then
if (write_diags) then
write(warnstr,*) ' '
call icepack_warnings_add(warnstr)
write(warnstr,*) subname
call icepack_warnings_add(warnstr)
write(warnstr,*) 'floe_rad(n-1) < fsd Cat n < floe_rad(n)'
call icepack_warnings_add(warnstr)
do n = 1, nfsd
write(warnstr,*) floe_rad(n-1),' < fsd Cat ',n, ' < ',floe_rad(n)
if (write_diags) then
write(warnstr,*) ' '
call icepack_warnings_add(warnstr)
enddo
write(warnstr,*) ' '
call icepack_warnings_add(warnstr)
write(warnstr,*) subname
call icepack_warnings_add(warnstr)
write(warnstr,*) 'floe_rad(n-1) < fsd Cat n < floe_rad(n)'
call icepack_warnings_add(warnstr)
do n = 1, nfsd
write(warnstr,*) floe_rad(n-1),' < fsd Cat ',n, ' < ',floe_rad(n)
call icepack_warnings_add(warnstr)
enddo
write(warnstr,*) ' '
call icepack_warnings_add(warnstr)
endif
endif

if (present(floe_rad_l_out)) then
if (size(floe_rad_l_out) /= size(floe_rad_l)) then
call icepack_warnings_add(subname//' floe_rad_l_out incorrect size')
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
return
endif
floe_rad_l_out(:) = floe_rad_l(:)
endif

if (present(floe_rad_c_out)) then
if (size(floe_rad_c_out) /= size(floe_rad_c)) then
call icepack_warnings_add(subname//' floe_rad_c_out incorrect size')
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
return
endif
floe_rad_c_out(:) = floe_rad_c(:)
endif

if (present(floe_binwidth_out)) then
if (size(floe_binwidth_out) /= size(floe_binwidth)) then
call icepack_warnings_add(subname//' floe_binwidth_out incorrect size')
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
return
endif
floe_binwidth_out(:) = floe_binwidth(:)
endif

if (present(c_fsd_range_out)) then
if (size(c_fsd_range_out) /= size(c_fsd_range)) then
call icepack_warnings_add(subname//' c_fsd_range_out incorrect size')
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
return
endif
c_fsd_range_out(:) = c_fsd_range(:)
endif

end subroutine icepack_init_fsd_bounds
Expand All @@ -256,18 +303,11 @@ end subroutine icepack_init_fsd_bounds
!
! authors: Lettie Roach, NIWA/VUW

subroutine icepack_init_fsd(ice_ic, &
floe_rad_c, & ! fsd size bin centre in m (radius)
floe_binwidth, & ! fsd size bin width in m (radius)
afsd) ! floe size distribution tracer
subroutine icepack_init_fsd(ice_ic, afsd) ! floe size distribution tracer

character(len=char_len_long), intent(in) :: &
ice_ic ! method of ice cover initialization

real(kind=dbl_kind), dimension(:), intent(inout) :: &
floe_rad_c, & ! fsd size bin centre in m (radius)
floe_binwidth ! fsd size bin width in m (radius)

real (kind=dbl_kind), dimension (:), intent(inout) :: &
afsd ! floe size tracer: fraction distribution of floes

Expand Down Expand Up @@ -323,7 +363,6 @@ subroutine icepack_cleanup_fsd (afsdn)

character(len=*), parameter :: subname='(icepack_cleanup_fsd)'


if (tr_fsd) then

do n = 1, ncat
Expand Down Expand Up @@ -378,14 +417,11 @@ end subroutine icepack_cleanup_fsdn
!
! authors: Lettie Roach, NIWA/VUW

subroutine partition_area (floe_rad_c, aice, &
subroutine partition_area (aice, &
aicen, vicen, &
afsdn, lead_area, &
latsurf_area)

real (kind=dbl_kind), dimension(:), intent(in) :: &
floe_rad_c ! fsd size bin centre in m (radius)

real (kind=dbl_kind), intent(in) :: &
aice ! ice concentration

Expand Down Expand Up @@ -476,7 +512,7 @@ end subroutine partition_area
subroutine fsd_lateral_growth (dt, aice, &
aicen, vicen, &
vi0new, &
frazil, floe_rad_c, &
frazil, &
afsdn, &
lead_area, latsurf_area, &
G_radial, d_an_latg, &
Expand All @@ -497,10 +533,6 @@ subroutine fsd_lateral_growth (dt, aice, &
vi0new , & ! volume of new ice added to cat 1 (m)
frazil ! frazil ice growth (m/step-->cm/day)

! floe size distribution
real (kind=dbl_kind), dimension (:), intent(in) :: &
floe_rad_c ! fsd size bin centre in m (radius)

real (kind=dbl_kind), dimension(ncat), intent(out) :: &
d_an_latg ! change in aicen occuring due to lateral growth

Expand Down Expand Up @@ -529,7 +561,7 @@ subroutine fsd_lateral_growth (dt, aice, &
d_an_latg = c0

! partition volume into lateral growth and frazil
call partition_area (floe_rad_c, aice, &
call partition_area (aice, &
aicen, vicen, &
afsdn, lead_area, &
latsurf_area)
Expand All @@ -540,9 +572,6 @@ subroutine fsd_lateral_growth (dt, aice, &
vi0new_lat = vi0new * lead_area / (c1 + aice/latsurf_area)
end if

! for history/diagnostics
frazil = vi0new - vi0new_lat

! lateral growth increment
if (vi0new_lat > puny) then
G_radial = vi0new_lat/dt
Expand All @@ -564,7 +593,6 @@ subroutine fsd_lateral_growth (dt, aice, &

! Use remaining ice volume as in standard model,
! but ice cannot grow into the area that has grown laterally
dabail10 marked this conversation as resolved.
Show resolved Hide resolved
vi0new = vi0new - vi0new_lat
tot_latg = SUM(d_an_latg(:))

end subroutine fsd_lateral_growth
Expand All @@ -589,7 +617,6 @@ end subroutine fsd_lateral_growth
subroutine fsd_add_new_ice (n, &
dt, ai0new, &
d_an_latg, d_an_newi, &
floe_rad_c, floe_binwidth, &
G_radial, area2, &
wave_sig_ht, &
wave_spectrum, &
Expand Down Expand Up @@ -623,9 +650,7 @@ subroutine fsd_add_new_ice (n, &

real (kind=dbl_kind), dimension (:), intent(in) :: &
aicen_init , & ! fractional area of ice
aicen , & ! after update
floe_rad_c , & ! fsd size bin centre in m (radius)
floe_binwidth ! fsd size bin width in m (radius)
aicen ! after update

real (kind=dbl_kind), dimension (:,:), intent(in) :: &
afsdn ! floe size distribution tracer
Expand Down
Loading
Loading