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

Dynamic mapping of pore water tracers to ocean tracers #192

Merged
merged 4 commits into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
29 changes: 9 additions & 20 deletions hamocc/dipowa.F90
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ subroutine dipowa(kpie,kpje,kpke,omask,lspin)

use mo_carbch, only: ocetra, sedfluxo
use mo_sedmnt, only: powtra,porwat,porwah,sedict,seddw,seddzi
use mo_param1_bgc, only: ks,npowtra
use mo_param1_bgc, only: ks,npowtra,map_por2octra
use mo_vgrid, only: kbo,bolay
#ifdef cisonew
use mo_param1_bgc, only: ipowc13,ipowc14,isco213,isco214
Expand Down Expand Up @@ -112,11 +112,7 @@ subroutine dipowa(kpie,kpje,kpke,omask,lspin)

k = 0
do iv = 1,npowtra ! loop over pore water tracers
iv_oc = iv
#ifdef cisonew
if (iv == ipowc13) iv_oc = isco213
if (iv == ipowc14) iv_oc = isco214
#endif
iv_oc = map_por2octra(iv)
do i = 1,kpie
sedb1(i,k,iv) = 0.
if (omask(i,j) > 0.5) then
Expand Down Expand Up @@ -190,16 +186,8 @@ subroutine dipowa(kpie,kpje,kpke,omask,lspin)

if(.not. lspin) THEN
! sediment ocean interface
!
! CAUTION - the following assumes same indecees for ocetra and powtra
! test npowa_base 071106
! check mo_param1_bgc.f90 for consistency
do iv = 1, npowtra
iv_oc = iv
#ifdef cisonew
if (iv == ipowc13) iv_oc=isco213
if (iv == ipowc14) iv_oc=isco214
#endif
iv_oc = map_por2octra(iv)
do i = 1,kpie
l = 0
if (omask(i,j) > 0.5) then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the correspondence between pore water and ocean tracers is not guaranteed, iv needs to be replaced by iv_oc in all ocetra occurances below. Also inside the #ifdef natDIC block

Copy link
Collaborator Author

@jmaerz jmaerz Sep 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #191 (comment) - since it seems as it doesn't affect CMIP backwards compatibility at all, I would then suggest to do it in one goal and exchange the indices. The code as is was tested against the former master, but maybe it's then worth to test it also against master cisonew switched on.

Expand All @@ -210,14 +198,15 @@ subroutine dipowa(kpie,kpje,kpke,omask,lspin)

! diffusive fluxes (positive downward)
sedfluxo(i,j,iv) = sedfluxo(i,j,iv) &
& -(ocetra(i,j,kbo(i,j),iv) - aprior)* bolay(i,j)
& -(ocetra(i,j,kbo(i,j),iv_oc) - aprior)* bolay(i,j)
#ifdef natDIC
if (iv==isco212) ocetra(i,j,kbo(i,j),inatsco212) = &
! workaround as long as natDIC is not implemented throughout the sediment module
if (iv_oc==isco212) ocetra(i,j,kbo(i,j),inatsco212) = &
& ocetra(i,j,kbo(i,j),inatsco212) + &
& ocetra(i,j,kbo(i,j),iv) - aprior
if (iv==ialkali) ocetra(i,j,kbo(i,j),inatalkali) = &
& ocetra(i,j,kbo(i,j),isco212) - aprior
if (iv_oc==ialkali) ocetra(i,j,kbo(i,j),inatalkali) = &
& ocetra(i,j,kbo(i,j),inatalkali) + &
& ocetra(i,j,kbo(i,j),iv) - aprior
& ocetra(i,j,kbo(i,j),ialkali) - aprior
#endif
endif
enddo
Expand Down
5 changes: 4 additions & 1 deletion hamocc/hamocc_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ subroutine hamocc_init(read_rest,rstfnm_hamocc)
& sedspin_yr_s,sedspin_yr_e,sedspin_ncyc, &
& dtb,dtbgc,io_stdo_bgc,ldtbgc, &
& ldtrunbgc,ndtdaybgc,with_dmsph
use mo_param1_bgc, only: ks,nsedtra,npowtra
use mo_param1_bgc, only: ks,nsedtra,npowtra,init_por2octra_mapping
use mo_carbch, only: alloc_mem_carbch,ocetra,atm,atm_co2
use mo_biomod, only: alloc_mem_biomod
use mo_sedmnt, only: alloc_mem_sedmnt,sedlay,powtra,burial
Expand Down Expand Up @@ -130,6 +130,9 @@ subroutine hamocc_init(read_rest,rstfnm_hamocc)
endif

