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

Generated by: LCOV version 1.14-6-g40580cd