LCOV - code coverage report
Current view: top level - icepack/columnphysics - icepack_tracers.F90 (source / functions) Hit Total Coverage
Test: 200617-180449:aec9683041:7:first,base,travis,decomp,reprosum,io,quick Lines: 447 487 91.79 %
Date: 2020-06-17 18:05:09 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        5656 :       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        5656 :         if (present(tr_iage_in)) tr_iage = tr_iage_in
     241        5656 :         if (present(tr_FY_in)  ) tr_FY   = tr_FY_in
     242        5656 :         if (present(tr_lvl_in) ) tr_lvl  = tr_lvl_in
     243        5656 :         if (present(tr_pond_in)) tr_pond = tr_pond_in
     244        5656 :         if (present(tr_pond_cesm_in)) tr_pond_cesm = tr_pond_cesm_in
     245        5656 :         if (present(tr_pond_lvl_in) ) tr_pond_lvl  = tr_pond_lvl_in
     246        5656 :         if (present(tr_pond_topo_in)) tr_pond_topo = tr_pond_topo_in
     247        5656 :         if (present(tr_fsd_in)    ) tr_fsd     = tr_fsd_in
     248        5656 :         if (present(tr_iso_in)    ) tr_iso     = tr_iso_in
     249        5656 :         if (present(tr_aero_in)   ) tr_aero    = tr_aero_in
     250        5656 :         if (present(tr_brine_in)  ) tr_brine   = tr_brine_in
     251        5656 :         if (present(tr_zaero_in)  ) tr_zaero   = tr_zaero_in 
     252        5656 :         if (present(tr_bgc_Nit_in)) tr_bgc_Nit = tr_bgc_Nit_in
     253        5656 :         if (present(tr_bgc_N_in)  ) tr_bgc_N   = tr_bgc_N_in 
     254        5656 :         if (present(tr_bgc_DON_in)) tr_bgc_DON = tr_bgc_DON_in
     255        5656 :         if (present(tr_bgc_C_in)  ) tr_bgc_C   = tr_bgc_C_in 
     256        5656 :         if (present(tr_bgc_chl_in)) tr_bgc_chl = tr_bgc_chl_in
     257        5656 :         if (present(tr_bgc_Am_in) ) tr_bgc_Am  = tr_bgc_Am_in
     258        5656 :         if (present(tr_bgc_Sil_in)) tr_bgc_Sil = tr_bgc_Sil_in
     259        5656 :         if (present(tr_bgc_DMS_in)) tr_bgc_DMS = tr_bgc_DMS_in
     260        5656 :         if (present(tr_bgc_Fe_in )) tr_bgc_Fe  = tr_bgc_Fe_in 
     261        5656 :         if (present(tr_bgc_hum_in)) tr_bgc_hum = tr_bgc_hum_in
     262        5656 :         if (present(tr_bgc_PON_in)) tr_bgc_PON = tr_bgc_PON_in 
     263             : 
     264        5656 :       end subroutine icepack_init_tracer_flags
     265             : 
     266             : !=======================================================================
     267             : !autodocument_start icepack_query_tracer_flags
     268             : ! query tracer active flags
     269             : 
     270    40310392 :       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    40310392 :         if (present(tr_iage_out)) tr_iage_out = tr_iage
     308    40310392 :         if (present(tr_FY_out)  ) tr_FY_out   = tr_FY
     309    40310392 :         if (present(tr_lvl_out) ) tr_lvl_out  = tr_lvl
     310    40310392 :         if (present(tr_pond_out)) tr_pond_out = tr_pond
     311    40310392 :         if (present(tr_pond_cesm_out)) tr_pond_cesm_out = tr_pond_cesm
     312    40310392 :         if (present(tr_pond_lvl_out) ) tr_pond_lvl_out  = tr_pond_lvl
     313    40310392 :         if (present(tr_pond_topo_out)) tr_pond_topo_out = tr_pond_topo
     314    40310392 :         if (present(tr_fsd_out)    ) tr_fsd_out     = tr_fsd
     315    40310392 :         if (present(tr_iso_out)    ) tr_iso_out     = tr_iso
     316    40310392 :         if (present(tr_aero_out)   ) tr_aero_out    = tr_aero
     317    40310392 :         if (present(tr_brine_out)  ) tr_brine_out   = tr_brine
     318    40310392 :         if (present(tr_zaero_out)  ) tr_zaero_out   = tr_zaero
     319    40310392 :         if (present(tr_bgc_Nit_out)) tr_bgc_Nit_out = tr_bgc_Nit
     320    40310392 :         if (present(tr_bgc_N_out)  ) tr_bgc_N_out   = tr_bgc_N
     321    40310392 :         if (present(tr_bgc_DON_out)) tr_bgc_DON_out = tr_bgc_DON
     322    40310392 :         if (present(tr_bgc_C_out)  ) tr_bgc_C_out   = tr_bgc_C
     323    40310392 :         if (present(tr_bgc_chl_out)) tr_bgc_chl_out = tr_bgc_chl
     324    40310392 :         if (present(tr_bgc_Am_out) ) tr_bgc_Am_out  = tr_bgc_Am
     325    40310392 :         if (present(tr_bgc_Sil_out)) tr_bgc_Sil_out = tr_bgc_Sil
     326    40310392 :         if (present(tr_bgc_DMS_out)) tr_bgc_DMS_out = tr_bgc_DMS
     327    40310392 :         if (present(tr_bgc_Fe_out )) tr_bgc_Fe_out  = tr_bgc_Fe
     328    40310392 :         if (present(tr_bgc_hum_out)) tr_bgc_hum_out = tr_bgc_hum
     329    40310392 :         if (present(tr_bgc_PON_out)) tr_bgc_PON_out = tr_bgc_PON
     330             : 
     331    40310392 :       end subroutine icepack_query_tracer_flags
     332             : 
     333             : !=======================================================================
     334             : !autodocument_start icepack_write_tracer_flags
     335             : ! write tracer active flags
     336             : 
     337         249 :       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         249 :         write(iounit,*) subname//":"
     346         249 :         write(iounit,*) "  tr_iage = ",tr_iage
     347         249 :         write(iounit,*) "  tr_FY   = ",tr_FY  
     348         249 :         write(iounit,*) "  tr_lvl  = ",tr_lvl 
     349         249 :         write(iounit,*) "  tr_pond = ",tr_pond
     350         249 :         write(iounit,*) "  tr_pond_cesm = ",tr_pond_cesm
     351         249 :         write(iounit,*) "  tr_pond_lvl  = ",tr_pond_lvl 
     352         249 :         write(iounit,*) "  tr_pond_topo = ",tr_pond_topo
     353         249 :         write(iounit,*) "  tr_fsd     = ",tr_fsd
     354         249 :         write(iounit,*) "  tr_iso     = ",tr_iso   
     355         249 :         write(iounit,*) "  tr_aero    = ",tr_aero
     356         249 :         write(iounit,*) "  tr_brine   = ",tr_brine  
     357         249 :         write(iounit,*) "  tr_zaero   = ",tr_zaero  
     358         249 :         write(iounit,*) "  tr_bgc_Nit = ",tr_bgc_Nit
     359         249 :         write(iounit,*) "  tr_bgc_N   = ",tr_bgc_N  
     360         249 :         write(iounit,*) "  tr_bgc_DON = ",tr_bgc_DON
     361         249 :         write(iounit,*) "  tr_bgc_C   = ",tr_bgc_C  
     362         249 :         write(iounit,*) "  tr_bgc_chl = ",tr_bgc_chl
     363         249 :         write(iounit,*) "  tr_bgc_Am  = ",tr_bgc_Am 
     364         249 :         write(iounit,*) "  tr_bgc_Sil = ",tr_bgc_Sil
     365         249 :         write(iounit,*) "  tr_bgc_DMS = ",tr_bgc_DMS
     366         249 :         write(iounit,*) "  tr_bgc_Fe  = ",tr_bgc_Fe 
     367         249 :         write(iounit,*) "  tr_bgc_hum = ",tr_bgc_hum
     368         249 :         write(iounit,*) "  tr_bgc_PON = ",tr_bgc_PON
     369             : 
     370         249 :       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        5656 :       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       11312 :            nt_aero_in, nt_zaero_in, nt_bgc_C_in, &
     382       22624 :            nt_bgc_N_in, nt_bgc_chl_in, nt_bgc_DOC_in, nt_bgc_DON_in, &
     383       16968 :            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       22624 :            nt_bgc_PON_in, nlt_zaero_in, nlt_bgc_C_in, nlt_bgc_N_in, nlt_bgc_chl_in, &
     386       22624 :            nlt_bgc_DOC_in, nlt_bgc_DON_in, nlt_bgc_DIC_in, nlt_bgc_Fed_in, &
     387        5656 :            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        5656 :            nlt_zaero_sw_in, &
     391        5656 :            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        5656 :         if (present(nt_Tsfc_in)) nt_Tsfc = nt_Tsfc_in
     472        5656 :         if (present(nt_qice_in)) nt_qice = nt_qice_in
     473        5656 :         if (present(nt_qsno_in)) nt_qsno = nt_qsno_in
     474        5656 :         if (present(nt_sice_in)) nt_sice = nt_sice_in
     475        5656 :         if (present(nt_fbri_in)) nt_fbri = nt_fbri_in
     476        5656 :         if (present(nt_iage_in)) nt_iage = nt_iage_in
     477        5656 :         if (present(nt_FY_in)  ) nt_FY   = nt_FY_in
     478        5656 :         if (present(nt_alvl_in)) nt_alvl = nt_alvl_in
     479        5656 :         if (present(nt_vlvl_in)) nt_vlvl = nt_vlvl_in
     480        5656 :         if (present(nt_apnd_in)) nt_apnd = nt_apnd_in
     481        5656 :         if (present(nt_hpnd_in)) nt_hpnd = nt_hpnd_in
     482        5656 :         if (present(nt_ipnd_in)) nt_ipnd = nt_ipnd_in
     483        5656 :         if (present(nt_fsd_in) ) nt_fsd  = nt_fsd_in
     484        5656 :         if (present(nt_isosno_in)    ) nt_isosno     = nt_isosno_in
     485        5656 :         if (present(nt_isoice_in)    ) nt_isoice     = nt_isoice_in
     486        5656 :         if (present(nt_aero_in)      ) nt_aero       = nt_aero_in
     487        5656 :         if (present(nt_bgc_Nit_in)   ) nt_bgc_Nit    = nt_bgc_Nit_in
     488        5656 :         if (present(nt_bgc_Am_in)    ) nt_bgc_Am     = nt_bgc_Am_in
     489        5656 :         if (present(nt_bgc_Sil_in)   ) nt_bgc_Sil    = nt_bgc_Sil_in
     490        5656 :         if (present(nt_bgc_DMSPp_in) ) nt_bgc_DMSPp  = nt_bgc_DMSPp_in
     491        5656 :         if (present(nt_bgc_DMSPd_in) ) nt_bgc_DMSPd  = nt_bgc_DMSPd_in
     492        5656 :         if (present(nt_bgc_DMS_in)   ) nt_bgc_DMS    = nt_bgc_DMS_in
     493        5656 :         if (present(nt_bgc_hum_in)   ) nt_bgc_hum    = nt_bgc_hum_in
     494        5656 :         if (present(nt_bgc_PON_in)   ) nt_bgc_PON    = nt_bgc_PON_in
     495        5656 :         if (present(nlt_bgc_Nit_in)  ) nlt_bgc_Nit   = nlt_bgc_Nit_in
     496        5656 :         if (present(nlt_bgc_Am_in)   ) nlt_bgc_Am    = nlt_bgc_Am_in
     497        5656 :         if (present(nlt_bgc_Sil_in)  ) nlt_bgc_Sil   = nlt_bgc_Sil_in
     498        5656 :         if (present(nlt_bgc_DMSPp_in)) nlt_bgc_DMSPp = nlt_bgc_DMSPp_in
     499        5656 :         if (present(nlt_bgc_DMSPd_in)) nlt_bgc_DMSPd = nlt_bgc_DMSPd_in
     500        5656 :         if (present(nlt_bgc_DMS_in)  ) nlt_bgc_DMS   = nlt_bgc_DMS_in
     501        5656 :         if (present(nlt_bgc_hum_in)  ) nlt_bgc_hum   = nlt_bgc_hum_in
     502        5656 :         if (present(nlt_bgc_PON_in)  ) nlt_bgc_PON   = nlt_bgc_PON_in
     503        5656 :         if (present(nlt_chl_sw_in)   ) nlt_chl_sw    = nlt_chl_sw_in
     504        5656 :         if (present(nt_zbgc_frac_in) ) nt_zbgc_frac  = nt_zbgc_frac_in
     505        5656 :         if (present(nt_bgc_S_in)     ) nt_bgc_S      = nt_bgc_S_in
     506             : 
     507        5656 :         if (present(bio_index_in)) then
     508        2828 :            nsiz = size(bio_index_in)
     509        2828 :            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       84840 :               bio_index(1:nsiz) = bio_index_in(1:nsiz)
     514             :            endif
     515             :         endif
     516             : 
     517        5656 :         if (present(bio_index_o_in)) then
     518        2828 :            nsiz = size(bio_index_o_in)
     519        2828 :            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       84840 :               bio_index_o(1:nsiz) = bio_index_o_in(1:nsiz)
     524             :            endif
     525             :         endif
     526             : 
     527        5656 :         if (present(nt_bgc_N_in)) then
     528        2828 :            nsiz = size(nt_bgc_N_in)
     529        2828 :            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       11312 :               nt_bgc_N(1:nsiz) = nt_bgc_N_in(1:nsiz)
     534             :            endif
     535             :         endif
     536             : 
     537        5656 :         if (present(nlt_bgc_N_in)) then
     538        2828 :            nsiz = size(nlt_bgc_N_in)
     539        2828 :            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       11312 :               nlt_bgc_N(1:nsiz) = nlt_bgc_N_in(1:nsiz)
     544             :            endif
     545             :         endif
     546             : 
     547        5656 :         if (present(nt_bgc_chl_in)) then
     548        2828 :            nsiz = size(nt_bgc_chl_in)
     549        2828 :            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       11312 :               nt_bgc_chl(1:nsiz) = nt_bgc_chl_in(1:nsiz)
     554             :            endif
     555             :         endif
     556             : 
     557        5656 :         if (present(nlt_bgc_chl_in)) then
     558        2828 :            nsiz = size(nlt_bgc_chl_in)
     559        2828 :            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       11312 :               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        5656 :         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        5656 :         if (present(nt_bgc_DOC_in)) then
     594        2828 :            nsiz = size(nt_bgc_DOC_in)
     595        2828 :            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       11312 :               nt_bgc_DOC(1:nsiz) = nt_bgc_DOC_in(1:nsiz)
     600             :            endif
     601             :         endif
     602             : 
     603        5656 :         if (present(nlt_bgc_DOC_in)) then
     604        2828 :            nsiz = size(nlt_bgc_DOC_in)
     605        2828 :            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       11312 :               nlt_bgc_DOC(1:nsiz) = nlt_bgc_DOC_in(1:nsiz)
     610             :            endif
     611             :         endif
     612             : 
     613        5656 :         if (present(nt_bgc_DON_in)) then
     614        2828 :            nsiz = size(nt_bgc_DON_in)
     615        2828 :            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        5656 :               nt_bgc_DON(1:nsiz) = nt_bgc_DON_in(1:nsiz)
     620             :            endif
     621             :         endif
     622             : 
     623        5656 :         if (present(nlt_bgc_DON_in)) then
     624        2828 :            nsiz = size(nlt_bgc_DON_in)
     625        2828 :            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        5656 :               nlt_bgc_DON(1:nsiz) = nlt_bgc_DON_in(1:nsiz)
     630             :            endif
     631             :         endif
     632             : 
     633        5656 :         if (present(nt_bgc_DIC_in)) then
     634        2828 :            nsiz = size(nt_bgc_DIC_in)
     635        2828 :            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        5656 :               nt_bgc_DIC(1:nsiz) = nt_bgc_DIC_in(1:nsiz)
     640             :            endif
     641             :         endif
     642             : 
     643        5656 :         if (present(nlt_bgc_DIC_in)) then
     644        2828 :            nsiz = size(nlt_bgc_DIC_in)
     645        2828 :            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        5656 :               nlt_bgc_DIC(1:nsiz) = nlt_bgc_DIC_in(1:nsiz)
     650             :            endif
     651             :         endif
     652             : 
     653        5656 :         if (present(nt_bgc_Fed_in)) then
     654        2828 :            nsiz = size(nt_bgc_Fed_in)
     655        2828 :            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        8484 :               nt_bgc_Fed(1:nsiz) = nt_bgc_Fed_in(1:nsiz)
     660             :            endif
     661             :         endif
     662             : 
     663        5656 :         if (present(nlt_bgc_Fed_in)) then
     664        2828 :            nsiz = size(nlt_bgc_Fed_in)
     665        2828 :            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        8484 :               nlt_bgc_Fed(1:nsiz) = nlt_bgc_Fed_in(1:nsiz)
     670             :            endif
     671             :         endif
     672             : 
     673        5656 :         if (present(nt_bgc_Fep_in)) then
     674        2828 :            nsiz = size(nt_bgc_Fep_in)
     675        2828 :            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        8484 :               nt_bgc_Fep(1:nsiz) = nt_bgc_Fep_in(1:nsiz)
     680             :            endif
     681             :         endif
     682             : 
     683        5656 :         if (present(nlt_bgc_Fep_in)) then
     684        2828 :            nsiz = size(nlt_bgc_Fep_in)
     685        2828 :            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        8484 :               nlt_bgc_Fep(1:nsiz) = nlt_bgc_Fep_in(1:nsiz)
     690             :            endif
     691             :         endif
     692             : 
     693        5656 :         if (present(nt_zaero_in)) then
     694        2828 :            nsiz = size(nt_zaero_in)
     695        2828 :            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       19796 :               nt_zaero(1:nsiz) = nt_zaero_in(1:nsiz)
     700             :            endif
     701             :         endif
     702             : 
     703        5656 :         if (present(nlt_zaero_in)) then
     704        2828 :            nsiz = size(nlt_zaero_in)
     705        2828 :            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       19796 :               nlt_zaero(1:nsiz) = nlt_zaero_in(1:nsiz)
     710             :            endif
     711             :         endif
     712             : 
     713        5656 :         if (present(nlt_zaero_sw_in)) then
     714        2828 :            nsiz = size(nlt_zaero_sw_in)
     715        2828 :            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       19796 :               nlt_zaero_sw(1:nsiz) = nlt_zaero_sw_in(1:nsiz)
     720             :            endif
     721             :         endif
     722             : 
     723        5656 :       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    48676886 :       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    97353772 :            nt_aero_out, nt_zaero_out, nt_bgc_C_out, &
     735   194707544 :            nt_bgc_N_out, nt_bgc_chl_out, nt_bgc_DOC_out, nt_bgc_DON_out, &
     736   146030658 :            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   194707544 :            nt_bgc_PON_out, nlt_zaero_out, nlt_bgc_C_out, nlt_bgc_N_out, nlt_bgc_chl_out, &
     739   194707544 :            nlt_bgc_DOC_out, nlt_bgc_DON_out, nlt_bgc_DIC_out, nlt_bgc_Fed_out, &
     740    48676886 :            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    48676886 :            nlt_zaero_sw_out, &
     744    48676886 :            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    48676886 :         if (present(nt_Tsfc_out)) nt_Tsfc_out = nt_Tsfc
     823    48676886 :         if (present(nt_qice_out)) nt_qice_out = nt_qice
     824    48676886 :         if (present(nt_qsno_out)) nt_qsno_out = nt_qsno
     825    48676886 :         if (present(nt_sice_out)) nt_sice_out = nt_sice
     826    48676886 :         if (present(nt_fbri_out)) nt_fbri_out = nt_fbri
     827    48676886 :         if (present(nt_iage_out)) nt_iage_out = nt_iage
     828    48676886 :         if (present(nt_FY_out)  ) nt_FY_out   = nt_FY
     829    48676886 :         if (present(nt_alvl_out)) nt_alvl_out = nt_alvl
     830    48676886 :         if (present(nt_vlvl_out)) nt_vlvl_out = nt_vlvl
     831    48676886 :         if (present(nt_apnd_out)) nt_apnd_out = nt_apnd
     832    48676886 :         if (present(nt_hpnd_out)) nt_hpnd_out = nt_hpnd
     833    48676886 :         if (present(nt_ipnd_out)) nt_ipnd_out = nt_ipnd
     834    48676886 :         if (present(nt_fsd_out) ) nt_fsd_out  = nt_fsd
     835    48676886 :         if (present(nt_isosno_out)    ) nt_isosno_out     = nt_isosno
     836    48676886 :         if (present(nt_isoice_out)    ) nt_isoice_out     = nt_isoice
     837    48676886 :         if (present(nt_aero_out)      ) nt_aero_out       = nt_aero
     838    48676886 :         if (present(nt_bgc_Nit_out)   ) nt_bgc_Nit_out    = nt_bgc_Nit
     839    48676886 :         if (present(nt_bgc_Am_out)    ) nt_bgc_Am_out     = nt_bgc_Am
     840    48676886 :         if (present(nt_bgc_Sil_out)   ) nt_bgc_Sil_out    = nt_bgc_Sil
     841    48676886 :         if (present(nt_bgc_DMSPp_out) ) nt_bgc_DMSPp_out  = nt_bgc_DMSPp
     842    48676886 :         if (present(nt_bgc_DMSPd_out) ) nt_bgc_DMSPd_out  = nt_bgc_DMSPd
     843    48676886 :         if (present(nt_bgc_DMS_out)   ) nt_bgc_DMS_out    = nt_bgc_DMS
     844    48676886 :         if (present(nt_bgc_hum_out)   ) nt_bgc_hum_out    = nt_bgc_hum
     845    48676886 :         if (present(nt_bgc_PON_out)   ) nt_bgc_PON_out    = nt_bgc_PON
     846    48676886 :         if (present(nlt_bgc_Nit_out)  ) nlt_bgc_Nit_out   = nlt_bgc_Nit
     847    48676886 :         if (present(nlt_bgc_Am_out)   ) nlt_bgc_Am_out    = nlt_bgc_Am
     848    48676886 :         if (present(nlt_bgc_Sil_out)  ) nlt_bgc_Sil_out   = nlt_bgc_Sil
     849    48676886 :         if (present(nlt_bgc_DMSPp_out)) nlt_bgc_DMSPp_out = nlt_bgc_DMSPp
     850    48676886 :         if (present(nlt_bgc_DMSPd_out)) nlt_bgc_DMSPd_out = nlt_bgc_DMSPd
     851    48676886 :         if (present(nlt_bgc_DMS_out)  ) nlt_bgc_DMS_out   = nlt_bgc_DMS
     852    48676886 :         if (present(nlt_bgc_hum_out)  ) nlt_bgc_hum_out   = nlt_bgc_hum
     853    48676886 :         if (present(nlt_bgc_PON_out)  ) nlt_bgc_PON_out   = nlt_bgc_PON
     854    48676886 :         if (present(nlt_chl_sw_out)   ) nlt_chl_sw_out    = nlt_chl_sw
     855    48676886 :         if (present(nt_zbgc_frac_out) ) nt_zbgc_frac_out  = nt_zbgc_frac
     856    48676886 :         if (present(nt_bgc_S_out)     ) nt_bgc_S_out      = nt_bgc_S
     857             : 
     858   175114334 :         if (present(bio_index_o_out) ) bio_index_o_out  = bio_index_o
     859    48676886 :         if (present(bio_index_out)   ) bio_index_out    = bio_index
     860    74928458 :         if (present(nt_bgc_N_out)    ) nt_bgc_N_out     = nt_bgc_N 
     861    61836608 :         if (present(nlt_bgc_N_out)   ) nlt_bgc_N_out    = nlt_bgc_N 
     862    61818587 :         if (present(nt_bgc_C_out)    ) nt_bgc_C_out     = nt_bgc_C 
     863    61814957 :         if (present(nlt_bgc_C_out)   ) nlt_bgc_C_out    = nlt_bgc_C 
     864    61827071 :         if (present(nt_bgc_chl_out)  ) nt_bgc_chl_out   = nt_bgc_chl 
     865    61823441 :         if (present(nlt_bgc_chl_out) ) nlt_bgc_chl_out  = nlt_bgc_chl 
     866    61840238 :         if (present(nt_bgc_DOC_out)  ) nt_bgc_DOC_out   = nt_bgc_DOC 
     867    61836608 :         if (present(nlt_bgc_DOC_out) ) nlt_bgc_DOC_out  = nlt_bgc_DOC 
     868    53064670 :         if (present(nt_bgc_DON_out)  ) nt_bgc_DON_out   = nt_bgc_DON 
     869    53063460 :         if (present(nlt_bgc_DON_out) ) nlt_bgc_DON_out  = nlt_bgc_DON 
     870    53060281 :         if (present(nt_bgc_DIC_out)  ) nt_bgc_DIC_out   = nt_bgc_DIC 
     871    53059071 :         if (present(nlt_bgc_DIC_out) ) nlt_bgc_DIC_out  = nlt_bgc_DIC 
     872    57452454 :         if (present(nt_bgc_Fed_out)  ) nt_bgc_Fed_out   = nt_bgc_Fed 
     873    57450034 :         if (present(nlt_bgc_Fed_out) ) nlt_bgc_Fed_out  = nlt_bgc_Fed 
     874    57452454 :         if (present(nt_bgc_Fep_out)  ) nt_bgc_Fep_out   = nt_bgc_Fep 
     875    57450034 :         if (present(nlt_bgc_Fep_out) ) nlt_bgc_Fep_out  = nlt_bgc_Fep 
     876   101180030 :         if (present(nt_zaero_out)    ) nt_zaero_out     = nt_zaero   
     877   101451866 :         if (present(nlt_zaero_out)   ) nlt_zaero_out    = nlt_zaero   
     878   101155802 :         if (present(nlt_zaero_sw_out)) nlt_zaero_sw_out = nlt_zaero_sw   
     879             : 
     880    48676886 :       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         249 :       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         249 :         write(iounit,*) subname//":"
     897         249 :         write(iounit,*) "  nt_Tsfc = ",nt_Tsfc
     898         249 :         write(iounit,*) "  nt_qice = ",nt_qice
     899         249 :         write(iounit,*) "  nt_qsno = ",nt_qsno
     900         249 :         write(iounit,*) "  nt_sice = ",nt_sice
     901         249 :         write(iounit,*) "  nt_fbri = ",nt_fbri
     902         249 :         write(iounit,*) "  nt_iage = ",nt_iage
     903         249 :         write(iounit,*) "  nt_FY   = ",nt_FY  
     904         249 :         write(iounit,*) "  nt_alvl = ",nt_alvl
     905         249 :         write(iounit,*) "  nt_vlvl = ",nt_vlvl
     906         249 :         write(iounit,*) "  nt_apnd = ",nt_apnd
     907         249 :         write(iounit,*) "  nt_hpnd = ",nt_hpnd
     908         249 :         write(iounit,*) "  nt_ipnd = ",nt_ipnd
     909         249 :         write(iounit,*) "  nt_fsd  = ",nt_fsd
     910         249 :         write(iounit,*) "  nt_isosno     = ",nt_isosno
     911         249 :         write(iounit,*) "  nt_isoice     = ",nt_isoice
     912         249 :         write(iounit,*) "  nt_aero       = ",nt_aero
     913         249 :         write(iounit,*) "  nt_bgc_Nit    = ",nt_bgc_Nit   
     914         249 :         write(iounit,*) "  nt_bgc_Am     = ",nt_bgc_Am    
     915         249 :         write(iounit,*) "  nt_bgc_Sil    = ",nt_bgc_Sil   
     916         249 :         write(iounit,*) "  nt_bgc_DMSPp  = ",nt_bgc_DMSPp 
     917         249 :         write(iounit,*) "  nt_bgc_DMSPd  = ",nt_bgc_DMSPd 
     918         249 :         write(iounit,*) "  nt_bgc_DMS    = ",nt_bgc_DMS   
     919         249 :         write(iounit,*) "  nt_bgc_hum    = ",nt_bgc_hum   
     920         249 :         write(iounit,*) "  nt_bgc_PON    = ",nt_bgc_PON   
     921         249 :         write(iounit,*) "  nlt_bgc_Nit   = ",nlt_bgc_Nit  
     922         249 :         write(iounit,*) "  nlt_bgc_Am    = ",nlt_bgc_Am   
     923         249 :         write(iounit,*) "  nlt_bgc_Sil   = ",nlt_bgc_Sil  
     924         249 :         write(iounit,*) "  nlt_bgc_DMSPp = ",nlt_bgc_DMSPp
     925         249 :         write(iounit,*) "  nlt_bgc_DMSPd = ",nlt_bgc_DMSPd
     926         249 :         write(iounit,*) "  nlt_bgc_DMS   = ",nlt_bgc_DMS  
     927         249 :         write(iounit,*) "  nlt_bgc_hum   = ",nlt_bgc_hum  
     928         249 :         write(iounit,*) "  nlt_bgc_PON   = ",nlt_bgc_PON  
     929         249 :         write(iounit,*) "  nlt_chl_sw    = ",nlt_chl_sw   
     930         249 :         write(iounit,*) "  nt_zbgc_frac  = ",nt_zbgc_frac 
     931         249 :         write(iounit,*) "  nt_bgc_S      = ",nt_bgc_S     
     932             : 
     933         249 :         write(iounit,*) "  max_nbtrcr = ",max_nbtrcr
     934        7470 :         do k = 1, max_nbtrcr
     935        7221 :            write(iounit,*) "  bio_index_o(k) = ",k,bio_index_o(k)
     936        7470 :            write(iounit,*) "  bio_index(k)   = ",k,bio_index(k)  
     937             :         enddo
     938             : 
     939         249 :         write(iounit,*) "  max_algae = ",max_algae
     940         996 :         do k = 1, max_algae
     941         747 :            write(iounit,*) "  nt_bgc_N(k)  = ",k,nt_bgc_N(k)
     942         747 :            write(iounit,*) "  nlt_bgc_N(k) = ",k,nlt_bgc_N(k)
     943         747 :            write(iounit,*) "  nt_bgc_C(k)  = ",k,nt_bgc_C(k)
     944         747 :            write(iounit,*) "  nlt_bgc_C(k) = ",k,nlt_bgc_C(k)
     945         747 :            write(iounit,*) "  nt_bgc_chl(k)  = ",k,nt_bgc_chl(k) 
     946         996 :            write(iounit,*) "  nlt_bgc_chl(k) = ",k,nlt_bgc_chl(k)
     947             :         enddo
     948             : 
     949         249 :         write(iounit,*) "  max_DOC = ",max_DOC
     950         996 :         do k = 1, max_DOC
     951         747 :            write(iounit,*) "  nt_bgc_DOC(k)  = ",k,nt_bgc_DOC(k) 
     952         996 :            write(iounit,*) "  nlt_bgc_DOC(k) = ",k,nlt_bgc_DOC(k)
     953             :         enddo
     954             : 
     955         249 :         write(iounit,*) "  max_DON = ",max_DON
     956         498 :         do k = 1, max_DON
     957         249 :            write(iounit,*) "  nt_bgc_DON(k)  = ",k,nt_bgc_DON(k) 
     958         498 :            write(iounit,*) "  nlt_bgc_DON(k) = ",k,nlt_bgc_DON(k)
     959             :         enddo
     960             : 
     961         249 :         write(iounit,*) "  max_DIC = ",max_DIC
     962         498 :         do k = 1, max_DIC
     963         249 :            write(iounit,*) "  nt_bgc_DIC(k)  = ",k,nt_bgc_DIC(k) 
     964         498 :            write(iounit,*) "  nlt_bgc_DIC(k) = ",k,nlt_bgc_DIC(k)
     965             :         enddo
     966             : 
     967         249 :         write(iounit,*) "  max_fe = ",max_fe
     968         747 :         do k = 1, max_fe
     969         498 :            write(iounit,*) "  nt_bgc_Fed(k)  = ",k,nt_bgc_Fed(k) 
     970         498 :            write(iounit,*) "  nlt_bgc_Fed(k) = ",k,nlt_bgc_Fed(k)
     971         498 :            write(iounit,*) "  nt_bgc_Fep(k)  = ",k,nt_bgc_Fep(k) 
     972         747 :            write(iounit,*) "  nlt_bgc_Fep(k) = ",k,nlt_bgc_Fep(k)
     973             :         enddo
     974             : 
     975         249 :         write(iounit,*) "  max_aero = ",max_aero
     976        1743 :         do k = 1, max_aero
     977        1494 :            write(iounit,*) "  nt_zaero(k)     = ",k,nt_zaero(k)    
     978        1494 :            write(iounit,*) "  nlt_zaero(k)    = ",k,nlt_zaero(k)   
     979        1743 :            write(iounit,*) "  nlt_zaero_sw(k) = ",k,nlt_zaero_sw(k)
     980             :         enddo
     981             : 
     982         249 :       end subroutine icepack_write_tracer_indices
     983             : 
     984             : !=======================================================================
     985             : !autodocument_start icepack_init_tracer_sizes
     986             : ! set the number of column tracers
     987             : 
     988        5656 :       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        5656 :         if (present(ncat_in)     ) ncat      = ncat_in
    1019        5656 :         if (present(nilyr_in)    ) nilyr     = nilyr_in
    1020        5656 :         if (present(nslyr_in)    ) nslyr     = nslyr_in
    1021        5656 :         if (present(nblyr_in)    ) nblyr     = nblyr_in
    1022        5656 :         if (present(nfsd_in)     ) nfsd      = nfsd_in
    1023             : 
    1024        5656 :         if (present(n_algae_in)  ) n_algae   = n_algae_in
    1025        5656 :         if (present(n_DOC_in)    ) n_DOC     = n_DOC_in
    1026        5656 :         if (present(n_DON_in)    ) n_DON     = n_DON_in
    1027        5656 :         if (present(n_DIC_in)    ) n_DIC     = n_DIC_in
    1028        5656 :         if (present(n_fed_in)    ) n_fed     = n_fed_in
    1029        5656 :         if (present(n_fep_in)    ) n_fep     = n_fep_in
    1030        5656 :         if (present(n_zaero_in)  ) n_zaero   = n_zaero_in
    1031        5656 :         if (present(n_iso_in)    ) n_iso     = n_iso_in
    1032        5656 :         if (present(n_aero_in)   ) n_aero    = n_aero_in
    1033             : 
    1034        5656 :         if (present(ntrcr_in)    ) ntrcr     = ntrcr_in
    1035        5656 :         if (present(ntrcr_o_in)  ) ntrcr_o   = ntrcr_o_in
    1036        5656 :         if (present(nbtrcr_in)   ) nbtrcr    = nbtrcr_in
    1037        5656 :         if (present(nbtrcr_sw_in)) nbtrcr_sw = nbtrcr_sw_in
    1038             : 
    1039        5656 :       end subroutine icepack_init_tracer_sizes
    1040             : 
    1041             : !=======================================================================
    1042             : !autodocument_start icepack_query_tracer_sizes
    1043             : ! query the number of column tracers
    1044             : 
    1045    28073134 :       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    28073134 :         if (present(max_algae_out))  max_algae_out = max_algae
    1090    28073134 :         if (present(max_dic_out))    max_dic_out   = max_dic
    1091    28073134 :         if (present(max_doc_out))    max_doc_out   = max_doc
    1092    28073134 :         if (present(max_don_out))    max_don_out   = max_don
    1093    28073134 :         if (present(max_fe_out))     max_fe_out    = max_fe
    1094    28073134 :         if (present(nmodal1_out))    nmodal1_out   = nmodal1
    1095    28073134 :         if (present(nmodal2_out))    nmodal2_out   = nmodal2
    1096    28073134 :         if (present(max_aero_out))   max_aero_out  = max_aero
    1097    28073134 :         if (present(max_nbtrcr_out)) max_nbtrcr_out= max_nbtrcr
    1098             : 
    1099    28073134 :         if (present(ncat_out)     ) ncat_out      = ncat
    1100    28073134 :         if (present(nilyr_out)    ) nilyr_out     = nilyr
    1101    28073134 :         if (present(nslyr_out)    ) nslyr_out     = nslyr
    1102    28073134 :         if (present(nblyr_out)    ) nblyr_out     = nblyr
    1103    28073134 :         if (present(nfsd_out)     ) nfsd_out      = nfsd
    1104             : 
    1105    28073134 :         if (present(n_algae_out)  ) n_algae_out   = n_algae
    1106    28073134 :         if (present(n_DOC_out)    ) n_DOC_out     = n_DOC
    1107    28073134 :         if (present(n_DON_out)    ) n_DON_out     = n_DON
    1108    28073134 :         if (present(n_DIC_out)    ) n_DIC_out     = n_DIC
    1109    28073134 :         if (present(n_fed_out)    ) n_fed_out     = n_fed
    1110    28073134 :         if (present(n_fep_out)    ) n_fep_out     = n_fep
    1111    28073134 :         if (present(n_zaero_out)  ) n_zaero_out   = n_zaero
    1112    28073134 :         if (present(n_aero_out)   ) n_aero_out    = n_aero
    1113    28073134 :         if (present(n_iso_out)    ) n_iso_out     = n_iso
    1114             : 
    1115    28073134 :         if (present(ntrcr_out)    ) ntrcr_out     = ntrcr
    1116    28073134 :         if (present(ntrcr_o_out)  ) ntrcr_o_out   = ntrcr_o
    1117    28073134 :         if (present(nbtrcr_out)   ) nbtrcr_out    = nbtrcr
    1118    28073134 :         if (present(nbtrcr_sw_out)) nbtrcr_sw_out = nbtrcr_sw
    1119             : 
    1120    28073134 :       end subroutine icepack_query_tracer_sizes
    1121             : 
    1122             : !=======================================================================
    1123             : !autodocument_start icepack_write_tracer_sizes
    1124             : ! write the number of column tracers
    1125             : 
    1126         249 :       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         249 :         write(iounit,*) subname//":"
    1135         249 :         write(iounit,*) "  fixed parameters: "
    1136         249 :         write(iounit,*) "  max_algae_out =", max_algae
    1137         249 :         write(iounit,*) "  max_dic_out   =", max_dic
    1138         249 :         write(iounit,*) "  max_doc_out   =", max_doc
    1139         249 :         write(iounit,*) "  max_don_out   =", max_don
    1140         249 :         write(iounit,*) "  max_fe_out    =", max_fe
    1141         249 :         write(iounit,*) "  nmodal1_out   =", nmodal1
    1142         249 :         write(iounit,*) "  nmodal2_out   =", nmodal2
    1143         249 :         write(iounit,*) "  max_iso_out   =", max_iso
    1144         249 :         write(iounit,*) "  max_aero_out  =", max_aero
    1145         249 :         write(iounit,*) "  max_nbtrcr_out=", max_nbtrcr
    1146             : 
    1147         249 :         write(iounit,*) "  model defined parameters: "
    1148         249 :         write(iounit,*) "  ncat      = ",ncat
    1149         249 :         write(iounit,*) "  nilyr     = ",nilyr
    1150         249 :         write(iounit,*) "  nslyr     = ",nslyr
    1151         249 :         write(iounit,*) "  nblyr     = ",nblyr
    1152         249 :         write(iounit,*) "  nfsd      = ",nfsd
    1153         249 :         write(iounit,*) "  n_algae   = ",n_algae
    1154         249 :         write(iounit,*) "  n_DOC     = ",n_DOC
    1155         249 :         write(iounit,*) "  n_DON     = ",n_DON
    1156         249 :         write(iounit,*) "  n_DIC     = ",n_DIC
    1157         249 :         write(iounit,*) "  n_fed     = ",n_fed
    1158         249 :         write(iounit,*) "  n_fep     = ",n_fep
    1159         249 :         write(iounit,*) "  n_zaero   = ",n_zaero
    1160         249 :         write(iounit,*) "  n_aero    = ",n_aero
    1161         249 :         write(iounit,*) "  n_iso     = ",n_iso
    1162         249 :         write(iounit,*) "  ntrcr     = ",ntrcr
    1163         249 :         write(iounit,*) "  ntrcr_o   = ",ntrcr_o
    1164         249 :         write(iounit,*) "  nbtrcr    = ",nbtrcr
    1165         249 :         write(iounit,*) "  nbtrcr_sw = ",nbtrcr_sw
    1166             : 
    1167         249 :       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 14324674796 :       subroutine icepack_compute_tracers (ntrcr,     trcr_depend,    &
    1175  7162337398 :                                          atrcrn,    aicen,          &
    1176             :                                          vicen,     vsnon,          &
    1177  7162337398 :                                          trcr_base, n_trcr_strata,  &
    1178 14324674796 :                                          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  1727283112 :          divisor   ! base quantity on which tracers are carried
    1217             : 
    1218             :       real (kind=dbl_kind) :: &
    1219   431820778 :          work      ! temporary scalar
    1220             : 
    1221             :       character(len=*),parameter :: subname='(icepack_compute_tracers)'
    1222             : 
    1223             :       !-----------------------------------------------------------------
    1224             :       ! Compute new tracers
    1225             :       !-----------------------------------------------------------------
    1226             : 
    1227 >27725*10^7 :       do it = 1, ntrcr
    1228 >27009*10^7 :          divisor(1) = trcr_base(it,1)*aicen
    1229 >27009*10^7 :          divisor(2) = trcr_base(it,2)*vicen
    1230 >27009*10^7 :          divisor(3) = trcr_base(it,3)*vsnon
    1231             : 
    1232 >27725*10^7 :          if (trcr_depend(it) == 0) then ! ice area tracers
    1233 37526207462 :             if (aicen > puny) then  
    1234  9551905367 :                trcrn(it) = atrcrn(it) / aicen
    1235             :             else
    1236 27974302095 :                trcrn(it) = c0
    1237 27974302095 :                if (it == nt_Tsfc) trcrn(it) = Tocnfrz  ! surface temperature
    1238             :             endif
    1239             : 
    1240             :          else
    1241             : 
    1242 >23256*10^7 :             work = c0
    1243 >93026*10^7 :             do k = 1, 3
    1244 >93026*10^7 :                if (divisor(k) > c0) then
    1245 51423485340 :                   work = atrcrn(it) / divisor(k)
    1246             :                endif
    1247             :             enddo
    1248 >23256*10^7 :             trcrn(it) = work                ! save it
    1249 >23256*10^7 :             if (n_trcr_strata(it) > 0) then          ! additional tracer layers
    1250 50047681068 :                do itl = 1, n_trcr_strata(it)
    1251 31095937838 :                   ntr = nt_strata(it,itl)
    1252 50047681068 :                   if (trcrn(ntr) > c0) then
    1253  6277949183 :                       trcrn(it) = trcrn(it) / trcrn(ntr)
    1254             :                   else
    1255 24817988655 :                       trcrn(it) = c0
    1256             :                   endif
    1257             :                enddo
    1258             :             endif
    1259 >23256*10^7 :             if (vicen <= c0 .and. it == nt_fbri) trcrn(it) = c1
    1260             : 
    1261             :          endif ! trcr_depend=0
    1262             : 
    1263             :       enddo
    1264             : 
    1265  7162337398 :     end subroutine icepack_compute_tracers
    1266             : 
    1267             : !=======================================================================
    1268             : 
    1269             :       end module icepack_tracers
    1270             : 
    1271             : !=======================================================================

Generated by: LCOV version 1.14-6-g40580cd