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

Njeffery debug zbgc3 d #207

Merged
merged 17 commits into from
Oct 26, 2018
Merged
Show file tree
Hide file tree
Changes from 11 commits
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
259 changes: 166 additions & 93 deletions cicecore/cicedynB/general/ice_forcing_bgc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ end subroutine alloc_forcing_bgc

subroutine get_forcing_bgc

use ice_blocks, only: block, get_block
use ice_domain, only: nblocks, blocks_ice
use ice_arrays_column, only: ocean_bio_all
use ice_calendar, only: yday
use ice_domain, only: nblocks
use ice_flux, only: sss
use ice_flux_bgc, only: sil, nit
use ice_forcing, only: trestore, trest, fyear, &
Expand All @@ -84,6 +85,7 @@ subroutine get_forcing_bgc

integer (kind=int_kind) :: &
i, j, iblk, & ! horizontal indices
ilo,ihi,jlo,jhi, & ! beginning and end of physical domain
ixm,ixp, ixx, & ! record numbers for neighboring months
maxrec , & ! maximum record number
recslot , & ! spline slot for current record
Expand Down Expand Up @@ -111,6 +113,9 @@ subroutine get_forcing_bgc
nit_file , & ! nitrate input file
sil_file ! silicate input file

type (block) :: &
this_block ! block information for current block

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

call icepack_query_parameters(secday_out=secday)
Expand All @@ -125,11 +130,14 @@ subroutine get_forcing_bgc
if (trim(nit_data_type) == 'clim'.or. &
trim(sil_data_type) == 'clim') then

nit_file = trim(bgc_data_dir)//'nitrate_climatologyWOA_gx1v6f.nc'
nit_file = 'nitrate_climatologyWOA_gx1v6f_20150107.nc'
!'nitrate_WOA2005_surface_monthly' ! gx1 only
sil_file = trim(bgc_data_dir)//'silicate_climatologyWOA_gx1v6f.nc'
sil_file = 'silicate_climatologyWOA_gx1v6f_20150107.nc'
!'silicate_WOA2005_surface_monthly' ! gx1 only

nit_file = trim(bgc_data_dir)//'/'//trim(nit_file)
sil_file = trim(bgc_data_dir)//'/'//trim(sil_file)

if (my_task == master_task .and. istep == 1) then
if (trim(sil_data_type)=='clim' .AND. tr_bgc_Sil) then
write (nu_diag,*) ' '
Expand Down Expand Up @@ -194,43 +202,70 @@ subroutine get_forcing_bgc
call interpolate_data (sil_data, sildat)

if (istep == 1 .or. .NOT. restore_bgc) then
!$OMP PARALLEL DO PRIVATE(iblk,i,j)
do iblk = 1, nblocks
do j = 1, ny_block
do i = 1, nx_block
sil(i,j,iblk) = sildat(i,j,iblk)
ks = 2*icepack_max_algae + icepack_max_doc + 3 + icepack_max_dic
ocean_bio_all(i,j,ks,iblk) = sil(i,j,iblk) !Sil
enddo
enddo

!$OMP PARALLEL DO PRIVATE(iblk,ilo,ihi,jlo,jhi,this_block)
do iblk = 1, nblocks

this_block = get_block(blocks_ice(iblk),iblk)
ilo = this_block%ilo
ihi = this_block%ihi
jlo = this_block%jlo
jhi = this_block%jhi

do j = jlo, jhi
do i = ilo, ihi

sil(i,j,iblk) = sildat(i,j,iblk)
ks = 2*icepack_max_algae + icepack_max_doc + 3 + icepack_max_dic
ocean_bio_all(i,j,ks,iblk) = sil(i,j,iblk) !Sil
enddo
enddo
enddo

!$OMP END PARALLEL DO
elseif (restore_bgc) then
!$OMP PARALLEL DO PRIVATE(iblk,i,j)
do iblk = 1, nblocks
do j = 1, ny_block
do i = 1, nx_block
sil(i,j,iblk) = sil(i,j,iblk) &

!$OMP PARALLEL DO PRIVATE(iblk,ilo,ihi,jlo,jhi,this_block)
do iblk = 1, nblocks

