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

update icepack interfaces #282

Merged
merged 6 commits into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Next Next commit
update icepack_itd interfaces
  • Loading branch information
apcraig committed Nov 6, 2019
commit dd22beae4a8570aef42064a56a8c400b01d4aeff
89 changes: 64 additions & 25 deletions columnphysics/icepack_itd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module icepack_itd
use icepack_parameters, only: solve_zsal, skl_bgc, z_tracers
use icepack_parameters, only: kcatbound, kitd
use icepack_therm_shared, only: Tmin, hi_min
use icepack_warnings, only: warnstr, icepack_warnings_add
use icepack_warnings, only: warnstr, icepack_warnings_add, icepack_warnings_argchk
use icepack_warnings, only: icepack_warnings_setabort, icepack_warnings_aborted

use icepack_zbgc_shared, only: zap_small_bgc
Expand Down Expand Up @@ -816,7 +816,7 @@ subroutine cleanup_itd (dt, ntrcr, &
tr_pond_topo, & ! topo pond flag
heat_capacity ! if false, ice and snow have zero heat capacity

logical (kind=log_kind), dimension(ncat),intent(inout) :: &
logical (kind=log_kind), dimension(ncat), intent(inout) :: &
first_ice ! For bgc and S tracers. set to true if zapping ice.

! ice-ocean fluxes (required for strict conservation)
Expand All @@ -831,8 +831,7 @@ subroutine cleanup_itd (dt, ntrcr, &
real (kind=dbl_kind), dimension (:), intent(inout), optional :: &
flux_bio ! net tracer flux to ocean from biology (mmol/m^2/s)

real (kind=dbl_kind), dimension (:), &
intent(inout), optional :: &
real (kind=dbl_kind), dimension (:), intent(inout), optional :: &
faero_ocn ! aerosol flux to ocean (kg/m^2/s)

logical (kind=log_kind), intent(in), optional :: &
Expand Down Expand Up @@ -1073,7 +1072,7 @@ subroutine zap_small_areas (dt, ntrcr, &
tr_aero, & ! aerosol flag
tr_pond_topo ! pond flag

logical (kind=log_kind), dimension (:),intent(inout) :: &
logical (kind=log_kind), dimension (:), intent(inout) :: &
first_ice ! For bgc tracers. Set to true if zapping ice

! local variables
Expand Down Expand Up @@ -1439,7 +1438,7 @@ subroutine zap_snow_temperature(dt, ncat, &
real (kind=dbl_kind), dimension (:), intent(inout) :: &
dfaero_ocn ! zapped aerosol flux (kg/m^2/s)

real (kind=dbl_kind), dimension (:),intent(inout) :: &
real (kind=dbl_kind), dimension (:), intent(inout) :: &
dflux_bio ! zapped biology flux (mmol/m^2/s)

logical (kind=log_kind), intent(in) :: &
Expand Down Expand Up @@ -1677,11 +1676,11 @@ end subroutine zerolayer_check

subroutine icepack_init_itd(ncat, hin_max)

integer (kind=int_kind), intent(in) :: &
integer (kind=int_kind), intent(in), optional :: &
ncat ! number of thickness categories

real (kind=dbl_kind), intent(out) :: &
hin_max(0:ncat) ! category limits (m)
real (kind=dbl_kind), intent(out), optional :: &
hin_max(0:) ! category limits (m) (0:ncat)

! local variables

Expand All @@ -1703,6 +1702,9 @@ subroutine icepack_init_itd(ncat, hin_max)
real (kind=dbl_kind), dimension(6) :: wmo6 ! data for wmo itd
real (kind=dbl_kind), dimension(7) :: wmo7 ! data for wmo itd

logical (kind=log_kind) :: &
interface_error ! = .true. if interface error is found

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

! thinnest 3 categories combined
Expand All @@ -1725,6 +1727,11 @@ subroutine icepack_init_itd(ncat, hin_max)
1.20_dbl_kind, 2.00_dbl_kind, &
999._dbl_kind /

interface_error = .false.
call icepack_warnings_argchk(present(ncat) ,"ncat" ,subname,interface_error)
call icepack_warnings_argchk(present(hin_max),"hin_max",subname,interface_error)
if (interface_error) return

rncat = real(ncat, kind=dbl_kind)
d1 = 3.0_dbl_kind / rncat
d2 = 0.5_dbl_kind / rncat
Expand Down Expand Up @@ -1856,14 +1863,14 @@ end subroutine icepack_init_itd

subroutine icepack_init_itd_hist (ncat, hin_max, c_hi_range)

integer (kind=int_kind), intent(in) :: &
ncat ! number of thickness categories
integer (kind=int_kind), intent(in), optional :: &
ncat ! number of thickness categories

real (kind=dbl_kind), intent(in) :: &
hin_max(0:ncat) ! category limits (m)
real (kind=dbl_kind), intent(in), optional :: &
hin_max(0:) ! category limits (m) (0:ncat)

character (len=35), intent(out) :: &
c_hi_range(ncat) ! string for history output
character (len=35), intent(out), optional :: &
c_hi_range(:) ! string for history output (ncat)

! local variables

Expand All @@ -1873,8 +1880,17 @@ subroutine icepack_init_itd_hist (ncat, hin_max, c_hi_range)
character(len=8) :: c_hinmax1,c_hinmax2
character(len=2) :: c_nc

logical (kind=log_kind) :: &
interface_error ! = .true. if interface error is found

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

interface_error = .false.
call icepack_warnings_argchk(present(ncat) ,"ncat" ,subname,interface_error)
call icepack_warnings_argchk(present(hin_max) ,"hin_max" ,subname,interface_error)
call icepack_warnings_argchk(present(c_hi_range),"c_hi_range",subname,interface_error)
if (interface_error) return

write(warnstr,*) ' '
call icepack_warnings_add(warnstr)
write(warnstr,*) subname
Expand Down Expand Up @@ -1919,38 +1935,36 @@ subroutine icepack_aggregate (ncat, &
n_trcr_strata, &
nt_strata)

integer (kind=int_kind), intent(in) :: &
integer (kind=int_kind), intent(in), optional :: &
ncat , & ! number of thickness categories
ntrcr ! number of tracers in use

real (kind=dbl_kind), dimension (:), intent(in) :: &
real (kind=dbl_kind), dimension (:), intent(in), optional :: &
aicen , & ! concentration of ice
vicen , & ! volume per unit area of ice (m)
vsnon ! volume per unit area of snow (m)

real (kind=dbl_kind), dimension (:,:), &
intent(inout) :: &
real (kind=dbl_kind), dimension (:,:), intent(inout), optional :: &
trcrn ! ice tracers

integer (kind=int_kind), dimension (:), intent(in) :: &
integer (kind=int_kind), dimension (:), intent(in), optional :: &
trcr_depend, & ! = 0 for aicen tracers, 1 for vicen, 2 for vsnon
n_trcr_strata ! number of underlying tracer layers

real (kind=dbl_kind), dimension (:,:), intent(in) :: &
real (kind=dbl_kind), dimension (:,:), intent(in), optional :: &
trcr_base ! = 0 or 1 depending on tracer dependency
! argument 2: (1) aice, (2) vice, (3) vsno

integer (kind=int_kind), dimension (:,:), intent(in) :: &
integer (kind=int_kind), dimension (:,:), intent(in), optional :: &
nt_strata ! indices of underlying tracer layers

real (kind=dbl_kind), intent(out) :: &
real (kind=dbl_kind), intent(out), optional :: &
aice , & ! concentration of ice
vice , & ! volume per unit area of ice (m)
vsno , & ! volume per unit area of snow (m)
aice0 ! concentration of open water

real (kind=dbl_kind), dimension (:), &
intent(out) :: &
real (kind=dbl_kind), dimension (:), intent(out), optional :: &
trcr ! ice tracers

! local variables
Expand All @@ -1965,8 +1979,33 @@ subroutine icepack_aggregate (ncat, &
real (kind=dbl_kind) :: &
atrcrn ! category value

logical (kind=log_kind) :: &
interface_error ! = .true. if interface error is found

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

!-----------------------------------------------------------------
! Check arguments
!-----------------------------------------------------------------

interface_error = .false.
call icepack_warnings_argchk(present(ncat) ,"ncat" ,subname,interface_error)
call icepack_warnings_argchk(present(trcrn),"trcrn",subname,interface_error)
call icepack_warnings_argchk(present(aicen),"aicen",subname,interface_error)
call icepack_warnings_argchk(present(vicen),"vicen",subname,interface_error)
call icepack_warnings_argchk(present(vsnon),"vsnon",subname,interface_error)
call icepack_warnings_argchk(present(trcr) ,"trcr" ,subname,interface_error)
call icepack_warnings_argchk(present(aice) ,"aice" ,subname,interface_error)
call icepack_warnings_argchk(present(vice) ,"vice" ,subname,interface_error)
call icepack_warnings_argchk(present(vsno) ,"vsno" ,subname,interface_error)
call icepack_warnings_argchk(present(aice0),"aice0",subname,interface_error)
call icepack_warnings_argchk(present(ntrcr),"ntrcr",subname,interface_error)
call icepack_warnings_argchk(present(trcr_depend),"trcr_depend",subname,interface_error)
call icepack_warnings_argchk(present(trcr_base),"trcr_base",subname,interface_error)
call icepack_warnings_argchk(present(n_trcr_strata),"n_trcr_strata",subname,interface_error)
call icepack_warnings_argchk(present(nt_strata),"nt_strata",subname,interface_error)
if (interface_error) return

!-----------------------------------------------------------------
! Initialize
!-----------------------------------------------------------------
Expand Down
26 changes: 25 additions & 1 deletion columnphysics/icepack_warnings.F90
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ module icepack_warnings
icepack_warnings_flush, &
icepack_warnings_aborted, &
icepack_warnings_add, &
icepack_warnings_setabort
icepack_warnings_setabort, &
icepack_warnings_argchk

private :: &
icepack_warnings_getall, &
Expand Down Expand Up @@ -219,6 +220,29 @@ function icepack_warnings_getone(iWarning) result(warning)

end function icepack_warnings_getone

!=======================================================================

subroutine icepack_warnings_argchk(argflag,arg,sub,errflag)

logical, intent(in) :: argflag
character(len=*), intent(in) :: sub
character(len=*), intent(in) :: arg
logical, intent(inout), optional :: errflag

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

! subroutine to check interface arguments
! expect argflag is passing (present(arg)) and if false, trigger error

if (.not.argflag) then
write(warnstr,*) trim(sub)//" "//trim(arg)//" required in interface"
call icepack_warnings_add(warnstr)
if (present(errflag)) errflag = .true.
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
endif

end subroutine icepack_warnings_argchk

!=======================================================================

end module icepack_warnings
34 changes: 17 additions & 17 deletions configuration/driver/icedrv_InitMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ subroutine icedrv_initialize
call init_calendar ! initialize some calendar stuff
call init_coupler_flux ! initialize fluxes exchanged with coupler
call init_thermo_vertical ! initialize vertical thermodynamics
call icepack_init_itd(ncat, hin_max)
call icepack_init_itd(ncat=ncat, hin_max=hin_max)

call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted(subname)) then
call icedrv_system_abort(file=__FILE__,line=__LINE__)
endif

call icepack_init_itd_hist(ncat, hin_max, c_hi_range) ! output
call icepack_init_itd_hist(ncat=ncat, c_hi_range=c_hi_range, hin_max=hin_max) ! output

call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted(subname)) then
Expand Down Expand Up @@ -178,21 +178,21 @@ subroutine init_restart
!-----------------------------------------------------------------
do i = 1, nx
if (tmask(i)) &
call icepack_aggregate(ncat, &
aicen(i,:), &
trcrn(i,:,:), &
vicen(i,:), &
vsnon(i,:), &
aice (i), &
trcr (i,:), &
vice (i), &
vsno (i), &
aice0(i), &
max_ntrcr, &
trcr_depend, &
trcr_base, &
n_trcr_strata, &
nt_strata)
call icepack_aggregate(ncat=ncat, &
aicen=aicen(i,:), &
vicen=vicen(i,:), &
vsnon=vsnon(i,:), &
trcrn=trcrn(i,:,:), &
aice=aice (i), &
vice=vice (i), &
vsno=vsno (i), &
trcr=trcr (i,:), &
aice0=aice0(i), &
ntrcr=max_ntrcr, &
trcr_depend=trcr_depend, &
trcr_base=trcr_base, &
n_trcr_strata=n_trcr_strata, &
nt_strata=nt_strata)
enddo
call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call icedrv_system_abort(string=subname, &
Expand Down
30 changes: 15 additions & 15 deletions configuration/driver/icedrv_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -973,21 +973,21 @@ subroutine init_state
enddo

if (tmask(i)) &
call icepack_aggregate (ncat, &
aicen(i,:), &
trcrn(i,1:ntrcr,:), &
vicen(i,:), &
vsnon(i,:), &
aice (i), &
trcr (i,1:ntrcr), &
vice (i), &
vsno (i), &
aice0(i), &
ntrcr, &
trcr_depend (1:ntrcr), &
trcr_base (1:ntrcr,:), &
n_trcr_strata(1:ntrcr), &
nt_strata (1:ntrcr,:))
call icepack_aggregate (ncat=ncat, &
trcrn=trcrn(i,1:ntrcr,:), &
aicen=aicen(i,:), &
vicen=vicen(i,:), &
vsnon=vsnon(i,:), &
trcr=trcr (i,1:ntrcr), &
aice=aice (i), &
vice=vice (i), &
vsno=vsno (i), &
aice0=aice0(i), &
ntrcr=ntrcr, &
trcr_depend=trcr_depend(1:ntrcr), &
trcr_base=trcr_base (1:ntrcr,:), &
n_trcr_strata=n_trcr_strata(1:ntrcr), &
nt_strata=nt_strata (1:ntrcr,:))

aice_init(i) = aice(i)

Expand Down
30 changes: 15 additions & 15 deletions configuration/driver/icedrv_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -277,21 +277,21 @@ subroutine restartfile (ice_ic)

do i = 1, nx
if (tmask(i)) &
call icepack_aggregate (ncat, &
aicen(i,:), &
trcrn(i,:,:),&
vicen(i,:), &
vsnon(i,:), &
aice (i), &
trcr (i,:), &
vice (i), &
vsno (i), &
aice0(i), &
max_ntrcr, &
trcr_depend, &
trcr_base, &
n_trcr_strata, &
nt_strata)
call icepack_aggregate (ncat=ncat, &
aicen=aicen(i,:), &
trcrn=trcrn(i,:,:), &
vicen=vicen(i,:), &
vsnon=vsnon(i,:), &
aice=aice (i), &
trcr=trcr (i,:), &
vice=vice (i), &
vsno=vsno (i), &
aice0=aice0(i), &
ntrcr=max_ntrcr, &
trcr_depend=trcr_depend, &
trcr_base=trcr_base, &
n_trcr_strata=n_trcr_strata, &
nt_strata=nt_strata)

aice_init(i) = aice(i)
enddo
Expand Down
Loading