LCOV - code coverage report
Current view: top level - cicecore/cicedyn/analysis - ice_history_bgc.F90 (source / functions) Hit Total Coverage
Test: 231018-211459:8916b9ff2c:1:quick Lines: 476 1745 27.28 %
Date: 2023-10-18 15:30:36 Functions: 6 6 100.00 %

          Line data    Source code
       1             : !=======================================================================
       2             : ! Biogeochemistry history output
       3             : !
       4             : ! authors Elizabeth C. Hunke and Nicole Jeffery, LANL
       5             : !
       6             : ! 2012 Elizabeth Hunke split code from ice_history.F90
       7             : 
       8             :       module ice_history_bgc
       9             : 
      10             :       use ice_kinds_mod
      11             :       use ice_constants
      12             :       use ice_fileunits, only: nu_nml, nml_filename, &
      13             :           get_fileunit, release_fileunit
      14             :       use ice_fileunits, only: nu_diag
      15             :       use ice_exit, only: abort_ice
      16             :       use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted
      17             :       use icepack_intfc, only: icepack_max_iso, icepack_max_aero, &
      18             :           icepack_max_dic, icepack_max_doc, icepack_max_don, &   ! LCOV_EXCL_LINE
      19             :           icepack_max_algae, icepack_max_fe
      20             :       use icepack_intfc, only: icepack_query_tracer_flags, &
      21             :           icepack_query_tracer_indices, icepack_query_parameters, &   ! LCOV_EXCL_LINE
      22             :           icepack_query_parameters
      23             :       use ice_domain_size, only: max_nstrm, n_iso, n_aero, &
      24             :           n_algae, n_dic, n_doc, n_don, n_zaero, n_fed, n_fep
      25             : 
      26             :       implicit none
      27             :       private
      28             :       public :: init_hist_bgc_2D, init_hist_bgc_3Dc, &
      29             :                 init_hist_bgc_3Db, init_hist_bgc_3Da,&   ! LCOV_EXCL_LINE
      30             :                 accum_hist_bgc, init_history_bgc
      31             : 
      32             :       !---------------------------------------------------------------
      33             :       ! flags: write to output file if true or histfreq value
      34             :       !---------------------------------------------------------------
      35             :       ! specified in input_templates
      36             :       !--------------------------------------------------------------
      37             :       character (len=max_nstrm), public :: &
      38             :            f_fiso_atm     = 'x', f_fiso_ocn     = 'x', &   ! LCOV_EXCL_LINE
      39             :            f_iso          = 'x', &   ! LCOV_EXCL_LINE
      40             :            f_faero_atm    = 'x', f_faero_ocn    = 'x', &   ! LCOV_EXCL_LINE
      41             :            f_aero         = 'x', &   ! LCOV_EXCL_LINE
      42             :            f_fbio         = 'x', f_fbio_ai      = 'x', &   ! LCOV_EXCL_LINE
      43             :            f_zaero        = 'x', f_bgc_S        = 'x', &   ! LCOV_EXCL_LINE
      44             :            f_bgc_N        = 'x', f_bgc_C        = 'x', &   ! LCOV_EXCL_LINE
      45             :            f_bgc_DOC      = 'x', f_bgc_DIC      = 'x', &   ! LCOV_EXCL_LINE
      46             :            f_bgc_chl      = 'x', f_bgc_Nit      = 'x', &   ! LCOV_EXCL_LINE
      47             :            f_bgc_Am       = 'x', f_bgc_Sil      = 'x', &   ! LCOV_EXCL_LINE
      48             :            f_bgc_DMSPp    = 'x', f_bgc_DMSPd    = 'x', &   ! LCOV_EXCL_LINE
      49             :            f_bgc_DMS      = 'x', f_bgc_DON      = 'x', &   ! LCOV_EXCL_LINE
      50             :            f_bgc_Fe       = 'x', f_bgc_hum      = 'x', &   ! LCOV_EXCL_LINE
      51             :            f_bgc_PON      = 'x', f_bgc_ml       = 'x', &   ! LCOV_EXCL_LINE
      52             :            f_upNO         = 'x', f_upNH         = 'x', &   ! LCOV_EXCL_LINE
      53             :            f_bTin         = 'x', f_bphi         = 'x', &   ! LCOV_EXCL_LINE
      54             :            f_iDi          = 'x', f_iki          = 'x', &   ! LCOV_EXCL_LINE
      55             :            f_fbri         = 'x', f_hbri         = 'x', &   ! LCOV_EXCL_LINE
      56             :            f_zfswin       = 'x', f_grownet      = 'x', &   ! LCOV_EXCL_LINE
      57             :            f_bionet       = 'x', f_biosnow      = 'x', &   ! LCOV_EXCL_LINE
      58             :            f_PPnet        = 'x', f_algalpeak    = 'x', &   ! LCOV_EXCL_LINE
      59             :            f_zbgc_frac    = 'x', &   ! LCOV_EXCL_LINE
      60             :          !------------------------------------------------
      61             :          ! specified by combinations of above values
      62             :          !-------------------------------------------------
      63             :            f_bgc_Fed      = 'x', f_bgc_Fep      = 'x', &
      64             :            f_DONnet       = 'x',                       &   ! LCOV_EXCL_LINE
      65             :            f_DICnet       = 'x', f_DOCnet       = 'x', &   ! LCOV_EXCL_LINE
      66             :            f_chlnet       = 'x', f_Nitnet       = 'x', &   ! LCOV_EXCL_LINE
      67             :            f_Amnet        = 'x', f_Cnet         = 'x', &   ! LCOV_EXCL_LINE
      68             :            f_Nnet         = 'x', f_DMSPpnet     = 'x', &   ! LCOV_EXCL_LINE
      69             :            f_DMSPdnet     = 'x', f_DMSnet       = 'x', &   ! LCOV_EXCL_LINE
      70             :            f_Fednet       = 'x', f_Fepnet       = 'x', &   ! LCOV_EXCL_LINE
      71             :            f_Silnet       = 'x', f_PONnet       = 'x', &   ! LCOV_EXCL_LINE
      72             :            f_zaeronet     = 'x', f_humnet       = 'x', &   ! LCOV_EXCL_LINE
      73             :            f_chlsnow      = 'x', f_Nitsnow      = 'x', &   ! LCOV_EXCL_LINE
      74             :            f_Amsnow       = 'x', f_Csnow        = 'x', &   ! LCOV_EXCL_LINE
      75             :            f_Nsnow        = 'x', f_DMSPpsnow    = 'x', &   ! LCOV_EXCL_LINE
      76             :            f_DMSPdsnow    = 'x', f_DMSsnow      = 'x', &   ! LCOV_EXCL_LINE
      77             :            f_Fedsnow      = 'x', f_Fepsnow      = 'x', &   ! LCOV_EXCL_LINE
      78             :            f_Silsnow      = 'x', f_PONsnow      = 'x', &   ! LCOV_EXCL_LINE
      79             :            f_humsnow      = 'x',                       &   ! LCOV_EXCL_LINE
      80             :            f_DICsnow      = 'x', f_DOCsnow      = 'x', &   ! LCOV_EXCL_LINE
      81             :            f_DONsnow      = 'x', f_zaerosnow    = 'x', &   ! LCOV_EXCL_LINE
      82             :            f_chlfrac      = 'x', f_Nitfrac      = 'x', &   ! LCOV_EXCL_LINE
      83             :            f_Amfrac       = 'x',                       &   ! LCOV_EXCL_LINE
      84             :            f_Nfrac        = 'x', f_DMSPpfrac    = 'x', &   ! LCOV_EXCL_LINE
      85             :            f_DMSPdfrac    = 'x', f_DMSfrac      = 'x', &   ! LCOV_EXCL_LINE
      86             :            f_Silfrac      = 'x', f_PONfrac      = 'x', &   ! LCOV_EXCL_LINE
      87             :            f_humfrac      = 'x',                       &   ! LCOV_EXCL_LINE
      88             :            f_DICfrac      = 'x', f_DOCfrac      = 'x', &   ! LCOV_EXCL_LINE
      89             :            f_DONfrac      = 'x', f_zaerofrac    = 'x', &   ! LCOV_EXCL_LINE
      90             :            f_Fedfrac      = 'x', f_Fepfrac      = 'x', &   ! LCOV_EXCL_LINE
      91             :            f_fNit         = 'x', f_fNit_ai      = 'x', &   ! LCOV_EXCL_LINE
      92             :            f_fAm          = 'x', f_fAm_ai       = 'x', &   ! LCOV_EXCL_LINE
      93             :            f_fN           = 'x', f_fN_ai        = 'x', &   ! LCOV_EXCL_LINE
      94             :            f_fDOC         = 'x', f_fDOC_ai      = 'x', &   ! LCOV_EXCL_LINE
      95             :            f_fDIC         = 'x', f_fDIC_ai      = 'x', &   ! LCOV_EXCL_LINE
      96             :            f_fDON         = 'x', f_fDON_ai      = 'x', &   ! LCOV_EXCL_LINE
      97             :            f_fFed         = 'x', f_fFed_ai      = 'x', &   ! LCOV_EXCL_LINE
      98             :            f_fFep         = 'x', f_fFep_ai      = 'x', &   ! LCOV_EXCL_LINE
      99             :            f_fSil         = 'x', f_fSil_ai      = 'x', &   ! LCOV_EXCL_LINE
     100             :            f_fPON         = 'x', f_fPON_ai      = 'x', &   ! LCOV_EXCL_LINE
     101             :            f_fhum         = 'x', f_fhum_ai      = 'x', &   ! LCOV_EXCL_LINE
     102             :            f_fDMSPp       = 'x', f_fDMSPp_ai    = 'x', &   ! LCOV_EXCL_LINE
     103             :            f_fDMSPd       = 'x', f_fDMSPd_ai    = 'x', &   ! LCOV_EXCL_LINE
     104             :            f_fDMS         = 'x', f_fDMS_ai      = 'x', &   ! LCOV_EXCL_LINE
     105             :            f_fzaero       = 'x', f_fzaero_ai    = 'x', &   ! LCOV_EXCL_LINE
     106             :            f_bgc_Sil_ml   = 'x', &   ! LCOV_EXCL_LINE
     107             :            f_bgc_Nit_ml   = 'x', f_bgc_Am_ml    = 'x', &   ! LCOV_EXCL_LINE
     108             :            f_bgc_DMSP_ml  = 'x', f_bgc_DMS_ml   = 'x', &   ! LCOV_EXCL_LINE
     109             :            f_bgc_DOC_ml   = 'x', f_bgc_DIC_ml   = 'x', &   ! LCOV_EXCL_LINE
     110             :            f_bgc_N_ml     = 'x', f_bgc_DON_ml   = 'x', &   ! LCOV_EXCL_LINE
     111             :            f_peakval      = 'x', f_bgc_Fed_ml   = 'x', &   ! LCOV_EXCL_LINE
     112             :            f_bgc_Fep_ml   = 'x', f_bgc_hum_ml   = 'x', &   ! LCOV_EXCL_LINE
     113             :            f_bgc_N_cat1   = 'x', f_bgc_DOC_cat1 = 'x', &   ! LCOV_EXCL_LINE
     114             :            f_bgc_DIC_cat1 = 'x', f_bgc_Nit_cat1 = 'x', &   ! LCOV_EXCL_LINE
     115             :            f_bgc_Am_cat1  = 'x', f_bgc_Sil_cat1 = 'x', &   ! LCOV_EXCL_LINE
     116             :            f_bgc_DMSPd_cat1= 'x', f_bgc_DMS_cat1 = 'x', &   ! LCOV_EXCL_LINE
     117             :            f_bgc_DON_cat1 = 'x', f_bgc_Fed_cat1 = 'x', &   ! LCOV_EXCL_LINE
     118             :            f_bgc_hum_cat1 = 'x', f_bgc_Fep_cat1 = 'x', &   ! LCOV_EXCL_LINE
     119             :            f_bgc_PON_cat1 = 'x'
     120             : 
     121             :       !---------------------------------------------------------------
     122             :       ! namelist variables
     123             :       !---------------------------------------------------------------
     124             : 
     125             :       namelist / icefields_bgc_nml /     &
     126             :            f_fiso_atm    , f_fiso_ocn    , &   ! LCOV_EXCL_LINE
     127             :            f_iso         , &   ! LCOV_EXCL_LINE
     128             :            f_faero_atm   , f_faero_ocn   , &   ! LCOV_EXCL_LINE
     129             :            f_aero        , &   ! LCOV_EXCL_LINE
     130             :            f_fbio        , f_fbio_ai     , &   ! LCOV_EXCL_LINE
     131             :            f_zaero       , f_bgc_S       , &   ! LCOV_EXCL_LINE
     132             :            f_bgc_N       , f_bgc_C       , &   ! LCOV_EXCL_LINE
     133             :            f_bgc_DOC     , f_bgc_DIC     , &   ! LCOV_EXCL_LINE
     134             :            f_bgc_chl     , f_bgc_Nit     , &   ! LCOV_EXCL_LINE
     135             :            f_bgc_Am      , f_bgc_Sil     , &   ! LCOV_EXCL_LINE
     136             :            f_bgc_DMSPp   , f_bgc_DMSPd   , &   ! LCOV_EXCL_LINE
     137             :            f_bgc_DMS     , f_bgc_DON     , &   ! LCOV_EXCL_LINE
     138             :            f_bgc_Fe      , f_bgc_hum     , &   ! LCOV_EXCL_LINE
     139             :            f_bgc_PON     , f_bgc_ml      , &   ! LCOV_EXCL_LINE
     140             :            f_upNO        , f_upNH        , &   ! LCOV_EXCL_LINE
     141             :            f_bTin        , f_bphi        , &   ! LCOV_EXCL_LINE
     142             :            f_iDi         , f_iki         , &   ! LCOV_EXCL_LINE
     143             :            f_fbri        , f_hbri        , &   ! LCOV_EXCL_LINE
     144             :            f_zfswin      , f_grownet     , &   ! LCOV_EXCL_LINE
     145             :            f_bionet      , f_biosnow     , &   ! LCOV_EXCL_LINE
     146             :            f_PPnet       , f_algalpeak   , &   ! LCOV_EXCL_LINE
     147             :            f_zbgc_frac
     148             : 
     149             :       !---------------------------------------------------------------
     150             :       ! field indices
     151             :       !---------------------------------------------------------------
     152             : 
     153             :       integer(kind=int_kind), dimension(icepack_max_iso,max_nstrm) :: &
     154             :            n_fiso_atm    , &   ! LCOV_EXCL_LINE
     155             :            n_fiso_ocn    , &   ! LCOV_EXCL_LINE
     156             :            n_isosno      , &   ! LCOV_EXCL_LINE
     157             :            n_isoice
     158             : 
     159             :       integer(kind=int_kind), dimension(icepack_max_aero,max_nstrm) :: &
     160             :            n_faero_atm    , &   ! LCOV_EXCL_LINE
     161             :            n_faero_ocn    , &   ! LCOV_EXCL_LINE
     162             :            n_aerosn1      , &   ! LCOV_EXCL_LINE
     163             :            n_aerosn2      , &   ! LCOV_EXCL_LINE
     164             :            n_aeroic1      , &   ! LCOV_EXCL_LINE
     165             :            n_aeroic2      , &   ! LCOV_EXCL_LINE
     166             :            n_zaeros       , & !  using z tracers   ! LCOV_EXCL_LINE
     167             :            n_fzaero       , &   ! LCOV_EXCL_LINE
     168             :            n_fzaero_ai    , &   ! LCOV_EXCL_LINE
     169             :            n_zaeronet     , &   ! LCOV_EXCL_LINE
     170             :            n_zaerosnow    , &   ! LCOV_EXCL_LINE
     171             :            n_zaerofrac
     172             : 
     173             :       integer(kind=int_kind), dimension(icepack_max_algae, max_nstrm) :: &
     174             :            n_bgc_N  , n_bgc_C   , &   ! LCOV_EXCL_LINE
     175             :            n_bgc_chl, n_bgc_N_ml, &   ! LCOV_EXCL_LINE
     176             :            n_fN     , n_fN_ai   , &   ! LCOV_EXCL_LINE
     177             :            n_Nnet   , n_Nsnow   , n_Nfrac,   &   ! LCOV_EXCL_LINE
     178             :            n_Cnet   , n_Csnow   ,            &   ! LCOV_EXCL_LINE
     179             :            n_chlnet , n_chlsnow , n_chlfrac, &   ! LCOV_EXCL_LINE
     180             :            n_algalpeak          , &   ! LCOV_EXCL_LINE
     181             :            n_peakval, n_bgc_N_cat1
     182             : 
     183             :       integer(kind=int_kind), dimension(icepack_max_doc, max_nstrm) :: &
     184             :            n_bgc_DOC,  n_bgc_DOC_ml, &   ! LCOV_EXCL_LINE
     185             :            n_fDOC   ,  n_fDOC_ai   , &   ! LCOV_EXCL_LINE
     186             :            n_DOCnet ,  n_DOCsnow   , n_DOCfrac, &   ! LCOV_EXCL_LINE
     187             :            n_bgc_DOC_cat1
     188             : 
     189             :       integer(kind=int_kind), dimension(icepack_max_dic, max_nstrm) :: &
     190             :            n_bgc_DIC,  n_bgc_DIC_ml, &   ! LCOV_EXCL_LINE
     191             :            n_fDIC   ,  n_fDIC_ai   , &   ! LCOV_EXCL_LINE
     192             :            n_DICnet ,  n_DICsnow   , n_DICfrac, &   ! LCOV_EXCL_LINE
     193             :            n_bgc_DIC_cat1
     194             : 
     195             :       integer(kind=int_kind), dimension(icepack_max_don, max_nstrm) :: &
     196             :            n_bgc_DON,  n_bgc_DON_ml, &   ! LCOV_EXCL_LINE
     197             :            n_fDON   ,  n_fDON_ai   , &   ! LCOV_EXCL_LINE
     198             :            n_DONnet ,  n_DONsnow   , n_DONfrac, &   ! LCOV_EXCL_LINE
     199             :            n_bgc_DON_cat1
     200             : 
     201             :       integer(kind=int_kind), dimension(icepack_max_fe,  max_nstrm) :: &
     202             :            n_bgc_Fed ,  n_bgc_Fed_ml , &   ! LCOV_EXCL_LINE
     203             :            n_fFed    ,  n_fFed_ai    , &   ! LCOV_EXCL_LINE
     204             :            n_Fednet  ,  n_Fedsnow    , n_Fedfrac, &   ! LCOV_EXCL_LINE
     205             :            n_bgc_Fep ,  n_bgc_Fep_ml , &   ! LCOV_EXCL_LINE
     206             :            n_fFep    ,  n_fFep_ai    , &   ! LCOV_EXCL_LINE
     207             :            n_Fepnet  ,  n_Fepsnow    , n_Fepfrac, &   ! LCOV_EXCL_LINE
     208             :            n_bgc_Fed_cat1, n_bgc_Fep_cat1
     209             : 
     210             :       integer(kind=int_kind), dimension(max_nstrm) :: &
     211             :            n_fNit        , n_fNit_ai     , &   ! LCOV_EXCL_LINE
     212             :            n_fAm         , n_fAm_ai      , &   ! LCOV_EXCL_LINE
     213             :            n_fSil        , n_fSil_ai     , &   ! LCOV_EXCL_LINE
     214             :            n_fDMS        , n_fDMS_ai     , &   ! LCOV_EXCL_LINE
     215             :            n_fDMSPp      , n_fDMSPp_ai   , &   ! LCOV_EXCL_LINE
     216             :            n_fDMSPd      , n_fDMSPd_ai   , &   ! LCOV_EXCL_LINE
     217             :            n_fPON        , n_fPON_ai     , &   ! LCOV_EXCL_LINE
     218             :            n_fhum        , n_fhum_ai     , &   ! LCOV_EXCL_LINE
     219             :            n_bgc_Nit                     , &   ! LCOV_EXCL_LINE
     220             :            n_bgc_Am      , n_bgc_Sil     , &   ! LCOV_EXCL_LINE
     221             :            n_bgc_hum     ,                 &   ! LCOV_EXCL_LINE
     222             :            n_bgc_DMSPp   , n_bgc_DMSPd   , &   ! LCOV_EXCL_LINE
     223             :            n_bgc_DMS     , n_bgc_Sil_ml  , &   ! LCOV_EXCL_LINE
     224             :            n_bgc_hum_ml  ,                 &   ! LCOV_EXCL_LINE
     225             :            n_bgc_Nit_ml  , n_bgc_Am_ml   , &   ! LCOV_EXCL_LINE
     226             :            n_bgc_DMSP_ml , n_bgc_DMS_ml  , &   ! LCOV_EXCL_LINE
     227             :            n_upNO        , n_upNH        , &   ! LCOV_EXCL_LINE
     228             :            n_bTin        , n_bphi        , &   ! LCOV_EXCL_LINE
     229             :            n_iDi         , n_iki         , &   ! LCOV_EXCL_LINE
     230             :            n_bgc_PON     ,                 &   ! LCOV_EXCL_LINE
     231             :            n_fbri        , n_hbri        , &   ! LCOV_EXCL_LINE
     232             :            n_zfswin      , n_Nitnet      , &   ! LCOV_EXCL_LINE
     233             :            n_Amnet       , n_Silnet      , &   ! LCOV_EXCL_LINE
     234             :            n_humnet      ,                 &   ! LCOV_EXCL_LINE
     235             :            n_DMSPpnet    , n_DMSPdnet    , &   ! LCOV_EXCL_LINE
     236             :            n_DMSnet      , n_PONnet      , &   ! LCOV_EXCL_LINE
     237             :            n_Nitsnow     , n_Amsnow      , &   ! LCOV_EXCL_LINE
     238             :            n_Silsnow     , n_humsnow     , &   ! LCOV_EXCL_LINE
     239             :            n_DMSPpsnow   , n_DMSPdsnow   , &   ! LCOV_EXCL_LINE
     240             :            n_DMSsnow     , n_PONsnow     , &   ! LCOV_EXCL_LINE
     241             :            n_Nitfrac     , n_Amfrac      , &   ! LCOV_EXCL_LINE
     242             :            n_Silfrac     ,                 &   ! LCOV_EXCL_LINE
     243             :            n_humfrac     ,                 &   ! LCOV_EXCL_LINE
     244             :            n_DMSPpfrac   , n_DMSPdfrac   , &   ! LCOV_EXCL_LINE
     245             :            n_DMSfrac     , n_PONfrac     , &   ! LCOV_EXCL_LINE
     246             :            n_grownet     , n_PPnet       , &   ! LCOV_EXCL_LINE
     247             :            n_bgc_Nit_cat1, n_bgc_Am_cat1 , &   ! LCOV_EXCL_LINE
     248             :            n_bgc_Sil_cat1, n_bgc_DMSPd_cat1,&   ! LCOV_EXCL_LINE
     249             :            n_bgc_DMS_cat1, n_bgc_PON_cat1, &   ! LCOV_EXCL_LINE
     250             :            n_bgc_hum_cat1
     251             : 
     252             : !=======================================================================
     253             : 
     254             :       contains
     255             : 
     256             : !=======================================================================
     257             : 
     258          37 :       subroutine init_hist_bgc_2D
     259             : 
     260             :       use ice_broadcast, only: broadcast_scalar
     261             :       use ice_calendar, only: nstreams, histfreq
     262             :       use ice_communicate, only: my_task, master_task
     263             :       use ice_history_shared, only: tstr2D, tcstr, define_hist_field, &
     264             :           f_fsalt, f_fsalt_ai, f_sice
     265             :       use ice_fileunits, only: goto_nml
     266             : 
     267             :       integer (kind=int_kind) :: n, ns
     268             :       integer (kind=int_kind) :: nml_error ! namelist i/o error flag
     269             :       character (len=3) :: nchar
     270             :       character (len=16) :: vname_in     ! variable name
     271             :       logical (kind=log_kind) :: tr_zaero, tr_aero, tr_brine, tr_iso, &
     272             :           tr_bgc_Nit,    tr_bgc_Am,    tr_bgc_Sil,   &   ! LCOV_EXCL_LINE
     273             :           tr_bgc_DMS,    tr_bgc_PON,                 &   ! LCOV_EXCL_LINE
     274             :           tr_bgc_N,      tr_bgc_C,     tr_bgc_chl,   &   ! LCOV_EXCL_LINE
     275             :           tr_bgc_DON,    tr_bgc_Fe,    tr_bgc_hum,   &   ! LCOV_EXCL_LINE
     276             :           skl_bgc, z_tracers
     277             : 
     278             :       character(len=char_len)      :: nml_name ! for namelist check
     279             :       character(len=char_len_long) :: tmpstr2 ! for namelist check
     280             : 
     281             :       character(len=*), parameter  :: subname = '(init_hist_bgc_2D)'
     282             : 
     283             :       call icepack_query_parameters(skl_bgc_out=skl_bgc, &
     284          37 :           z_tracers_out=z_tracers)
     285             :       call icepack_query_tracer_flags( &
     286             :           tr_iso_out    =tr_iso,     tr_zaero_out  =tr_zaero, &   ! LCOV_EXCL_LINE
     287             :           tr_aero_out   =tr_aero,    tr_brine_out  =tr_brine, &   ! LCOV_EXCL_LINE
     288             :           tr_bgc_Nit_out=tr_bgc_Nit, tr_bgc_Am_out =tr_bgc_Am, &   ! LCOV_EXCL_LINE
     289             :           tr_bgc_Sil_out=tr_bgc_Sil, tr_bgc_DMS_out=tr_bgc_DMS, &   ! LCOV_EXCL_LINE
     290             :           tr_bgc_PON_out=tr_bgc_PON, &   ! LCOV_EXCL_LINE
     291             :           tr_bgc_N_out  =tr_bgc_N,   tr_bgc_C_out  =tr_bgc_C, &   ! LCOV_EXCL_LINE
     292             :           tr_bgc_chl_out=tr_bgc_chl, tr_bgc_DON_out=tr_bgc_DON, &   ! LCOV_EXCL_LINE
     293          37 :           tr_bgc_Fe_out =tr_bgc_Fe,  tr_bgc_hum_out=tr_bgc_hum )
     294          37 :       call icepack_warnings_flush(nu_diag)
     295          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
     296           0 :          file=__FILE__, line=__LINE__)
     297             : 
     298             :       !-----------------------------------------------------------------
     299             :       ! read namelist
     300             :       !-----------------------------------------------------------------
     301             : 
     302          37 :       if (my_task == master_task) then
     303           7 :          nml_name = 'icefields_bgc_nml'
     304           7 :          write(nu_diag,*) subname,' Reading ', trim(nml_name)
     305             : 
     306             :          ! check if can open file
     307           7 :          call get_fileunit(nu_nml)
     308           7 :          open (nu_nml, file=trim(nml_filename), status='old',iostat=nml_error)
     309           7 :          if (nml_error /= 0) then
     310             :             call abort_ice(subname//'ERROR: '//trim(nml_name)//' open file '// &
     311             :                trim(nml_filename), &   ! LCOV_EXCL_LINE
     312           0 :                file=__FILE__, line=__LINE__)
     313             :          endif
     314             : 
     315             :          ! seek to namelist in file
     316           7 :          call goto_nml(nu_nml,trim(nml_name),nml_error)
     317           7 :          if (nml_error /= 0) then
     318             :             call abort_ice(subname//'ERROR: searching for '// trim(nml_name), &
     319           0 :                file=__FILE__, line=__LINE__)
     320             :          endif
     321             : 
     322             :          ! read namelist
     323           7 :          nml_error =  1
     324          14 :          do while (nml_error > 0)
     325           7 :             read(nu_nml, nml=icefields_bgc_nml,iostat=nml_error)
     326             :             ! check if error
     327           7 :             if (nml_error /= 0) then
     328             :                ! backspace and re-read erroneous line
     329           0 :                backspace(nu_nml)
     330           0 :                read(nu_nml,fmt='(A)') tmpstr2
     331             :                call abort_ice(subname//'ERROR: ' // trim(nml_name) // ' reading ' // &
     332           0 :                     trim(tmpstr2), file=__FILE__, line=__LINE__)
     333             :             endif
     334             :          end do
     335             : 
     336           7 :          close(nu_nml)
     337           7 :          call release_fileunit(nu_nml)
     338             :       endif
     339             : 
     340          37 :       if (.not. tr_iso) then
     341          37 :          f_fiso_atm = 'x'
     342          37 :          f_fiso_ocn = 'x'
     343          37 :          f_iso      = 'x'
     344             :       endif
     345             : 
     346          37 :       if (.not. tr_aero) then
     347          37 :          f_faero_atm = 'x'
     348          37 :          f_faero_ocn = 'x'
     349          37 :          f_aero      = 'x'
     350             :       endif
     351             : 
     352          37 :       if (.not. tr_brine)  then
     353          37 :          f_fbri  = 'x'
     354          37 :          f_hbri  = 'x'
     355             :       endif
     356             : 
     357          37 :       f_zaeronet  = f_bionet
     358          37 :       f_zaerosnow = f_biosnow
     359          37 :       f_zaerofrac = f_zbgc_frac
     360          37 :       f_fzaero    = f_fbio
     361          37 :       f_fzaero_ai = f_fbio_ai
     362             : 
     363          37 :       if (.not. tr_zaero) then
     364          37 :          f_zaero     = 'x'
     365          37 :          f_fzaero    = 'x'
     366          37 :          f_fzaero_ai = 'x'
     367          37 :          f_zaeronet  = 'x'
     368          37 :          f_zaerosnow = 'x'
     369          37 :          f_zaerofrac = 'x'
     370             :       endif
     371             : 
     372          37 :      if (skl_bgc) then
     373           0 :        f_bionet  = 'x'
     374           0 :        f_biosnow = 'x'
     375           0 :        f_zfswin  = 'x'
     376           0 :        f_zbgc_frac = 'x'
     377           0 :        f_algalpeak = 'x'
     378             :      endif
     379             : 
     380          37 :       f_bgc_Nit_ml    = f_bgc_ml
     381          37 :       f_bgc_N_ml      = f_bgc_ml
     382          37 :       f_bgc_DOC_ml    = f_bgc_ml
     383          37 :       f_bgc_DIC_ml    = f_bgc_ml
     384          37 :       f_bgc_Sil_ml    = f_bgc_ml
     385          37 :       f_bgc_hum_ml    = f_bgc_ml
     386          37 :       f_bgc_Am_ml     = f_bgc_ml
     387          37 :       f_bgc_DMSP_ml   = f_bgc_ml
     388          37 :       f_bgc_DMS_ml    = f_bgc_ml
     389          37 :       f_bgc_DON_ml    = f_bgc_ml
     390          37 :       f_bgc_Fed_ml    = f_bgc_ml
     391          37 :       f_bgc_Fep_ml    = f_bgc_ml
     392             : 
     393          37 :       f_Nitnet    = f_bionet
     394          37 :       f_Amnet     = f_bionet
     395          37 :       f_Nnet      = f_bionet
     396          37 :       f_chlnet    = f_bionet
     397          37 :       f_Cnet      = f_bionet
     398          37 :       f_DOCnet    = f_bionet
     399          37 :       f_DICnet    = f_bionet
     400          37 :       f_DONnet    = f_bionet
     401          37 :       f_Fednet    = f_bionet
     402          37 :       f_Fepnet    = f_bionet
     403          37 :       f_Silnet    = f_bionet
     404          37 :       f_humnet    = f_bionet
     405          37 :       f_DMSPpnet  = f_bionet
     406          37 :       f_DMSPdnet  = f_bionet
     407          37 :       f_DMSnet    = f_bionet
     408          37 :       f_PONnet    = f_bionet
     409             : 
     410          37 :       f_Nitsnow    = f_biosnow
     411          37 :       f_Amsnow     = f_biosnow
     412          37 :       f_Nsnow      = f_biosnow
     413          37 :       f_chlsnow    = f_biosnow
     414          37 :       f_Csnow      = f_biosnow
     415          37 :       f_DOCsnow    = f_biosnow
     416          37 :       f_DICsnow    = f_biosnow
     417          37 :       f_DONsnow    = f_biosnow
     418          37 :       f_Fedsnow    = f_biosnow
     419          37 :       f_Fepsnow    = f_biosnow
     420          37 :       f_Silsnow    = f_biosnow
     421          37 :       f_humsnow    = f_biosnow
     422          37 :       f_DMSPpsnow  = f_biosnow
     423          37 :       f_DMSPdsnow  = f_biosnow
     424          37 :       f_DMSsnow    = f_biosnow
     425          37 :       f_PONsnow    = f_biosnow
     426             : 
     427          37 :       f_Nitfrac    = f_zbgc_frac
     428          37 :       f_Amfrac     = f_zbgc_frac
     429          37 :       f_Nfrac      = f_zbgc_frac
     430          37 :       f_chlfrac    = f_zbgc_frac
     431          37 :       f_DOCfrac    = f_zbgc_frac
     432          37 :       f_DICfrac    = f_zbgc_frac
     433          37 :       f_DONfrac    = f_zbgc_frac
     434          37 :       f_Fedfrac    = f_zbgc_frac
     435          37 :       f_Fepfrac    = f_zbgc_frac
     436          37 :       f_Silfrac    = f_zbgc_frac
     437          37 :       f_humfrac    = f_zbgc_frac
     438          37 :       f_DMSPpfrac  = f_zbgc_frac
     439          37 :       f_DMSPdfrac  = f_zbgc_frac
     440          37 :       f_DMSfrac    = f_zbgc_frac
     441          37 :       f_PONfrac    = f_zbgc_frac
     442             : 
     443          37 :       f_bgc_DMSPp  = f_bgc_DMS
     444          37 :       f_bgc_DMSPd  = f_bgc_DMS
     445             : 
     446          37 :       f_bgc_Fed = f_bgc_Fe
     447          37 :       f_bgc_Fep = f_bgc_Fe
     448             : 
     449          37 :       f_fDOC    = f_fbio
     450          37 :       f_fDIC    = f_fbio
     451          37 :       f_fDON    = f_fbio
     452          37 :       f_fFed    = f_fbio
     453          37 :       f_fFep    = f_fbio
     454          37 :       f_fNit    = f_fbio
     455          37 :       f_fAm     = f_fbio
     456          37 :       f_fN      = f_fbio
     457          37 :       f_fSil    = f_fbio
     458          37 :       f_fhum    = f_fbio
     459          37 :       f_fPON    = f_fbio
     460          37 :       f_fDMSPp  = f_fbio
     461          37 :       f_fDMSPd  = f_fbio
     462          37 :       f_fDMS    = f_fbio
     463             : 
     464          37 :       f_fDOC_ai    = f_fbio_ai
     465          37 :       f_fDIC_ai    = f_fbio_ai
     466          37 :       f_fDON_ai    = f_fbio_ai
     467          37 :       f_fFed_ai    = f_fbio_ai
     468          37 :       f_fFep_ai    = f_fbio_ai
     469          37 :       f_fNit_ai    = f_fbio_ai
     470          37 :       f_fAm_ai     = f_fbio_ai
     471          37 :       f_fN_ai      = f_fbio_ai
     472          37 :       f_fSil_ai    = f_fbio_ai
     473          37 :       f_fhum_ai    = f_fbio_ai
     474          37 :       f_fPON_ai    = f_fbio_ai
     475          37 :       f_fDMSPp_ai  = f_fbio_ai
     476          37 :       f_fDMSPd_ai  = f_fbio_ai
     477          37 :       f_fDMS_ai    = f_fbio_ai
     478             : 
     479          37 :      if (.not. tr_bgc_N) then
     480          37 :         f_bgc_N     = 'x'
     481          37 :         f_bgc_N_ml  = 'x'
     482          37 :         f_fN        = 'x'
     483          37 :         f_fN_ai     = 'x'
     484          37 :         f_Nsnow     = 'x'
     485          37 :         f_Nfrac     = 'x'
     486          37 :         f_Nnet      = 'x'
     487          37 :         f_algalpeak = 'x'
     488             :      endif
     489             : 
     490          37 :      f_peakval = f_algalpeak
     491          37 :      if (.not. tr_bgc_Nit) then
     492          37 :         f_upNO      = 'x'
     493          37 :         f_bgc_Nit   = 'x'
     494          37 :         f_bgc_Nit_ml= 'x'
     495          37 :         f_fNit      = 'x'
     496          37 :         f_fNit_ai   = 'x'
     497          37 :         f_Nitsnow   = 'x'
     498          37 :         f_Nitfrac   = 'x'
     499          37 :         f_Nitnet    = 'x'
     500             :      endif
     501          37 :      if (.not. tr_bgc_C) then
     502          37 :         f_bgc_C   = 'x'
     503          37 :         f_bgc_DOC = 'x'
     504          37 :         f_bgc_DIC = 'x'
     505          37 :         f_fDOC    = 'x'
     506          37 :         f_fDOC_ai = 'x'
     507          37 :         f_bgc_DOC_ml = 'x'
     508          37 :         f_bgc_DIC_ml = 'x'
     509          37 :         f_Csnow      = 'x'
     510          37 :         f_DOCsnow    = 'x'
     511          37 :         f_DICsnow    = 'x'
     512          37 :         f_DOCfrac    = 'x'
     513          37 :         f_DICfrac    = 'x'
     514          37 :         f_Cnet       = 'x'
     515          37 :         f_DOCnet     = 'x'
     516          37 :         f_DICnet     = 'x'
     517             :      endif
     518          37 :      if (.not. tr_bgc_chl) then
     519          37 :         f_bgc_chl = 'x'
     520          37 :         f_chlnet  = 'x'
     521          37 :         f_chlsnow = 'x'
     522          37 :         f_chlfrac = 'x'
     523             :      endif
     524          37 :      if (.not. tr_bgc_Am) then
     525          37 :         f_upNH      = 'x'
     526          37 :         f_bgc_Am    = 'x'
     527          37 :         f_bgc_Am_ml = 'x'
     528          37 :         f_fAm       = 'x'
     529          37 :         f_fAm_ai    = 'x'
     530          37 :         f_Amsnow    = 'x'
     531          37 :         f_Amfrac    = 'x'
     532          37 :         f_Amnet     = 'x'
     533             :      endif
     534          37 :      if (.not. tr_bgc_Sil) then
     535          37 :         f_bgc_Sil    = 'x'
     536          37 :         f_bgc_Sil_ml = 'x'
     537          37 :         f_fSil       = 'x'
     538          37 :         f_fSil_ai    = 'x'
     539          37 :         f_Silnet     = 'x'
     540          37 :         f_Silsnow    = 'x'
     541          37 :         f_Silfrac    = 'x'
     542             :      endif
     543          37 :      if (.not. tr_bgc_hum) then
     544          37 :         f_bgc_hum    = 'x'
     545          37 :         f_bgc_hum_ml = 'x'
     546          37 :         f_fhum       = 'x'
     547          37 :         f_fhum_ai    = 'x'
     548          37 :         f_humnet     = 'x'
     549          37 :         f_humsnow    = 'x'
     550          37 :         f_humfrac    = 'x'
     551             :      endif
     552          37 :      if (.not. tr_bgc_DMS) then
     553          37 :         f_bgc_DMS   = 'x'
     554          37 :         f_bgc_DMSPp = 'x'
     555          37 :         f_bgc_DMSPd = 'x'
     556          37 :         f_bgc_DMSP_ml= 'x'
     557          37 :         f_bgc_DMS_ml = 'x'
     558          37 :         f_fDMS       = 'x'
     559          37 :         f_fDMSPp     = 'x'
     560          37 :         f_fDMSPd     = 'x'
     561          37 :         f_fDMS_ai    = 'x'
     562          37 :         f_fDMSPp_ai  = 'x'
     563          37 :         f_fDMSPd_ai  = 'x'
     564          37 :         f_DMSnet     = 'x'
     565          37 :         f_DMSPpnet   = 'x'
     566          37 :         f_DMSPdnet   = 'x'
     567          37 :         f_DMSsnow    = 'x'
     568          37 :         f_DMSPpsnow  = 'x'
     569          37 :         f_DMSPdsnow  = 'x'
     570          37 :         f_DMSfrac    = 'x'
     571          37 :         f_DMSPpfrac  = 'x'
     572          37 :         f_DMSPdfrac  = 'x'
     573             :      endif
     574          37 :      if (.not. tr_bgc_DON) then
     575          37 :         f_bgc_DON    = 'x'
     576          37 :         f_bgc_DON_ml = 'x'
     577          37 :         f_DONsnow    = 'x'
     578          37 :         f_DONfrac    = 'x'
     579          37 :         f_DONnet     = 'x'
     580          37 :         f_fDON       = 'x'
     581          37 :         f_fDON_ai    = 'x'
     582             :      endif
     583          37 :      if (.not. tr_bgc_Fe ) then
     584          37 :         f_bgc_Fe     = 'x'
     585          37 :         f_bgc_Fed    = 'x'
     586          37 :         f_bgc_Fed_ml = 'x'
     587          37 :         f_Fedsnow    = 'x'
     588          37 :         f_Fedfrac    = 'x'
     589          37 :         f_Fednet     = 'x'
     590          37 :         f_fFed       = 'x'
     591          37 :         f_fFed_ai    = 'x'
     592          37 :         f_bgc_Fep    = 'x'
     593          37 :         f_bgc_Fep_ml = 'x'
     594          37 :         f_Fepsnow    = 'x'
     595          37 :         f_Fepfrac    = 'x'
     596          37 :         f_Fepnet     = 'x'
     597          37 :         f_fFep       = 'x'
     598          37 :         f_fFep_ai    = 'x'
     599             :      endif
     600          37 :      if (.not. tr_bgc_PON .or. skl_bgc) then
     601          37 :         f_bgc_PON   = 'x'
     602          37 :         f_PONsnow    = 'x'
     603          37 :         f_PONfrac    = 'x'
     604          37 :         f_PONnet     = 'x'
     605          37 :         f_fPON       = 'x'
     606          37 :         f_fPON_ai    = 'x'
     607             :      endif
     608             : 
     609          37 :       f_bgc_Nit_cat1    = f_bgc_Nit
     610          37 :       f_bgc_Am_cat1     = f_bgc_Am
     611          37 :       f_bgc_N_cat1      = f_bgc_N
     612          37 :       f_bgc_DOC_cat1    = f_bgc_DOC
     613          37 :       f_bgc_DIC_cat1    = f_bgc_DIC
     614          37 :       f_bgc_DON_cat1    = f_bgc_DON
     615          37 :       f_bgc_Fed_cat1    = f_bgc_Fe
     616          37 :       f_bgc_Fep_cat1    = f_bgc_Fe
     617          37 :       f_bgc_Sil_cat1    = f_bgc_Sil
     618          37 :       f_bgc_hum_cat1    = f_bgc_hum
     619          37 :       f_bgc_DMSPd_cat1  = f_bgc_DMSPd
     620          37 :       f_bgc_DMS_cat1    = f_bgc_DMS
     621          37 :       f_bgc_PON_cat1    = f_bgc_PON
     622             : 
     623          37 :       call broadcast_scalar (f_fiso_atm,     master_task)
     624          37 :       call broadcast_scalar (f_fiso_ocn,     master_task)
     625          37 :       call broadcast_scalar (f_iso,          master_task)
     626          37 :       call broadcast_scalar (f_faero_atm,    master_task)
     627          37 :       call broadcast_scalar (f_faero_ocn,    master_task)
     628          37 :       call broadcast_scalar (f_aero,         master_task)
     629          37 :       call broadcast_scalar (f_fbri,         master_task)
     630          37 :       call broadcast_scalar (f_hbri,         master_task)
     631          37 :       call broadcast_scalar (f_fNit,         master_task)
     632          37 :       call broadcast_scalar (f_fNit_ai,      master_task)
     633          37 :       call broadcast_scalar (f_fDOC,         master_task)
     634          37 :       call broadcast_scalar (f_fDOC_ai,      master_task)
     635          37 :       call broadcast_scalar (f_fDIC,         master_task)
     636          37 :       call broadcast_scalar (f_fDIC_ai,      master_task)
     637          37 :       call broadcast_scalar (f_fDON,         master_task)
     638          37 :       call broadcast_scalar (f_fDON_ai,      master_task)
     639          37 :       call broadcast_scalar (f_fFed,         master_task)
     640          37 :       call broadcast_scalar (f_fFed_ai,      master_task)
     641          37 :       call broadcast_scalar (f_fFep,         master_task)
     642          37 :       call broadcast_scalar (f_fFep_ai,      master_task)
     643          37 :       call broadcast_scalar (f_fAm,          master_task)
     644          37 :       call broadcast_scalar (f_fAm_ai,       master_task)
     645          37 :       call broadcast_scalar (f_fN,           master_task)
     646          37 :       call broadcast_scalar (f_fN_ai,        master_task)
     647          37 :       call broadcast_scalar (f_fSil,         master_task)
     648          37 :       call broadcast_scalar (f_fSil_ai,      master_task)
     649          37 :       call broadcast_scalar (f_fhum,         master_task)
     650          37 :       call broadcast_scalar (f_fhum_ai,      master_task)
     651          37 :       call broadcast_scalar (f_fPON,         master_task)
     652          37 :       call broadcast_scalar (f_fPON_ai,      master_task)
     653          37 :       call broadcast_scalar (f_fDMS,         master_task)
     654          37 :       call broadcast_scalar (f_fDMS_ai,      master_task)
     655          37 :       call broadcast_scalar (f_fDMSPp,       master_task)
     656          37 :       call broadcast_scalar (f_fDMSPp_ai,    master_task)
     657          37 :       call broadcast_scalar (f_fDMSPd,       master_task)
     658          37 :       call broadcast_scalar (f_fDMSPd_ai,    master_task)
     659          37 :       call broadcast_scalar (f_fzaero,       master_task)
     660          37 :       call broadcast_scalar (f_fzaero_ai,    master_task)
     661          37 :       call broadcast_scalar (f_zaero,        master_task)
     662          37 :       call broadcast_scalar (f_bgc_N,        master_task)
     663          37 :       call broadcast_scalar (f_bgc_C,        master_task)
     664          37 :       call broadcast_scalar (f_bgc_DOC,      master_task)
     665          37 :       call broadcast_scalar (f_bgc_DIC,      master_task)
     666          37 :       call broadcast_scalar (f_bgc_chl,      master_task)
     667          37 :       call broadcast_scalar (f_bgc_Nit,      master_task)
     668          37 :       call broadcast_scalar (f_bgc_Am,       master_task)
     669          37 :       call broadcast_scalar (f_bgc_Sil,      master_task)
     670          37 :       call broadcast_scalar (f_bgc_hum,      master_task)
     671          37 :       call broadcast_scalar (f_bgc_DMSPp,    master_task)
     672          37 :       call broadcast_scalar (f_bgc_DMSPd,    master_task)
     673          37 :       call broadcast_scalar (f_bgc_DMS,      master_task)
     674          37 :       call broadcast_scalar (f_bgc_PON,      master_task)
     675          37 :       call broadcast_scalar (f_bgc_DON,      master_task)
     676          37 :       call broadcast_scalar (f_bgc_Fe,       master_task)
     677          37 :       call broadcast_scalar (f_bgc_Fed,      master_task)
     678          37 :       call broadcast_scalar (f_bgc_Fep,      master_task)
     679          37 :       call broadcast_scalar (f_bgc_N_cat1,   master_task)
     680          37 :       call broadcast_scalar (f_bgc_DOC_cat1, master_task)
     681          37 :       call broadcast_scalar (f_bgc_DIC_cat1, master_task)
     682          37 :       call broadcast_scalar (f_bgc_Nit_cat1, master_task)
     683          37 :       call broadcast_scalar (f_bgc_Am_cat1,  master_task)
     684          37 :       call broadcast_scalar (f_bgc_Sil_cat1, master_task)
     685          37 :       call broadcast_scalar (f_bgc_hum_cat1, master_task)
     686          37 :       call broadcast_scalar (f_bgc_DMSPd_cat1, master_task)
     687          37 :       call broadcast_scalar (f_bgc_DMS_cat1, master_task)
     688          37 :       call broadcast_scalar (f_bgc_PON_cat1, master_task)
     689          37 :       call broadcast_scalar (f_bgc_DON_cat1, master_task)
     690          37 :       call broadcast_scalar (f_bgc_Fed_cat1, master_task)
     691          37 :       call broadcast_scalar (f_bgc_Fep_cat1, master_task)
     692          37 :       call broadcast_scalar (f_bgc_Nit_ml,   master_task)
     693          37 :       call broadcast_scalar (f_bgc_DOC_ml,   master_task)
     694          37 :       call broadcast_scalar (f_bgc_DIC_ml,   master_task)
     695          37 :       call broadcast_scalar (f_bgc_N_ml,     master_task)
     696          37 :       call broadcast_scalar (f_bgc_Am_ml,    master_task)
     697          37 :       call broadcast_scalar (f_bgc_Sil_ml,   master_task)
     698          37 :       call broadcast_scalar (f_bgc_hum_ml,   master_task)
     699          37 :       call broadcast_scalar (f_bgc_DMSP_ml,  master_task)
     700          37 :       call broadcast_scalar (f_bgc_DMS_ml,   master_task)
     701          37 :       call broadcast_scalar (f_bgc_DON_ml,   master_task)
     702          37 :       call broadcast_scalar (f_bgc_Fed_ml,   master_task)
     703          37 :       call broadcast_scalar (f_bgc_Fep_ml,   master_task)
     704          37 :       call broadcast_scalar (f_upNO,         master_task)
     705          37 :       call broadcast_scalar (f_upNH,         master_task)
     706          37 :       call broadcast_scalar (f_bTin,         master_task)
     707          37 :       call broadcast_scalar (f_bphi,         master_task)
     708          37 :       call broadcast_scalar (f_iDi,          master_task)
     709          37 :       call broadcast_scalar (f_iki,          master_task)
     710          37 :       call broadcast_scalar (f_zfswin,       master_task)
     711          37 :       call broadcast_scalar (f_PPnet,        master_task)
     712          37 :       call broadcast_scalar (f_algalpeak,    master_task)
     713          37 :       call broadcast_scalar (f_zbgc_frac,    master_task)
     714          37 :       call broadcast_scalar (f_peakval,      master_task)
     715          37 :       call broadcast_scalar (f_grownet,      master_task)
     716          37 :       call broadcast_scalar (f_chlnet,       master_task)
     717          37 :       call broadcast_scalar (f_Nitnet,       master_task)
     718          37 :       call broadcast_scalar (f_Nnet,         master_task)
     719          37 :       call broadcast_scalar (f_Cnet,         master_task)
     720          37 :       call broadcast_scalar (f_DOCnet,       master_task)
     721          37 :       call broadcast_scalar (f_DICnet,       master_task)
     722          37 :       call broadcast_scalar (f_Amnet,        master_task)
     723          37 :       call broadcast_scalar (f_Silnet,       master_task)
     724          37 :       call broadcast_scalar (f_humnet,       master_task)
     725          37 :       call broadcast_scalar (f_DMSPpnet,     master_task)
     726          37 :       call broadcast_scalar (f_DMSPdnet,     master_task)
     727          37 :       call broadcast_scalar (f_DMSnet,       master_task)
     728          37 :       call broadcast_scalar (f_PONnet,       master_task)
     729          37 :       call broadcast_scalar (f_DONnet,       master_task)
     730          37 :       call broadcast_scalar (f_Fednet,       master_task)
     731          37 :       call broadcast_scalar (f_Fepnet,       master_task)
     732          37 :       call broadcast_scalar (f_zaeronet,     master_task)
     733          37 :       call broadcast_scalar (f_chlsnow,      master_task)
     734          37 :       call broadcast_scalar (f_Nitsnow,      master_task)
     735          37 :       call broadcast_scalar (f_Nsnow,        master_task)
     736          37 :       call broadcast_scalar (f_Csnow,        master_task)
     737          37 :       call broadcast_scalar (f_DOCsnow,      master_task)
     738          37 :       call broadcast_scalar (f_DICsnow,      master_task)
     739          37 :       call broadcast_scalar (f_Amsnow,       master_task)
     740          37 :       call broadcast_scalar (f_Silsnow,      master_task)
     741          37 :       call broadcast_scalar (f_humsnow,      master_task)
     742          37 :       call broadcast_scalar (f_DMSPpsnow,    master_task)
     743          37 :       call broadcast_scalar (f_DMSPdsnow,    master_task)
     744          37 :       call broadcast_scalar (f_DMSsnow,      master_task)
     745          37 :       call broadcast_scalar (f_PONsnow,      master_task)
     746          37 :       call broadcast_scalar (f_DONsnow,      master_task)
     747          37 :       call broadcast_scalar (f_Fedsnow,      master_task)
     748          37 :       call broadcast_scalar (f_Fepsnow,      master_task)
     749          37 :       call broadcast_scalar (f_zaerosnow,    master_task)
     750          37 :       call broadcast_scalar (f_chlfrac,      master_task)
     751          37 :       call broadcast_scalar (f_Nitfrac,      master_task)
     752          37 :       call broadcast_scalar (f_Nfrac,        master_task)
     753          37 :       call broadcast_scalar (f_DOCfrac,      master_task)
     754          37 :       call broadcast_scalar (f_DICfrac,      master_task)
     755          37 :       call broadcast_scalar (f_Amfrac,       master_task)
     756          37 :       call broadcast_scalar (f_Silfrac,      master_task)
     757          37 :       call broadcast_scalar (f_humfrac,      master_task)
     758          37 :       call broadcast_scalar (f_DMSPpfrac,    master_task)
     759          37 :       call broadcast_scalar (f_DMSPdfrac,    master_task)
     760          37 :       call broadcast_scalar (f_DMSfrac,      master_task)
     761          37 :       call broadcast_scalar (f_PONfrac,      master_task)
     762          37 :       call broadcast_scalar (f_DONfrac,      master_task)
     763          37 :       call broadcast_scalar (f_Fedfrac,      master_task)
     764          37 :       call broadcast_scalar (f_Fepfrac,      master_task)
     765          37 :       call broadcast_scalar (f_zaerofrac,    master_task)
     766             : 
     767             :       ! 2D variables
     768             : 
     769          37 :      if (tr_iso .or. tr_aero .or. tr_brine .or. skl_bgc) then
     770             : 
     771           0 :      do ns = 1, nstreams
     772           0 :        if (histfreq(ns) /= 'x') then
     773             : 
     774           0 :       if (f_iso(1:1) /= 'x') then
     775           0 :          do n=1,n_iso
     776           0 :             write(nchar,'(i3.3)') n
     777           0 :             write(vname_in,'(a,a)') 'isosno', trim(nchar)
     778             :             call define_hist_field(n_isosno(n,:),vname_in,"kg/kg",   &
     779             :                 tstr2D, tcstr,"snow isotope mass concentration","none", c1, c0, &   ! LCOV_EXCL_LINE
     780           0 :                 ns, f_iso)
     781           0 :             write(vname_in,'(a,a)') 'isoice', trim(nchar)
     782             :             call define_hist_field(n_isoice(n,:),vname_in,"kg/kg",   &
     783             :                 tstr2D, tcstr,"ice isotope mass concentration","none", c1, c0, &   ! LCOV_EXCL_LINE
     784           0 :                 ns, f_iso)
     785             :          enddo
     786             :       endif
     787             : 
     788           0 :       if (f_fiso_atm(1:1) /= 'x') then
     789           0 :          do n=1,n_iso
     790           0 :             write(nchar,'(i3.3)') n
     791           0 :             write(vname_in,'(a,a)') 'fiso_atm', trim(nchar)
     792             :             call define_hist_field(n_fiso_atm(n,:),vname_in,"kg/m^2 s", &
     793             :                 tstr2D, tcstr,"isotope deposition rate","none", c1, c0,  &   ! LCOV_EXCL_LINE
     794           0 :                 ns, f_fiso_atm)
     795             :          enddo
     796             :       endif
     797             : 
     798           0 :       if (f_fiso_ocn(1:1) /= 'x') then
     799           0 :          do n=1,n_iso
     800           0 :             write(nchar,'(i3.3)') n
     801           0 :             write(vname_in,'(a,a)') 'fiso_ocn', trim(nchar)
     802             :             call define_hist_field(n_fiso_ocn(n,:),vname_in,"kg/m^2 s", &
     803             :                 tstr2D, tcstr,"isotope flux to ocean","none", c1, c0,    &   ! LCOV_EXCL_LINE
     804           0 :                 ns, f_fiso_ocn)
     805             :          enddo
     806             :       endif
     807             : 
     808             :       ! Aerosols
     809           0 :       if (f_aero(1:1) /= 'x') then
     810           0 :          do n=1,n_aero
     811           0 :             write(nchar,'(i3.3)') n
     812           0 :             write(vname_in,'(a,a)') 'aerosnossl', trim(nchar)
     813             :             call define_hist_field(n_aerosn1(n,:),vname_in,"kg/kg",   &
     814             :                 tstr2D, tcstr,"snow ssl aerosol mass","none", c1, c0, &   ! LCOV_EXCL_LINE
     815           0 :                 ns, f_aero)
     816           0 :             write(vname_in,'(a,a)') 'aerosnoint', trim(nchar)
     817             :             call define_hist_field(n_aerosn2(n,:),vname_in,"kg/kg",   &
     818             :                 tstr2D, tcstr,"snow int aerosol mass","none", c1, c0, &   ! LCOV_EXCL_LINE
     819           0 :                 ns, f_aero)
     820           0 :             write(vname_in,'(a,a)') 'aeroicessl', trim(nchar)
     821             :             call define_hist_field(n_aeroic1(n,:),vname_in,"kg/kg",  &
     822             :                 tstr2D, tcstr,"ice ssl aerosol mass","none", c1, c0, &   ! LCOV_EXCL_LINE
     823           0 :                 ns, f_aero)
     824           0 :             write(vname_in,'(a,a)') 'aeroiceint', trim(nchar)
     825             :             call define_hist_field(n_aeroic2(n,:),vname_in,"kg/kg",  &
     826             :                 tstr2D, tcstr,"ice int aerosol mass","none", c1, c0, &   ! LCOV_EXCL_LINE
     827           0 :                 ns, f_aero)
     828             :          enddo
     829             :       endif
     830             : 
     831           0 :       if (f_faero_atm(1:1) /= 'x') then
     832           0 :          do n=1,n_aero
     833           0 :             write(nchar,'(i3.3)') n
     834           0 :             write(vname_in,'(a,a)') 'faero_atm', trim(nchar)
     835             :             call define_hist_field(n_faero_atm(n,:),vname_in,"kg/m^2 s", &
     836             :                 tstr2D, tcstr,"aerosol deposition rate","none", c1, c0,  &   ! LCOV_EXCL_LINE
     837           0 :                 ns, f_faero_atm)
     838             :          enddo
     839             :       endif
     840             : 
     841           0 :       if (f_faero_ocn(1:1) /= 'x') then
     842           0 :          do n=1,n_aero
     843           0 :             write(nchar,'(i3.3)') n
     844           0 :             write(vname_in,'(a,a)') 'faero_ocn', trim(nchar)
     845             :             call define_hist_field(n_faero_ocn(n,:),vname_in,"kg/m^2 s", &
     846             :                 tstr2D, tcstr,"aerosol flux to ocean","none", c1, c0,    &   ! LCOV_EXCL_LINE
     847           0 :                 ns, f_faero_ocn)
     848             :          enddo
     849             :       endif
     850             : 
     851           0 :       if (skl_bgc) then
     852             :         ! skeletal layer tracers
     853             : 
     854             : 
     855           0 :         if (f_bgc_N(1:1) /= 'x') then
     856           0 :           do n = 1, n_algae
     857           0 :             write(nchar,'(i3.3)') n
     858           0 :             write(vname_in,'(a,a)') 'algal_N', trim(nchar)
     859             :             call define_hist_field(n_bgc_N(n,:),vname_in,"mmol/m^2",tstr2D, tcstr, &
     860             :              "Bulk ice bottom algae (nitrogen)",                           &   ! LCOV_EXCL_LINE
     861             :              "skeletal layer: bottom 3 cm", c1, c0,                &   ! LCOV_EXCL_LINE
     862           0 :              ns, f_bgc_N)
     863             :          enddo
     864             :         endif
     865           0 :         if (f_bgc_chl(1:1) /= 'x') then
     866           0 :           do n = 1, n_algae
     867           0 :             write(nchar,'(i3.3)') n
     868           0 :             write(vname_in,'(a,a)') 'algal_chl', trim(nchar)
     869             :             call define_hist_field(n_bgc_chl(n,:),vname_in,"mg chl/m^2",tstr2D, tcstr, &
     870             :              "Bulk ice bottom algae (chlorophyll)",                             &   ! LCOV_EXCL_LINE
     871             :              "skeletal layer: bottom 3 cm", c1, c0,                &   ! LCOV_EXCL_LINE
     872           0 :              ns, f_bgc_chl)
     873             :           enddo
     874             :         endif !f_bgc_chl
     875           0 :         if (f_bgc_C(1:1) /= 'x') then
     876           0 :           do n = 1, n_algae
     877           0 :             write(nchar,'(i3.3)') n
     878           0 :             write(vname_in,'(a,a)') 'algal_C', trim(nchar)
     879             :             call define_hist_field(n_bgc_C(n,:),vname_in,"mmol C/m^2",tstr2D, tcstr, &
     880             :              "Bulk ice bottom diatoms (carbon)",                             &   ! LCOV_EXCL_LINE
     881             :              "skeletal layer: bottom 3 cm", c1, c0,                &   ! LCOV_EXCL_LINE
     882           0 :              ns, f_bgc_C)
     883             :           enddo
     884             :         endif
     885           0 :         if (f_bgc_DOC(1:1) /= 'x') then
     886           0 :           do n = 1, n_doc
     887           0 :             write(nchar,'(i3.3)') n
     888           0 :             write(vname_in,'(a,a)') 'DOC', trim(nchar)
     889             :             call define_hist_field(n_bgc_DOC(n,:),vname_in,"mmol/m^2",tstr2D, tcstr, &
     890             :              "Bulk DOC (carbon)",                                      &   ! LCOV_EXCL_LINE
     891             :              "skeletal layer: bottom 3 cm", c1, c0,                &   ! LCOV_EXCL_LINE
     892           0 :              ns, f_bgc_DOC)
     893             :           enddo
     894             :         endif
     895           0 :         if (f_bgc_DIC(1:1) /= 'x') then
     896           0 :           do n = 1, n_dic
     897           0 :             write(nchar,'(i3.3)') n
     898           0 :             write(vname_in,'(a,a)') 'DIC', trim(nchar)
     899             :             call define_hist_field(n_bgc_DIC(n,:),vname_in,"mmol/m^2",tstr2D, tcstr, &
     900             :              "Bulk DIC (carbon)",                                      &   ! LCOV_EXCL_LINE
     901             :              "skeletal layer: bottom 3 cm", c1, c0,                &   ! LCOV_EXCL_LINE
     902           0 :              ns, f_bgc_DIC)
     903             :           enddo
     904             :         endif
     905           0 :         if (f_bgc_DON(1:1) /= 'x') then
     906           0 :           do n = 1, n_don
     907           0 :             write(nchar,'(i3.3)') n
     908           0 :             write(vname_in,'(a,a)') 'DON', trim(nchar)
     909             :             call define_hist_field(n_bgc_DON(n,:),vname_in,"mmol/m^2",tstr2D, tcstr, &
     910             :              "Bulk ice bottom DON (nitrogen)",                             &   ! LCOV_EXCL_LINE
     911             :              "skeletal layer: bottom 3 cm", c1, c0,                &   ! LCOV_EXCL_LINE
     912           0 :              ns, f_bgc_DON)
     913             :           enddo
     914             :         endif !f_bgc_DON
     915           0 :         if (f_bgc_Fe (1:1) /= 'x') then
     916           0 :           do n = 1, n_fed
     917           0 :             write(nchar,'(i3.3)') n
     918           0 :             write(vname_in,'(a,a)') 'dFe', trim(nchar)
     919             :             call define_hist_field(n_bgc_Fed (n,:),vname_in,"umol/m^2",tstr2D, tcstr, &
     920             :              "Bulk ice bottom dissolved Fe (iron)",                             &   ! LCOV_EXCL_LINE
     921             :              "skeletal layer: bottom 3 cm", c1, c0,                &   ! LCOV_EXCL_LINE
     922           0 :              ns, f_bgc_Fed )
     923             :           enddo
     924           0 :           do n = 1, n_fep
     925           0 :             write(nchar,'(i3.3)') n
     926           0 :             write(vname_in,'(a,a)') 'pFe', trim(nchar)
     927             :             call define_hist_field(n_bgc_Fep (n,:),vname_in,"umol/m^2",tstr2D, tcstr, &
     928             :              "Bulk ice bottom particulate Fe (iron)",                           &   ! LCOV_EXCL_LINE
     929             :              "skeletal layer: bottom 3 cm", c1, c0,                &   ! LCOV_EXCL_LINE
     930           0 :              ns, f_bgc_Fep )
     931             :           enddo
     932             :         endif !f_bgc_Fe
     933             : 
     934           0 :         if (f_bgc_Nit(1:1) /= 'x') &
     935             :           call define_hist_field(n_bgc_Nit,"Nit","mmol/m^2",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     936             :              "Bulk skeletal nutrient (nitrate)",                             &   ! LCOV_EXCL_LINE
     937             :              "skeletal layer: bottom 3 cm", c1, c0,                &   ! LCOV_EXCL_LINE
     938           0 :              ns, f_bgc_Nit)
     939           0 :         if (f_bgc_Am(1:1) /= 'x') &
     940             :           call define_hist_field(n_bgc_Am,"Am","mmol/m^2",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     941             :              "Bulk skeletal nutrient (ammonia/um)",                        &   ! LCOV_EXCL_LINE
     942             :              "skeletal layer: bottom 3 cm", c1, c0,                &   ! LCOV_EXCL_LINE
     943           0 :              ns, f_bgc_Am)
     944           0 :         if (f_bgc_Sil(1:1) /= 'x') &
     945             :           call define_hist_field(n_bgc_Sil,"Sil","mmol/m^2",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     946             :              "Bulk skeletal nutrient (silicate)",                            &   ! LCOV_EXCL_LINE
     947             :              "skelelal layer: bottom 3 cm", c1, c0,                &   ! LCOV_EXCL_LINE
     948           0 :              ns, f_bgc_Sil)
     949           0 :         if (f_bgc_hum(1:1) /= 'x') &
     950             :           call define_hist_field(n_bgc_hum,"hum","mmol/m^2",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     951             :              "Bulk skeletal humic material (carbon)",              &   ! LCOV_EXCL_LINE
     952             :              "skelelal layer: bottom 3 cm", c1, c0,                &   ! LCOV_EXCL_LINE
     953           0 :              ns, f_bgc_hum)
     954           0 :         if (f_bgc_PON(1:1) /= 'x') &
     955             :           call define_hist_field(n_bgc_PON,"PON","mmol/m^2",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     956             :              "Bulk skeletal nutrient (silicate)",                            &   ! LCOV_EXCL_LINE
     957             :              "skelelal layer: bottom 3 cm", c1, c0,                &   ! LCOV_EXCL_LINE
     958           0 :              ns, f_bgc_PON)
     959           0 :         if (f_bgc_DMSPp(1:1) /= 'x') &
     960             :           call define_hist_field(n_bgc_DMSPp,"DMSPp","mmol/m^2",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     961             :              "Bulk particulate S in algae (DMSPp)",                              &   ! LCOV_EXCL_LINE
     962             :              "skeletal layer: bottom 3 cm", c1, c0,                &   ! LCOV_EXCL_LINE
     963           0 :              ns, f_bgc_DMSPp)
     964           0 :         if (f_bgc_DMSPd(1:1) /= 'x') &
     965             :           call define_hist_field(n_bgc_DMSPd,"DMSPd","mmol/m^2",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     966             :              "Bulk dissolved skl precursor (DSMPd)",                             &   ! LCOV_EXCL_LINE
     967             :              "skeletal layer: bottom 3 cm", c1, c0,                &   ! LCOV_EXCL_LINE
     968           0 :              ns, f_bgc_DMSPd)
     969           0 :         if (f_bgc_DMS(1:1) /= 'x') &
     970             :           call define_hist_field(n_bgc_DMS,"DMS","mmol/m^2",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
     971             :              "Bulk dissolved skl trace gas (DMS)",                           &   ! LCOV_EXCL_LINE
     972             :              "skeletal layer: bottom 3 cm", c1, c0,                &   ! LCOV_EXCL_LINE
     973           0 :              ns, f_bgc_DMS)
     974             : 
     975             :       endif  !skl_bgc
     976             : 
     977             :       ! vertical and skeletal layer biogeochemistry
     978             : 
     979           0 :         if (f_bgc_DOC_ml(1:1) /= 'x') then
     980           0 :           do n = 1, n_doc
     981           0 :             write(nchar,'(i3.3)') n
     982           0 :             write(vname_in,'(a,a)') 'ml_DOC', trim(nchar)
     983             :             call define_hist_field(n_bgc_DOC_ml(n,:),vname_in,"mmol/m^3",tstr2D, tcstr, &
     984             :              "mixed layer DOC (carbon)",                             &   ! LCOV_EXCL_LINE
     985             :              "upper ocean", c1, c0,                &   ! LCOV_EXCL_LINE
     986           0 :              ns, f_bgc_DOC_ml)
     987             :           enddo
     988             :         endif
     989           0 :         if (f_bgc_DIC_ml(1:1) /= 'x') then
     990           0 :           do n = 1, n_dic
     991           0 :             write(nchar,'(i3.3)') n
     992           0 :             write(vname_in,'(a,a)') 'ml_DIC', trim(nchar)
     993             :             call define_hist_field(n_bgc_DIC_ml(n,:),vname_in,"mmol/m^3",tstr2D, tcstr, &
     994             :              "mixed layer DIC (carbon)",                             &   ! LCOV_EXCL_LINE
     995             :              "upper ocean", c1, c0,                &   ! LCOV_EXCL_LINE
     996           0 :              ns, f_bgc_DIC_ml)
     997             :           enddo
     998             :         endif
     999           0 :         if (f_bgc_DON_ml(1:1) /= 'x') then
    1000           0 :           do n = 1, n_don
    1001           0 :             write(nchar,'(i3.3)') n
    1002           0 :             write(vname_in,'(a,a)') 'ml_DON', trim(nchar)
    1003             :             call define_hist_field(n_bgc_DON_ml(n,:),vname_in,"mmol/m^3",tstr2D, tcstr, &
    1004             :              "mixed layer DON (nitrogen)",                           &   ! LCOV_EXCL_LINE
    1005             :              "upper ocean", c1, c0,                &   ! LCOV_EXCL_LINE
    1006           0 :              ns, f_bgc_DON_ml)
    1007             :           enddo
    1008             :         endif
    1009           0 :         if (f_bgc_Fed_ml (1:1) /= 'x') then
    1010           0 :           do n = 1, n_fed
    1011           0 :             write(nchar,'(i3.3)') n
    1012           0 :             write(vname_in,'(a,a)') 'ml_dFe', trim(nchar)
    1013             :             call define_hist_field(n_bgc_Fed_ml (n,:),vname_in,"nM",tstr2D, tcstr, &
    1014             :              "mixed layer dissolved Fe (iron)",                           &   ! LCOV_EXCL_LINE
    1015             :              "upper ocean", c1, c0,                &   ! LCOV_EXCL_LINE
    1016           0 :              ns, f_bgc_Fed_ml )
    1017             :           enddo
    1018             :         endif
    1019           0 :         if (f_bgc_Fep_ml (1:1) /= 'x') then
    1020           0 :           do n = 1, n_fep
    1021           0 :             write(nchar,'(i3.3)') n
    1022           0 :             write(vname_in,'(a,a)') 'ml_pFe', trim(nchar)
    1023             :             call define_hist_field(n_bgc_Fep_ml (n,:),vname_in,"nM",tstr2D, tcstr, &
    1024             :              "mixed layer particulate Fe (iron)",                           &   ! LCOV_EXCL_LINE
    1025             :              "upper ocean", c1, c0,                &   ! LCOV_EXCL_LINE
    1026           0 :              ns, f_bgc_Fep_ml )
    1027             :           enddo
    1028             :         endif
    1029           0 :         if (f_bgc_N_ml(1:1) /= 'x') then
    1030           0 :           do n = 1, n_algae
    1031           0 :             write(nchar,'(i3.3)') n
    1032           0 :             write(vname_in,'(a,a)') 'ml_N', trim(nchar)
    1033             :             call define_hist_field(n_bgc_N_ml(n,:),vname_in,"mmol/m^3",tstr2D, tcstr, &
    1034             :              "mixed layer nitrogen",                             &   ! LCOV_EXCL_LINE
    1035             :              "upper ocean", c1, c0,                &   ! LCOV_EXCL_LINE
    1036           0 :              ns, f_bgc_N_ml)
    1037             :           enddo
    1038             :         endif
    1039           0 :         if (f_bgc_Nit_ml(1:1) /= 'x') &
    1040             :           call define_hist_field(n_bgc_Nit_ml,"ml_Nit","mmol/m^3",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1041             :              "mixed layer nutrient (nitrate)",                         &   ! LCOV_EXCL_LINE
    1042             :              "upper ocean", c1, c0,                                  &   ! LCOV_EXCL_LINE
    1043           0 :              ns, f_bgc_Nit_ml)
    1044           0 :         if (f_bgc_Am_ml(1:1) /= 'x') &
    1045             :           call define_hist_field(n_bgc_Am_ml,"ml_Am","mmol/m^3",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1046             :              "mixed layer nutrient (ammonia/um)",                    &   ! LCOV_EXCL_LINE
    1047             :              "upper ocean", c1, c0,                                  &   ! LCOV_EXCL_LINE
    1048           0 :              ns, f_bgc_Am_ml)
    1049           0 :         if (f_bgc_Sil_ml(1:1) /= 'x') &
    1050             :           call define_hist_field(n_bgc_Sil_ml,"ml_Sil","mmol/m^3",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1051             :              "mixed layer nutrient (silicate)",                        &   ! LCOV_EXCL_LINE
    1052             :              "upper ocean", c1, c0,                                  &   ! LCOV_EXCL_LINE
    1053           0 :              ns, f_bgc_Sil_ml)
    1054           0 :         if (f_bgc_hum_ml(1:1) /= 'x') &
    1055             :           call define_hist_field(n_bgc_hum_ml,"ml_hum","mmol/m^3",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1056             :              "mixed layer humic material (carbon)",                             &   ! LCOV_EXCL_LINE
    1057             :              "upper ocean", c1, c0,                                  &   ! LCOV_EXCL_LINE
    1058           0 :              ns, f_bgc_hum_ml)
    1059           0 :         if (f_bgc_DMSP_ml(1:1) /= 'x') &
    1060             :           call define_hist_field(n_bgc_DMSP_ml,"ml_DMSP","mmol/m^3",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1061             :              "mixed layer precursor (DMSP)",                             &   ! LCOV_EXCL_LINE
    1062             :              "upper ocean", c1, c0,                                  &   ! LCOV_EXCL_LINE
    1063           0 :              ns, f_bgc_DMSP_ml)
    1064           0 :         if (f_bgc_DMS_ml(1:1) /= 'x') &
    1065             :           call define_hist_field(n_bgc_DMS_ml,"ml_DMS","mmol/m^3",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1066             :              "mixed layer trace gas (DMS)",                            &   ! LCOV_EXCL_LINE
    1067             :              "upper ocean", c1, c0,                                  &   ! LCOV_EXCL_LINE
    1068           0 :              ns, f_bgc_DMS_ml)
    1069             : 
    1070           0 :         if (f_fNit(1:1) /= 'x') &
    1071             :           call define_hist_field(n_fNit,"fNit","mmol/m^2/s",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1072             :              "nitrate flux ice to ocn (cpl)",                           &   ! LCOV_EXCL_LINE
    1073             :              "if positive, ocean gains nitrate", c1, c0,                &   ! LCOV_EXCL_LINE
    1074           0 :              ns, f_fNit)
    1075             : 
    1076           0 :         if (f_fNit_ai(1:1) /= 'x') &
    1077             :           call define_hist_field(n_fNit_ai,"fNit_ai","mmol/m^2/s",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1078             :              "nitrate flux ice to ocean",                            &   ! LCOV_EXCL_LINE
    1079             :              "weighted by ice area", c1, c0,                         &   ! LCOV_EXCL_LINE
    1080           0 :              ns, f_fNit_ai)
    1081             : 
    1082           0 :         if (f_fAm(1:1) /= 'x') &
    1083             :           call define_hist_field(n_fAm,"fAm","mmol/m^2/s",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1084             :              "ammonium flux ice to ocn (cpl)",                     &   ! LCOV_EXCL_LINE
    1085             :              "if positive, ocean gains ammonium", c1, c0,          &   ! LCOV_EXCL_LINE
    1086           0 :              ns, f_fAm)
    1087             : 
    1088           0 :         if (f_fAm_ai(1:1) /= 'x') &
    1089             :           call define_hist_field(n_fAm_ai,"fAm_ai","mmol/m^2/s",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1090             :              "ammonium flux ice to ocean",                           &   ! LCOV_EXCL_LINE
    1091             :              "weighted by ice area", c1, c0,                         &   ! LCOV_EXCL_LINE
    1092           0 :              ns, f_fAm_ai)
    1093           0 :         if (f_fN(1:1) /= 'x') then
    1094           0 :           do n = 1, n_algae
    1095           0 :             write(nchar,'(i3.3)') n
    1096           0 :             write(vname_in,'(a,a)') 'fN', trim(nchar)
    1097             :             call define_hist_field(n_fN(n,:),vname_in,"mmol/m^2/s",tstr2D, tcstr, &
    1098             :              "algal N flux ice to ocn (cpl)",                     &   ! LCOV_EXCL_LINE
    1099             :              "if positive, ocean gains algal N", c1, c0,          &   ! LCOV_EXCL_LINE
    1100           0 :              ns, f_fN)
    1101             :           enddo
    1102             :         endif
    1103           0 :         if (f_fN_ai(1:1) /= 'x') then
    1104           0 :           do n = 1, n_algae
    1105           0 :             write(nchar,'(i3.3)') n
    1106           0 :             write(vname_in,'(a,a)') 'fN_ai', trim(nchar)
    1107             :             call define_hist_field(n_fN_ai(n,:),vname_in,"mmol/m^2/s",tstr2D, tcstr, &
    1108             :              "algal N flux ice to ocean",                            &   ! LCOV_EXCL_LINE
    1109             :              "weighted by ice area", c1, c0,                         &   ! LCOV_EXCL_LINE
    1110           0 :              ns, f_fN_ai)
    1111             :           enddo
    1112             :         endif
    1113           0 :         if (f_fDOC(1:1) /= 'x') then
    1114           0 :           do n = 1, n_doc
    1115           0 :             write(nchar,'(i3.3)') n
    1116           0 :             write(vname_in,'(a,a)') 'fDOC', trim(nchar)
    1117             :             call define_hist_field(n_fDOC(n,:),vname_in,"mmol/m^2/s",tstr2D, tcstr, &
    1118             :              "DOC flux ice to ocn (cpl)",                     &   ! LCOV_EXCL_LINE
    1119             :              "positive to ocean", c1, c0,                   &   ! LCOV_EXCL_LINE
    1120           0 :              ns, f_fDOC)
    1121             :           enddo
    1122             :         endif
    1123           0 :         if (f_fDOC_ai(1:1) /= 'x') then
    1124           0 :           do n = 1, n_doc
    1125           0 :             write(nchar,'(i3.3)') n
    1126           0 :             write(vname_in,'(a,a)') 'fDOC_ai', trim(nchar)
    1127             :             call define_hist_field(n_fDOC_ai(n,:),vname_in,"mmol/m^2/s",tstr2D, tcstr, &
    1128             :              "DOC flux ice to ocn",                              &   ! LCOV_EXCL_LINE
    1129             :              "weighted by ice area", c1, c0,                         &   ! LCOV_EXCL_LINE
    1130           0 :              ns, f_fDOC_ai)
    1131             :           enddo
    1132             :         endif
    1133           0 :         if (f_fDIC(1:1) /= 'x') then
    1134           0 :           do n = 1, n_dic
    1135           0 :             write(nchar,'(i3.3)') n
    1136           0 :             write(vname_in,'(a,a)') 'fDIC', trim(nchar)
    1137             :             call define_hist_field(n_fDIC(n,:),vname_in,"mmol/m^2/s",tstr2D, tcstr, &
    1138             :              "DIC flux ice to ocn (cpl)",                     &   ! LCOV_EXCL_LINE
    1139             :              "positive to ocean", c1, c0,                   &   ! LCOV_EXCL_LINE
    1140           0 :              ns, f_fDIC)
    1141             :           enddo
    1142             :         endif
    1143           0 :         if (f_fDIC_ai(1:1) /= 'x') then
    1144           0 :           do n = 1, n_dic
    1145           0 :             write(nchar,'(i3.3)') n
    1146           0 :             write(vname_in,'(a,a)') 'fDIC_ai', trim(nchar)
    1147             :             call define_hist_field(n_fDIC_ai(n,:),vname_in,"mmol/m^2/s",tstr2D, tcstr, &
    1148             :              "DIC flux ice to ocn",                              &   ! LCOV_EXCL_LINE
    1149             :              "weighted by ice area", c1, c0,                         &   ! LCOV_EXCL_LINE
    1150           0 :              ns, f_fDIC_ai)
    1151             :           enddo
    1152             :         endif
    1153           0 :         if (f_fDON(1:1) /= 'x') then
    1154           0 :           do n = 1, n_don
    1155           0 :             write(nchar,'(i3.3)') n
    1156           0 :             write(vname_in,'(a,a)') 'fDON', trim(nchar)
    1157             :             call define_hist_field(n_fDON(n,:),vname_in,"mmol/m^2/s",tstr2D, tcstr, &
    1158             :              "DON flux ice to ocn (cpl)",                     &   ! LCOV_EXCL_LINE
    1159             :              "positive to ocean", c1, c0,                   &   ! LCOV_EXCL_LINE
    1160           0 :              ns, f_fDON)
    1161             :           enddo
    1162             :         endif
    1163           0 :         if (f_fDON_ai(1:1) /= 'x') then
    1164           0 :           do n = 1, n_don
    1165           0 :             write(nchar,'(i3.3)') n
    1166           0 :             write(vname_in,'(a,a)') 'fDON_ai', trim(nchar)
    1167             :             call define_hist_field(n_fDON_ai(n,:),vname_in,"mmol/m^2/s",tstr2D, tcstr, &
    1168             :              "DON flux ice to ocn",                              &   ! LCOV_EXCL_LINE
    1169             :              "weighted by ice area", c1, c0,                         &   ! LCOV_EXCL_LINE
    1170           0 :              ns, f_fDON_ai)
    1171             :           enddo
    1172             :         endif
    1173           0 :         if (f_fFed(1:1) /= 'x') then
    1174           0 :           do n = 1, n_fed
    1175           0 :             write(nchar,'(i3.3)') n
    1176           0 :             write(vname_in,'(a,a)') 'fdFe', trim(nchar)
    1177             :             call define_hist_field(n_fFed (n,:),vname_in,"umol/m^2/s",tstr2D, tcstr, &
    1178             :              "dFe flux ice to ocn (cpl)",                     &   ! LCOV_EXCL_LINE
    1179             :              "positive to ocean", c1, c0,                   &   ! LCOV_EXCL_LINE
    1180           0 :              ns, f_fFed )
    1181             :           enddo
    1182             :         endif
    1183           0 :         if (f_fFed_ai (1:1) /= 'x') then
    1184           0 :           do n = 1, n_fed
    1185           0 :             write(nchar,'(i3.3)') n
    1186           0 :             write(vname_in,'(a,a)') 'fdFe_ai', trim(nchar)
    1187             :             call define_hist_field(n_fFed_ai (n,:),vname_in,"umol/m^2/s",tstr2D, tcstr, &
    1188             :              "dFe flux ice to ocn",                              &   ! LCOV_EXCL_LINE
    1189             :              "weighted by ice area", c1, c0,                         &   ! LCOV_EXCL_LINE
    1190           0 :              ns, f_fFed_ai )
    1191             :           enddo
    1192             :         endif
    1193           0 :         if (f_fFep(1:1) /= 'x') then
    1194           0 :           do n = 1, n_fep
    1195           0 :             write(nchar,'(i3.3)') n
    1196           0 :             write(vname_in,'(a,a)') 'fpFe', trim(nchar)
    1197             :             call define_hist_field(n_fFep (n,:),vname_in,"umol/m^2/s",tstr2D, tcstr, &
    1198             :              "pFe flux ice to ocn (cpl)",                     &   ! LCOV_EXCL_LINE
    1199             :              "positive to ocean", c1, c0,                   &   ! LCOV_EXCL_LINE
    1200           0 :              ns, f_fFep )
    1201             :           enddo
    1202             :         endif
    1203           0 :         if (f_fFep_ai (1:1) /= 'x') then
    1204           0 :           do n = 1, n_fep
    1205           0 :             write(nchar,'(i3.3)') n
    1206           0 :             write(vname_in,'(a,a)') 'fpFe_ai', trim(nchar)
    1207             :             call define_hist_field(n_fFep_ai (n,:),vname_in,"umol/m^2/s",tstr2D, tcstr, &
    1208             :              "pFe flux ice to ocn",                              &   ! LCOV_EXCL_LINE
    1209             :              "weighted by ice area", c1, c0,                         &   ! LCOV_EXCL_LINE
    1210           0 :              ns, f_fFep_ai )
    1211             :           enddo
    1212             :         endif
    1213           0 :         if (f_fSil(1:1) /= 'x') &
    1214             :           call define_hist_field(n_fSil,"fSil","mmol/m^2/s",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1215             :              "silicate flux ice to ocn (cpl)",                     &   ! LCOV_EXCL_LINE
    1216             :              "positive into ocean", c1, c0,          &   ! LCOV_EXCL_LINE
    1217           0 :              ns, f_fSil)
    1218             : 
    1219           0 :         if (f_fSil_ai(1:1) /= 'x') &
    1220             :           call define_hist_field(n_fSil_ai,"fSil_ai","mmol/m^2/s",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1221             :              "silicate flux ice to ocean",                               &   ! LCOV_EXCL_LINE
    1222             :              "weighted by ice area", c1, c0,                         &   ! LCOV_EXCL_LINE
    1223           0 :              ns, f_fSil_ai)
    1224             : 
    1225           0 :         if (f_fhum(1:1) /= 'x') &
    1226             :           call define_hist_field(n_fhum,"fhum","mmol/m^2/s",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1227             :              "humic matter (carbon) flux ice to ocn (cpl)",          &   ! LCOV_EXCL_LINE
    1228             :              "positive into ocean", c1, c0,                   &   ! LCOV_EXCL_LINE
    1229           0 :              ns, f_fhum)
    1230             : 
    1231           0 :         if (f_fhum_ai(1:1) /= 'x') &
    1232             :           call define_hist_field(n_fhum_ai,"fhum_ai","mmol/m^2/s",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1233             :              "humic matter (carbon) flux ice to ocean",              &   ! LCOV_EXCL_LINE
    1234             :              "weighted by ice area", c1, c0,                         &   ! LCOV_EXCL_LINE
    1235           0 :              ns, f_fhum_ai)
    1236             : 
    1237           0 :         if (f_fPON(1:1) /= 'x') &
    1238             :           call define_hist_field(n_fPON,"fPON","mmol/m^2/s",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1239             :              "PON flux ice to ocean",                               &   ! LCOV_EXCL_LINE
    1240             :              "positive into ocean", c1, c0,                         &   ! LCOV_EXCL_LINE
    1241           0 :              ns, f_fPON)
    1242             : 
    1243           0 :         if (f_fPON_ai(1:1) /= 'x') &
    1244             :           call define_hist_field(n_fPON_ai,"fPON_ai","mmol/m^2/s",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1245             :              "PON flux ice to ocean",                               &   ! LCOV_EXCL_LINE
    1246             :              "weighted by ice area", c1, c0,                         &   ! LCOV_EXCL_LINE
    1247           0 :              ns, f_fPON_ai)
    1248             : 
    1249           0 :         if (f_fDMS(1:1) /= 'x') &
    1250             :           call define_hist_field(n_fDMS,"fDMS","mmol/m^2/s",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1251             :              "DMS flux ice to ocean",                               &   ! LCOV_EXCL_LINE
    1252             :              "positive into ocean", c1, c0,                         &   ! LCOV_EXCL_LINE
    1253           0 :              ns, f_fDMS)
    1254             : 
    1255           0 :         if (f_fDMS_ai(1:1) /= 'x') &
    1256             :           call define_hist_field(n_fDMS_ai,"fDMS_ai","mmol/m^2/s",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1257             :              "DMS flux ice to ocean",                               &   ! LCOV_EXCL_LINE
    1258             :              "weighted by ice area", c1, c0,                         &   ! LCOV_EXCL_LINE
    1259           0 :              ns, f_fDMS_ai)
    1260             : 
    1261           0 :         if (f_fDMSPd(1:1) /= 'x') &
    1262             :           call define_hist_field(n_fDMSPd,"fDMSPd","mmol/m^2/s",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1263             :              "DMSPd flux ice to ocean",                               &   ! LCOV_EXCL_LINE
    1264             :              "positive into ocean", c1, c0,                         &   ! LCOV_EXCL_LINE
    1265           0 :              ns, f_fDMSPd)
    1266             : 
    1267           0 :         if (f_fDMSPd_ai(1:1) /= 'x') &
    1268             :           call define_hist_field(n_fDMSPd_ai,"fDMSPd_ai","mmol/m^2/s",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1269             :              "DMSPd flux ice to ocean",                               &   ! LCOV_EXCL_LINE
    1270             :              "weighted by ice area", c1, c0,                         &   ! LCOV_EXCL_LINE
    1271           0 :              ns, f_fDMSPd_ai)
    1272             : 
    1273           0 :         if (f_fDMSPp(1:1) /= 'x') &
    1274             :           call define_hist_field(n_fDMSPp,"fDMSPp","mmol/m^2/s",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1275             :              "DMSPp flux ice to ocean",                               &   ! LCOV_EXCL_LINE
    1276             :              "positive into ocean", c1, c0,                         &   ! LCOV_EXCL_LINE
    1277           0 :              ns, f_fDMSPp)
    1278             : 
    1279           0 :         if (f_fDMSPp_ai(1:1) /= 'x') &
    1280             :           call define_hist_field(n_fDMSPp_ai,"fDMSPp_ai","mmol/m^2/s",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1281             :              "DMSPp flux ice to ocean",                               &   ! LCOV_EXCL_LINE
    1282             :              "weighted by ice area", c1, c0,                         &   ! LCOV_EXCL_LINE
    1283           0 :              ns, f_fDMSPp_ai)
    1284             : 
    1285           0 :         if (f_PPnet(1:1) /= 'x') &
    1286             :           call define_hist_field(n_PPnet,"PP_net","mg C/m^2/d",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1287             :              "Net Primary Production",            &   ! LCOV_EXCL_LINE
    1288             :              "weighted by ice area", c1, c0,       &   ! LCOV_EXCL_LINE
    1289           0 :              ns, f_PPnet)
    1290             : 
    1291           0 :         if (f_grownet(1:1) /= 'x') &
    1292             :           call define_hist_field(n_grownet,"grow_net","m/d",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1293             :              "Net specific growth",                     &   ! LCOV_EXCL_LINE
    1294             :              "weighted by brine or skl volume ", c1, c0,       &   ! LCOV_EXCL_LINE
    1295           0 :              ns, f_grownet)
    1296             : 
    1297           0 :         if (f_upNO(1:1) /= 'x') &
    1298             :           call define_hist_field(n_upNO,"upNO","mmol/m^2/d",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1299             :              "Tot algal Nit uptake rate",                  &   ! LCOV_EXCL_LINE
    1300             :              "weighted by ice area", c1, c0, &   ! LCOV_EXCL_LINE
    1301           0 :              ns, f_upNO)
    1302             : 
    1303           0 :         if (f_upNH(1:1) /= 'x') &
    1304             :           call define_hist_field(n_upNH,"upNH","mmol/m^2/d",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1305             :              "Tot algal Am uptake rate",                  &   ! LCOV_EXCL_LINE
    1306             :              "weighted by ice area", c1, c0,&   ! LCOV_EXCL_LINE
    1307           0 :              ns, f_upNH)
    1308             : 
    1309             :         ! vertical biogeochemistry
    1310           0 :       if (z_tracers) then
    1311             : 
    1312           0 :         if (f_fzaero(1:1) /= 'x') then
    1313           0 :           do n = 1, n_zaero
    1314           0 :             write(nchar,'(i3.3)') n
    1315           0 :             write(vname_in,'(a,a)') 'fzaero', trim(nchar)
    1316             :             call define_hist_field(n_fzaero(n,:),vname_in,"kg/m^2/s",tstr2D, tcstr, &
    1317             :              "z aerosol flux ice to ocn (cpl)",                     &   ! LCOV_EXCL_LINE
    1318             :              "positive to ocean", c1, c0,                   &   ! LCOV_EXCL_LINE
    1319           0 :              ns, f_fzaero)
    1320             :           enddo
    1321             :         endif
    1322           0 :         if (f_fzaero_ai(1:1) /= 'x') then
    1323           0 :           do n = 1, n_zaero
    1324           0 :             write(nchar,'(i3.3)') n
    1325           0 :             write(vname_in,'(a,a)') 'fzaero_ai', trim(nchar)
    1326             :             call define_hist_field(n_fzaero_ai(n,:),vname_in,"kg/m^2/s",tstr2D, tcstr, &
    1327             :              "z aerosol flux ice to ocn",                     &   ! LCOV_EXCL_LINE
    1328             :              "weighted by ice area", c1, c0,                   &   ! LCOV_EXCL_LINE
    1329           0 :              ns, f_fzaero_ai)
    1330             :           enddo
    1331             :         endif
    1332           0 :         if (f_algalpeak(1:1) /= 'x') then
    1333           0 :           do n = 1, n_algae
    1334           0 :             write(nchar,'(i3.3)') n
    1335           0 :             write(vname_in,'(a,a)') 'peak_loc', trim(nchar)
    1336             :             call define_hist_field(n_algalpeak(n,:),vname_in,"1",tstr2D, tcstr, &
    1337             :              "zgrid level of peak chla",            &   ! LCOV_EXCL_LINE
    1338             :              "0 if no distinct peak", c1, c0,       &   ! LCOV_EXCL_LINE
    1339           0 :              ns, f_algalpeak)
    1340             :           enddo
    1341             :         endif
    1342           0 :         if (f_peakval(1:1) /= 'x') then
    1343           0 :           do n = 1, n_algae
    1344           0 :             write(nchar,'(i3.3)') n
    1345           0 :             write(vname_in,'(a,a)') 'peak_val', trim(nchar)
    1346             :             call define_hist_field(n_peakval(n,:),vname_in,"mg/m^3",tstr2D, tcstr, &
    1347             :              "Bulk concentration of peak chla",            &   ! LCOV_EXCL_LINE
    1348             :              "at peak_loc", c1, c0,       &   ! LCOV_EXCL_LINE
    1349           0 :              ns, f_peakval)
    1350             :           enddo
    1351             :         endif
    1352           0 :         if (f_zaeronet(1:1) /= 'x')  then
    1353           0 :           do n = 1, n_zaero
    1354           0 :             write(nchar,'(i3.3)') n
    1355           0 :             write(vname_in,'(a,a)') 'zaero_net', trim(nchar)
    1356             :              call define_hist_field(n_zaeronet(n,:),vname_in,"kg/m^2",tstr2D, tcstr, &
    1357             :              "Net z aerosol",                     &   ! LCOV_EXCL_LINE
    1358             :              "weighted by ice area ", c1, c0,       &   ! LCOV_EXCL_LINE
    1359           0 :              ns, f_zaeronet)
    1360             :           enddo
    1361             :         endif  !f_zaeronet
    1362           0 :         if (f_chlnet(1:1) /= 'x')  then
    1363           0 :           do n = 1, n_algae
    1364           0 :             write(nchar,'(i3.3)') n
    1365           0 :             write(vname_in,'(a,a)') 'chl_net', trim(nchar)
    1366             :              call define_hist_field(n_chlnet(n,:),vname_in,"mg chl/m^2",tstr2D, tcstr, &
    1367             :              "Net chlorophyll",                     &   ! LCOV_EXCL_LINE
    1368             :              "weighted by ice area ", c1, c0,       &   ! LCOV_EXCL_LINE
    1369           0 :              ns, f_chlnet)
    1370             :           enddo
    1371             :         endif  !f_chlnet
    1372           0 :         if (f_Nnet(1:1) /= 'x') then
    1373           0 :           do n = 1, n_algae
    1374           0 :             write(nchar,'(i3.3)') n
    1375           0 :             write(vname_in,'(a,a)') 'algalN_net', trim(nchar)
    1376             :             call define_hist_field(n_Nnet(n,:),vname_in,"mmol/m^2",tstr2D, tcstr, &
    1377             :              "Net algal nitrogen",                     &   ! LCOV_EXCL_LINE
    1378             :              "weighted by ice area ", c1, c0,       &   ! LCOV_EXCL_LINE
    1379           0 :              ns, f_Nnet)
    1380             :           enddo
    1381             :         endif !f_Nnet
    1382             : 
    1383           0 :         if (f_Cnet(1:1) /= 'x') then
    1384           0 :           do n = 1, n_algae
    1385           0 :             write(nchar,'(i3.3)') n
    1386           0 :             write(vname_in,'(a,a)') 'algalC_net', trim(nchar)
    1387             :             call define_hist_field(n_Cnet(n,:),vname_in,"mmol/m^2",tstr2D, tcstr, &
    1388             :              "Net algal carbon",                     &   ! LCOV_EXCL_LINE
    1389             :              "weighted by ice area ", c1, c0,       &   ! LCOV_EXCL_LINE
    1390           0 :              ns, f_Cnet)
    1391             :           enddo
    1392             :         endif !f_Cnet
    1393           0 :         if (f_DOCnet(1:1) /= 'x') then
    1394           0 :           do n = 1, n_doc
    1395           0 :             write(nchar,'(i3.3)') n
    1396           0 :             write(vname_in,'(a,a)') 'DOC_net', trim(nchar)
    1397             :             call define_hist_field(n_DOCnet(n,:),vname_in,"mmol/m^2",tstr2D, tcstr, &
    1398             :              "Net DOC",                     &   ! LCOV_EXCL_LINE
    1399             :              "weighted by ice area ", c1, c0,       &   ! LCOV_EXCL_LINE
    1400           0 :              ns, f_DOCnet)
    1401             :           enddo
    1402             :         endif !f_DOCnet
    1403           0 :         if (f_DICnet(1:1) /= 'x') then
    1404           0 :           do n = 1, n_dic
    1405           0 :             write(nchar,'(i3.3)') n
    1406           0 :             write(vname_in,'(a,a)') 'DIC_net', trim(nchar)
    1407             :             call define_hist_field(n_DICnet(n,:),vname_in,"mmol/m^2",tstr2D, tcstr, &
    1408             :              "Net DIC",                     &   ! LCOV_EXCL_LINE
    1409             :              "weighted by ice area ", c1, c0,       &   ! LCOV_EXCL_LINE
    1410           0 :              ns, f_DICnet)
    1411             :           enddo
    1412             :         endif !f_DICnet
    1413           0 :         if (f_DONnet(1:1) /= 'x') then
    1414           0 :           do n = 1, n_don
    1415           0 :             write(nchar,'(i3.3)') n
    1416           0 :             write(vname_in,'(a,a)') 'DON_net', trim(nchar)
    1417             :             call define_hist_field(n_DONnet(n,:),vname_in,"mmol/m^2",tstr2D, tcstr, &
    1418             :              "Net DON",                     &   ! LCOV_EXCL_LINE
    1419             :              "weighted by ice area ", c1, c0,       &   ! LCOV_EXCL_LINE
    1420           0 :              ns, f_DONnet)
    1421             :           enddo
    1422             :         endif !f_DONnet
    1423           0 :         if (f_Fednet (1:1) /= 'x') then
    1424           0 :           do n = 1, n_fed
    1425           0 :             write(nchar,'(i3.3)') n
    1426           0 :             write(vname_in,'(a,a)') 'dFe_net', trim(nchar)
    1427             :             call define_hist_field(n_Fednet (n,:),vname_in,"umol/m^2",tstr2D, tcstr, &
    1428             :              "Net dFe",                     &   ! LCOV_EXCL_LINE
    1429             :              "weighted by ice area ", c1, c0,       &   ! LCOV_EXCL_LINE
    1430           0 :              ns, f_Fednet )
    1431             :           enddo
    1432             :         endif !f_Fednet
    1433           0 :         if (f_Fepnet (1:1) /= 'x') then
    1434           0 :           do n = 1, n_fep
    1435           0 :             write(nchar,'(i3.3)') n
    1436           0 :             write(vname_in,'(a,a)') 'pFe_net', trim(nchar)
    1437             :             call define_hist_field(n_Fepnet (n,:),vname_in,"umol/m^2",tstr2D, tcstr, &
    1438             :              "Net pFe",                     &   ! LCOV_EXCL_LINE
    1439             :              "weighted by ice area ", c1, c0,       &   ! LCOV_EXCL_LINE
    1440           0 :              ns, f_Fepnet )
    1441             :           enddo
    1442             :         endif !f_Fepnet
    1443           0 :         if (f_Nitnet(1:1) /= 'x') &
    1444             :           call define_hist_field(n_Nitnet,"Nit_net","mmol/m^2",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1445             :              "Net Nitrate",                     &   ! LCOV_EXCL_LINE
    1446             :              "weighted by ice area", c1, c0,       &   ! LCOV_EXCL_LINE
    1447           0 :              ns, f_Nitnet)
    1448           0 :         if (f_Amnet(1:1) /= 'x') &
    1449             :           call define_hist_field(n_Amnet,"Am_net","mmol/m^2",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1450             :              "Net Ammonium",                     &   ! LCOV_EXCL_LINE
    1451             :              "weighted by ice area", c1, c0,       &   ! LCOV_EXCL_LINE
    1452           0 :              ns, f_Amnet)
    1453           0 :         if (f_Silnet(1:1) /= 'x') &
    1454             :           call define_hist_field(n_Silnet,"Sil_net","mmol/m^2",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1455             :              "Net Silicate",                     &   ! LCOV_EXCL_LINE
    1456             :              "weighted by ice area", c1, c0,       &   ! LCOV_EXCL_LINE
    1457           0 :              ns, f_Silnet)
    1458           0 :         if (f_humnet(1:1) /= 'x') &
    1459             :           call define_hist_field(n_humnet,"hum_net","mmol/m^2",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1460             :              "Net humic material (carbon)",               &   ! LCOV_EXCL_LINE
    1461             :              "weighted by ice area", c1, c0,       &   ! LCOV_EXCL_LINE
    1462           0 :              ns, f_humnet)
    1463           0 :         if (f_DMSPpnet(1:1) /= 'x') &
    1464             :           call define_hist_field(n_DMSPpnet,"DMSPp_net","mmol/m^2",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1465             :              "Net DMSPp",                     &   ! LCOV_EXCL_LINE
    1466             :              "weighted by ice area", c1, c0,       &   ! LCOV_EXCL_LINE
    1467           0 :              ns, f_DMSPpnet)
    1468           0 :         if (f_DMSPdnet(1:1) /= 'x') &
    1469             :           call define_hist_field(n_DMSPdnet,"DMSPd_net","mmol/m^2",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1470             :              "Net DMSPd",                     &   ! LCOV_EXCL_LINE
    1471             :              "weighted by ice area", c1, c0,       &   ! LCOV_EXCL_LINE
    1472           0 :              ns, f_DMSPdnet)
    1473           0 :         if (f_DMSnet(1:1) /= 'x') &
    1474             :           call define_hist_field(n_DMSnet,"DMS_net","mmol/m^2",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1475             :              "Net DMS",                     &   ! LCOV_EXCL_LINE
    1476             :              "weighted by ice area", c1, c0,       &   ! LCOV_EXCL_LINE
    1477           0 :              ns, f_DMSnet)
    1478           0 :         if (f_PONnet(1:1) /= 'x') &
    1479             :           call define_hist_field(n_PONnet,"PON_net","mmol/m^2",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1480             :              "Net Nitrate if no reactions",                     &   ! LCOV_EXCL_LINE
    1481             :              "weighted by ice area", c1, c0,       &   ! LCOV_EXCL_LINE
    1482           0 :              ns, f_PONnet)
    1483             : 
    1484           0 :         if (f_zaerosnow(1:1) /= 'x')  then
    1485           0 :           do n = 1, n_zaero
    1486           0 :             write(nchar,'(i3.3)') n
    1487           0 :             write(vname_in,'(a,a)') 'zaero_snow', trim(nchar)
    1488             :              call define_hist_field(n_zaerosnow(n,:),vname_in,"kg/m^2",tstr2D, tcstr, &
    1489             :              "Snow z aerosol",                     &   ! LCOV_EXCL_LINE
    1490             :              "weighted by ice area ", c1, c0,       &   ! LCOV_EXCL_LINE
    1491           0 :              ns, f_zaerosnow)
    1492             :           enddo
    1493             :         endif  !f_chlnet
    1494           0 :         if (f_chlsnow(1:1) /= 'x')  then
    1495           0 :           do n = 1, n_algae
    1496           0 :             write(nchar,'(i3.3)') n
    1497           0 :             write(vname_in,'(a,a)') 'chl_snow', trim(nchar)
    1498             :              call define_hist_field(n_chlsnow(n,:),vname_in,"mg chl/m^2",tstr2D, tcstr, &
    1499             :              "Snow chlorophyll",                     &   ! LCOV_EXCL_LINE
    1500             :              "weighted by ice area ", c1, c0,       &   ! LCOV_EXCL_LINE
    1501           0 :              ns, f_chlsnow)
    1502             :           enddo
    1503             :         endif  !f_chlnet
    1504           0 :         if (f_Nsnow(1:1) /= 'x') then
    1505           0 :           do n = 1, n_algae
    1506           0 :             write(nchar,'(i3.3)') n
    1507           0 :             write(vname_in,'(a,a)') 'algalN_snow', trim(nchar)
    1508             :             call define_hist_field(n_Nsnow(n,:),vname_in,"mmol/m^2",tstr2D, tcstr, &
    1509             :              "Snow algal nitrogen",                     &   ! LCOV_EXCL_LINE
    1510             :              "weighted by ice area ", c1, c0,       &   ! LCOV_EXCL_LINE
    1511           0 :              ns, f_Nsnow)
    1512             :           enddo
    1513             :         endif !f_Nsnow
    1514           0 :         if (f_Csnow(1:1) /= 'x') then
    1515           0 :           do n = 1, n_algae
    1516           0 :             write(nchar,'(i3.3)') n
    1517           0 :             write(vname_in,'(a,a)') 'algalC_snow', trim(nchar)
    1518             :             call define_hist_field(n_Csnow(n,:),vname_in,"mmol/m^2",tstr2D, tcstr, &
    1519             :              "Snow algal carbon",                     &   ! LCOV_EXCL_LINE
    1520             :              "weighted by ice area ", c1, c0,       &   ! LCOV_EXCL_LINE
    1521           0 :              ns, f_Csnow)
    1522             :           enddo
    1523             :         endif !f_Csnow
    1524           0 :         if (f_DOCsnow(1:1) /= 'x') then
    1525           0 :           do n = 1, n_doc
    1526           0 :             write(nchar,'(i3.3)') n
    1527           0 :             write(vname_in,'(a,a)') 'DOC_snow', trim(nchar)
    1528             :             call define_hist_field(n_DOCsnow(n,:),vname_in,"mmol/m^2",tstr2D, tcstr, &
    1529             :              "Snow DOC",                     &   ! LCOV_EXCL_LINE
    1530             :              "weighted by ice area ", c1, c0,       &   ! LCOV_EXCL_LINE
    1531           0 :              ns, f_DOCsnow)
    1532             :           enddo
    1533             :         endif !f_DOCsnow
    1534           0 :         if (f_DICsnow(1:1) /= 'x') then
    1535           0 :           do n = 1, n_dic
    1536           0 :             write(nchar,'(i3.3)') n
    1537           0 :             write(vname_in,'(a,a)') 'DIC_snow', trim(nchar)
    1538             :             call define_hist_field(n_DICsnow(n,:),vname_in,"mmol/m^2",tstr2D, tcstr, &
    1539             :              "Snow DIC",                     &   ! LCOV_EXCL_LINE
    1540             :              "weighted by ice area ", c1, c0,       &   ! LCOV_EXCL_LINE
    1541           0 :              ns, f_DICsnow)
    1542             :           enddo
    1543             :         endif !f_DICsnow
    1544           0 :         if (f_DONsnow(1:1) /= 'x') then
    1545           0 :           do n = 1, n_don
    1546           0 :             write(nchar,'(i3.3)') n
    1547           0 :             write(vname_in,'(a,a)') 'DON_snow', trim(nchar)
    1548             :             call define_hist_field(n_DONsnow(n,:),vname_in,"mmol/m^2",tstr2D, tcstr, &
    1549             :              "Snow DON",                     &   ! LCOV_EXCL_LINE
    1550             :              "weighted by ice area ", c1, c0,       &   ! LCOV_EXCL_LINE
    1551           0 :              ns, f_DONsnow)
    1552             :           enddo
    1553             :         endif !f_DONsnow
    1554           0 :         if (f_Fedsnow (1:1) /= 'x') then
    1555           0 :           do n = 1, n_fed
    1556           0 :             write(nchar,'(i3.3)') n
    1557           0 :             write(vname_in,'(a,a)') 'dFe_snow', trim(nchar)
    1558             :             call define_hist_field(n_Fedsnow (n,:),vname_in,"umol/m^2",tstr2D, tcstr, &
    1559             :              "Snow dFe",                     &   ! LCOV_EXCL_LINE
    1560             :              "weighted by ice area ", c1, c0,       &   ! LCOV_EXCL_LINE
    1561           0 :              ns, f_Fedsnow )
    1562             :           enddo
    1563             :         endif !f_Fedsnow
    1564           0 :         if (f_Fepsnow (1:1) /= 'x') then
    1565           0 :           do n = 1, n_fed
    1566           0 :             write(nchar,'(i3.3)') n
    1567           0 :             write(vname_in,'(a,a)') 'pFe_snow', trim(nchar)
    1568             :             call define_hist_field(n_Fepsnow (n,:),vname_in,"umol/m^2",tstr2D, tcstr, &
    1569             :              "Snow pFe",                     &   ! LCOV_EXCL_LINE
    1570             :              "weighted by ice area ", c1, c0,       &   ! LCOV_EXCL_LINE
    1571           0 :              ns, f_Fepsnow )
    1572             :           enddo
    1573             :         endif !f_Fepsnow
    1574           0 :         if (f_Nitsnow(1:1) /= 'x') &
    1575             :           call define_hist_field(n_Nitsnow,"Nit_snow","mmol/m^2",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1576             :              "Snow Nitrate",                     &   ! LCOV_EXCL_LINE
    1577             :              "weighted by ice area", c1, c0,       &   ! LCOV_EXCL_LINE
    1578           0 :              ns, f_Nitsnow)
    1579           0 :         if (f_Amsnow(1:1) /= 'x') &
    1580             :           call define_hist_field(n_Amsnow,"Am_snow","mmol/m^2",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1581             :              "Snow Ammonium",                     &   ! LCOV_EXCL_LINE
    1582             :              "weighted by ice area", c1, c0,       &   ! LCOV_EXCL_LINE
    1583           0 :              ns, f_Amsnow)
    1584           0 :         if (f_Silsnow(1:1) /= 'x') &
    1585             :           call define_hist_field(n_Silsnow,"Sil_snow","mmol/m^2",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1586             :              "Snow Silicate",                     &   ! LCOV_EXCL_LINE
    1587             :              "weighted by ice area", c1, c0,       &   ! LCOV_EXCL_LINE
    1588           0 :              ns, f_Silsnow)
    1589           0 :         if (f_humsnow(1:1) /= 'x') &
    1590             :           call define_hist_field(n_humsnow,"hum_snow","mmol/m^2",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1591             :              "Snow humic material (carbon)",               &   ! LCOV_EXCL_LINE
    1592             :              "weighted by ice area", c1, c0,       &   ! LCOV_EXCL_LINE
    1593           0 :              ns, f_humsnow)
    1594           0 :         if (f_DMSPpsnow(1:1) /= 'x') &
    1595             :           call define_hist_field(n_DMSPpsnow,"DMSPp_snow","mmol/m^2",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1596             :              "Snow DMSPp",                     &   ! LCOV_EXCL_LINE
    1597             :              "weighted by ice area", c1, c0,       &   ! LCOV_EXCL_LINE
    1598           0 :              ns, f_DMSPpsnow)
    1599           0 :         if (f_DMSPdsnow(1:1) /= 'x') &
    1600             :           call define_hist_field(n_DMSPdsnow,"DMSPd_snow","mmol/m^2",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1601             :              "Snow DMSPd",                     &   ! LCOV_EXCL_LINE
    1602             :              "weighted by ice area", c1, c0,       &   ! LCOV_EXCL_LINE
    1603           0 :              ns, f_DMSPdsnow)
    1604           0 :         if (f_DMSsnow(1:1) /= 'x') &
    1605             :           call define_hist_field(n_DMSsnow,"DMS_snow","mmol/m^2",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1606             :              "Snow DMS",                     &   ! LCOV_EXCL_LINE
    1607             :              "weighted by ice area", c1, c0,       &   ! LCOV_EXCL_LINE
    1608           0 :              ns, f_DMSsnow)
    1609           0 :         if (f_PONsnow(1:1) /= 'x') &
    1610             :           call define_hist_field(n_PONsnow,"PON_snow","mmol/m^2",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1611             :              "Snow Nitrate if no reactions",                     &   ! LCOV_EXCL_LINE
    1612             :              "weighted by ice area", c1, c0,       &   ! LCOV_EXCL_LINE
    1613           0 :              ns, f_PONsnow)
    1614             : 
    1615           0 :         if (f_zaerofrac(1:1) /= 'x')  then
    1616           0 :           do n = 1, n_zaero
    1617           0 :             write(nchar,'(i3.3)') n
    1618           0 :             write(vname_in,'(a,a)') 'zaero_frac', trim(nchar)
    1619             :              call define_hist_field(n_zaerofrac(n,:),vname_in,"1",tstr2D, tcstr, &
    1620             :              "Mobile frac z aerosol",                     &   ! LCOV_EXCL_LINE
    1621             :              "averaged over depth ", c1, c0,       &   ! LCOV_EXCL_LINE
    1622           0 :              ns, f_zaerofrac)
    1623             :           enddo
    1624             :         endif  !f_chlnet
    1625           0 :         if (f_chlfrac(1:1) /= 'x')  then
    1626           0 :           do n = 1, n_algae
    1627           0 :             write(nchar,'(i3.3)') n
    1628           0 :             write(vname_in,'(a,a)') 'chl_frac', trim(nchar)
    1629             :              call define_hist_field(n_chlfrac(n,:),vname_in,"mg chl/m^2",tstr2D, tcstr, &
    1630             :              "Mobile frac chlorophyll",                     &   ! LCOV_EXCL_LINE
    1631             :              "averaged over depth ", c1, c0,       &   ! LCOV_EXCL_LINE
    1632           0 :              ns, f_chlfrac)
    1633             :           enddo
    1634             :         endif  !f_chlnet
    1635           0 :         if (f_Nfrac(1:1) /= 'x') then
    1636           0 :           do n = 1, n_algae
    1637           0 :             write(nchar,'(i3.3)') n
    1638           0 :             write(vname_in,'(a,a)') 'algalN_frac', trim(nchar)
    1639             :             call define_hist_field(n_Nfrac(n,:),vname_in,"1",tstr2D, tcstr, &
    1640             :              "Mobile frac algal nitrogen",                     &   ! LCOV_EXCL_LINE
    1641             :              "averaged over depth ", c1, c0,       &   ! LCOV_EXCL_LINE
    1642           0 :              ns, f_Nfrac)
    1643             :           enddo
    1644             :         endif !f_Nfrac
    1645           0 :         if (f_DOCfrac(1:1) /= 'x') then
    1646           0 :           do n = 1, n_doc
    1647           0 :             write(nchar,'(i3.3)') n
    1648           0 :             write(vname_in,'(a,a)') 'DOC_frac', trim(nchar)
    1649             :             call define_hist_field(n_DOCfrac(n,:),vname_in,"1",tstr2D, tcstr, &
    1650             :              "Mobile frac DOC",                     &   ! LCOV_EXCL_LINE
    1651             :              "averaged over depth ", c1, c0,       &   ! LCOV_EXCL_LINE
    1652           0 :              ns, f_DOCfrac)
    1653             :           enddo
    1654             :         endif !f_DOCfrac
    1655           0 :         if (f_DICfrac(1:1) /= 'x') then
    1656           0 :           do n = 1, n_dic
    1657           0 :             write(nchar,'(i3.3)') n
    1658           0 :             write(vname_in,'(a,a)') 'DIC_frac', trim(nchar)
    1659             :             call define_hist_field(n_DICfrac(n,:),vname_in,"1",tstr2D, tcstr, &
    1660             :              "Mobile frac DIC",                     &   ! LCOV_EXCL_LINE
    1661             :              "averaged over depth ", c1, c0,       &   ! LCOV_EXCL_LINE
    1662           0 :              ns, f_DICfrac)
    1663             :           enddo
    1664             :         endif !f_DICfrac
    1665           0 :         if (f_DONfrac(1:1) /= 'x') then
    1666           0 :           do n = 1, n_don
    1667           0 :             write(nchar,'(i3.3)') n
    1668           0 :             write(vname_in,'(a,a)') 'DON_frac', trim(nchar)
    1669             :             call define_hist_field(n_DONfrac(n,:),vname_in,"1",tstr2D, tcstr, &
    1670             :              "Mobile frac DON",                     &   ! LCOV_EXCL_LINE
    1671             :              "averaged over depth ", c1, c0,       &   ! LCOV_EXCL_LINE
    1672           0 :              ns, f_DONfrac)
    1673             :          enddo
    1674             :         endif !f_DONfrac
    1675           0 :         if (f_Fedfrac (1:1) /= 'x') then
    1676           0 :           do n = 1, n_fed
    1677           0 :             write(nchar,'(i3.3)') n
    1678           0 :             write(vname_in,'(a,a)') 'dFe_frac', trim(nchar)
    1679             :             call define_hist_field(n_Fedfrac (n,:),vname_in,"1",tstr2D, tcstr, &
    1680             :              "Mobile frac dFe",                     &   ! LCOV_EXCL_LINE
    1681             :              "averaged over depth ", c1, c0,       &   ! LCOV_EXCL_LINE
    1682           0 :              ns, f_Fedfrac )
    1683             :           enddo
    1684             :         endif !f_Fedfrac
    1685           0 :         if (f_Fepfrac (1:1) /= 'x') then
    1686           0 :           do n = 1, n_fep
    1687           0 :             write(nchar,'(i3.3)') n
    1688           0 :             write(vname_in,'(a,a)') 'pFe_frac', trim(nchar)
    1689             :             call define_hist_field(n_Fepfrac (n,:),vname_in,"1",tstr2D, tcstr, &
    1690             :              "Mobile frac pFe",                     &   ! LCOV_EXCL_LINE
    1691             :              "averaged over depth ", c1, c0,       &   ! LCOV_EXCL_LINE
    1692           0 :              ns, f_Fepfrac )
    1693             :           enddo
    1694             :         endif !f_Fepfrac
    1695           0 :         if (f_Nitfrac(1:1) /= 'x') &
    1696             :           call define_hist_field(n_Nitfrac,"Nit_frac","1",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1697             :              "Mobile frac Nitrate",                     &   ! LCOV_EXCL_LINE
    1698             :              "averaged over depth", c1, c0,       &   ! LCOV_EXCL_LINE
    1699           0 :              ns, f_Nitfrac)
    1700           0 :         if (f_Amfrac(1:1) /= 'x') &
    1701             :           call define_hist_field(n_Amfrac,"Am_frac","1",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1702             :              "Mobile frac Ammonium",                     &   ! LCOV_EXCL_LINE
    1703             :              "averaged over depth", c1, c0,       &   ! LCOV_EXCL_LINE
    1704           0 :              ns, f_Amfrac)
    1705           0 :         if (f_Silfrac(1:1) /= 'x') &
    1706             :           call define_hist_field(n_Silfrac,"Sil_frac","1",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1707             :              "Mobile frac Silicate",                     &   ! LCOV_EXCL_LINE
    1708             :              "averaged over depth", c1, c0,       &   ! LCOV_EXCL_LINE
    1709           0 :              ns, f_Silfrac)
    1710           0 :         if (f_humfrac(1:1) /= 'x') &
    1711             :           call define_hist_field(n_humfrac,"hum_frac","1",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1712             :              "Mobile frac humic material",               &   ! LCOV_EXCL_LINE
    1713             :              "averaged over depth", c1, c0,       &   ! LCOV_EXCL_LINE
    1714           0 :              ns, f_humfrac)
    1715           0 :         if (f_DMSPpfrac(1:1) /= 'x') &
    1716             :           call define_hist_field(n_DMSPpfrac,"DMSPp_frac","1",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1717             :              "Mobile frac DMSPp",                     &   ! LCOV_EXCL_LINE
    1718             :              "averaged over depth", c1, c0,       &   ! LCOV_EXCL_LINE
    1719           0 :              ns, f_DMSPpfrac)
    1720           0 :         if (f_DMSPdfrac(1:1) /= 'x') &
    1721             :           call define_hist_field(n_DMSPdfrac,"DMSPd_frac","1",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1722             :              "Mobile frac DMSPd",                     &   ! LCOV_EXCL_LINE
    1723             :              "averaged over depth", c1, c0,       &   ! LCOV_EXCL_LINE
    1724           0 :              ns, f_DMSPdfrac)
    1725           0 :         if (f_DMSfrac(1:1) /= 'x') &
    1726             :           call define_hist_field(n_DMSfrac,"DMS_frac","1",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1727             :              "Mobile frac DMS",                     &   ! LCOV_EXCL_LINE
    1728             :              "averaged over depth", c1, c0,       &   ! LCOV_EXCL_LINE
    1729           0 :              ns, f_DMSfrac)
    1730           0 :         if (f_PONfrac(1:1) /= 'x') &
    1731             :           call define_hist_field(n_PONfrac,"PON_frac","1",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1732             :              "Mobile frac Nitrate if no reactions",                     &   ! LCOV_EXCL_LINE
    1733             :              "averaged over depth", c1, c0,       &   ! LCOV_EXCL_LINE
    1734           0 :              ns, f_PONfrac)
    1735             : 
    1736             :       endif ! z_tracers
    1737             : 
    1738             :       ! brine
    1739           0 :       if (f_hbri(1:1) /= 'x') &
    1740             :          call define_hist_field(n_hbri,"hbrine","m",tstr2D, tcstr, &   ! LCOV_EXCL_LINE
    1741             :              "Brine height",                     &   ! LCOV_EXCL_LINE
    1742             :              "distance from ice bottom to brine surface", c1, c0,       &   ! LCOV_EXCL_LINE
    1743           0 :              ns, f_hbri)
    1744             : 
    1745             :        endif ! histfreq(ns) /= 'x'
    1746             :      enddo ! nstreams
    1747             : 
    1748             :      endif ! tr_aero, etc
    1749             : 
    1750          37 :       end subroutine init_hist_bgc_2D
    1751             : 
    1752             : !=======================================================================
    1753             : 
    1754          37 :       subroutine init_hist_bgc_3Dc
    1755             : 
    1756             :       use ice_calendar, only: nstreams, histfreq
    1757             :       use ice_history_shared, only: tstr3Dc, tcstr, define_hist_field
    1758             : 
    1759             :       integer (kind=int_kind) :: ns
    1760             :       logical (kind=log_kind) :: tr_brine
    1761             :       character(len=*), parameter :: subname = '(init_hist_bgc_3Dc)'
    1762             : 
    1763          37 :       call icepack_query_tracer_flags(tr_brine_out=tr_brine)
    1764          37 :       call icepack_warnings_flush(nu_diag)
    1765          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
    1766           0 :          file=__FILE__, line=__LINE__)
    1767             : 
    1768          37 :       if (tr_brine) then
    1769             : 
    1770             :       ! 3D (category) variables must be looped separately
    1771           0 :       do ns = 1, nstreams
    1772           0 :          if (histfreq(ns) /= 'x') then
    1773           0 :            if (f_fbri(1:1) /= 'x') &
    1774             :            call define_hist_field(n_fbri,"fbrine","1",tstr3Dc, tcstr, &   ! LCOV_EXCL_LINE
    1775             :              "brine tracer fraction of ice volume, cat",             &   ! LCOV_EXCL_LINE
    1776           0 :              "none", c1, c0, ns, f_fbri)
    1777             :          endif ! histfreq /= 'x'
    1778             :       enddo ! ns
    1779             : 
    1780             :       endif ! tr_brine
    1781             : 
    1782          37 :       end subroutine init_hist_bgc_3Dc
    1783             : 
    1784             : !=======================================================================
    1785             : 
    1786          37 :       subroutine init_hist_bgc_3Db
    1787             : 
    1788             :       use ice_calendar, only: nstreams,histfreq
    1789             :       use ice_history_shared, only: tstr3Db, tcstr, define_hist_field
    1790             : 
    1791             :       integer (kind=int_kind) :: ns
    1792           8 :       real (kind=dbl_kind) :: secday
    1793             :       logical (kind=log_kind) :: z_tracers
    1794             :       character(len=*), parameter :: subname = '(init_hist_bgc_3Db)'
    1795             : 
    1796             :       ! biology vertical grid
    1797             : 
    1798          37 :       call icepack_query_parameters(secday_out=secday)
    1799          37 :       call icepack_query_parameters(z_tracers_out=z_tracers)
    1800          37 :       call icepack_warnings_flush(nu_diag)
    1801          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
    1802           0 :          file=__FILE__, line=__LINE__)
    1803             : 
    1804          37 :      if (z_tracers) then
    1805             : 
    1806           0 :       do ns = 1, nstreams
    1807           0 :          if (histfreq(ns) /= 'x') then
    1808             : 
    1809           0 :          if (f_bTin(1:1) /= 'x') &
    1810             :             call define_hist_field(n_bTin,"bTizn","C",tstr3Db, tcstr, &   ! LCOV_EXCL_LINE
    1811             :                 "ice internal temperatures on bio grid", &   ! LCOV_EXCL_LINE
    1812             :                 "interpolated to bio grid", c1, c0,      &   ! LCOV_EXCL_LINE
    1813           0 :                 ns, f_bTin)
    1814             : 
    1815           0 :          if (f_bphi(1:1) /= 'x') &
    1816             :             call define_hist_field(n_bphi,"bphizn","%",tstr3Db, tcstr, &   ! LCOV_EXCL_LINE
    1817             :                 "porosity", "brine volume fraction", c100, c0, &   ! LCOV_EXCL_LINE
    1818           0 :                 ns, f_bphi)
    1819             : 
    1820           0 :          if (f_iDi(1:1) /= 'x') &
    1821             :              call define_hist_field(n_iDi,"iDin","m^2/d",tstr3Db, tcstr, &   ! LCOV_EXCL_LINE
    1822             :                 "interface diffusivity", "on bio interface grid", secday, c0, &   ! LCOV_EXCL_LINE
    1823           0 :                 ns, f_iDi)
    1824             : 
    1825           0 :          if (f_iki(1:1) /= 'x') &
    1826             :             call define_hist_field(n_iki,"ikin","mm^2",tstr3Db, tcstr, &   ! LCOV_EXCL_LINE
    1827             :                 "permeability", "on bio interface grid", 1.0e6_dbl_kind, c0, &   ! LCOV_EXCL_LINE
    1828           0 :                 ns, f_iki)
    1829             : 
    1830           0 :          if (f_zfswin(1:1) /= 'x') &
    1831             :             call define_hist_field(n_zfswin,"zfswin","W/m^2",tstr3Db, tcstr, &   ! LCOV_EXCL_LINE
    1832             :                 "internal ice PAR", "on bio interface grid", c1, c0, &   ! LCOV_EXCL_LINE
    1833           0 :                 ns, f_zfswin)
    1834             : 
    1835             :          endif ! histfreq(ns) /= 'x'
    1836             :       enddo  ! ns
    1837             : 
    1838             :      endif  ! z_tracers
    1839             : 
    1840          37 :       end subroutine init_hist_bgc_3Db
    1841             : 
    1842             : !=======================================================================
    1843             : !
    1844             : ! write average ice quantities or snapshots
    1845             : 
    1846       23104 :       subroutine accum_hist_bgc (iblk)
    1847             : 
    1848             :       use ice_arrays_column, only: ocean_bio, &
    1849             :           grow_net, PP_net, upNO, upNH, ice_bio_net, snow_bio_net, &   ! LCOV_EXCL_LINE
    1850             :           hbri, bTiz, bphi, zfswin, iDi, iki, &   ! LCOV_EXCL_LINE
    1851             :           R_C2N, R_chl2N
    1852             :       use ice_blocks, only: block, get_block, nx_block, ny_block
    1853             :       use ice_domain, only: blocks_ice
    1854             :       use ice_domain_size, only: nblyr
    1855             :       use ice_flux, only: sss
    1856             :       use ice_flux_bgc, only: fiso_atm, fiso_ocn, faero_atm, faero_ocn, &
    1857             :           flux_bio, flux_bio_ai
    1858             :       use ice_history_shared, only: n2D, a2D, a3Dc, &
    1859             :           n3Dzcum, n3Dbcum, a3Db, a3Da, &   ! LCOV_EXCL_LINE
    1860             :           ncat_hist, accum_hist_field, nzblyr, nzalyr
    1861             :       use ice_state, only: trcrn, trcr, aicen, aice, vicen
    1862             : 
    1863             :       integer (kind=int_kind), intent(in) :: &
    1864             :            iblk                 ! block index
    1865             : 
    1866             :       ! local variables
    1867             : 
    1868             :       integer (kind=int_kind) :: &
    1869             :          i, j, n, k,        & ! loop indices   ! LCOV_EXCL_LINE
    1870             :          ilo,ihi,jlo,jhi      ! beginning and end of physical domain
    1871             : 
    1872             :       real (kind=dbl_kind), dimension (nx_block,ny_block,nblyr+4) :: &
    1873    50372896 :          workz, workz2
    1874             : 
    1875             :       real (kind=dbl_kind) :: &
    1876        5792 :          maxv, rhos, rhoi, rhow, puny, sk_l
    1877             : 
    1878             :       real (kind=dbl_kind), dimension (nblyr+1) :: &
    1879       52000 :          workv
    1880             : 
    1881             :       real (kind=dbl_kind), dimension (nx_block,ny_block) :: &
    1882    10101120 :          workni, worknj
    1883             : 
    1884             :       integer (kind=int_kind), dimension (1) :: &
    1885             :          worki
    1886             :       integer (kind=int_kind) :: &
    1887             :          workii
    1888             : 
    1889             :       logical (kind=log_kind) :: &
    1890             :          skl_bgc, z_tracers, tr_iso, tr_aero, tr_brine
    1891             : 
    1892             :       integer(kind=int_kind) :: &
    1893             :          nt_isosno,     nt_isoice,  nt_aero,    nt_fbri,      &   ! LCOV_EXCL_LINE
    1894             :          nt_bgc_Nit,    nt_bgc_Am,  nt_bgc_Sil, nt_bgc_DMSPp, &   ! LCOV_EXCL_LINE
    1895             :          nt_bgc_DMSPd,  nt_bgc_DMS, nt_bgc_PON,               &   ! LCOV_EXCL_LINE
    1896             :          nt_zbgc_frac,  nlt_chl_sw,                           &   ! LCOV_EXCL_LINE
    1897             :          nlt_bgc_Nit,   nlt_bgc_Am, nlt_bgc_Sil,              &   ! LCOV_EXCL_LINE
    1898             :          nlt_bgc_DMS,   nlt_bgc_PON,                          &   ! LCOV_EXCL_LINE
    1899             :          nlt_bgc_DMSPp, nlt_bgc_DMSPd,                        &   ! LCOV_EXCL_LINE
    1900             :          nt_bgc_hum,    nlt_bgc_hum
    1901             : 
    1902             :       integer (kind=int_kind), dimension(icepack_max_aero) :: &
    1903             :          nlt_zaero_sw       ! points to aerosol in trcrn_sw
    1904             : 
    1905             :       integer (kind=int_kind), dimension(icepack_max_algae) :: &
    1906             :          nt_bgc_N, nlt_bgc_N, &     ! algae   ! LCOV_EXCL_LINE
    1907             :          nt_bgc_C, nlt_bgc_C, &     !   ! LCOV_EXCL_LINE
    1908             :          nt_bgc_chl, nlt_bgc_chl    !
    1909             : 
    1910             :       integer (kind=int_kind), dimension(icepack_max_doc) :: &
    1911             :          nt_bgc_DOC, nlt_bgc_DOC    ! disolved organic carbon
    1912             : 
    1913             :       integer (kind=int_kind), dimension(icepack_max_don) :: &
    1914             :          nt_bgc_DON, nlt_bgc_DON    !
    1915             : 
    1916             :       integer (kind=int_kind), dimension(icepack_max_dic) :: &
    1917             :          nt_bgc_DIC, nlt_bgc_DIC    ! disolved inorganic carbon
    1918             : 
    1919             :       integer (kind=int_kind), dimension(icepack_max_fe) :: &
    1920             :          nt_bgc_Fed, nlt_bgc_Fed, & !   ! LCOV_EXCL_LINE
    1921             :          nt_bgc_Fep, nlt_bgc_Fep    !
    1922             : 
    1923             :       integer (kind=int_kind), dimension(icepack_max_aero) :: &
    1924             :          nt_zaero, nlt_zaero        ! non-reacting layer aerosols
    1925             : 
    1926             :       type (block) :: &
    1927             :          this_block           ! block information for current block
    1928             : 
    1929             :       character(len=*), parameter :: subname = '(accum_hist_bgc)'
    1930             : 
    1931             :       call icepack_query_parameters(rhos_out=rhos, rhoi_out=rhoi, &
    1932       23104 :          rhow_out=rhow, puny_out=puny, sk_l_out=sk_l)
    1933             :       call icepack_query_tracer_flags(tr_iso_out=tr_iso, &
    1934       23104 :          tr_aero_out=tr_aero, tr_brine_out=tr_brine)
    1935             :       call icepack_query_parameters(skl_bgc_out=skl_bgc, &
    1936       23104 :          z_tracers_out=z_tracers)
    1937             :       call icepack_query_tracer_indices( &
    1938             :          nt_isosno_out=nt_isosno, nt_isoice_out=nt_isoice, &   ! LCOV_EXCL_LINE
    1939             :          nt_aero_out=nt_aero, &   ! LCOV_EXCL_LINE
    1940             :          nt_fbri_out=nt_fbri, nt_bgc_DOC_out=nt_bgc_DOC, &   ! LCOV_EXCL_LINE
    1941             :          nt_zaero_out=nt_zaero, nt_bgc_DIC_out=nt_bgc_DIC, &   ! LCOV_EXCL_LINE
    1942             :          nt_bgc_DON_out=nt_bgc_DON, nt_bgc_N_out=nt_bgc_N, &   ! LCOV_EXCL_LINE
    1943             :          nt_bgc_C_out=nt_bgc_C, nt_bgc_Am_out=nt_bgc_Am, &   ! LCOV_EXCL_LINE
    1944             :          nt_bgc_chl_out=nt_bgc_chl, nt_bgc_Nit_out=nt_bgc_Nit, &   ! LCOV_EXCL_LINE
    1945             :          nt_bgc_Sil_out=nt_bgc_Sil, nt_bgc_DMSPp_out=nt_bgc_DMSPp, &   ! LCOV_EXCL_LINE
    1946             :          nt_bgc_DMSPd_out=nt_bgc_DMSPd, nt_bgc_DMS_out=nt_bgc_DMS, &   ! LCOV_EXCL_LINE
    1947             :          nt_bgc_PON_out=nt_bgc_PON, &   ! LCOV_EXCL_LINE
    1948             :          nt_bgc_Fed_out=nt_bgc_Fed, &   ! LCOV_EXCL_LINE
    1949             :          nt_bgc_Fep_out=nt_bgc_Fep, nt_zbgc_frac_out=nt_zbgc_frac, &   ! LCOV_EXCL_LINE
    1950             :          nlt_zaero_sw_out=nlt_zaero_sw, nlt_chl_sw_out=nlt_chl_sw, &   ! LCOV_EXCL_LINE
    1951             :          nlt_bgc_Nit_out=nlt_bgc_Nit,   nlt_bgc_Am_out=nlt_bgc_Am,   &   ! LCOV_EXCL_LINE
    1952             :          nlt_bgc_Sil_out=nlt_bgc_Sil,   &   ! LCOV_EXCL_LINE
    1953             :          nlt_bgc_DMS_out=nlt_bgc_DMS,   nlt_bgc_PON_out=nlt_bgc_PON,  &   ! LCOV_EXCL_LINE
    1954             :          nlt_bgc_N_out=nlt_bgc_N,     nlt_bgc_C_out=nlt_bgc_C,    &   ! LCOV_EXCL_LINE
    1955             :          nlt_bgc_chl_out=nlt_bgc_chl, nlt_bgc_DIC_out=nlt_bgc_DIC,   &   ! LCOV_EXCL_LINE
    1956             :          nlt_bgc_DOC_out=nlt_bgc_DOC,   nlt_bgc_DON_out=nlt_bgc_DON,  &   ! LCOV_EXCL_LINE
    1957             :          nlt_zaero_out=nlt_zaero,   nlt_bgc_DMSPp_out=nlt_bgc_DMSPp, &   ! LCOV_EXCL_LINE
    1958             :          nlt_bgc_DMSPd_out=nlt_bgc_DMSPd, &   ! LCOV_EXCL_LINE
    1959             :          nlt_bgc_Fed_out=nlt_bgc_Fed,   nlt_bgc_Fep_out=nlt_bgc_Fep,  &   ! LCOV_EXCL_LINE
    1960       23104 :          nt_bgc_hum_out=nt_bgc_hum,    nlt_bgc_hum_out=nlt_bgc_hum)
    1961       23104 :       call icepack_warnings_flush(nu_diag)
    1962       23104 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
    1963           0 :          file=__FILE__, line=__LINE__)
    1964             : 
    1965       23104 :       this_block = get_block(blocks_ice(iblk),iblk)
    1966       23104 :       ilo = this_block%ilo
    1967       23104 :       ihi = this_block%ihi
    1968       23104 :       jlo = this_block%jlo
    1969       23104 :       jhi = this_block%jhi
    1970             : 
    1971             :       !---------------------------------------------------------------
    1972             :       ! increment field
    1973             :       !---------------------------------------------------------------
    1974             : 
    1975             :      ! 2d bgc fields
    1976       23104 :      if (allocated(a2D)) then
    1977             : 
    1978       23104 :      if (tr_iso .or. tr_aero .or. tr_brine .or. skl_bgc) then
    1979             : 
    1980             :       ! isotopes
    1981           0 :       if (f_fiso_atm(1:1) /= 'x') then
    1982           0 :          do n=1,n_iso
    1983             :             call accum_hist_field(n_fiso_atm(n,:),iblk, &
    1984           0 :                                     fiso_atm(:,:,n,iblk), a2D)
    1985             :          enddo
    1986             :       endif
    1987           0 :       if (f_fiso_ocn(1:1) /= 'x') then
    1988           0 :          do n=1,n_iso
    1989             :             call accum_hist_field(n_fiso_ocn(n,:),iblk, &
    1990           0 :                                     fiso_ocn(:,:,n,iblk), a2D)
    1991             :          enddo
    1992             :       endif
    1993           0 :       if (f_iso(1:1) /= 'x') then
    1994           0 :          do n=1,n_iso
    1995             :             call accum_hist_field(n_isosno(n,:), iblk, &
    1996           0 :                                trcr(:,:,nt_isosno+n-1,iblk)/rhos, a2D)
    1997             :             call accum_hist_field(n_isoice(n,:), iblk, &
    1998           0 :                                trcr(:,:,nt_isoice+n-1,iblk)/rhos, a2D)
    1999             :          enddo
    2000             :       endif
    2001             : 
    2002             :       ! Aerosols
    2003           0 :       if (f_faero_atm(1:1) /= 'x') then
    2004           0 :          do n=1,n_aero
    2005             :             call accum_hist_field(n_faero_atm(n,:),iblk, &
    2006           0 :                                     faero_atm(:,:,n,iblk), a2D)
    2007             :          enddo
    2008             :       endif
    2009           0 :       if (f_faero_ocn(1:1) /= 'x') then
    2010           0 :          do n=1,n_aero
    2011             :             call accum_hist_field(n_faero_ocn(n,:),iblk, &
    2012           0 :                                     faero_ocn(:,:,n,iblk), a2D)
    2013             :          enddo
    2014             :       endif
    2015           0 :       if (f_aero(1:1) /= 'x') then
    2016           0 :          do n=1,n_aero
    2017             :             call accum_hist_field(n_aerosn1(n,:), iblk, &
    2018           0 :                                trcr(:,:,nt_aero  +4*(n-1),iblk)/rhos, a2D)
    2019             :             call accum_hist_field(n_aerosn2(n,:), iblk, &
    2020           0 :                                trcr(:,:,nt_aero+1+4*(n-1),iblk)/rhos, a2D)
    2021             :             call accum_hist_field(n_aeroic1(n,:), iblk, &
    2022           0 :                                trcr(:,:,nt_aero+2+4*(n-1),iblk)/rhoi, a2D)
    2023             :             call accum_hist_field(n_aeroic2(n,:), iblk, &
    2024           0 :                                trcr(:,:,nt_aero+3+4*(n-1),iblk)/rhoi, a2D)
    2025             :          enddo
    2026             :       endif
    2027             : 
    2028           0 :      if (skl_bgc) then
    2029             : 
    2030             :       ! skeletal layer bgc
    2031             : 
    2032           0 :       if (f_bgc_N(1:1)/= 'x') then
    2033           0 :          do n=1,n_algae
    2034             :             call accum_hist_field(n_bgc_N(n,:), iblk, &
    2035           0 :                     sk_l*trcr(:,:,nt_bgc_N(n),   iblk), a2D)
    2036             :          enddo
    2037             :       endif
    2038           0 :       if (f_bgc_C(1:1)/= 'x') then
    2039           0 :          do n=1,n_algae
    2040             :             call accum_hist_field(n_bgc_C(n,:),        iblk, &
    2041           0 :                     sk_l*R_C2N(n)*trcr(:,:,nt_bgc_N(n), iblk), a2D)
    2042             :          enddo
    2043             :       endif
    2044           0 :       if (f_bgc_DOC(1:1)/= 'x') then
    2045           0 :          do n=1,n_doc
    2046             :             call accum_hist_field(n_bgc_DOC(n,:), iblk, &
    2047           0 :                     sk_l*trcr(:,:,nt_bgc_DOC(n),   iblk), a2D)
    2048             :          enddo
    2049             :       endif
    2050           0 :       if (f_bgc_DIC(1:1)/= 'x') then
    2051           0 :          do n=1,n_dic
    2052             :             call accum_hist_field(n_bgc_DIC(n,:), iblk, &
    2053           0 :                     sk_l*trcr(:,:,nt_bgc_DIC(n),   iblk), a2D)
    2054             :          enddo
    2055             :       endif
    2056           0 :       if (f_bgc_DON(1:1)/= 'x') then
    2057           0 :          do n=1,n_don
    2058             :             call accum_hist_field(n_bgc_DON(n,:), iblk, &
    2059           0 :                     sk_l*trcr(:,:,nt_bgc_DON(n),   iblk), a2D)
    2060             :          enddo
    2061             :       endif
    2062           0 :       if (f_bgc_Fed (1:1)/= 'x') then
    2063           0 :          do n=1,n_fed
    2064             :             call accum_hist_field(n_bgc_Fed (n,:), iblk, &
    2065           0 :                     sk_l*trcr(:,:,nt_bgc_Fed (n),   iblk), a2D)
    2066             :          enddo
    2067             :       endif
    2068           0 :       if (f_bgc_Fep (1:1)/= 'x') then
    2069           0 :          do n=1,n_fep
    2070             :             call accum_hist_field(n_bgc_Fep (n,:), iblk, &
    2071           0 :                     sk_l*trcr(:,:,nt_bgc_Fep (n),   iblk), a2D)
    2072             :          enddo
    2073             :       endif
    2074           0 :       if (f_bgc_chl(1:1)/= 'x') then
    2075           0 :          do n=1,n_algae
    2076             :             call accum_hist_field(n_bgc_chl(n,:), iblk, &
    2077           0 :                     sk_l*trcr(:,:,nt_bgc_chl(n),   iblk), a2D)
    2078             :          enddo
    2079             :       endif
    2080           0 :       if (f_bgc_Nit(1:1)/= 'x') &
    2081             :          call accum_hist_field(n_bgc_Nit,  iblk, &   ! LCOV_EXCL_LINE
    2082           0 :                 sk_l*trcr(:,:,nt_bgc_Nit,  iblk), a2D)
    2083           0 :       if (f_bgc_Am(1:1)/= 'x') &
    2084             :          call accum_hist_field(n_bgc_Am,   iblk, &   ! LCOV_EXCL_LINE
    2085           0 :                 sk_l*trcr(:,:,nt_bgc_Am,   iblk), a2D)
    2086           0 :       if (f_bgc_Sil(1:1)/= 'x') &
    2087             :          call accum_hist_field(n_bgc_Sil,  iblk, &   ! LCOV_EXCL_LINE
    2088           0 :                 sk_l*trcr(:,:,nt_bgc_Sil,  iblk), a2D)
    2089           0 :       if (f_bgc_hum(1:1)/= 'x') &
    2090             :          call accum_hist_field(n_bgc_hum,  iblk, &   ! LCOV_EXCL_LINE
    2091           0 :                 sk_l*trcr(:,:,nt_bgc_hum,  iblk), a2D)
    2092           0 :       if (f_bgc_PON(1:1)/= 'x') &
    2093             :          call accum_hist_field(n_bgc_PON,  iblk, &   ! LCOV_EXCL_LINE
    2094           0 :                 sk_l*trcr(:,:,nt_bgc_PON,  iblk), a2D)
    2095           0 :       if (f_bgc_DMSPp(1:1)/= 'x') &
    2096             :          call accum_hist_field(n_bgc_DMSPp,iblk, &   ! LCOV_EXCL_LINE
    2097           0 :                 sk_l*trcr(:,:,nt_bgc_DMSPp,iblk), a2D)
    2098           0 :       if (f_bgc_DMSPd(1:1)/= 'x') &
    2099             :          call accum_hist_field(n_bgc_DMSPd,iblk, &   ! LCOV_EXCL_LINE
    2100           0 :                 sk_l*trcr(:,:,nt_bgc_DMSPd,iblk), a2D)
    2101           0 :       if (f_bgc_DMS(1:1)/= 'x') &
    2102             :          call accum_hist_field(n_bgc_DMS,  iblk, &   ! LCOV_EXCL_LINE
    2103           0 :                 sk_l*trcr(:,:,nt_bgc_DMS,  iblk), a2D)
    2104             : 
    2105             :      endif  !skl_bgc
    2106             : 
    2107             :       ! skeletal layer and vertical bgc
    2108             : 
    2109           0 :       if (f_bgc_DOC_ml(1:1)/= 'x') then
    2110           0 :          do n=1,n_doc
    2111             :             call accum_hist_field(n_bgc_DOC_ml(n,:), iblk, &
    2112           0 :                    ocean_bio(:,:,nlt_bgc_DOC(n),      iblk), a2D)
    2113             :          enddo
    2114             :       endif
    2115           0 :       if (f_bgc_DIC_ml(1:1)/= 'x') then
    2116           0 :          do n=1,n_dic
    2117             :             call accum_hist_field(n_bgc_DIC_ml(n,:), iblk, &
    2118           0 :                    ocean_bio(:,:,nlt_bgc_DIC(n),      iblk), a2D)
    2119             :          enddo
    2120             :       endif
    2121           0 :       if (f_bgc_DON_ml(1:1)/= 'x') then
    2122           0 :          do n=1,n_don
    2123             :             call accum_hist_field(n_bgc_DON_ml(n,:), iblk, &
    2124           0 :                    ocean_bio(:,:,nlt_bgc_DON(n),      iblk), a2D)
    2125             :          enddo
    2126             :       endif
    2127           0 :       if (f_bgc_Fed_ml (1:1)/= 'x') then
    2128           0 :          do n=1,n_fed
    2129             :             call accum_hist_field(n_bgc_Fed_ml (n,:), iblk, &
    2130           0 :                    ocean_bio(:,:,nlt_bgc_Fed (n),      iblk), a2D)
    2131             :          enddo
    2132             :       endif
    2133           0 :       if (f_bgc_Fep_ml (1:1)/= 'x') then
    2134           0 :          do n=1,n_fep
    2135             :             call accum_hist_field(n_bgc_Fep_ml (n,:), iblk, &
    2136           0 :                    ocean_bio(:,:,nlt_bgc_Fep (n),      iblk), a2D)
    2137             :          enddo
    2138             :       endif
    2139           0 :       if (f_bgc_N_ml(1:1)/= 'x') then
    2140           0 :          do n=1,n_algae
    2141             :             call accum_hist_field(n_bgc_N_ml(n,:), iblk, &
    2142           0 :                    ocean_bio(:,:,nlt_bgc_N(n),      iblk), a2D)
    2143             :          enddo
    2144             :       endif
    2145           0 :       if (f_bgc_Nit_ml(1:1)/= 'x') &
    2146             :          call accum_hist_field(n_bgc_Nit_ml,  iblk, &   ! LCOV_EXCL_LINE
    2147           0 :                ocean_bio(:,:,nlt_bgc_Nit,     iblk), a2D)
    2148           0 :       if (f_bgc_Am_ml(1:1)/= 'x') &
    2149             :          call accum_hist_field(n_bgc_Am_ml,   iblk, &   ! LCOV_EXCL_LINE
    2150           0 :                ocean_bio(:,:,nlt_bgc_Am,      iblk), a2D)
    2151           0 :       if (f_bgc_Sil_ml(1:1)/= 'x') &
    2152             :          call accum_hist_field(n_bgc_Sil_ml,  iblk, &   ! LCOV_EXCL_LINE
    2153           0 :                ocean_bio(:,:,nlt_bgc_Sil,     iblk), a2D)
    2154           0 :       if (f_bgc_hum_ml(1:1)/= 'x') &
    2155             :          call accum_hist_field(n_bgc_hum_ml,  iblk, &   ! LCOV_EXCL_LINE
    2156           0 :                ocean_bio(:,:,nlt_bgc_hum,     iblk), a2D)
    2157           0 :       if (f_bgc_DMSP_ml(1:1)/= 'x') &
    2158             :          call accum_hist_field(n_bgc_DMSP_ml, iblk, &   ! LCOV_EXCL_LINE
    2159           0 :                ocean_bio(:,:,nlt_bgc_DMSPd,   iblk), a2D)
    2160           0 :       if (f_bgc_DMS_ml(1:1)/= 'x') &
    2161             :          call accum_hist_field(n_bgc_DMS_ml,  iblk, &   ! LCOV_EXCL_LINE
    2162           0 :                ocean_bio(:,:,nlt_bgc_DMS,     iblk), a2D)
    2163             : 
    2164           0 :       if (f_fNit  (1:1) /= 'x') &
    2165             :          call accum_hist_field(n_fNit,     iblk, &   ! LCOV_EXCL_LINE
    2166           0 :                   flux_bio(:,:,nlt_bgc_Nit,iblk), a2D)
    2167           0 :       if (f_fNit_ai(1:1)/= 'x') &
    2168             :          call accum_hist_field(n_fNit_ai,  iblk, &   ! LCOV_EXCL_LINE
    2169           0 :                flux_bio_ai(:,:,nlt_bgc_Nit,iblk), a2D)
    2170             : 
    2171           0 :       if (f_fAm  (1:1) /= 'x') &
    2172             :          call accum_hist_field(n_fAm,     iblk, &   ! LCOV_EXCL_LINE
    2173           0 :                   flux_bio(:,:,nlt_bgc_Am,iblk), a2D)
    2174           0 :       if (f_fAm_ai(1:1)/= 'x') &
    2175             :          call accum_hist_field(n_fAm_ai,  iblk, &   ! LCOV_EXCL_LINE
    2176           0 :                flux_bio_ai(:,:,nlt_bgc_Am,iblk), a2D)
    2177           0 :       if (f_fN(1:1)/= 'x') then
    2178           0 :          do n=1,n_algae
    2179             :             call accum_hist_field(n_fN(n,:),    iblk, &
    2180           0 :                   flux_bio(:,:,nlt_bgc_N(n),iblk), a2D)
    2181             :          enddo
    2182             :       endif
    2183           0 :       if (f_fN_ai(1:1)/= 'x') then
    2184           0 :          do n=1,n_algae
    2185             :             call accum_hist_field(n_fN_ai(n,:),    iblk, &
    2186           0 :                   flux_bio_ai(:,:,nlt_bgc_N(n),iblk), a2D)
    2187             :          enddo
    2188             :       endif
    2189           0 :       if (f_fDOC(1:1)/= 'x') then
    2190           0 :          do n=1,n_doc
    2191             :             call accum_hist_field(n_fDOC(n,:),    iblk, &
    2192           0 :                   flux_bio(:,:,nlt_bgc_DOC(n),iblk), a2D)
    2193             :          enddo
    2194             :       endif
    2195           0 :       if (f_fDOC_ai(1:1)/= 'x') then
    2196           0 :          do n=1,n_doc
    2197             :             call accum_hist_field(n_fDOC_ai(n,:),    iblk, &
    2198           0 :                   flux_bio_ai(:,:,nlt_bgc_DOC(n),iblk), a2D)
    2199             :          enddo
    2200             :       endif
    2201           0 :       if (f_fDIC(1:1)/= 'x') then
    2202           0 :          do n=1,n_dic
    2203             :             call accum_hist_field(n_fDIC(n,:),    iblk, &
    2204           0 :                   flux_bio(:,:,nlt_bgc_DIC(n),iblk), a2D)
    2205             :          enddo
    2206             :       endif
    2207           0 :       if (f_fDIC_ai(1:1)/= 'x') then
    2208           0 :          do n=1,n_dic
    2209             :             call accum_hist_field(n_fDIC_ai(n,:),    iblk, &
    2210           0 :                   flux_bio_ai(:,:,nlt_bgc_DIC(n),iblk), a2D)
    2211             :          enddo
    2212             :       endif
    2213           0 :       if (f_fDON(1:1)/= 'x') then
    2214           0 :          do n=1,n_don
    2215             :             call accum_hist_field(n_fDON(n,:),    iblk, &
    2216           0 :                   flux_bio(:,:,nlt_bgc_DON(n),iblk), a2D)
    2217             :          enddo
    2218             :       endif
    2219           0 :       if (f_fDON_ai(1:1)/= 'x') then
    2220           0 :          do n=1,n_don
    2221             :             call accum_hist_field(n_fDON_ai(n,:),    iblk, &
    2222           0 :                   flux_bio_ai(:,:,nlt_bgc_DON(n),iblk), a2D)
    2223             :          enddo
    2224             :       endif
    2225           0 :       if (f_fFed (1:1)/= 'x') then
    2226           0 :          do n=1,n_fed
    2227             :             call accum_hist_field(n_fFed (n,:),    iblk, &
    2228           0 :                   flux_bio(:,:,nlt_bgc_Fed (n),iblk), a2D)
    2229             :          enddo
    2230             :       endif
    2231           0 :       if (f_fFed_ai (1:1)/= 'x') then
    2232           0 :          do n=1,n_fed
    2233             :             call accum_hist_field(n_fFed_ai (n,:),    iblk, &
    2234           0 :                   flux_bio_ai(:,:,nlt_bgc_Fed (n),iblk), a2D)
    2235             :          enddo
    2236             :       endif
    2237           0 :       if (f_fFep (1:1)/= 'x') then
    2238           0 :          do n=1,n_fep
    2239             :             call accum_hist_field(n_fFep (n,:),    iblk, &
    2240           0 :                   flux_bio(:,:,nlt_bgc_Fep (n),iblk), a2D)
    2241             :          enddo
    2242             :       endif
    2243           0 :       if (f_fFep_ai (1:1)/= 'x') then
    2244           0 :          do n=1,n_fep
    2245             :             call accum_hist_field(n_fFep_ai (n,:),    iblk, &
    2246           0 :                   flux_bio_ai(:,:,nlt_bgc_Fep (n),iblk), a2D)
    2247             :          enddo
    2248             :       endif
    2249           0 :       if (f_fSil  (1:1) /= 'x') &
    2250             :          call accum_hist_field(n_fSil,    iblk, &   ! LCOV_EXCL_LINE
    2251           0 :                  flux_bio(:,:,nlt_bgc_Sil,iblk), a2D)
    2252           0 :       if (f_fSil_ai(1:1)/= 'x') &
    2253             :          call accum_hist_field(n_fSil_ai, iblk, &   ! LCOV_EXCL_LINE
    2254           0 :               flux_bio_ai(:,:,nlt_bgc_Sil,iblk), a2D)
    2255           0 :       if (f_fhum  (1:1) /= 'x') &
    2256             :          call accum_hist_field(n_fhum,    iblk, &   ! LCOV_EXCL_LINE
    2257           0 :                  flux_bio(:,:,nlt_bgc_hum,iblk), a2D)
    2258           0 :       if (f_fhum_ai(1:1)/= 'x') &
    2259             :          call accum_hist_field(n_fhum_ai, iblk, &   ! LCOV_EXCL_LINE
    2260           0 :               flux_bio_ai(:,:,nlt_bgc_hum,iblk), a2D)
    2261           0 :       if (f_fPON  (1:1) /= 'x') &
    2262             :          call accum_hist_field(n_fPON,    iblk, &   ! LCOV_EXCL_LINE
    2263           0 :                  flux_bio(:,:,nlt_bgc_PON,iblk), a2D)
    2264           0 :       if (f_fPON_ai(1:1)/= 'x') &
    2265             :          call accum_hist_field(n_fPON_ai, iblk, &   ! LCOV_EXCL_LINE
    2266           0 :               flux_bio_ai(:,:,nlt_bgc_PON,iblk), a2D)
    2267           0 :       if (f_fDMS  (1:1) /= 'x') &
    2268             :          call accum_hist_field(n_fDMS,    iblk, &   ! LCOV_EXCL_LINE
    2269           0 :                  flux_bio(:,:,nlt_bgc_DMS,iblk), a2D)
    2270           0 :       if (f_fDMS_ai(1:1)/= 'x') &
    2271             :          call accum_hist_field(n_fDMS_ai, iblk, &   ! LCOV_EXCL_LINE
    2272           0 :               flux_bio_ai(:,:,nlt_bgc_DMS,iblk), a2D)
    2273           0 :       if (f_fDMSPd  (1:1) /= 'x') &
    2274             :          call accum_hist_field(n_fDMSPd,    iblk, &   ! LCOV_EXCL_LINE
    2275           0 :                  flux_bio(:,:,nlt_bgc_DMSPd,iblk), a2D)
    2276           0 :       if (f_fDMSPd_ai(1:1)/= 'x') &
    2277             :          call accum_hist_field(n_fDMSPd_ai, iblk, &   ! LCOV_EXCL_LINE
    2278           0 :               flux_bio_ai(:,:,nlt_bgc_DMSPd,iblk), a2D)
    2279           0 :       if (f_fDMSPp  (1:1) /= 'x') &
    2280             :          call accum_hist_field(n_fDMSPp,    iblk, &   ! LCOV_EXCL_LINE
    2281           0 :                  flux_bio(:,:,nlt_bgc_DMSPp,iblk), a2D)
    2282           0 :       if (f_fDMSPp_ai(1:1)/= 'x') &
    2283             :          call accum_hist_field(n_fDMSPp_ai, iblk, &   ! LCOV_EXCL_LINE
    2284           0 :               flux_bio_ai(:,:,nlt_bgc_DMSPp,iblk), a2D)
    2285           0 :       if (f_PPnet  (1:1) /= 'x') &
    2286             :          call accum_hist_field(n_PPnet,   iblk, &   ! LCOV_EXCL_LINE
    2287           0 :                                PP_net(:,:,iblk), a2D)
    2288           0 :       if (f_grownet  (1:1) /= 'x') &
    2289             :          call accum_hist_field(n_grownet, iblk, &   ! LCOV_EXCL_LINE
    2290           0 :                              grow_net(:,:,iblk), a2D)
    2291           0 :       if (f_upNO (1:1) /= 'x') &
    2292             :          call accum_hist_field(n_upNO,   iblk, &   ! LCOV_EXCL_LINE
    2293           0 :                    upNO(:,:,iblk), a2D)
    2294           0 :       if (f_upNH (1:1) /= 'x') &
    2295             :          call accum_hist_field(n_upNH,   iblk, &   ! LCOV_EXCL_LINE
    2296           0 :                    upNH(:,:,iblk), a2D)
    2297             : 
    2298             :       ! vertical biogeochemistry
    2299             : 
    2300           0 :      if (z_tracers) then
    2301             : 
    2302           0 :       if (f_fzaero(1:1)/= 'x') then
    2303           0 :          do n=1,n_zaero
    2304             :             call accum_hist_field(n_fzaero(n,:),    iblk, &
    2305           0 :                   flux_bio(:,:,nlt_zaero(n),iblk), a2D)
    2306             :          enddo
    2307             :       endif
    2308           0 :       if (f_fzaero_ai(1:1)/= 'x') then
    2309           0 :          do n=1,n_zaero
    2310             :             call accum_hist_field(n_fzaero_ai(n,:),    iblk, &
    2311           0 :                   flux_bio_ai(:,:,nlt_zaero(n),iblk), a2D)
    2312             :          enddo
    2313             :       endif
    2314           0 :       if (f_algalpeak  (1:1) /= 'x') then
    2315           0 :          do n=1,n_algae
    2316           0 :             do j = jlo, jhi
    2317           0 :                do i = ilo, ihi
    2318           0 :                 workii = 0
    2319           0 :                 maxv = c0
    2320           0 :                 if (aice(i,j,iblk) > c0) then
    2321           0 :                   workv(:) = trcr(i,j,nt_bgc_N(n):nt_bgc_N(n)+nblyr,iblk)
    2322           0 :                   worki = maxloc(workv)  ! integer for first location of max
    2323           0 :                   maxv = workv(worki(1)) ! value of max
    2324           0 :                   workv(worki(1)) = c0   ! remove maximum at first location
    2325           0 :                   if (maxval(workv) - maxv < -puny) &
    2326           0 :                     workii =  worki(1)
    2327             :                 endif
    2328           0 :                 workni(i,j) = real(workii,kind=dbl_kind)
    2329           0 :                 worknj(i,j) = maxv
    2330             :                enddo  ! i
    2331             :              enddo    ! j
    2332             :              call accum_hist_field(n_algalpeak(n,:),    iblk, &
    2333           0 :                    workni(:,:), a2D)
    2334             :              call accum_hist_field(n_peakval(n,:), iblk, &
    2335           0 :                    worknj(:,:), a2D)
    2336             :          enddo      ! n
    2337             :       endif !f_algalpeak
    2338             : 
    2339             :       !
    2340             :       ! ice_bio_net
    2341             :       !
    2342           0 :       if (f_zaeronet  (1:1) /= 'x') then
    2343           0 :          do n=1,n_zaero
    2344             :             call accum_hist_field(n_zaeronet(n,:),    iblk, &
    2345           0 :                    ice_bio_net(:,:,nlt_zaero(n), iblk), a2D)
    2346             :          enddo
    2347             :       endif !f_zaeronet
    2348           0 :       if (f_chlnet  (1:1) /= 'x') then
    2349           0 :          do n=1,n_algae
    2350             :             call accum_hist_field(n_chlnet(n,:),    iblk, &
    2351           0 :                    R_chl2N(n)*ice_bio_net(:,:,nlt_bgc_N(n), iblk), a2D)
    2352             :          enddo
    2353             :       endif !f_chlnet
    2354           0 :       if (f_Nnet  (1:1) /= 'x') then
    2355           0 :          do n=1,n_algae
    2356             :             call accum_hist_field(n_Nnet(n,:),    iblk, &
    2357           0 :                    ice_bio_net(:,:,nlt_bgc_N(n), iblk), a2D)
    2358             :          enddo
    2359             :       endif !f_Nnet
    2360           0 :       if (f_Cnet  (1:1) /= 'x') then
    2361           0 :          do n=1,n_algae
    2362             :             call accum_hist_field(n_Cnet(n,:),    iblk, &
    2363           0 :                    R_C2N(n) *ice_bio_net(:,:,nlt_bgc_N(n), iblk), a2D)
    2364             :          enddo
    2365             :       endif !f_Cnet
    2366           0 :       if (f_DOCnet  (1:1) /= 'x') then
    2367           0 :          do n=1,n_doc
    2368             :             call accum_hist_field(n_DOCnet(n,:),    iblk, &
    2369           0 :                    ice_bio_net(:,:,nlt_bgc_DOC(n), iblk), a2D)
    2370             :          enddo
    2371             :       endif !f_DOCnet
    2372           0 :       if (f_DICnet  (1:1) /= 'x') then
    2373           0 :          do n=1,n_dic
    2374             :             call accum_hist_field(n_DICnet(n,:),    iblk, &
    2375           0 :                    ice_bio_net(:,:,nlt_bgc_DIC(n), iblk), a2D)
    2376             :          enddo
    2377             :       endif !f_DICnet
    2378           0 :       if (f_DONnet  (1:1) /= 'x') then
    2379           0 :          do n=1,n_don
    2380             :             call accum_hist_field(n_DONnet(n,:),    iblk, &
    2381           0 :                    ice_bio_net(:,:,nlt_bgc_DON(n), iblk), a2D)
    2382             :          enddo
    2383             :       endif !f_DONnet
    2384           0 :       if (f_Fednet   (1:1) /= 'x') then
    2385           0 :          do n=1,n_fed
    2386             :             call accum_hist_field(n_Fednet (n,:),    iblk, &
    2387           0 :                    ice_bio_net(:,:,nlt_bgc_Fed (n), iblk), a2D)
    2388             :          enddo
    2389             :       endif !f_Fednet
    2390           0 :       if (f_Fepnet   (1:1) /= 'x') then
    2391           0 :          do n=1,n_fep
    2392             :             call accum_hist_field(n_Fepnet (n,:),    iblk, &
    2393           0 :                    ice_bio_net(:,:,nlt_bgc_Fep (n), iblk), a2D)
    2394             :          enddo
    2395             :       endif !f_Fepnet
    2396             : 
    2397           0 :       if (f_Nitnet  (1:1) /= 'x') &
    2398             :          call accum_hist_field(n_Nitnet,   iblk, &   ! LCOV_EXCL_LINE
    2399           0 :                    ice_bio_net(:,:,nlt_bgc_Nit, iblk), a2D)
    2400           0 :       if (f_Amnet  (1:1) /= 'x') &
    2401             :          call accum_hist_field(n_Amnet,   iblk, &   ! LCOV_EXCL_LINE
    2402           0 :                    ice_bio_net(:,:,nlt_bgc_Am, iblk), a2D)
    2403           0 :       if (f_Silnet  (1:1) /= 'x') &
    2404             :          call accum_hist_field(n_Silnet,   iblk, &   ! LCOV_EXCL_LINE
    2405           0 :                    ice_bio_net(:,:,nlt_bgc_Sil, iblk), a2D)
    2406           0 :       if (f_humnet  (1:1) /= 'x') &
    2407             :          call accum_hist_field(n_humnet,   iblk, &   ! LCOV_EXCL_LINE
    2408           0 :                    ice_bio_net(:,:,nlt_bgc_hum, iblk), a2D)
    2409           0 :       if (f_DMSPpnet  (1:1) /= 'x') &
    2410             :          call accum_hist_field(n_DMSPpnet,   iblk, &   ! LCOV_EXCL_LINE
    2411           0 :                   ice_bio_net(:,:,nlt_bgc_DMSPp, iblk), a2D)
    2412           0 :       if (f_DMSPdnet  (1:1) /= 'x') &
    2413             :          call accum_hist_field(n_DMSPdnet,   iblk, &   ! LCOV_EXCL_LINE
    2414           0 :                    ice_bio_net(:,:,nlt_bgc_DMSPd, iblk), a2D)
    2415           0 :       if (f_DMSnet  (1:1) /= 'x') &
    2416             :          call accum_hist_field(n_DMSnet,   iblk, &   ! LCOV_EXCL_LINE
    2417           0 :                    ice_bio_net(:,:,nlt_bgc_DMS, iblk), a2D)
    2418           0 :       if (f_PONnet  (1:1) /= 'x') &
    2419             :          call accum_hist_field(n_PONnet,   iblk, &   ! LCOV_EXCL_LINE
    2420           0 :                    ice_bio_net(:,:,nlt_bgc_PON, iblk), a2D)
    2421             :       !
    2422             :       !  snow_bio_net
    2423             :       !
    2424           0 :       if (f_zaerosnow  (1:1) /= 'x') then
    2425           0 :          do n=1,n_zaero
    2426             :             call accum_hist_field(n_zaerosnow(n,:),    iblk, &
    2427           0 :                    snow_bio_net(:,:,nlt_zaero(n), iblk), a2D)
    2428             :          enddo
    2429             :       endif !f_zaerosnow
    2430           0 :       if (f_chlsnow  (1:1) /= 'x') then
    2431           0 :          do n=1,n_algae
    2432             :             call accum_hist_field(n_chlsnow(n,:),    iblk, &
    2433           0 :                    R_chl2N(n)*snow_bio_net(:,:,nlt_bgc_N(n), iblk), a2D)
    2434             :          enddo
    2435             :       endif !f_chlsnow
    2436           0 :       if (f_Nsnow  (1:1) /= 'x') then
    2437           0 :          do n=1,n_algae
    2438             :             call accum_hist_field(n_Nsnow(n,:),    iblk, &
    2439           0 :                    snow_bio_net(:,:,nlt_bgc_N(n), iblk), a2D)
    2440             :          enddo
    2441             :       endif !f_Nsnow
    2442           0 :       if (f_Csnow  (1:1) /= 'x') then
    2443           0 :          do n=1,n_algae
    2444             :             call accum_hist_field(n_Csnow(n,:),    iblk, &
    2445           0 :                    R_C2N(n)*snow_bio_net(:,:,nlt_bgc_N(n), iblk), a2D)
    2446             :          enddo
    2447             :       endif !f_Csnow
    2448           0 :       if (f_DOCsnow  (1:1) /= 'x') then
    2449           0 :          do n=1,n_doc
    2450             :             call accum_hist_field(n_DOCsnow(n,:),    iblk, &
    2451           0 :                    snow_bio_net(:,:,nlt_bgc_DOC(n), iblk), a2D)
    2452             :          enddo
    2453             :       endif !f_DOCsnow
    2454           0 :       if (f_DICsnow  (1:1) /= 'x') then
    2455           0 :          do n=1,n_dic
    2456             :             call accum_hist_field(n_DICsnow(n,:),    iblk, &
    2457           0 :                    snow_bio_net(:,:,nlt_bgc_DIC(n), iblk), a2D)
    2458             :          enddo
    2459             :       endif !f_DICsnow
    2460           0 :       if (f_DONsnow  (1:1) /= 'x') then
    2461           0 :          do n=1,n_don
    2462             :             call accum_hist_field(n_DONsnow(n,:),    iblk, &
    2463           0 :                    snow_bio_net(:,:,nlt_bgc_DON(n), iblk), a2D)
    2464             :          enddo
    2465             :       endif !f_DONsnow
    2466           0 :       if (f_Fedsnow   (1:1) /= 'x') then
    2467           0 :          do n=1,n_fed
    2468             :             call accum_hist_field(n_Fedsnow (n,:),    iblk, &
    2469           0 :                    snow_bio_net(:,:,nlt_bgc_Fed (n), iblk), a2D)
    2470             :          enddo
    2471             :       endif !f_Fedsnow
    2472           0 :       if (f_Fepsnow   (1:1) /= 'x') then
    2473           0 :          do n=1,n_fep
    2474             :             call accum_hist_field(n_Fepsnow (n,:),    iblk, &
    2475           0 :                    snow_bio_net(:,:,nlt_bgc_Fep (n), iblk), a2D)
    2476             :          enddo
    2477             :       endif !f_Fepsnow
    2478             : 
    2479           0 :       if (f_Nitsnow  (1:1) /= 'x') &
    2480             :          call accum_hist_field(n_Nitsnow,   iblk, &   ! LCOV_EXCL_LINE
    2481           0 :                    snow_bio_net(:,:,nlt_bgc_Nit, iblk), a2D)
    2482           0 :       if (f_Amsnow  (1:1) /= 'x') &
    2483             :          call accum_hist_field(n_Amsnow,   iblk, &   ! LCOV_EXCL_LINE
    2484           0 :                    snow_bio_net(:,:,nlt_bgc_Am, iblk), a2D)
    2485           0 :       if (f_Silsnow  (1:1) /= 'x') &
    2486             :          call accum_hist_field(n_Silsnow,   iblk, &   ! LCOV_EXCL_LINE
    2487           0 :                    snow_bio_net(:,:,nlt_bgc_Sil, iblk), a2D)
    2488           0 :       if (f_humsnow  (1:1) /= 'x') &
    2489             :          call accum_hist_field(n_humsnow,   iblk, &   ! LCOV_EXCL_LINE
    2490           0 :                    snow_bio_net(:,:,nlt_bgc_hum, iblk), a2D)
    2491           0 :       if (f_DMSPpsnow  (1:1) /= 'x') &
    2492             :          call accum_hist_field(n_DMSPpsnow,   iblk, &   ! LCOV_EXCL_LINE
    2493           0 :                    snow_bio_net(:,:,nlt_bgc_DMSPp, iblk), a2D)
    2494           0 :       if (f_DMSPdsnow  (1:1) /= 'x') &
    2495             :          call accum_hist_field(n_DMSPdsnow,   iblk, &   ! LCOV_EXCL_LINE
    2496           0 :                    snow_bio_net(:,:,nlt_bgc_DMSPd, iblk), a2D)
    2497           0 :       if (f_DMSsnow  (1:1) /= 'x') &
    2498             :          call accum_hist_field(n_DMSsnow,   iblk, &   ! LCOV_EXCL_LINE
    2499           0 :                    snow_bio_net(:,:,nlt_bgc_DMS, iblk), a2D)
    2500           0 :       if (f_PONsnow  (1:1) /= 'x') &
    2501             :          call accum_hist_field(n_PONsnow,   iblk, &   ! LCOV_EXCL_LINE
    2502           0 :                    snow_bio_net(:,:,nlt_bgc_PON, iblk), a2D)
    2503             :       !
    2504             :       ! mobile frac
    2505             :       !
    2506           0 :       if (f_zaerofrac  (1:1) /= 'x') then
    2507           0 :          do n=1,n_zaero
    2508             :             call accum_hist_field(n_zaerofrac(n,:),    iblk, &
    2509           0 :                    trcr(:,:,nt_zbgc_frac - 1 + nlt_zaero(n), iblk), a2D)
    2510             :          enddo
    2511             :       endif !f_zaerofrac
    2512           0 :       if (f_chlfrac  (1:1) /= 'x') then
    2513           0 :          do n=1,n_algae
    2514             :             call accum_hist_field(n_chlfrac(n,:),    iblk, &
    2515           0 :                    trcr(:,:,nlt_bgc_N(n), iblk), a2D)
    2516             :          enddo
    2517             :       endif !f_chlfrac
    2518           0 :       if (f_Nfrac  (1:1) /= 'x') then
    2519           0 :          do n=1,n_algae
    2520             :             call accum_hist_field(n_Nfrac(n,:),    iblk, &
    2521           0 :                    trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_N(n), iblk), a2D)
    2522             :          enddo
    2523             :       endif !f_Nfrac
    2524           0 :       if (f_DOCfrac  (1:1) /= 'x') then
    2525           0 :          do n=1,n_doc
    2526             :             call accum_hist_field(n_DOCfrac(n,:),    iblk, &
    2527           0 :                    trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_DOC(n), iblk), a2D)
    2528             :          enddo
    2529             :       endif !f_DOCfrac
    2530           0 :       if (f_DICfrac  (1:1) /= 'x') then
    2531           0 :          do n=1,n_dic
    2532             :             call accum_hist_field(n_DICfrac(n,:),    iblk, &
    2533           0 :                    trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_DIC(n), iblk), a2D)
    2534             :          enddo
    2535             :       endif !f_DICfrac
    2536           0 :       if (f_DONfrac  (1:1) /= 'x') then
    2537           0 :          do n=1,n_don
    2538             :             call accum_hist_field(n_DONfrac(n,:),    iblk, &
    2539           0 :                    trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_DON(n), iblk), a2D)
    2540             :          enddo
    2541             :       endif !f_DONfrac
    2542           0 :       if (f_Fedfrac   (1:1) /= 'x') then
    2543           0 :          do n=1,n_fed
    2544             :             call accum_hist_field(n_Fedfrac (n,:),    iblk, &
    2545           0 :                    trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_Fed (n), iblk), a2D)
    2546             :          enddo
    2547             :       endif !f_Fedfrac
    2548           0 :       if (f_Fepfrac   (1:1) /= 'x') then
    2549           0 :          do n=1,n_fep
    2550             :             call accum_hist_field(n_Fepfrac (n,:),    iblk, &
    2551           0 :                    trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_Fep (n), iblk), a2D)
    2552             :          enddo
    2553             :       endif !f_Fepfrac
    2554             : 
    2555           0 :       if (f_Nitfrac  (1:1) /= 'x') &
    2556             :          call accum_hist_field(n_Nitfrac,   iblk, &   ! LCOV_EXCL_LINE
    2557           0 :                    trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_Nit, iblk), a2D)
    2558           0 :       if (f_Amfrac  (1:1) /= 'x') &
    2559             :          call accum_hist_field(n_Amfrac,   iblk, &   ! LCOV_EXCL_LINE
    2560           0 :                    trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_Am, iblk), a2D)
    2561           0 :       if (f_Silfrac  (1:1) /= 'x') &
    2562             :          call accum_hist_field(n_Silfrac,   iblk, &   ! LCOV_EXCL_LINE
    2563           0 :                    trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_Sil, iblk), a2D)
    2564           0 :       if (f_humfrac  (1:1) /= 'x') &
    2565             :          call accum_hist_field(n_humfrac,   iblk, &   ! LCOV_EXCL_LINE
    2566           0 :                    trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_hum, iblk), a2D)
    2567           0 :       if (f_DMSPpfrac  (1:1) /= 'x') &
    2568             :          call accum_hist_field(n_DMSPpfrac,   iblk, &   ! LCOV_EXCL_LINE
    2569           0 :                    trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_DMSPp, iblk), a2D)
    2570           0 :       if (f_DMSPdfrac  (1:1) /= 'x') &
    2571             :          call accum_hist_field(n_DMSPdfrac,   iblk, &   ! LCOV_EXCL_LINE
    2572           0 :                    trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_DMSPd, iblk), a2D)
    2573           0 :       if (f_DMSfrac  (1:1) /= 'x') &
    2574             :          call accum_hist_field(n_DMSfrac,   iblk, &   ! LCOV_EXCL_LINE
    2575           0 :                    trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_DMS, iblk), a2D)
    2576           0 :       if (f_PONfrac  (1:1) /= 'x') &
    2577             :          call accum_hist_field(n_PONfrac,   iblk, &   ! LCOV_EXCL_LINE
    2578           0 :                    trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_PON, iblk), a2D)
    2579             : 
    2580             :      endif  ! z_tracers
    2581             : 
    2582             :       ! brine
    2583           0 :       if (f_hbri  (1:1) /= 'x') &
    2584             :          call accum_hist_field(n_hbri,     iblk, &   ! LCOV_EXCL_LINE
    2585           0 :                         hbri(:,:,iblk), a2D)
    2586             : 
    2587             :      endif ! 2d bgc tracers, tr_aero, tr_brine, skl_bgc
    2588             :      endif ! allocated(a2D)
    2589             : 
    2590             :       ! 3D category fields
    2591             : 
    2592       23104 :      if (allocated(a3Dc)) then
    2593           0 :      if (tr_brine) then
    2594             :       ! 3Dc bgc category fields
    2595             : 
    2596           0 :       if (f_fbri   (1:1) /= 'x') &
    2597             :          call accum_hist_field(n_fbri-n2D, iblk, ncat_hist, &   ! LCOV_EXCL_LINE
    2598           0 :                                trcrn(:,:,nt_fbri,1:ncat_hist,iblk), a3Dc)
    2599             :      endif
    2600             :      endif ! allocated(a3Dc)
    2601             : 
    2602       23104 :      if (allocated(a3Db)) then
    2603           0 :      if (z_tracers) then
    2604             :       ! 3Db category fields
    2605             : 
    2606           0 :       if (f_bTin  (1:1) /= 'x')  then
    2607           0 :          workz(:,:,:) = c0
    2608           0 :          do n = 1, ncat_hist
    2609           0 :             do j = jlo, jhi
    2610           0 :                do i = ilo, ihi
    2611           0 :                   if (aicen(i,j,n,iblk) > c0) then
    2612           0 :                       workz(i,j,1:nzblyr) =  workz(i,j,1:nzblyr) + bTiz(i,j,1:nzblyr,n,iblk)*&
    2613           0 :                                aicen(i,j,n,iblk)
    2614             :                   endif
    2615             :                enddo  ! i
    2616             :             enddo     ! j
    2617             :          enddo        ! n
    2618             :          call accum_hist_field(n_bTin-n3Dzcum, iblk, nzblyr, &
    2619           0 :                                workz(:,:,1:nzblyr), a3Db)
    2620             :       endif
    2621             : 
    2622           0 :       if (f_bphi  (1:1) /= 'x') then
    2623           0 :          workz(:,:,:) = c0
    2624           0 :          do n = 1, ncat_hist
    2625           0 :             do j = jlo, jhi
    2626           0 :                do i = ilo, ihi
    2627           0 :                   if (aicen(i,j,n,iblk) > c0) then
    2628           0 :                       workz(i,j,1:nzblyr) =  workz(i,j,1:nzblyr) + bphi(i,j,1:nzblyr,n,iblk)*&
    2629           0 :                                aicen(i,j,n,iblk)
    2630             :                   endif
    2631             :                enddo ! i
    2632             :             enddo    ! j
    2633             :          enddo       ! n
    2634             :          call accum_hist_field(n_bphi-n3Dzcum, iblk, nzblyr, &
    2635           0 :                                workz(:,:,1:nzblyr), a3Db)
    2636             :       endif
    2637             : 
    2638           0 :       if (f_zfswin   (1:1) /= 'x') then
    2639           0 :          workz(:,:,:) = c0
    2640           0 :          do n = 1, ncat_hist
    2641           0 :             do j = jlo, jhi
    2642           0 :                do i = ilo, ihi
    2643           0 :                 if (aicen(i,j,n,iblk) > c0) then
    2644           0 :                    workz(i,j,1:nblyr+1) = workz(i,j,1:nblyr+1)+ zfswin(i,j,1:nblyr+1,n,iblk)*&
    2645           0 :                        aicen(i,j,n,iblk)
    2646           0 :                    workz(i,j,nzblyr) = workz(i,j,nzblyr) + zfswin(i,j,nblyr+1,n,iblk)*&
    2647           0 :                        aicen(i,j,n,iblk)
    2648             :                 endif
    2649             :                enddo ! i
    2650             :             enddo    ! j
    2651             :          enddo       ! n
    2652             :          call accum_hist_field(n_zfswin-n3Dzcum, iblk, nzblyr, &
    2653           0 :                                   workz(:,:,1:nzblyr), a3Db)
    2654             :       endif
    2655             : 
    2656           0 :       if (f_iDi   (1:1) /= 'x') then
    2657           0 :          workz(:,:,:) = c0
    2658           0 :          do n = 1, ncat_hist
    2659           0 :             do k = 1,nzblyr-1
    2660           0 :               do j = jlo, jhi
    2661           0 :                do i = ilo, ihi
    2662           0 :                 if (aicen(i,j,n,iblk) > c0) then
    2663           0 :                    workz(i,j,k) = workz(i,j,k) + iDi(i,j,k,n,iblk)*vicen(i,j,n,iblk)**2/aicen(i,j,n,iblk)
    2664           0 :                    workz(i,j,nzblyr)   = workz(i,j,nzblyr-1)
    2665             :                 endif
    2666             :                enddo ! i
    2667             :               enddo  ! j
    2668             :             enddo    ! k
    2669             :           enddo      ! n
    2670             :           call accum_hist_field(n_iDi-n3Dzcum, iblk, nzblyr, &
    2671           0 :                                   workz(:,:,1:nzblyr), a3Db)
    2672             :       endif
    2673             : 
    2674           0 :       if (f_iki   (1:1) /= 'x') then
    2675           0 :          workz(:,:,:) = c0
    2676           0 :          do n = 1, ncat_hist
    2677           0 :             do k = 1,nzblyr-1
    2678           0 :             do j = jlo, jhi
    2679           0 :                do i = ilo, ihi
    2680           0 :                 if (aicen(i,j,n,iblk) > c0) then
    2681           0 :                    workz(i,j,k) = workz(i,j,k) + iki(i,j,k,n,iblk)*&
    2682           0 :                        aicen(i,j,n,iblk)
    2683           0 :                    workz(i,j,nzblyr)   = workz(i,j,nzblyr) + iki(i,j,nblyr+1,n,iblk)*&
    2684           0 :                        aicen(i,j,n,iblk)
    2685             :                 endif
    2686             :                enddo ! i
    2687             :             enddo    ! j
    2688             :             enddo    ! k
    2689             :          enddo       ! n
    2690             :          call accum_hist_field(n_iki-n3Dzcum, iblk, nzblyr,  &
    2691           0 :                                   workz(:,:,1:nzblyr), a3Db)
    2692             :       endif
    2693             : 
    2694             :      endif ! 3Db fields
    2695             :      endif ! allocated(a3Db)
    2696             : 
    2697       23104 :      if (allocated(a3Da)) then
    2698           0 :      if (z_tracers) then
    2699             :       ! 3Da category fields
    2700             : 
    2701           0 :       if (f_zaero   (1:1) /= 'x') then
    2702           0 :          do k = 1,n_zaero
    2703           0 :            workz(:,:,:) = c0
    2704           0 :              do j = jlo, jhi
    2705           0 :                do i = ilo, ihi
    2706           0 :                   if (aice(i,j,iblk) > puny) then
    2707           0 :                     workz(i,j,1:2) =  &   !snow
    2708           0 :                          trcr(i,j,nt_zaero(k)+nblyr+1:nt_zaero(k)+nblyr+2,iblk)/rhos
    2709           0 :                     workz(i,j,3:nblyr+3) = &  !ice
    2710           0 :                          trcr(i,j,nt_zaero(k):nt_zaero(k)+nblyr,iblk)/rhoi
    2711           0 :                     workz(i,j,nblyr+4) =  ocean_bio(i,j,nlt_zaero(k),iblk)/rhow !ocean
    2712             :                   endif
    2713             :                 enddo ! i
    2714             :              enddo    ! j
    2715           0 :            call accum_hist_field(n_zaeros(k,:)-n3Dbcum, iblk, nzalyr, &
    2716           0 :                                   workz(:,:,1:nzalyr), a3Da)
    2717             :          enddo !k
    2718             :       endif  !f_zaero
    2719           0 :       if (f_bgc_N   (1:1) /= 'x') then
    2720           0 :          do k = 1,n_algae
    2721           0 :            workz(:,:,:) = c0
    2722           0 :            workz2(:,:,:) = c0
    2723           0 :              do j = jlo, jhi
    2724           0 :                do i = ilo, ihi
    2725           0 :                   if (aice(i,j,iblk) > puny) then
    2726           0 :                     workz(i,j,1:2) =  &   !snow
    2727           0 :                          trcr(i,j,nt_bgc_N(k)+nblyr+1:nt_bgc_N(k)+nblyr+2,iblk)
    2728           0 :                     workz(i,j,3:nblyr+3) = &  !ice
    2729           0 :                          trcr(i,j,nt_bgc_N(k):nt_bgc_N(k)+nblyr,iblk)
    2730           0 :                     workz(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_N(k),iblk) !ocean
    2731             :                   endif
    2732           0 :                   if (aicen(i,j,1,iblk) > puny) then
    2733           0 :                     workz2(i,j,1:2) =  &   !snow
    2734           0 :                          trcrn(i,j,nt_bgc_N(k)+nblyr+1:nt_bgc_N(k)+nblyr+2,1,iblk)
    2735           0 :                     workz2(i,j,3:nblyr+3) = &  !ice
    2736           0 :                          trcrn(i,j,nt_bgc_N(k):nt_bgc_N(k)+nblyr,1,iblk)
    2737           0 :                     workz2(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_N(k),iblk) !ocean
    2738             :                   endif
    2739             :                 enddo ! i
    2740             :              enddo    ! j
    2741           0 :            call accum_hist_field(n_bgc_N(k,:)-n3Dbcum, iblk, nzalyr,  &
    2742           0 :                                   workz(:,:,1:nzalyr), a3Da)
    2743           0 :            call accum_hist_field(n_bgc_N_cat1(k,:)-n3Dbcum, iblk, nzalyr,  &
    2744           0 :                                   workz2(:,:,1:nzalyr), a3Da)
    2745             :          enddo !k
    2746             :       endif  !f_bgc_N
    2747           0 :       if (f_bgc_C   (1:1) /= 'x') then
    2748           0 :          do k = 1,n_algae
    2749           0 :            workz(:,:,:) = c0
    2750           0 :              do j = jlo, jhi
    2751           0 :                do i = ilo, ihi
    2752           0 :                   if (aice(i,j,iblk) > puny) then
    2753           0 :                     workz(i,j,1:2) =  &   !snow
    2754           0 :                          R_C2N(k)*trcr(i,j,nt_bgc_N(k)+nblyr+1:nt_bgc_N(k)+nblyr+2,iblk)
    2755           0 :                     workz(i,j,3:nblyr+3) = &  !ice
    2756           0 :                          R_C2N(k)*trcr(i,j,nt_bgc_N(k):nt_bgc_N(k)+nblyr,iblk)
    2757           0 :                     workz(i,j,nblyr+4) =  R_C2N(k)*ocean_bio(i,j,nlt_bgc_N(k),iblk) !ocean
    2758             :                   endif
    2759             :                 enddo ! i
    2760             :              enddo    ! j
    2761           0 :            call accum_hist_field(n_bgc_C(k,:)-n3Dbcum, iblk, nzalyr, &
    2762           0 :                                   workz(:,:,1:nzalyr), a3Da)
    2763             :          enddo !k
    2764             :       endif  !f_bgc_C
    2765           0 :       if (f_bgc_DOC   (1:1) /= 'x') then
    2766           0 :          do k = 1,n_doc
    2767           0 :            workz(:,:,:) = c0
    2768           0 :            workz2(:,:,:) = c0
    2769           0 :              do j = jlo, jhi
    2770           0 :                do i = ilo, ihi
    2771           0 :                   if (aice(i,j,iblk) > puny) then
    2772           0 :                     workz(i,j,1:2) =  &   !snow
    2773           0 :                          trcr(i,j,nt_bgc_DOC(k)+nblyr+1:nt_bgc_DOC(k)+nblyr+2,iblk)
    2774           0 :                     workz(i,j,3:nblyr+3) = &  !ice
    2775           0 :                          trcr(i,j,nt_bgc_DOC(k):nt_bgc_DOC(k)+nblyr,iblk)
    2776           0 :                     workz(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_DOC(k),iblk) !ocean
    2777             :                   endif
    2778           0 :                   if (aicen(i,j,1,iblk) > puny) then
    2779           0 :                     workz2(i,j,1:2) =  &   !snow
    2780           0 :                          trcrn(i,j,nt_bgc_DOC(k)+nblyr+1:nt_bgc_DOC(k)+nblyr+2,1,iblk)
    2781           0 :                     workz2(i,j,3:nblyr+3) = &  !ice
    2782           0 :                          trcrn(i,j,nt_bgc_DOC(k):nt_bgc_DOC(k)+nblyr,1,iblk)
    2783           0 :                     workz2(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_DOC(k),iblk) !ocean
    2784             :                   endif
    2785             :                 enddo ! i
    2786             :              enddo    ! j
    2787           0 :            call accum_hist_field(n_bgc_DOC(k,:)-n3Dbcum, iblk, nzalyr,  &
    2788           0 :                                   workz(:,:,1:nzalyr), a3Da)
    2789           0 :            call accum_hist_field(n_bgc_DOC_cat1(k,:)-n3Dbcum, iblk, nzalyr,  &
    2790           0 :                                   workz2(:,:,1:nzalyr), a3Da)
    2791             :          enddo !k
    2792             :       endif  !f_bgc_DOC
    2793           0 :       if (f_bgc_DIC   (1:1) /= 'x') then
    2794           0 :          do k = 1,n_dic
    2795           0 :            workz(:,:,:) = c0
    2796           0 :            workz2(:,:,:) = c0
    2797           0 :              do j = jlo, jhi
    2798           0 :                do i = ilo, ihi
    2799           0 :                   if (aice(i,j,iblk) > puny) then
    2800           0 :                     workz(i,j,1:2) =  &   !snow
    2801           0 :                          trcr(i,j,nt_bgc_DIC(k)+nblyr+1:nt_bgc_DIC(k)+nblyr+2,iblk)
    2802           0 :                     workz(i,j,3:nblyr+3) = &  !ice
    2803           0 :                          trcr(i,j,nt_bgc_DIC(k):nt_bgc_DIC(k)+nblyr,iblk)
    2804           0 :                     workz(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_DIC(k),iblk) !ocean
    2805             :                   endif
    2806           0 :                   if (aicen(i,j,1,iblk) > puny) then
    2807           0 :                     workz2(i,j,1:2) =  &   !snow
    2808           0 :                          trcrn(i,j,nt_bgc_DIC(k)+nblyr+1:nt_bgc_DIC(k)+nblyr+2,1,iblk)
    2809           0 :                     workz2(i,j,3:nblyr+3) = &  !ice
    2810           0 :                          trcrn(i,j,nt_bgc_DIC(k):nt_bgc_DIC(k)+nblyr,1,iblk)
    2811           0 :                     workz2(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_DIC(k),iblk) !ocean
    2812             :                   endif
    2813             :                 enddo ! i
    2814             :              enddo    ! j
    2815           0 :            call accum_hist_field(n_bgc_DIC(k,:)-n3Dbcum, iblk, nzalyr,  &
    2816           0 :                                   workz(:,:,1:nzalyr), a3Da)
    2817           0 :           call accum_hist_field(n_bgc_DIC_cat1(k,:)-n3Dbcum, iblk, nzalyr,  &
    2818           0 :                                   workz2(:,:,1:nzalyr), a3Da)
    2819             :          enddo !k
    2820             :       endif  !f_bgc_DIC
    2821           0 :       if (f_bgc_DON   (1:1) /= 'x') then
    2822           0 :          do k = 1,n_don
    2823           0 :            workz(:,:,:) = c0
    2824           0 :            workz2(:,:,:) = c0
    2825           0 :              do j = jlo, jhi
    2826           0 :                do i = ilo, ihi
    2827           0 :                   if (aice(i,j,iblk) > puny) then
    2828           0 :                     workz(i,j,1:2) =  &   !snow
    2829           0 :                          trcr(i,j,nt_bgc_DON(k)+nblyr+1:nt_bgc_DON(k)+nblyr+2,iblk)
    2830           0 :                     workz(i,j,3:nblyr+3) = &  !ice
    2831           0 :                          trcr(i,j,nt_bgc_DON(k):nt_bgc_DON(k)+nblyr,iblk)
    2832           0 :                     workz(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_DON(k),iblk) !ocean
    2833             :                   endif
    2834           0 :                   if (aicen(i,j,1,iblk) > puny) then
    2835           0 :                     workz2(i,j,1:2) =  &   !snow
    2836           0 :                          trcrn(i,j,nt_bgc_DON(k)+nblyr+1:nt_bgc_DON(k)+nblyr+2,1,iblk)
    2837           0 :                     workz2(i,j,3:nblyr+3) = &  !ice
    2838           0 :                          trcrn(i,j,nt_bgc_DON(k):nt_bgc_DON(k)+nblyr,1,iblk)
    2839           0 :                     workz2(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_DON(k),iblk) !ocean
    2840             :                   endif
    2841             :                 enddo ! i
    2842             :              enddo    ! j
    2843           0 :            call accum_hist_field(n_bgc_DON(k,:)-n3Dbcum, iblk, nzalyr,  &
    2844           0 :                                   workz(:,:,1:nzalyr), a3Da)
    2845           0 :            call accum_hist_field(n_bgc_DON_cat1(k,:)-n3Dbcum, iblk, nzalyr,  &
    2846           0 :                                   workz2(:,:,1:nzalyr), a3Da)
    2847             :          enddo !k
    2848             :       endif  !f_bgc_DON
    2849           0 :       if (f_bgc_Fed    (1:1) /= 'x') then
    2850           0 :          do k = 1,n_fed
    2851           0 :            workz(:,:,:) = c0
    2852           0 :            workz2(:,:,:) = c0
    2853           0 :              do j = jlo, jhi
    2854           0 :                do i = ilo, ihi
    2855           0 :                   if (aice(i,j,iblk) > puny) then
    2856           0 :                     workz(i,j,1:2) =  &   !snow
    2857           0 :                          trcr(i,j,nt_bgc_Fed (k)+nblyr+1:nt_bgc_Fed (k)+nblyr+2,iblk)
    2858           0 :                     workz(i,j,3:nblyr+3) = &  !ice
    2859           0 :                          trcr(i,j,nt_bgc_Fed (k):nt_bgc_Fed (k)+nblyr,iblk)
    2860           0 :                     workz(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_Fed (k),iblk) !ocean
    2861             :                   endif
    2862           0 :                   if (aicen(i,j,1,iblk) > puny) then
    2863           0 :                     workz2(i,j,1:2) =  &   !snow
    2864           0 :                          trcrn(i,j,nt_bgc_Fed (k)+nblyr+1:nt_bgc_Fed (k)+nblyr+2,1,iblk)
    2865           0 :                     workz2(i,j,3:nblyr+3) = &  !ice
    2866           0 :                          trcrn(i,j,nt_bgc_Fed (k):nt_bgc_Fed (k)+nblyr,1,iblk)
    2867           0 :                     workz2(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_Fed (k),iblk) !ocean
    2868             :                   endif
    2869             :                 enddo ! i
    2870             :              enddo    ! j
    2871           0 :            call accum_hist_field(n_bgc_Fed (k,:)-n3Dbcum, iblk, nzalyr,  &
    2872           0 :                                   workz(:,:,1:nzalyr), a3Da)
    2873           0 :            call accum_hist_field(n_bgc_Fed_cat1 (k,:)-n3Dbcum, iblk, nzalyr,  &
    2874           0 :                                   workz2(:,:,1:nzalyr), a3Da)
    2875             :          enddo !k
    2876             :       endif  !f_bgc_Fed
    2877           0 :       if (f_bgc_Fep    (1:1) /= 'x') then
    2878           0 :          do k = 1,n_fep
    2879           0 :            workz(:,:,:) = c0
    2880           0 :            workz2(:,:,:) = c0
    2881           0 :              do j = jlo, jhi
    2882           0 :                do i = ilo, ihi
    2883           0 :                   if (aice(i,j,iblk) > puny) then
    2884           0 :                     workz(i,j,1:2) =  &   !snow
    2885           0 :                          trcr(i,j,nt_bgc_Fep (k)+nblyr+1:nt_bgc_Fep (k)+nblyr+2,iblk)
    2886           0 :                     workz(i,j,3:nblyr+3) = &  !ice
    2887           0 :                          trcr(i,j,nt_bgc_Fep (k):nt_bgc_Fep (k)+nblyr,iblk)
    2888           0 :                     workz(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_Fep (k),iblk) !ocean
    2889             :                   endif
    2890           0 :                   if (aicen(i,j,1,iblk) > puny) then
    2891           0 :                     workz2(i,j,1:2) =  &   !snow
    2892           0 :                          trcrn(i,j,nt_bgc_Fep (k)+nblyr+1:nt_bgc_Fep (k)+nblyr+2,1,iblk)
    2893           0 :                     workz2(i,j,3:nblyr+3) = &  !ice
    2894           0 :                          trcrn(i,j,nt_bgc_Fep (k):nt_bgc_Fep (k)+nblyr,1,iblk)
    2895           0 :                     workz2(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_Fep (k),iblk) !ocean
    2896             :                   endif
    2897             :                 enddo ! i
    2898             :              enddo    ! j
    2899           0 :            call accum_hist_field(n_bgc_Fep (k,:)-n3Dbcum, iblk, nzalyr,  &
    2900           0 :                                   workz(:,:,1:nzalyr), a3Da)
    2901           0 :            call accum_hist_field(n_bgc_Fep_cat1 (k,:)-n3Dbcum, iblk, nzalyr,  &
    2902           0 :                                   workz2(:,:,1:nzalyr), a3Da)
    2903             :          enddo !k
    2904             :       endif  !f_bgc_Fep
    2905           0 :       if (f_bgc_chl   (1:1) /= 'x') then
    2906           0 :          do k = 1,n_algae
    2907           0 :            workz(:,:,:) = c0
    2908           0 :              do j = jlo, jhi
    2909           0 :                do i = ilo, ihi
    2910           0 :                   if (aice(i,j,iblk) > puny) then
    2911           0 :                     workz(i,j,1:2) =  &   !snow
    2912           0 :                          trcr(i,j,nt_bgc_chl(k)+nblyr+1:nt_bgc_chl(k)+nblyr+2,iblk)
    2913           0 :                     workz(i,j,3:nblyr+3) = &  !ice
    2914           0 :                          trcr(i,j,nt_bgc_chl(k):nt_bgc_chl(k)+nblyr,iblk)
    2915           0 :                     workz(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_chl(k),iblk) !ocean
    2916             :                   endif
    2917             :                 enddo ! i
    2918             :              enddo    ! j
    2919           0 :            call accum_hist_field(n_bgc_chl(k,:)-n3Dbcum, iblk, nzalyr,  &
    2920           0 :                                   workz(:,:,1:nzalyr), a3Da)
    2921             :          enddo !k
    2922             :       endif  !f_bgc_chl
    2923             : 
    2924           0 :       if (f_bgc_Nit   (1:1) /= 'x') then
    2925           0 :          workz(:,:,:) = c0
    2926           0 :          workz2(:,:,:) = c0
    2927           0 :             do j = jlo, jhi
    2928           0 :                do i = ilo, ihi
    2929           0 :                   if (aice(i,j,iblk) > puny) then
    2930           0 :                     workz(i,j,1:2) =  &   !snow
    2931           0 :                          trcr(i,j,nt_bgc_Nit+nblyr+2:nt_bgc_Nit+nblyr+3,iblk)
    2932           0 :                     workz(i,j,3:nblyr+3) = &  !ice
    2933           0 :                          trcr(i,j,nt_bgc_Nit:nt_bgc_Nit+nblyr,iblk)
    2934           0 :                     workz(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_Nit,iblk) !ocean
    2935             :                   endif
    2936           0 :                   if (aicen(i,j,1,iblk) > puny) then
    2937           0 :                     workz2(i,j,1:2) =  &   !snow
    2938           0 :                          trcrn(i,j,nt_bgc_Nit+nblyr+2:nt_bgc_Nit+nblyr+3,1,iblk)
    2939           0 :                     workz2(i,j,3:nblyr+3) = &  !ice
    2940           0 :                          trcrn(i,j,nt_bgc_Nit:nt_bgc_Nit+nblyr,1,iblk)
    2941           0 :                     workz2(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_Nit,iblk) !ocean
    2942             :                   endif
    2943             :                 enddo ! i
    2944             :              enddo    ! j
    2945             :          call accum_hist_field(n_bgc_Nit-n3Dbcum, iblk, nzalyr,  &
    2946           0 :                                   workz(:,:,1:nzalyr), a3Da)
    2947             :          call accum_hist_field(n_bgc_Nit_cat1-n3Dbcum, iblk, nzalyr,  &
    2948           0 :                                   workz2(:,:,1:nzalyr), a3Da)
    2949             :       endif
    2950             : 
    2951           0 :       if (f_bgc_Am   (1:1) /= 'x') then
    2952           0 :          workz(:,:,:) = c0
    2953           0 :          workz2(:,:,:) = c0
    2954           0 :             do j = jlo, jhi
    2955           0 :                do i = ilo, ihi
    2956           0 :                   if (aice(i,j,iblk) > puny) then
    2957           0 :                     workz(i,j,1:2) =  &   !snow
    2958           0 :                          trcr(i,j,nt_bgc_Am+nblyr+1:nt_bgc_Am+nblyr+2,iblk)
    2959           0 :                     workz(i,j,3:nblyr+3) = &  !ice
    2960           0 :                          trcr(i,j,nt_bgc_Am:nt_bgc_Am+nblyr,iblk)
    2961           0 :                     workz(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_Am,iblk) !ocean
    2962             :                   endif
    2963           0 :                   if (aicen(i,j,1,iblk) > puny) then
    2964           0 :                     workz2(i,j,1:2) =  &   !snow
    2965           0 :                          trcrn(i,j,nt_bgc_Am+nblyr+1:nt_bgc_Am+nblyr+2,1,iblk)
    2966           0 :                     workz2(i,j,3:nblyr+3) = &  !ice
    2967           0 :                          trcrn(i,j,nt_bgc_Am:nt_bgc_Am+nblyr,1,iblk)
    2968           0 :                     workz2(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_Am,iblk) !ocean
    2969             :                   endif
    2970             :                 enddo ! i
    2971             :              enddo    ! j
    2972             :          call accum_hist_field(n_bgc_Am-n3Dbcum, iblk, nzalyr,  &
    2973           0 :                                   workz(:,:,1:nzalyr), a3Da)
    2974             :          call accum_hist_field(n_bgc_Am_cat1-n3Dbcum, iblk, nzalyr,  &
    2975           0 :                                   workz2(:,:,1:nzalyr), a3Da)
    2976             :       endif
    2977             : 
    2978           0 :       if (f_bgc_Sil   (1:1) /= 'x') then
    2979           0 :          workz(:,:,:) = c0
    2980           0 :          workz2(:,:,:) = c0
    2981           0 :             do j = jlo, jhi
    2982           0 :                do i = ilo, ihi
    2983           0 :                   if (aice(i,j,iblk) > puny) then
    2984           0 :                     workz(i,j,1:2) =  &   !snow
    2985           0 :                          trcr(i,j,nt_bgc_Sil+nblyr+1:nt_bgc_Sil+nblyr+2,iblk)
    2986           0 :                     workz(i,j,3:nblyr+3) = &  !ice
    2987           0 :                          trcr(i,j,nt_bgc_Sil:nt_bgc_Sil+nblyr,iblk)
    2988           0 :                     workz(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_Sil,iblk) !ocean
    2989             :                   endif
    2990           0 :                   if (aicen(i,j,1,iblk) > puny) then
    2991           0 :                     workz2(i,j,1:2) =  &   !snow
    2992           0 :                          trcrn(i,j,nt_bgc_Sil+nblyr+1:nt_bgc_Sil+nblyr+2,1,iblk)
    2993           0 :                     workz2(i,j,3:nblyr+3) = &  !ice
    2994           0 :                          trcrn(i,j,nt_bgc_Sil:nt_bgc_Sil+nblyr,1,iblk)
    2995           0 :                     workz2(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_Sil,iblk) !ocean
    2996             :                   endif
    2997             :                 enddo ! i
    2998             :              enddo    ! j
    2999             :          call accum_hist_field(n_bgc_Sil-n3Dbcum, iblk, nzalyr,  &
    3000           0 :                                   workz(:,:,1:nzalyr), a3Da)
    3001             :          call accum_hist_field(n_bgc_Sil_cat1-n3Dbcum, iblk, nzalyr,  &
    3002           0 :                                   workz2(:,:,1:nzalyr), a3Da)
    3003             :       endif
    3004             : 
    3005             : 
    3006           0 :       if (f_bgc_hum   (1:1) /= 'x') then
    3007           0 :          workz(:,:,:) = c0
    3008           0 :          workz2(:,:,:) = c0
    3009           0 :             do j = jlo, jhi
    3010           0 :                do i = ilo, ihi
    3011           0 :                   if (aice(i,j,iblk) > puny) then
    3012           0 :                     workz(i,j,1:2) =  &   !snow
    3013           0 :                          trcr(i,j,nt_bgc_hum+nblyr+1:nt_bgc_hum+nblyr+2,iblk)
    3014           0 :                     workz(i,j,3:nblyr+3) = &  !ice
    3015           0 :                          trcr(i,j,nt_bgc_hum:nt_bgc_hum+nblyr,iblk)
    3016           0 :                     workz(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_hum,iblk) !ocean
    3017             :                   endif
    3018           0 :                   if (aicen(i,j,1,iblk) > puny) then
    3019           0 :                     workz2(i,j,1:2) =  &   !snow
    3020           0 :                          trcrn(i,j,nt_bgc_hum+nblyr+1:nt_bgc_hum+nblyr+2,1,iblk)
    3021           0 :                     workz2(i,j,3:nblyr+3) = &  !ice
    3022           0 :                          trcrn(i,j,nt_bgc_hum:nt_bgc_hum+nblyr,1,iblk)
    3023           0 :                     workz2(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_hum,iblk) !ocean
    3024             :                   endif
    3025             :                 enddo ! i
    3026             :              enddo    ! j
    3027             :          call accum_hist_field(n_bgc_hum-n3Dbcum, iblk, nzalyr,  &
    3028           0 :                                   workz(:,:,1:nzalyr), a3Da)
    3029             :          call accum_hist_field(n_bgc_hum_cat1-n3Dbcum, iblk, nzalyr,  &
    3030           0 :                                   workz2(:,:,1:nzalyr), a3Da)
    3031             :       endif
    3032             : 
    3033           0 :       if (f_bgc_DMSPd   (1:1) /= 'x') then
    3034           0 :          workz(:,:,:) = c0
    3035           0 :          workz2(:,:,:) = c0
    3036           0 :             do j = jlo, jhi
    3037           0 :                do i = ilo, ihi
    3038           0 :                   if (aice(i,j,iblk) > puny) then
    3039           0 :                     workz(i,j,1:2) =  &   !snow
    3040           0 :                          trcr(i,j,nt_bgc_DMSPd+nblyr+1:nt_bgc_DMSPd+nblyr+2,iblk)
    3041           0 :                     workz(i,j,3:nblyr+3) = &  !ice
    3042           0 :                          trcr(i,j,nt_bgc_DMSPd:nt_bgc_DMSPd+nblyr,iblk)
    3043           0 :                     workz(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_DMSPd,iblk) !ocean
    3044             :                   endif
    3045           0 :                   if (aicen(i,j,1,iblk) > puny) then
    3046           0 :                     workz2(i,j,1:2) =  &   !snow
    3047           0 :                          trcrn(i,j,nt_bgc_DMSPd+nblyr+1:nt_bgc_DMSPd+nblyr+2,1,iblk)
    3048           0 :                     workz2(i,j,3:nblyr+3) = &  !ice
    3049           0 :                          trcrn(i,j,nt_bgc_DMSPd:nt_bgc_DMSPd+nblyr,1,iblk)
    3050           0 :                     workz2(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_DMSPd,iblk) !ocean
    3051             :                   endif
    3052             :                 enddo ! i
    3053             :              enddo    ! j
    3054             :          call accum_hist_field(n_bgc_DMSPd-n3Dbcum, iblk, nzalyr,  &
    3055           0 :                                   workz(:,:,1:nzalyr), a3Da)
    3056             :          call accum_hist_field(n_bgc_DMSPd_cat1-n3Dbcum, iblk, nzalyr,  &
    3057           0 :                                   workz2(:,:,1:nzalyr), a3Da)
    3058             :       endif
    3059             : 
    3060           0 :       if (f_bgc_DMSPp   (1:1) /= 'x') then
    3061           0 :          workz(:,:,:) = c0
    3062           0 :             do j = jlo, jhi
    3063           0 :                do i = ilo, ihi
    3064           0 :                   if (aice(i,j,iblk) > puny) then
    3065           0 :                     workz(i,j,1:2) =  &   !snow
    3066           0 :                          trcr(i,j,nt_bgc_DMSPp+nblyr+1:nt_bgc_DMSPp+nblyr+2,iblk)
    3067           0 :                     workz(i,j,3:nblyr+3) = &  !ice
    3068           0 :                          trcr(i,j,nt_bgc_DMSPp:nt_bgc_DMSPp+nblyr,iblk)
    3069           0 :                     workz(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_DMSPp,iblk) !ocean
    3070             :                   endif
    3071             :                 enddo ! i
    3072             :              enddo    ! j
    3073             :          call accum_hist_field(n_bgc_DMSPp-n3Dbcum, iblk, nzalyr,  &
    3074           0 :                                   workz(:,:,1:nzalyr), a3Da)
    3075             :       endif
    3076             : 
    3077           0 :       if (f_bgc_DMS   (1:1) /= 'x') then
    3078           0 :          workz(:,:,:) = c0
    3079           0 :          workz2(:,:,:) = c0
    3080           0 :             do j = jlo, jhi
    3081           0 :                do i = ilo, ihi
    3082           0 :                   if (aice(i,j,iblk) > puny) then
    3083           0 :                     workz(i,j,1:2) =  &   !snow
    3084           0 :                          trcr(i,j,nt_bgc_DMS+nblyr+1:nt_bgc_DMS+nblyr+2,iblk)
    3085           0 :                     workz(i,j,3:nblyr+3) = &  !ice
    3086           0 :                          trcr(i,j,nt_bgc_DMS:nt_bgc_DMS+nblyr,iblk)
    3087           0 :                     workz(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_DMS,iblk) !ocean
    3088             :                   endif
    3089           0 :                   if (aicen(i,j,1,iblk) > puny) then
    3090           0 :                     workz2(i,j,1:2) =  &   !snow
    3091           0 :                          trcrn(i,j,nt_bgc_DMS+nblyr+1:nt_bgc_DMS+nblyr+2,1,iblk)
    3092           0 :                     workz2(i,j,3:nblyr+3) = &  !ice
    3093           0 :                          trcrn(i,j,nt_bgc_DMS:nt_bgc_DMS+nblyr,1,iblk)
    3094           0 :                     workz2(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_DMS,iblk) !ocean
    3095             :                   endif
    3096             :                 enddo ! i
    3097             :              enddo    ! j
    3098             :          call accum_hist_field(n_bgc_DMS-n3Dbcum, iblk, nzalyr,  &
    3099           0 :                                   workz(:,:,1:nzalyr), a3Da)
    3100             :          call accum_hist_field(n_bgc_DMS_cat1-n3Dbcum, iblk, nzalyr,  &
    3101           0 :                                   workz2(:,:,1:nzalyr), a3Da)
    3102             :       endif
    3103             : 
    3104           0 :       if (f_bgc_PON   (1:1) /= 'x') then
    3105           0 :          workz(:,:,:) = c0
    3106           0 :          workz2(:,:,:) = c0
    3107           0 :             do j = jlo, jhi
    3108           0 :                do i = ilo, ihi
    3109           0 :                   if (aice(i,j,iblk) > puny) then
    3110           0 :                     workz(i,j,1:2) =  &   !snow
    3111           0 :                          trcr(i,j,nt_bgc_PON+nblyr+1:nt_bgc_PON+nblyr+2,iblk)
    3112           0 :                     workz(i,j,3:nblyr+3) = &  !ice
    3113           0 :                          trcr(i,j,nt_bgc_PON:nt_bgc_PON+nblyr,iblk)
    3114           0 :                     workz(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_PON,iblk) !ocean
    3115             :                   endif
    3116           0 :                   if (aicen(i,j,1,iblk) > puny) then
    3117           0 :                     workz2(i,j,1:2) =  &   !snow
    3118           0 :                          trcrn(i,j,nt_bgc_PON+nblyr+1:nt_bgc_PON+nblyr+2,1,iblk)
    3119           0 :                     workz2(i,j,3:nblyr+3) = &  !ice
    3120           0 :                          trcrn(i,j,nt_bgc_PON:nt_bgc_PON+nblyr,1,iblk)
    3121           0 :                     workz2(i,j,nblyr+4) =  ocean_bio(i,j,nlt_bgc_PON,iblk) !ocean
    3122             :                   endif
    3123             :                 enddo ! i
    3124             :              enddo    ! j
    3125             :          call accum_hist_field(n_bgc_PON-n3Dbcum, iblk, nzalyr,  &
    3126           0 :                                   workz(:,:,1:nzalyr), a3Da)
    3127             :          call accum_hist_field(n_bgc_PON_cat1-n3Dbcum, iblk, nzalyr,  &
    3128           0 :                                   workz2(:,:,1:nzalyr), a3Da)
    3129             :       endif
    3130             : 
    3131             :       endif ! z_tracers, 3Da tracers
    3132             :       endif ! allocated(a3Da)
    3133             : 
    3134       23104 :       end subroutine accum_hist_bgc
    3135             : 
    3136             : !=======================================================================
    3137             : 
    3138          37 :       subroutine init_hist_bgc_3Da
    3139             : 
    3140             :       use ice_calendar, only: nstreams, histfreq
    3141             :       use ice_history_shared, only: tstr3Da, tcstr, define_hist_field
    3142             : 
    3143             :       integer (kind=int_kind) :: ns, n
    3144             :       logical (kind=log_kind) :: z_tracers
    3145             :       character (len=3) :: nchar
    3146             :       character (len=16):: vname_in     ! variable name
    3147             :       character(len=*), parameter :: subname = '(init_hist_bgc_3Da)'
    3148             : 
    3149          37 :       call icepack_query_parameters(z_tracers_out=z_tracers)
    3150          37 :       call icepack_warnings_flush(nu_diag)
    3151          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
    3152           0 :          file=__FILE__, line=__LINE__)
    3153             : 
    3154             :      ! snow+bio grid
    3155             : 
    3156          37 :      if (z_tracers) then
    3157             : 
    3158           0 :      do ns = 1, nstreams
    3159           0 :        if (histfreq(ns) /= 'x') then
    3160             : 
    3161             : !----------------------------------------------------------------------------
    3162             : ! snow+bio grid ==>
    3163             : ! 1:2 snow (surface layer +interior), 3:nblyr+2 ice (bio grid), nblyr+3 ocean
    3164             : !----------------------------------------------------------------------------
    3165             : 
    3166           0 :        if (f_zaero(1:1) /= 'x') then
    3167           0 :          do n=1,n_zaero
    3168           0 :             write(nchar,'(i3.3)') n
    3169           0 :             write(vname_in,'(a,a)') 'zaero', trim(nchar)
    3170             :             call define_hist_field(n_zaeros(n,:),vname_in,"kg/kg",tstr3Da, tcstr, &
    3171             :                 "bulk z aerosol mass fraction", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3172           0 :                 ns, f_zaero)
    3173             :          enddo
    3174             :        endif
    3175             : 
    3176           0 :        if (f_bgc_Nit(1:1) /= 'x') &
    3177             :             call define_hist_field(n_bgc_Nit,"bgc_Nit","mmol/m^3",tstr3Da, tcstr, &   ! LCOV_EXCL_LINE
    3178             :                 "bulk nitrate ", "snow+bio grid", c1, c0,     &   ! LCOV_EXCL_LINE
    3179           0 :                 ns, f_bgc_Nit)
    3180             : 
    3181           0 :        if (f_bgc_Am(1:1) /= 'x') &
    3182             :             call define_hist_field(n_bgc_Am,"bgc_Am","mmol/m^3",tstr3Da, tcstr, &   ! LCOV_EXCL_LINE
    3183             :                 "bulk ammonia/um ", "snow+bio grid", c1, c0,  &   ! LCOV_EXCL_LINE
    3184           0 :                 ns, f_bgc_Am)
    3185             : 
    3186           0 :        if (f_bgc_N(1:1) /= 'x') then
    3187           0 :          do n=1,n_algae
    3188           0 :             write(nchar,'(i3.3)') n
    3189           0 :             write(vname_in,'(a,a)') 'bgc_N', trim(nchar)
    3190             :             call define_hist_field(n_bgc_N(n,:),vname_in,"mmol/m^3",tstr3Da, tcstr, &
    3191             :                 "bulk algal N conc. ", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3192           0 :                 ns, f_bgc_N)
    3193             :          enddo
    3194             :        endif
    3195           0 :        if (f_bgc_C(1:1) /= 'x') then
    3196           0 :          do n=1,n_algae
    3197           0 :             write(nchar,'(i3.3)') n
    3198           0 :             write(vname_in,'(a,a)') 'bgc_C', trim(nchar)
    3199             :             call define_hist_field(n_bgc_C(n,:),vname_in,"mmol C/m^3",tstr3Da, tcstr, &
    3200             :                 "bulk algal C conc. ", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3201           0 :                 ns, f_bgc_C)
    3202             :          enddo
    3203             :        endif
    3204           0 :        if (f_bgc_chl(1:1) /= 'x') then
    3205           0 :          do n=1,n_algae
    3206           0 :             write(nchar,'(i3.3)') n
    3207           0 :             write(vname_in,'(a,a)') 'bgc_chl', trim(nchar)
    3208             :             call define_hist_field(n_bgc_chl(n,:),vname_in,"mg chl/m^3",tstr3Da, tcstr, &
    3209             :                 "bulk algal chl conc. ", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3210           0 :                 ns, f_bgc_chl)
    3211             :          enddo
    3212             :        endif
    3213           0 :        if (f_bgc_DOC(1:1) /= 'x') then
    3214           0 :          do n=1,n_doc
    3215           0 :             write(nchar,'(i3.3)') n
    3216           0 :             write(vname_in,'(a,a)') 'bgc_DOC', trim(nchar)
    3217             :             call define_hist_field(n_bgc_DOC(n,:),vname_in,"mmol/m^3",tstr3Da, tcstr, &
    3218             :                 "bulk DOC conc. ", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3219           0 :                 ns, f_bgc_DOC)
    3220             :          enddo
    3221             :        endif
    3222           0 :        if (f_bgc_DIC(1:1) /= 'x') then
    3223           0 :          do n=1,n_dic
    3224           0 :             write(nchar,'(i3.3)') n
    3225           0 :             write(vname_in,'(a,a)') 'bgc_DIC', trim(nchar)
    3226             :             call define_hist_field(n_bgc_DIC(n,:),vname_in,"mmol/m^3",tstr3Da, tcstr, &
    3227             :                 "bulk DIC conc. ", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3228           0 :                 ns, f_bgc_DIC)
    3229             :          enddo
    3230             :        endif
    3231           0 :        if (f_bgc_DON(1:1) /= 'x') then
    3232           0 :          do n=1,n_don
    3233           0 :             write(nchar,'(i3.3)') n
    3234           0 :             write(vname_in,'(a,a)') 'bgc_DON', trim(nchar)
    3235             :             call define_hist_field(n_bgc_DON(n,:),vname_in,"mmol/m^3",tstr3Da, tcstr, &
    3236             :                 "bulk DON conc. ", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3237           0 :                 ns, f_bgc_DON)
    3238             :          enddo
    3239             :        endif
    3240           0 :        if (f_bgc_Fed (1:1) /= 'x') then
    3241           0 :          do n=1,n_fed
    3242           0 :             write(nchar,'(i3.3)') n
    3243           0 :             write(vname_in,'(a,a)') 'bgc_Fed', trim(nchar)
    3244             :             call define_hist_field(n_bgc_Fed (n,:),vname_in,"umol/m^3",tstr3Da, tcstr, &
    3245             :                 "bulk dFe conc. ", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3246           0 :                 ns, f_bgc_Fed )
    3247             :          enddo
    3248             :        endif
    3249           0 :        if (f_bgc_Fep (1:1) /= 'x') then
    3250           0 :          do n=1,n_fep
    3251           0 :             write(nchar,'(i3.3)') n
    3252           0 :             write(vname_in,'(a,a)') 'bgc_Fep', trim(nchar)
    3253             :             call define_hist_field(n_bgc_Fep (n,:),vname_in,"umol/m^3",tstr3Da, tcstr, &
    3254             :                 "bulk pFe conc. ", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3255           0 :                 ns, f_bgc_Fep )
    3256             :          enddo
    3257             :        endif
    3258             : 
    3259           0 :        if (f_bgc_Sil(1:1) /= 'x') &
    3260             :             call define_hist_field(n_bgc_Sil,"bgc_Sil","mmol/m^3",tstr3Da, tcstr, &   ! LCOV_EXCL_LINE
    3261             :                 "bulk silicate ", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3262           0 :                 ns, f_bgc_Sil)
    3263             : 
    3264           0 :        if (f_bgc_hum(1:1) /= 'x') &
    3265             :             call define_hist_field(n_bgc_hum,"bgc_hum","mmol/m^3",tstr3Da, tcstr, &   ! LCOV_EXCL_LINE
    3266             :                 "bulk humic (carbon) material ", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3267           0 :                 ns, f_bgc_hum)
    3268             : 
    3269           0 :        if (f_bgc_DMSPp(1:1) /= 'x') &
    3270             :             call define_hist_field(n_bgc_DMSPp,"bgc_DMSPp","mmol/m^3",tstr3Da, tcstr, &   ! LCOV_EXCL_LINE
    3271             :                 "bulk algal DMSP ", "snow+bio grid", c1, c0,&   ! LCOV_EXCL_LINE
    3272           0 :                 ns, f_bgc_DMSPp)
    3273             : 
    3274           0 :        if (f_bgc_DMSPd(1:1) /= 'x') &
    3275             :             call define_hist_field(n_bgc_DMSPd,"bgc_DMSPd","mmol/m^3",tstr3Da, tcstr, &   ! LCOV_EXCL_LINE
    3276             :                 "bulk dissolved DMSP ", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3277           0 :                 ns, f_bgc_DMSPd)
    3278             : 
    3279           0 :        if (f_bgc_DMS(1:1) /= 'x') &
    3280             :             call define_hist_field(n_bgc_DMS,"bgc_DMS","mmol/m^3",tstr3Da, tcstr, &   ! LCOV_EXCL_LINE
    3281             :                 "bulk DMS gas ", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3282           0 :                 ns, f_bgc_DMS)
    3283             : 
    3284           0 :        if (f_bgc_PON(1:1) /= 'x') &
    3285             :             call define_hist_field(n_bgc_PON,"bgc_PON","mmol/m^3",tstr3Da, tcstr, &   ! LCOV_EXCL_LINE
    3286             :                 "other bulk nitrogen pool ", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3287           0 :                 ns, f_bgc_PON)
    3288             : 
    3289             :        !--------------------------------------------
    3290             :        !   Category 1 BGC
    3291             :        !----------------------------------------------
    3292             : 
    3293           0 :        if (f_bgc_Nit_cat1(1:1) /= 'x') &
    3294             :             call define_hist_field(n_bgc_Nit_cat1,"bgc_Nit_cat1","mmol/m^3",tstr3Da, tcstr, &   ! LCOV_EXCL_LINE
    3295             :                 "bulk nitrate in cat 1 ", "snow+bio grid", c1, c0,     &   ! LCOV_EXCL_LINE
    3296           0 :                 ns, f_bgc_Nit_cat1)
    3297             : 
    3298           0 :        if (f_bgc_Am_cat1(1:1) /= 'x') &
    3299             :             call define_hist_field(n_bgc_Am_cat1,"bgc_Am_cat1","mmol/m^3",tstr3Da, tcstr, &   ! LCOV_EXCL_LINE
    3300             :                 "bulk ammonia/um in cat 1", "snow+bio grid", c1, c0,  &   ! LCOV_EXCL_LINE
    3301           0 :                 ns, f_bgc_Am_cat1)
    3302             : 
    3303           0 :        if (f_bgc_N_cat1(1:1) /= 'x') then
    3304           0 :          do n=1,n_algae
    3305           0 :             write(nchar,'(i3.3)') n
    3306           0 :             write(vname_in,'(a,a)') 'bgc_N_cat1', trim(nchar)
    3307             :             call define_hist_field(n_bgc_N_cat1(n,:),vname_in,"mmol/m^3",tstr3Da, tcstr, &
    3308             :                 "bulk algal N conc. in cat 1", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3309           0 :                 ns, f_bgc_N_cat1)
    3310             :          enddo
    3311             :        endif
    3312           0 :        if (f_bgc_DOC_cat1(1:1) /= 'x') then
    3313           0 :          do n=1,n_doc
    3314           0 :             write(nchar,'(i3.3)') n
    3315           0 :             write(vname_in,'(a,a)') 'bgc_DOC_cat1', trim(nchar)
    3316             :             call define_hist_field(n_bgc_DOC_cat1(n,:),vname_in,"mmol/m^3",tstr3Da, tcstr, &
    3317             :                 "bulk DOC conc. in cat 1 ", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3318           0 :                 ns, f_bgc_DOC_cat1)
    3319             :          enddo
    3320             :        endif
    3321           0 :        if (f_bgc_DIC_cat1(1:1) /= 'x') then
    3322           0 :          do n=1,n_dic
    3323           0 :             write(nchar,'(i3.3)') n
    3324           0 :             write(vname_in,'(a,a)') 'bgc_DIC_cat1', trim(nchar)
    3325             :             call define_hist_field(n_bgc_DIC_cat1(n,:),vname_in,"mmol/m^3",tstr3Da, tcstr, &
    3326             :                 "bulk DIC conc. in cat 1", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3327           0 :                 ns, f_bgc_DIC_cat1)
    3328             :          enddo
    3329             :        endif
    3330           0 :        if (f_bgc_DON_cat1(1:1) /= 'x') then
    3331           0 :          do n=1,n_don
    3332           0 :             write(nchar,'(i3.3)') n
    3333           0 :             write(vname_in,'(a,a)') 'bgc_DON_cat1', trim(nchar)
    3334             :             call define_hist_field(n_bgc_DON_cat1(n,:),vname_in,"mmol/m^3",tstr3Da, tcstr, &
    3335             :                 "bulk DON conc. in cat 1", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3336           0 :                 ns, f_bgc_DON_cat1)
    3337             :          enddo
    3338             :        endif
    3339           0 :        if (f_bgc_Fed_cat1 (1:1) /= 'x') then
    3340           0 :          do n=1,n_fed
    3341           0 :             write(nchar,'(i3.3)') n
    3342           0 :             write(vname_in,'(a,a)') 'bgc_Fed_cat1', trim(nchar)
    3343             :             call define_hist_field(n_bgc_Fed_cat1 (n,:),vname_in,"umol/m^3",tstr3Da, tcstr, &
    3344             :                 "bulk dFe conc. in cat 1 ", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3345           0 :                 ns, f_bgc_Fed_cat1 )
    3346             :          enddo
    3347             :        endif
    3348           0 :        if (f_bgc_Fep_cat1 (1:1) /= 'x') then
    3349           0 :          do n=1,n_fep
    3350           0 :             write(nchar,'(i3.3)') n
    3351           0 :             write(vname_in,'(a,a)') 'bgc_Fep_cat1', trim(nchar)
    3352             :             call define_hist_field(n_bgc_Fep_cat1 (n,:),vname_in,"umol/m^3",tstr3Da, tcstr, &
    3353             :                 "bulk pFe conc. in cat 1", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3354           0 :                 ns, f_bgc_Fep_cat1 )
    3355             :          enddo
    3356             :        endif
    3357             : 
    3358           0 :        if (f_bgc_Sil_cat1(1:1) /= 'x') &
    3359             :             call define_hist_field(n_bgc_Sil_cat1,"bgc_Sil_cat1","mmol/m^3",tstr3Da, tcstr, &   ! LCOV_EXCL_LINE
    3360             :                 "bulk silicate in cat 1", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3361           0 :                 ns, f_bgc_Sil_cat1)
    3362             : 
    3363           0 :        if (f_bgc_hum_cat1(1:1) /= 'x') &
    3364             :             call define_hist_field(n_bgc_hum,"bgc_hum_cat1","mmol/m^3",tstr3Da, tcstr, &   ! LCOV_EXCL_LINE
    3365             :                 "bulk humic (carbon) material in cat 1", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3366           0 :                 ns, f_bgc_hum_cat1)
    3367             : 
    3368           0 :        if (f_bgc_DMSPd_cat1(1:1) /= 'x') &
    3369             :             call define_hist_field(n_bgc_DMSPd_cat1,"bgc_DMSPd_cat1","mmol/m^3",tstr3Da, tcstr, &   ! LCOV_EXCL_LINE
    3370             :                 "bulk dissolved DMSP in cat 1", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3371           0 :                 ns, f_bgc_DMSPd_cat1)
    3372             : 
    3373           0 :        if (f_bgc_DMS_cat1(1:1) /= 'x') &
    3374             :             call define_hist_field(n_bgc_DMS_cat1,"bgc_DMS_cat1","mmol/m^3",tstr3Da, tcstr, &   ! LCOV_EXCL_LINE
    3375             :                 "bulk DMS gas in cat 1", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3376           0 :                 ns, f_bgc_DMS_cat1)
    3377             : 
    3378           0 :        if (f_bgc_PON_cat1(1:1) /= 'x') &
    3379             :             call define_hist_field(n_bgc_PON_cat1,"bgc_PON_cat1","mmol/m^3",tstr3Da, tcstr, &   ! LCOV_EXCL_LINE
    3380             :                 "other bulk nitrogen pool in cat 1", "snow+bio grid", c1, c0, &   ! LCOV_EXCL_LINE
    3381           0 :                 ns, f_bgc_PON_cat1)
    3382             : 
    3383             :        endif ! histfreq(ns) /= 'x'
    3384             :     enddo  !ns
    3385             : 
    3386             :     endif ! z_tracers
    3387             : 
    3388          37 :       end subroutine init_hist_bgc_3Da
    3389             : 
    3390             : !=======================================================================
    3391             : 
    3392             : ! Initialize bgc fields written to history files
    3393             : !
    3394             : ! authors: Nicole Jeffery, LANL
    3395             : !          Elizabeth C. Hunke, LANL
    3396             : 
    3397        5784 :       subroutine init_history_bgc
    3398             : 
    3399             :       use ice_arrays_column, only: PP_net, grow_net, hbri, &
    3400             :           ice_bio_net, snow_bio_net, fbio_snoice, fbio_atmice, &   ! LCOV_EXCL_LINE
    3401             :           zfswin
    3402             :       use ice_flux_bgc, only: flux_bio, flux_bio_ai, fnit, fsil, &
    3403             :           famm, fdmsp, fdms, fhum, fdust, falgalN, fdoc, fdic, &   ! LCOV_EXCL_LINE
    3404             :           fdon, ffep, ffed
    3405             : 
    3406             :       character(len=*), parameter :: subname = '(init_history_bgc)'
    3407             : 
    3408    16221984 :       PP_net        (:,:,:) = c0
    3409    16221984 :       grow_net      (:,:,:) = c0
    3410    16221984 :       hbri          (:,:,:) = c0
    3411   470298648 :       flux_bio    (:,:,:,:) = c0
    3412   470298648 :       flux_bio_ai (:,:,:,:) = c0
    3413   470298648 :       ice_bio_net (:,:,:,:) = c0
    3414   470298648 :       snow_bio_net(:,:,:,:) = c0
    3415   470298648 :       fbio_snoice (:,:,:,:) = c0
    3416   470298648 :       fbio_atmice (:,:,:,:) = c0
    3417   162306168 :       zfswin    (:,:,:,:,:) = c0
    3418    16221984 :       fnit          (:,:,:) = c0
    3419    16221984 :       fsil          (:,:,:) = c0
    3420    16221984 :       famm          (:,:,:) = c0
    3421    16221984 :       fdmsp         (:,:,:) = c0
    3422    16221984 :       fdms          (:,:,:) = c0
    3423    16221984 :       fhum          (:,:,:) = c0
    3424    16221984 :       fdust         (:,:,:) = c0
    3425    48677448 :       falgalN     (:,:,:,:) = c0
    3426    48677448 :       fdoc        (:,:,:,:) = c0
    3427    16245048 :       fdic        (:,:,:,:) = c0
    3428    16245048 :       fdon        (:,:,:,:) = c0
    3429    32461248 :       ffep        (:,:,:,:) = c0
    3430    32461248 :       ffed        (:,:,:,:) = c0
    3431             : 
    3432        5784 :       end subroutine init_history_bgc
    3433             : 
    3434             : !=======================================================================
    3435             : 
    3436             :       end module ice_history_bgc
    3437             : 
    3438             : !=======================================================================

Generated by: LCOV version 1.14-6-g40580cd