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

Generated by: LCOV version 1.14-6-g40580cd