ENDIF
! init the index-mapping between pore water and ocean tracers
CALL init_por2octra_mapping()

!
! --- Memory allocation
!
Expand Down
89 changes: 53 additions & 36 deletions hamocc/mo_param1_bgc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -201,53 +201,70 @@ MODULE mo_param1_bgc
& irdoc =6, & ! dissolved organic carbon
& irdet =7 ! particulate carbon


! sediment
#ifdef cisonew
INTEGER, PARAMETER :: nsedtra=8
! --- sediment
! sediment solid components
INTEGER, PARAMETER :: i_sed_base = 4
INTEGER, PARAMETER :: issso12=1, &
& isssc12=2, &
& issssil=3, &
& issster=4, &
& issso13=5, &
& issso14=6, &
& isssc13=7, &
& isssc14=8

! pore water tracers, index should be the same as for ocetra
INTEGER, PARAMETER :: npowtra=9
INTEGER, PARAMETER :: ipowaic=1, &
& ipowaal=2, &
& ipowaph=3, &
& ipowaox=4, &
& ipown2 =5, &
& ipowno3=6, &
& ipowasi=7, &
& ipowc13=8, & ! C-isotope idices do NOT correspond to ocetra!
& ipowc14=9 ! C-isotope idices do NOT correspond to ocetra!
& issster=4
#ifdef cisonew
INTEGER, PARAMETER :: i_sed_cisonew = 4
INTEGER, PARAMETER :: issso13 = i_sed_base+1, &
& issso14 = i_sed_base+2, &
& isssc13 = i_sed_base+3, &
& isssc14 = i_sed_base+4
#else
INTEGER, PARAMETER :: nsedtra=4
INTEGER, PARAMETER :: issso12=1, &
& isssc12=2, &
& issssil=3, &
& issster=4, &
& issso13=-1, &
& issso14=-1, &
& isssc13=-1, &
& isssc14=-1

! pore water tracers, index should be the same as for ocetra
INTEGER, PARAMETER :: npowtra=7
INTEGER, PARAMETER :: i_sed_cisonew = 0
INTEGER, PARAMETER :: issso13 = -1, &
& issso14 = -1, &
& isssc13 = -1, &
& isssc14 = -1
#endif
INTEGER, PARAMETER :: nsedtra = i_sed_base + i_sed_cisonew


! sediment pore water components
INTEGER, PARAMETER :: i_pow_base=7
INTEGER, PARAMETER :: ipowaic=1, &
& ipowaal=2, &
& ipowaph=3, &
& ipowaox=4, &
& ipown2 =5, &
& ipowno3=6, &
& ipowasi=7, &
& ipowc13=-1, &
& ipowc14=-1
& ipowasi=7
#ifdef cisonew
INTEGER, PARAMETER :: i_pow_cisonew = 2
INTEGER, PARAMETER :: ipowc13=i_pow_base + 1, &
& ipowc14=i_pow_base + 2
#else
INTEGER, PARAMETER :: i_pow_cisonew = 0
INTEGER, PARAMETER :: ipowc13 = -1, &
& ipowc14 = -1
#endif
INTEGER, PARAMETER :: npowtra = i_pow_base + i_pow_cisonew

! Mapping between pore water and ocean tracers needed for pore water diffusion
INTEGER, SAVE :: map_por2octra(npowtra)

contains

subroutine init_por2octra_mapping()

map_por2octra(ipowaic) = isco212
map_por2octra(ipowaal) = ialkali
map_por2octra(ipowaph) = iphosph
map_por2octra(ipowaox) = ioxygen
map_por2octra(ipown2) = igasnit
map_por2octra(ipowno3) = iano3
map_por2octra(ipowasi) = isilica

! if statements for non-base tracers
if(ipowc13 > 0) map_por2octra(ipowc13) = isco213
if(ipowc14 > 0) map_por2octra(ipowc14) = isco214

end subroutine init_por2octra_mapping

!******************************************************************************
END MODULE mo_param1_bgc