LCOV - code coverage report
Current view: top level - cicecore/shared - ice_init_column.F90 (source / functions) Hit Total Coverage
Test: 231018-211459:8916b9ff2c:1:quick Lines: 801 1362 58.81 %
Date: 2023-10-18 15:30:36 Functions: 9 17 52.94 %

          Line data    Source code
       1             : !=========================================================================
       2             : !
       3             : ! Initialization routines for the column package.
       4             : !
       5             : ! author: Elizabeth C. Hunke, LANL
       6             : !
       7             :       module ice_init_column
       8             : 
       9             :       use ice_kinds_mod
      10             :       use ice_blocks, only: nx_block, ny_block
      11             :       use ice_constants
      12             :       use ice_communicate, only: my_task, master_task, ice_barrier
      13             :       use ice_domain_size, only: ncat, max_blocks
      14             :       use ice_domain_size, only: nblyr, nilyr, nslyr
      15             :       use ice_domain_size, only: n_aero, n_zaero, n_algae
      16             :       use ice_domain_size, only: n_doc, n_dic, n_don
      17             :       use ice_domain_size, only: n_fed, n_fep
      18             :       use ice_fileunits, only: nu_diag
      19             :       use ice_fileunits, only: nu_nml, nml_filename, get_fileunit, &
      20             :                                release_fileunit, flush_fileunit
      21             :       use ice_exit, only: abort_ice
      22             :       use icepack_intfc, only: icepack_max_don, icepack_max_doc, icepack_max_dic
      23             :       use icepack_intfc, only: icepack_max_algae, icepack_max_aero, icepack_max_fe
      24             :       use icepack_intfc, only: icepack_max_nbtrcr
      25             :       use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted
      26             :       use icepack_intfc, only: icepack_init_tracer_sizes, icepack_init_tracer_flags
      27             :       use icepack_intfc, only: icepack_init_tracer_indices
      28             :       use icepack_intfc, only: icepack_init_parameters
      29             :       use icepack_intfc, only: icepack_query_tracer_sizes, icepack_query_tracer_flags
      30             :       use icepack_intfc, only: icepack_query_tracer_indices, icepack_query_tracer_sizes
      31             :       use icepack_intfc, only: icepack_query_parameters
      32             :       use icepack_intfc, only: icepack_write_tracer_sizes, icepack_write_tracer_flags
      33             :       use icepack_intfc, only: icepack_write_tracer_indices, icepack_write_tracer_sizes
      34             :       use icepack_intfc, only: icepack_init_fsd, icepack_cleanup_fsd
      35             :       use icepack_intfc, only: icepack_init_zbgc
      36             :       use icepack_intfc, only: icepack_init_thermo
      37             :       use icepack_intfc, only: icepack_step_radiation, icepack_init_orbit
      38             :       use icepack_intfc, only: icepack_init_bgc
      39             :       use icepack_intfc, only: icepack_init_ocean_bio, icepack_load_ocean_bio_array
      40             :       use icepack_intfc, only: icepack_init_hbrine
      41             : 
      42             :       implicit none
      43             : 
      44             :       private
      45             :       public :: init_thermo_vertical, init_shortwave, &
      46             :                 init_age, init_FY, init_lvl, init_fsd, &   ! LCOV_EXCL_LINE
      47             :                 init_meltponds_lvl, init_meltponds_topo, &   ! LCOV_EXCL_LINE
      48             :                 init_aerosol, init_bgc, init_hbrine, init_zbgc, input_zbgc, &   ! LCOV_EXCL_LINE
      49             :                 count_tracers, init_isotope, init_snowtracers
      50             : 
      51             :       ! namelist parameters needed locally
      52             : 
      53             :       real (kind=dbl_kind) :: &
      54             :          tau_min            , tau_max            , &   ! LCOV_EXCL_LINE
      55             :          nitratetype        , ammoniumtype       , silicatetype,  &   ! LCOV_EXCL_LINE
      56             :          dmspptype          , dmspdtype          , humtype
      57             : 
      58             :       real (kind=dbl_kind), dimension(icepack_max_dic) :: &
      59             :          dictype
      60             : 
      61             :       real (kind=dbl_kind), dimension(icepack_max_algae) :: &
      62             :          algaltype   ! tau_min for both retention and release
      63             : 
      64             :       real (kind=dbl_kind), dimension(icepack_max_doc) :: &
      65             :          doctype
      66             : 
      67             :       real (kind=dbl_kind), dimension(icepack_max_don) :: &
      68             :          dontype
      69             : 
      70             :       real (kind=dbl_kind), dimension(icepack_max_fe) :: &
      71             :          fedtype
      72             : 
      73             :       real (kind=dbl_kind), dimension(icepack_max_fe) :: &
      74             :          feptype
      75             : 
      76             :       real (kind=dbl_kind), dimension(icepack_max_aero) :: &
      77             :          zaerotype
      78             : 
      79             :       real (kind=dbl_kind) :: &
      80             :           grid_o, l_sk, grid_o_t, initbio_frac, &   ! LCOV_EXCL_LINE
      81             :           frazil_scav, grid_oS, l_skS, &   ! LCOV_EXCL_LINE
      82             :           phi_snow, &   ! LCOV_EXCL_LINE
      83             :           ratio_Si2N_diatoms , ratio_Si2N_sp      , ratio_Si2N_phaeo   ,  &   ! LCOV_EXCL_LINE
      84             :           ratio_S2N_diatoms  , ratio_S2N_sp       , ratio_S2N_phaeo    ,  &   ! LCOV_EXCL_LINE
      85             :           ratio_Fe2C_diatoms , ratio_Fe2C_sp      , ratio_Fe2C_phaeo   ,  &   ! LCOV_EXCL_LINE
      86             :           ratio_Fe2N_diatoms , ratio_Fe2N_sp      , ratio_Fe2N_phaeo   ,  &   ! LCOV_EXCL_LINE
      87             :           ratio_Fe2DON       , ratio_Fe2DOC_s     , ratio_Fe2DOC_l     ,  &   ! LCOV_EXCL_LINE
      88             :           fr_resp            , &   ! LCOV_EXCL_LINE
      89             :           algal_vel          , R_dFe2dust         , dustFe_sol         ,  &   ! LCOV_EXCL_LINE
      90             :           chlabs_diatoms     , chlabs_sp          , chlabs_phaeo       ,  &   ! LCOV_EXCL_LINE
      91             :           alpha2max_low_diatoms,alpha2max_low_sp  , alpha2max_low_phaeo,  &   ! LCOV_EXCL_LINE
      92             :           beta2max_diatoms   , beta2max_sp        , beta2max_phaeo     ,  &   ! LCOV_EXCL_LINE
      93             :           mu_max_diatoms     , mu_max_sp          , mu_max_phaeo       ,  &   ! LCOV_EXCL_LINE
      94             :           grow_Tdep_diatoms  , grow_Tdep_sp       , grow_Tdep_phaeo    ,  &   ! LCOV_EXCL_LINE
      95             :           fr_graze_diatoms   , fr_graze_sp        , fr_graze_phaeo     ,  &   ! LCOV_EXCL_LINE
      96             :           mort_pre_diatoms   , mort_pre_sp        , mort_pre_phaeo     ,  &   ! LCOV_EXCL_LINE
      97             :           mort_Tdep_diatoms  , mort_Tdep_sp       , mort_Tdep_phaeo    ,  &   ! LCOV_EXCL_LINE
      98             :           k_exude_diatoms    , k_exude_sp         , k_exude_phaeo      ,  &   ! LCOV_EXCL_LINE
      99             :           K_Nit_diatoms      , K_Nit_sp           , K_Nit_phaeo        ,  &   ! LCOV_EXCL_LINE
     100             :           K_Am_diatoms       , K_Am_sp            , K_Am_phaeo         ,  &   ! LCOV_EXCL_LINE
     101             :           K_Sil_diatoms      , K_Sil_sp           , K_Sil_phaeo        ,  &   ! LCOV_EXCL_LINE
     102             :           K_Fe_diatoms       , K_Fe_sp            , K_Fe_phaeo         ,  &   ! LCOV_EXCL_LINE
     103             :           f_don_protein      , kn_bac_protein     , f_don_Am_protein   ,  &   ! LCOV_EXCL_LINE
     104             :           f_doc_s            , f_doc_l            , f_exude_s          ,  &   ! LCOV_EXCL_LINE
     105             :           f_exude_l          , k_bac_s            , k_bac_l            ,  &   ! LCOV_EXCL_LINE
     106             :           T_max              , fsal               , op_dep_min         ,  &   ! LCOV_EXCL_LINE
     107             :           fr_graze_s         , fr_graze_e         , fr_mort2min        ,  &   ! LCOV_EXCL_LINE
     108             :           fr_dFe             , k_nitrif           , t_iron_conv        ,  &   ! LCOV_EXCL_LINE
     109             :           max_loss           , max_dfe_doc1       , fr_resp_s          ,  &   ! LCOV_EXCL_LINE
     110             :           y_sk_DMS           , t_sk_conv          , t_sk_ox            ,  &   ! LCOV_EXCL_LINE
     111             :           algaltype_diatoms  , algaltype_sp       , algaltype_phaeo    ,  &   ! LCOV_EXCL_LINE
     112             :           doctype_s          , doctype_l          , dontype_protein    ,  &   ! LCOV_EXCL_LINE
     113             :           fedtype_1          , feptype_1          , zaerotype_bc1      ,  &   ! LCOV_EXCL_LINE
     114             :           zaerotype_bc2      , zaerotype_dust1    , zaerotype_dust2    ,  &   ! LCOV_EXCL_LINE
     115             :           zaerotype_dust3    , zaerotype_dust4    , ratio_C2N_diatoms  ,  &   ! LCOV_EXCL_LINE
     116             :           ratio_C2N_sp       , ratio_C2N_phaeo    , ratio_chl2N_diatoms,  &   ! LCOV_EXCL_LINE
     117             :           ratio_chl2N_sp     , ratio_chl2N_phaeo  , F_abs_chl_diatoms  ,  &   ! LCOV_EXCL_LINE
     118             :           F_abs_chl_sp       , F_abs_chl_phaeo    , ratio_C2N_proteins
     119             : 
     120             : !=======================================================================
     121             : 
     122             :       contains
     123             : 
     124             : !=======================================================================
     125             : !
     126             : ! Initialize the vertical profile of ice salinity and melting temperature.
     127             : !
     128             : ! authors: C. M. Bitz, UW
     129             : !          William H. Lipscomb, LANL
     130             : 
     131          37 :       subroutine init_thermo_vertical
     132             : 
     133             :       use ice_flux, only: salinz, Tmltz
     134             : 
     135             :       integer (kind=int_kind) :: &
     136             :          i, j, iblk, &  ! horizontal indices   ! LCOV_EXCL_LINE
     137             :          k              ! ice layer index
     138             : 
     139             :       real (kind=dbl_kind), dimension(nilyr+1) :: &
     140         130 :          sprofile                         ! vertical salinity profile
     141             : 
     142             :       real (kind=dbl_kind) :: &
     143           8 :          depressT
     144             : 
     145             :       character(len=*), parameter :: subname='(init_thermo_vertical)'
     146             : 
     147             :       !-----------------------------------------------------------------
     148             :       ! initialize
     149             :       !-----------------------------------------------------------------
     150             : 
     151          37 :       call icepack_query_parameters(depressT_out=depressT)
     152          37 :       call icepack_init_thermo(nilyr=nilyr, sprofile=sprofile)
     153          37 :       call icepack_warnings_flush(nu_diag)
     154          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
     155           0 :           file=__FILE__, line=__LINE__)
     156             : 
     157             :       !-----------------------------------------------------------------
     158             :       ! Prescibe vertical profile of salinity and melting temperature.
     159             :       ! Note this profile is only used for BL99 thermodynamics.
     160             :       !-----------------------------------------------------------------
     161             : 
     162          20 :       !$OMP PARALLEL DO PRIVATE(iblk,i,j,k)
     163          50 :       do iblk = 1,max_blocks
     164        1276 :       do j = 1, ny_block
     165       50267 :       do i = 1, nx_block
     166      442458 :          do k = 1, nilyr+1
     167      392224 :             salinz(i,j,k,iblk) = sprofile(k)
     168      441252 :             Tmltz (i,j,k,iblk) = -salinz(i,j,k,iblk)*depressT
     169             :          enddo ! k
     170             :       enddo    ! i
     171             :       enddo    ! j
     172             :       enddo    ! iblk
     173             :       !$OMP END PARALLEL DO
     174             : 
     175          37 :       end subroutine init_thermo_vertical
     176             : 
     177             : !=======================================================================
     178             : !
     179             : !  Initialize shortwave
     180             : 
     181          37 :       subroutine init_shortwave
     182             : 
     183             :       use ice_arrays_column, only: fswpenln, Iswabsn, Sswabsn, albicen, &
     184             :           albsnon, alvdrn, alidrn, alvdfn, alidfn, fswsfcn, &   ! LCOV_EXCL_LINE
     185             :           fswthrun, fswthrun_vdr, fswthrun_vdf, fswthrun_idr, fswthrun_idf, &   ! LCOV_EXCL_LINE
     186             :           fswintn, albpndn, apeffn, trcrn_sw, dhsn, ffracn, snowfracn, &   ! LCOV_EXCL_LINE
     187             :           swgrid, igrid
     188             :       use ice_blocks, only: block, get_block
     189             :       use ice_calendar, only: dt, calendar_type, &
     190             :           days_per_year, nextsw_cday, yday, msec
     191             :       use ice_diagnostics, only: npnt, print_points, pmloc, piloc, pjloc
     192             :       use ice_domain, only: nblocks, blocks_ice
     193             :       use ice_flux, only: alvdf, alidf, alvdr, alidr, &
     194             :                           alvdr_ai, alidr_ai, alvdf_ai, alidf_ai, &   ! LCOV_EXCL_LINE
     195             :                           swvdr, swvdf, swidr, swidf, scale_factor, snowfrac, &   ! LCOV_EXCL_LINE
     196             :                           albice, albsno, albpnd, apeff_ai, coszen, fsnow
     197             :       use ice_grid, only: tlat, tlon, tmask
     198             :       use ice_restart_shared, only: restart, runtype
     199             :       use ice_state, only: aicen, vicen, vsnon, trcrn
     200             : 
     201             :       integer (kind=int_kind) :: &
     202             :          i, j , k    , & ! horizontal indices   ! LCOV_EXCL_LINE
     203             :          iblk        , & ! block index   ! LCOV_EXCL_LINE
     204             :          ilo,ihi,jlo,jhi, & ! beginning and end of physical domain   ! LCOV_EXCL_LINE
     205             :          n                  ! thickness category index
     206             : 
     207             :       real (kind=dbl_kind) :: &
     208           8 :          netsw           ! flag for shortwave radiation presence
     209             : 
     210             :       type (block) :: &
     211             :          this_block      ! block information for current block
     212             : 
     213             :       logical (kind=log_kind) :: &
     214             :          l_print_point, & ! flag to print designated grid point diagnostics   ! LCOV_EXCL_LINE
     215             :          debug,         & ! if true, print diagnostics   ! LCOV_EXCL_LINE
     216             :          dEdd_algae,    & ! use prognostic chla in dEdd radiation   ! LCOV_EXCL_LINE
     217             :          modal_aero,    & ! use modal aerosol optical treatment   ! LCOV_EXCL_LINE
     218             :          snwgrain         ! use variable snow radius
     219             : 
     220             :       character (char_len) :: shortwave
     221             : 
     222             :       integer (kind=int_kind) :: &
     223             :          ipoint
     224             : 
     225             :       real (kind=dbl_kind), dimension(ncat) :: &
     226         106 :          fbri                 ! brine height to ice thickness
     227             : 
     228             :       real(kind= dbl_kind), dimension(:,:), allocatable :: &
     229             :          ztrcr_sw,        & ! zaerosols (kg/m^3) and chla (mg/m^3)   ! LCOV_EXCL_LINE
     230          37 :          rsnow              ! snow grain radius tracer (10^-6 m)
     231             : 
     232             :       logical (kind=log_kind) :: tr_brine, tr_zaero, tr_bgc_n
     233             :       integer (kind=int_kind) :: nt_alvl, nt_apnd, nt_hpnd, nt_ipnd, nt_aero, &
     234             :          nt_fbri, nt_tsfc, ntrcr, nbtrcr, nbtrcr_sw, nt_rsnw
     235             :       integer (kind=int_kind), dimension(icepack_max_algae) :: &
     236             :          nt_bgc_N
     237             :       integer (kind=int_kind), dimension(icepack_max_aero) :: &
     238             :          nt_zaero
     239           8 :       real (kind=dbl_kind) :: puny
     240             : 
     241             :       character(len=*), parameter :: subname='(init_shortwave)'
     242             : 
     243          37 :       call icepack_query_parameters(puny_out=puny)
     244          37 :       call icepack_query_parameters(shortwave_out=shortwave)
     245          37 :       call icepack_query_parameters(dEdd_algae_out=dEdd_algae)
     246          37 :       call icepack_query_parameters(modal_aero_out=modal_aero)
     247          37 :       call icepack_query_parameters(snwgrain_out=snwgrain)
     248          37 :       call icepack_query_tracer_sizes(ntrcr_out=ntrcr, nbtrcr_out=nbtrcr, nbtrcr_sw_out=nbtrcr_sw)
     249             :       call icepack_query_tracer_flags(tr_brine_out=tr_brine, tr_zaero_out=tr_zaero, &
     250          37 :          tr_bgc_n_out=tr_bgc_n)
     251             :       call icepack_query_tracer_indices(nt_alvl_out=nt_alvl, nt_apnd_out=nt_apnd, nt_hpnd_out=nt_hpnd, &
     252             :          nt_ipnd_out=nt_ipnd, nt_aero_out=nt_aero, nt_fbri_out=nt_fbri, nt_tsfc_out=nt_tsfc, &   ! LCOV_EXCL_LINE
     253          37 :          nt_bgc_N_out=nt_bgc_N, nt_zaero_out=nt_zaero, nt_rsnw_out=nt_rsnw)
     254          37 :       call icepack_warnings_flush(nu_diag)
     255          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
     256           0 :           file=__FILE__,line= __LINE__)
     257             : 
     258          37 :       allocate(ztrcr_sw(nbtrcr_sw, ncat))
     259          37 :       allocate(rsnow(nslyr,ncat))
     260             : 
     261         197 :       do iblk=1,nblocks
     262             : 
     263             :          ! Initialize
     264     4466960 :          fswpenln(:,:,:,:,iblk) = c0
     265     3908710 :          Iswabsn(:,:,:,:,iblk) = c0
     266      559210 :          Sswabsn(:,:,:,:,iblk) = c0
     267             : 
     268         160 :          this_block = get_block(blocks_ice(iblk),iblk)
     269         160 :          ilo = this_block%ilo
     270         160 :          ihi = this_block%ihi
     271         160 :          jlo = this_block%jlo
     272         160 :          jhi = this_block%jhi
     273             : 
     274        5303 :          do j = 1, ny_block ! can be jlo, jhi
     275      111650 :          do i = 1, nx_block ! can be ilo, ihi
     276             : 
     277      106347 :             l_print_point = .false.
     278      106347 :             debug = .false.
     279      106347 :             if (debug .and. print_points) then
     280           0 :                do ipoint = 1, npnt
     281           0 :                   if (my_task == pmloc(ipoint) .and. &
     282             :                        i == piloc(ipoint) .and. &   ! LCOV_EXCL_LINE
     283             :                        j == pjloc(ipoint)) &   ! LCOV_EXCL_LINE
     284           0 :                        l_print_point = .true.
     285           0 :                        write (nu_diag, *) 'my_task = ',my_task
     286             :                enddo ! n
     287             :             endif
     288             : 
     289      106347 :             alvdf(i,j,iblk) = c0
     290      106347 :             alidf(i,j,iblk) = c0
     291      106347 :             alvdr(i,j,iblk) = c0
     292      106347 :             alidr(i,j,iblk) = c0
     293      106347 :             alvdr_ai(i,j,iblk) = c0
     294      106347 :             alidr_ai(i,j,iblk) = c0
     295      106347 :             alvdf_ai(i,j,iblk) = c0
     296      106347 :             alidf_ai(i,j,iblk) = c0
     297      106347 :             albice(i,j,iblk) = c0
     298      106347 :             albsno(i,j,iblk) = c0
     299      106347 :             albpnd(i,j,iblk) = c0
     300      106347 :             snowfrac(i,j,iblk) = c0
     301      106347 :             apeff_ai(i,j,iblk) = c0
     302             : 
     303      643225 :             do n = 1, ncat
     304      531735 :                alvdrn(i,j,n,iblk) = c0
     305      531735 :                alidrn(i,j,n,iblk) = c0
     306      531735 :                alvdfn(i,j,n,iblk) = c0
     307      531735 :                alidfn(i,j,n,iblk) = c0
     308      531735 :                fswsfcn(i,j,n,iblk) = c0
     309      531735 :                fswintn(i,j,n,iblk) = c0
     310      531735 :                fswthrun(i,j,n,iblk) = c0
     311      531735 :                fswthrun_vdr(i,j,n,iblk) = c0
     312      531735 :                fswthrun_vdf(i,j,n,iblk) = c0
     313      531735 :                fswthrun_idr(i,j,n,iblk) = c0
     314      638082 :                fswthrun_idf(i,j,n,iblk) = c0
     315             :             enddo   ! ncat
     316             : 
     317             :          enddo
     318             :          enddo
     319        4983 :          do j = jlo, jhi
     320       95606 :          do i = ilo, ihi
     321             : 
     322       90623 :             if (shortwave(1:4) == 'dEdd') then ! delta Eddington
     323             : 
     324             : #ifndef CESMCOUPLED
     325             :                ! initialize orbital parameters
     326             :                ! These come from the driver in the coupled model.
     327       90623 :                call icepack_init_orbit()
     328       90623 :                call icepack_warnings_flush(nu_diag)
     329       90623 :                if (icepack_warnings_aborted()) call abort_ice(subname//' init_orbit', &
     330           0 :                   file=__FILE__, line=__LINE__)
     331             : #endif
     332             :             endif
     333             : 
     334      543738 :             fbri(:) = c0
     335      996853 :             ztrcr_sw(:,:) = c0
     336      996853 :             rsnow   (:,:) = c0
     337      543738 :             do n = 1, ncat
     338      453115 :                if (tr_brine)  fbri(n) = trcrn(i,j,nt_fbri,n,iblk)
     339      543738 :                if (snwgrain) then
     340           0 :                   do k = 1, nslyr
     341           0 :                      rsnow(k,n) = trcrn(i,j,nt_rsnw+k-1,n,iblk)
     342             :                   enddo
     343             :                endif
     344             :             enddo
     345             : 
     346       90623 :             if (tmask(i,j,iblk)) then
     347             :                call icepack_step_radiation (dt=dt,                             &
     348             :                           swgrid=swgrid(:), igrid=igrid(:),                    &   ! LCOV_EXCL_LINE
     349             :                           fbri=fbri(:),                                        &   ! LCOV_EXCL_LINE
     350             :                           aicen=aicen(i,j,:,iblk),                             &   ! LCOV_EXCL_LINE
     351             :                           vicen=vicen(i,j,:,iblk),                             &   ! LCOV_EXCL_LINE
     352             :                           vsnon=vsnon(i,j,:,iblk),                             &   ! LCOV_EXCL_LINE
     353             :                           Tsfcn=trcrn(i,j,nt_Tsfc,:,iblk),                     &   ! LCOV_EXCL_LINE
     354             :                           alvln=trcrn(i,j,nt_alvl,:,iblk),                     &   ! LCOV_EXCL_LINE
     355             :                           apndn=trcrn(i,j,nt_apnd,:,iblk),                     &   ! LCOV_EXCL_LINE
     356             :                           hpndn=trcrn(i,j,nt_hpnd,:,iblk),                     &   ! LCOV_EXCL_LINE
     357             :                           ipndn=trcrn(i,j,nt_ipnd,:,iblk),                     &   ! LCOV_EXCL_LINE
     358             :                           aeron=trcrn(i,j,nt_aero:nt_aero+4*n_aero-1,:,iblk),  &   ! LCOV_EXCL_LINE
     359             :                           bgcNn=trcrn(i,j,nt_bgc_N(1):nt_bgc_N(1)+n_algae*(nblyr+3)-1,:,iblk), &   ! LCOV_EXCL_LINE
     360             :                           zaeron=trcrn(i,j,nt_zaero(1):nt_zaero(1)+n_zaero*(nblyr+3)-1,:,iblk), &   ! LCOV_EXCL_LINE
     361             :                           trcrn_bgcsw=ztrcr_sw,                                &   ! LCOV_EXCL_LINE
     362             :                           TLAT=TLAT(i,j,iblk), TLON=TLON(i,j,iblk),            &   ! LCOV_EXCL_LINE
     363             :                           calendar_type=calendar_type,                         &   ! LCOV_EXCL_LINE
     364             :                           days_per_year=days_per_year,                         &   ! LCOV_EXCL_LINE
     365             :                           nextsw_cday=nextsw_cday, yday=yday,                  &   ! LCOV_EXCL_LINE
     366             :                           sec=msec,                                             &   ! LCOV_EXCL_LINE
     367             :                           swvdr=swvdr(i,j,iblk),         swvdf=swvdf(i,j,iblk),&   ! LCOV_EXCL_LINE
     368             :                           swidr=swidr(i,j,iblk),         swidf=swidf(i,j,iblk),&   ! LCOV_EXCL_LINE
     369             :                           coszen=coszen(i,j,iblk),       fsnow=fsnow(i,j,iblk),&   ! LCOV_EXCL_LINE
     370             :                           alvdrn=alvdrn(i,j,:,iblk),     alvdfn=alvdfn(i,j,:,iblk), &   ! LCOV_EXCL_LINE
     371             :                           alidrn=alidrn(i,j,:,iblk),     alidfn=alidfn(i,j,:,iblk), &   ! LCOV_EXCL_LINE
     372             :                           fswsfcn=fswsfcn(i,j,:,iblk),   fswintn=fswintn(i,j,:,iblk), &   ! LCOV_EXCL_LINE
     373             :                           fswthrun=fswthrun(i,j,:,iblk),                       &   ! LCOV_EXCL_LINE
     374             :                           fswthrun_vdr=fswthrun_vdr(i,j,:,iblk),               &   ! LCOV_EXCL_LINE
     375             :                           fswthrun_vdf=fswthrun_vdf(i,j,:,iblk),               &   ! LCOV_EXCL_LINE
     376             :                           fswthrun_idr=fswthrun_idr(i,j,:,iblk),               &   ! LCOV_EXCL_LINE
     377             :                           fswthrun_idf=fswthrun_idf(i,j,:,iblk),               &   ! LCOV_EXCL_LINE
     378             :                           fswpenln=fswpenln(i,j,:,:,iblk),                     &   ! LCOV_EXCL_LINE
     379             :                           Sswabsn=Sswabsn(i,j,:,:,iblk), Iswabsn=Iswabsn(i,j,:,:,iblk), &   ! LCOV_EXCL_LINE
     380             :                           albicen=albicen(i,j,:,iblk),   albsnon=albsnon(i,j,:,iblk), &   ! LCOV_EXCL_LINE
     381             :                           albpndn=albpndn(i,j,:,iblk),   apeffn=apeffn(i,j,:,iblk), &   ! LCOV_EXCL_LINE
     382             :                           snowfracn=snowfracn(i,j,:,iblk),                     &   ! LCOV_EXCL_LINE
     383             :                           dhsn=dhsn(i,j,:,iblk),         ffracn=ffracn(i,j,:,iblk), &   ! LCOV_EXCL_LINE
     384             :                           rsnow=rsnow(:,:), &   ! LCOV_EXCL_LINE
     385             :                           l_print_point=l_print_point,                         &   ! LCOV_EXCL_LINE
     386       71830 :                           initonly = .true.)
     387             :             endif
     388             : 
     389             :       !-----------------------------------------------------------------
     390             :       ! Define aerosol tracer on shortwave grid
     391             :       !-----------------------------------------------------------------
     392             : 
     393       95446 :             if (dEdd_algae .and. (tr_zaero .or. tr_bgc_N)) then
     394           0 :               do n = 1, ncat
     395           0 :                  do k = 1, nbtrcr_sw
     396           0 :                     trcrn_sw(i,j,k,n,iblk) = ztrcr_sw(k,n)
     397             :                  enddo
     398             :               enddo
     399             :             endif
     400             : 
     401             :          enddo ! i
     402             :          enddo ! j
     403             : 
     404             :       !-----------------------------------------------------------------
     405             :       ! Aggregate albedos
     406             :       ! Match loop order in coupling_prep for same order of operations
     407             :       !-----------------------------------------------------------------
     408             : 
     409         960 :          do n = 1, ncat
     410       25075 :          do j = jlo, jhi
     411      478030 :          do i = ilo, ihi
     412             : 
     413      477230 :                if (aicen(i,j,n,iblk) > puny) then
     414             : 
     415           0 :                   alvdf(i,j,iblk) = alvdf(i,j,iblk) &
     416      138246 :                        + alvdfn(i,j,n,iblk)*aicen(i,j,n,iblk)
     417           0 :                   alidf(i,j,iblk) = alidf(i,j,iblk) &
     418      138246 :                        + alidfn(i,j,n,iblk)*aicen(i,j,n,iblk)
     419           0 :                   alvdr(i,j,iblk) = alvdr(i,j,iblk) &
     420      138246 :                        + alvdrn(i,j,n,iblk)*aicen(i,j,n,iblk)
     421           0 :                   alidr(i,j,iblk) = alidr(i,j,iblk) &
     422      138246 :                        + alidrn(i,j,n,iblk)*aicen(i,j,n,iblk)
     423             : 
     424           0 :                   netsw = swvdr(i,j,iblk) + swidr(i,j,iblk) &
     425      138246 :                         + swvdf(i,j,iblk) + swidf(i,j,iblk)
     426      138246 :                   if (netsw > puny) then ! sun above horizon
     427           0 :                      albice(i,j,iblk) = albice(i,j,iblk) &
     428       27327 :                           + albicen(i,j,n,iblk)*aicen(i,j,n,iblk)
     429           0 :                      albsno(i,j,iblk) = albsno(i,j,iblk) &
     430       27327 :                           + albsnon(i,j,n,iblk)*aicen(i,j,n,iblk)
     431           0 :                      albpnd(i,j,iblk) = albpnd(i,j,iblk) &
     432       27327 :                           + albpndn(i,j,n,iblk)*aicen(i,j,n,iblk)
     433             :                   endif
     434             : 
     435           0 :                   apeff_ai(i,j,iblk) = apeff_ai(i,j,iblk) &
     436      138246 :                        + apeffn(i,j,n,iblk)*aicen(i,j,n,iblk)
     437           0 :                   snowfrac(i,j,iblk) = snowfrac(i,j,iblk) &
     438      138246 :                        + snowfracn(i,j,n,iblk)*aicen(i,j,n,iblk)
     439             : 
     440             :                endif ! aicen > puny
     441             : 
     442             :          enddo ! i
     443             :          enddo ! j
     444             :          enddo ! ncat
     445             : 
     446        5340 :          do j = 1, ny_block
     447      111650 :          do i = 1, nx_block
     448             : 
     449             :       !----------------------------------------------------------------
     450             :       ! Store grid box mean albedos and fluxes before scaling by aice
     451             :       !----------------------------------------------------------------
     452             : 
     453      106347 :             alvdf_ai  (i,j,iblk) = alvdf  (i,j,iblk)
     454      106347 :             alidf_ai  (i,j,iblk) = alidf  (i,j,iblk)
     455      106347 :             alvdr_ai  (i,j,iblk) = alvdr  (i,j,iblk)
     456      106347 :             alidr_ai  (i,j,iblk) = alidr  (i,j,iblk)
     457             : 
     458             :             ! for history averaging
     459             : !echmod?            cszn = c0
     460             : !echmod            if (coszen(i,j,iblk) > puny) cszn = c1
     461             : !echmod            do n = 1, nstreams
     462             : !echmod               albcnt(i,j,iblk,n) = albcnt(i,j,iblk,n) + cszn
     463             : !echmod            enddo
     464             : 
     465             :       !----------------------------------------------------------------
     466             :       ! Save net shortwave for scaling factor in scale_factor
     467             :       !----------------------------------------------------------------
     468      111490 :             if (runtype == 'initial' .and. .not. restart) then
     469           0 :                scale_factor(i,j,iblk) = &
     470             :                       swvdr(i,j,iblk)*(c1 - alvdr_ai(i,j,iblk)) &   ! LCOV_EXCL_LINE
     471             :                     + swvdf(i,j,iblk)*(c1 - alvdf_ai(i,j,iblk)) &   ! LCOV_EXCL_LINE
     472             :                     + swidr(i,j,iblk)*(c1 - alidr_ai(i,j,iblk)) &   ! LCOV_EXCL_LINE
     473       18496 :                     + swidf(i,j,iblk)*(c1 - alidf_ai(i,j,iblk))
     474             :             endif
     475             : 
     476             :          enddo ! i
     477             :          enddo ! j
     478             :       enddo ! iblk
     479             : 
     480          37 :       deallocate(ztrcr_sw)
     481          37 :       deallocate(rsnow)
     482             : 
     483          37 :       call icepack_warnings_flush(nu_diag)
     484          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
     485           0 :          file=__FILE__, line=__LINE__)
     486             : 
     487         111 :       end subroutine init_shortwave
     488             : 
     489             : !=======================================================================
     490             : 
     491             : !  Initialize ice age tracer (call prior to reading restart data)
     492             : 
     493         128 :       subroutine init_age(iage)
     494             : 
     495             :       real(kind=dbl_kind), dimension(:,:,:), intent(out) :: iage
     496             :       character(len=*),parameter :: subname='(init_age)'
     497             : 
     498      393578 :       iage(:,:,:) = c0
     499             : 
     500         128 :       end subroutine init_age
     501             : 
     502             : !=======================================================================
     503             : 
     504             : !  Initialize ice FY tracer (call prior to reading restart data)
     505             : 
     506         128 :       subroutine init_FY(firstyear)
     507             : 
     508             :       real(kind=dbl_kind), dimension(:,:,:), intent(out) :: firstyear
     509             :       character(len=*),parameter :: subname='(init_FY)'
     510             : 
     511      393578 :       firstyear(:,:,:) = c0
     512             : 
     513         128 :       end subroutine init_FY
     514             : 
     515             : !=======================================================================
     516             : 
     517             : !  Initialize ice lvl tracers (call prior to reading restart data)
     518             : 
     519         128 :       subroutine init_lvl(iblk, alvl, vlvl)
     520             : 
     521             :       use ice_constants, only: c0, c1
     522             :       use ice_arrays_column, only: ffracn, dhsn
     523             : 
     524             :       integer (kind=int_kind), intent(in)  :: iblk
     525             : 
     526             :       real (kind=dbl_kind), dimension(:,:,:), intent(out) :: &
     527             :          alvl , & ! level ice area fraction   ! LCOV_EXCL_LINE
     528             :          vlvl     ! level ice volume
     529             :       character(len=*),parameter :: subname='(init_lvl)'
     530             : 
     531      393578 :       alvl(:,:,:) = c1 ! level ice area fraction
     532      393578 :       vlvl(:,:,:) = c1 ! level ice volume
     533      393578 :       ffracn(:,:,:,iblk) = c0
     534      393578 :       dhsn(:,:,:,iblk) = c0
     535             : 
     536         128 :       end subroutine init_lvl
     537             : 
     538             : !=======================================================================
     539             : 
     540             : !  Initialize melt ponds.
     541             : 
     542         128 :       subroutine init_meltponds_lvl(apnd, hpnd, ipnd, dhsn)
     543             : 
     544             :       real(kind=dbl_kind), dimension(:,:,:), intent(out) :: &
     545             :          apnd , & ! melt pond area fraction   ! LCOV_EXCL_LINE
     546             :          hpnd , & ! melt pond depth   ! LCOV_EXCL_LINE
     547             :          ipnd , & ! melt pond refrozen lid thickness   ! LCOV_EXCL_LINE
     548             :          dhsn     ! depth difference for snow on sea ice and pond ice
     549             :       character(len=*),parameter :: subname='(init_meltponds_lvl)'
     550             : 
     551      393578 :       apnd(:,:,:) = c0
     552      393578 :       hpnd(:,:,:) = c0
     553      393578 :       ipnd(:,:,:) = c0
     554      393578 :       dhsn(:,:,:) = c0
     555             : 
     556         128 :       end subroutine init_meltponds_lvl
     557             : 
     558             : !=======================================================================
     559             : 
     560             : !  Initialize melt ponds.
     561             : 
     562           0 :       subroutine init_meltponds_topo(apnd, hpnd, ipnd)
     563             : 
     564             :       real(kind=dbl_kind), dimension(:,:,:), intent(out) :: &
     565             :          apnd , & ! melt pond area fraction   ! LCOV_EXCL_LINE
     566             :          hpnd , & ! melt pond depth   ! LCOV_EXCL_LINE
     567             :          ipnd     ! melt pond refrozen lid thickness
     568             :       character(len=*),parameter :: subname='(init_meltponds_topo)'
     569             : 
     570           0 :       apnd(:,:,:) = c0
     571           0 :       hpnd(:,:,:) = c0
     572           0 :       ipnd(:,:,:) = c0
     573             : 
     574           0 :       end subroutine init_meltponds_topo
     575             : 
     576             : !=======================================================================
     577             : 
     578             : !  Initialize snow redistribution/metamorphosis tracers (call prior to reading restart data)
     579             : 
     580           0 :       subroutine init_snowtracers(smice, smliq, rhos_cmp, rsnw)
     581             : 
     582             :       real(kind=dbl_kind), dimension(:,:,:,:), intent(out) :: &
     583             :          smice, smliq, rhos_cmp, rsnw
     584             :       character(len=*),parameter :: subname='(init_snowtracers)'
     585             : 
     586             :       real (kind=dbl_kind) :: &
     587             :          rsnw_fall, & ! snow grain radius of new fallen snow  (10^-6 m)   ! LCOV_EXCL_LINE
     588           0 :          rhos         ! snow density (kg/m^3)
     589             : 
     590           0 :       call icepack_query_parameters(rsnw_fall_out=rsnw_fall, rhos_out=rhos)
     591             : 
     592           0 :       rsnw    (:,:,:,:) = rsnw_fall
     593           0 :       rhos_cmp(:,:,:,:) = rhos
     594           0 :       smice   (:,:,:,:) = rhos
     595           0 :       smliq   (:,:,:,:) = c0
     596             : 
     597           0 :       end subroutine init_snowtracers
     598             : 
     599             : !=======================================================================
     600             : 
     601             : !  Initialize floe size distribution tracer (call prior to reading restart data)
     602             : 
     603           0 :       subroutine init_fsd(floesize)
     604             : 
     605             :       use ice_arrays_column, only: floe_rad_c, floe_binwidth, &
     606             :          wavefreq, dwavefreq, wave_sig_ht, wave_spectrum, &   ! LCOV_EXCL_LINE
     607             :          d_afsd_newi, d_afsd_latg, d_afsd_latm, d_afsd_wave, d_afsd_weld
     608             :       use ice_domain_size, only: ncat, max_blocks, nfsd
     609             :       use ice_init, only: ice_ic
     610             :       use ice_state, only: aicen
     611             : 
     612             :       real(kind=dbl_kind), dimension(:,:,:,:,:), intent(out) :: &
     613             :          floesize            ! floe size distribution tracer
     614             : 
     615             :       ! local variables
     616             : 
     617             :       real (kind=dbl_kind), dimension(nfsd) :: &
     618           0 :          afsd                ! floe size distribution "profile"
     619             : 
     620             :       real (kind=dbl_kind), dimension(nfsd,ncat) :: &
     621           0 :          afsdn               ! floe size distribution "profile"
     622             : 
     623           0 :       real (kind=dbl_kind) :: puny
     624             : 
     625             :       integer (kind=int_kind) :: &
     626             :          i, j, iblk     , &  ! horizontal indices   ! LCOV_EXCL_LINE
     627             :          n, k                ! category index
     628             : 
     629             :       logical (kind=log_kind) :: tr_fsd
     630             : 
     631             :       character(len=*), parameter :: subname='(init_fsd)'
     632             : 
     633           0 :       call icepack_query_parameters(puny_out=puny)
     634             : 
     635           0 :       wavefreq       (:)       = c0
     636           0 :       dwavefreq      (:)       = c0
     637           0 :       wave_sig_ht    (:,:,:)   = c0
     638           0 :       wave_spectrum  (:,:,:,:) = c0
     639           0 :       d_afsd_newi    (:,:,:,:) = c0
     640           0 :       d_afsd_latg    (:,:,:,:) = c0
     641           0 :       d_afsd_latm    (:,:,:,:) = c0
     642           0 :       d_afsd_wave    (:,:,:,:) = c0
     643           0 :       d_afsd_weld    (:,:,:,:) = c0
     644             : 
     645             :       ! default: floes occupy the smallest size category in all thickness categories
     646           0 :       afsdn(:,:) = c0
     647           0 :       afsdn(1,:) = c1
     648           0 :       floesize(:,:,:,:,:) = c0
     649           0 :       floesize(:,:,1,:,:) = c1
     650             : 
     651           0 :       call icepack_query_tracer_flags(tr_fsd_out=tr_fsd)
     652           0 :       call icepack_warnings_flush(nu_diag)
     653           0 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
     654           0 :           file=__FILE__,line= __LINE__)
     655             : 
     656           0 :       if (tr_fsd) then
     657             : 
     658             :          ! initialize floe size distribution the same in every column and category
     659             :          call icepack_init_fsd(nfsd, ice_ic, &
     660             :             floe_rad_c,    &  ! fsd size bin centre in m (radius)   ! LCOV_EXCL_LINE
     661             :             floe_binwidth, &  ! fsd size bin width in m (radius)   ! LCOV_EXCL_LINE
     662           0 :             afsd)             ! floe size distribution
     663             : 
     664           0 :          do iblk = 1, max_blocks
     665           0 :             do j = 1, ny_block
     666           0 :             do i = 1, nx_block
     667           0 :                do n = 1, ncat
     668           0 :                do k = 1, nfsd
     669           0 :                   if (aicen(i,j,n,iblk) > puny) afsdn(k,n) = afsd(k)
     670             :                enddo    ! k
     671             :                enddo    ! n
     672             : 
     673           0 :                call icepack_cleanup_fsd (ncat, nfsd, afsdn) ! renormalize
     674             : 
     675           0 :                do n = 1, ncat
     676           0 :                do k = 1, nfsd
     677           0 :                   floesize(i,j,k,n,iblk) = afsdn(k,n)
     678             :                enddo    ! k
     679             :                enddo    ! n
     680             :             enddo       ! i
     681             :             enddo       ! j
     682             :          enddo          ! iblk
     683             : 
     684           0 :          call icepack_warnings_flush(nu_diag)
     685           0 :          if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
     686           0 :             file=__FILE__, line=__LINE__)
     687             : 
     688             :       endif ! tr_fsd
     689             : 
     690           0 :       end subroutine init_fsd
     691             : 
     692             : !=======================================================================
     693             : 
     694             : !  Initialize isotope tracers (call prior to reading restart data)
     695             : 
     696           0 :       subroutine init_isotope(isosno, isoice)
     697             : 
     698             :       real(kind=dbl_kind), dimension(:,:,:,:), intent(out) :: &
     699             :          isosno, isoice
     700             :       character(len=*),parameter :: subname='(init_isotope)'
     701             : 
     702           0 :       isosno(:,:,:,:) = c0
     703           0 :       isoice(:,:,:,:) = c0
     704             : 
     705           0 :       end subroutine init_isotope
     706             : 
     707             : !=======================================================================
     708             : 
     709             : !  Initialize ice aerosol tracer (call prior to reading restart data)
     710             : 
     711           0 :       subroutine init_aerosol(aero)
     712             : 
     713             :       real(kind=dbl_kind), dimension(:,:,:,:), intent(out) :: &
     714             :          aero ! aerosol tracers
     715             :       character(len=*),parameter :: subname='(init_aerosol)'
     716             : 
     717           0 :       aero(:,:,:,:) = c0
     718             : 
     719           0 :       end subroutine init_aerosol
     720             : 
     721             : !=======================================================================
     722             : 
     723             : !  Initialize vertical profile for biogeochemistry
     724             : 
     725           0 :       subroutine init_bgc()
     726             : 
     727             :       use ice_arrays_column, only: zfswin, trcrn_sw, &
     728             :           ocean_bio_all, ice_bio_net, snow_bio_net, &   ! LCOV_EXCL_LINE
     729             :           cgrid, igrid, bphi, iDi, bTiz, iki
     730             :       use ice_blocks, only: block, get_block
     731             :       use ice_domain, only: nblocks, blocks_ice
     732             :       use ice_flux, only: sss
     733             :       use ice_flux_bgc, only: nit, amm, sil, dmsp, dms, algalN, &
     734             :           doc, don, dic, fed, fep, zaeros, hum
     735             :       use ice_forcing_bgc, only: init_bgc_data, get_forcing_bgc
     736             :       use ice_restart_column, only: read_restart_bgc, restart_bgc
     737             :       use ice_state, only: trcrn
     738             : 
     739             :       ! local variables
     740             : 
     741             :       integer (kind=int_kind) :: &
     742             :          i, j, iblk       , & ! horizontal indices   ! LCOV_EXCL_LINE
     743             :          ilo,ihi,jlo,jhi  , & ! beginning and end of physical domain   ! LCOV_EXCL_LINE
     744             :          k                , & ! vertical index   ! LCOV_EXCL_LINE
     745             :          n                    ! category index
     746             : 
     747             :       integer (kind=int_kind) :: &
     748             :          max_nbtrcr, max_algae, max_don, max_doc, max_dic, max_aero, max_fe
     749             : 
     750             :       type (block) :: &
     751             :          this_block      ! block information for current block
     752             : 
     753             :       real(kind=dbl_kind), allocatable :: &
     754           0 :          trcrn_bgc(:,:)
     755             : 
     756             :       real(kind=dbl_kind), dimension(nilyr,ncat) :: &
     757           0 :          sicen
     758             : 
     759             :       integer (kind=int_kind) :: &
     760             :          nbtrcr, ntrcr, ntrcr_o, nt_sice
     761             : 
     762             :       character(len=*), parameter :: subname='(init_bgc)'
     763             : 
     764             :       ! Initialize
     765             : 
     766           0 :       call icepack_query_tracer_sizes(nbtrcr_out=nbtrcr, ntrcr_out=ntrcr, ntrcr_o_out=ntrcr_o)
     767           0 :       call icepack_query_tracer_indices(nt_sice_out=nt_sice)
     768             :       call icepack_query_tracer_sizes(max_nbtrcr_out=max_nbtrcr,         &
     769             :            max_algae_out=max_algae, max_don_out=max_don, max_doc_out=max_doc,   &   ! LCOV_EXCL_LINE
     770           0 :            max_dic_out=max_dic, max_aero_out=max_aero, max_fe_out=max_fe)
     771           0 :       call icepack_warnings_flush(nu_diag)
     772           0 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
     773           0 :           file=__FILE__,line= __LINE__)
     774             : 
     775           0 :       allocate(trcrn_bgc(ntrcr,ncat))
     776             : 
     777           0 :       bphi(:,:,:,:,:) = c0   ! initial porosity for no ice
     778           0 :       iDi (:,:,:,:,:) = c0   ! interface diffusivity
     779           0 :       bTiz(:,:,:,:,:) = c0   ! initial bio grid ice temperature
     780           0 :       iki (:,:,:,:,:) = c0   ! permeability
     781             : 
     782           0 :       ocean_bio_all(:,:,:,:)   = c0
     783           0 :       ice_bio_net  (:,:,:,:)   = c0 ! integrated ice tracer conc (mmol/m^2 or mg/m^2)
     784           0 :       snow_bio_net (:,:,:,:)   = c0 ! integrated snow tracer conc (mmol/m^2 or mg/m^2)
     785           0 :       zfswin       (:,:,:,:,:) = c0 ! shortwave flux on bio grid
     786           0 :       trcrn_sw     (:,:,:,:,:) = c0 ! tracers active in the shortwave calculation
     787           0 :       trcrn_bgc    (:,:)       = c0
     788             : 
     789             :       !-----------------------------------------------------------------
     790             :       ! biogeochemistry initialization
     791             :       !-----------------------------------------------------------------
     792             : 
     793           0 :       if (.not. restart_bgc) then
     794             : 
     795             :       !-----------------------------------------------------------------
     796             :       ! Initial Ocean Values if not coupled to the ocean bgc
     797             :       !-----------------------------------------------------------------
     798           0 :          !$OMP PARALLEL DO PRIVATE(iblk,i,j,n,ilo,ihi,jlo,jhi,this_block)
     799           0 :          do iblk = 1, nblocks
     800             : 
     801           0 :             this_block = get_block(blocks_ice(iblk),iblk)
     802           0 :             ilo = this_block%ilo
     803           0 :             ihi = this_block%ihi
     804           0 :             jlo = this_block%jlo
     805           0 :             jhi = this_block%jhi
     806             : 
     807           0 :             do j = jlo, jhi
     808           0 :             do i = ilo, ihi
     809             :                call icepack_init_ocean_bio ( &
     810             :                     amm=amm      (i,j,  iblk), dmsp=dmsp(i,j,  iblk), dms=dms(i,j,  iblk), &   ! LCOV_EXCL_LINE
     811             :                     algalN=algalN(i,j,:,iblk), doc=doc  (i,j,:,iblk), dic=dic(i,j,:,iblk), &   ! LCOV_EXCL_LINE
     812             :                     don=don      (i,j,:,iblk), fed=fed  (i,j,:,iblk), fep=fep(i,j,:,iblk), &   ! LCOV_EXCL_LINE
     813             :                     hum=hum      (i,j,  iblk), nit=nit  (i,j,  iblk), sil=sil(i,j,  iblk), &   ! LCOV_EXCL_LINE
     814             :                     zaeros=zaeros(i,j,:,iblk), &   ! LCOV_EXCL_LINE
     815             :                     max_dic = icepack_max_dic, max_don  = icepack_max_don, &   ! LCOV_EXCL_LINE
     816           0 :                     max_fe  = icepack_max_fe,  max_aero = icepack_max_aero)
     817             :             enddo  ! i
     818             :             enddo  ! j
     819             : 
     820             :          enddo     ! iblk
     821             :          !$OMP END PARALLEL DO
     822             : 
     823           0 :          call icepack_warnings_flush(nu_diag)
     824           0 :          if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
     825           0 :             file=__FILE__, line=__LINE__)
     826             : 
     827           0 :          call init_bgc_data(fed(:,:,1,:),fep(:,:,1,:)) ! input dFe from file
     828           0 :          call get_forcing_bgc                          ! defines nit and sil
     829             : 
     830             :       endif     ! .not. restart
     831             : 
     832           0 :       !$OMP PARALLEL DO PRIVATE(iblk,i,j,n,ilo,ihi,jlo,jhi,this_block)
     833           0 :       do iblk = 1, nblocks
     834             : 
     835           0 :          this_block = get_block(blocks_ice(iblk),iblk)
     836           0 :          ilo = this_block%ilo
     837           0 :          ihi = this_block%ihi
     838           0 :          jlo = this_block%jlo
     839           0 :          jhi = this_block%jhi
     840             : 
     841           0 :          do j = jlo, jhi
     842           0 :          do i = ilo, ihi
     843             : 
     844             :             call icepack_load_ocean_bio_array(max_nbtrcr=icepack_max_nbtrcr,     &
     845             :                          max_algae=icepack_max_algae, max_don=icepack_max_don,   &   ! LCOV_EXCL_LINE
     846             :                          max_doc=icepack_max_doc,     max_fe=icepack_max_fe,     &   ! LCOV_EXCL_LINE
     847             :                          max_dic=icepack_max_dic,     max_aero=icepack_max_aero, &   ! LCOV_EXCL_LINE
     848             :                          nit =nit (i,j,  iblk), amm=amm(i,j,  iblk), sil   =sil   (i,j,  iblk), &   ! LCOV_EXCL_LINE
     849             :                          dmsp=dmsp(i,j,  iblk), dms=dms(i,j,  iblk), algalN=algalN(i,j,:,iblk), &   ! LCOV_EXCL_LINE
     850             :                          doc =doc (i,j,:,iblk), don=don(i,j,:,iblk), dic   =dic   (i,j,:,iblk), &   ! LCOV_EXCL_LINE
     851             :                          fed =fed (i,j,:,iblk), fep=fep(i,j,:,iblk), zaeros=zaeros(i,j,:,iblk), &   ! LCOV_EXCL_LINE
     852           0 :                          hum=hum  (i,j,  iblk), ocean_bio_all=ocean_bio_all(i,j,:,iblk))
     853             : 
     854             :          enddo  ! i
     855             :          enddo  ! j
     856             : 
     857             :       enddo     ! iblk
     858             :       !$OMP END PARALLEL DO
     859             : 
     860           0 :       call icepack_warnings_flush(nu_diag)
     861           0 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
     862           0 :          file=__FILE__, line=__LINE__)
     863             : 
     864           0 :       if (.not. restart_bgc) then
     865           0 :          !$OMP PARALLEL DO PRIVATE(iblk,i,j,k,n,ilo,ihi,jlo,jhi,this_block,sicen,trcrn_bgc)
     866           0 :          do iblk = 1, nblocks
     867             : 
     868           0 :             this_block = get_block(blocks_ice(iblk),iblk)
     869           0 :             ilo = this_block%ilo
     870           0 :             ihi = this_block%ihi
     871           0 :             jlo = this_block%jlo
     872           0 :             jhi = this_block%jhi
     873             : 
     874           0 :             do j = jlo, jhi
     875           0 :             do i = ilo, ihi
     876           0 :                 do n = 1, ncat
     877           0 :                 do k = 1, nilyr
     878           0 :                    sicen(k,n) = trcrn(i,j,nt_sice+k-1,n,iblk)
     879             :                 enddo
     880           0 :                 do k = ntrcr_o+1, ntrcr
     881           0 :                    trcrn_bgc(k-ntrcr_o,n) = trcrn(i,j,k,n,iblk)
     882             :                 enddo
     883             :                 enddo
     884             :             call icepack_init_bgc(ncat=ncat, nblyr=nblyr, nilyr=nilyr, ntrcr_o=ntrcr_o,  &
     885             :                          cgrid=cgrid, igrid=igrid, ntrcr=ntrcr, nbtrcr=nbtrcr,           &   ! LCOV_EXCL_LINE
     886             :                          sicen=sicen(:,:), trcrn=trcrn_bgc(:,:), sss=sss(i,j, iblk), &   ! LCOV_EXCL_LINE
     887           0 :                          ocean_bio_all=ocean_bio_all(i,j,:,iblk))
     888             :             enddo  ! i
     889             :             enddo  ! j
     890             :          enddo     ! iblk
     891             :          !$OMP END PARALLEL DO
     892             : 
     893           0 :          call icepack_warnings_flush(nu_diag)
     894           0 :          if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
     895           0 :             file=__FILE__, line=__LINE__)
     896             : 
     897             :       endif ! .not. restart
     898             : 
     899             :       !-----------------------------------------------------------------
     900             :       ! read restart to complete BGC initialization
     901             :       !-----------------------------------------------------------------
     902             : 
     903           0 :       if (restart_bgc) call read_restart_bgc
     904             : 
     905           0 :       deallocate(trcrn_bgc)
     906             : 
     907           0 :       end subroutine init_bgc
     908             : 
     909             : !=======================================================================
     910             : 
     911             : !  Initialize brine height tracer
     912             : 
     913           0 :       subroutine init_hbrine()
     914             : 
     915             :       use ice_arrays_column, only: first_ice, bgrid, igrid, cgrid, &
     916             :           icgrid, swgrid
     917             :       use ice_state, only: trcrn
     918             : 
     919           0 :       real (kind=dbl_kind) :: phi_snow
     920             :       integer (kind=int_kind) :: nt_fbri
     921             :       logical (kind=log_kind) :: tr_brine
     922             :       character(len=*), parameter :: subname='(init_hbrine)'
     923             : 
     924           0 :       call icepack_query_parameters(phi_snow_out=phi_snow)
     925           0 :       call icepack_warnings_flush(nu_diag)
     926           0 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
     927           0 :           file=__FILE__,line= __LINE__)
     928             : 
     929             :       call icepack_init_hbrine(bgrid=bgrid, igrid=igrid, cgrid=cgrid, icgrid=icgrid, &
     930           0 :             swgrid=swgrid, nblyr=nblyr, nilyr=nilyr, phi_snow=phi_snow)
     931           0 :       call icepack_warnings_flush(nu_diag)
     932           0 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
     933           0 :           file=__FILE__, line=__LINE__)
     934             : 
     935           0 :       call icepack_init_parameters(phi_snow_in=phi_snow)
     936           0 :       call icepack_warnings_flush(nu_diag)
     937           0 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
     938           0 :           file=__FILE__,line= __LINE__)
     939             : 
     940           0 :       call icepack_query_tracer_flags(tr_brine_out=tr_brine)
     941           0 :       call icepack_query_tracer_indices(nt_fbri_out=nt_fbri)
     942           0 :       call icepack_warnings_flush(nu_diag)
     943           0 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
     944           0 :           file=__FILE__,line= __LINE__)
     945             : 
     946           0 :       first_ice(:,:,:,:) = .true.
     947           0 :       if (tr_brine) trcrn(:,:,nt_fbri,:,:) = c1
     948             : 
     949           0 :       end subroutine init_hbrine
     950             : 
     951             : !=======================================================================
     952             : 
     953             : ! Namelist variables, set to default values; may be altered at run time
     954             : !
     955             : ! author Elizabeth C. Hunke, LANL
     956             : !        Nicole Jeffery, LANL
     957             : 
     958          37 :       subroutine input_zbgc
     959             : 
     960             :       use ice_arrays_column, only: restore_bgc
     961             :       use ice_broadcast, only: broadcast_scalar
     962             :       use ice_restart_column, only: restart_bgc, restart_hbrine
     963             :       use ice_restart_shared, only: restart
     964             : 
     965             :       character (len=char_len) :: &
     966             :          shortwave        ! from icepack
     967             : 
     968             :       logical (kind=log_kind) :: &
     969             :          tr_brine, &   ! LCOV_EXCL_LINE
     970             :          tr_bgc_Nit,    tr_bgc_Am,    tr_bgc_Sil,   &   ! LCOV_EXCL_LINE
     971             :          tr_bgc_DMS,    tr_bgc_PON,   &   ! LCOV_EXCL_LINE
     972             :          tr_bgc_N,      tr_bgc_C,     tr_bgc_chl,   &   ! LCOV_EXCL_LINE
     973             :          tr_bgc_DON,    tr_bgc_Fe,    tr_zaero,     &   ! LCOV_EXCL_LINE
     974             :          tr_bgc_hum,    tr_aero
     975             : 
     976             :       integer (kind=int_kind) :: &
     977             :          ktherm
     978             : 
     979             :       logical (kind=log_kind) :: &
     980             :          solve_zsal, skl_bgc, z_tracers, scale_bgc, solve_zbgc, dEdd_algae, &   ! LCOV_EXCL_LINE
     981             :          modal_aero, restart_zsal
     982             : 
     983             :       character (char_len) :: &
     984             :          bgc_flux_type
     985             : 
     986             :       integer (kind=int_kind) :: &
     987             :          nml_error, & ! namelist i/o error flag   ! LCOV_EXCL_LINE
     988             :          abort_flag
     989             : 
     990             :       character(len=*), parameter :: subname='(input_zbgc)'
     991             : 
     992             :       !-----------------------------------------------------------------
     993             :       ! namelist variables
     994             :       !-----------------------------------------------------------------
     995             : 
     996             :       namelist /zbgc_nml/  &
     997             :         tr_brine, restart_hbrine, tr_zaero, modal_aero, skl_bgc, &   ! LCOV_EXCL_LINE
     998             :         z_tracers, dEdd_algae, solve_zbgc, bgc_flux_type, &   ! LCOV_EXCL_LINE
     999             :         restore_bgc, restart_bgc, scale_bgc, solve_zsal, restart_zsal, &   ! LCOV_EXCL_LINE
    1000             :         tr_bgc_Nit, tr_bgc_C, tr_bgc_chl, tr_bgc_Am, tr_bgc_Sil, &   ! LCOV_EXCL_LINE
    1001             :         tr_bgc_DMS, tr_bgc_PON, tr_bgc_hum, tr_bgc_DON, tr_bgc_Fe, &   ! LCOV_EXCL_LINE
    1002             :         grid_o, grid_o_t, l_sk, grid_oS, &   ! LCOV_EXCL_LINE
    1003             :         l_skS, phi_snow,  initbio_frac, frazil_scav, &   ! LCOV_EXCL_LINE
    1004             :         ratio_Si2N_diatoms , ratio_Si2N_sp      , ratio_Si2N_phaeo   ,  &   ! LCOV_EXCL_LINE
    1005             :         ratio_S2N_diatoms  , ratio_S2N_sp       , ratio_S2N_phaeo    ,  &   ! LCOV_EXCL_LINE
    1006             :         ratio_Fe2C_diatoms , ratio_Fe2C_sp      , ratio_Fe2C_phaeo   ,  &   ! LCOV_EXCL_LINE
    1007             :         ratio_Fe2N_diatoms , ratio_Fe2N_sp      , ratio_Fe2N_phaeo   ,  &   ! LCOV_EXCL_LINE
    1008             :         ratio_Fe2DON       , ratio_Fe2DOC_s     , ratio_Fe2DOC_l     ,  &   ! LCOV_EXCL_LINE
    1009             :         fr_resp            , tau_min            , tau_max            ,  &   ! LCOV_EXCL_LINE
    1010             :         algal_vel          , R_dFe2dust         , dustFe_sol         ,  &   ! LCOV_EXCL_LINE
    1011             :         chlabs_diatoms     , chlabs_sp          , chlabs_phaeo       ,  &   ! LCOV_EXCL_LINE
    1012             :         alpha2max_low_diatoms,alpha2max_low_sp  , alpha2max_low_phaeo,  &   ! LCOV_EXCL_LINE
    1013             :         beta2max_diatoms   , beta2max_sp        , beta2max_phaeo     ,  &   ! LCOV_EXCL_LINE
    1014             :         mu_max_diatoms     , mu_max_sp          , mu_max_phaeo       ,  &   ! LCOV_EXCL_LINE
    1015             :         grow_Tdep_diatoms  , grow_Tdep_sp       , grow_Tdep_phaeo    ,  &   ! LCOV_EXCL_LINE
    1016             :         fr_graze_diatoms   , fr_graze_sp        , fr_graze_phaeo     ,  &   ! LCOV_EXCL_LINE
    1017             :         mort_pre_diatoms   , mort_pre_sp        , mort_pre_phaeo     ,  &   ! LCOV_EXCL_LINE
    1018             :         mort_Tdep_diatoms  , mort_Tdep_sp       , mort_Tdep_phaeo    ,  &   ! LCOV_EXCL_LINE
    1019             :         k_exude_diatoms    , k_exude_sp         , k_exude_phaeo      ,  &   ! LCOV_EXCL_LINE
    1020             :         K_Nit_diatoms      , K_Nit_sp           , K_Nit_phaeo        ,  &   ! LCOV_EXCL_LINE
    1021             :         K_Am_diatoms       , K_Am_sp            , K_Am_phaeo         ,  &   ! LCOV_EXCL_LINE
    1022             :         K_Sil_diatoms      , K_Sil_sp           , K_Sil_phaeo        ,  &   ! LCOV_EXCL_LINE
    1023             :         K_Fe_diatoms       , K_Fe_sp            , K_Fe_phaeo         ,  &   ! LCOV_EXCL_LINE
    1024             :         f_don_protein      , kn_bac_protein     , f_don_Am_protein   ,  &   ! LCOV_EXCL_LINE
    1025             :         f_doc_s            , f_doc_l            , f_exude_s          ,  &   ! LCOV_EXCL_LINE
    1026             :         f_exude_l          , k_bac_s            , k_bac_l            ,  &   ! LCOV_EXCL_LINE
    1027             :         T_max              , fsal               , op_dep_min         ,  &   ! LCOV_EXCL_LINE
    1028             :         fr_graze_s         , fr_graze_e         , fr_mort2min        ,  &   ! LCOV_EXCL_LINE
    1029             :         fr_dFe             , k_nitrif           , t_iron_conv        ,  &   ! LCOV_EXCL_LINE
    1030             :         max_loss           , max_dfe_doc1       , fr_resp_s          ,  &   ! LCOV_EXCL_LINE
    1031             :         y_sk_DMS           , t_sk_conv          , t_sk_ox            ,  &   ! LCOV_EXCL_LINE
    1032             :         algaltype_diatoms  , algaltype_sp       , algaltype_phaeo    ,  &   ! LCOV_EXCL_LINE
    1033             :         nitratetype        , ammoniumtype       , silicatetype       ,  &   ! LCOV_EXCL_LINE
    1034             :         dmspptype          , dmspdtype          , humtype            ,  &   ! LCOV_EXCL_LINE
    1035             :         doctype_s          , doctype_l          , dontype_protein    ,  &   ! LCOV_EXCL_LINE
    1036             :         fedtype_1          , feptype_1          , zaerotype_bc1      ,  &   ! LCOV_EXCL_LINE
    1037             :         zaerotype_bc2      , zaerotype_dust1    , zaerotype_dust2    ,  &   ! LCOV_EXCL_LINE
    1038             :         zaerotype_dust3    , zaerotype_dust4    , ratio_C2N_diatoms  ,  &   ! LCOV_EXCL_LINE
    1039             :         ratio_C2N_sp       , ratio_C2N_phaeo    , ratio_chl2N_diatoms,  &   ! LCOV_EXCL_LINE
    1040             :         ratio_chl2N_sp     , ratio_chl2N_phaeo  , F_abs_chl_diatoms  ,  &   ! LCOV_EXCL_LINE
    1041             :         F_abs_chl_sp       , F_abs_chl_phaeo    , ratio_C2N_proteins
    1042             : 
    1043             :       !-----------------------------------------------------------------
    1044             : 
    1045          37 :       abort_flag = 0
    1046             : 
    1047          37 :       call icepack_query_tracer_flags(tr_aero_out=tr_aero)
    1048          37 :       call icepack_query_parameters(ktherm_out=ktherm, shortwave_out=shortwave)
    1049          37 :       call icepack_warnings_flush(nu_diag)
    1050          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
    1051           0 :           file=__FILE__, line=__LINE__)
    1052             : 
    1053             :       !-----------------------------------------------------------------
    1054             :       ! default values
    1055             :       !-----------------------------------------------------------------
    1056          37 :       tr_brine        = .false.  ! brine height differs from ice height
    1057          37 :       tr_zaero        = .false.  ! z aerosol tracers
    1058          37 :       modal_aero      = .false.  ! use modal aerosol treatment of aerosols
    1059          37 :       restore_bgc     = .false.  ! restore bgc if true
    1060          37 :       solve_zsal      = .false.  ! update salinity tracer profile from solve_S_dt
    1061          37 :       restart_bgc     = .false.  ! biogeochemistry restart
    1062          37 :       restart_zsal    = .false.  ! salinity restart
    1063          37 :       restart_hbrine  = .false.  ! hbrine restart
    1064          37 :       scale_bgc       = .false.  ! initial bgc tracers proportional to S
    1065          37 :       skl_bgc         = .false.  ! solve skeletal biochemistry
    1066          37 :       z_tracers       = .false.  ! solve vertically resolved tracers
    1067          37 :       dEdd_algae      = .false.  ! dynamic algae contributes to shortwave absorption
    1068             :                                  ! in delta-Eddington calculation
    1069          37 :       solve_zbgc      = .false.  ! turn on z layer biochemistry
    1070          37 :       tr_bgc_PON      = .false.  !---------------------------------------------
    1071          37 :       tr_bgc_Nit      = .false.  ! biogeochemistry (skl or zbgc)
    1072          37 :       tr_bgc_C        = .false.  ! if skl_bgc = .true. then skl
    1073          37 :       tr_bgc_chl      = .false.  ! if z_tracers = .true. then vertically resolved
    1074          37 :       tr_bgc_Sil      = .false.  ! if z_tracers + solve_zbgc = .true. then
    1075          37 :       tr_bgc_Am       = .false.  ! vertically resolved with reactions
    1076          37 :       tr_bgc_DMS      = .false.  !------------------------------------------------
    1077          37 :       tr_bgc_DON      = .false.  !
    1078          37 :       tr_bgc_hum      = .false.  !
    1079          37 :       tr_bgc_Fe       = .false.  !
    1080          37 :       tr_bgc_N        = .true.   !
    1081             : 
    1082             :       ! brine height parameter
    1083          37 :       phi_snow        = p5       ! snow porosity
    1084             : 
    1085             :       ! skl biology parameters
    1086          37 :       bgc_flux_type   = 'Jin2006'! type of ocean-ice poston velocity ('constant')
    1087             : 
    1088             :       ! z biology parameters
    1089          37 :       grid_o          = c5           ! for bottom flux
    1090          37 :       grid_o_t        = c5           ! for top flux
    1091          37 :       l_sk            = 7.0_dbl_kind ! characteristic diffusive scale (m)
    1092          37 :       initbio_frac    = c1           ! fraction of ocean trcr concentration in bio trcrs
    1093          37 :       frazil_scav     = c1           ! increase in initial bio tracer from ocean scavenging
    1094          37 :       ratio_Si2N_diatoms = 1.8_dbl_kind    ! algal Si to N (mol/mol)
    1095          37 :       ratio_Si2N_sp      = c0              ! diatoms, small plankton, phaeocystis
    1096          37 :       ratio_Si2N_phaeo   = c0
    1097          37 :       ratio_S2N_diatoms  = 0.03_dbl_kind   ! algal S  to N (mol/mol)
    1098          37 :       ratio_S2N_sp       = 0.03_dbl_kind
    1099          37 :       ratio_S2N_phaeo    = 0.03_dbl_kind
    1100          37 :       ratio_Fe2C_diatoms = 0.0033_dbl_kind ! algal Fe to C  (umol/mol)
    1101          37 :       ratio_Fe2C_sp      = 0.0033_dbl_kind
    1102          37 :       ratio_Fe2C_phaeo   = p1
    1103          37 :       ratio_Fe2N_diatoms = 0.023_dbl_kind  ! algal Fe to N  (umol/mol)
    1104          37 :       ratio_Fe2N_sp      = 0.023_dbl_kind
    1105          37 :       ratio_Fe2N_phaeo   = 0.7_dbl_kind
    1106          37 :       ratio_Fe2DON       = 0.023_dbl_kind  ! Fe to N of DON (nmol/umol)
    1107          37 :       ratio_Fe2DOC_s     = p1              ! Fe to C of DOC (nmol/umol) saccharids
    1108          37 :       ratio_Fe2DOC_l     = 0.033_dbl_kind  ! Fe to C of DOC (nmol/umol) lipids
    1109          37 :       fr_resp            = 0.05_dbl_kind   ! frac of algal growth lost due to respiration
    1110          37 :       tau_min            = 5200.0_dbl_kind ! rapid mobile to stationary exchanges (s)
    1111          37 :       tau_max            = 1.73e5_dbl_kind ! long time mobile to stationary exchanges (s)
    1112          37 :       algal_vel          = 1.11e-8_dbl_kind! 0.5 cm/d(m/s) Lavoie 2005  1.5 cm/day
    1113          37 :       R_dFe2dust         = 0.035_dbl_kind  !  g/g (3.5% content) Tagliabue 2009
    1114          37 :       dustFe_sol         = 0.005_dbl_kind  ! solubility fraction
    1115          37 :       chlabs_diatoms     = 0.03_dbl_kind   ! chl absorption (1/m/(mg/m^3))
    1116          37 :       chlabs_sp          = 0.01_dbl_kind
    1117          37 :       chlabs_phaeo       = 0.05_dbl_kind
    1118          37 :       alpha2max_low_diatoms = 0.8_dbl_kind ! light limitation (1/(W/m^2))
    1119          37 :       alpha2max_low_sp      = 0.67_dbl_kind
    1120          37 :       alpha2max_low_phaeo   = 0.67_dbl_kind
    1121          37 :       beta2max_diatoms   = 0.018_dbl_kind  ! light inhibition (1/(W/m^2))
    1122          37 :       beta2max_sp        = 0.0025_dbl_kind
    1123          37 :       beta2max_phaeo     = 0.01_dbl_kind
    1124          37 :       mu_max_diatoms     = 1.2_dbl_kind    ! maximum growth rate (1/day)
    1125          37 :       mu_max_sp          = 0.851_dbl_kind
    1126          37 :       mu_max_phaeo       = 0.851_dbl_kind
    1127          37 :       grow_Tdep_diatoms  = 0.06_dbl_kind ! Temperature dependence of growth (1/C)
    1128          37 :       grow_Tdep_sp       = 0.06_dbl_kind
    1129          37 :       grow_Tdep_phaeo    = 0.06_dbl_kind
    1130          37 :       fr_graze_diatoms   = 0.01_dbl_kind ! Fraction grazed
    1131          37 :       fr_graze_sp        = p1
    1132          37 :       fr_graze_phaeo     = p1
    1133          37 :       mort_pre_diatoms   = 0.007_dbl_kind! Mortality (1/day)
    1134          37 :       mort_pre_sp        = 0.007_dbl_kind
    1135          37 :       mort_pre_phaeo     = 0.007_dbl_kind
    1136          37 :       mort_Tdep_diatoms  = 0.03_dbl_kind ! T dependence of mortality (1/C)
    1137          37 :       mort_Tdep_sp       = 0.03_dbl_kind
    1138          37 :       mort_Tdep_phaeo    = 0.03_dbl_kind
    1139          37 :       k_exude_diatoms    = c0            ! algal exudation (1/d)
    1140          37 :       k_exude_sp         = c0
    1141          37 :       k_exude_phaeo      = c0
    1142          37 :       K_Nit_diatoms      = c1            ! nitrate half saturation (mmol/m^3)
    1143          37 :       K_Nit_sp           = c1
    1144          37 :       K_Nit_phaeo        = c1
    1145          37 :       K_Am_diatoms       = 0.3_dbl_kind  ! ammonium half saturation (mmol/m^3)
    1146          37 :       K_Am_sp            = 0.3_dbl_kind
    1147          37 :       K_Am_phaeo         = 0.3_dbl_kind
    1148          37 :       K_Sil_diatoms      = 4.0_dbl_kind  ! silicate half saturation (mmol/m^3)
    1149          37 :       K_Sil_sp           = c0
    1150          37 :       K_Sil_phaeo        = c0
    1151          37 :       K_Fe_diatoms       = c1            ! iron half saturation (nM)
    1152          37 :       K_Fe_sp            = 0.2_dbl_kind
    1153          37 :       K_Fe_phaeo         = p1
    1154          37 :       f_don_protein      = 0.6_dbl_kind  ! fraction of spilled grazing to proteins
    1155          37 :       kn_bac_protein     = 0.03_dbl_kind ! Bacterial degredation of DON (1/d)
    1156          37 :       f_don_Am_protein   = 0.25_dbl_kind ! fraction of remineralized DON to ammonium
    1157          37 :       f_doc_s            = 0.4_dbl_kind  ! fraction of mortality to DOC
    1158          37 :       f_doc_l            = 0.4_dbl_kind
    1159          37 :       f_exude_s          = c1            ! fraction of exudation to DOC
    1160          37 :       f_exude_l          = c1
    1161          37 :       k_bac_s            = 0.03_dbl_kind ! Bacterial degredation of DOC (1/d)
    1162          37 :       k_bac_l            = 0.03_dbl_kind
    1163          37 :       T_max              = c0            ! maximum temperature (C)
    1164          37 :       fsal               = c1            ! Salinity limitation (ppt)
    1165          37 :       op_dep_min         = p1            ! Light attenuates for optical depths exceeding min
    1166          37 :       fr_graze_s         = p5            ! fraction of grazing spilled or slopped
    1167          37 :       fr_graze_e         = p5            ! fraction of assimilation excreted
    1168          37 :       fr_mort2min        = p5            ! fractionation of mortality to Am
    1169          37 :       fr_dFe             = 0.3_dbl_kind  ! fraction of remineralized nitrogen
    1170             :                                          ! (in units of algal iron)
    1171          37 :       k_nitrif           = c0            ! nitrification rate (1/day)
    1172          37 :       t_iron_conv        = 3065.0_dbl_kind ! desorption loss pFe to dFe (day)
    1173          37 :       max_loss           = 0.9_dbl_kind ! restrict uptake to % of remaining value
    1174          37 :       max_dfe_doc1       = 0.2_dbl_kind ! max ratio of dFe to saccharides in the ice
    1175             :                                          !(nM Fe/muM C)
    1176          37 :       fr_resp_s          = 0.75_dbl_kind ! DMSPd fraction of respiration loss as DMSPd
    1177          37 :       y_sk_DMS           = p5            ! fraction conversion given high yield
    1178          37 :       t_sk_conv          = 3.0_dbl_kind  ! Stefels conversion time (d)
    1179          37 :       t_sk_ox            = 10.0_dbl_kind ! DMS oxidation time (d)
    1180          37 :       algaltype_diatoms  = c0            ! ------------------
    1181          37 :       algaltype_sp       = p5            !
    1182          37 :       algaltype_phaeo    = p5            !
    1183          37 :       nitratetype        = -c1           ! mobility type between
    1184          37 :       ammoniumtype       = c1            ! stationary <-->  mobile
    1185          37 :       silicatetype       = -c1           !
    1186          37 :       dmspptype          = p5            !
    1187          37 :       dmspdtype          = -c1           !
    1188          37 :       humtype            = c1            !
    1189          37 :       doctype_s          = p5            !
    1190          37 :       doctype_l          = p5            !
    1191          37 :       dontype_protein    = p5            !
    1192          37 :       fedtype_1          = p5            !
    1193          37 :       feptype_1          = p5            !
    1194          37 :       zaerotype_bc1      = c1            !
    1195          37 :       zaerotype_bc2      = c1            !
    1196          37 :       zaerotype_dust1    = c1            !
    1197          37 :       zaerotype_dust2    = c1            !
    1198          37 :       zaerotype_dust3    = c1            !
    1199          37 :       zaerotype_dust4    = c1            !--------------------
    1200          37 :       ratio_C2N_diatoms  = 7.0_dbl_kind  ! algal C to N ratio (mol/mol)
    1201          37 :       ratio_C2N_sp       = 7.0_dbl_kind
    1202          37 :       ratio_C2N_phaeo    = 7.0_dbl_kind
    1203          37 :       ratio_chl2N_diatoms= 2.1_dbl_kind  ! algal chlorophyll to N ratio (mg/mmol)
    1204          37 :       ratio_chl2N_sp     = 1.1_dbl_kind
    1205          37 :       ratio_chl2N_phaeo  = 0.84_dbl_kind
    1206          37 :       F_abs_chl_diatoms  = 2.0_dbl_kind  ! scales absorbed radiation for dEdd
    1207          37 :       F_abs_chl_sp       = 4.0_dbl_kind
    1208          37 :       F_abs_chl_phaeo    = 5.0
    1209          37 :       ratio_C2N_proteins = 7.0_dbl_kind  ! ratio of C to N in proteins (mol/mol)
    1210             : 
    1211             :       ! z salinity  parameters
    1212          37 :       grid_oS         = c5            ! for bottom flux
    1213          37 :       l_skS           = 7.0_dbl_kind  ! characteristic diffusive scale (m)
    1214             : 
    1215             :       !-----------------------------------------------------------------
    1216             :       ! read from input file
    1217             :       !-----------------------------------------------------------------
    1218             : 
    1219          37 :       if (my_task == master_task) then
    1220           7 :          write(nu_diag,*) subname,' Reading zbgc_nml'
    1221             : 
    1222           7 :          call get_fileunit(nu_nml)
    1223           7 :          open (nu_nml, file=trim(nml_filename), status='old',iostat=nml_error)
    1224           7 :          if (nml_error /= 0) then
    1225             :             call abort_ice(subname//'ERROR: zbgc_nml open file '// &
    1226             :                trim(nml_filename), &   ! LCOV_EXCL_LINE
    1227           0 :                file=__FILE__, line=__LINE__)
    1228             :          endif
    1229             : 
    1230           7 :          nml_error =  1
    1231          14 :          do while (nml_error > 0)
    1232           7 :             read(nu_nml, nml=zbgc_nml,iostat=nml_error)
    1233             :          end do
    1234           7 :          if (nml_error /= 0) then
    1235             :             call abort_ice(subname//'ERROR: zbgc_nml reading ', &
    1236           0 :                file=__FILE__, line=__LINE__)
    1237             :          endif
    1238           7 :          close(nu_nml)
    1239           7 :          call release_fileunit(nu_nml)
    1240             :       endif
    1241             : 
    1242             :       !-----------------------------------------------------------------
    1243             :       ! broadcast
    1244             :       !-----------------------------------------------------------------
    1245             : 
    1246          37 :       call broadcast_scalar(solve_zsal,         master_task)
    1247          37 :       call broadcast_scalar(restart_zsal,       master_task)
    1248          37 :       call broadcast_scalar(tr_brine,           master_task)
    1249          37 :       call broadcast_scalar(restart_hbrine,     master_task)
    1250             : 
    1251          37 :       call broadcast_scalar(phi_snow,           master_task)
    1252          37 :       call broadcast_scalar(grid_oS,            master_task)
    1253          37 :       call broadcast_scalar(l_skS,              master_task)
    1254             : 
    1255          37 :       call broadcast_scalar(solve_zbgc,         master_task)
    1256          37 :       call broadcast_scalar(skl_bgc,            master_task)
    1257          37 :       call broadcast_scalar(restart_bgc,        master_task)
    1258          37 :       call broadcast_scalar(bgc_flux_type,      master_task)
    1259          37 :       call broadcast_scalar(restore_bgc,        master_task)
    1260          37 :       call broadcast_scalar(tr_bgc_N,           master_task)
    1261          37 :       call broadcast_scalar(tr_bgc_C,           master_task)
    1262          37 :       call broadcast_scalar(tr_bgc_chl,         master_task)
    1263          37 :       call broadcast_scalar(tr_bgc_Nit,         master_task)
    1264          37 :       call broadcast_scalar(tr_bgc_Am,          master_task)
    1265          37 :       call broadcast_scalar(tr_bgc_Sil,         master_task)
    1266          37 :       call broadcast_scalar(tr_bgc_hum,         master_task)
    1267          37 :       call broadcast_scalar(tr_bgc_DMS,         master_task)
    1268          37 :       call broadcast_scalar(tr_bgc_PON,         master_task)
    1269          37 :       call broadcast_scalar(tr_bgc_DON,         master_task)
    1270          37 :       call broadcast_scalar(tr_bgc_Fe,          master_task)
    1271             : 
    1272          37 :       call broadcast_scalar(z_tracers,          master_task)
    1273          37 :       call broadcast_scalar(tr_zaero,           master_task)
    1274          37 :       call broadcast_scalar(dEdd_algae,         master_task)
    1275          37 :       call broadcast_scalar(modal_aero,         master_task)
    1276          37 :       call broadcast_scalar(grid_o,             master_task)
    1277          37 :       call broadcast_scalar(grid_o_t,           master_task)
    1278          37 :       call broadcast_scalar(l_sk,               master_task)
    1279          37 :       call broadcast_scalar(scale_bgc,          master_task)
    1280          37 :       call broadcast_scalar(initbio_frac,       master_task)
    1281          37 :       call broadcast_scalar(frazil_scav,        master_task)
    1282          37 :       call broadcast_scalar(ratio_Si2N_diatoms, master_task)
    1283          37 :       call broadcast_scalar(ratio_Si2N_sp,      master_task)
    1284          37 :       call broadcast_scalar(ratio_Si2N_phaeo,   master_task)
    1285          37 :       call broadcast_scalar(ratio_S2N_diatoms,  master_task)
    1286          37 :       call broadcast_scalar(ratio_S2N_sp,       master_task)
    1287          37 :       call broadcast_scalar(ratio_S2N_phaeo,    master_task)
    1288          37 :       call broadcast_scalar(ratio_Fe2C_diatoms, master_task)
    1289          37 :       call broadcast_scalar(ratio_Fe2C_sp,      master_task)
    1290          37 :       call broadcast_scalar(ratio_Fe2C_phaeo,   master_task)
    1291          37 :       call broadcast_scalar(ratio_Fe2N_diatoms, master_task)
    1292          37 :       call broadcast_scalar(ratio_Fe2N_sp,      master_task)
    1293          37 :       call broadcast_scalar(ratio_Fe2N_phaeo,   master_task)
    1294          37 :       call broadcast_scalar(ratio_Fe2DON   ,    master_task)
    1295          37 :       call broadcast_scalar(ratio_Fe2DOC_s ,    master_task)
    1296          37 :       call broadcast_scalar(ratio_Fe2DOC_l ,    master_task)
    1297          37 :       call broadcast_scalar(fr_resp     ,       master_task)
    1298          37 :       call broadcast_scalar(tau_min  ,          master_task)
    1299          37 :       call broadcast_scalar(tau_max  ,          master_task)
    1300          37 :       call broadcast_scalar(algal_vel  ,        master_task)
    1301          37 :       call broadcast_scalar(R_dFe2dust ,        master_task)
    1302          37 :       call broadcast_scalar(dustFe_sol      ,   master_task)
    1303          37 :       call broadcast_scalar(chlabs_diatoms ,  master_task)
    1304          37 :       call broadcast_scalar(chlabs_sp      ,  master_task)
    1305          37 :       call broadcast_scalar(chlabs_phaeo     ,  master_task)
    1306          37 :       call broadcast_scalar(alpha2max_low_diatoms ,  master_task)
    1307          37 :       call broadcast_scalar(alpha2max_low_sp      ,  master_task)
    1308          37 :       call broadcast_scalar(alpha2max_low_phaeo   ,  master_task)
    1309          37 :       call broadcast_scalar(beta2max_diatoms ,  master_task)
    1310          37 :       call broadcast_scalar(beta2max_sp      ,  master_task)
    1311          37 :       call broadcast_scalar(beta2max_phaeo   ,  master_task)
    1312          37 :       call broadcast_scalar(mu_max_diatoms   ,  master_task)
    1313          37 :       call broadcast_scalar(mu_max_sp        ,  master_task)
    1314          37 :       call broadcast_scalar(mu_max_phaeo     ,  master_task)
    1315          37 :       call broadcast_scalar(grow_Tdep_diatoms,  master_task)
    1316          37 :       call broadcast_scalar(grow_Tdep_sp     ,  master_task)
    1317          37 :       call broadcast_scalar(grow_Tdep_phaeo  ,  master_task)
    1318          37 :       call broadcast_scalar(fr_graze_diatoms ,  master_task)
    1319          37 :       call broadcast_scalar(fr_graze_sp      ,  master_task)
    1320          37 :       call broadcast_scalar(fr_graze_phaeo   ,  master_task)
    1321          37 :       call broadcast_scalar(mort_pre_diatoms ,  master_task)
    1322          37 :       call broadcast_scalar(mort_pre_sp      ,  master_task)
    1323          37 :       call broadcast_scalar(mort_pre_phaeo   ,  master_task)
    1324          37 :       call broadcast_scalar(mort_Tdep_diatoms,  master_task)
    1325          37 :       call broadcast_scalar(mort_Tdep_sp     ,  master_task)
    1326          37 :       call broadcast_scalar(mort_Tdep_phaeo  ,  master_task)
    1327          37 :       call broadcast_scalar(k_exude_diatoms  ,  master_task)
    1328          37 :       call broadcast_scalar(k_exude_sp       ,  master_task)
    1329          37 :       call broadcast_scalar(k_exude_phaeo    ,  master_task)
    1330          37 :       call broadcast_scalar(K_Nit_diatoms    ,  master_task)
    1331          37 :       call broadcast_scalar(K_Nit_sp         ,  master_task)
    1332          37 :       call broadcast_scalar(K_Nit_phaeo      ,  master_task)
    1333          37 :       call broadcast_scalar(K_Am_diatoms     ,  master_task)
    1334          37 :       call broadcast_scalar(K_Am_sp          ,  master_task)
    1335          37 :       call broadcast_scalar(K_Am_phaeo       ,  master_task)
    1336          37 :       call broadcast_scalar(K_Sil_diatoms    ,  master_task)
    1337          37 :       call broadcast_scalar(K_Sil_sp         ,  master_task)
    1338          37 :       call broadcast_scalar(K_Sil_phaeo      ,  master_task)
    1339          37 :       call broadcast_scalar(K_Fe_diatoms     ,  master_task)
    1340          37 :       call broadcast_scalar(K_Fe_sp          ,  master_task)
    1341          37 :       call broadcast_scalar(K_Fe_phaeo       ,  master_task)
    1342          37 :       call broadcast_scalar(f_don_protein    ,  master_task)
    1343          37 :       call broadcast_scalar(kn_bac_protein   ,  master_task)
    1344          37 :       call broadcast_scalar(f_don_Am_protein ,  master_task)
    1345          37 :       call broadcast_scalar(f_doc_s          ,  master_task)
    1346          37 :       call broadcast_scalar(f_doc_l          ,  master_task)
    1347          37 :       call broadcast_scalar(f_exude_s        ,  master_task)
    1348          37 :       call broadcast_scalar(f_exude_l        ,  master_task)
    1349          37 :       call broadcast_scalar(k_bac_s          ,  master_task)
    1350          37 :       call broadcast_scalar(k_bac_l          ,  master_task)
    1351          37 :       call broadcast_scalar(T_max            ,  master_task)
    1352          37 :       call broadcast_scalar(fsal             ,  master_task)
    1353          37 :       call broadcast_scalar(op_dep_min       ,  master_task)
    1354          37 :       call broadcast_scalar(fr_graze_s       ,  master_task)
    1355          37 :       call broadcast_scalar(fr_graze_e       ,  master_task)
    1356          37 :       call broadcast_scalar(fr_mort2min      ,  master_task)
    1357          37 :       call broadcast_scalar(fr_dFe           ,  master_task)
    1358          37 :       call broadcast_scalar(k_nitrif         ,  master_task)
    1359          37 :       call broadcast_scalar(t_iron_conv      ,  master_task)
    1360          37 :       call broadcast_scalar(max_loss         ,  master_task)
    1361          37 :       call broadcast_scalar(max_dfe_doc1     ,  master_task)
    1362          37 :       call broadcast_scalar(fr_resp_s        ,  master_task)
    1363          37 :       call broadcast_scalar(y_sk_DMS         ,  master_task)
    1364          37 :       call broadcast_scalar(t_sk_conv        ,  master_task)
    1365          37 :       call broadcast_scalar(t_sk_ox          ,  master_task)
    1366          37 :       call broadcast_scalar(algaltype_diatoms,  master_task)
    1367          37 :       call broadcast_scalar(algaltype_sp       ,  master_task)
    1368          37 :       call broadcast_scalar(algaltype_phaeo    ,  master_task)
    1369          37 :       call broadcast_scalar(nitratetype        ,  master_task)
    1370          37 :       call broadcast_scalar(ammoniumtype       ,  master_task)
    1371          37 :       call broadcast_scalar(silicatetype       ,  master_task)
    1372          37 :       call broadcast_scalar(dmspptype          ,  master_task)
    1373          37 :       call broadcast_scalar(dmspdtype          ,  master_task)
    1374          37 :       call broadcast_scalar(humtype            ,  master_task)
    1375          37 :       call broadcast_scalar(doctype_s          ,  master_task)
    1376          37 :       call broadcast_scalar(doctype_l          ,  master_task)
    1377          37 :       call broadcast_scalar(dontype_protein    ,  master_task)
    1378          37 :       call broadcast_scalar(fedtype_1          ,  master_task)
    1379          37 :       call broadcast_scalar(feptype_1          ,  master_task)
    1380          37 :       call broadcast_scalar(zaerotype_bc1      ,  master_task)
    1381          37 :       call broadcast_scalar(zaerotype_bc2      ,  master_task)
    1382          37 :       call broadcast_scalar(zaerotype_dust1    ,  master_task)
    1383          37 :       call broadcast_scalar(zaerotype_dust2    ,  master_task)
    1384          37 :       call broadcast_scalar(zaerotype_dust3    ,  master_task)
    1385          37 :       call broadcast_scalar(zaerotype_dust4    ,  master_task)
    1386          37 :       call broadcast_scalar(ratio_C2N_diatoms  ,  master_task)
    1387          37 :       call broadcast_scalar(ratio_C2N_sp       ,  master_task)
    1388          37 :       call broadcast_scalar(ratio_C2N_phaeo    ,  master_task)
    1389          37 :       call broadcast_scalar(ratio_chl2N_diatoms,  master_task)
    1390          37 :       call broadcast_scalar(ratio_chl2N_sp     ,  master_task)
    1391          37 :       call broadcast_scalar(ratio_chl2N_phaeo  ,  master_task)
    1392          37 :       call broadcast_scalar(F_abs_chl_diatoms  ,  master_task)
    1393          37 :       call broadcast_scalar(F_abs_chl_sp       ,  master_task)
    1394          37 :       call broadcast_scalar(F_abs_chl_phaeo    ,  master_task)
    1395          37 :       call broadcast_scalar(ratio_C2N_proteins ,  master_task)
    1396             : 
    1397             :       !-----------------------------------------------------------------
    1398             :       ! zsalinity and brine
    1399             :       !-----------------------------------------------------------------
    1400             : 
    1401          37 :       if (.not.restart) then
    1402           8 :          if (my_task == master_task) &
    1403           1 :             write(nu_diag,*) subname//' WARNING: restart = false, setting bgc restart flags to false'
    1404           8 :          restart_bgc =  .false.
    1405           8 :          restart_hbrine =  .false.
    1406             :       endif
    1407             : 
    1408          37 :       if (solve_zsal)  then
    1409           0 :          if (my_task == master_task) then
    1410           0 :             write(nu_diag,*) subname,' ERROR: solve_zsal=T deprecated'
    1411             :          endif
    1412           0 :          abort_flag = 101
    1413             :       endif
    1414             : 
    1415          37 :       if (tr_brine .and. nblyr < 1 ) then
    1416           0 :          if (my_task == master_task) then
    1417           0 :             write(nu_diag,*) subname,' ERROR: tr_brine=T but no biology layers compiled'
    1418             :          endif
    1419           0 :          abort_flag = 103
    1420             :       endif
    1421             : 
    1422             :       !-----------------------------------------------------------------
    1423             :       ! biogeochemistry
    1424             :       !-----------------------------------------------------------------
    1425             : 
    1426          37 :       if (.not. tr_brine) then
    1427          37 :          if (solve_zbgc) then
    1428           0 :             if (my_task == master_task) then
    1429           0 :                write(nu_diag,*) subname,' ERROR: tr_brine = F and solve_zbgc = T'
    1430             :             endif
    1431           0 :             abort_flag = 104
    1432             :          endif
    1433          37 :          if (tr_zaero) then
    1434           0 :             if (my_task == master_task) then
    1435           0 :                write(nu_diag,*) subname,' ERROR: tr_brine = F and tr_zaero = T'
    1436             :             endif
    1437           0 :             abort_flag = 105
    1438             :          endif
    1439             :       endif
    1440             : 
    1441          37 :       if ((skl_bgc .AND. solve_zbgc) .or. (skl_bgc .AND. z_tracers)) then
    1442           0 :          if (my_task == master_task) then
    1443           0 :             write(nu_diag,*) subname,' ERROR: skl_bgc and solve_zbgc or z_tracers are both true'
    1444             :          endif
    1445           0 :          abort_flag = 106
    1446             :       endif
    1447             : 
    1448          37 :       if (skl_bgc .AND. tr_zaero) then
    1449           0 :          if (my_task == master_task) then
    1450           0 :             write(nu_diag,*) subname,' ERROR: skl_bgc does not use vertical tracers'
    1451             :          endif
    1452           0 :          abort_flag = 107
    1453             :       endif
    1454             : 
    1455          37 :       if (dEdd_algae .AND. shortwave(1:4) /= 'dEdd') then
    1456           0 :          if (my_task == master_task) then
    1457           0 :             write(nu_diag,*) subname,' ERROR: dEdd_algae = T but shortwave /= dEdd or dEdd_snicar_ad'
    1458             :          endif
    1459           0 :          abort_flag = 108
    1460             :       endif
    1461             : 
    1462          37 :       if (dEdd_algae .AND. (.NOT. tr_bgc_N) .AND. (.NOT. tr_zaero)) then
    1463           0 :          if (my_task == master_task) then
    1464           0 :             write(nu_diag,*) subname,' ERROR: need tr_bgc_N or tr_zaero for dEdd_algae'
    1465             :          endif
    1466           0 :          abort_flag = 109
    1467             :       endif
    1468             : 
    1469          37 :       if (modal_aero .AND. (.NOT. tr_zaero) .AND. (.NOT. tr_aero)) then
    1470           0 :          if (my_task == master_task) then
    1471           0 :             write(nu_diag,*) subname,' ERROR: modal_aero T with tr_zaero and tr_aero'
    1472             :          endif
    1473           0 :          abort_flag = 110
    1474             :       endif
    1475             : 
    1476          37 :       if (modal_aero .AND. shortwave(1:4) /= 'dEdd') then
    1477           0 :          if (my_task == master_task) then
    1478           0 :             write(nu_diag,*) subname,' ERROR: modal_aero = T but shortwave /= dEdd or dEdd_snicar_ad'
    1479             :          endif
    1480           0 :          abort_flag = 111
    1481             :       endif
    1482          37 :       if (n_algae > icepack_max_algae) then
    1483           0 :          if (my_task == master_task) then
    1484           0 :             write(nu_diag,*) subname//'ERROR: number of algal types exceeds icepack_max_algae'
    1485             :          endif
    1486           0 :          abort_flag = 112
    1487             :       endif
    1488          37 :       if (n_doc > icepack_max_doc) then
    1489           0 :          if (my_task == master_task) then
    1490           0 :             write(nu_diag,*) subname//'ERROR: number of doc types exceeds icepack_max_doc'
    1491             :          endif
    1492           0 :          abort_flag = 113
    1493             :       endif
    1494          37 :       if (n_dic > icepack_max_doc) then
    1495           0 :          if (my_task == master_task) then
    1496           0 :             write(nu_diag,*) subname//'ERROR: number of dic types exceeds icepack_max_dic'
    1497             :          endif
    1498           0 :          abort_flag = 114
    1499             :       endif
    1500          37 :       if (n_don > icepack_max_don) then
    1501           0 :          if (my_task == master_task) then
    1502           0 :             write(nu_diag,*) subname//'ERROR: number of don types exceeds icepack_max_don'
    1503             :          endif
    1504           0 :          abort_flag = 115
    1505             :       endif
    1506          37 :       if (n_fed  > icepack_max_fe ) then
    1507           0 :          if (my_task == master_task) then
    1508           0 :             write(nu_diag,*) subname//'ERROR: number of dissolved fe types exceeds icepack_max_fe '
    1509             :          endif
    1510           0 :          abort_flag = 116
    1511             :       endif
    1512          37 :       if (n_fep  > icepack_max_fe ) then
    1513           0 :          if (my_task == master_task) then
    1514           0 :             write(nu_diag,*) subname//'ERROR: number of particulate fe types exceeds icepack_max_fe '
    1515             :          endif
    1516           0 :          abort_flag = 117
    1517             :       endif
    1518             : 
    1519          37 :       if (n_algae == 0 .and. skl_bgc) then
    1520           0 :          if (my_task == master_task) then
    1521           0 :             write(nu_diag,*) subname//'ERROR: skl_bgc=T but 0 bgc or algal tracers compiled'
    1522             :          endif
    1523           0 :          abort_flag = 118
    1524             :       endif
    1525             : 
    1526          37 :       if (n_algae == 0 .and. solve_zbgc) then
    1527           0 :          if (my_task == master_task) then
    1528           0 :             write(nu_diag,*) subname//'ERROR: solve_zbgc=T but 0 zbgc or algal tracers compiled'
    1529             :          endif
    1530           0 :          abort_flag = 119
    1531             :       endif
    1532             : 
    1533          37 :       if (solve_zbgc .and. .not. z_tracers) then
    1534           0 :          if (my_task == master_task) then
    1535           0 :             write(nu_diag,*) subname//'ERROR: solve_zbgc=T but not z_tracers'
    1536             :          endif
    1537           0 :          abort_flag = 120
    1538             :       endif
    1539             : 
    1540          37 :       if (skl_bgc .or. solve_zbgc) then
    1541           0 :          if (.not. tr_bgc_N) then
    1542           0 :             if (my_task == master_task) then
    1543           0 :                write(nu_diag,*) subname//'ERROR: tr_bgc_N must be on for bgc'
    1544             :             endif
    1545           0 :             abort_flag = 121
    1546             :          endif
    1547           0 :          if (.not. tr_bgc_Nit) then
    1548           0 :             if (my_task == master_task) then
    1549           0 :                write(nu_diag,*) subname//'ERROR: tr_bgc_Nit must be on for bgc'
    1550             :             endif
    1551           0 :             abort_flag = 122
    1552             :          endif
    1553             :       else
    1554             :          ! tcraig, allow bgc to be turned off in this case?
    1555          37 :          tr_bgc_N         = .false.
    1556          37 :          tr_bgc_C         = .false.
    1557          37 :          tr_bgc_chl       = .false.
    1558          37 :          tr_bgc_Nit       = .false.
    1559          37 :          tr_bgc_Am        = .false.
    1560          37 :          tr_bgc_Sil       = .false.
    1561          37 :          tr_bgc_hum       = .false.
    1562          37 :          tr_bgc_DMS       = .false.
    1563          37 :          tr_bgc_PON       = .false.
    1564          37 :          tr_bgc_DON       = .false.
    1565          37 :          tr_bgc_Fe        = .false.
    1566             :       endif
    1567             : 
    1568             :       !-----------------------------------------------------------------
    1569             :       ! z layer aerosols
    1570             :       !-----------------------------------------------------------------
    1571          37 :       if (tr_zaero .and. .not. z_tracers) then
    1572           0 :          if (my_task == master_task) then
    1573           0 :             write(nu_diag,*) subname//'ERROR: tr_zaero and not z_tracers'
    1574             :          endif
    1575           0 :          abort_flag = 123
    1576             :       endif
    1577             : 
    1578          37 :       if (n_zaero > icepack_max_aero) then
    1579           0 :          if (my_task == master_task) then
    1580           0 :             write(nu_diag,*) subname//'ERROR: number of z aerosols exceeds icepack_max_aero'
    1581             :          endif
    1582           0 :          abort_flag = 124
    1583             :       endif
    1584             : 
    1585             :       !-----------------------------------------------------------------
    1586             :       ! output
    1587             :       !-----------------------------------------------------------------
    1588             : 
    1589          37 :       if (my_task == master_task) then
    1590           7 :          write(nu_diag,1010) ' tr_brine                  = ', tr_brine
    1591           7 :          if (tr_brine) then
    1592           0 :          write(nu_diag,1010) ' restart_hbrine            = ', restart_hbrine
    1593           0 :          write(nu_diag,1005) ' phi_snow                  = ', phi_snow
    1594             :          endif
    1595           7 :          write(nu_diag,1010) ' solve_zsal (deprecated)   = ', solve_zsal
    1596           7 :          write(nu_diag,*   ) '     WARNING: zsalinity has been deprecated.  Namelists and interfaces'
    1597           7 :          write(nu_diag,*   ) '              will be removed in a future version'
    1598             : 
    1599           7 :          write(nu_diag,1010) ' skl_bgc                   = ', skl_bgc
    1600           7 :          write(nu_diag,1010) ' restart_bgc               = ', restart_bgc
    1601           7 :          write(nu_diag,1010) ' tr_bgc_N                  = ', tr_bgc_N
    1602           7 :          write(nu_diag,1010) ' tr_bgc_C                  = ', tr_bgc_C
    1603           7 :          write(nu_diag,1010) ' tr_bgc_chl                = ', tr_bgc_chl
    1604           7 :          write(nu_diag,1010) ' tr_bgc_Nit                = ', tr_bgc_Nit
    1605           7 :          write(nu_diag,1010) ' tr_bgc_Am                 = ', tr_bgc_Am
    1606           7 :          write(nu_diag,1010) ' tr_bgc_Sil                = ', tr_bgc_Sil
    1607           7 :          write(nu_diag,1010) ' tr_bgc_hum                = ', tr_bgc_hum
    1608           7 :          write(nu_diag,1010) ' tr_bgc_DMS                = ', tr_bgc_DMS
    1609           7 :          write(nu_diag,1010) ' tr_bgc_PON                = ', tr_bgc_PON
    1610           7 :          write(nu_diag,1010) ' tr_bgc_DON                = ', tr_bgc_DON
    1611           7 :          write(nu_diag,1010) ' tr_bgc_Fe                 = ', tr_bgc_Fe
    1612           7 :          write(nu_diag,1020) ' n_aero                    = ', n_aero
    1613           7 :          write(nu_diag,1020) ' n_zaero                   = ', n_zaero
    1614           7 :          write(nu_diag,1020) ' n_algae                   = ', n_algae
    1615           7 :          write(nu_diag,1020) ' n_doc                     = ', n_doc
    1616           7 :          write(nu_diag,1020) ' n_dic                     = ', n_dic
    1617           7 :          write(nu_diag,1020) ' n_don                     = ', n_don
    1618           7 :          write(nu_diag,1020) ' n_fed                     = ', n_fed
    1619           7 :          write(nu_diag,1020) ' n_fep                     = ', n_fep
    1620             : 
    1621           7 :         if (skl_bgc) then
    1622             : 
    1623           0 :          write(nu_diag,1030) ' bgc_flux_type             = ', bgc_flux_type
    1624           0 :          write(nu_diag,1010) ' restore_bgc               = ', restore_bgc
    1625             : 
    1626           7 :         elseif (z_tracers) then
    1627             : 
    1628           0 :          write(nu_diag,1010) ' dEdd_algae                = ', dEdd_algae
    1629           0 :          write(nu_diag,1010) ' modal_aero                = ', modal_aero
    1630           0 :          write(nu_diag,1010) ' scale_bgc                 = ', scale_bgc
    1631           0 :          write(nu_diag,1010) ' solve_zbgc                = ', solve_zbgc
    1632           0 :          write(nu_diag,1010) ' tr_zaero                  = ', tr_zaero
    1633           0 :          write(nu_diag,1020) ' number of aerosols        = ', n_zaero
    1634             :          ! bio parameters
    1635           0 :          write(nu_diag,1000) ' grid_o                    = ', grid_o
    1636           0 :          write(nu_diag,1000) ' grid_o_t                  = ', grid_o_t
    1637           0 :          write(nu_diag,1005) ' l_sk                      = ', l_sk
    1638           0 :          write(nu_diag,1000) ' initbio_frac              = ', initbio_frac
    1639           0 :          write(nu_diag,1000) ' frazil_scav               = ', frazil_scav
    1640             : 
    1641             :         endif  ! skl_bgc or solve_bgc
    1642             :       endif
    1643             : 
    1644             :       !-----------------------------------------------------------------
    1645             :       ! abort if abort flag is set
    1646             :       !-----------------------------------------------------------------
    1647             : 
    1648          37 :       if (abort_flag /= 0) then
    1649           0 :         call flush_fileunit(nu_diag)
    1650             :       endif
    1651          37 :       call ice_barrier()
    1652          37 :       if (abort_flag /= 0) then
    1653           0 :          write(nu_diag,*) subname,' ERROR: abort_flag=',abort_flag
    1654             :          call abort_ice (subname//' ABORTING on input ERRORS', &
    1655           0 :             file=__FILE__, line=__LINE__)
    1656             :       endif
    1657             : 
    1658             :       !-----------------------------------------------------------------
    1659             :       ! set values in icepack
    1660             :       !-----------------------------------------------------------------
    1661             : 
    1662             :       call icepack_init_parameters( &
    1663             :           ktherm_in=ktherm, shortwave_in=shortwave, &   ! LCOV_EXCL_LINE
    1664             :           skl_bgc_in=skl_bgc, z_tracers_in=z_tracers, scale_bgc_in=scale_bgc, &   ! LCOV_EXCL_LINE
    1665             :           dEdd_algae_in=dEdd_algae, &   ! LCOV_EXCL_LINE
    1666             :           solve_zbgc_in=solve_zbgc, &   ! LCOV_EXCL_LINE
    1667             :           bgc_flux_type_in=bgc_flux_type, grid_o_in=grid_o, l_sk_in=l_sk, &   ! LCOV_EXCL_LINE
    1668             :           initbio_frac_in=initbio_frac, &   ! LCOV_EXCL_LINE
    1669             :           grid_oS_in=grid_oS, l_skS_in=l_skS, &   ! LCOV_EXCL_LINE
    1670             :           phi_snow_in=phi_snow, frazil_scav_in = frazil_scav, &   ! LCOV_EXCL_LINE
    1671          37 :           modal_aero_in=modal_aero)
    1672          37 :       call icepack_warnings_flush(nu_diag)
    1673          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
    1674           0 :           file=__FILE__, line=__LINE__)
    1675             : 
    1676             :       call icepack_init_tracer_flags(tr_brine_in=tr_brine, &
    1677             :          tr_bgc_Nit_in=tr_bgc_Nit, tr_bgc_Am_in =tr_bgc_Am,  tr_bgc_Sil_in=tr_bgc_Sil,   &   ! LCOV_EXCL_LINE
    1678             :          tr_bgc_DMS_in=tr_bgc_DMS, tr_bgc_PON_in=tr_bgc_PON, &   ! LCOV_EXCL_LINE
    1679             :          tr_bgc_N_in  =tr_bgc_N,   tr_bgc_C_in  =tr_bgc_C,   tr_bgc_chl_in=tr_bgc_chl,   &   ! LCOV_EXCL_LINE
    1680             :          tr_bgc_DON_in=tr_bgc_DON, tr_bgc_Fe_in =tr_bgc_Fe,  tr_zaero_in  =tr_zaero,     &   ! LCOV_EXCL_LINE
    1681          37 :          tr_bgc_hum_in=tr_bgc_hum)
    1682          37 :       call icepack_warnings_flush(nu_diag)
    1683          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
    1684           0 :           file=__FILE__, line=__LINE__)
    1685             : 
    1686             :  1000    format (a30,2x,f9.2)  ! a30 to align formatted, unformatted statements
    1687             :  1005    format (a30,2x,f9.6)  ! float
    1688             :  1010    format (a30,2x,l6)    ! logical
    1689             :  1020    format (a30,2x,i6)    ! integer
    1690             :  1030    format (a30,   a8)    ! character
    1691             :  1031    format (a30,   a )    ! character
    1692             : 
    1693          37 :       end subroutine input_zbgc
    1694             : 
    1695             : !=======================================================================
    1696             : 
    1697             : ! Count and index tracers
    1698             : !
    1699             : ! author Elizabeth C. Hunke, LANL
    1700             : 
    1701          37 :       subroutine count_tracers
    1702             : 
    1703             :       use ice_domain_size, only: nilyr, nslyr, nblyr, nfsd, n_iso, &
    1704             :           n_aero, n_zaero, n_algae, n_doc, n_dic, n_don, n_fed, n_fep
    1705             : 
    1706             :       ! local variables
    1707             : 
    1708             :       integer (kind=int_kind) :: &
    1709             :          k, mm    , & ! loop index   ! LCOV_EXCL_LINE
    1710             :          nk       , & ! layer index   ! LCOV_EXCL_LINE
    1711             :          nk_bgc       ! layer index
    1712             : 
    1713             :       integer (kind=int_kind) :: ntrcr
    1714             :       logical (kind=log_kind) :: tr_iage, tr_FY, tr_lvl, tr_pond, tr_aero, tr_fsd
    1715             :       logical (kind=log_kind) :: tr_snow
    1716             :       logical (kind=log_kind) :: tr_iso, tr_pond_lvl, tr_pond_topo
    1717             :       integer (kind=int_kind) :: nt_Tsfc, nt_sice, nt_qice, nt_qsno, nt_iage, nt_FY
    1718             :       integer (kind=int_kind) :: nt_alvl, nt_vlvl, nt_apnd, nt_hpnd, nt_ipnd, nt_aero
    1719             :       integer (kind=int_kind) :: nt_fsd, nt_isosno, nt_isoice
    1720             :       integer (kind=int_kind) :: nt_smice, nt_smliq, nt_rhos, nt_rsnw
    1721             : 
    1722             :       integer (kind=int_kind) :: &
    1723             :          nbtrcr,        nbtrcr_sw,     &   ! LCOV_EXCL_LINE
    1724             :          ntrcr_o,       nt_fbri,       &   ! LCOV_EXCL_LINE
    1725             :          nt_bgc_Nit,    nt_bgc_Am,     nt_bgc_Sil,   &   ! LCOV_EXCL_LINE
    1726             :          nt_bgc_DMS,    nt_bgc_PON,    &   ! LCOV_EXCL_LINE
    1727             :          nt_bgc_DMSPp,  nt_bgc_DMSPd,  &   ! LCOV_EXCL_LINE
    1728             :          nt_zbgc_frac,  nlt_chl_sw,    &   ! LCOV_EXCL_LINE
    1729             :          nlt_bgc_Nit,   nlt_bgc_Am,    nlt_bgc_Sil, &   ! LCOV_EXCL_LINE
    1730             :          nlt_bgc_DMS,   nlt_bgc_DMSPp, nlt_bgc_DMSPd, &   ! LCOV_EXCL_LINE
    1731             :          nlt_bgc_PON,   nt_bgc_hum,    nlt_bgc_hum
    1732             : 
    1733             :       integer (kind=int_kind), dimension(icepack_max_aero) :: &
    1734             :          nlt_zaero_sw       ! points to aerosol in trcrn_sw
    1735             : 
    1736             :       integer (kind=int_kind), dimension(icepack_max_algae) :: &
    1737             :          nlt_bgc_N      , & ! algae   ! LCOV_EXCL_LINE
    1738             :          nlt_bgc_chl
    1739             : 
    1740             :       integer (kind=int_kind), dimension(icepack_max_doc) :: &
    1741             :          nlt_bgc_DOC        ! disolved organic carbon
    1742             : 
    1743             :       integer (kind=int_kind), dimension(icepack_max_don) :: &
    1744             :          nlt_bgc_DON        !
    1745             : 
    1746             :       integer (kind=int_kind), dimension(icepack_max_dic) :: &
    1747             :          nlt_bgc_DIC        ! disolved inorganic carbon
    1748             : 
    1749             :       integer (kind=int_kind), dimension(icepack_max_fe) :: &
    1750             :          nlt_bgc_Fed    , & !   ! LCOV_EXCL_LINE
    1751             :          nlt_bgc_Fep        !
    1752             : 
    1753             :       integer (kind=int_kind), dimension(icepack_max_aero) :: &
    1754             :          nlt_zaero          ! non-reacting layer aerosols
    1755             : 
    1756             :       integer (kind=int_kind), dimension(icepack_max_algae) :: &
    1757             :          nt_bgc_N , & ! diatoms, phaeocystis, pico/small   ! LCOV_EXCL_LINE
    1758             :          nt_bgc_chl   ! diatoms, phaeocystis, pico/small
    1759             : 
    1760             :       integer (kind=int_kind), dimension(icepack_max_doc) :: &
    1761             :          nt_bgc_DOC      !  dissolved organic carbon
    1762             : 
    1763             :       integer (kind=int_kind), dimension(icepack_max_don) :: &
    1764             :          nt_bgc_DON         !  dissolved organic nitrogen
    1765             : 
    1766             :       integer (kind=int_kind), dimension(icepack_max_dic) :: &
    1767             :          nt_bgc_DIC         !  dissolved inorganic carbon
    1768             : 
    1769             :       integer (kind=int_kind), dimension(icepack_max_fe) :: &
    1770             :          nt_bgc_Fed,     & !  dissolved iron   ! LCOV_EXCL_LINE
    1771             :          nt_bgc_Fep        !  particulate iron
    1772             : 
    1773             :       integer (kind=int_kind), dimension(icepack_max_aero) :: &
    1774             :          nt_zaero       !  black carbon and other aerosols
    1775             : 
    1776             :       logical (kind=log_kind) :: &
    1777             :           tr_brine, &   ! LCOV_EXCL_LINE
    1778             :           tr_bgc_Nit,    tr_bgc_Am,    tr_bgc_Sil,   &   ! LCOV_EXCL_LINE
    1779             :           tr_bgc_DMS,    tr_bgc_PON,   &   ! LCOV_EXCL_LINE
    1780             :           tr_bgc_N,      tr_bgc_C,     tr_bgc_chl,   &   ! LCOV_EXCL_LINE
    1781             :           tr_bgc_DON,    tr_bgc_Fe,    tr_zaero,     &   ! LCOV_EXCL_LINE
    1782             :           tr_bgc_hum
    1783             : 
    1784             :       logical (kind=log_kind) :: &
    1785             :           skl_bgc, z_tracers
    1786             : 
    1787             :       character(len=*), parameter :: subname='(count_tracers)'
    1788             : 
    1789             :       !-----------------------------------------------------------------
    1790             : 
    1791             :       call icepack_query_parameters( &
    1792          37 :           skl_bgc_out=skl_bgc, z_tracers_out=z_tracers)
    1793             : 
    1794          37 :       call icepack_warnings_flush(nu_diag)
    1795          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
    1796           0 :           file=__FILE__, line=__LINE__)
    1797             : 
    1798             :       call icepack_query_tracer_flags(tr_iage_out=tr_iage, tr_FY_out=tr_FY, &
    1799             :          tr_lvl_out=tr_lvl, tr_aero_out=tr_aero, tr_pond_out=tr_pond, &   ! LCOV_EXCL_LINE
    1800             :          tr_pond_lvl_out=tr_pond_lvl, &   ! LCOV_EXCL_LINE
    1801             :          tr_pond_topo_out=tr_pond_topo, tr_brine_out=tr_brine, tr_fsd_out=tr_fsd, &   ! LCOV_EXCL_LINE
    1802             :          tr_snow_out=tr_snow, tr_iso_out=tr_iso, &   ! LCOV_EXCL_LINE
    1803             :          tr_bgc_Nit_out=tr_bgc_Nit, tr_bgc_Am_out =tr_bgc_Am,  tr_bgc_Sil_out=tr_bgc_Sil,   &   ! LCOV_EXCL_LINE
    1804             :          tr_bgc_DMS_out=tr_bgc_DMS, tr_bgc_PON_out=tr_bgc_PON, &   ! LCOV_EXCL_LINE
    1805             :          tr_bgc_N_out  =tr_bgc_N,   tr_bgc_C_out  =tr_bgc_C,   tr_bgc_chl_out=tr_bgc_chl,   &   ! LCOV_EXCL_LINE
    1806             :          tr_bgc_DON_out=tr_bgc_DON, tr_bgc_Fe_out =tr_bgc_Fe,  tr_zaero_out  =tr_zaero,     &   ! LCOV_EXCL_LINE
    1807          37 :          tr_bgc_hum_out=tr_bgc_hum)
    1808          37 :       call icepack_warnings_flush(nu_diag)
    1809          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
    1810           0 :           file=__FILE__, line=__LINE__)
    1811             : 
    1812          37 :       ntrcr = 0
    1813             : 
    1814          37 :       ntrcr = ntrcr + 1             ! count tracers, starting with Tsfc = 1
    1815          37 :       nt_Tsfc = ntrcr               ! index tracers, starting with Tsfc = 1
    1816             : 
    1817          37 :       nt_qice = ntrcr + 1
    1818          37 :       ntrcr = ntrcr + nilyr ! qice in nilyr layers
    1819             : 
    1820          37 :       nt_qsno = ntrcr + 1
    1821          37 :       ntrcr = ntrcr + nslyr ! qsno in nslyr layers
    1822             : 
    1823          37 :       nt_sice = ntrcr + 1
    1824          37 :       ntrcr = ntrcr + nilyr ! sice in nilyr layers
    1825             : 
    1826          37 :       nt_iage = 0
    1827          37 :       if (tr_iage) then
    1828          37 :           ntrcr = ntrcr + 1
    1829          37 :           nt_iage = ntrcr   ! chronological ice age
    1830             :       endif
    1831             : 
    1832          37 :       nt_FY = 0
    1833          37 :       if (tr_FY) then
    1834          37 :           ntrcr = ntrcr + 1
    1835          37 :           nt_FY = ntrcr     ! area of first year ice
    1836             :       endif
    1837             : 
    1838          37 :       nt_alvl = 0
    1839          37 :       nt_vlvl = 0
    1840          37 :       if (tr_lvl) then
    1841          37 :           ntrcr = ntrcr + 1
    1842          37 :           nt_alvl = ntrcr
    1843          37 :           ntrcr = ntrcr + 1
    1844          37 :           nt_vlvl = ntrcr
    1845             :       endif
    1846             : 
    1847          37 :       nt_apnd = 0
    1848          37 :       nt_hpnd = 0
    1849          37 :       nt_ipnd = 0
    1850          37 :       if (tr_pond) then            ! all explicit melt pond schemes
    1851          37 :           ntrcr = ntrcr + 1
    1852          37 :           nt_apnd = ntrcr
    1853          37 :           ntrcr = ntrcr + 1
    1854          37 :           nt_hpnd = ntrcr
    1855          37 :           if (tr_pond_lvl) then
    1856          37 :               ntrcr = ntrcr + 1    ! refrozen pond ice lid thickness
    1857          37 :               nt_ipnd = ntrcr      ! on level-ice ponds (if frzpnd='hlid')
    1858             :           endif
    1859          37 :           if (tr_pond_topo) then
    1860           0 :               ntrcr = ntrcr + 1    !
    1861           0 :               nt_ipnd = ntrcr      ! refrozen pond ice lid thickness
    1862             :           endif
    1863             :       endif
    1864             : 
    1865          37 :       nt_smice = 0
    1866          37 :       nt_smliq = 0
    1867          37 :       nt_rhos = 0
    1868          37 :       nt_rsnw = 0
    1869          37 :       if (tr_snow) then
    1870           0 :          nt_smice = ntrcr + 1
    1871           0 :          ntrcr = ntrcr + nslyr     ! mass of ice in nslyr snow layers
    1872           0 :          nt_smliq = ntrcr + 1
    1873           0 :          ntrcr = ntrcr + nslyr     ! mass of liquid in nslyr snow layers
    1874           0 :          nt_rhos = ntrcr + 1
    1875           0 :          ntrcr = ntrcr + nslyr     ! snow density in nslyr layers
    1876           0 :          nt_rsnw = ntrcr + 1
    1877           0 :          ntrcr = ntrcr + nslyr     ! snow grain radius in nslyr layers
    1878             :       endif
    1879             : 
    1880          37 :       nt_fsd = 0
    1881          37 :       if (tr_fsd) then
    1882           0 :           nt_fsd = ntrcr + 1       ! floe size distribution
    1883           0 :           ntrcr = ntrcr + nfsd
    1884             :       endif
    1885             : 
    1886          37 :       nt_isosno = 0
    1887          37 :       nt_isoice = 0
    1888          37 :       if (tr_iso) then
    1889           0 :           nt_isosno = ntrcr + 1    ! isotopes in snow
    1890           0 :           ntrcr = ntrcr + n_iso
    1891           0 :           nt_isoice = ntrcr + 1    ! isotopes in ice
    1892           0 :           ntrcr = ntrcr + n_iso
    1893             :       endif
    1894             : 
    1895          37 :       nt_aero = 0
    1896          37 :       if (tr_aero) then
    1897           0 :           nt_aero = ntrcr + 1
    1898           0 :           ntrcr = ntrcr + 4*n_aero ! 4 dEdd layers, n_aero species
    1899             :       else
    1900             : !tcx, modify code so we don't have to reset n_aero here
    1901          37 :           n_aero = 0       !echmod - this is not getting set correctly (overwritten later?)
    1902             :       endif
    1903             : 
    1904             :       !-----------------------------------------------------------------
    1905             :       ! initialize zbgc tracer indices
    1906             :       !-----------------------------------------------------------------
    1907             : 
    1908          37 :       nbtrcr = 0
    1909          37 :       nbtrcr_sw = 0
    1910          37 :       nt_zbgc_frac = 0
    1911             : 
    1912             :       ! vectors of size icepack_max_algae
    1913          37 :       nlt_bgc_N(:) = 0
    1914          37 :       nlt_bgc_chl(:) = 0
    1915          37 :       nt_bgc_N(:) = 0
    1916          37 :       nt_bgc_chl(:) = 0
    1917             : 
    1918             :       ! vectors of size icepack_max_dic
    1919          37 :       nlt_bgc_DIC(:) = 0
    1920          37 :       nt_bgc_DIC(:) = 0
    1921             : 
    1922             :       ! vectors of size icepack_max_doc
    1923          37 :       nlt_bgc_DOC(:) = 0
    1924          37 :       nt_bgc_DOC(:) = 0
    1925             : 
    1926             :       ! vectors of size icepack_max_don
    1927          37 :       nlt_bgc_DON(:) = 0
    1928          37 :       nt_bgc_DON(:) = 0
    1929             : 
    1930             :       ! vectors of size icepack_max_fe
    1931          37 :       nlt_bgc_Fed(:) = 0
    1932          37 :       nlt_bgc_Fep(:) = 0
    1933          37 :       nt_bgc_Fed(:) = 0
    1934          37 :       nt_bgc_Fep(:) = 0
    1935             : 
    1936             :       ! vectors of size icepack_max_aero
    1937          37 :       nlt_zaero(:) = 0
    1938          37 :       nlt_zaero_sw(:) = 0
    1939          37 :       nt_zaero(:) = 0
    1940             : 
    1941          37 :       nlt_bgc_Nit    = 0
    1942          37 :       nlt_bgc_Am     = 0
    1943          37 :       nlt_bgc_Sil    = 0
    1944          37 :       nlt_bgc_DMSPp  = 0
    1945          37 :       nlt_bgc_DMSPd  = 0
    1946          37 :       nlt_bgc_DMS    = 0
    1947          37 :       nlt_bgc_PON    = 0
    1948          37 :       nlt_bgc_hum    = 0
    1949             : !      nlt_bgc_C      = 0
    1950          37 :       nlt_chl_sw     = 0
    1951             : 
    1952          37 :       nt_bgc_Nit    = 0
    1953          37 :       nt_bgc_Am     = 0
    1954          37 :       nt_bgc_Sil    = 0
    1955          37 :       nt_bgc_DMSPp  = 0
    1956          37 :       nt_bgc_DMSPd  = 0
    1957          37 :       nt_bgc_DMS    = 0
    1958          37 :       nt_bgc_PON    = 0
    1959          37 :       nt_bgc_hum    = 0
    1960             : !      nt_bgc_C      = 0
    1961             : 
    1962          37 :       ntrcr_o = ntrcr
    1963          37 :       nt_fbri = 0
    1964          37 :       if (tr_brine) then
    1965           0 :           nt_fbri = ntrcr + 1   ! ice volume fraction with salt
    1966           0 :           ntrcr = ntrcr + 1
    1967             :       endif
    1968             : 
    1969          37 :       if (skl_bgc .or. z_tracers) then
    1970             : 
    1971           0 :          if (skl_bgc) then
    1972           0 :             nk = 1
    1973           0 :          elseif (z_tracers) then ! defined on nblyr+1 in ice
    1974             :                                  ! and 2 snow layers (snow surface + interior)
    1975           0 :             nk = nblyr + 1
    1976             :          endif ! skl_bgc or z_tracers
    1977           0 :          nk_bgc = nk                 ! number of bgc layers in ice
    1978           0 :          if (nk > 1) nk_bgc = nk + 2 ! number of bgc layers in ice and snow
    1979             : 
    1980             :          !-----------------------------------------------------------------
    1981             :          ! count tracers and assign tracer indices
    1982             :          !-----------------------------------------------------------------
    1983             : 
    1984           0 :          if (tr_bgc_N) then
    1985           0 :             do mm = 1, n_algae
    1986           0 :                nt_bgc_N(mm) = ntrcr + 1
    1987           0 :                do k = 1, nk_bgc
    1988           0 :                   ntrcr = ntrcr + 1
    1989             :                enddo
    1990           0 :                nbtrcr = nbtrcr + 1
    1991           0 :                nlt_bgc_N(mm) = nbtrcr
    1992             :             enddo   ! mm
    1993             :          endif ! tr_bgc_N
    1994             : 
    1995           0 :          if (tr_bgc_Nit) then
    1996           0 :             nt_bgc_Nit = ntrcr + 1
    1997           0 :             do k = 1, nk_bgc
    1998           0 :                ntrcr = ntrcr + 1
    1999             :             enddo
    2000           0 :             nbtrcr = nbtrcr + 1
    2001           0 :             nlt_bgc_Nit = nbtrcr
    2002             :          endif ! tr_bgc_Nit
    2003             : 
    2004           0 :          if (tr_bgc_C) then
    2005             :           !
    2006             :           ! Algal C is not yet distinct from algal N
    2007             :           ! * Reqires exudation and/or changing C:N ratios
    2008             :           ! for implementation
    2009             :           !
    2010             :           !  do mm = 1,n_algae
    2011             :           !     nt_bgc_C(mm) = ntrcr + 1
    2012             :           !     do k = 1, nk_bgc
    2013             :           !        ntrcr = ntrcr + 1
    2014             :           !     enddo
    2015             :           !     nbtrcr = nbtrcr + 1
    2016             :           !     nlt_bgc_C(mm) = nbtrcr
    2017             :           !  enddo   ! mm
    2018             : 
    2019           0 :             do mm = 1, n_doc
    2020           0 :                nt_bgc_DOC(mm) = ntrcr + 1
    2021           0 :                do k = 1, nk_bgc
    2022           0 :                   ntrcr = ntrcr + 1
    2023             :                enddo
    2024           0 :                nbtrcr = nbtrcr + 1
    2025           0 :                nlt_bgc_DOC(mm) = nbtrcr
    2026             :             enddo   ! mm
    2027           0 :             do mm = 1, n_dic
    2028           0 :                nt_bgc_DIC(mm) = ntrcr + 1
    2029           0 :                do k = 1, nk_bgc
    2030           0 :                   ntrcr = ntrcr + 1
    2031             :                enddo
    2032           0 :                nbtrcr = nbtrcr + 1
    2033           0 :                nlt_bgc_DIC(mm) = nbtrcr
    2034             :             enddo   ! mm
    2035             :          endif      ! tr_bgc_C
    2036             : 
    2037           0 :          if (tr_bgc_chl) then
    2038           0 :             do mm = 1, n_algae
    2039           0 :                nt_bgc_chl(mm) = ntrcr + 1
    2040           0 :                do k = 1, nk_bgc
    2041           0 :                   ntrcr = ntrcr + 1
    2042             :                enddo
    2043           0 :                nbtrcr = nbtrcr + 1
    2044           0 :                nlt_bgc_chl(mm) = nbtrcr
    2045             :             enddo   ! mm
    2046             :          endif      ! tr_bgc_chl
    2047             : 
    2048           0 :          if (tr_bgc_Am) then
    2049           0 :             nt_bgc_Am = ntrcr + 1
    2050           0 :             do k = 1, nk_bgc
    2051           0 :                ntrcr = ntrcr + 1
    2052             :             enddo
    2053           0 :             nbtrcr = nbtrcr + 1
    2054           0 :             nlt_bgc_Am = nbtrcr
    2055             :          endif
    2056           0 :          if (tr_bgc_Sil) then
    2057           0 :             nt_bgc_Sil = ntrcr + 1
    2058           0 :             do k = 1, nk_bgc
    2059           0 :                ntrcr = ntrcr + 1
    2060             :             enddo
    2061           0 :             nbtrcr = nbtrcr + 1
    2062           0 :             nlt_bgc_Sil = nbtrcr
    2063             :          endif
    2064             : 
    2065           0 :          if (tr_bgc_DMS) then   ! all together
    2066           0 :             nt_bgc_DMSPp = ntrcr + 1
    2067           0 :             do k = 1, nk_bgc
    2068           0 :                ntrcr = ntrcr + 1
    2069             :             enddo
    2070           0 :             nbtrcr = nbtrcr + 1
    2071           0 :             nlt_bgc_DMSPp = nbtrcr
    2072             : 
    2073           0 :             nt_bgc_DMSPd = ntrcr + 1
    2074           0 :             do k = 1, nk_bgc
    2075           0 :                ntrcr = ntrcr + 1
    2076             :             enddo
    2077           0 :             nbtrcr = nbtrcr + 1
    2078           0 :             nlt_bgc_DMSPd = nbtrcr
    2079             : 
    2080           0 :             nt_bgc_DMS = ntrcr + 1
    2081           0 :             do k = 1, nk_bgc
    2082           0 :                ntrcr = ntrcr + 1
    2083             :             enddo
    2084           0 :             nbtrcr = nbtrcr + 1
    2085           0 :             nlt_bgc_DMS = nbtrcr
    2086             :          endif
    2087             : 
    2088           0 :          if (tr_bgc_PON) then
    2089           0 :             nt_bgc_PON = ntrcr + 1
    2090           0 :             do k = 1, nk_bgc
    2091           0 :                ntrcr = ntrcr + 1
    2092             :             enddo
    2093           0 :             nbtrcr = nbtrcr + 1
    2094           0 :             nlt_bgc_PON = nbtrcr
    2095             :          endif
    2096             : 
    2097           0 :          if (tr_bgc_DON) then
    2098           0 :             do mm = 1, n_don
    2099           0 :                nt_bgc_DON(mm) = ntrcr + 1
    2100           0 :                do k = 1, nk_bgc
    2101           0 :                   ntrcr = ntrcr + 1
    2102             :                enddo
    2103           0 :                nbtrcr = nbtrcr + 1
    2104           0 :                nlt_bgc_DON(mm) = nbtrcr
    2105             :             enddo   ! mm
    2106             :          endif      ! tr_bgc_DON
    2107             : 
    2108           0 :          if (tr_bgc_Fe) then
    2109           0 :             do mm = 1, n_fed
    2110           0 :                nt_bgc_Fed(mm) = ntrcr + 1
    2111           0 :                do k = 1, nk_bgc
    2112           0 :                   ntrcr = ntrcr + 1
    2113             :                enddo
    2114           0 :                nbtrcr = nbtrcr + 1
    2115           0 :                nlt_bgc_Fed(mm) = nbtrcr
    2116             :             enddo   ! mm
    2117           0 :             do mm = 1, n_fep
    2118           0 :                nt_bgc_Fep(mm) = ntrcr + 1
    2119           0 :                do k = 1, nk_bgc
    2120           0 :                   ntrcr = ntrcr + 1
    2121             :                enddo
    2122           0 :                nbtrcr = nbtrcr + 1
    2123           0 :                nlt_bgc_Fep(mm) = nbtrcr
    2124             :             enddo   ! mm
    2125             :          endif      ! tr_bgc_Fe
    2126             : 
    2127           0 :          if (tr_bgc_hum) then
    2128           0 :             nt_bgc_hum = ntrcr + 1
    2129           0 :             do k = 1, nk_bgc
    2130           0 :                ntrcr = ntrcr + 1
    2131             :             enddo
    2132           0 :             nbtrcr = nbtrcr + 1
    2133           0 :             nlt_bgc_hum = nbtrcr
    2134             :          endif
    2135             : 
    2136             :       endif ! skl_bgc .or. z_tracers
    2137             : 
    2138          37 :       if (z_tracers) then ! defined on nblyr+1 in ice
    2139             :                           ! and 2 snow layers (snow surface + interior)
    2140             :          ! z layer aerosols
    2141           0 :          if (tr_zaero) then
    2142           0 :             do mm = 1, n_zaero
    2143           0 :                nt_zaero(mm) = ntrcr + 1
    2144           0 :                do k = 1, nk_bgc
    2145           0 :                   ntrcr = ntrcr + 1
    2146             :                enddo
    2147           0 :                nbtrcr = nbtrcr + 1
    2148           0 :                nlt_zaero(mm) = nbtrcr
    2149             :             enddo   ! mm
    2150             :          endif      ! tr_zaero
    2151             : 
    2152           0 :          if (nbtrcr > 0) then
    2153           0 :             nt_zbgc_frac = ntrcr + 1
    2154           0 :             ntrcr = ntrcr + nbtrcr
    2155             :          endif
    2156             :       endif ! z_tracers
    2157             : 
    2158             : !tcx, +1 here is the unused tracer, want to get rid of it
    2159          37 :       ntrcr = ntrcr + 1
    2160             : 
    2161             : !tcx, reset unused tracer index, eventually get rid of it.
    2162          37 :       if (nt_iage  <= 0) nt_iage  = ntrcr
    2163          37 :       if (nt_FY    <= 0) nt_FY    = ntrcr
    2164          37 :       if (nt_alvl  <= 0) nt_alvl  = ntrcr
    2165          37 :       if (nt_vlvl  <= 0) nt_vlvl  = ntrcr
    2166          37 :       if (nt_apnd  <= 0) nt_apnd  = ntrcr
    2167          37 :       if (nt_hpnd  <= 0) nt_hpnd  = ntrcr
    2168          37 :       if (nt_ipnd  <= 0) nt_ipnd  = ntrcr
    2169          37 :       if (nt_smice <= 0) nt_smice = ntrcr
    2170          37 :       if (nt_smliq <= 0) nt_smliq = ntrcr
    2171          37 :       if (nt_rhos  <= 0) nt_rhos  = ntrcr
    2172          37 :       if (nt_rsnw  <= 0) nt_rsnw  = ntrcr
    2173          37 :       if (nt_fsd   <= 0) nt_fsd   = ntrcr
    2174          37 :       if (nt_isosno<= 0) nt_isosno= ntrcr
    2175          37 :       if (nt_isoice<= 0) nt_isoice= ntrcr
    2176          37 :       if (nt_aero  <= 0) nt_aero  = ntrcr
    2177          37 :       if (nt_fbri  <= 0) nt_fbri  = ntrcr
    2178             : !      if (nt_bgc_S <= 0) nt_bgc_S = ntrcr
    2179             : 
    2180          37 :       if (my_task == master_task) then
    2181           7 :          write(nu_diag,*) ' '
    2182           7 :          write(nu_diag,1020) ' ntrcr                     = ', ntrcr
    2183           7 :          write(nu_diag,1020) ' nbtrcr                    = ', nbtrcr
    2184           7 :          write(nu_diag,1020) ' nbtrcr_sw                 = ', nbtrcr_sw
    2185           7 :          write(nu_diag,*) ' '
    2186           7 :          write(nu_diag,1020) ' nt_sice                   = ', nt_sice
    2187           7 :          write(nu_diag,1020) ' nt_qice                   = ', nt_qice
    2188           7 :          write(nu_diag,1020) ' nt_qsno                   = ', nt_qsno
    2189           7 :          write(nu_diag,*)' '
    2190             :  1020    format (a30,2x,i6)     ! integer
    2191           7 :          call flush_fileunit(nu_diag)
    2192             :       endif                     ! my_task = master_task
    2193             :       call icepack_init_tracer_sizes(ntrcr_in=ntrcr, &
    2194          37 :          ntrcr_o_in=ntrcr_o, nbtrcr_in=nbtrcr, nbtrcr_sw_in=nbtrcr_sw)
    2195             :       call icepack_init_tracer_indices(nt_Tsfc_in=nt_Tsfc, nt_sice_in=nt_sice, &
    2196             :          nt_qice_in=nt_qice, nt_qsno_in=nt_qsno, nt_iage_in=nt_iage, nt_fy_in=nt_fy, &   ! LCOV_EXCL_LINE
    2197             :          nt_alvl_in=nt_alvl, nt_vlvl_in=nt_vlvl, nt_apnd_in=nt_apnd, nt_hpnd_in=nt_hpnd, &   ! LCOV_EXCL_LINE
    2198             :          nt_ipnd_in=nt_ipnd, nt_fsd_in=nt_fsd, nt_aero_in=nt_aero, &   ! LCOV_EXCL_LINE
    2199             :          nt_smice_in=nt_smice, nt_smliq_in=nt_smliq, nt_rhos_in=nt_rhos, nt_rsnw_in=nt_rsnw, &   ! LCOV_EXCL_LINE
    2200             :          nt_isosno_in=nt_isosno,     nt_isoice_in=nt_isoice,       nt_fbri_in=nt_fbri,      &   ! LCOV_EXCL_LINE
    2201             :          nt_bgc_Nit_in=nt_bgc_Nit,   nt_bgc_Am_in=nt_bgc_Am,       nt_bgc_Sil_in=nt_bgc_Sil,   &   ! LCOV_EXCL_LINE
    2202             :          nt_bgc_DMS_in=nt_bgc_DMS,   nt_bgc_PON_in=nt_bgc_PON,   &   ! LCOV_EXCL_LINE
    2203             :          nt_bgc_N_in=nt_bgc_N,       nt_bgc_chl_in=nt_bgc_chl,   &   ! LCOV_EXCL_LINE
    2204             :          nt_bgc_DOC_in=nt_bgc_DOC,   nt_bgc_DON_in=nt_bgc_DON,     nt_bgc_DIC_in=nt_bgc_DIC,   &   ! LCOV_EXCL_LINE
    2205             :          nt_zaero_in=nt_zaero,       nt_bgc_DMSPp_in=nt_bgc_DMSPp, nt_bgc_DMSPd_in=nt_bgc_DMSPd, &   ! LCOV_EXCL_LINE
    2206             :          nt_bgc_Fed_in=nt_bgc_Fed,   nt_bgc_Fep_in=nt_bgc_Fep,     nt_zbgc_frac_in=nt_zbgc_frac, &   ! LCOV_EXCL_LINE
    2207             :          nlt_zaero_sw_in=nlt_zaero_sw,  nlt_chl_sw_in=nlt_chl_sw,  nlt_bgc_Sil_in=nlt_bgc_Sil, &   ! LCOV_EXCL_LINE
    2208             :          nlt_bgc_N_in=nlt_bgc_N,     nlt_bgc_Nit_in=nlt_bgc_Nit,   nlt_bgc_Am_in=nlt_bgc_Am, &   ! LCOV_EXCL_LINE
    2209             :          nlt_bgc_DMS_in=nlt_bgc_DMS, nlt_bgc_DMSPp_in=nlt_bgc_DMSPp, nlt_bgc_DMSPd_in=nlt_bgc_DMSPd, &   ! LCOV_EXCL_LINE
    2210             :          nlt_zaero_in=nlt_zaero,     nlt_bgc_chl_in=nlt_bgc_chl, &   ! LCOV_EXCL_LINE
    2211             :          nlt_bgc_DIC_in=nlt_bgc_DIC, nlt_bgc_DOC_in=nlt_bgc_DOC,   nlt_bgc_PON_in=nlt_bgc_PON, &   ! LCOV_EXCL_LINE
    2212             :          nlt_bgc_DON_in=nlt_bgc_DON, nlt_bgc_Fed_in=nlt_bgc_Fed,   nlt_bgc_Fep_in=nlt_bgc_Fep, &   ! LCOV_EXCL_LINE
    2213          37 :          nt_bgc_hum_in=nt_bgc_hum,   nlt_bgc_hum_in=nlt_bgc_hum)
    2214          37 :       call icepack_warnings_flush(nu_diag)
    2215          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname//' Icepack Abort2', &
    2216           0 :          file=__FILE__, line=__LINE__)
    2217             : 
    2218          37 :       if (my_task == master_task) then
    2219           7 :          call icepack_write_tracer_flags(nu_diag)
    2220           7 :          call icepack_write_tracer_sizes(nu_diag)
    2221           7 :          call icepack_write_tracer_indices(nu_diag)
    2222             :       endif
    2223          37 :       call icepack_warnings_flush(nu_diag)
    2224          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname//' Icepack Abort3', &
    2225           0 :          file=__FILE__, line=__LINE__)
    2226             : 
    2227          74 :       end subroutine count_tracers
    2228             : 
    2229             : !=======================================================================
    2230             : 
    2231             : ! Initialize vertical biogeochemistry
    2232             : !
    2233             : ! author Elizabeth C. Hunke, LANL
    2234             : !        Nicole Jeffery, LANL
    2235             : 
    2236          37 :       subroutine init_zbgc
    2237             : 
    2238             :       use ice_state, only: trcr_base, trcr_depend, n_trcr_strata, &
    2239             :           nt_strata
    2240             :       use ice_arrays_column, only: R_C2N, R_chl2N, R_C2N_DON, R_Si2N, trcrn_sw
    2241             : 
    2242             :       integer (kind=int_kind) :: &
    2243             :          nbtrcr,        nbtrcr_sw,     nt_fbri,       &   ! LCOV_EXCL_LINE
    2244             :          nt_bgc_Nit,    nt_bgc_Am,     nt_bgc_Sil,    &   ! LCOV_EXCL_LINE
    2245             :          nt_bgc_DMS,    nt_bgc_PON,                   &   ! LCOV_EXCL_LINE
    2246             :          nt_bgc_DMSPp,  nt_bgc_DMSPd,                 &   ! LCOV_EXCL_LINE
    2247             :          nt_zbgc_frac,  nlt_chl_sw,                   &   ! LCOV_EXCL_LINE
    2248             :          nlt_bgc_Nit,   nlt_bgc_Am,    nlt_bgc_Sil,   &   ! LCOV_EXCL_LINE
    2249             :          nlt_bgc_DMS,   nlt_bgc_DMSPp, nlt_bgc_DMSPd, &   ! LCOV_EXCL_LINE
    2250             :          nlt_bgc_PON,   nt_bgc_hum,    nlt_bgc_hum
    2251             : 
    2252             :       integer (kind=int_kind), dimension(icepack_max_aero) :: &
    2253             :          nlt_zaero_sw       ! points to aerosol in trcrn_sw
    2254             : 
    2255             :       integer (kind=int_kind), dimension(icepack_max_algae) :: &
    2256             :          nlt_bgc_N      , & ! algae   ! LCOV_EXCL_LINE
    2257             :          nlt_bgc_chl
    2258             : 
    2259             :       integer (kind=int_kind), dimension(icepack_max_doc) :: &
    2260             :          nlt_bgc_DOC        ! disolved organic carbon
    2261             : 
    2262             :       integer (kind=int_kind), dimension(icepack_max_don) :: &
    2263             :          nlt_bgc_DON        !
    2264             : 
    2265             :       integer (kind=int_kind), dimension(icepack_max_dic) :: &
    2266             :          nlt_bgc_DIC        ! disolved inorganic carbon
    2267             : 
    2268             :       integer (kind=int_kind), dimension(icepack_max_fe) :: &
    2269             :          nlt_bgc_Fed    , & !   ! LCOV_EXCL_LINE
    2270             :          nlt_bgc_Fep        !
    2271             : 
    2272             :       integer (kind=int_kind), dimension(icepack_max_aero) :: &
    2273             :          nlt_zaero          ! non-reacting layer aerosols
    2274             : 
    2275             :       integer (kind=int_kind), dimension(icepack_max_algae) :: &
    2276             :          nt_bgc_N , & ! diatoms, phaeocystis, pico/small   ! LCOV_EXCL_LINE
    2277             :          nt_bgc_chl   ! diatoms, phaeocystis, pico/small
    2278             : 
    2279             :       integer (kind=int_kind), dimension(icepack_max_doc) :: &
    2280             :          nt_bgc_DOC      !  dissolved organic carbon
    2281             : 
    2282             :       integer (kind=int_kind), dimension(icepack_max_don) :: &
    2283             :          nt_bgc_DON         !  dissolved organic nitrogen
    2284             : 
    2285             :       integer (kind=int_kind), dimension(icepack_max_dic) :: &
    2286             :          nt_bgc_DIC         !  dissolved inorganic carbon
    2287             : 
    2288             :       integer (kind=int_kind), dimension(icepack_max_fe) :: &
    2289             :          nt_bgc_Fed,     & !  dissolved iron   ! LCOV_EXCL_LINE
    2290             :          nt_bgc_Fep        !  particulate iron
    2291             : 
    2292             :       integer (kind=int_kind), dimension(icepack_max_aero) :: &
    2293             :          nt_zaero       !  black carbon and other aerosols
    2294             : 
    2295             :       integer (kind=int_kind), dimension(icepack_max_nbtrcr) :: &
    2296             :          bio_index_o         ! relates nlt_bgc_NO to ocean concentration index
    2297             : 
    2298             :       integer (kind=int_kind), dimension(icepack_max_nbtrcr) :: &
    2299             :          bio_index           ! relates bio indices, ie.  nlt_bgc_N to nt_bgc_N
    2300             : 
    2301             :       logical (kind=log_kind) :: &
    2302             :          tr_brine, &   ! LCOV_EXCL_LINE
    2303             :          tr_bgc_Nit,    tr_bgc_Am,    tr_bgc_Sil,   &   ! LCOV_EXCL_LINE
    2304             :          tr_bgc_DMS,    tr_bgc_PON,   &   ! LCOV_EXCL_LINE
    2305             :          tr_bgc_N,      tr_bgc_C,     tr_bgc_chl,   &   ! LCOV_EXCL_LINE
    2306             :          tr_bgc_DON,    tr_bgc_Fe,    tr_zaero,     &   ! LCOV_EXCL_LINE
    2307             :          tr_bgc_hum
    2308             : 
    2309             :       real (kind=dbl_kind) :: &
    2310             :          initbio_frac, &   ! LCOV_EXCL_LINE
    2311           8 :          frazil_scav
    2312             : 
    2313             :       real (kind=dbl_kind), dimension(icepack_max_nbtrcr) :: &
    2314             :          zbgc_frac_init,&! initializes mobile fraction   ! LCOV_EXCL_LINE
    2315         240 :          bgc_tracer_type ! described tracer in mobile or stationary phases
    2316             :                          ! < 0 is purely mobile (eg. nitrate)
    2317             :                          ! > 0 has timescales for transitions between
    2318             :                          ! phases based on whether the ice is melting or growing
    2319             : 
    2320             :      real (kind=dbl_kind), dimension(icepack_max_nbtrcr) :: &
    2321             :          zbgc_init_frac, &   ! fraction of ocean tracer  concentration in new ice   ! LCOV_EXCL_LINE
    2322             :          tau_ret,        &   ! retention timescale  (s), mobile to stationary phase   ! LCOV_EXCL_LINE
    2323         240 :          tau_rel             ! release timescale    (s), stationary to mobile phase
    2324             : 
    2325             :       logical (kind=log_kind) :: &
    2326             :          skl_bgc, z_tracers, dEdd_algae
    2327             : 
    2328             :       real (kind=dbl_kind), dimension(icepack_max_algae) :: &
    2329          32 :          F_abs_chl          ! to scale absorption in Dedd
    2330             : 
    2331             :        real (kind=dbl_kind),  dimension(icepack_max_algae) :: &
    2332             :          R_S2N      , & ! algal S to N (mole/mole)   ! LCOV_EXCL_LINE
    2333             :          ! Marchetti et al 2006, 3 umol Fe/mol C for iron limited Pseudo-nitzschia
    2334          32 :          R_Fe2C     , & ! algal Fe to carbon (umol/mmol)
    2335          32 :          R_Fe2N         ! algal Fe to N (umol/mmol)
    2336             : 
    2337             :       real (kind=dbl_kind), dimension(icepack_max_don) :: &
    2338          16 :          R_Fe2DON       ! Fe to N of DON (nmol/umol)
    2339             : 
    2340             :       real (kind=dbl_kind), dimension(icepack_max_doc) :: &
    2341          32 :          R_Fe2DOC       ! Fe to C of DOC (nmol/umol)
    2342             : 
    2343             :       real (kind=dbl_kind), dimension(icepack_max_algae) :: &
    2344             :          chlabs           , & ! chla absorption 1/m/(mg/m^3)   ! LCOV_EXCL_LINE
    2345             :          alpha2max_low    , & ! light limitation (1/(W/m^2))   ! LCOV_EXCL_LINE
    2346             :          beta2max         , & ! light inhibition (1/(W/m^2))   ! LCOV_EXCL_LINE
    2347             :          mu_max           , & ! maximum growth rate (1/d)   ! LCOV_EXCL_LINE
    2348             :          grow_Tdep        , & ! T dependence of growth (1/C)   ! LCOV_EXCL_LINE
    2349             :          fr_graze         , & ! fraction of algae grazed   ! LCOV_EXCL_LINE
    2350             :          mort_pre         , & ! mortality (1/day)   ! LCOV_EXCL_LINE
    2351             :          mort_Tdep        , & ! T dependence of mortality (1/C)   ! LCOV_EXCL_LINE
    2352             :          k_exude          , & ! algal carbon  exudation rate (1/d)   ! LCOV_EXCL_LINE
    2353             :          K_Nit            , & ! nitrate half saturation (mmol/m^3)   ! LCOV_EXCL_LINE
    2354             :          K_Am             , & ! ammonium half saturation (mmol/m^3)   ! LCOV_EXCL_LINE
    2355             :          K_Sil            , & ! silicon half saturation (mmol/m^3)   ! LCOV_EXCL_LINE
    2356          32 :          K_Fe                 ! iron half saturation  or micromol/m^3
    2357             : 
    2358             :       real (kind=dbl_kind), dimension(icepack_max_DON) :: &
    2359             :          f_don            , & ! fraction of spilled grazing to DON   ! LCOV_EXCL_LINE
    2360             :          kn_bac           , & ! Bacterial degredation of DON (1/d)   ! LCOV_EXCL_LINE
    2361          16 :          f_don_Am             ! fraction of remineralized DON to Am
    2362             : 
    2363             :       real (kind=dbl_kind), dimension(icepack_max_DOC) :: &
    2364             :          f_doc            , & ! fraction of mort_N that goes to each doc pool   ! LCOV_EXCL_LINE
    2365             :          f_exude          , & ! fraction of exuded carbon to each DOC pool   ! LCOV_EXCL_LINE
    2366          32 :          k_bac                ! Bacterial degredation of DOC (1/d)
    2367             : 
    2368             :       integer (kind=int_kind) :: &
    2369             :          k, mm    , & ! loop index   ! LCOV_EXCL_LINE
    2370             :          nk       , & ! layer index   ! LCOV_EXCL_LINE
    2371             :          ierr
    2372             : 
    2373             :       integer (kind=int_kind) :: &
    2374             :         ntd      , & ! for tracer dependency calculation   ! LCOV_EXCL_LINE
    2375             :         nt_depend
    2376             : 
    2377             :       character(len=*), parameter :: subname='(init_zbgc)'
    2378             : 
    2379             :       !------------------------------------------------------------
    2380             :       !        Tracers have mobile and stationary phases.
    2381             :       ! ice growth allows for retention, ice melt facilitates mobility
    2382             :       ! bgc_tracer_type defines the exchange timescales between these phases
    2383             :       ! -1 : entirely in the mobile phase, no exchange  (this is the default)
    2384             :       !  0 : retention time scale is tau_min, release time scale is tau_max
    2385             :       !  1 : retention time scale is tau_max, release time scale is tau_min
    2386             :       ! 0.5: retention time scale is tau_min, release time scale is tau_min
    2387             :       !  2 : retention time scale is tau_max, release time scale is tau_max
    2388             :       ! tau_min and tau_max are defined in icepack_intfc.f90
    2389             :       !------------------------------------------------------------
    2390             : 
    2391             :       !-----------------------------------------------------------------
    2392             :       ! get values from icepack
    2393             :       !-----------------------------------------------------------------
    2394             : 
    2395             :       call icepack_query_parameters( &
    2396             :           skl_bgc_out=skl_bgc, z_tracers_out=z_tracers, &   ! LCOV_EXCL_LINE
    2397             :           dEdd_algae_out=dEdd_algae, &   ! LCOV_EXCL_LINE
    2398             :           grid_o_out=grid_o, l_sk_out=l_sk, &   ! LCOV_EXCL_LINE
    2399             :           initbio_frac_out=initbio_frac, &   ! LCOV_EXCL_LINE
    2400          37 :           phi_snow_out=phi_snow, frazil_scav_out = frazil_scav)
    2401          37 :       call icepack_warnings_flush(nu_diag)
    2402          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
    2403           0 :           file=__FILE__, line=__LINE__)
    2404             : 
    2405             :       call icepack_query_tracer_sizes( &
    2406          37 :           nbtrcr_out=nbtrcr, nbtrcr_sw_out=nbtrcr_sw)
    2407          37 :       call icepack_warnings_flush(nu_diag)
    2408          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
    2409           0 :           file=__FILE__, line=__LINE__)
    2410             : 
    2411             :       call icepack_query_tracer_flags( &
    2412             :           tr_brine_out =tr_brine, &   ! LCOV_EXCL_LINE
    2413             :           tr_bgc_Nit_out=tr_bgc_Nit, tr_bgc_Am_out=tr_bgc_Am,  tr_bgc_Sil_out=tr_bgc_Sil,   &   ! LCOV_EXCL_LINE
    2414             :           tr_bgc_DMS_out=tr_bgc_DMS, tr_bgc_PON_out=tr_bgc_PON, &   ! LCOV_EXCL_LINE
    2415             :           tr_bgc_N_out =tr_bgc_N,   tr_bgc_C_out =tr_bgc_C,   tr_bgc_chl_out=tr_bgc_chl,   &   ! LCOV_EXCL_LINE
    2416             :           tr_bgc_DON_out=tr_bgc_DON, tr_bgc_Fe_out=tr_bgc_Fe,  tr_zaero_out =tr_zaero,     &   ! LCOV_EXCL_LINE
    2417          37 :           tr_bgc_hum_out=tr_bgc_hum)
    2418          37 :       call icepack_warnings_flush(nu_diag)
    2419          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
    2420           0 :           file=__FILE__, line=__LINE__)
    2421             : 
    2422             :       call icepack_query_tracer_indices( &
    2423             :           nt_fbri_out=nt_fbri,         &   ! LCOV_EXCL_LINE
    2424             :           nt_bgc_Nit_out=nt_bgc_Nit,   nt_bgc_Am_out=nt_bgc_Am,       nt_bgc_Sil_out=nt_bgc_Sil,   &   ! LCOV_EXCL_LINE
    2425             :           nt_bgc_DMS_out=nt_bgc_DMS,   nt_bgc_PON_out=nt_bgc_PON,   &   ! LCOV_EXCL_LINE
    2426             :           nt_bgc_N_out=nt_bgc_N,       nt_bgc_chl_out=nt_bgc_chl,   &   ! LCOV_EXCL_LINE
    2427             :           nt_bgc_DOC_out=nt_bgc_DOC,   nt_bgc_DON_out=nt_bgc_DON,     nt_bgc_DIC_out=nt_bgc_DIC,   &   ! LCOV_EXCL_LINE
    2428             :           nt_zaero_out=nt_zaero,       nt_bgc_DMSPp_out=nt_bgc_DMSPp, nt_bgc_DMSPd_out=nt_bgc_DMSPd, &   ! LCOV_EXCL_LINE
    2429             :           nt_bgc_Fed_out=nt_bgc_Fed,   nt_bgc_Fep_out=nt_bgc_Fep,     nt_zbgc_frac_out=nt_zbgc_frac, &   ! LCOV_EXCL_LINE
    2430             :           nlt_zaero_sw_out=nlt_zaero_sw,  nlt_chl_sw_out=nlt_chl_sw,  nlt_bgc_Sil_out=nlt_bgc_Sil, &   ! LCOV_EXCL_LINE
    2431             :           nlt_bgc_N_out=nlt_bgc_N,     nlt_bgc_Nit_out=nlt_bgc_Nit,   nlt_bgc_Am_out=nlt_bgc_Am, &   ! LCOV_EXCL_LINE
    2432             :           nlt_bgc_DMS_out=nlt_bgc_DMS, nlt_bgc_DMSPp_out=nlt_bgc_DMSPp, nlt_bgc_DMSPd_out=nlt_bgc_DMSPd, &   ! LCOV_EXCL_LINE
    2433             :           nlt_zaero_out=nlt_zaero,     nlt_bgc_chl_out=nlt_bgc_chl, &   ! LCOV_EXCL_LINE
    2434             :           nlt_bgc_DIC_out=nlt_bgc_DIC, nlt_bgc_DOC_out=nlt_bgc_DOC,   nlt_bgc_PON_out=nlt_bgc_PON, &   ! LCOV_EXCL_LINE
    2435             :           nlt_bgc_DON_out=nlt_bgc_DON, nlt_bgc_Fed_out=nlt_bgc_Fed,   nlt_bgc_Fep_out=nlt_bgc_Fep, &   ! LCOV_EXCL_LINE
    2436          37 :           nt_bgc_hum_out=nt_bgc_hum,   nlt_bgc_hum_out=nlt_bgc_hum)
    2437          37 :       call icepack_warnings_flush(nu_diag)
    2438          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
    2439           0 :           file=__FILE__, line=__LINE__)
    2440             : 
    2441             :       !-----------------------------------------------------------------
    2442             :       ! Define array parameters
    2443             :       !-----------------------------------------------------------------
    2444             : 
    2445             :       allocate(          &
    2446             :          R_C2N_DON(icepack_max_don), & ! carbon to nitrogen mole ratio of DON pool   ! LCOV_EXCL_LINE
    2447             :          R_C2N(icepack_max_algae),   & ! algal C to N (mole/mole)   ! LCOV_EXCL_LINE
    2448             :          R_chl2N(icepack_max_algae), & ! 3 algal chlorophyll to N (mg/mmol)   ! LCOV_EXCL_LINE
    2449             :          R_Si2N(icepack_max_algae),  & ! silica to nitrogen mole ratio for algal groups   ! LCOV_EXCL_LINE
    2450          37 :          stat=ierr)
    2451          37 :       if (ierr/=0) call abort_ice(subname//' Out of Memory')
    2452             : 
    2453          37 :       R_Si2N(1) = ratio_Si2N_diatoms
    2454          37 :       R_Si2N(2) = ratio_Si2N_sp
    2455          37 :       R_Si2N(3) = ratio_Si2N_phaeo
    2456             : 
    2457          37 :       R_S2N(1) = ratio_S2N_diatoms
    2458          37 :       R_S2N(2) = ratio_S2N_sp
    2459          37 :       R_S2N(3) = ratio_S2N_phaeo
    2460             : 
    2461          37 :       R_Fe2C(1) = ratio_Fe2C_diatoms
    2462          37 :       R_Fe2C(2) = ratio_Fe2C_sp
    2463          37 :       R_Fe2C(3) = ratio_Fe2C_phaeo
    2464             : 
    2465          37 :       R_Fe2N(1) = ratio_Fe2N_diatoms
    2466          37 :       R_Fe2N(2) = ratio_Fe2N_sp
    2467          37 :       R_Fe2N(3) = ratio_Fe2N_phaeo
    2468             : 
    2469          37 :       R_C2N(1) = ratio_C2N_diatoms
    2470          37 :       R_C2N(2) = ratio_C2N_sp
    2471          37 :       R_C2N(3) = ratio_C2N_phaeo
    2472             : 
    2473          37 :       R_chl2N(1) = ratio_chl2N_diatoms
    2474          37 :       R_chl2N(2) = ratio_chl2N_sp
    2475          37 :       R_chl2N(3) = ratio_chl2N_phaeo
    2476             : 
    2477          37 :       F_abs_chl(1) = F_abs_chl_diatoms
    2478          37 :       F_abs_chl(2) = F_abs_chl_sp
    2479          37 :       F_abs_chl(3) = F_abs_chl_phaeo
    2480             : 
    2481          37 :       R_Fe2DON(1) = ratio_Fe2DON
    2482          37 :       R_C2N_DON(1) = ratio_C2N_proteins
    2483             : 
    2484          37 :       R_Fe2DOC(1) = ratio_Fe2DOC_s
    2485          37 :       R_Fe2DOC(2) = ratio_Fe2DOC_l
    2486          37 :       R_Fe2DOC(3) = c0
    2487             : 
    2488          37 :       chlabs(1) = chlabs_diatoms
    2489          37 :       chlabs(2) = chlabs_sp
    2490          37 :       chlabs(3) = chlabs_phaeo
    2491             : 
    2492          37 :       alpha2max_low(1) = alpha2max_low_diatoms
    2493          37 :       alpha2max_low(2) = alpha2max_low_sp
    2494          37 :       alpha2max_low(3) = alpha2max_low_phaeo
    2495             : 
    2496          37 :       beta2max(1) = beta2max_diatoms
    2497          37 :       beta2max(2) = beta2max_sp
    2498          37 :       beta2max(3) = beta2max_phaeo
    2499             : 
    2500          37 :       mu_max(1) = mu_max_diatoms
    2501          37 :       mu_max(2) = mu_max_sp
    2502          37 :       mu_max(3) = mu_max_phaeo
    2503             : 
    2504          37 :       grow_Tdep(1) = grow_Tdep_diatoms
    2505          37 :       grow_Tdep(2) = grow_Tdep_sp
    2506          37 :       grow_Tdep(3) = grow_Tdep_phaeo
    2507             : 
    2508          37 :       fr_graze(1) = fr_graze_diatoms
    2509          37 :       fr_graze(2) = fr_graze_sp
    2510          37 :       fr_graze(3) = fr_graze_phaeo
    2511             : 
    2512          37 :       mort_pre(1) = mort_pre_diatoms
    2513          37 :       mort_pre(2) = mort_pre_sp
    2514          37 :       mort_pre(3) = mort_pre_phaeo
    2515             : 
    2516          37 :       mort_Tdep(1) = mort_Tdep_diatoms
    2517          37 :       mort_Tdep(2) = mort_Tdep_sp
    2518          37 :       mort_Tdep(3) = mort_Tdep_phaeo
    2519             : 
    2520          37 :       k_exude(1) = k_exude_diatoms
    2521          37 :       k_exude(2) = k_exude_sp
    2522          37 :       k_exude(3) = k_exude_phaeo
    2523             : 
    2524          37 :       K_Nit(1) = K_Nit_diatoms
    2525          37 :       K_Nit(2) = K_Nit_sp
    2526          37 :       K_Nit(3) = K_Nit_phaeo
    2527             : 
    2528          37 :       K_Am(1) = K_Am_diatoms
    2529          37 :       K_Am(2) = K_Am_sp
    2530          37 :       K_Am(3) = K_Am_phaeo
    2531             : 
    2532          37 :       K_Sil(1) = K_Sil_diatoms
    2533          37 :       K_Sil(2) = K_Sil_sp
    2534          37 :       K_Sil(3) = K_Sil_phaeo
    2535             : 
    2536          37 :       K_Fe(1) = K_Fe_diatoms
    2537          37 :       K_Fe(2) = K_Fe_sp
    2538          37 :       K_Fe(3) = K_Fe_phaeo
    2539             : 
    2540          37 :       f_don(1) = f_don_protein
    2541          37 :       kn_bac(1) = kn_bac_protein
    2542          37 :       f_don_Am(1) = f_don_Am_protein
    2543             : 
    2544          37 :       f_doc(1) = f_doc_s
    2545          37 :       f_doc(2) = f_doc_l
    2546             : 
    2547          37 :       f_exude(1) = f_exude_s
    2548          37 :       f_exude(2) = f_exude_l
    2549          37 :       k_bac(1) = k_bac_s
    2550          37 :       k_bac(2) = k_bac_l
    2551             : 
    2552          74 :       dictype(:) = -c1
    2553             : 
    2554          37 :       algaltype(1) = algaltype_diatoms
    2555          37 :       algaltype(2) = algaltype_sp
    2556          37 :       algaltype(3) = algaltype_phaeo
    2557             : 
    2558          37 :       doctype(1) = doctype_s
    2559          37 :       doctype(2) = doctype_l
    2560             : 
    2561          37 :       dontype(1) = dontype_protein
    2562             : 
    2563          37 :       fedtype(1) = fedtype_1
    2564          37 :       feptype(1) = feptype_1
    2565             : 
    2566          37 :       zaerotype(1) = zaerotype_bc1
    2567          37 :       zaerotype(2) = zaerotype_bc2
    2568          37 :       zaerotype(3) = zaerotype_dust1
    2569          37 :       zaerotype(4) = zaerotype_dust2
    2570          37 :       zaerotype(5) = zaerotype_dust3
    2571          37 :       zaerotype(6) = zaerotype_dust4
    2572             : 
    2573             :       call icepack_init_zbgc ( &
    2574             :          R_S2N_in=R_S2N, R_Fe2C_in=R_Fe2C, R_Fe2N_in=R_Fe2N, R_C2N_in=R_C2N, &   ! LCOV_EXCL_LINE
    2575             :          R_chl2N_in=R_chl2N, F_abs_chl_in=F_abs_chl, R_Fe2DON_in=R_Fe2DON, R_Fe2DOC_in=R_Fe2DOC, &   ! LCOV_EXCL_LINE
    2576             :          mort_Tdep_in=mort_Tdep, k_exude_in=k_exude, &   ! LCOV_EXCL_LINE
    2577             :          K_Nit_in=K_Nit, K_Am_in=K_Am, K_sil_in=K_Sil, K_Fe_in=K_Fe, &   ! LCOV_EXCL_LINE
    2578             :          f_don_in=f_don, kn_bac_in=kn_bac, f_don_Am_in=f_don_Am, f_exude_in=f_exude, k_bac_in=k_bac, &   ! LCOV_EXCL_LINE
    2579             :          fr_resp_in=fr_resp, algal_vel_in=algal_vel, R_dFe2dust_in=R_dFe2dust, &   ! LCOV_EXCL_LINE
    2580             :          dustFe_sol_in=dustFe_sol, T_max_in=T_max, fr_mort2min_in=fr_mort2min, fr_dFe_in=fr_dFe, &   ! LCOV_EXCL_LINE
    2581             :          op_dep_min_in=op_dep_min, fr_graze_s_in=fr_graze_s, fr_graze_e_in=fr_graze_e, &   ! LCOV_EXCL_LINE
    2582             :          k_nitrif_in=k_nitrif, t_iron_conv_in=t_iron_conv, max_loss_in=max_loss, max_dfe_doc1_in=max_dfe_doc1, &   ! LCOV_EXCL_LINE
    2583             :          fr_resp_s_in=fr_resp_s, y_sk_DMS_in=y_sk_DMS, t_sk_conv_in=t_sk_conv, t_sk_ox_in=t_sk_ox, &   ! LCOV_EXCL_LINE
    2584             :          mu_max_in=mu_max, R_Si2N_in=R_Si2N, R_C2N_DON_in=R_C2N_DON, chlabs_in=chlabs, &   ! LCOV_EXCL_LINE
    2585             :          alpha2max_low_in=alpha2max_low, beta2max_in=beta2max, grow_Tdep_in=grow_Tdep, &   ! LCOV_EXCL_LINE
    2586          37 :          fr_graze_in=fr_graze, mort_pre_in=mort_pre, f_doc_in=f_doc,fsal_in=fsal)
    2587          37 :       call icepack_warnings_flush(nu_diag)
    2588          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
    2589           0 :           file=__FILE__, line=__LINE__)
    2590             : 
    2591             :       !-----------------------------------------------------------------
    2592             :       ! assign tracer dependencies
    2593             :       ! bgc_tracer_type: < 0  purely mobile , >= 0 stationary
    2594             :       !------------------------------------------------------------------
    2595             : 
    2596          37 :       if (tr_brine) then
    2597           0 :           trcr_depend(nt_fbri)   = 1   ! volume-weighted
    2598           0 :           trcr_base  (nt_fbri,1) = c0  ! volume-weighted
    2599           0 :           trcr_base  (nt_fbri,2) = c1  ! volume-weighted
    2600           0 :           trcr_base  (nt_fbri,3) = c0  ! volume-weighted
    2601           0 :           n_trcr_strata(nt_fbri) = 0
    2602           0 :           nt_strata  (nt_fbri,1) = 0
    2603           0 :           nt_strata  (nt_fbri,2) = 0
    2604             :       endif
    2605             : 
    2606          37 :       ntd = 0                    ! if nt_fbri /= 0 then use fbri dependency
    2607          37 :       if (nt_fbri == 0) ntd = -1 ! otherwise make tracers depend on ice volume
    2608             : 
    2609          37 :       bio_index(:)   = 0
    2610          37 :       bio_index_o(:) = 0
    2611             : 
    2612          37 :       if (skl_bgc) then
    2613           0 :          nk = 1
    2614           0 :          nt_depend = 0
    2615          37 :       elseif (z_tracers) then ! defined on nblyr+1 in ice
    2616             :                               ! and 2 snow layers (snow surface + interior)
    2617           0 :          nk = nblyr + 1
    2618           0 :          nt_depend = 2 + nt_fbri + ntd
    2619             :       endif ! skl_bgc or z_tracers
    2620             : 
    2621          37 :       if (skl_bgc .or. z_tracers) then
    2622             : 
    2623           0 :       if (tr_bgc_N) then
    2624           0 :          do mm = 1, n_algae
    2625             :             call init_bgc_trcr(nk,              nt_fbri,       &
    2626             :                                nt_bgc_N(mm),    nlt_bgc_N(mm), &   ! LCOV_EXCL_LINE
    2627             :                                algaltype(mm),   nt_depend,     &   ! LCOV_EXCL_LINE
    2628             :                                bgc_tracer_type, trcr_depend,   &   ! LCOV_EXCL_LINE
    2629             :                                trcr_base,       n_trcr_strata, &   ! LCOV_EXCL_LINE
    2630           0 :                                nt_strata,       bio_index)
    2631           0 :             bio_index_o(nlt_bgc_N(mm)) = mm
    2632             :          enddo   ! mm
    2633             :       endif ! tr_bgc_N
    2634             : 
    2635           0 :       if (tr_bgc_Nit) then
    2636             :             call init_bgc_trcr(nk,              nt_fbri,       &
    2637             :                                nt_bgc_Nit,      nlt_bgc_Nit,   &   ! LCOV_EXCL_LINE
    2638             :                                nitratetype,     nt_depend,     &   ! LCOV_EXCL_LINE
    2639             :                                bgc_tracer_type, trcr_depend,   &   ! LCOV_EXCL_LINE
    2640             :                                trcr_base,       n_trcr_strata, &   ! LCOV_EXCL_LINE
    2641           0 :                                nt_strata,       bio_index)
    2642           0 :             bio_index_o(nlt_bgc_Nit) = icepack_max_algae + 1
    2643             :       endif ! tr_bgc_Nit
    2644             : 
    2645           0 :       if (tr_bgc_C) then
    2646             :        !
    2647             :        ! Algal C is not yet distinct from algal N
    2648             :        ! * Reqires exudation and/or changing C:N ratios
    2649             :        ! for implementation
    2650             :        !
    2651             :        !  do mm = 1,n_algae
    2652             :        !     call init_bgc_trcr(nk,              nt_fbri,       &
    2653             :        !                        nt_bgc_C(mm),    nlt_bgc_C(mm), &   ! LCOV_EXCL_LINE
    2654             :        !                        algaltype(mm),   nt_depend,     &   ! LCOV_EXCL_LINE
    2655             :        !                        bgc_tracer_type, trcr_depend,   &   ! LCOV_EXCL_LINE
    2656             :        !                        trcr_base,       n_trcr_strata, &   ! LCOV_EXCL_LINE
    2657             :        !                        nt_strata,       bio_index)
    2658             :        !     bio_index_o(nlt_bgc_C(mm)) = icepack_max_algae + 1 + mm
    2659             :        !  enddo   ! mm
    2660             : 
    2661           0 :          do mm = 1, n_doc
    2662             :             call init_bgc_trcr(nk,              nt_fbri,       &
    2663             :                                nt_bgc_DOC(mm),  nlt_bgc_DOC(mm), &   ! LCOV_EXCL_LINE
    2664             :                                doctype(mm),     nt_depend,     &   ! LCOV_EXCL_LINE
    2665             :                                bgc_tracer_type, trcr_depend,   &   ! LCOV_EXCL_LINE
    2666             :                                trcr_base,       n_trcr_strata, &   ! LCOV_EXCL_LINE
    2667           0 :                                nt_strata,       bio_index)
    2668           0 :             bio_index_o(nlt_bgc_DOC(mm)) = icepack_max_algae + 1 + mm
    2669             :          enddo   ! mm
    2670           0 :          do mm = 1, n_dic
    2671             :             call init_bgc_trcr(nk,              nt_fbri,       &
    2672             :                                nt_bgc_DIC(mm),  nlt_bgc_DIC(mm), &   ! LCOV_EXCL_LINE
    2673             :                                dictype(mm),     nt_depend,     &   ! LCOV_EXCL_LINE
    2674             :                                bgc_tracer_type, trcr_depend,   &   ! LCOV_EXCL_LINE
    2675             :                                trcr_base,       n_trcr_strata, &   ! LCOV_EXCL_LINE
    2676           0 :                                nt_strata,       bio_index)
    2677           0 :             bio_index_o(nlt_bgc_DIC(mm)) = icepack_max_algae + icepack_max_doc + 1 + mm
    2678             :          enddo   ! mm
    2679             :       endif      ! tr_bgc_C
    2680             : 
    2681           0 :       if (tr_bgc_chl) then
    2682           0 :          do mm = 1, n_algae
    2683             :             call init_bgc_trcr(nk,              nt_fbri,       &
    2684             :                                nt_bgc_chl(mm),  nlt_bgc_chl(mm), &   ! LCOV_EXCL_LINE
    2685             :                                algaltype(mm),   nt_depend,     &   ! LCOV_EXCL_LINE
    2686             :                                bgc_tracer_type, trcr_depend,   &   ! LCOV_EXCL_LINE
    2687             :                                trcr_base,       n_trcr_strata, &   ! LCOV_EXCL_LINE
    2688           0 :                                nt_strata,       bio_index)
    2689           0 :             bio_index_o(nlt_bgc_chl(mm)) = icepack_max_algae + 1 + icepack_max_doc + icepack_max_dic + mm
    2690             :          enddo   ! mm
    2691             :       endif      ! tr_bgc_chl
    2692             : 
    2693           0 :       if (tr_bgc_Am) then
    2694             :             call init_bgc_trcr(nk,              nt_fbri,       &
    2695             :                                nt_bgc_Am,       nlt_bgc_Am,    &   ! LCOV_EXCL_LINE
    2696             :                                ammoniumtype,    nt_depend,     &   ! LCOV_EXCL_LINE
    2697             :                                bgc_tracer_type, trcr_depend,   &   ! LCOV_EXCL_LINE
    2698             :                                trcr_base,       n_trcr_strata, &   ! LCOV_EXCL_LINE
    2699           0 :                                nt_strata,       bio_index)
    2700           0 :             bio_index_o(nlt_bgc_Am) = 2*icepack_max_algae + icepack_max_doc + icepack_max_dic + 2
    2701             :       endif
    2702           0 :       if (tr_bgc_Sil) then
    2703             :             call init_bgc_trcr(nk,              nt_fbri,       &
    2704             :                                nt_bgc_Sil,      nlt_bgc_Sil,   &   ! LCOV_EXCL_LINE
    2705             :                                silicatetype,    nt_depend,     &   ! LCOV_EXCL_LINE
    2706             :                                bgc_tracer_type, trcr_depend,   &   ! LCOV_EXCL_LINE
    2707             :                                trcr_base,       n_trcr_strata, &   ! LCOV_EXCL_LINE
    2708           0 :                                nt_strata,       bio_index)
    2709           0 :             bio_index_o(nlt_bgc_Sil) = 2*icepack_max_algae + icepack_max_doc + icepack_max_dic + 3
    2710             :       endif
    2711           0 :       if (tr_bgc_DMS) then   ! all together
    2712             :             call init_bgc_trcr(nk,              nt_fbri,       &
    2713             :                                nt_bgc_DMSPp,    nlt_bgc_DMSPp, &   ! LCOV_EXCL_LINE
    2714             :                                dmspptype,       nt_depend,     &   ! LCOV_EXCL_LINE
    2715             :                                bgc_tracer_type, trcr_depend,   &   ! LCOV_EXCL_LINE
    2716             :                                trcr_base,       n_trcr_strata, &   ! LCOV_EXCL_LINE
    2717           0 :                                nt_strata,       bio_index)
    2718           0 :             bio_index_o(nlt_bgc_DMSPp) = 2*icepack_max_algae + icepack_max_doc + icepack_max_dic + 4
    2719             : 
    2720             :             call init_bgc_trcr(nk,              nt_fbri,       &
    2721             :                                nt_bgc_DMSPd,    nlt_bgc_DMSPd, &   ! LCOV_EXCL_LINE
    2722             :                                dmspdtype,       nt_depend,     &   ! LCOV_EXCL_LINE
    2723             :                                bgc_tracer_type, trcr_depend,   &   ! LCOV_EXCL_LINE
    2724             :                                trcr_base,       n_trcr_strata, &   ! LCOV_EXCL_LINE
    2725           0 :                                nt_strata,       bio_index)
    2726           0 :             bio_index_o(nlt_bgc_DMSPd) = 2*icepack_max_algae + icepack_max_doc + icepack_max_dic + 5
    2727             : 
    2728             :             call init_bgc_trcr(nk,              nt_fbri,       &
    2729             :                                nt_bgc_DMS,      nlt_bgc_DMS,   &   ! LCOV_EXCL_LINE
    2730             :                                dmspdtype,       nt_depend,     &   ! LCOV_EXCL_LINE
    2731             :                                bgc_tracer_type, trcr_depend,   &   ! LCOV_EXCL_LINE
    2732             :                                trcr_base,       n_trcr_strata, &   ! LCOV_EXCL_LINE
    2733           0 :                                nt_strata,       bio_index)
    2734           0 :             bio_index_o(nlt_bgc_DMS) = 2*icepack_max_algae + icepack_max_doc + icepack_max_dic + 6
    2735             :       endif
    2736           0 :       if (tr_bgc_PON) then
    2737             :             call init_bgc_trcr(nk,              nt_fbri,       &
    2738             :                                nt_bgc_PON,      nlt_bgc_PON, &   ! LCOV_EXCL_LINE
    2739             :                                nitratetype,     nt_depend,     &   ! LCOV_EXCL_LINE
    2740             :                                bgc_tracer_type, trcr_depend,   &   ! LCOV_EXCL_LINE
    2741             :                                trcr_base,       n_trcr_strata, &   ! LCOV_EXCL_LINE
    2742           0 :                                nt_strata,       bio_index)
    2743           0 :             bio_index_o(nlt_bgc_PON) =  2*icepack_max_algae + icepack_max_doc + icepack_max_dic + 7
    2744             :       endif
    2745           0 :       if (tr_bgc_DON) then
    2746           0 :          do mm = 1, n_don
    2747             :             call init_bgc_trcr(nk,              nt_fbri,       &
    2748             :                                nt_bgc_DON(mm),  nlt_bgc_DON(mm), &   ! LCOV_EXCL_LINE
    2749             :                                dontype(mm),     nt_depend,     &   ! LCOV_EXCL_LINE
    2750             :                                bgc_tracer_type, trcr_depend,   &   ! LCOV_EXCL_LINE
    2751             :                                trcr_base,       n_trcr_strata, &   ! LCOV_EXCL_LINE
    2752           0 :                                nt_strata,       bio_index)
    2753           0 :             bio_index_o(nlt_bgc_DON(mm)) = 2*icepack_max_algae + icepack_max_doc + icepack_max_dic + 7 + mm
    2754             :          enddo   ! mm
    2755             :       endif      ! tr_bgc_DON
    2756           0 :       if (tr_bgc_Fe) then
    2757           0 :          do mm = 1, n_fed
    2758             :             call init_bgc_trcr(nk,              nt_fbri,       &
    2759             :                                nt_bgc_Fed(mm),  nlt_bgc_Fed(mm), &   ! LCOV_EXCL_LINE
    2760             :                                fedtype(mm),     nt_depend,     &   ! LCOV_EXCL_LINE
    2761             :                                bgc_tracer_type, trcr_depend,   &   ! LCOV_EXCL_LINE
    2762             :                                trcr_base,       n_trcr_strata, &   ! LCOV_EXCL_LINE
    2763           0 :                                nt_strata,       bio_index)
    2764           0 :             bio_index_o(nlt_bgc_Fed(mm)) = 2*icepack_max_algae + icepack_max_doc + icepack_max_dic &
    2765           0 :                                          + icepack_max_don + 7 + mm
    2766             :          enddo   ! mm
    2767           0 :          do mm = 1, n_fep
    2768             :             call init_bgc_trcr(nk,              nt_fbri,       &
    2769             :                                nt_bgc_Fep(mm),  nlt_bgc_Fep(mm), &   ! LCOV_EXCL_LINE
    2770             :                                feptype(mm),     nt_depend,     &   ! LCOV_EXCL_LINE
    2771             :                                bgc_tracer_type, trcr_depend,   &   ! LCOV_EXCL_LINE
    2772             :                                trcr_base,       n_trcr_strata, &   ! LCOV_EXCL_LINE
    2773           0 :                                nt_strata,       bio_index)
    2774           0 :             bio_index_o(nlt_bgc_Fep(mm)) = 2*icepack_max_algae + icepack_max_doc + icepack_max_dic &
    2775           0 :                                          + icepack_max_don + icepack_max_fe + 7 + mm
    2776             :          enddo   ! mm
    2777             :       endif      ! tr_bgc_Fe
    2778             : 
    2779           0 :       if (tr_bgc_hum) then
    2780             :             call init_bgc_trcr(nk,              nt_fbri,       &
    2781             :                                nt_bgc_hum,      nlt_bgc_hum,   &   ! LCOV_EXCL_LINE
    2782             :                                humtype,         nt_depend,     &   ! LCOV_EXCL_LINE
    2783             :                                bgc_tracer_type, trcr_depend,   &   ! LCOV_EXCL_LINE
    2784             :                                trcr_base,       n_trcr_strata, &   ! LCOV_EXCL_LINE
    2785           0 :                                nt_strata,       bio_index)
    2786           0 :             bio_index_o(nlt_bgc_hum) =   2*icepack_max_algae + icepack_max_doc + 8 + icepack_max_dic &
    2787           0 :                                          + icepack_max_don + 2*icepack_max_fe + icepack_max_aero
    2788             :       endif
    2789             :       endif  ! skl_bgc or z_tracers
    2790             : 
    2791          37 :       if (skl_bgc) then
    2792           0 :          if (dEdd_algae) then
    2793           0 :            nlt_chl_sw = 1
    2794           0 :            nbtrcr_sw = nilyr+nslyr+2  ! only the bottom layer will be nonzero
    2795             :          endif
    2796             : 
    2797          37 :       elseif (z_tracers) then ! defined on nblyr+1 in ice
    2798             :                               ! and 2 snow layers (snow surface + interior)
    2799           0 :          if (tr_bgc_N) then
    2800           0 :             if (dEdd_algae) then
    2801           0 :                nlt_chl_sw = 1
    2802           0 :                nbtrcr_sw =  nilyr+nslyr+2
    2803             :             endif
    2804             :          endif ! tr_bgc_N
    2805             :       endif ! skl_bgc or z_tracers
    2806             : 
    2807          37 :       if (z_tracers) then ! defined on nblyr+1 in ice
    2808             :                           ! and 2 snow layers (snow surface + interior)
    2809             : 
    2810           0 :          nk = nblyr + 1
    2811           0 :          nt_depend = 2 + nt_fbri + ntd
    2812             : 
    2813             :          ! z layer aerosols
    2814           0 :          if (tr_zaero) then
    2815           0 :             do mm = 1, n_zaero
    2816           0 :                if (dEdd_algae) then
    2817           0 :                   nlt_zaero_sw(mm) = nbtrcr_sw + 1
    2818           0 :                   nbtrcr_sw = nbtrcr_sw + nilyr + nslyr+2
    2819             :                endif
    2820             :                call init_bgc_trcr(nk,              nt_fbri,       &
    2821             :                                   nt_zaero(mm),    nlt_zaero(mm), &   ! LCOV_EXCL_LINE
    2822             :                                   zaerotype(mm),   nt_depend,     &   ! LCOV_EXCL_LINE
    2823             :                                   bgc_tracer_type, trcr_depend,   &   ! LCOV_EXCL_LINE
    2824             :                                   trcr_base,       n_trcr_strata, &   ! LCOV_EXCL_LINE
    2825           0 :                                   nt_strata,       bio_index)
    2826           0 :                bio_index_o(nlt_zaero(mm)) = 2*icepack_max_algae + icepack_max_doc + icepack_max_dic &
    2827           0 :                                           + icepack_max_don + 2*icepack_max_fe + 7 + mm
    2828             :             enddo   ! mm
    2829             :          endif      ! tr_zaero
    2830             : 
    2831           0 :          if (nbtrcr > 0) then
    2832           0 :             do k = 1,nbtrcr
    2833           0 :                zbgc_frac_init(k) = c1
    2834           0 :                trcr_depend(nt_zbgc_frac+k-1) =  2+nt_fbri
    2835           0 :                trcr_base(nt_zbgc_frac+ k - 1,1)  = c0
    2836           0 :                trcr_base(nt_zbgc_frac+ k - 1,2)  = c1
    2837           0 :                trcr_base(nt_zbgc_frac+ k - 1,3)  = c0
    2838           0 :                n_trcr_strata(nt_zbgc_frac+ k - 1)= 1
    2839           0 :                nt_strata(nt_zbgc_frac+ k - 1,1)  = nt_fbri
    2840           0 :                nt_strata(nt_zbgc_frac+ k - 1,2)  = 0
    2841           0 :                tau_ret(k) = c1
    2842           0 :                tau_rel(k) = c1
    2843           0 :                if (bgc_tracer_type(k) >=  c0 .and. bgc_tracer_type(k) < p5) then
    2844           0 :                   tau_ret(k) = tau_min
    2845           0 :                   tau_rel(k) = tau_max
    2846           0 :                   zbgc_frac_init(k) = c1
    2847           0 :                elseif (bgc_tracer_type(k) >= p5 .and. bgc_tracer_type(k) < c1) then
    2848           0 :                   tau_ret(k) = tau_min
    2849           0 :                   tau_rel(k) = tau_min
    2850           0 :                   zbgc_frac_init(k) = c1
    2851           0 :                elseif (bgc_tracer_type(k) >= c1 .and. bgc_tracer_type(k) < c2) then
    2852           0 :                   tau_ret(k) = tau_max
    2853           0 :                   tau_rel(k) = tau_min
    2854           0 :                   zbgc_frac_init(k) = c1
    2855           0 :                elseif (bgc_tracer_type(k) >= c2 ) then
    2856           0 :                   tau_ret(k) = tau_max
    2857           0 :                   tau_rel(k) = tau_max
    2858           0 :                   zbgc_frac_init(k) = c1
    2859             :                endif
    2860             :             enddo
    2861             :          endif
    2862             : 
    2863             :       endif ! z_tracers
    2864             : 
    2865          37 :       do k = 1, nbtrcr
    2866           0 :          zbgc_init_frac(k) = frazil_scav
    2867          37 :          if (bgc_tracer_type(k) < c0)  zbgc_init_frac(k) = initbio_frac
    2868             :       enddo
    2869             : 
    2870             :       !-----------------------------------------------------------------
    2871             :       ! set values in icepack
    2872             :       !-----------------------------------------------------------------
    2873             : 
    2874             :       call icepack_init_zbgc( &
    2875             :          zbgc_init_frac_in=zbgc_init_frac, tau_ret_in=tau_ret, tau_rel_in=tau_rel, &   ! LCOV_EXCL_LINE
    2876          37 :          zbgc_frac_init_in=zbgc_frac_init, bgc_tracer_type_in=bgc_tracer_type)
    2877             :       call icepack_init_tracer_indices( &
    2878          37 :          bio_index_o_in=bio_index_o, bio_index_in=bio_index)
    2879          37 :       call icepack_warnings_flush(nu_diag)
    2880          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
    2881           0 :          file=__FILE__, line=__LINE__)
    2882             : 
    2883             :       !-----------------------------------------------------------------
    2884             :       ! final consistency checks
    2885             :       !-----------------------------------------------------------------
    2886          37 :       if (nbtrcr > icepack_max_nbtrcr) then
    2887           0 :          write (nu_diag,*) subname,' '
    2888           0 :          write (nu_diag,*) subname,'nbtrcr > icepack_max_nbtrcr'
    2889           0 :          write (nu_diag,*) subname,'nbtrcr, icepack_max_nbtrcr:',nbtrcr, icepack_max_nbtrcr
    2890           0 :          call abort_ice (subname//'ERROR: nbtrcr > icepack_max_nbtrcr')
    2891             :       endif
    2892          37 :       if (.NOT. dEdd_algae) nbtrcr_sw = 1
    2893             : 
    2894             :       ! tcraig, added 6/1/21, why is nbtrcr_sw set here?
    2895          37 :       call icepack_init_tracer_sizes(nbtrcr_sw_in=nbtrcr_sw)
    2896          37 :       allocate(trcrn_sw(nx_block,ny_block,nbtrcr_sw,ncat,max_blocks)) ! bgc tracers active in the delta-Eddington shortwave
    2897             : 
    2898             :       !-----------------------------------------------------------------
    2899             :       ! spew
    2900             :       !-----------------------------------------------------------------
    2901          37 :       if (my_task == master_task) then
    2902           7 :       if (skl_bgc) then
    2903             : 
    2904           0 :          write(nu_diag,1020) ' number of bio tracers     = ', nbtrcr
    2905           0 :          write(nu_diag,1020) ' number of Isw tracers     = ', nbtrcr_sw
    2906             : 
    2907           7 :       elseif (z_tracers) then
    2908             : 
    2909           0 :          write(nu_diag,1020) ' number of ztracers        = ', nbtrcr
    2910           0 :          write(nu_diag,1020) ' number of Isw tracers     = ', nbtrcr_sw
    2911           0 :          write(nu_diag,1000) ' initbio_frac              = ', initbio_frac
    2912           0 :          write(nu_diag,1000) ' frazil_scav               = ', frazil_scav
    2913             : 
    2914             :       endif  ! skl_bgc or solve_bgc
    2915             :       endif  ! master_task
    2916             : 
    2917             :  1000    format (a30,2x,f9.2)  ! a30 to align formatted, unformatted statements
    2918             :  1020    format (a30,2x,i6)    ! integer
    2919             : 
    2920         111 :       end subroutine init_zbgc
    2921             : 
    2922             : !=======================================================================
    2923             : 
    2924           0 :       subroutine init_bgc_trcr(nk,              nt_fbri,       &
    2925             :                                nt_bgc,          nlt_bgc,       &   ! LCOV_EXCL_LINE
    2926             :                                bgctype,         nt_depend,     &   ! LCOV_EXCL_LINE
    2927             :                                bgc_tracer_type, trcr_depend,   &   ! LCOV_EXCL_LINE
    2928             :                                trcr_base,       n_trcr_strata, &   ! LCOV_EXCL_LINE
    2929           0 :                                nt_strata,       bio_index)
    2930             : 
    2931             :       integer (kind=int_kind), intent(in) :: &
    2932             :          nk           , & ! counter   ! LCOV_EXCL_LINE
    2933             :          nt_depend    , & ! tracer dependency index   ! LCOV_EXCL_LINE
    2934             :          nt_bgc       , & ! tracer index   ! LCOV_EXCL_LINE
    2935             :          nlt_bgc      , & ! bio tracer index   ! LCOV_EXCL_LINE
    2936             :          nt_fbri
    2937             : 
    2938             :       integer (kind=int_kind), dimension(:), intent(inout) :: &
    2939             :          trcr_depend  , & ! tracer dependencies   ! LCOV_EXCL_LINE
    2940             :          n_trcr_strata, & ! number of underlying tracer layers   ! LCOV_EXCL_LINE
    2941             :          bio_index        !
    2942             : 
    2943             :       integer (kind=int_kind), dimension(:,:), intent(inout) :: &
    2944             :          nt_strata        ! indices of underlying tracer layers
    2945             : 
    2946             :       real (kind=dbl_kind), dimension(:,:), intent(inout) :: &
    2947             :          trcr_base        ! = 0 or 1 depending on tracer dependency
    2948             :                           ! argument 2:  (1) aice, (2) vice, (3) vsno
    2949             : 
    2950             :       real (kind=dbl_kind), intent(in) :: &
    2951             :          bgctype          ! bio tracer transport type (mobile vs stationary)
    2952             : 
    2953             :       real (kind=dbl_kind), dimension(:), intent(inout) :: &
    2954             :          bgc_tracer_type  ! bio tracer transport type array
    2955             : 
    2956             :       ! local variables
    2957             : 
    2958             :       integer (kind=int_kind) :: &
    2959             :          k         , & ! loop index   ! LCOV_EXCL_LINE
    2960             :          n_strata  , & ! temporary values   ! LCOV_EXCL_LINE
    2961             :          nt_strata1, & !   ! LCOV_EXCL_LINE
    2962             :          nt_strata2
    2963             : 
    2964             :       real (kind=dbl_kind) :: &
    2965             :          trcr_base1, & ! temporary values   ! LCOV_EXCL_LINE
    2966             :          trcr_base2, &   ! LCOV_EXCL_LINE
    2967           0 :          trcr_base3
    2968             : 
    2969             :       character(len=*), parameter :: subname='(init_bgc_trcr)'
    2970             : 
    2971             :       !--------
    2972             : 
    2973           0 :       bgc_tracer_type(nlt_bgc) = bgctype
    2974             : 
    2975           0 :       if (nk > 1) then ! include vertical bgc in snow
    2976           0 :          do k = nk, nk+1
    2977           0 :             trcr_depend  (nt_bgc + k  ) = 2 ! snow volume
    2978           0 :             trcr_base    (nt_bgc + k,1) = c0
    2979           0 :             trcr_base    (nt_bgc + k,2) = c0
    2980           0 :             trcr_base    (nt_bgc + k,3) = c1
    2981           0 :             n_trcr_strata(nt_bgc + k  ) = 0
    2982           0 :             nt_strata    (nt_bgc + k,1) = 0
    2983           0 :             nt_strata    (nt_bgc + k,2) = 0
    2984             :          enddo
    2985             : 
    2986           0 :          trcr_base1 = c0
    2987           0 :          trcr_base2 = c1
    2988           0 :          trcr_base3 = c0
    2989           0 :          n_strata = 1
    2990           0 :          nt_strata1 = nt_fbri
    2991           0 :          nt_strata2 = 0
    2992             :       else  ! nk = 1
    2993           0 :          trcr_base1 = c1
    2994           0 :          trcr_base2 = c0
    2995           0 :          trcr_base3 = c0
    2996           0 :          n_strata = 0
    2997           0 :          nt_strata1 = 0
    2998           0 :          nt_strata2 = 0
    2999             :       endif ! nk
    3000             : 
    3001           0 :       do k = 1, nk     ! in ice
    3002           0 :          trcr_depend  (nt_bgc + k - 1  ) = nt_depend
    3003           0 :          trcr_base    (nt_bgc + k - 1,1) = trcr_base1
    3004           0 :          trcr_base    (nt_bgc + k - 1,2) = trcr_base2
    3005           0 :          trcr_base    (nt_bgc + k - 1,3) = trcr_base3
    3006           0 :          n_trcr_strata(nt_bgc + k - 1  ) = n_strata
    3007           0 :          nt_strata    (nt_bgc + k - 1,1) = nt_strata1
    3008           0 :          nt_strata    (nt_bgc + k - 1,2) = nt_strata2
    3009             :       enddo
    3010             : 
    3011           0 :       bio_index (nlt_bgc) = nt_bgc
    3012             : 
    3013           0 :       end subroutine init_bgc_trcr
    3014             : 
    3015             : !=======================================================================
    3016             : 
    3017             :       end module ice_init_column
    3018             : 
    3019             : !=======================================================================

Generated by: LCOV version 1.14-6-g40580cd