LCOV - code coverage report
Current view: top level - icepack/columnphysics - icepack_tracers.F90 (source / functions) Hit Total Coverage
Test: 231018-211459:8916b9ff2c:1:quick Lines: 447 490 91.22 %
Date: 2023-10-18 15:30:36 Functions: 10 10 100.00 %

          Line data    Source code
       1             : !=======================================================================
       2             : ! Indices and flags associated with the tracer infrastructure.
       3             : ! Grid-dependent and max_trcr-dependent arrays are declared in ice_state.F90.
       4             : !
       5             : ! author Elizabeth C. Hunke, LANL
       6             : 
       7             :       module icepack_tracers
       8             : 
       9             :       use icepack_kinds
      10             :       use icepack_parameters, only: c0, c1, puny, rhos, rsnw_fall, rhosnew
      11             :       use icepack_parameters, only: snwredist, snwgrain
      12             :       use icepack_warnings, only: warnstr, icepack_warnings_add
      13             :       use icepack_warnings, only: icepack_warnings_setabort, icepack_warnings_aborted
      14             : 
      15             :       implicit none
      16             : 
      17             :       private
      18             :       public :: icepack_compute_tracers
      19             :       public :: icepack_init_tracer_flags
      20             :       public :: icepack_query_tracer_flags
      21             :       public :: icepack_write_tracer_flags
      22             :       public :: icepack_init_tracer_indices
      23             :       public :: icepack_query_tracer_indices
      24             :       public :: icepack_write_tracer_indices
      25             :       public :: icepack_init_tracer_sizes
      26             :       public :: icepack_query_tracer_sizes
      27             :       public :: icepack_write_tracer_sizes
      28             : 
      29             :       !-----------------------------------------------------------------
      30             :       ! dimensions
      31             :       !-----------------------------------------------------------------
      32             :       integer (kind=int_kind), parameter, public :: &
      33             :          max_iso    =   3       , & ! maximum number of isotopes   ! LCOV_EXCL_LINE
      34             :          max_algae  =   3       , & ! maximum number of algal types   ! LCOV_EXCL_LINE
      35             :          max_dic    =   1       , & ! maximum number of dissolved inorganic carbon types   ! LCOV_EXCL_LINE
      36             :          max_doc    =   3       , & ! maximum number of dissolved organic carbon types   ! LCOV_EXCL_LINE
      37             :          max_don    =   1       , & ! maximum number of dissolved organic nitrogen types   ! LCOV_EXCL_LINE
      38             :          max_fe     =   2       , & ! maximum number of iron types   ! LCOV_EXCL_LINE
      39             :          nmodal1    =   10      , & ! dimension for modal aerosol radiation parameters   ! LCOV_EXCL_LINE
      40             :          nmodal2    =   8       , & ! dimension for modal aerosol radiation parameters   ! LCOV_EXCL_LINE
      41             :          max_aero   =   6       , & ! maximum number of aerosols   ! LCOV_EXCL_LINE
      42             : 
      43             :          max_nbtrcr = max_algae*2 & ! algal nitrogen and chlorophyll
      44             :                     + max_dic     & ! dissolved inorganic carbon   ! LCOV_EXCL_LINE
      45             :                     + max_doc     & ! dissolved organic carbon   ! LCOV_EXCL_LINE
      46             :                     + max_don     & ! dissolved organic nitrogen   ! LCOV_EXCL_LINE
      47             :                     + 5           & ! nitrate, ammonium, silicate, PON, and humics   ! LCOV_EXCL_LINE
      48             :                     + 3           & ! DMSPp, DMSPd, DMS   ! LCOV_EXCL_LINE
      49             :                     + max_fe*2    & ! dissolved Fe and  particulate Fe   ! LCOV_EXCL_LINE
      50             :                     + max_aero      ! aerosols
      51             : 
      52             :       integer (kind=int_kind), public :: &
      53             :          ntrcr        = 0, & ! number of tracers in use   ! LCOV_EXCL_LINE
      54             :          ntrcr_o      = 0, & ! number of non-bio tracers in use   ! LCOV_EXCL_LINE
      55             :          ncat         = 0, & ! number of ice categories in use   ! LCOV_EXCL_LINE
      56             :          nilyr        = 0, & ! number of ice layers per category   ! LCOV_EXCL_LINE
      57             :          nslyr        = 0, & ! number of snow layers per category   ! LCOV_EXCL_LINE
      58             :          nblyr        = 0, & ! number of bio/brine layers per category   ! LCOV_EXCL_LINE
      59             :          nfsd         = 0, & ! number of fsd layers   ! LCOV_EXCL_LINE
      60             :          n_iso        = 0, & ! number of isotopes in use   ! LCOV_EXCL_LINE
      61             :          n_aero       = 0, & ! number of aerosols in use   ! LCOV_EXCL_LINE
      62             :          n_zaero      = 0, & ! number of z aerosols in use   ! LCOV_EXCL_LINE
      63             :          n_algae      = 0, & ! number of algae in use   ! LCOV_EXCL_LINE
      64             :          n_doc        = 0, & ! number of DOC pools in use   ! LCOV_EXCL_LINE
      65             :          n_dic        = 0, & ! number of DIC pools in use   ! LCOV_EXCL_LINE
      66             :          n_don        = 0, & ! number of DON pools in use   ! LCOV_EXCL_LINE
      67             :          n_fed        = 0, & ! number of Fe  pools in use dissolved Fe   ! LCOV_EXCL_LINE
      68             :          n_fep        = 0    ! number of Fe  pools in use particulate Fe
      69             : 
      70             :       integer (kind=int_kind), public :: &
      71             :          nt_Tsfc      = 0, & ! ice/snow temperature   ! LCOV_EXCL_LINE
      72             :          nt_qice      = 0, & ! volume-weighted ice enthalpy (in layers)   ! LCOV_EXCL_LINE
      73             :          nt_qsno      = 0, & ! volume-weighted snow enthalpy (in layers)   ! LCOV_EXCL_LINE
      74             :          nt_sice      = 0, & ! volume-weighted ice bulk salinity (CICE grid layers)   ! LCOV_EXCL_LINE
      75             :          nt_fbri      = 0, & ! volume fraction of ice with dynamic salt (hinS/vicen*aicen)   ! LCOV_EXCL_LINE
      76             :          nt_iage      = 0, & ! volume-weighted ice age   ! LCOV_EXCL_LINE
      77             :          nt_FY        = 0, & ! area-weighted first-year ice area   ! LCOV_EXCL_LINE
      78             :          nt_alvl      = 0, & ! level ice area fraction   ! LCOV_EXCL_LINE
      79             :          nt_vlvl      = 0, & ! level ice volume fraction   ! LCOV_EXCL_LINE
      80             :          nt_apnd      = 0, & ! melt pond area fraction   ! LCOV_EXCL_LINE
      81             :          nt_hpnd      = 0, & ! melt pond depth   ! LCOV_EXCL_LINE
      82             :          nt_ipnd      = 0, & ! melt pond refrozen lid thickness   ! LCOV_EXCL_LINE
      83             :          nt_fsd       = 0, & ! floe size distribution   ! LCOV_EXCL_LINE
      84             :          nt_smice     = 0, & ! mass of ice in snow   ! LCOV_EXCL_LINE
      85             :          nt_smliq     = 0, & ! mass of liquid water in snow   ! LCOV_EXCL_LINE
      86             :          nt_rhos      = 0, & ! snow density   ! LCOV_EXCL_LINE
      87             :          nt_rsnw      = 0, & ! snow grain radius   ! LCOV_EXCL_LINE
      88             :          nt_isosno    = 0, & ! starting index for isotopes in snow   ! LCOV_EXCL_LINE
      89             :          nt_isoice    = 0, & ! starting index for isotopes in ice   ! LCOV_EXCL_LINE
      90             :          nt_aero      = 0, & ! starting index for aerosols in ice   ! LCOV_EXCL_LINE
      91             :          nt_bgc_Nit   = 0, & ! nutrients   ! LCOV_EXCL_LINE
      92             :          nt_bgc_Am    = 0, & !   ! LCOV_EXCL_LINE
      93             :          nt_bgc_Sil   = 0, & !   ! LCOV_EXCL_LINE
      94             :          nt_bgc_DMSPp = 0, & ! trace gases (skeletal layer)   ! LCOV_EXCL_LINE
      95             :          nt_bgc_DMSPd = 0, & !   ! LCOV_EXCL_LINE
      96             :          nt_bgc_DMS   = 0, & !   ! LCOV_EXCL_LINE
      97             :          nt_bgc_PON   = 0, & ! zooplankton and detritus   ! LCOV_EXCL_LINE
      98             :          nt_bgc_hum   = 0, & ! humic material   ! LCOV_EXCL_LINE
      99             :          nt_zbgc_frac = 0, & ! fraction of tracer in the mobile phase   ! LCOV_EXCL_LINE
     100             :          nt_bgc_S     = 0    ! Bulk salinity in fraction ice with dynamic salinity (Bio grid) (deprecated)
     101             : 
     102             :       logical (kind=log_kind), public :: &
     103             :          tr_iage      = .false., & ! if .true., use age tracer   ! LCOV_EXCL_LINE
     104             :          tr_FY        = .false., & ! if .true., use first-year area tracer   ! LCOV_EXCL_LINE
     105             :          tr_lvl       = .false., & ! if .true., use level ice tracer   ! LCOV_EXCL_LINE
     106             :          tr_pond      = .false., & ! if .true., use melt pond tracer   ! LCOV_EXCL_LINE
     107             :          tr_pond_lvl  = .false., & ! if .true., use level-ice pond tracer   ! LCOV_EXCL_LINE
     108             :          tr_pond_topo = .false., & ! if .true., use explicit topography-based ponds   ! LCOV_EXCL_LINE
     109             :          tr_snow      = .false., & ! if .true., use snow redistribution or metamorphosis tracers   ! LCOV_EXCL_LINE
     110             :          tr_iso       = .false., & ! if .true., use isotope tracers   ! LCOV_EXCL_LINE
     111             :          tr_aero      = .false., & ! if .true., use aerosol tracers   ! LCOV_EXCL_LINE
     112             :          tr_brine     = .false., & ! if .true., brine height differs from ice thickness   ! LCOV_EXCL_LINE
     113             :          tr_fsd       = .false.    ! if .true., use floe size distribution
     114             : 
     115             :       !-----------------------------------------------------------------
     116             :       !  biogeochemistry
     117             :       !-----------------------------------------------------------------
     118             : 
     119             :       logical (kind=log_kind), public :: &
     120             :          tr_zaero     = .false., & ! if .true., black carbon as tracers  (n_zaero)   ! LCOV_EXCL_LINE
     121             :          tr_bgc_Nit   = .false., & ! if .true. Nitrate tracer in ice   ! LCOV_EXCL_LINE
     122             :          tr_bgc_N     = .false., & ! if .true., algal nitrogen tracers  (n_algae)   ! LCOV_EXCL_LINE
     123             :          tr_bgc_DON   = .false., & ! if .true., DON pools are tracers  (n_don)   ! LCOV_EXCL_LINE
     124             :          tr_bgc_C     = .false., & ! if .true., algal carbon tracers + DOC and DIC   ! LCOV_EXCL_LINE
     125             :          tr_bgc_chl   = .false., & ! if .true., algal chlorophyll tracers   ! LCOV_EXCL_LINE
     126             :          tr_bgc_Am    = .false., & ! if .true., ammonia/um as nutrient tracer   ! LCOV_EXCL_LINE
     127             :          tr_bgc_Sil   = .false., & ! if .true., silicon as nutrient tracer   ! LCOV_EXCL_LINE
     128             :          tr_bgc_DMS   = .false., & ! if .true., DMS as tracer   ! LCOV_EXCL_LINE
     129             :          tr_bgc_Fe    = .false., & ! if .true., Fe as  tracer   ! LCOV_EXCL_LINE
     130             :          tr_bgc_PON   = .false., & ! if .true., PON as tracer   ! LCOV_EXCL_LINE
     131             :          tr_bgc_hum   = .false.    ! if .true., humic material as tracer
     132             : 
     133             :       integer (kind=int_kind), public :: &
     134             :          nbtrcr       = 0, & ! number of bgc tracers in use   ! LCOV_EXCL_LINE
     135             :          nbtrcr_sw    = 0, & ! number of bgc tracers which impact shortwave   ! LCOV_EXCL_LINE
     136             :          nlt_chl_sw   = 0    ! points to total chla in trcrn_sw
     137             : 
     138             :       integer (kind=int_kind), dimension(max_aero), public :: &
     139             :          nlt_zaero_sw = 0    ! points to aerosol in trcrn_sw
     140             : 
     141             :       integer (kind=int_kind), dimension(max_algae), public :: &
     142             :          nlt_bgc_N    = 0, & ! algae   ! LCOV_EXCL_LINE
     143             :          nlt_bgc_C    = 0, & !   ! LCOV_EXCL_LINE
     144             :          nlt_bgc_chl  = 0    !
     145             : 
     146             :       integer (kind=int_kind), dimension(max_doc), public :: &
     147             :          nlt_bgc_DOC  = 0    ! disolved organic carbon
     148             : 
     149             :       integer (kind=int_kind), dimension(max_don), public :: &
     150             :          nlt_bgc_DON  = 0    !
     151             : 
     152             :       integer (kind=int_kind), dimension(max_dic), public :: &
     153             :          nlt_bgc_DIC  = 0    ! disolved inorganic carbon
     154             : 
     155             :       integer (kind=int_kind), dimension(max_fe), public :: &
     156             :          nlt_bgc_Fed  = 0, & !   ! LCOV_EXCL_LINE
     157             :          nlt_bgc_Fep  = 0    !
     158             : 
     159             :       integer (kind=int_kind), dimension(max_aero), public :: &
     160             :          nlt_zaero    = 0    ! non-reacting layer aerosols
     161             : 
     162             :       integer (kind=int_kind), public :: &
     163             :          nlt_bgc_Nit  = 0, & ! nutrients   ! LCOV_EXCL_LINE
     164             :          nlt_bgc_Am   = 0, & !   ! LCOV_EXCL_LINE
     165             :          nlt_bgc_Sil  = 0, & !   ! LCOV_EXCL_LINE
     166             :          nlt_bgc_DMSPp= 0, & ! trace gases (skeletal layer)   ! LCOV_EXCL_LINE
     167             :          nlt_bgc_DMSPd= 0, & !   ! LCOV_EXCL_LINE
     168             :          nlt_bgc_DMS  = 0, & !   ! LCOV_EXCL_LINE
     169             :          nlt_bgc_PON  = 0, & ! zooplankton and detritus   ! LCOV_EXCL_LINE
     170             :          nlt_bgc_hum  = 0    ! humic material
     171             : 
     172             :       integer (kind=int_kind), dimension(max_algae), public :: &
     173             :          nt_bgc_N     = 0, & ! diatoms, phaeocystis, pico/small   ! LCOV_EXCL_LINE
     174             :          nt_bgc_C     = 0, & ! diatoms, phaeocystis, pico/small   ! LCOV_EXCL_LINE
     175             :          nt_bgc_chl   = 0    ! diatoms, phaeocystis, pico/small
     176             : 
     177             :       integer (kind=int_kind), dimension(max_doc), public :: &
     178             :          nt_bgc_DOC   = 0    !  dissolved organic carbon
     179             : 
     180             :       integer (kind=int_kind), dimension(max_don), public :: &
     181             :          nt_bgc_DON   = 0    !  dissolved organic nitrogen
     182             : 
     183             :       integer (kind=int_kind), dimension(max_dic), public :: &
     184             :          nt_bgc_DIC   = 0    !  dissolved inorganic carbon
     185             : 
     186             :       integer (kind=int_kind), dimension(max_fe), public :: &
     187             :          nt_bgc_Fed   = 0, & !  dissolved iron   ! LCOV_EXCL_LINE
     188             :          nt_bgc_Fep   = 0    !  particulate iron
     189             : 
     190             :       integer (kind=int_kind), dimension(max_aero), public :: &
     191             :          nt_zaero     = 0    !  black carbon and other aerosols
     192             : 
     193             :       integer (kind=int_kind), dimension(max_nbtrcr), public :: &
     194             :          bio_index_o  = 0    ! relates nlt_bgc_NO to ocean concentration index
     195             :                              ! see ocean_bio_all
     196             : 
     197             :       integer (kind=int_kind), dimension(max_nbtrcr), public :: &
     198             :          bio_index    = 0    ! relates bio indices, ie.  nlt_bgc_N to nt_bgc_N
     199             : 
     200             : !=======================================================================
     201             : 
     202             :       contains
     203             : 
     204             : !=======================================================================
     205             : !autodocument_start icepack_init_tracer_flags
     206             : ! set tracer active flags
     207             : 
     208          74 :       subroutine icepack_init_tracer_flags(&
     209             :            tr_iage_in, tr_FY_in, tr_lvl_in, tr_snow_in, &   ! LCOV_EXCL_LINE
     210             :            tr_pond_in, tr_pond_lvl_in, tr_pond_topo_in, &   ! LCOV_EXCL_LINE
     211             :            tr_fsd_in, tr_aero_in, tr_iso_in, tr_brine_in, tr_zaero_in, &   ! LCOV_EXCL_LINE
     212             :            tr_bgc_Nit_in, tr_bgc_N_in, tr_bgc_DON_in, tr_bgc_C_in, tr_bgc_chl_in, &   ! LCOV_EXCL_LINE
     213             :            tr_bgc_Am_in, tr_bgc_Sil_in, tr_bgc_DMS_in, tr_bgc_Fe_in, tr_bgc_hum_in, &   ! LCOV_EXCL_LINE
     214             :            tr_bgc_PON_in)
     215             : 
     216             :         logical, intent(in), optional :: &
     217             :              tr_iage_in      , & ! if .true., use age tracer   ! LCOV_EXCL_LINE
     218             :              tr_FY_in        , & ! if .true., use first-year area tracer   ! LCOV_EXCL_LINE
     219             :              tr_lvl_in       , & ! if .true., use level ice tracer   ! LCOV_EXCL_LINE
     220             :              tr_pond_in      , & ! if .true., use melt pond tracer   ! LCOV_EXCL_LINE
     221             :              tr_pond_lvl_in  , & ! if .true., use level-ice pond tracer   ! LCOV_EXCL_LINE
     222             :              tr_pond_topo_in , & ! if .true., use explicit topography-based ponds   ! LCOV_EXCL_LINE
     223             :              tr_snow_in      , & ! if .true., use snow redistribution or metamorphosis tracers   ! LCOV_EXCL_LINE
     224             :              tr_fsd_in       , & ! if .true., use floe size distribution tracers   ! LCOV_EXCL_LINE
     225             :              tr_iso_in       , & ! if .true., use isotope tracers   ! LCOV_EXCL_LINE
     226             :              tr_aero_in      , & ! if .true., use aerosol tracers   ! LCOV_EXCL_LINE
     227             :              tr_brine_in     , & ! if .true., brine height differs from ice thickness   ! LCOV_EXCL_LINE
     228             :              tr_zaero_in     , & ! if .true., black carbon is tracers  (n_zaero)   ! LCOV_EXCL_LINE
     229             :              tr_bgc_Nit_in   , & ! if .true., Nitrate tracer in ice   ! LCOV_EXCL_LINE
     230             :              tr_bgc_N_in     , & ! if .true., algal nitrogen tracers  (n_algae)   ! LCOV_EXCL_LINE
     231             :              tr_bgc_DON_in   , & ! if .true., DON pools are tracers  (n_don)   ! LCOV_EXCL_LINE
     232             :              tr_bgc_C_in     , & ! if .true., algal carbon tracers + DOC and DIC   ! LCOV_EXCL_LINE
     233             :              tr_bgc_chl_in   , & ! if .true., algal chlorophyll tracers   ! LCOV_EXCL_LINE
     234             :              tr_bgc_Am_in    , & ! if .true., ammonia/um as nutrient tracer   ! LCOV_EXCL_LINE
     235             :              tr_bgc_Sil_in   , & ! if .true., silicon as nutrient tracer   ! LCOV_EXCL_LINE
     236             :              tr_bgc_DMS_in   , & ! if .true., DMS as product tracer   ! LCOV_EXCL_LINE
     237             :              tr_bgc_Fe_in    , & ! if .true., Fe as product tracer   ! LCOV_EXCL_LINE
     238             :              tr_bgc_hum_in   , & ! if .true., hum as product tracer   ! LCOV_EXCL_LINE
     239             :              tr_bgc_PON_in       ! if .true., PON as product tracer
     240             : 
     241             : !autodocument_end
     242             : 
     243             :         character(len=*),parameter :: subname='(icepack_init_tracer_flags)'
     244             : 
     245          74 :         if (present(tr_iage_in)) tr_iage = tr_iage_in
     246          74 :         if (present(tr_FY_in)  ) tr_FY   = tr_FY_in
     247          74 :         if (present(tr_lvl_in) ) tr_lvl  = tr_lvl_in
     248          74 :         if (present(tr_pond_in)) tr_pond = tr_pond_in
     249          74 :         if (present(tr_pond_lvl_in) ) tr_pond_lvl  = tr_pond_lvl_in
     250          74 :         if (present(tr_pond_topo_in)) tr_pond_topo = tr_pond_topo_in
     251          74 :         if (present(tr_snow_in)   ) tr_snow    = tr_snow_in
     252          74 :         if (present(tr_fsd_in)    ) tr_fsd     = tr_fsd_in
     253          74 :         if (present(tr_iso_in)    ) tr_iso     = tr_iso_in
     254          74 :         if (present(tr_aero_in)   ) tr_aero    = tr_aero_in
     255          74 :         if (present(tr_brine_in)  ) tr_brine   = tr_brine_in
     256          74 :         if (present(tr_zaero_in)  ) tr_zaero   = tr_zaero_in
     257          74 :         if (present(tr_bgc_Nit_in)) tr_bgc_Nit = tr_bgc_Nit_in
     258          74 :         if (present(tr_bgc_N_in)  ) tr_bgc_N   = tr_bgc_N_in
     259          74 :         if (present(tr_bgc_DON_in)) tr_bgc_DON = tr_bgc_DON_in
     260          74 :         if (present(tr_bgc_C_in)  ) tr_bgc_C   = tr_bgc_C_in
     261          74 :         if (present(tr_bgc_chl_in)) tr_bgc_chl = tr_bgc_chl_in
     262          74 :         if (present(tr_bgc_Am_in) ) tr_bgc_Am  = tr_bgc_Am_in
     263          74 :         if (present(tr_bgc_Sil_in)) tr_bgc_Sil = tr_bgc_Sil_in
     264          74 :         if (present(tr_bgc_DMS_in)) tr_bgc_DMS = tr_bgc_DMS_in
     265          74 :         if (present(tr_bgc_Fe_in )) tr_bgc_Fe  = tr_bgc_Fe_in
     266          74 :         if (present(tr_bgc_hum_in)) tr_bgc_hum = tr_bgc_hum_in
     267          74 :         if (present(tr_bgc_PON_in)) tr_bgc_PON = tr_bgc_PON_in
     268             : 
     269          74 :       end subroutine icepack_init_tracer_flags
     270             : 
     271             : !=======================================================================
     272             : !autodocument_start icepack_query_tracer_flags
     273             : ! query tracer active flags
     274             : 
     275      260289 :       subroutine icepack_query_tracer_flags(&
     276             :            tr_iage_out, tr_FY_out, tr_lvl_out, tr_snow_out, &   ! LCOV_EXCL_LINE
     277             :            tr_pond_out, tr_pond_lvl_out, tr_pond_topo_out, &   ! LCOV_EXCL_LINE
     278             :            tr_fsd_out, tr_aero_out, tr_iso_out, tr_brine_out, tr_zaero_out, &   ! LCOV_EXCL_LINE
     279             :            tr_bgc_Nit_out, tr_bgc_N_out, tr_bgc_DON_out, tr_bgc_C_out, tr_bgc_chl_out, &   ! LCOV_EXCL_LINE
     280             :            tr_bgc_Am_out, tr_bgc_Sil_out, tr_bgc_DMS_out, tr_bgc_Fe_out, tr_bgc_hum_out, &   ! LCOV_EXCL_LINE
     281             :            tr_bgc_PON_out)
     282             : 
     283             :         logical, intent(out), optional :: &
     284             :              tr_iage_out      , & ! if .true., use age tracer   ! LCOV_EXCL_LINE
     285             :              tr_FY_out        , & ! if .true., use first-year area tracer   ! LCOV_EXCL_LINE
     286             :              tr_lvl_out       , & ! if .true., use level ice tracer   ! LCOV_EXCL_LINE
     287             :              tr_pond_out      , & ! if .true., use melt pond tracer   ! LCOV_EXCL_LINE
     288             :              tr_pond_lvl_out  , & ! if .true., use level-ice pond tracer   ! LCOV_EXCL_LINE
     289             :              tr_pond_topo_out , & ! if .true., use explicit topography-based ponds   ! LCOV_EXCL_LINE
     290             :              tr_snow_out      , & ! if .true., use snow redistribution or metamorphosis tracers   ! LCOV_EXCL_LINE
     291             :              tr_fsd_out       , & ! if .true., use floe size distribution   ! LCOV_EXCL_LINE
     292             :              tr_iso_out       , & ! if .true., use isotope tracers   ! LCOV_EXCL_LINE
     293             :              tr_aero_out      , & ! if .true., use aerosol tracers   ! LCOV_EXCL_LINE
     294             :              tr_brine_out     , & ! if .true., brine height differs from ice thickness   ! LCOV_EXCL_LINE
     295             :              tr_zaero_out     , & ! if .true., black carbon is tracers  (n_zaero)   ! LCOV_EXCL_LINE
     296             :              tr_bgc_Nit_out   , & ! if .true., Nitrate tracer in ice   ! LCOV_EXCL_LINE
     297             :              tr_bgc_N_out     , & ! if .true., algal nitrogen tracers  (n_algae)   ! LCOV_EXCL_LINE
     298             :              tr_bgc_DON_out   , & ! if .true., DON pools are tracers  (n_don)   ! LCOV_EXCL_LINE
     299             :              tr_bgc_C_out     , & ! if .true., algal carbon tracers + DOC and DIC   ! LCOV_EXCL_LINE
     300             :              tr_bgc_chl_out   , & ! if .true., algal chlorophyll tracers   ! LCOV_EXCL_LINE
     301             :              tr_bgc_Am_out    , & ! if .true., ammonia/um as nutrient tracer   ! LCOV_EXCL_LINE
     302             :              tr_bgc_Sil_out   , & ! if .true., silicon as nutrient tracer   ! LCOV_EXCL_LINE
     303             :              tr_bgc_DMS_out   , & ! if .true., DMS as product tracer   ! LCOV_EXCL_LINE
     304             :              tr_bgc_Fe_out    , & ! if .true., Fe as product tracer   ! LCOV_EXCL_LINE
     305             :              tr_bgc_hum_out   , & ! if .true., hum as product tracer   ! LCOV_EXCL_LINE
     306             :              tr_bgc_PON_out       ! if .true., PON as product tracer
     307             : 
     308             : !autodocument_end
     309             : 
     310             :         character(len=*),parameter :: subname='(icepack_query_tracer_flags)'
     311             : 
     312      260289 :         if (present(tr_iage_out)) tr_iage_out = tr_iage
     313      260289 :         if (present(tr_FY_out)  ) tr_FY_out   = tr_FY
     314      260289 :         if (present(tr_lvl_out) ) tr_lvl_out  = tr_lvl
     315      260289 :         if (present(tr_pond_out)) tr_pond_out = tr_pond
     316      260289 :         if (present(tr_pond_lvl_out) ) tr_pond_lvl_out  = tr_pond_lvl
     317      260289 :         if (present(tr_pond_topo_out)) tr_pond_topo_out = tr_pond_topo
     318      260289 :         if (present(tr_snow_out)   ) tr_snow_out    = tr_snow
     319      260289 :         if (present(tr_fsd_out)    ) tr_fsd_out     = tr_fsd
     320      260289 :         if (present(tr_iso_out)    ) tr_iso_out     = tr_iso
     321      260289 :         if (present(tr_aero_out)   ) tr_aero_out    = tr_aero
     322      260289 :         if (present(tr_brine_out)  ) tr_brine_out   = tr_brine
     323      260289 :         if (present(tr_zaero_out)  ) tr_zaero_out   = tr_zaero
     324      260289 :         if (present(tr_bgc_Nit_out)) tr_bgc_Nit_out = tr_bgc_Nit
     325      260289 :         if (present(tr_bgc_N_out)  ) tr_bgc_N_out   = tr_bgc_N
     326      260289 :         if (present(tr_bgc_DON_out)) tr_bgc_DON_out = tr_bgc_DON
     327      260289 :         if (present(tr_bgc_C_out)  ) tr_bgc_C_out   = tr_bgc_C
     328      260289 :         if (present(tr_bgc_chl_out)) tr_bgc_chl_out = tr_bgc_chl
     329      260289 :         if (present(tr_bgc_Am_out) ) tr_bgc_Am_out  = tr_bgc_Am
     330      260289 :         if (present(tr_bgc_Sil_out)) tr_bgc_Sil_out = tr_bgc_Sil
     331      260289 :         if (present(tr_bgc_DMS_out)) tr_bgc_DMS_out = tr_bgc_DMS
     332      260289 :         if (present(tr_bgc_Fe_out )) tr_bgc_Fe_out  = tr_bgc_Fe
     333      260289 :         if (present(tr_bgc_hum_out)) tr_bgc_hum_out = tr_bgc_hum
     334      260289 :         if (present(tr_bgc_PON_out)) tr_bgc_PON_out = tr_bgc_PON
     335             : 
     336      260289 :       end subroutine icepack_query_tracer_flags
     337             : 
     338             : !=======================================================================
     339             : !autodocument_start icepack_write_tracer_flags
     340             : ! write tracer active flags
     341             : 
     342           7 :       subroutine icepack_write_tracer_flags(iounit)
     343             : 
     344             :         integer, intent(in) :: iounit
     345             : 
     346             : !autodocument_end
     347             : 
     348             :         character(len=*),parameter :: subname='(icepack_write_tracer_flags)'
     349             : 
     350           7 :         write(iounit,*) subname//":"
     351           7 :         write(iounit,*) "  tr_iage = ",tr_iage
     352           7 :         write(iounit,*) "  tr_FY   = ",tr_FY
     353           7 :         write(iounit,*) "  tr_lvl  = ",tr_lvl
     354           7 :         write(iounit,*) "  tr_pond = ",tr_pond
     355           7 :         write(iounit,*) "  tr_pond_lvl  = ",tr_pond_lvl
     356           7 :         write(iounit,*) "  tr_pond_topo = ",tr_pond_topo
     357           7 :         write(iounit,*) "  tr_snow    = ",tr_snow
     358           7 :         write(iounit,*) "  tr_fsd     = ",tr_fsd
     359           7 :         write(iounit,*) "  tr_iso     = ",tr_iso
     360           7 :         write(iounit,*) "  tr_aero    = ",tr_aero
     361           7 :         write(iounit,*) "  tr_brine   = ",tr_brine
     362           7 :         write(iounit,*) "  tr_zaero   = ",tr_zaero
     363           7 :         write(iounit,*) "  tr_bgc_Nit = ",tr_bgc_Nit
     364           7 :         write(iounit,*) "  tr_bgc_N   = ",tr_bgc_N
     365           7 :         write(iounit,*) "  tr_bgc_DON = ",tr_bgc_DON
     366           7 :         write(iounit,*) "  tr_bgc_C   = ",tr_bgc_C
     367           7 :         write(iounit,*) "  tr_bgc_chl = ",tr_bgc_chl
     368           7 :         write(iounit,*) "  tr_bgc_Am  = ",tr_bgc_Am
     369           7 :         write(iounit,*) "  tr_bgc_Sil = ",tr_bgc_Sil
     370           7 :         write(iounit,*) "  tr_bgc_DMS = ",tr_bgc_DMS
     371           7 :         write(iounit,*) "  tr_bgc_Fe  = ",tr_bgc_Fe
     372           7 :         write(iounit,*) "  tr_bgc_hum = ",tr_bgc_hum
     373           7 :         write(iounit,*) "  tr_bgc_PON = ",tr_bgc_PON
     374             : 
     375           7 :       end subroutine icepack_write_tracer_flags
     376             : 
     377             : !=======================================================================
     378             : !autodocument_start icepack_init_tracer_indices
     379             : ! set the number of column tracer indices
     380             : 
     381          74 :       subroutine icepack_init_tracer_indices(&
     382             :            nt_Tsfc_in, nt_qice_in, nt_qsno_in, nt_sice_in, &   ! LCOV_EXCL_LINE
     383             :            nt_fbri_in, nt_iage_in, nt_FY_in, &   ! LCOV_EXCL_LINE
     384             :            nt_alvl_in, nt_vlvl_in, nt_apnd_in, nt_hpnd_in, nt_ipnd_in, &   ! LCOV_EXCL_LINE
     385             :            nt_smice_in, nt_smliq_in, nt_rhos_in, nt_rsnw_in, &   ! LCOV_EXCL_LINE
     386             :            nt_fsd_in, nt_isosno_in, nt_isoice_in, &   ! LCOV_EXCL_LINE
     387             :            nt_aero_in, nt_zaero_in, nt_bgc_C_in, &   ! LCOV_EXCL_LINE
     388             :            nt_bgc_N_in, nt_bgc_chl_in, nt_bgc_DOC_in, nt_bgc_DON_in, &   ! LCOV_EXCL_LINE
     389             :            nt_bgc_DIC_in, nt_bgc_Fed_in, nt_bgc_Fep_in, nt_bgc_Nit_in, nt_bgc_Am_in, &   ! LCOV_EXCL_LINE
     390             :            nt_bgc_Sil_in, nt_bgc_DMSPp_in, nt_bgc_DMSPd_in, nt_bgc_DMS_in, nt_bgc_hum_in, &   ! LCOV_EXCL_LINE
     391             :            nt_bgc_PON_in, nlt_zaero_in, nlt_bgc_C_in, nlt_bgc_N_in, nlt_bgc_chl_in, &   ! LCOV_EXCL_LINE
     392             :            nlt_bgc_DOC_in, nlt_bgc_DON_in, nlt_bgc_DIC_in, nlt_bgc_Fed_in, &   ! LCOV_EXCL_LINE
     393             :            nlt_bgc_Fep_in, nlt_bgc_Nit_in, nlt_bgc_Am_in, nlt_bgc_Sil_in, &   ! LCOV_EXCL_LINE
     394             :            nlt_bgc_DMSPp_in, nlt_bgc_DMSPd_in, nlt_bgc_DMS_in, nlt_bgc_hum_in, &   ! LCOV_EXCL_LINE
     395             :            nlt_bgc_PON_in, nt_zbgc_frac_in, nt_bgc_S_in, nlt_chl_sw_in, &   ! LCOV_EXCL_LINE
     396             :            nlt_zaero_sw_in, &   ! LCOV_EXCL_LINE
     397          74 :            bio_index_o_in, bio_index_in)
     398             : 
     399             :         integer, intent(in), optional :: &
     400             :              nt_Tsfc_in, & ! ice/snow temperature   ! LCOV_EXCL_LINE
     401             :              nt_qice_in, & ! volume-weighted ice enthalpy (in layers)   ! LCOV_EXCL_LINE
     402             :              nt_qsno_in, & ! volume-weighted snow enthalpy (in layers)   ! LCOV_EXCL_LINE
     403             :              nt_sice_in, & ! volume-weighted ice bulk salinity (CICE grid layers)   ! LCOV_EXCL_LINE
     404             :              nt_fbri_in, & ! volume fraction of ice with dynamic salt (hinS/vicen*aicen)   ! LCOV_EXCL_LINE
     405             :              nt_iage_in, & ! volume-weighted ice age   ! LCOV_EXCL_LINE
     406             :              nt_FY_in,   & ! area-weighted first-year ice area   ! LCOV_EXCL_LINE
     407             :              nt_alvl_in, & ! level ice area fraction   ! LCOV_EXCL_LINE
     408             :              nt_vlvl_in, & ! level ice volume fraction   ! LCOV_EXCL_LINE
     409             :              nt_apnd_in, & ! melt pond area fraction   ! LCOV_EXCL_LINE
     410             :              nt_hpnd_in, & ! melt pond depth   ! LCOV_EXCL_LINE
     411             :              nt_ipnd_in, & ! melt pond refrozen lid thickness   ! LCOV_EXCL_LINE
     412             :              nt_smice_in,& ! mass of ice in snow   ! LCOV_EXCL_LINE
     413             :              nt_smliq_in,& ! mass of liquid water in snow   ! LCOV_EXCL_LINE
     414             :              nt_rhos_in, & ! snow density   ! LCOV_EXCL_LINE
     415             :              nt_rsnw_in, & ! snow grain radius   ! LCOV_EXCL_LINE
     416             :              nt_fsd_in,  & ! floe size distribution   ! LCOV_EXCL_LINE
     417             :              nt_isosno_in,  & ! starting index for isotopes in snow   ! LCOV_EXCL_LINE
     418             :              nt_isoice_in,  & ! starting index for isotopes in ice   ! LCOV_EXCL_LINE
     419             :              nt_aero_in,    & ! starting index for aerosols in ice   ! LCOV_EXCL_LINE
     420             :              nt_bgc_Nit_in, & ! nutrients   ! LCOV_EXCL_LINE
     421             :              nt_bgc_Am_in,  & !   ! LCOV_EXCL_LINE
     422             :              nt_bgc_Sil_in, & !   ! LCOV_EXCL_LINE
     423             :              nt_bgc_DMSPp_in,&! trace gases (skeletal layer)   ! LCOV_EXCL_LINE
     424             :              nt_bgc_DMSPd_in,&!   ! LCOV_EXCL_LINE
     425             :              nt_bgc_DMS_in, & !   ! LCOV_EXCL_LINE
     426             :              nt_bgc_hum_in, & !   ! LCOV_EXCL_LINE
     427             :              nt_bgc_PON_in, & ! zooplankton and detritus   ! LCOV_EXCL_LINE
     428             :              nlt_bgc_Nit_in,& ! nutrients   ! LCOV_EXCL_LINE
     429             :              nlt_bgc_Am_in, & !   ! LCOV_EXCL_LINE
     430             :              nlt_bgc_Sil_in,& !   ! LCOV_EXCL_LINE
     431             :              nlt_bgc_DMSPp_in,&! trace gases (skeletal layer)   ! LCOV_EXCL_LINE
     432             :              nlt_bgc_DMSPd_in,&!   ! LCOV_EXCL_LINE
     433             :              nlt_bgc_DMS_in,& !   ! LCOV_EXCL_LINE
     434             :              nlt_bgc_hum_in,& !   ! LCOV_EXCL_LINE
     435             :              nlt_bgc_PON_in,& ! zooplankton and detritus   ! LCOV_EXCL_LINE
     436             :              nt_zbgc_frac_in,&! fraction of tracer in the mobile phase   ! LCOV_EXCL_LINE
     437             :              nt_bgc_S_in,   & ! (deprecated, was related to zsalinity)   ! LCOV_EXCL_LINE
     438             :              nlt_chl_sw_in    ! points to total chla in trcrn_sw
     439             : 
     440             :         integer (kind=int_kind), dimension(:), intent(in), optional :: &
     441             :              bio_index_o_in, &   ! LCOV_EXCL_LINE
     442             :              bio_index_in
     443             : 
     444             :         integer (kind=int_kind), dimension(:), intent(in), optional :: &
     445             :              nt_bgc_N_in ,  & ! diatoms, phaeocystis, pico/small   ! LCOV_EXCL_LINE
     446             :              nt_bgc_C_in ,  & ! diatoms, phaeocystis, pico/small   ! LCOV_EXCL_LINE
     447             :              nt_bgc_chl_in, & ! diatoms, phaeocystis, pico/small   ! LCOV_EXCL_LINE
     448             :              nlt_bgc_N_in , & ! diatoms, phaeocystis, pico/small   ! LCOV_EXCL_LINE
     449             :              nlt_bgc_C_in , & ! diatoms, phaeocystis, pico/small   ! LCOV_EXCL_LINE
     450             :              nlt_bgc_chl_in   ! diatoms, phaeocystis, pico/small
     451             : 
     452             :         integer (kind=int_kind), dimension(:), intent(in), optional :: &
     453             :              nt_bgc_DOC_in, & !  dissolved organic carbon   ! LCOV_EXCL_LINE
     454             :              nlt_bgc_DOC_in   !  dissolved organic carbon
     455             : 
     456             :         integer (kind=int_kind), dimension(:), intent(in), optional :: &
     457             :              nt_bgc_DON_in, & !  dissolved organic nitrogen   ! LCOV_EXCL_LINE
     458             :              nlt_bgc_DON_in   !  dissolved organic nitrogen
     459             : 
     460             :         integer (kind=int_kind), dimension(:), intent(in), optional :: &
     461             :              nt_bgc_DIC_in, & ! dissolved inorganic carbon   ! LCOV_EXCL_LINE
     462             :              nlt_bgc_DIC_in   !  dissolved inorganic carbon
     463             : 
     464             :         integer (kind=int_kind), dimension(:), intent(in), optional :: &
     465             :              nt_bgc_Fed_in, & !  dissolved iron   ! LCOV_EXCL_LINE
     466             :              nt_bgc_Fep_in, & !  particulate iron   ! LCOV_EXCL_LINE
     467             :              nlt_bgc_Fed_in,& !  dissolved iron   ! LCOV_EXCL_LINE
     468             :              nlt_bgc_Fep_in   !  particulate iron
     469             : 
     470             :         integer (kind=int_kind), dimension(:), intent(in), optional :: &
     471             :              nt_zaero_in,   & !  black carbon and other aerosols   ! LCOV_EXCL_LINE
     472             :              nlt_zaero_in,  & !  black carbon and other aerosols   ! LCOV_EXCL_LINE
     473             :              nlt_zaero_sw_in  ! black carbon and dust in trcrn_sw
     474             : 
     475             : !autodocument_end
     476             : 
     477             :         ! local
     478             :         integer (kind=int_kind) :: nsiz
     479             :         character(len=*),parameter :: subname='(icepack_init_tracer_indices)'
     480             : 
     481          74 :         if (present(nt_Tsfc_in)) nt_Tsfc = nt_Tsfc_in
     482          74 :         if (present(nt_qice_in)) nt_qice = nt_qice_in
     483          74 :         if (present(nt_qsno_in)) nt_qsno = nt_qsno_in
     484          74 :         if (present(nt_sice_in)) nt_sice = nt_sice_in
     485          74 :         if (present(nt_fbri_in)) nt_fbri = nt_fbri_in
     486          74 :         if (present(nt_iage_in)) nt_iage = nt_iage_in
     487          74 :         if (present(nt_FY_in)  ) nt_FY   = nt_FY_in
     488          74 :         if (present(nt_alvl_in)) nt_alvl = nt_alvl_in
     489          74 :         if (present(nt_vlvl_in)) nt_vlvl = nt_vlvl_in
     490          74 :         if (present(nt_apnd_in)) nt_apnd = nt_apnd_in
     491          74 :         if (present(nt_hpnd_in)) nt_hpnd = nt_hpnd_in
     492          74 :         if (present(nt_ipnd_in)) nt_ipnd = nt_ipnd_in
     493          74 :         if (present(nt_fsd_in) ) nt_fsd  = nt_fsd_in
     494          74 :         if (present(nt_smice_in)     ) nt_smice      = nt_smice_in
     495          74 :         if (present(nt_smliq_in)     ) nt_smliq      = nt_smliq_in
     496          74 :         if (present(nt_rhos_in)      ) nt_rhos       = nt_rhos_in
     497          74 :         if (present(nt_rsnw_in)      ) nt_rsnw       = nt_rsnw_in
     498          74 :         if (present(nt_isosno_in)    ) nt_isosno     = nt_isosno_in
     499          74 :         if (present(nt_isoice_in)    ) nt_isoice     = nt_isoice_in
     500          74 :         if (present(nt_aero_in)      ) nt_aero       = nt_aero_in
     501          74 :         if (present(nt_bgc_Nit_in)   ) nt_bgc_Nit    = nt_bgc_Nit_in
     502          74 :         if (present(nt_bgc_Am_in)    ) nt_bgc_Am     = nt_bgc_Am_in
     503          74 :         if (present(nt_bgc_Sil_in)   ) nt_bgc_Sil    = nt_bgc_Sil_in
     504          74 :         if (present(nt_bgc_DMSPp_in) ) nt_bgc_DMSPp  = nt_bgc_DMSPp_in
     505          74 :         if (present(nt_bgc_DMSPd_in) ) nt_bgc_DMSPd  = nt_bgc_DMSPd_in
     506          74 :         if (present(nt_bgc_DMS_in)   ) nt_bgc_DMS    = nt_bgc_DMS_in
     507          74 :         if (present(nt_bgc_hum_in)   ) nt_bgc_hum    = nt_bgc_hum_in
     508          74 :         if (present(nt_bgc_PON_in)   ) nt_bgc_PON    = nt_bgc_PON_in
     509          74 :         if (present(nlt_bgc_Nit_in)  ) nlt_bgc_Nit   = nlt_bgc_Nit_in
     510          74 :         if (present(nlt_bgc_Am_in)   ) nlt_bgc_Am    = nlt_bgc_Am_in
     511          74 :         if (present(nlt_bgc_Sil_in)  ) nlt_bgc_Sil   = nlt_bgc_Sil_in
     512          74 :         if (present(nlt_bgc_DMSPp_in)) nlt_bgc_DMSPp = nlt_bgc_DMSPp_in
     513          74 :         if (present(nlt_bgc_DMSPd_in)) nlt_bgc_DMSPd = nlt_bgc_DMSPd_in
     514          74 :         if (present(nlt_bgc_DMS_in)  ) nlt_bgc_DMS   = nlt_bgc_DMS_in
     515          74 :         if (present(nlt_bgc_hum_in)  ) nlt_bgc_hum   = nlt_bgc_hum_in
     516          74 :         if (present(nlt_bgc_PON_in)  ) nlt_bgc_PON   = nlt_bgc_PON_in
     517          74 :         if (present(nlt_chl_sw_in)   ) nlt_chl_sw    = nlt_chl_sw_in
     518          74 :         if (present(nt_zbgc_frac_in) ) nt_zbgc_frac  = nt_zbgc_frac_in
     519          74 :         if (present(nt_bgc_S_in)     ) nt_bgc_S      = nt_bgc_S_in
     520             : 
     521          74 :         if (present(bio_index_in)) then
     522          37 :            nsiz = size(bio_index_in)
     523          37 :            if (size(bio_index) < nsiz) then
     524           0 :               call icepack_warnings_add(subname//'error in bio_index size')
     525           0 :               call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
     526             :            else
     527        1110 :               bio_index(1:nsiz) = bio_index_in(1:nsiz)
     528             :            endif
     529             :         endif
     530             : 
     531          74 :         if (present(bio_index_o_in)) then
     532          37 :            nsiz = size(bio_index_o_in)
     533          37 :            if (size(bio_index_o) < nsiz) then
     534           0 :               call icepack_warnings_add(subname//'error in bio_index_o size')
     535           0 :               call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
     536             :            else
     537        1110 :               bio_index_o(1:nsiz) = bio_index_o_in(1:nsiz)
     538             :            endif
     539             :         endif
     540             : 
     541          74 :         if (present(nt_bgc_N_in)) then
     542          37 :            nsiz = size(nt_bgc_N_in)
     543          37 :            if (size(nt_bgc_N) < nsiz) then
     544           0 :               call icepack_warnings_add(subname//'error in nt_bgc_N size')
     545           0 :               call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
     546             :            else
     547         148 :               nt_bgc_N(1:nsiz) = nt_bgc_N_in(1:nsiz)
     548             :            endif
     549             :         endif
     550             : 
     551          74 :         if (present(nlt_bgc_N_in)) then
     552          37 :            nsiz = size(nlt_bgc_N_in)
     553          37 :            if (size(nlt_bgc_N) < nsiz) then
     554           0 :               call icepack_warnings_add(subname//'error in nlt_bgc_N size')
     555           0 :               call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
     556             :            else
     557         148 :               nlt_bgc_N(1:nsiz) = nlt_bgc_N_in(1:nsiz)
     558             :            endif
     559             :         endif
     560             : 
     561          74 :         if (present(nt_bgc_chl_in)) then
     562          37 :            nsiz = size(nt_bgc_chl_in)
     563          37 :            if (size(nt_bgc_chl) < nsiz) then
     564           0 :               call icepack_warnings_add(subname//'error in nt_bgc_chl size')
     565           0 :               call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
     566             :            else
     567         148 :               nt_bgc_chl(1:nsiz) = nt_bgc_chl_in(1:nsiz)
     568             :            endif
     569             :         endif
     570             : 
     571          74 :         if (present(nlt_bgc_chl_in)) then
     572          37 :            nsiz = size(nlt_bgc_chl_in)
     573          37 :            if (size(nlt_bgc_chl) < nsiz) then
     574           0 :               call icepack_warnings_add(subname//'error in nlt_bgc_chl size')
     575           0 :               call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
     576             :            else
     577         148 :               nlt_bgc_chl(1:nsiz) = nlt_bgc_chl_in(1:nsiz)
     578             :            endif
     579             :         endif
     580             : 
     581             : ! algal C is not yet distinct from algal N
     582          74 :         if (present(nt_bgc_C_in) .or. present(nlt_bgc_C_in)) then
     583           0 :            call icepack_warnings_add(subname//'error bgc_C not supported')
     584           0 :            call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
     585             :         endif
     586             : 
     587             : !        if (present(nt_bgc_C_in)) then
     588             : !           nsiz = size(nt_bgc_C_in)
     589             : !           if (size(nt_bgc_C) < nsiz) then
     590             : !              call icepack_warnings_add(subname//'error in nt_bgc_C size')
     591             : !              call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
     592             : !           else
     593             : !              nt_bgc_C(1:nsiz) = nt_bgc_C_in(1:nsiz)
     594             : !           endif
     595             : !        endif
     596             : 
     597             : !        if (present(nlt_bgc_C_in)) then
     598             : !           nsiz = size(nlt_bgc_C_in)
     599             : !           if (size(nlt_bgc_C) < nsiz) then
     600             : !              call icepack_warnings_add(subname//'error in nlt_bgc_C size')
     601             : !              call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
     602             : !           else
     603             : !              nlt_bgc_C(1:nsiz) = nlt_bgc_C_in(1:nsiz)
     604             : !           endif
     605             : !        endif
     606             : 
     607          74 :         if (present(nt_bgc_DOC_in)) then
     608          37 :            nsiz = size(nt_bgc_DOC_in)
     609          37 :            if (size(nt_bgc_DOC) < nsiz) then
     610           0 :               call icepack_warnings_add(subname//'error in nt_bgc_DOC size')
     611           0 :               call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
     612             :            else
     613         148 :               nt_bgc_DOC(1:nsiz) = nt_bgc_DOC_in(1:nsiz)
     614             :            endif
     615             :         endif
     616             : 
     617          74 :         if (present(nlt_bgc_DOC_in)) then
     618          37 :            nsiz = size(nlt_bgc_DOC_in)
     619          37 :            if (size(nlt_bgc_DOC) < nsiz) then
     620           0 :               call icepack_warnings_add(subname//'error in nlt_bgc_DOC size')
     621           0 :               call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
     622             :            else
     623         148 :               nlt_bgc_DOC(1:nsiz) = nlt_bgc_DOC_in(1:nsiz)
     624             :            endif
     625             :         endif
     626             : 
     627          74 :         if (present(nt_bgc_DON_in)) then
     628          37 :            nsiz = size(nt_bgc_DON_in)
     629          37 :            if (size(nt_bgc_DON) < nsiz) then
     630           0 :               call icepack_warnings_add(subname//'error in nt_bgc_DON size')
     631           0 :               call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
     632             :            else
     633          74 :               nt_bgc_DON(1:nsiz) = nt_bgc_DON_in(1:nsiz)
     634             :            endif
     635             :         endif
     636             : 
     637          74 :         if (present(nlt_bgc_DON_in)) then
     638          37 :            nsiz = size(nlt_bgc_DON_in)
     639          37 :            if (size(nlt_bgc_DON) < nsiz) then
     640           0 :               call icepack_warnings_add(subname//'error in nlt_bgc_DON size')
     641           0 :               call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
     642             :            else
     643          74 :               nlt_bgc_DON(1:nsiz) = nlt_bgc_DON_in(1:nsiz)
     644             :            endif
     645             :         endif
     646             : 
     647          74 :         if (present(nt_bgc_DIC_in)) then
     648          37 :            nsiz = size(nt_bgc_DIC_in)
     649          37 :            if (size(nt_bgc_DIC) < nsiz) then
     650           0 :               call icepack_warnings_add(subname//'error in nt_bgc_DIC size')
     651           0 :               call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
     652             :            else
     653          74 :               nt_bgc_DIC(1:nsiz) = nt_bgc_DIC_in(1:nsiz)
     654             :            endif
     655             :         endif
     656             : 
     657          74 :         if (present(nlt_bgc_DIC_in)) then
     658          37 :            nsiz = size(nlt_bgc_DIC_in)
     659          37 :            if (size(nlt_bgc_DIC) < nsiz) then
     660           0 :               call icepack_warnings_add(subname//'error in nlt_bgc_DIC size')
     661           0 :               call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
     662             :            else
     663          74 :               nlt_bgc_DIC(1:nsiz) = nlt_bgc_DIC_in(1:nsiz)
     664             :            endif
     665             :         endif
     666             : 
     667          74 :         if (present(nt_bgc_Fed_in)) then
     668          37 :            nsiz = size(nt_bgc_Fed_in)
     669          37 :            if (size(nt_bgc_Fed) < nsiz) then
     670           0 :               call icepack_warnings_add(subname//'error in nt_bgc_Fed size')
     671           0 :               call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
     672             :            else
     673         111 :               nt_bgc_Fed(1:nsiz) = nt_bgc_Fed_in(1:nsiz)
     674             :            endif
     675             :         endif
     676             : 
     677          74 :         if (present(nlt_bgc_Fed_in)) then
     678          37 :            nsiz = size(nlt_bgc_Fed_in)
     679          37 :            if (size(nlt_bgc_Fed) < nsiz) then
     680           0 :               call icepack_warnings_add(subname//'error in nlt_bgc_Fed size')
     681           0 :               call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
     682             :            else
     683         111 :               nlt_bgc_Fed(1:nsiz) = nlt_bgc_Fed_in(1:nsiz)
     684             :            endif
     685             :         endif
     686             : 
     687          74 :         if (present(nt_bgc_Fep_in)) then
     688          37 :            nsiz = size(nt_bgc_Fep_in)
     689          37 :            if (size(nt_bgc_Fep) < nsiz) then
     690           0 :               call icepack_warnings_add(subname//'error in nt_bgc_Fep size')
     691           0 :               call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
     692             :            else
     693         111 :               nt_bgc_Fep(1:nsiz) = nt_bgc_Fep_in(1:nsiz)
     694             :            endif
     695             :         endif
     696             : 
     697          74 :         if (present(nlt_bgc_Fep_in)) then
     698          37 :            nsiz = size(nlt_bgc_Fep_in)
     699          37 :            if (size(nlt_bgc_Fep) < nsiz) then
     700           0 :               call icepack_warnings_add(subname//'error in nlt_bgc_Fep size')
     701           0 :               call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
     702             :            else
     703         111 :               nlt_bgc_Fep(1:nsiz) = nlt_bgc_Fep_in(1:nsiz)
     704             :            endif
     705             :         endif
     706             : 
     707          74 :         if (present(nt_zaero_in)) then
     708          37 :            nsiz = size(nt_zaero_in)
     709          37 :            if (size(nt_zaero) < nsiz) then
     710           0 :               call icepack_warnings_add(subname//'error in nt_zaero size')
     711           0 :               call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
     712             :            else
     713         259 :               nt_zaero(1:nsiz) = nt_zaero_in(1:nsiz)
     714             :            endif
     715             :         endif
     716             : 
     717          74 :         if (present(nlt_zaero_in)) then
     718          37 :            nsiz = size(nlt_zaero_in)
     719          37 :            if (size(nlt_zaero) < nsiz) then
     720           0 :               call icepack_warnings_add(subname//'error in nlt_zaero size')
     721           0 :               call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
     722             :            else
     723         259 :               nlt_zaero(1:nsiz) = nlt_zaero_in(1:nsiz)
     724             :            endif
     725             :         endif
     726             : 
     727          74 :         if (present(nlt_zaero_sw_in)) then
     728          37 :            nsiz = size(nlt_zaero_sw_in)
     729          37 :            if (size(nlt_zaero_sw) < nsiz) then
     730           0 :               call icepack_warnings_add(subname//'error in nlt_zaero_sw size')
     731           0 :               call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
     732             :            else
     733         259 :               nlt_zaero_sw(1:nsiz) = nlt_zaero_sw_in(1:nsiz)
     734             :            endif
     735             :         endif
     736             : 
     737          74 :       end subroutine icepack_init_tracer_indices
     738             : 
     739             : !=======================================================================
     740             : !autodocument_start icepack_query_tracer_indices
     741             : ! query the number of column tracer indices
     742             : 
     743      334938 :       subroutine icepack_query_tracer_indices(&
     744             :            nt_Tsfc_out, nt_qice_out, nt_qsno_out, nt_sice_out, &   ! LCOV_EXCL_LINE
     745             :            nt_fbri_out, nt_iage_out, nt_FY_out, &   ! LCOV_EXCL_LINE
     746             :            nt_alvl_out, nt_vlvl_out, nt_apnd_out, nt_hpnd_out, nt_ipnd_out, &   ! LCOV_EXCL_LINE
     747             :            nt_smice_out, nt_smliq_out, nt_rhos_out, nt_rsnw_out, &   ! LCOV_EXCL_LINE
     748             :            nt_fsd_out, nt_isosno_out, nt_isoice_out, &   ! LCOV_EXCL_LINE
     749             :            nt_aero_out, nt_zaero_out, nt_bgc_C_out, &   ! LCOV_EXCL_LINE
     750             :            nt_bgc_N_out, nt_bgc_chl_out, nt_bgc_DOC_out, nt_bgc_DON_out, &   ! LCOV_EXCL_LINE
     751             :            nt_bgc_DIC_out, nt_bgc_Fed_out, nt_bgc_Fep_out, nt_bgc_Nit_out, nt_bgc_Am_out, &   ! LCOV_EXCL_LINE
     752             :            nt_bgc_Sil_out, nt_bgc_DMSPp_out, nt_bgc_DMSPd_out, nt_bgc_DMS_out, nt_bgc_hum_out, &   ! LCOV_EXCL_LINE
     753             :            nt_bgc_PON_out, nlt_zaero_out, nlt_bgc_C_out, nlt_bgc_N_out, nlt_bgc_chl_out, &   ! LCOV_EXCL_LINE
     754             :            nlt_bgc_DOC_out, nlt_bgc_DON_out, nlt_bgc_DIC_out, nlt_bgc_Fed_out, &   ! LCOV_EXCL_LINE
     755             :            nlt_bgc_Fep_out, nlt_bgc_Nit_out, nlt_bgc_Am_out, nlt_bgc_Sil_out, &   ! LCOV_EXCL_LINE
     756             :            nlt_bgc_DMSPp_out, nlt_bgc_DMSPd_out, nlt_bgc_DMS_out, nlt_bgc_hum_out, &   ! LCOV_EXCL_LINE
     757             :            nlt_bgc_PON_out, nt_zbgc_frac_out, nt_bgc_S_out, nlt_chl_sw_out, &   ! LCOV_EXCL_LINE
     758             :            nlt_zaero_sw_out, &   ! LCOV_EXCL_LINE
     759      334938 :            bio_index_o_out, bio_index_out)
     760             : 
     761             :         integer, intent(out), optional :: &
     762             :              nt_Tsfc_out, & ! ice/snow temperature   ! LCOV_EXCL_LINE
     763             :              nt_qice_out, & ! volume-weighted ice enthalpy (in layers)   ! LCOV_EXCL_LINE
     764             :              nt_qsno_out, & ! volume-weighted snow enthalpy (in layers)   ! LCOV_EXCL_LINE
     765             :              nt_sice_out, & ! volume-weighted ice bulk salinity (CICE grid layers)   ! LCOV_EXCL_LINE
     766             :              nt_fbri_out, & ! volume fraction of ice with dynamic salt (hinS/vicen*aicen)   ! LCOV_EXCL_LINE
     767             :              nt_iage_out, & ! volume-weighted ice age   ! LCOV_EXCL_LINE
     768             :              nt_FY_out, & ! area-weighted first-year ice area   ! LCOV_EXCL_LINE
     769             :              nt_alvl_out, & ! level ice area fraction   ! LCOV_EXCL_LINE
     770             :              nt_vlvl_out, & ! level ice volume fraction   ! LCOV_EXCL_LINE
     771             :              nt_apnd_out, & ! melt pond area fraction   ! LCOV_EXCL_LINE
     772             :              nt_hpnd_out, & ! melt pond depth   ! LCOV_EXCL_LINE
     773             :              nt_ipnd_out, & ! melt pond refrozen lid thickness   ! LCOV_EXCL_LINE
     774             :              nt_smice_out,& ! mass of ice in snow   ! LCOV_EXCL_LINE
     775             :              nt_smliq_out,& ! mass of liquid water in snow   ! LCOV_EXCL_LINE
     776             :              nt_rhos_out, & ! snow density   ! LCOV_EXCL_LINE
     777             :              nt_rsnw_out, & ! snow grain radius   ! LCOV_EXCL_LINE
     778             :              nt_fsd_out,  & ! floe size distribution   ! LCOV_EXCL_LINE
     779             :              nt_isosno_out,  & ! starting index for isotopes in snow   ! LCOV_EXCL_LINE
     780             :              nt_isoice_out,  & ! starting index for isotopes in ice   ! LCOV_EXCL_LINE
     781             :              nt_aero_out,    & ! starting index for aerosols in ice   ! LCOV_EXCL_LINE
     782             :              nt_bgc_Nit_out, & ! nutrients   ! LCOV_EXCL_LINE
     783             :              nt_bgc_Am_out,  & !   ! LCOV_EXCL_LINE
     784             :              nt_bgc_Sil_out, & !   ! LCOV_EXCL_LINE
     785             :              nt_bgc_DMSPp_out,&! trace gases (skeletal layer)   ! LCOV_EXCL_LINE
     786             :              nt_bgc_DMSPd_out,&!   ! LCOV_EXCL_LINE
     787             :              nt_bgc_DMS_out, & !   ! LCOV_EXCL_LINE
     788             :              nt_bgc_hum_out, & !   ! LCOV_EXCL_LINE
     789             :              nt_bgc_PON_out, & ! zooplankton and detritus   ! LCOV_EXCL_LINE
     790             :              nlt_bgc_Nit_out,& ! nutrients   ! LCOV_EXCL_LINE
     791             :              nlt_bgc_Am_out, & !   ! LCOV_EXCL_LINE
     792             :              nlt_bgc_Sil_out,& !   ! LCOV_EXCL_LINE
     793             :              nlt_bgc_DMSPp_out,&! trace gases (skeletal layer)   ! LCOV_EXCL_LINE
     794             :              nlt_bgc_DMSPd_out,&!   ! LCOV_EXCL_LINE
     795             :              nlt_bgc_DMS_out,& !   ! LCOV_EXCL_LINE
     796             :              nlt_bgc_hum_out,& !   ! LCOV_EXCL_LINE
     797             :              nlt_bgc_PON_out,& ! zooplankton and detritus   ! LCOV_EXCL_LINE
     798             :              nt_zbgc_frac_out,&! fraction of tracer in the mobile phase   ! LCOV_EXCL_LINE
     799             :              nt_bgc_S_out,   & ! (deprecated, was related to zsalinity)   ! LCOV_EXCL_LINE
     800             :              nlt_chl_sw_out    ! points to total chla in trcrn_sw
     801             : 
     802             :         integer (kind=int_kind), dimension(:), intent(out), optional :: &
     803             :              bio_index_o_out, &   ! LCOV_EXCL_LINE
     804             :              bio_index_out
     805             : 
     806             :         integer (kind=int_kind), dimension(:), intent(out), optional :: &
     807             :              nt_bgc_N_out ,  & ! diatoms, phaeocystis, pico/small   ! LCOV_EXCL_LINE
     808             :              nt_bgc_C_out ,  & ! diatoms, phaeocystis, pico/small   ! LCOV_EXCL_LINE
     809             :              nt_bgc_chl_out, & ! diatoms, phaeocystis, pico/small   ! LCOV_EXCL_LINE
     810             :              nlt_bgc_N_out , & ! diatoms, phaeocystis, pico/small   ! LCOV_EXCL_LINE
     811             :              nlt_bgc_C_out , & ! diatoms, phaeocystis, pico/small   ! LCOV_EXCL_LINE
     812             :              nlt_bgc_chl_out   ! diatoms, phaeocystis, pico/small
     813             : 
     814             :         integer (kind=int_kind), dimension(:), intent(out), optional :: &
     815             :              nt_bgc_DOC_out, & !  dissolved organic carbon   ! LCOV_EXCL_LINE
     816             :              nlt_bgc_DOC_out   !  dissolved organic carbon
     817             : 
     818             :         integer (kind=int_kind), dimension(:), intent(out), optional :: &
     819             :              nt_bgc_DON_out, & !  dissolved organic nitrogen   ! LCOV_EXCL_LINE
     820             :              nlt_bgc_DON_out   !  dissolved organic nitrogen
     821             : 
     822             :         integer (kind=int_kind), dimension(:), intent(out), optional :: &
     823             :              nt_bgc_DIC_out, & ! dissolved inorganic carbon   ! LCOV_EXCL_LINE
     824             :              nlt_bgc_DIC_out   !  dissolved inorganic carbon
     825             : 
     826             :         integer (kind=int_kind), dimension(:), intent(out), optional :: &
     827             :              nt_bgc_Fed_out, & !  dissolved iron   ! LCOV_EXCL_LINE
     828             :              nt_bgc_Fep_out, & !  particulate iron   ! LCOV_EXCL_LINE
     829             :              nlt_bgc_Fed_out,& !  dissolved iron   ! LCOV_EXCL_LINE
     830             :              nlt_bgc_Fep_out   !  particulate iron
     831             : 
     832             :         integer (kind=int_kind), dimension(:), intent(out), optional :: &
     833             :              nt_zaero_out,   & !  black carbon and other aerosols   ! LCOV_EXCL_LINE
     834             :              nlt_zaero_out,  & !  black carbon and other aerosols   ! LCOV_EXCL_LINE
     835             :              nlt_zaero_sw_out  ! black carbon and dust in trcrn_sw
     836             : 
     837             : !autodocument_end
     838             : 
     839             :         character(len=*),parameter :: subname='(icepack_query_tracer_indices)'
     840             : 
     841      334938 :         if (present(nt_Tsfc_out)) nt_Tsfc_out = nt_Tsfc
     842      334938 :         if (present(nt_qice_out)) nt_qice_out = nt_qice
     843      334938 :         if (present(nt_qsno_out)) nt_qsno_out = nt_qsno
     844      334938 :         if (present(nt_sice_out)) nt_sice_out = nt_sice
     845      334938 :         if (present(nt_fbri_out)) nt_fbri_out = nt_fbri
     846      334938 :         if (present(nt_iage_out)) nt_iage_out = nt_iage
     847      334938 :         if (present(nt_FY_out)  ) nt_FY_out   = nt_FY
     848      334938 :         if (present(nt_alvl_out)) nt_alvl_out = nt_alvl
     849      334938 :         if (present(nt_vlvl_out)) nt_vlvl_out = nt_vlvl
     850      334938 :         if (present(nt_apnd_out)) nt_apnd_out = nt_apnd
     851      334938 :         if (present(nt_hpnd_out)) nt_hpnd_out = nt_hpnd
     852      334938 :         if (present(nt_ipnd_out)) nt_ipnd_out = nt_ipnd
     853      334938 :         if (present(nt_fsd_out) ) nt_fsd_out  = nt_fsd
     854      334938 :         if (present(nt_smice_out)     ) nt_smice_out      = nt_smice
     855      334938 :         if (present(nt_smliq_out)     ) nt_smliq_out      = nt_smliq
     856      334938 :         if (present(nt_rhos_out)      ) nt_rhos_out       = nt_rhos
     857      334938 :         if (present(nt_rsnw_out)      ) nt_rsnw_out       = nt_rsnw
     858      334938 :         if (present(nt_isosno_out)    ) nt_isosno_out     = nt_isosno
     859      334938 :         if (present(nt_isoice_out)    ) nt_isoice_out     = nt_isoice
     860      334938 :         if (present(nt_aero_out)      ) nt_aero_out       = nt_aero
     861      334938 :         if (present(nt_bgc_Nit_out)   ) nt_bgc_Nit_out    = nt_bgc_Nit
     862      334938 :         if (present(nt_bgc_Am_out)    ) nt_bgc_Am_out     = nt_bgc_Am
     863      334938 :         if (present(nt_bgc_Sil_out)   ) nt_bgc_Sil_out    = nt_bgc_Sil
     864      334938 :         if (present(nt_bgc_DMSPp_out) ) nt_bgc_DMSPp_out  = nt_bgc_DMSPp
     865      334938 :         if (present(nt_bgc_DMSPd_out) ) nt_bgc_DMSPd_out  = nt_bgc_DMSPd
     866      334938 :         if (present(nt_bgc_DMS_out)   ) nt_bgc_DMS_out    = nt_bgc_DMS
     867      334938 :         if (present(nt_bgc_hum_out)   ) nt_bgc_hum_out    = nt_bgc_hum
     868      334938 :         if (present(nt_bgc_PON_out)   ) nt_bgc_PON_out    = nt_bgc_PON
     869      334938 :         if (present(nlt_bgc_Nit_out)  ) nlt_bgc_Nit_out   = nlt_bgc_Nit
     870      334938 :         if (present(nlt_bgc_Am_out)   ) nlt_bgc_Am_out    = nlt_bgc_Am
     871      334938 :         if (present(nlt_bgc_Sil_out)  ) nlt_bgc_Sil_out   = nlt_bgc_Sil
     872      334938 :         if (present(nlt_bgc_DMSPp_out)) nlt_bgc_DMSPp_out = nlt_bgc_DMSPp
     873      334938 :         if (present(nlt_bgc_DMSPd_out)) nlt_bgc_DMSPd_out = nlt_bgc_DMSPd
     874      334938 :         if (present(nlt_bgc_DMS_out)  ) nlt_bgc_DMS_out   = nlt_bgc_DMS
     875      334938 :         if (present(nlt_bgc_hum_out)  ) nlt_bgc_hum_out   = nlt_bgc_hum
     876      334938 :         if (present(nlt_bgc_PON_out)  ) nlt_bgc_PON_out   = nlt_bgc_PON
     877      334938 :         if (present(nlt_chl_sw_out)   ) nlt_chl_sw_out    = nlt_chl_sw
     878      334938 :         if (present(nt_zbgc_frac_out) ) nt_zbgc_frac_out  = nt_zbgc_frac
     879      334938 :         if (present(nt_bgc_S_out)     ) nt_bgc_S_out      = nt_bgc_S
     880             : 
     881     1000314 :         if (present(bio_index_o_out) ) bio_index_o_out  = bio_index_o
     882      334938 :         if (present(bio_index_out)   ) bio_index_out    = bio_index
     883      473304 :         if (present(nt_bgc_N_out)    ) nt_bgc_N_out     = nt_bgc_N
     884      404361 :         if (present(nlt_bgc_N_out)   ) nlt_bgc_N_out    = nlt_bgc_N
     885      404250 :         if (present(nt_bgc_C_out)    ) nt_bgc_C_out     = nt_bgc_C
     886      404250 :         if (present(nlt_bgc_C_out)   ) nlt_bgc_C_out    = nlt_bgc_C
     887      404361 :         if (present(nt_bgc_chl_out)  ) nt_bgc_chl_out   = nt_bgc_chl
     888      404361 :         if (present(nlt_bgc_chl_out) ) nlt_bgc_chl_out  = nlt_bgc_chl
     889      404361 :         if (present(nt_bgc_DOC_out)  ) nt_bgc_DOC_out   = nt_bgc_DOC
     890      404361 :         if (present(nlt_bgc_DOC_out) ) nlt_bgc_DOC_out  = nlt_bgc_DOC
     891      358079 :         if (present(nt_bgc_DON_out)  ) nt_bgc_DON_out   = nt_bgc_DON
     892      358079 :         if (present(nlt_bgc_DON_out) ) nlt_bgc_DON_out  = nlt_bgc_DON
     893      358079 :         if (present(nt_bgc_DIC_out)  ) nt_bgc_DIC_out   = nt_bgc_DIC
     894      358079 :         if (present(nlt_bgc_DIC_out) ) nlt_bgc_DIC_out  = nlt_bgc_DIC
     895      381220 :         if (present(nt_bgc_Fed_out)  ) nt_bgc_Fed_out   = nt_bgc_Fed
     896      381220 :         if (present(nlt_bgc_Fed_out) ) nlt_bgc_Fed_out  = nlt_bgc_Fed
     897      381220 :         if (present(nt_bgc_Fep_out)  ) nt_bgc_Fep_out   = nt_bgc_Fep
     898      381220 :         if (present(nlt_bgc_Fep_out) ) nlt_bgc_Fep_out  = nlt_bgc_Fep
     899      611670 :         if (present(nt_zaero_out)    ) nt_zaero_out     = nt_zaero
     900      611448 :         if (present(nlt_zaero_out)   ) nlt_zaero_out    = nlt_zaero
     901      611448 :         if (present(nlt_zaero_sw_out)) nlt_zaero_sw_out = nlt_zaero_sw
     902             : 
     903      334938 :       end subroutine icepack_query_tracer_indices
     904             : 
     905             : !=======================================================================
     906             : !autodocument_start icepack_write_tracer_indices
     907             : ! write the number of column tracer indices
     908             : 
     909           7 :       subroutine icepack_write_tracer_indices(iounit)
     910             : 
     911             :         integer, intent(in) :: iounit
     912             : 
     913             : !autodocument_end
     914             : 
     915             :         ! local
     916             :         integer (kind=int_kind) :: k
     917             :         character(len=*),parameter :: subname='(icepack_write_tracer_indices)'
     918             : 
     919           7 :         write(iounit,*) subname//":"
     920           7 :         write(iounit,*) "  nt_Tsfc = ",nt_Tsfc
     921           7 :         write(iounit,*) "  nt_qice = ",nt_qice
     922           7 :         write(iounit,*) "  nt_qsno = ",nt_qsno
     923           7 :         write(iounit,*) "  nt_sice = ",nt_sice
     924           7 :         write(iounit,*) "  nt_fbri = ",nt_fbri
     925           7 :         write(iounit,*) "  nt_iage = ",nt_iage
     926           7 :         write(iounit,*) "  nt_FY   = ",nt_FY
     927           7 :         write(iounit,*) "  nt_alvl = ",nt_alvl
     928           7 :         write(iounit,*) "  nt_vlvl = ",nt_vlvl
     929           7 :         write(iounit,*) "  nt_apnd = ",nt_apnd
     930           7 :         write(iounit,*) "  nt_hpnd = ",nt_hpnd
     931           7 :         write(iounit,*) "  nt_ipnd = ",nt_ipnd
     932           7 :         write(iounit,*) "  nt_fsd  = ",nt_fsd
     933           7 :         write(iounit,*) "  nt_smice      = ",nt_smice
     934           7 :         write(iounit,*) "  nt_smliq      = ",nt_smliq
     935           7 :         write(iounit,*) "  nt_rhos       = ",nt_rhos
     936           7 :         write(iounit,*) "  nt_rsnw       = ",nt_rsnw
     937           7 :         write(iounit,*) "  nt_isosno     = ",nt_isosno
     938           7 :         write(iounit,*) "  nt_isoice     = ",nt_isoice
     939           7 :         write(iounit,*) "  nt_aero       = ",nt_aero
     940           7 :         write(iounit,*) "  nt_bgc_Nit    = ",nt_bgc_Nit
     941           7 :         write(iounit,*) "  nt_bgc_Am     = ",nt_bgc_Am
     942           7 :         write(iounit,*) "  nt_bgc_Sil    = ",nt_bgc_Sil
     943           7 :         write(iounit,*) "  nt_bgc_DMSPp  = ",nt_bgc_DMSPp
     944           7 :         write(iounit,*) "  nt_bgc_DMSPd  = ",nt_bgc_DMSPd
     945           7 :         write(iounit,*) "  nt_bgc_DMS    = ",nt_bgc_DMS
     946           7 :         write(iounit,*) "  nt_bgc_hum    = ",nt_bgc_hum
     947           7 :         write(iounit,*) "  nt_bgc_PON    = ",nt_bgc_PON
     948           7 :         write(iounit,*) "  nlt_bgc_Nit   = ",nlt_bgc_Nit
     949           7 :         write(iounit,*) "  nlt_bgc_Am    = ",nlt_bgc_Am
     950           7 :         write(iounit,*) "  nlt_bgc_Sil   = ",nlt_bgc_Sil
     951           7 :         write(iounit,*) "  nlt_bgc_DMSPp = ",nlt_bgc_DMSPp
     952           7 :         write(iounit,*) "  nlt_bgc_DMSPd = ",nlt_bgc_DMSPd
     953           7 :         write(iounit,*) "  nlt_bgc_DMS   = ",nlt_bgc_DMS
     954           7 :         write(iounit,*) "  nlt_bgc_hum   = ",nlt_bgc_hum
     955           7 :         write(iounit,*) "  nlt_bgc_PON   = ",nlt_bgc_PON
     956           7 :         write(iounit,*) "  nlt_chl_sw    = ",nlt_chl_sw
     957           7 :         write(iounit,*) "  nt_zbgc_frac  = ",nt_zbgc_frac
     958           7 :         write(iounit,*) "  nt_bgc_S      = ",nt_bgc_S," (deprecated)"
     959             : 
     960           7 :         write(iounit,*) "  max_nbtrcr = ",max_nbtrcr
     961         210 :         do k = 1, max_nbtrcr
     962         203 :            write(iounit,*) "  bio_index_o(k) = ",k,bio_index_o(k)
     963         210 :            write(iounit,*) "  bio_index(k)   = ",k,bio_index(k)
     964             :         enddo
     965             : 
     966           7 :         write(iounit,*) "  max_algae = ",max_algae
     967          28 :         do k = 1, max_algae
     968          21 :            write(iounit,*) "  nt_bgc_N(k)  = ",k,nt_bgc_N(k)
     969          21 :            write(iounit,*) "  nlt_bgc_N(k) = ",k,nlt_bgc_N(k)
     970          21 :            write(iounit,*) "  nt_bgc_C(k)  = ",k,nt_bgc_C(k)
     971          21 :            write(iounit,*) "  nlt_bgc_C(k) = ",k,nlt_bgc_C(k)
     972          21 :            write(iounit,*) "  nt_bgc_chl(k)  = ",k,nt_bgc_chl(k)
     973          28 :            write(iounit,*) "  nlt_bgc_chl(k) = ",k,nlt_bgc_chl(k)
     974             :         enddo
     975             : 
     976           7 :         write(iounit,*) "  max_DOC = ",max_DOC
     977          28 :         do k = 1, max_DOC
     978          21 :            write(iounit,*) "  nt_bgc_DOC(k)  = ",k,nt_bgc_DOC(k)
     979          28 :            write(iounit,*) "  nlt_bgc_DOC(k) = ",k,nlt_bgc_DOC(k)
     980             :         enddo
     981             : 
     982           7 :         write(iounit,*) "  max_DON = ",max_DON
     983          14 :         do k = 1, max_DON
     984           7 :            write(iounit,*) "  nt_bgc_DON(k)  = ",k,nt_bgc_DON(k)
     985          14 :            write(iounit,*) "  nlt_bgc_DON(k) = ",k,nlt_bgc_DON(k)
     986             :         enddo
     987             : 
     988           7 :         write(iounit,*) "  max_DIC = ",max_DIC
     989          14 :         do k = 1, max_DIC
     990           7 :            write(iounit,*) "  nt_bgc_DIC(k)  = ",k,nt_bgc_DIC(k)
     991          14 :            write(iounit,*) "  nlt_bgc_DIC(k) = ",k,nlt_bgc_DIC(k)
     992             :         enddo
     993             : 
     994           7 :         write(iounit,*) "  max_fe = ",max_fe
     995          21 :         do k = 1, max_fe
     996          14 :            write(iounit,*) "  nt_bgc_Fed(k)  = ",k,nt_bgc_Fed(k)
     997          14 :            write(iounit,*) "  nlt_bgc_Fed(k) = ",k,nlt_bgc_Fed(k)
     998          14 :            write(iounit,*) "  nt_bgc_Fep(k)  = ",k,nt_bgc_Fep(k)
     999          21 :            write(iounit,*) "  nlt_bgc_Fep(k) = ",k,nlt_bgc_Fep(k)
    1000             :         enddo
    1001             : 
    1002           7 :         write(iounit,*) "  max_aero = ",max_aero
    1003          49 :         do k = 1, max_aero
    1004          42 :            write(iounit,*) "  nt_zaero(k)     = ",k,nt_zaero(k)
    1005          42 :            write(iounit,*) "  nlt_zaero(k)    = ",k,nlt_zaero(k)
    1006          49 :            write(iounit,*) "  nlt_zaero_sw(k) = ",k,nlt_zaero_sw(k)
    1007             :         enddo
    1008             : 
    1009           7 :       end subroutine icepack_write_tracer_indices
    1010             : 
    1011             : !=======================================================================
    1012             : !autodocument_start icepack_init_tracer_sizes
    1013             : ! set the number of column tracers
    1014             : 
    1015         111 :       subroutine icepack_init_tracer_sizes(&
    1016             :          ncat_in, nilyr_in, nslyr_in, nblyr_in, nfsd_in  , &   ! LCOV_EXCL_LINE
    1017             :          n_algae_in, n_DOC_in, n_aero_in, n_iso_in, &   ! LCOV_EXCL_LINE
    1018             :          n_DON_in, n_DIC_in, n_fed_in, n_fep_in, n_zaero_in, &   ! LCOV_EXCL_LINE
    1019             :          ntrcr_in, ntrcr_o_in, nbtrcr_in, nbtrcr_sw_in)
    1020             : 
    1021             :       integer (kind=int_kind), intent(in), optional :: &
    1022             :          ncat_in   , & ! Categories   ! LCOV_EXCL_LINE
    1023             :          nfsd_in   , & !   ! LCOV_EXCL_LINE
    1024             :          nilyr_in  , & ! Layers   ! LCOV_EXCL_LINE
    1025             :          nslyr_in  , & !   ! LCOV_EXCL_LINE
    1026             :          nblyr_in  , & !   ! LCOV_EXCL_LINE
    1027             :          n_algae_in, & ! Dimensions   ! LCOV_EXCL_LINE
    1028             :          n_DOC_in  , & !   ! LCOV_EXCL_LINE
    1029             :          n_DON_in  , & !   ! LCOV_EXCL_LINE
    1030             :          n_DIC_in  , & !   ! LCOV_EXCL_LINE
    1031             :          n_fed_in  , & !   ! LCOV_EXCL_LINE
    1032             :          n_fep_in  , & !   ! LCOV_EXCL_LINE
    1033             :          n_zaero_in, & !   ! LCOV_EXCL_LINE
    1034             :          n_iso_in  , & !   ! LCOV_EXCL_LINE
    1035             :          n_aero_in , & !   ! LCOV_EXCL_LINE
    1036             :          ntrcr_in  , & ! number of tracers in use   ! LCOV_EXCL_LINE
    1037             :          ntrcr_o_in, & ! number of non-bio tracers in use   ! LCOV_EXCL_LINE
    1038             :          nbtrcr_in , & ! number of bio tracers in use   ! LCOV_EXCL_LINE
    1039             :          nbtrcr_sw_in  ! number of shortwave bio tracers in use
    1040             : 
    1041             : !autodocument_end
    1042             : 
    1043             :         character(len=*),parameter :: subname='(icepack_init_tracer_sizes)'
    1044             : 
    1045         111 :         if (present(ncat_in)     ) ncat      = ncat_in
    1046         111 :         if (present(nilyr_in)    ) nilyr     = nilyr_in
    1047         111 :         if (present(nslyr_in)    ) nslyr     = nslyr_in
    1048         111 :         if (present(nblyr_in)    ) nblyr     = nblyr_in
    1049         111 :         if (present(nfsd_in)     ) nfsd      = nfsd_in
    1050             : 
    1051         111 :         if (present(n_algae_in)  ) n_algae   = n_algae_in
    1052         111 :         if (present(n_DOC_in)    ) n_DOC     = n_DOC_in
    1053         111 :         if (present(n_DON_in)    ) n_DON     = n_DON_in
    1054         111 :         if (present(n_DIC_in)    ) n_DIC     = n_DIC_in
    1055         111 :         if (present(n_fed_in)    ) n_fed     = n_fed_in
    1056         111 :         if (present(n_fep_in)    ) n_fep     = n_fep_in
    1057         111 :         if (present(n_zaero_in)  ) n_zaero   = n_zaero_in
    1058         111 :         if (present(n_iso_in)    ) n_iso     = n_iso_in
    1059         111 :         if (present(n_aero_in)   ) n_aero    = n_aero_in
    1060             : 
    1061         111 :         if (present(ntrcr_in)    ) ntrcr     = ntrcr_in
    1062         111 :         if (present(ntrcr_o_in)  ) ntrcr_o   = ntrcr_o_in
    1063         111 :         if (present(nbtrcr_in)   ) nbtrcr    = nbtrcr_in
    1064         111 :         if (present(nbtrcr_sw_in)) nbtrcr_sw = nbtrcr_sw_in
    1065             : 
    1066         111 :       end subroutine icepack_init_tracer_sizes
    1067             : 
    1068             : !=======================================================================
    1069             : !autodocument_start icepack_query_tracer_sizes
    1070             : ! query the number of column tracers
    1071             : 
    1072      155550 :       subroutine icepack_query_tracer_sizes(&
    1073             :          max_algae_out  , max_dic_out    , max_doc_out      , &   ! LCOV_EXCL_LINE
    1074             :          max_don_out    , max_fe_out     , nmodal1_out      , &   ! LCOV_EXCL_LINE
    1075             :          nmodal2_out    , max_aero_out   , max_nbtrcr_out   , &   ! LCOV_EXCL_LINE
    1076             :          ncat_out, nilyr_out, nslyr_out, nblyr_out, nfsd_out, &   ! LCOV_EXCL_LINE
    1077             :          n_algae_out, n_DOC_out, n_aero_out, n_iso_out, &   ! LCOV_EXCL_LINE
    1078             :          n_DON_out, n_DIC_out, n_fed_out, n_fep_out, n_zaero_out, &   ! LCOV_EXCL_LINE
    1079             :          ntrcr_out, ntrcr_o_out, nbtrcr_out, nbtrcr_sw_out)
    1080             : 
    1081             :       integer (kind=int_kind), intent(out), optional :: &
    1082             :          max_algae_out  , & ! maximum number of algal types   ! LCOV_EXCL_LINE
    1083             :          max_dic_out    , & ! maximum number of dissolved inorganic carbon types   ! LCOV_EXCL_LINE
    1084             :          max_doc_out    , & ! maximum number of dissolved organic carbon types   ! LCOV_EXCL_LINE
    1085             :          max_don_out    , & ! maximum number of dissolved organic nitrogen types   ! LCOV_EXCL_LINE
    1086             :          max_fe_out     , & ! maximum number of iron types   ! LCOV_EXCL_LINE
    1087             :          nmodal1_out    , & ! dimension for modal aerosol radiation parameters   ! LCOV_EXCL_LINE
    1088             :          nmodal2_out    , & ! dimension for modal aerosol radiation parameters   ! LCOV_EXCL_LINE
    1089             :          max_aero_out   , & ! maximum number of aerosols   ! LCOV_EXCL_LINE
    1090             :          max_nbtrcr_out     ! algal nitrogen and chlorophyll
    1091             : 
    1092             :       integer (kind=int_kind), intent(out), optional :: &
    1093             :          ncat_out   , & ! Categories   ! LCOV_EXCL_LINE
    1094             :          nfsd_out   , & !   ! LCOV_EXCL_LINE
    1095             :          nilyr_out  , & ! Layers   ! LCOV_EXCL_LINE
    1096             :          nslyr_out  , & !   ! LCOV_EXCL_LINE
    1097             :          nblyr_out  , & !   ! LCOV_EXCL_LINE
    1098             :          n_algae_out, & ! Dimensions   ! LCOV_EXCL_LINE
    1099             :          n_DOC_out  , & !   ! LCOV_EXCL_LINE
    1100             :          n_DON_out  , & !   ! LCOV_EXCL_LINE
    1101             :          n_DIC_out  , & !   ! LCOV_EXCL_LINE
    1102             :          n_fed_out  , & !   ! LCOV_EXCL_LINE
    1103             :          n_fep_out  , & !   ! LCOV_EXCL_LINE
    1104             :          n_zaero_out, & !   ! LCOV_EXCL_LINE
    1105             :          n_iso_out  , & !   ! LCOV_EXCL_LINE
    1106             :          n_aero_out , & !   ! LCOV_EXCL_LINE
    1107             :          ntrcr_out  , & ! number of tracers in use   ! LCOV_EXCL_LINE
    1108             :          ntrcr_o_out, & ! number of non-bio tracers in use   ! LCOV_EXCL_LINE
    1109             :          nbtrcr_out , & ! number of bio tracers in use   ! LCOV_EXCL_LINE
    1110             :          nbtrcr_sw_out  ! number of shortwave bio tracers in use
    1111             : 
    1112             : !autodocument_end
    1113             : 
    1114             :         character(len=*),parameter :: subname='(icepack_query_tracer_sizes)'
    1115             : 
    1116      155550 :         if (present(max_algae_out))  max_algae_out = max_algae
    1117      155550 :         if (present(max_dic_out))    max_dic_out   = max_dic
    1118      155550 :         if (present(max_doc_out))    max_doc_out   = max_doc
    1119      155550 :         if (present(max_don_out))    max_don_out   = max_don
    1120      155550 :         if (present(max_fe_out))     max_fe_out    = max_fe
    1121      155550 :         if (present(nmodal1_out))    nmodal1_out   = nmodal1
    1122      155550 :         if (present(nmodal2_out))    nmodal2_out   = nmodal2
    1123      155550 :         if (present(max_aero_out))   max_aero_out  = max_aero
    1124      155550 :         if (present(max_nbtrcr_out)) max_nbtrcr_out= max_nbtrcr
    1125             : 
    1126      155550 :         if (present(ncat_out)     ) ncat_out      = ncat
    1127      155550 :         if (present(nilyr_out)    ) nilyr_out     = nilyr
    1128      155550 :         if (present(nslyr_out)    ) nslyr_out     = nslyr
    1129      155550 :         if (present(nblyr_out)    ) nblyr_out     = nblyr
    1130      155550 :         if (present(nfsd_out)     ) nfsd_out      = nfsd
    1131             : 
    1132      155550 :         if (present(n_algae_out)  ) n_algae_out   = n_algae
    1133      155550 :         if (present(n_DOC_out)    ) n_DOC_out     = n_DOC
    1134      155550 :         if (present(n_DON_out)    ) n_DON_out     = n_DON
    1135      155550 :         if (present(n_DIC_out)    ) n_DIC_out     = n_DIC
    1136      155550 :         if (present(n_fed_out)    ) n_fed_out     = n_fed
    1137      155550 :         if (present(n_fep_out)    ) n_fep_out     = n_fep
    1138      155550 :         if (present(n_zaero_out)  ) n_zaero_out   = n_zaero
    1139      155550 :         if (present(n_aero_out)   ) n_aero_out    = n_aero
    1140      155550 :         if (present(n_iso_out)    ) n_iso_out     = n_iso
    1141             : 
    1142      155550 :         if (present(ntrcr_out)    ) ntrcr_out     = ntrcr
    1143      155550 :         if (present(ntrcr_o_out)  ) ntrcr_o_out   = ntrcr_o
    1144      155550 :         if (present(nbtrcr_out)   ) nbtrcr_out    = nbtrcr
    1145      155550 :         if (present(nbtrcr_sw_out)) nbtrcr_sw_out = nbtrcr_sw
    1146             : 
    1147      155550 :       end subroutine icepack_query_tracer_sizes
    1148             : 
    1149             : !=======================================================================
    1150             : !autodocument_start icepack_write_tracer_sizes
    1151             : ! write the number of column tracers
    1152             : 
    1153           7 :       subroutine icepack_write_tracer_sizes(iounit)
    1154             : 
    1155             :       integer (kind=int_kind), intent(in) :: iounit
    1156             : 
    1157             : !autodocument_end
    1158             : 
    1159             :         character(len=*),parameter :: subname='(icepack_write_tracer_sizes)'
    1160             : 
    1161           7 :         write(iounit,*) subname//":"
    1162           7 :         write(iounit,*) "  fixed parameters: "
    1163           7 :         write(iounit,*) "  max_algae_out =", max_algae
    1164           7 :         write(iounit,*) "  max_dic_out   =", max_dic
    1165           7 :         write(iounit,*) "  max_doc_out   =", max_doc
    1166           7 :         write(iounit,*) "  max_don_out   =", max_don
    1167           7 :         write(iounit,*) "  max_fe_out    =", max_fe
    1168           7 :         write(iounit,*) "  nmodal1_out   =", nmodal1
    1169           7 :         write(iounit,*) "  nmodal2_out   =", nmodal2
    1170           7 :         write(iounit,*) "  max_iso_out   =", max_iso
    1171           7 :         write(iounit,*) "  max_aero_out  =", max_aero
    1172           7 :         write(iounit,*) "  max_nbtrcr_out=", max_nbtrcr
    1173             : 
    1174           7 :         write(iounit,*) "  model defined parameters: "
    1175           7 :         write(iounit,*) "  ncat      = ",ncat
    1176           7 :         write(iounit,*) "  nilyr     = ",nilyr
    1177           7 :         write(iounit,*) "  nslyr     = ",nslyr
    1178           7 :         write(iounit,*) "  nblyr     = ",nblyr
    1179           7 :         write(iounit,*) "  nfsd      = ",nfsd
    1180           7 :         write(iounit,*) "  n_algae   = ",n_algae
    1181           7 :         write(iounit,*) "  n_DOC     = ",n_DOC
    1182           7 :         write(iounit,*) "  n_DON     = ",n_DON
    1183           7 :         write(iounit,*) "  n_DIC     = ",n_DIC
    1184           7 :         write(iounit,*) "  n_fed     = ",n_fed
    1185           7 :         write(iounit,*) "  n_fep     = ",n_fep
    1186           7 :         write(iounit,*) "  n_zaero   = ",n_zaero
    1187           7 :         write(iounit,*) "  n_aero    = ",n_aero
    1188           7 :         write(iounit,*) "  n_iso     = ",n_iso
    1189           7 :         write(iounit,*) "  ntrcr     = ",ntrcr
    1190           7 :         write(iounit,*) "  ntrcr_o   = ",ntrcr_o
    1191           7 :         write(iounit,*) "  nbtrcr    = ",nbtrcr
    1192           7 :         write(iounit,*) "  nbtrcr_sw = ",nbtrcr_sw
    1193             : 
    1194           7 :       end subroutine icepack_write_tracer_sizes
    1195             : 
    1196             : !=======================================================================
    1197             : !autodocument_start icepack_compute_tracers
    1198             : ! Compute tracer fields.
    1199             : ! Given atrcrn = aicen*trcrn (or vicen*trcrn, vsnon*trcrn), compute trcrn.
    1200             : 
    1201   237553236 :       subroutine icepack_compute_tracers (ntrcr,     trcr_depend,    &
    1202             :                                           atrcrn,    aicen,          &   ! LCOV_EXCL_LINE
    1203             :                                           vicen,     vsnon,          &   ! LCOV_EXCL_LINE
    1204             :                                           trcr_base, n_trcr_strata,  &   ! LCOV_EXCL_LINE
    1205   237553236 :                                           nt_strata, trcrn, Tf)
    1206             : 
    1207             :       integer (kind=int_kind), intent(in) :: &
    1208             :          ntrcr                 ! number of tracers in use
    1209             : 
    1210             :       integer (kind=int_kind), dimension (ntrcr), intent(in) :: &
    1211             :          trcr_depend, & ! = 0 for aicen tracers, 1 for vicen, 2 for vsnon   ! LCOV_EXCL_LINE
    1212             :          n_trcr_strata  ! number of underlying tracer layers
    1213             : 
    1214             :       real (kind=dbl_kind), dimension (:,:), intent(in) :: &
    1215             :          trcr_base      ! = 0 or 1 depending on tracer dependency
    1216             :                         ! argument 2:  (1) aice, (2) vice, (3) vsno
    1217             : 
    1218             :       integer (kind=int_kind), dimension (:,:), intent(in) :: &
    1219             :          nt_strata      ! indices of underlying tracer layers
    1220             : 
    1221             :       real (kind=dbl_kind), dimension (:), intent(in) :: &
    1222             :          atrcrn    ! aicen*trcrn or vicen*trcrn or vsnon*trcrn
    1223             : 
    1224             :       real (kind=dbl_kind), intent(in) :: &
    1225             :          aicen , & ! concentration of ice   ! LCOV_EXCL_LINE
    1226             :          vicen , & ! volume per unit area of ice          (m)   ! LCOV_EXCL_LINE
    1227             :          vsnon     ! volume per unit area of snow         (m)
    1228             : 
    1229             :       real (kind=dbl_kind), dimension (ntrcr), intent(out) :: &
    1230             :          trcrn     ! ice tracers
    1231             : 
    1232             :       real (kind=dbl_kind), intent(in) :: &
    1233             :          Tf        ! Freezing point
    1234             : 
    1235             : !autodocument_end
    1236             : 
    1237             :       ! local variables
    1238             : 
    1239             :       integer (kind=int_kind) :: &
    1240             :          it,     & ! tracer index   ! LCOV_EXCL_LINE
    1241             :          itl,    & ! tracer index   ! LCOV_EXCL_LINE
    1242             :          ntr,    & ! tracer index   ! LCOV_EXCL_LINE
    1243             :          k         ! loop index
    1244             : 
    1245             :       real (kind=dbl_kind), dimension(3) :: &
    1246   109040728 :          divisor   ! base quantity on which tracers are carried
    1247             : 
    1248             :       real (kind=dbl_kind) :: &
    1249    27260182 :          work      ! temporary scalar
    1250             : 
    1251             :       character(len=*),parameter :: subname='(icepack_compute_tracers)'
    1252             : 
    1253             :       !-----------------------------------------------------------------
    1254             :       ! Compute new tracers
    1255             :       !-----------------------------------------------------------------
    1256             : 
    1257  2969415450 :       do it = 1, ntrcr
    1258  2850638832 :          divisor(1) = trcr_base(it,1)*aicen
    1259  2850638832 :          divisor(2) = trcr_base(it,2)*vicen
    1260  2850638832 :          divisor(3) = trcr_base(it,3)*vsnon
    1261             : 
    1262  2969415450 :          if (trcr_depend(it) == 0) then ! ice area tracers
    1263   475106472 :             if (aicen > puny) then
    1264   332165268 :                trcrn(it) = atrcrn(it) / aicen
    1265             :             else
    1266   142941204 :                trcrn(it) = c0
    1267   142941204 :                if (it == nt_Tsfc) then
    1268    35735301 :                   trcrn(it) = Tf  ! surface temperature
    1269             :                endif
    1270             :             endif
    1271             : 
    1272             :          else
    1273             : 
    1274  2375532360 :             work = c0
    1275  9502129440 :             do k = 1, 3
    1276  9502129440 :                if (divisor(k) > c0) then
    1277  1637526270 :                   work = atrcrn(it) / divisor(k)
    1278             :                endif
    1279             :             enddo
    1280  2375532360 :             trcrn(it) = work                ! save it
    1281  2375532360 :             if (n_trcr_strata(it) > 0) then          ! additional tracer layers
    1282   950212944 :                do itl = 1, n_trcr_strata(it)
    1283   593883090 :                   ntr = nt_strata(it,itl)
    1284   950212944 :                   if (trcrn(ntr) > c0) then
    1285   312603710 :                       trcrn(it) = trcrn(it) / trcrn(ntr)
    1286             :                   else
    1287   281279380 :                       trcrn(it) = c0
    1288             :                   endif
    1289             :                enddo
    1290             :             endif
    1291             : 
    1292             :          endif ! trcr_depend=0
    1293             : 
    1294             :       enddo
    1295             : 
    1296   118776618 :       if (vicen <= c0 .and. tr_brine) trcrn(nt_fbri) = c1
    1297   118776618 :       if (vsnon <= c0) then
    1298    59654600 :          if (snwredist(1:3) == 'ITD') then
    1299           0 :             trcrn(nt_rhos :nt_rhos +nslyr-1) = rhosnew
    1300             :          endif
    1301    59654600 :          if (snwgrain) then
    1302           0 :             trcrn(nt_rsnw :nt_rsnw +nslyr-1) = rsnw_fall
    1303           0 :             trcrn(nt_smice:nt_smice+nslyr-1) = rhos
    1304             :          endif
    1305             :       endif ! vsnon <= 0
    1306             : 
    1307   118776618 :       end subroutine icepack_compute_tracers
    1308             : 
    1309             : !=======================================================================
    1310             : 
    1311             :       end module icepack_tracers
    1312             : 
    1313             : !=======================================================================

Generated by: LCOV version 1.14-6-g40580cd