this_block = get_block(blocks_ice(iblk),iblk)
ilo = this_block%ilo
ihi = this_block%ihi
jlo = this_block%jlo
jhi = this_block%jhi

do j = jlo, jhi
do i = ilo, ihi

sil(i,j,iblk) = sil(i,j,iblk) &
+ (sildat(i,j,iblk)-sil(i,j,iblk))*dt/trest
ks = 2*icepack_max_algae + icepack_max_doc + 3 + icepack_max_dic
ocean_bio_all(i,j,ks,iblk) = sil(i,j,iblk) !Sil
enddo
ks = 2*icepack_max_algae + icepack_max_doc + 3 + icepack_max_dic
ocean_bio_all(i,j,ks,iblk) = sil(i,j,iblk) !Sil
enddo
enddo
enddo
enddo
!$OMP END PARALLEL DO
!$OMP END PARALLEL DO
endif !restore
elseif (tr_bgc_Sil) then
!$OMP PARALLEL DO PRIVATE(iblk,i,j)
do iblk = 1, nblocks
do j = 1, ny_block
do i = 1, nx_block
sil(i,j,iblk) = 25.0_dbl_kind
ks = 2*icepack_max_algae + icepack_max_doc + 3 + icepack_max_dic
ocean_bio_all(i,j,ks,iblk) = sil(i,j,iblk) !Sil
enddo
!$OMP PARALLEL DO PRIVATE(iblk,ilo,ihi,jlo,jhi,this_block)
do iblk = 1, nblocks

this_block = get_block(blocks_ice(iblk),iblk)
ilo = this_block%ilo
ihi = this_block%ihi
jlo = this_block%jlo
jhi = this_block%jhi

do j = jlo, jhi
do i = ilo, ihi

sil(i,j,iblk) = 25.0_dbl_kind
ks = 2*icepack_max_algae + icepack_max_doc + 3 + icepack_max_dic
ocean_bio_all(i,j,ks,iblk) = sil(i,j,iblk) !Sil
enddo
enddo
enddo
enddo
!$OMP END PARALLEL DO
!$OMP END PARALLEL DO

endif !tr_bgc_Sil
!-------------------------------------------------------------------
Expand All @@ -249,67 +284,97 @@ subroutine get_forcing_bgc
call interpolate_data (nit_data, nitdat)

if (istep == 1 .or. .NOT. restore_bgc) then
!$OMP PARALLEL DO PRIVATE(iblk,i,j)
do iblk = 1, nblocks
do j = 1, ny_block
do i = 1, nx_block
nit(i,j,iblk) = nitdat(i,j,iblk)
ks = icepack_max_algae + 1
ocean_bio_all(i,j,ks,iblk) = nit(i,j,iblk) !nit
ks = 2*icepack_max_algae + icepack_max_doc + 7 + icepack_max_dic
ocean_bio_all(i,j,ks,iblk) = nit(i,j,iblk) !PON
!$OMP PARALLEL DO PRIVATE(iblk,ilo,ihi,jlo,jhi,this_block)
do iblk = 1, nblocks

this_block = get_block(blocks_ice(iblk),iblk)
ilo = this_block%ilo
ihi = this_block%ihi
jlo = this_block%jlo
jhi = this_block%jhi

do j = jlo, jhi
do i = ilo, ihi

nit(i,j,iblk) = nitdat(i,j,iblk)
ks = icepack_max_algae + 1
ocean_bio_all(i,j,ks,iblk) = nit(i,j,iblk) !nit
ks = 2*icepack_max_algae + icepack_max_doc + 7 + icepack_max_dic
ocean_bio_all(i,j,ks,iblk) = nit(i,j,iblk) !PON
enddo
enddo
enddo
enddo
enddo
!$OMP END PARALLEL DO
!$OMP END PARALLEL DO
elseif (restore_bgc ) then
!$OMP PARALLEL DO PRIVATE(iblk,i,j)
do iblk = 1, nblocks
do j = 1, ny_block
do i = 1, nx_block
nit(i,j,iblk) = nit(i,j,iblk) &
!$OMP PARALLEL DO PRIVATE(iblk,ilo,ihi,jlo,jhi,this_block)
do iblk = 1, nblocks

