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

Refactor icepack interfaces #285

Merged
merged 10 commits into from
Dec 8, 2019
6 changes: 3 additions & 3 deletions columnphysics/icepack_brine.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ end subroutine icepack_init_hbrine
! Initialize zSalinity

subroutine icepack_init_zsalinity(nblyr,ntrcr_o, Rayleigh_criteria, &
Rayleigh_real, trcrn, nt_bgc_S, ncat, sss)
Rayleigh_real, trcrn_bgc, nt_bgc_S, ncat, sss)

integer (kind=int_kind), intent(in) :: &
nblyr, & ! number of biolayers
Expand All @@ -1028,7 +1028,7 @@ subroutine icepack_init_zsalinity(nblyr,ntrcr_o, Rayleigh_criteria, &
sss

real (kind=dbl_kind), dimension(:,:), intent(inout):: &
trcrn ! bgc subset of trcrn
trcrn_bgc ! bgc subset of trcrn

!autodocument_end

Expand All @@ -1049,7 +1049,7 @@ subroutine icepack_init_zsalinity(nblyr,ntrcr_o, Rayleigh_criteria, &
Rayleigh_real = c0
do n = 1,ncat
do k = 1,nblyr
trcrn(nt_bgc_S+k-1-ntrcr_o,n) = sss*salt_loss
trcrn_bgc(nt_bgc_S+k-1-ntrcr_o,n) = sss*salt_loss
enddo ! k
enddo ! n

Expand Down
4 changes: 2 additions & 2 deletions columnphysics/icepack_intfc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ module icepack_intfc
use icepack_zbgc , only: icepack_init_bgc
use icepack_zbgc , only: icepack_init_zbgc
use icepack_zbgc , only: icepack_biogeochemistry
use icepack_zbgc , only: icepack_init_OceanConcArray
use icepack_zbgc , only: icepack_init_ocean_conc
use icepack_zbgc , only: icepack_init_ocean_bio
use icepack_zbgc , only: icepack_load_ocean_bio_array

use icepack_atmo , only: icepack_atm_boundary
use icepack_ocean, only: icepack_ocn_mixed_layer
Expand Down
239 changes: 92 additions & 147 deletions columnphysics/icepack_shortwave.F90

Large diffs are not rendered by default.

226 changes: 124 additions & 102 deletions columnphysics/icepack_tracers.F90

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions columnphysics/icepack_zbgc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ module icepack_zbgc
icepack_init_bgc, &
icepack_init_zbgc, &
icepack_biogeochemistry, &
icepack_init_OceanConcArray, &
icepack_init_ocean_conc
icepack_load_ocean_bio_array, &
icepack_init_ocean_bio

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

Expand Down Expand Up @@ -1159,10 +1159,10 @@ subroutine icepack_biogeochemistry(dt, &
end subroutine icepack_biogeochemistry

!=======================================================================
!autodocument_start icepack_init_OceanConcArray
!autodocument_start icepack_load_ocean_bio_array
! basic initialization for ocean_bio_all

subroutine icepack_init_OceanConcArray(max_nbtrcr, &
subroutine icepack_load_ocean_bio_array(max_nbtrcr, &
max_algae, max_don, max_doc, max_dic, max_aero, max_fe, &
nit, amm, sil, dmsp, dms, algalN, &
doc, don, dic, fed, fep, zaeros, ocean_bio_all, hum)
Expand Down Expand Up @@ -1212,7 +1212,7 @@ subroutine icepack_init_OceanConcArray(max_nbtrcr, &
integer (kind=int_kind) :: &
k, ks ! tracer indices

character(len=*),parameter :: subname='(icepack_init_OceanConcArray)'
character(len=*),parameter :: subname='(icepack_load_ocean_bio_array)'

ocean_bio_all(:) = c0

Expand Down Expand Up @@ -1268,13 +1268,13 @@ subroutine icepack_init_OceanConcArray(max_nbtrcr, &
ks = ks + max_aero + 1
ocean_bio_all(ks) = hum ! humics

end subroutine icepack_init_OceanConcArray
end subroutine icepack_load_ocean_bio_array

!=======================================================================
!autodocument_start icepack_init_ocean_conc
!autodocument_start icepack_init_ocean_bio
! Initialize ocean concentration

subroutine icepack_init_ocean_conc (amm, dmsp, dms, algalN, doc, dic, don, &
subroutine icepack_init_ocean_bio (amm, dmsp, dms, algalN, doc, dic, don, &
fed, fep, hum, nit, sil, zaeros, max_dic, max_don, max_fe, max_aero,&
CToN, CToN_DON)

Expand Down Expand Up @@ -1312,7 +1312,7 @@ subroutine icepack_init_ocean_conc (amm, dmsp, dms, algalN, doc, dic, don, &
integer (kind=int_kind) :: &
k

character(len=*),parameter :: subname='(icepack_init_ocean_conc)'
character(len=*),parameter :: subname='(icepack_init_ocean_bio)'

if (present(CToN)) then
CToN(1) = R_C2N(1)
Expand Down Expand Up @@ -1358,7 +1358,7 @@ subroutine icepack_init_ocean_conc (amm, dmsp, dms, algalN, doc, dic, don, &
enddo


end subroutine icepack_init_ocean_conc
end subroutine icepack_init_ocean_bio

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

Expand Down
11 changes: 11 additions & 0 deletions configuration/driver/icedrv_InitMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ module icedrv_InitMod
use icedrv_constants, only: nu_diag
use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted
use icepack_intfc, only: icepack_query_parameters, icepack_query_tracer_flags
use icepack_intfc, only: icepack_write_tracer_flags, icepack_write_tracer_indices
use icepack_intfc, only: icepack_write_tracer_numbers
use icedrv_system, only: icedrv_system_abort

implicit none
Expand Down Expand Up @@ -59,6 +61,15 @@ subroutine icedrv_initialize

call input_data ! namelist variables
call init_zbgc ! vertical biogeochemistry namelist

! generate some output
call icepack_write_tracer_flags(nu_diag)
call icepack_write_tracer_numbers(nu_diag)
call icepack_write_tracer_indices(nu_diag)
call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call icedrv_system_abort(string=subname, &
file=__FILE__,line= __LINE__)

call init_grid2 ! grid variables
call init_calendar ! initialize some calendar stuff
call init_coupler_flux ! initialize fluxes exchanged with coupler
Expand Down
13 changes: 7 additions & 6 deletions configuration/driver/icedrv_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module icedrv_init
subroutine input_data

use icedrv_diagnostics, only: diag_file, nx_names
use icedrv_domain_size, only: nilyr, nslyr, max_ntrcr, ncat, n_aero
use icedrv_domain_size, only: nilyr, nslyr, nblyr, max_ntrcr, ncat, n_aero
use icedrv_calendar, only: year_init, istep0
use icedrv_calendar, only: dumpfreq, diagfreq, dump_last
use icedrv_calendar, only: npt, dt, ndtd, days_per_year, use_leap_years
Expand Down Expand Up @@ -650,11 +650,12 @@ subroutine input_data
write(nu_diag,1020) 'nt_qice = ', nt_qice
write(nu_diag,1020) 'nt_qsno = ', nt_qsno
write(nu_diag,*)' '
write(nu_diag,1020) 'ncat', ncat
write(nu_diag,1020) 'nilyr', nilyr
write(nu_diag,1020) 'nslyr', nslyr
write(nu_diag,1020) 'ncat = ', ncat
write(nu_diag,1020) 'nilyr = ', nilyr
write(nu_diag,1020) 'nslyr = ', nslyr
write(nu_diag,1020) 'nblyr = ', nblyr
write(nu_diag,*)' '
write(nu_diag,1020) 'nx', nx
write(nu_diag,1020) 'nx = ', nx
write(nu_diag,*)' '

1000 format (a30,2x,f9.2) ! a30 to align formatted, unformatted statements
Expand Down Expand Up @@ -790,7 +791,7 @@ end subroutine init_grid2
subroutine init_state

use icepack_intfc, only: icepack_aggregate
use icedrv_domain_size, only: ncat, nilyr, nslyr, max_ntrcr, n_aero
use icedrv_domain_size, only: ncat, nilyr, nslyr, nblyr, max_ntrcr, n_aero
use icedrv_flux, only: sst, Tf, Tair, salinz, Tmltz
use icedrv_state, only: trcr_depend, aicen, trcrn, vicen, vsnon
use icedrv_state, only: aice0, aice, vice, vsno, trcr, aice_init
Expand Down
47 changes: 22 additions & 25 deletions configuration/driver/icedrv_init_column.F90
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module icedrv_init_column
use icepack_intfc, only: icepack_init_thermo
use icepack_intfc, only: icepack_step_radiation, icepack_init_orbit
use icepack_intfc, only: icepack_init_bgc, icepack_init_zsalinity
use icepack_intfc, only: icepack_init_ocean_conc, icepack_init_OceanConcArray
use icepack_intfc, only: icepack_init_ocean_bio, icepack_load_ocean_bio_array
use icepack_intfc, only: icepack_init_hbrine
use icedrv_system, only: icedrv_system_abort

Expand Down Expand Up @@ -113,11 +113,11 @@ subroutine init_shortwave
use icedrv_state, only: aicen, vicen, vsnon, trcrn

integer (kind=int_kind) :: &
i, k , & ! horizontal indices
n ! thickness category index
i, k , & ! horizontal indices
n ! thickness category index

real (kind=dbl_kind) :: &
netsw ! flag for shortwave radiation presence
netsw ! flag for shortwave radiation presence

logical (kind=log_kind) :: &
l_print_point, & ! flag to print designated grid point diagnostics
Expand All @@ -128,18 +128,17 @@ subroutine init_shortwave
shortwave ! from icepack

real (kind=dbl_kind), dimension(ncat) :: &
fbri ! brine height to ice thickness
fbri ! brine height to ice thickness

real (kind=dbl_kind), dimension(max_ntrcr, ncat) :: &
ztrcr

real (kind=dbl_kind), dimension(max_ntrcr, ncat) :: &
real (kind=dbl_kind), allocatable, dimension(:,:) :: &
ztrcr_sw

logical (kind=log_kind) :: tr_brine, tr_zaero, tr_bgc_n
logical (kind=log_kind) :: tr_brine, tr_zaero, tr_bgc_N
integer (kind=int_kind) :: nt_alvl, nt_apnd, nt_hpnd, nt_ipnd, nt_aero, &
nt_fbri, nt_tsfc, ntrcr, nbtrcr_sw, nlt_chl_sw
integer (kind=int_kind), dimension(icepack_max_aero) :: nlt_zaero_sw
integer (kind=int_kind), dimension(icepack_max_aero) :: nt_zaero
integer (kind=int_kind), dimension(icepack_max_algae) :: nt_bgc_N
real (kind=dbl_kind) :: puny

character(len=*), parameter :: subname='(init_shortwave)'
Expand All @@ -155,11 +154,12 @@ subroutine init_shortwave
call icepack_query_tracer_numbers(ntrcr_out=ntrcr, &
nbtrcr_sw_out=nbtrcr_sw)
call icepack_query_tracer_flags(tr_brine_out=tr_brine, &
tr_zaero_out=tr_zaero, tr_bgc_n_out=tr_bgc_n)
tr_zaero_out=tr_zaero, tr_bgc_N_out=tr_bgc_N)
call icepack_query_tracer_indices(nt_alvl_out=nt_alvl, &
nt_apnd_out=nt_apnd, nt_hpnd_out=nt_hpnd, &
nt_ipnd_out=nt_ipnd, nt_aero_out=nt_aero, &
nt_fbri_out=nt_fbri, nt_tsfc_out=nt_tsfc, &
nt_bgc_N_out=nt_bgc_N, nt_zaero_out=nt_zaero, &
nlt_chl_sw_out=nlt_chl_sw, nlt_zaero_sw_out=nlt_zaero_sw)
call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call icedrv_system_abort(string=subname, &
Expand All @@ -169,6 +169,8 @@ subroutine init_shortwave
! Initialize
!-----------------------------------------------------------------

allocate(ztrcr_sw(nbtrcr_sw, ncat))

fswpenln(:,:,:) = c0
Iswabsn(:,:,:) = c0
Sswabsn(:,:,:) = c0
Expand Down Expand Up @@ -221,23 +223,15 @@ subroutine init_shortwave
fbri(:) = c0
ztrcr_sw(:,:) = c0
do n = 1, ncat
do k = 1, ntrcr
ztrcr(k,n) = trcrn(i,k,n)
enddo
if (tr_brine) fbri(n) = trcrn(i,nt_fbri,n)
enddo

if (tmask(i)) then
call icepack_step_radiation ( &
dt=dt, ncat=ncat, &
n_algae=n_algae, nblyr=nblyr, &
ntrcr=ntrcr, nbtrcr_sw=nbtrcr_sw, &
nblyr=nblyr, &
nilyr=nilyr, nslyr=nslyr, &
n_aero=n_aero, n_zaero=n_zaero, &
tr_zaero=tr_zaero, &
dEdd_algae=dEdd_algae, &
nlt_chl_sw=nlt_chl_sw, &
nlt_zaero_sw=nlt_zaero_sw(:), &
swgrid=swgrid(:), &
igrid=igrid(:), &
fbri=fbri(:), &
Expand All @@ -250,8 +244,9 @@ subroutine init_shortwave
hpndn=trcrn(i,nt_hpnd,:), &
ipndn=trcrn(i,nt_ipnd,:), &
aeron=trcrn(i,nt_aero:nt_aero+4*n_aero-1,:), &
zbion=ztrcr_sw, &
trcrn=ztrcr, &
bgcNn=trcrn(i,nt_bgc_N(1):nt_bgc_N(1)+n_algae*(nblyr+3)-1,:), &
zaeron=trcrn(i,nt_zaero(1):nt_zaero(1)+n_zaero*(nblyr+3)-1,:), &
trcrn_bgcsw=ztrcr_sw, &
TLAT=TLAT(i), TLON=TLON(i), &
calendar_type=calendar_type, &
days_per_year=days_per_year, &
Expand Down Expand Up @@ -341,6 +336,8 @@ subroutine init_shortwave

enddo ! i

deallocate(ztrcr_sw)

end subroutine init_shortwave

!=======================================================================
Expand Down Expand Up @@ -428,7 +425,7 @@ subroutine init_bgc()
ntrcr_o = ntrcr_o, &
Rayleigh_criteria = RayleighC, &
Rayleigh_real = RayleighR, &
trcrn = trcrn_bgc, &
trcrn_bgc = trcrn_bgc, &
nt_bgc_S = nt_bgc_S, &
sss = sss(i))
Rayleigh_real (i) = RayleighR
Expand All @@ -452,7 +449,7 @@ subroutine init_bgc()
! Initial Ocean Values if not coupled to the ocean bgc
!-----------------------------------------------------------------
do i = 1, nx
call icepack_init_ocean_conc ( &
call icepack_init_ocean_bio ( &
amm=amm(i), dmsp=dmsp(i), dms=dms(i), &
doc=doc(i,:), dic =dic(i,:), don=don(i,:), &
fed=fed(i,:), fep =fep(i,:), hum=hum(i), &
Expand All @@ -479,7 +476,7 @@ subroutine init_bgc()
enddo
enddo

call icepack_init_OceanConcArray(max_nbtrcr=max_nbtrcr, &
call icepack_load_ocean_bio_array(max_nbtrcr=max_nbtrcr, &
max_algae=max_algae, max_don=max_don, max_doc=max_doc, &
max_aero =max_aero, max_dic=max_dic, max_fe =max_fe, &
nit =nit(i), amm=amm(i), sil =sil(i), &
Expand Down
Loading