Skip to content

Commit

Permalink
Update implementation of some optional arguments in Icepack (#429)
Browse files Browse the repository at this point in the history
* Update implementation of some optional arguments in Icepack
 - Remove local copies where possible
 - Check optional arguments
Remove public interface declarations where not needed
Clean up some intent statements

* Add write_diags argument to icepack_init_fsd_bounds
Update documentation

* Clean up meltsliq implementation in icepack_step_therm1
  • Loading branch information
apcraig authored Mar 1, 2023
1 parent 03e7e57 commit acfc046
Show file tree
Hide file tree
Showing 12 changed files with 241 additions and 311 deletions.
12 changes: 3 additions & 9 deletions columnphysics/icepack_fsd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,10 @@ subroutine icepack_init_fsd_bounds(nfsd, &
real (kind=dbl_kind), dimension(:), allocatable :: &
lims

logical (kind=log_kind) :: &
l_write_diags ! local write diags

character(len=8) :: c_fsd1,c_fsd2
character(len=2) :: c_nf
character(len=*), parameter :: subname='(icepack_init_fsd_bounds)'

l_write_diags = .true.
if (present(write_diags)) then
l_write_diags = write_diags
endif

if (nfsd.eq.24) then

allocate(lims(24+1))
Expand Down Expand Up @@ -230,7 +222,8 @@ subroutine icepack_init_fsd_bounds(nfsd, &
c_fsd_range(n)=c_fsd1//'m < fsd Cat '//c_nf//' < '//c_fsd2//'m'
enddo

if (l_write_diags) then
if (present(write_diags)) then
if (write_diags) then
write(warnstr,*) ' '
call icepack_warnings_add(warnstr)
write(warnstr,*) subname
Expand All @@ -244,6 +237,7 @@ subroutine icepack_init_fsd_bounds(nfsd, &
write(warnstr,*) ' '
call icepack_warnings_add(warnstr)
endif
endif

end subroutine icepack_init_fsd_bounds

Expand Down
10 changes: 6 additions & 4 deletions columnphysics/icepack_itd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -997,10 +997,12 @@ subroutine cleanup_itd (dt, ntrcr, &
faero_ocn(it) = faero_ocn(it) + dfaero_ocn(it)
enddo
endif
if (tr_iso) then
do it = 1, n_iso
fiso_ocn(it) = fiso_ocn(it) + dfiso_ocn(it)
enddo
if (present(fiso_ocn)) then
if (tr_iso) then
do it = 1, n_iso
fiso_ocn(it) = fiso_ocn(it) + dfiso_ocn(it)
enddo
endif
endif
if (present(flux_bio)) then
do it = 1, nbtrcr
Expand Down
39 changes: 11 additions & 28 deletions columnphysics/icepack_mechred.F90
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ module icepack_mechred
implicit none

private
public :: ridge_ice, &
asum_ridging, &
ridge_itd, &
icepack_ice_strength, &
public :: icepack_ice_strength, &
icepack_step_ridge

real (kind=dbl_kind), parameter :: &
Expand Down Expand Up @@ -113,7 +110,7 @@ subroutine ridge_ice (dt, ndtd, &
dardg1ndt, dardg2ndt, &
dvirdgndt, &
araftn, vraftn, &
closing_flag,closing )
closing )

integer (kind=int_kind), intent(in) :: &
ndtd , & ! number of dynamics subcycles
Expand Down Expand Up @@ -161,7 +158,6 @@ subroutine ridge_ice (dt, ndtd, &
krdg_redist ! selects redistribution function

logical (kind=log_kind), intent(in) :: &
closing_flag, &! flag if closing is valid
tr_brine ! if .true., brine height differs from ice thickness

! optional history fields
Expand Down Expand Up @@ -296,7 +292,7 @@ subroutine ridge_ice (dt, ndtd, &
! Compute the area opening and closing.
!-----------------------------------------------------------------

if (closing_flag) then
if (present(opening) .and. present(closing)) then

opning = opening
closing_net = closing
Expand Down Expand Up @@ -595,11 +591,13 @@ subroutine ridge_ice (dt, ndtd, &
faero_ocn(it) = faero_ocn(it) + maero(it)*dti
enddo
endif
if (tr_iso) then
! check size fiso_ocn vs n_iso ???
do it = 1, n_iso
fiso_ocn(it) = fiso_ocn(it) + miso(it)*dti
enddo
if (present(fiso_ocn)) then
if (tr_iso) then
! check size fiso_ocn vs n_iso ???
do it = 1, n_iso
fiso_ocn(it) = fiso_ocn(it) + miso(it)*dti
enddo
endif
endif
if (present(fpond)) then
fpond = fpond - mpond ! units change later
Expand Down Expand Up @@ -1826,12 +1824,6 @@ subroutine icepack_step_ridge (dt, ndtd, &
real (kind=dbl_kind) :: &
dtt ! thermo time step

real (kind=dbl_kind) :: &
l_closing ! local rate of closing due to divergence/shear (1/s)

logical (kind=log_kind) :: &
l_closing_flag ! flag if closing is passed

logical (kind=log_kind), save :: &
first_call = .true. ! first call flag

Expand Down Expand Up @@ -1859,14 +1851,6 @@ subroutine icepack_step_ridge (dt, ndtd, &
! it may be out of whack, which the ridging helps fix).-ECH
!-----------------------------------------------------------------

if (present(closing)) then
l_closing_flag = .true.
l_closing = closing
else
l_closing_flag = .false.
l_closing = c0
endif

call ridge_ice (dt, ndtd, &
ncat, n_aero, &
nilyr, nslyr, &
Expand All @@ -1892,8 +1876,7 @@ subroutine icepack_step_ridge (dt, ndtd, &
dardg1ndt, dardg2ndt, &
dvirdgndt, &
araftn, vraftn, &
l_closing_flag, &
l_closing )
closing )
if (icepack_warnings_aborted(subname)) return

!-----------------------------------------------------------------
Expand Down
15 changes: 15 additions & 0 deletions columnphysics/icepack_orbital.F90
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,24 @@ subroutine compute_coszen (tlat, tlon, &

real (kind=dbl_kind) :: ydayp1 ! day of year plus one time step

logical (kind=log_kind), save :: &
first_call = .true. ! first call flag

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

! Solar declination for next time step

#ifdef CESMCOUPLED
if (icepack_chkoptargflag(first_call)) then
if (.not.(present(days_per_year) .and. &
present(nextsw_cday) .and. &
present(calendar_type))) then
call icepack_warnings_add(subname//' error in CESMCOUPLED args')
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
return
endif
endif

if (calendar_type == "GREGORIAN") then
ydayp1 = min(nextsw_cday, real(days_per_year,kind=dbl_kind))
else
Expand All @@ -206,6 +219,8 @@ subroutine compute_coszen (tlat, tlon, &
endif
#endif

first_call = .false.

end subroutine compute_coszen

!===============================================================================
Expand Down
Loading

0 comments on commit acfc046

Please sign in to comment.