this_block = get_block(blocks_ice(iblk),iblk)
ilo = this_block%ilo
ihi = this_block%ihi
jlo = this_block%jlo
jhi = this_block%jhi

do j = jlo, jhi
do i = ilo, ihi

nit(i,j,iblk) = nit(i,j,iblk) &
+ (nitdat(i,j,iblk)-nit(i,j,iblk))*dt/trest
ks = icepack_max_algae + 1
ocean_bio_all(i,j,ks,iblk) = nit(i,j,iblk) !nit
ks = 2*icepack_max_algae + icepack_max_doc + 7 + icepack_max_dic
ocean_bio_all(i,j,ks,iblk) = nit(i,j,iblk) !PON
ks = icepack_max_algae + 1
ocean_bio_all(i,j,ks,iblk) = nit(i,j,iblk) !nit
ks = 2*icepack_max_algae + icepack_max_doc + 7 + icepack_max_dic
ocean_bio_all(i,j,ks,iblk) = nit(i,j,iblk) !PON
enddo
enddo
enddo
enddo
enddo
!$OMP END PARALLEL DO
!$OMP END PARALLEL DO
endif !restore_bgc

elseif (trim(nit_data_type) == 'sss' .AND. tr_bgc_Nit) then

!$OMP PARALLEL DO PRIVATE(iblk,i,j)
do iblk = 1, nblocks
do j = 1, ny_block
do i = 1, nx_block
nit(i,j,iblk) = sss(i,j,iblk)
ks = icepack_max_algae + 1
ocean_bio_all(i,j,ks,iblk) = nit(i,j,iblk) !nit
ks = 2*icepack_max_algae + icepack_max_doc + 7 + icepack_max_dic
ocean_bio_all(i,j,ks,iblk) = nit(i,j,iblk) !PON
!$OMP PARALLEL DO PRIVATE(iblk,ilo,ihi,jlo,jhi,this_block)
do iblk = 1, nblocks

this_block = get_block(blocks_ice(iblk),iblk)
ilo = this_block%ilo
ihi = this_block%ihi
jlo = this_block%jlo
jhi = this_block%jhi

do j = jlo, jhi
do i = ilo, ihi

nit(i,j,iblk) = sss(i,j,iblk)
ks = icepack_max_algae + 1
ocean_bio_all(i,j,ks,iblk) = nit(i,j,iblk) !nit
ks = 2*icepack_max_algae + icepack_max_doc + 7 + icepack_max_dic
ocean_bio_all(i,j,ks,iblk) = nit(i,j,iblk) !PON
enddo
enddo
enddo
enddo
enddo
!$OMP END PARALLEL DO

elseif (tr_bgc_Nit) then
!$OMP PARALLEL DO PRIVATE(iblk,ilo,ihi,jlo,jhi,this_block)
do iblk = 1, nblocks

this_block = get_block(blocks_ice(iblk),iblk)
ilo = this_block%ilo
ihi = this_block%ihi
jlo = this_block%jlo
jhi = this_block%jhi

do j = jlo, jhi
do i = ilo, ihi

!$OMP PARALLEL DO PRIVATE(iblk,i,j)
do iblk = 1, nblocks
do j = 1, ny_block
do i = 1, nx_block
nit(i,j,iblk) = 12.0_dbl_kind
ks = icepack_max_algae + 1
ocean_bio_all(i,j,ks,iblk) = nit(i,j,iblk) !nit
ks = 2*icepack_max_algae + icepack_max_doc + 7 + icepack_max_dic
ocean_bio_all(i,j,ks,iblk) = nit(i,j,iblk) !PON
enddo
nit(i,j,iblk) = 12.0_dbl_kind
ks = icepack_max_algae + 1
ocean_bio_all(i,j,ks,iblk) = nit(i,j,iblk) !nit
ks = 2*icepack_max_algae + icepack_max_doc + 7 + icepack_max_dic
ocean_bio_all(i,j,ks,iblk) = nit(i,j,iblk) !PON
enddo
enddo
enddo
enddo
!$OMP END PARALLEL DO
!$OMP END PARALLEL DO

endif !tr_bgc_Nit

Expand Down Expand Up @@ -381,20 +446,28 @@ subroutine get_forcing_bgc
+ c2intp * nit_data_p(2)
endif

!$OMP PARALLEL DO PRIVATE(iblk,i,j)
do iblk = 1, nblocks
do j = 1, ny_block
do i = 1, nx_block
ks = 2*icepack_max_algae + icepack_max_doc + 3 + icepack_max_dic
ocean_bio_all(i,j,ks,iblk) = sil(i,j,iblk) !Sil
ks = icepack_max_algae + 1
ocean_bio_all(i,j,ks,iblk) = nit(i,j,iblk) !nit
ks = 2*icepack_max_algae + icepack_max_doc + 7 + icepack_max_dic
ocean_bio_all(i,j,ks,iblk) = nit(i,j,iblk) !PON
enddo
!$OMP PARALLEL DO PRIVATE(iblk,ilo,ihi,jlo,jhi,this_block)
do iblk = 1, nblocks

this_block = get_block(blocks_ice(iblk),iblk)
ilo = this_block%ilo
ihi = this_block%ihi
jlo = this_block%jlo
jhi = this_block%jhi

do j = jlo, jhi
do i = ilo, ihi

ks = 2*icepack_max_algae + icepack_max_doc + 3 + icepack_max_dic
ocean_bio_all(i,j,ks,iblk) = sil(i,j,iblk) !Sil
ks = icepack_max_algae + 1
ocean_bio_all(i,j,ks,iblk) = nit(i,j,iblk) !nit
ks = 2*icepack_max_algae + icepack_max_doc + 7 + icepack_max_dic
ocean_bio_all(i,j,ks,iblk) = nit(i,j,iblk) !PON
enddo
enddo
enddo
enddo
!$OMP END PARALLEL DO
!$OMP END PARALLEL DO

! Save record number for next time step
bgcrecnum = recnum
Expand Down
7 changes: 3 additions & 4 deletions cicecore/drivers/cesm/CICE_InitMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ subroutine cice_init(mpicom_ice)

call input_data ! namelist variables
if (trim(runid) == 'bering') call check_finished_file
call init_zbgc ! vertical biogeochemistry namelist

call init_domain_blocks ! set up block decomposition
call init_grid1 ! domain distribution
Expand All @@ -118,6 +117,7 @@ subroutine cice_init(mpicom_ice)
call init_ice_timers ! initialize all timers
call ice_timer_start(timer_total) ! start timing entire run
call init_grid2 ! grid variables
call init_zbgc ! vertical biogeochemistry namelist

call init_calendar ! initialize some calendar stuff
call init_hist (dt) ! initialize output history file
Expand Down Expand Up @@ -149,6 +149,8 @@ subroutine cice_init(mpicom_ice)
call init_state ! initialize the ice state
call init_transport ! initialize horizontal transport
call ice_HaloRestore_init ! restored boundary conditions
call icepack_query_parameters(skl_bgc_out=skl_bgc, z_tracers_out=z_tracers)
if (skl_bgc .or. z_tracers) call alloc_forcing_bgc ! allocate biogeochemistry arrays

call init_restart ! initialize restart variables

Expand All @@ -157,7 +159,6 @@ subroutine cice_init(mpicom_ice)
call init_history_dyn ! initialize dynamic history variables

call icepack_query_tracer_flags(tr_aero_out=tr_aero, tr_zaero_out=tr_zaero)
call icepack_query_parameters(skl_bgc_out=skl_bgc, z_tracers_out=z_tracers)
call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
file=__FILE__, line=__LINE__)
Expand Down Expand Up @@ -186,8 +187,6 @@ subroutine cice_init(mpicom_ice)
! if (tr_aero) call faero_data ! data file
! if (tr_zaero) call fzaero_data ! data file (gx1)
if (tr_aero .or. tr_zaero) call faero_default ! default values

if (skl_bgc .or. z_tracers) call alloc_forcing_bgc ! allocate biogeochemistry arrays
if (skl_bgc .or. z_tracers) call get_forcing_bgc ! biogeochemistry
#endif
#endif
Expand Down
Loading