organic_mineral_mass_module.f90 Source File


This file depends on

sourcefile~~organic_mineral_mass_module.f90~~EfferentGraph sourcefile~organic_mineral_mass_module.f90 organic_mineral_mass_module.f90 sourcefile~carbon_module.f90 carbon_module.f90 sourcefile~organic_mineral_mass_module.f90->sourcefile~carbon_module.f90

Files dependent on this one

sourcefile~~organic_mineral_mass_module.f90~~AfferentGraph sourcefile~organic_mineral_mass_module.f90 organic_mineral_mass_module.f90 sourcefile~actions.f90 actions.f90 sourcefile~actions.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~albedo.f90 albedo.f90 sourcefile~albedo.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~basin_read_objs.f90 basin_read_objs.f90 sourcefile~basin_read_objs.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~cal_allo_init.f90 cal_allo_init.f90 sourcefile~cal_allo_init.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~cal_parm_select.f90 cal_parm_select.f90 sourcefile~cal_parm_select.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~calsoft_hyd.f90 calsoft_hyd.f90 sourcefile~calsoft_hyd.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~calsoft_hyd_bfr.f90 calsoft_hyd_bfr.f90 sourcefile~calsoft_hyd_bfr.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~calsoft_hyd_bfr_et.f90 calsoft_hyd_bfr_et.f90 sourcefile~calsoft_hyd_bfr_et.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~calsoft_hyd_bfr_latq.f90 calsoft_hyd_bfr_latq.f90 sourcefile~calsoft_hyd_bfr_latq.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~calsoft_hyd_bfr_perc.f90 calsoft_hyd_bfr_perc.f90 sourcefile~calsoft_hyd_bfr_perc.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~calsoft_hyd_bfr_pet.f90 calsoft_hyd_bfr_pet.f90 sourcefile~calsoft_hyd_bfr_pet.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~calsoft_hyd_bfr_surq.f90 calsoft_hyd_bfr_surq.f90 sourcefile~calsoft_hyd_bfr_surq.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~calsoft_read_codes.f90 calsoft_read_codes.f90 sourcefile~calsoft_read_codes.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~calsoft_sed.f90 calsoft_sed.f90 sourcefile~calsoft_sed.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~cbn_zhang2.f90 cbn_zhang2.f90 sourcefile~cbn_zhang2.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~command.f90 command.f90 sourcefile~command.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~conditions.f90 conditions.f90 sourcefile~conditions.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~cs_balance.f90 cs_balance.f90 sourcefile~cs_balance.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~cs_cha_read.f90 cs_cha_read.f90 sourcefile~cs_cha_read.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~cs_hru_init.f90 cs_hru_init.f90 sourcefile~cs_hru_init.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~cs_rain.f90 cs_rain.f90 sourcefile~cs_rain.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~cs_rctn_aqu.f90 cs_rctn_aqu.f90 sourcefile~cs_rctn_aqu.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~cs_rctn_hru.f90 cs_rctn_hru.f90 sourcefile~cs_rctn_hru.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~cs_sorb_aqu.f90 cs_sorb_aqu.f90 sourcefile~cs_sorb_aqu.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~cs_sorb_hru.f90 cs_sorb_hru.f90 sourcefile~cs_sorb_hru.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~cs_uptake.f90 cs_uptake.f90 sourcefile~cs_uptake.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~dr_read.f90 dr_read.f90 sourcefile~dr_read.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~dr_read_hmet.f90 dr_read_hmet.f90 sourcefile~dr_read_hmet.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~dr_read_om.f90 dr_read_om.f90 sourcefile~dr_read_om.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~dr_read_path.f90 dr_read_path.f90 sourcefile~dr_read_path.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~dr_read_pest.f90 dr_read_pest.f90 sourcefile~dr_read_pest.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~dr_read_salt.f90 dr_read_salt.f90 sourcefile~dr_read_salt.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~ero_ovrsed.f90 ero_ovrsed.f90 sourcefile~ero_ovrsed.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~et_act.f90 et_act.f90 sourcefile~et_act.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~exco_read.f90 exco_read.f90 sourcefile~exco_read.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~exco_read_hmet.f90 exco_read_hmet.f90 sourcefile~exco_read_hmet.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~exco_read_om.f90 exco_read_om.f90 sourcefile~exco_read_om.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~exco_read_path.f90 exco_read_path.f90 sourcefile~exco_read_path.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~exco_read_pest.f90 exco_read_pest.f90 sourcefile~exco_read_pest.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~exco_read_salt.f90 exco_read_salt.f90 sourcefile~exco_read_salt.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~gwflow_ppag.f90 gwflow_ppag.f90 sourcefile~gwflow_ppag.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~hru_allo.f90 hru_allo.f90 sourcefile~hru_allo.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~hru_carbon_output.f90 hru_carbon_output.f90 sourcefile~hru_carbon_output.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~hru_control.f90 hru_control.f90 sourcefile~hru_control.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~hru_output.f90 hru_output.f90 sourcefile~hru_output.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~hyd_connect.f90 hyd_connect.f90 sourcefile~hyd_connect.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~hydro_init.f90 hydro_init.f90 sourcefile~hydro_init.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~layersplit.f90 layersplit.f90 sourcefile~layersplit.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~lsreg_output.f90 lsreg_output.f90 sourcefile~lsreg_output.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~mallo_control.f90 mallo_control.f90 sourcefile~mallo_control.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~mgt_harvbiomass.f90 mgt_harvbiomass.f90 sourcefile~mgt_harvbiomass.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~mgt_harvgrain.f90 mgt_harvgrain.f90 sourcefile~mgt_harvgrain.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~mgt_harvresidue.f90 mgt_harvresidue.f90 sourcefile~mgt_harvresidue.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~mgt_harvtuber.f90 mgt_harvtuber.f90 sourcefile~mgt_harvtuber.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~mgt_killop.f90 mgt_killop.f90 sourcefile~mgt_killop.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~mgt_newtillmix.f90 mgt_newtillmix.f90 sourcefile~mgt_newtillmix.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~mgt_newtillmix_wet.f90 mgt_newtillmix_wet.f90 sourcefile~mgt_newtillmix_wet.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~mgt_plantop.f90 mgt_plantop.f90 sourcefile~mgt_plantop.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~mgt_sched.f90 mgt_sched.f90 sourcefile~mgt_sched.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~mgt_transplant.f90 mgt_transplant.f90 sourcefile~mgt_transplant.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~nut_denit.f90 nut_denit.f90 sourcefile~nut_denit.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~nut_nitvol.f90 nut_nitvol.f90 sourcefile~nut_nitvol.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~nut_nlch.f90 nut_nlch.f90 sourcefile~nut_nlch.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~nut_nminrl.f90 nut_nminrl.f90 sourcefile~nut_nminrl.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~nut_nrain.f90 nut_nrain.f90 sourcefile~nut_nrain.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~nut_orgn.f90 nut_orgn.f90 sourcefile~nut_orgn.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~nut_orgnc.f90 nut_orgnc.f90 sourcefile~nut_orgnc.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~nut_orgnc2.f90 nut_orgnc2.f90 sourcefile~nut_orgnc2.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~nut_pminrl.f90 nut_pminrl.f90 sourcefile~nut_pminrl.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~nut_pminrl2.f90 nut_pminrl2.f90 sourcefile~nut_pminrl2.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~nut_psed.f90 nut_psed.f90 sourcefile~nut_psed.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~nut_solp.f90 nut_solp.f90 sourcefile~nut_solp.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~obj_output.f90 obj_output.f90 sourcefile~obj_output.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~path_cha_res_read.f90 path_cha_res_read.f90 sourcefile~path_cha_res_read.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pathogen_init.f90 pathogen_init.f90 sourcefile~pathogen_init.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pest_cha_res_read.f90 pest_cha_res_read.f90 sourcefile~pest_cha_res_read.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pest_lch.f90 pest_lch.f90 sourcefile~pest_lch.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pest_pesty.f90 pest_pesty.f90 sourcefile~pest_pesty.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pesticide_init.f90 pesticide_init.f90 sourcefile~pesticide_init.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pl_biomass_gro.f90 pl_biomass_gro.f90 sourcefile~pl_biomass_gro.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pl_burnop.f90 pl_burnop.f90 sourcefile~pl_burnop.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pl_community.f90 pl_community.f90 sourcefile~pl_community.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pl_dormant.f90 pl_dormant.f90 sourcefile~pl_dormant.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pl_fert.f90 pl_fert.f90 sourcefile~pl_fert.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pl_fert_wet.f90 pl_fert_wet.f90 sourcefile~pl_fert_wet.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pl_graze.f90 pl_graze.f90 sourcefile~pl_graze.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pl_grow.f90 pl_grow.f90 sourcefile~pl_grow.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pl_leaf_gro.f90 pl_leaf_gro.f90 sourcefile~pl_leaf_gro.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pl_leaf_senes.f90 pl_leaf_senes.f90 sourcefile~pl_leaf_senes.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pl_manure.f90 pl_manure.f90 sourcefile~pl_manure.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pl_mortality.f90 pl_mortality.f90 sourcefile~pl_mortality.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pl_nfix.f90 pl_nfix.f90 sourcefile~pl_nfix.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pl_nup.f90 pl_nup.f90 sourcefile~pl_nup.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pl_nupd.f90 pl_nupd.f90 sourcefile~pl_nupd.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pl_nut_demand.f90 pl_nut_demand.f90 sourcefile~pl_nut_demand.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pl_partition.f90 pl_partition.f90 sourcefile~pl_partition.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pl_pup.f90 pl_pup.f90 sourcefile~pl_pup.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pl_pupd.f90 pl_pupd.f90 sourcefile~pl_pupd.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~pl_root_gro.f90 pl_root_gro.f90 sourcefile~pl_root_gro.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~plant_init.f90 plant_init.f90 sourcefile~plant_init.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~re_initialize.f90 re_initialize.f90 sourcefile~re_initialize.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~recall_read.f90 recall_read.f90 sourcefile~recall_read.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~recall_read_cs.f90 recall_read_cs.f90 sourcefile~recall_read_cs.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~recall_read_salt.f90 recall_read_salt.f90 sourcefile~recall_read_salt.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~rls_routeaqu.f90 rls_routeaqu.f90 sourcefile~rls_routeaqu.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~rls_routetile.f90 rls_routetile.f90 sourcefile~rls_routetile.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~rsd_decomp.f90 rsd_decomp.f90 sourcefile~rsd_decomp.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~salt_balance.f90 salt_balance.f90 sourcefile~salt_balance.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~salt_cha_read.f90 salt_cha_read.f90 sourcefile~salt_cha_read.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~salt_chem_hru.f90 salt_chem_hru.f90 sourcefile~salt_chem_hru.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~salt_hru_init.f90 salt_hru_init.f90 sourcefile~salt_hru_init.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~salt_rain.f90 salt_rain.f90 sourcefile~salt_rain.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~salt_roadsalt.f90 salt_roadsalt.f90 sourcefile~salt_roadsalt.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~salt_uptake.f90 salt_uptake.f90 sourcefile~salt_uptake.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~sep_biozone.f90 sep_biozone.f90 sourcefile~sep_biozone.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~sim_initday.f90 sim_initday.f90 sourcefile~sim_initday.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~soil_nutcarb_init.f90 soil_nutcarb_init.f90 sourcefile~soil_nutcarb_init.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~soil_nutcarb_write.f90 soil_nutcarb_write.f90 sourcefile~soil_nutcarb_write.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~soils_init.f90 soils_init.f90 sourcefile~soils_init.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~stmp_solt.f90 stmp_solt.f90 sourcefile~stmp_solt.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~swr_depstor.f90 swr_depstor.f90 sourcefile~swr_depstor.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~swr_satexcess.f90 swr_satexcess.f90 sourcefile~swr_satexcess.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~swr_subwq.f90 swr_subwq.f90 sourcefile~swr_subwq.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~treat_read_om.f90 treat_read_om.f90 sourcefile~treat_read_om.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~wallo_control.f90 wallo_control.f90 sourcefile~wallo_control.f90->sourcefile~organic_mineral_mass_module.f90 sourcefile~wetland_control.f90 wetland_control.f90 sourcefile~wetland_control.f90->sourcefile~organic_mineral_mass_module.f90

Source Code

      module organic_mineral_mass_module
    
      use carbon_module, only: organic_flux

      implicit none 

      type organic_mass
        real :: m = 0.              !kg/ha      |total object mass
        real :: c = 0.              !kg/ha      |carbon mass
        real :: n = 0.              !kg/ha      |organic nitrogen mass
        real :: p = 0.              !kg/ha      |organic phosphorus mass
      end type organic_mass
      type (organic_mass) :: orgz

      type organic_mixing_mass
        type (organic_mass) :: tot       !       |total organic pool
        type (organic_mass) :: rsd       !       |fresh residue-all plants in one pool - layer 1 = surface residue
        !! humus pools for old mineralization model (static carbon)
        type (organic_mass) :: hact      !       |active humus for old mineralization model
        type (organic_mass) :: hsta      !       |stable humus for old mineralization model
        !! organic pools used in CENTURY model
        type (organic_mass) :: hs        !       |slow humus
        type (organic_mass) :: hp        !       |passive humus
        type (organic_mass) :: microb    !       |microbial biomass
        type (organic_mass) :: str       !       |structural litter pool
        type (organic_mass) :: lig       !       |lignin pool
        type (organic_mass) :: meta      !       |metabolic litter pool
        type (organic_mass) :: man       !       |manure pool
        type (organic_mass) :: water     !       |water soluble
      end type organic_mixing_mass
      type (organic_mixing_mass) :: mix_org

      type clay_mass
        real :: m = 0.              !kg or kg/ha      |total object mass
        real :: nh4 = 0.            !kg or kg/ha      |ammonium mass
      end type clay_mass
      
      type sediment
        real :: m = 0.              !kg or kg/ha      |total object mass
        real :: sand = 0.           !kg or kg/ha      |sand mass
        real :: silt = 0.           !kg or kg/ha      |silt mass
        type (clay_mass) :: clay    !kg or kg/ha      |clay mass
        real :: gravel = 0.         !kg or kg/ha      |gravel mass
      end type sediment
      
      type mineral_nitrogen
        real :: no3 = 0.            !kg/ha  |nitrate dimensioned by layer
        real :: nh4 = 0.            !kg/ha  |ammonium dimensioned by layer
      end type mineral_nitrogen
      type (mineral_nitrogen) :: mnz
      type (mineral_nitrogen) :: mix_mn    !       |mineral n pool used in tillage mixing
            
      type mineral_phosphorus
        real :: wsol = 0.           !kg/ha  |water soluble p dimensioned by layer
        real :: lab = 0.            !kg/ha  |labile p dimensioned by layer
        real :: act = 0.            !kg/ha  |active mineral p dimensioned by layer
        real :: sta = 0.            !kg/ha  |stable mineral p dimensioned by layer
      end type mineral_phosphorus
      type (mineral_phosphorus) :: mpz
      type (mineral_phosphorus) :: mix_mp    !       |mineral p pool used in tillage mixing
      
      type soil_profile_mass
        character (len=16) :: name = ""
        real :: tot_mn = 0.                                         !       |total mineral n pool (no3+nh4) in soil profile
        real :: tot_mp = 0.                                         !       |mineral p pool (wsol+lab+act+sta) in soil profile
        real :: salt = 0.                                           !       |total salt amount (kg/ha) in soil profile
        type (organic_mass) :: tot_org                              !       |total organics in soil profile
        real, dimension(:), allocatable :: sw                       !mm     |soil water dimensioned by layer
        real, dimension(:), allocatable :: cbn                      !%      |percent carbon
        type (sediment), dimension(:), allocatable :: sed           !       |sediment dimensioned by layer
        type (mineral_nitrogen), dimension(:), allocatable :: mn    !       |mineral n pool dimensioned by layer
        type (mineral_phosphorus), dimension(:), allocatable :: mp  !       |mineral p humus pool dimensioned by layer
        !! tot and rsd used for both carbon methods
        type (organic_mass), dimension(:), allocatable :: tot       !       |total organic pool dimensioned by layer
        type (organic_mass), dimension(:), allocatable :: rsd       !       |fresh residue-all plants in one pool by layer - layer 1 = surface residue
        !! humus pools for old mineralization model (static carbon)
        type (organic_flux)                            :: org_flx_cum_tot ! |cumulative organic flux for soil profile
        type (organic_flux), dimension(:), allocatable :: org_flx_lr !      |organic flux by layer
        type (organic_flux), dimension(:), allocatable :: org_flx_cum_lr !  |cumulative organic flux by layer
        type (organic_mass), dimension(:), allocatable :: hact      !       |active humus for old mineralization model dimensioned by layer
        type (organic_mass), dimension(:), allocatable :: hsta      !       |stable humus for old mineralization model dimensioned by layer
        !! organic pools used in CENTURY model
        type (organic_mass), dimension(:), allocatable :: hs        !       |slow humus dimensioned by layer
        type (organic_mass), dimension(:), allocatable :: hp        !       |passive humus dimensioned by layer
		
        !! rest are used in CENTURY model
        type (organic_mass), dimension(:), allocatable :: microb    !       |microbial biomass
        type (organic_mass), dimension(:), allocatable :: str       !       |structural litter pool dimensioned by layer
        type (organic_mass), dimension(:), allocatable :: lig       !       |lignin pool dimensioned by layer
        type (organic_mass), dimension(:), allocatable :: meta      !       |metabolic litter pool dimensioned by layer
        type (organic_mass), dimension(:), allocatable :: man       !       |manure pool dimensioned by layer
        type (organic_mass), dimension(:), allocatable :: water     !       |water soluble
      end type soil_profile_mass
      
      !soil profile object - dimensioned to number of hrus, using the hru pointer
      type (soil_profile_mass), dimension(:), allocatable, target :: soil1
      type (soil_profile_mass), dimension(:), allocatable :: soil1_init
      type (organic_mass) :: soil_prof_tot                          !       |total organic pool for profile (summed by layer)
      type (organic_mass) :: soil_prof_rsd                          !       |total fresh organic residue pool for profile (summed by lower layers)
      type (organic_mass) :: soil_prof_srsd                         !       |total fresh organic residue pool for surface
      type (organic_mass) :: soil_prof_hact                         !       |total active humus pool for profile (summed by layer)
      type (organic_mass) :: soil_prof_hsta                         !       |total stable huumus pool for profile (summed by layer)
      type (organic_mass) :: soil_prof_hs                           !       |total slow humus pool for profile (summed by layer)
      type (organic_mass) :: soil_prof_hp                           !       |total passive humus pool for profile (summed by layer)
      type (organic_mass) :: soil_prof_microb                       !       |total microbial pool for profile (summed by layer)
      type (organic_mass) :: soil_prof_str                          !       |total structural pool for profile (summed by layer)
      type (organic_mass) :: soil_prof_lig                          !       |total lignin pool for profile (summed by layer)
      type (organic_mass) :: soil_prof_meta                         !       |total metabolic pool for profile (summed by layer)
      type (organic_mass) :: soil_prof_sstr                         !       |total structural pool for surface (summed by lower layers)
      type (organic_mass) :: soil_prof_slig                         !       |total lignin pool for suface (summed by lower layers)
      type (organic_mass) :: soil_prof_smeta                         !       |total metabolic pool for profile (summed by layer)
      type (organic_mass) :: soil_prof_man                          !       |total manure pool for profile (summed by layer)
      type (organic_mass) :: soil_prof_water                        !       |total dissolved pool for profile (summed by layer)
      type (organic_mass) :: soil_org_z                             !       |used to zero organic objects
      type (organic_mass) :: soil_prof_somc
      type (mineral_nitrogen) :: soil_prof_mn                       !       |mineral n pool (summed by layer)
      type (mineral_phosphorus) :: soil_prof_mp                     !       |mineral p  pool (summed by layer)
      type (mineral_nitrogen) :: soil_mn_z
      type (mineral_phosphorus) :: soil_mp_z
      type (organic_mass) :: bsn_org_soil                           !       |total soil organics in basin
      type (organic_mass) :: bsn_org_pl                             !       |total plant organics in basin
      type (organic_mass) :: bsn_org_rsd                            !       |total residue organics in basin
      real :: bsn_mn = 0.                                           !       |total mineral n pool (no3+nh4) in basin
      real :: bsn_mp = 0.                                           !       |mineral p pool (wsol+lab+act+sta) in basin
      type (organic_mass) :: decomp                                 !       |temporary storage for residue decomp
      type (organic_mass) :: pl_burn                                !       |residue and plant mass burned in fire
      type (organic_mass) :: rsd_meta                               !       |temporary storage for initial metabolic litter
      type (organic_mass) :: rsd_str                                !       |temporary storage for initial structural litter
      
      type plant_community_mass
       character(len=4) :: name = ""
       type (organic_mass), dimension(:), allocatable :: tot        !kg/ha      |total biomass for individual plant in community
       type (organic_mass), dimension(:), allocatable :: ab_gr      !kg/ha      |above ground biomass for individual plant in community
       type (organic_mass), dimension(:), allocatable :: leaf       !kg/ha      |leaf mass for individual plant in community
       type (organic_mass), dimension(:), allocatable :: stem       !kg/ha      |wood/stalk mass for individual plant in community
       type (organic_mass), dimension(:), allocatable :: root       !kg/ha      |root mass for individual plant in community (by soil layer)
       type (organic_mass), dimension(:), allocatable :: seed       !kg/ha      |seed (grain) mass for individual plant in community
       type (organic_mass), dimension(:), allocatable :: yield_tot  !kg/ha      |running total sum of yield at harvest -  ave annual print
       type (organic_mass), dimension(:), allocatable :: yield_yr   !kg/ha      |running yearly sum of yield at harvest - yearly print
       type (organic_mass) :: tot_com                               !kg/ha      |total biomass for entire community
       type (organic_mass) :: ab_gr_com                             !kg/ha      |above ground mass for entire community
       type (organic_mass) :: leaf_com                              !kg/ha      |leaf mass for entire community
       type (organic_mass) :: stem_com                              !kg/ha      |wood/stalk mass for entire community
       type (organic_mass) :: root_com                              !kg/ha      |root mass for entire community
       type (organic_mass) :: seed_com                              !kg/ha      |seed (grain) mass for entire community
      end type plant_community_mass
      
      type (plant_community_mass), dimension (:), allocatable :: pl_mass
      type (plant_community_mass), dimension (:), allocatable :: pl_mass_init
      type (organic_mass) :: pl_yield                               !kg/ha      |crop yield
      type (organic_mass) :: pl_mass_up                             !kg/ha      |daily biomass and c increase; n and p uptake
      type (organic_mass) :: pl_residue
      type (organic_mass) :: harv_seed, harv_leaf, harv_stem, harv_left
      type (organic_mass) :: graz_plant, graz_seed, graz_leaf, graz_stem
      type (organic_mass) :: leaf_drop                              !kg/ha      |organic mass of falling leaves
      type (organic_mass) :: abgr_drop                              !kg/ha      |above ground that dies at dormancy
      type (organic_mass) :: stem_drop                              !kg/ha      |stem that dies at dormancy
      type (organic_mass) :: seed_drop                              !kg/ha      |seed that dies at dormancy
      type (organic_mass) :: plt_mass_z

      type mineral_mass
        real :: m = 0.          !kg or kg/ha      |total object mass
        real :: no3 = 0.        !kg or kg/ha      |nitrate mass
        real :: no2 = 0.        !kg or kg/ha      |nitrite mass
        real :: nh4 = 0.        !kg or kg/ha      |ammonium mass  
        real :: po4 = 0.        !kg or kg/ha      |phosphate mass 
      end type mineral_mass

      type organic_mineral_mass
        real :: vol = 0.
        type (organic_mass) :: hum
        type (organic_mass) :: hum_act
        type (mineral_mass) :: min
      end type organic_mineral_mass
      
      !hru will point diretly to herds - managed in schedule_ops and ultimately can be managed in conditional subroutine
      !herds are different from soil and plant in that they can move from hru to hru
      type animal_herds
        character(len=16) :: name = ""                                      !           |herd name (small_dairy, )
        integer :: num_tot = 0                                              !           |total number of animals in the herd
        type (organic_mass) :: herd_mass                                    !kg         |total mass of herd
        character(len=16), dimension(:), allocatable :: typ                 !           |animal type (points to animal.hrd)
        integer, dimension(:), allocatable :: num                           !           |number of each type of animal
        type (organic_mass), dimension(:), allocatable :: mass              !           |mass of each type of animal
        type (organic_mass), dimension(:), allocatable :: eat               !           |biomass eaten by each type of animal
        type (organic_mineral_mass), dimension(:), allocatable :: manure    !           |manure from each type of animal
      end type animal_herds
      
      !fertilizer object      
      type fertilizer_mass
        character (len=16) :: name = ""
        type (mineral_mass) :: org       !soil matrix dimensioned by layer
        type (organic_mass) :: min       !soil water dimensioned by layer
      end type fertilizer_mass
      !fertilizer object should be used as database input from fert.dat
      type (fertilizer_mass), dimension(:), allocatable :: fert         !dimension to number of fertilzers in database
      
      !manure object should be used as database input from manure.dat
      type (organic_mineral_mass), dimension(:), allocatable :: manure  !dimension to number of manures in database
      
      type organic_mineral_hydrograph
        real :: flo = 0.               !! m^3          |volume of water
        real :: sed = 0.               !! metric tons  |sediment
        type (organic_mass) :: org
        type (mineral_mass) :: min
        real :: chla = 0.              !! kg           |chlorophyll-a
        real :: cbod = 0.              !! kg           |carbonaceous biological oxygen demand
        real :: dox = 0.               !! kg           |dissolved oxygen
        real :: temp = 0.              !! deg c        |temperature
        real :: san = 0.               !! tons         |detached sand
        real :: sil = 0.               !! tons         |detached silt
        real :: cla = 0.               !! tons         |detached clay
        real :: sag = 0.               !! tons         |detached small ag
        real :: lag = 0.               !! tons         |detached large ag
        real :: grv = 0.               !! tons         |gravel
      end type organic_mineral_hydrograph
      
      type spatial_object_hydrographs
        character (len=16) :: name = ""                                 !should match the object_connectivity object
        !water and soluble components
        type (organic_mineral_hydrograph) :: hin                                 !inflow hydrograph for surface runon - sum of all inflow hyds
        type (organic_mineral_hydrograph) :: hin_sur                             !inflow hydrograph for surface flow - sum of all surface inflow hyds
        type (organic_mineral_hydrograph) :: hin_lat                             !inflow hydrograph for lateral soil flow - sum of all lateral inflow hyds
        type (organic_mineral_hydrograph) :: hin_til                             !inflow hydrograph for tile flow - sum of all tile inflow hyds
        type (organic_mineral_hydrograph) :: hin_aqu                             !inflow hydrograph for aquifer flow - sum of all aquifer inflow hyds
        type (organic_mineral_hydrograph), dimension(:),allocatable :: hd        !generated hydrograph (ie 1=tot, 2= recharge, 3=surf, etc)
        type (organic_mineral_hydrograph), dimension(:,:),allocatable :: ts      !subdaily hydrographs
        type (organic_mineral_hydrograph), dimension(:),allocatable :: tsin      !inflow subdaily hydrograph
        !sediment (sorbed) in the water components
        type (organic_mineral_hydrograph) :: hins                                 !inflow hydrograph for surface runon - sum of all inflow hyds
        type (organic_mineral_hydrograph) :: hin_ssur                             !inflow hydrograph for surface flow - sum of all surface inflow hyds
        type (organic_mineral_hydrograph) :: hin_slat                             !inflow hydrograph for lateral soil flow - sum of all lateral inflow hyds
        type (organic_mineral_hydrograph) :: hin_stil                             !inflow hydrograph for tile flow - sum of all tile inflow hyds
        type (organic_mineral_hydrograph), dimension(:),allocatable :: hds        !generated hydrograph (ie 1=tot, 2= recharge, 3=surf, etc)
        type (organic_mineral_hydrograph), dimension(:,:),allocatable :: tss      !subdaily hydrographs
        type (organic_mineral_hydrograph), dimension(:),allocatable :: tsins      !inflow subdaily hydrograph
        !hydrograph output variables
        type (organic_mineral_hydrograph), dimension(:),allocatable :: hin_d
        type (organic_mineral_hydrograph), dimension(:),allocatable :: hin_m
        type (organic_mineral_hydrograph), dimension(:),allocatable :: hin_y
        type (organic_mineral_hydrograph), dimension(:),allocatable :: hin_a
        type (organic_mineral_hydrograph), dimension(:),allocatable :: hout_m
        type (organic_mineral_hydrograph), dimension(:),allocatable :: hout_y
        type (organic_mineral_hydrograph), dimension(:),allocatable :: hout_a
        type (organic_mineral_hydrograph) :: hdep_m
        type (organic_mineral_hydrograph) :: hdep_y
        type (organic_mineral_hydrograph) :: hdep_a
      end type spatial_object_hydrographs
      !track spatial_object_hydrographs with ob - use same pointer
      type (spatial_object_hydrographs), dimension(:),allocatable :: obom
      
      !recall organic-mineral inputs
      type recall_organic_mineral_inputs
         character (len=16) :: name = ""
         integer :: num = 0                    !number of elements
         integer :: typ = 0                    !recall type - 1=day, 2=mon, 3=year
         character(len=13) :: filename = ""    !filename
         !hyd_output units are in cms and mg/L
         type (organic_mineral_hydrograph), dimension (:,:), allocatable :: hd_om     !export coefficients
      end type recall_organic_mineral_inputs
      type (recall_organic_mineral_inputs),dimension(:),allocatable:: rec_om

      !export coefficient and delivery ratio pesticides
      type (organic_mineral_hydrograph), dimension(:,:), allocatable :: exco_om
      
      !export coefficient and delivery ratio pesticides
      type (organic_mineral_hydrograph), dimension(:,:), allocatable :: dr_om
      
      type routing_unit_elements_hydrographs
        character (len=16) :: name = ""                              !should match the object_connectivity object
        type (organic_mineral_mass), dimension(:), allocatable :: hd
      end type routing_unit_elements_hydrographs
      !point to subbasin element objects - same as sub_elem
      type (routing_unit_elements_hydrographs), dimension(:), allocatable :: sub_e_hd
      
      type channel_surface_elements_hydrographs
        character (len=16) :: name = ""                              !should match the channel_surface_elements object
        type (organic_mineral_mass), dimension(:), allocatable :: hd
      end type channel_surface_elements_hydrographs
      !point to channel-surface objects - same as ch_sur
      type (channel_surface_elements_hydrographs), dimension(:), allocatable :: ch_sur_hd
      
      !objects needed for operators
      type (organic_mineral_mass) :: o_m1, o_m2, o_m3
      type (mineral_phosphorus) :: pmin_m1, pmin_m2, pmin_m3
      type (mineral_nitrogen) :: nmin_m1, nmin_m2, nmin_m3

      !we may also need operators for organic and mineral operations
      
      interface operator (+)
        module procedure om_add1
      end interface
      
      interface operator (+)
        module procedure org_flux_add1
      end interface
      
      interface operator (-)
        module procedure om_subtract
      end interface
            
      interface operator (*)
        module procedure om_mult_const
      end interface 
                         
      interface operator (/)
        module procedure om_divide
      end interface 
                   
      interface operator (+)
        module procedure pmin_add
        end interface 
                  
      interface operator (*)
        module procedure nmin_mult_const
      end interface 
                  
      interface operator (+)
        module procedure nmin_add
        end interface 

      interface operator (*)
        module procedure pmin_mult_const
      end interface 

    contains

      !! add mineral n
      function nmin_add (nmin_m1, nmin_m2) result (nmin_m3)
        type (mineral_nitrogen), intent (in) :: nmin_m1
        type (mineral_nitrogen), intent (in) :: nmin_m2
        type (mineral_nitrogen) :: nmin_m3
        nmin_m3%no3 = nmin_m1%no3 + nmin_m2%no3
        nmin_m3%nh4 = nmin_m1%nh4 + nmin_m2%nh4
      end function nmin_add
      
      !! multiply mineral n by a constant
      function nmin_mult_const (const, nmin_m1) result (nmin_m2)
        real, intent (in) :: const
        type (mineral_nitrogen), intent (in) :: nmin_m1
        type (mineral_nitrogen) :: nmin_m2
        nmin_m2%no3 = const * nmin_m1%no3
        nmin_m2%nh4 = const * nmin_m1%nh4
      end function nmin_mult_const
                          
      function pmin_add (pmin_m1, pmin_m2) result (pmin_m3)
        type (mineral_phosphorus), intent (in) :: pmin_m1
        type (mineral_phosphorus), intent (in) :: pmin_m2
        type (mineral_phosphorus) :: pmin_m3
        pmin_m3%wsol = pmin_m1%wsol + pmin_m2%wsol
        pmin_m3%lab = pmin_m1%lab + pmin_m2%lab
        pmin_m3%act = pmin_m1%act + pmin_m2%act
        pmin_m3%sta = pmin_m1%sta + pmin_m2%sta
      end function pmin_add

      !! multiply mineral n by a constant
      function pmin_mult_const (const, pmin_m1) result (pmin_m2)
        real, intent (in) :: const
        type (mineral_phosphorus), intent (in) :: pmin_m1
        type (mineral_phosphorus) :: pmin_m2
        pmin_m2%wsol = const * pmin_m1%wsol
        pmin_m2%lab = const * pmin_m1%lab
        pmin_m2%act = const * pmin_m1%act
        pmin_m2%sta = const * pmin_m1%sta
      end function pmin_mult_const
                          
      !! add organic mass
      function om_add1 (o_m1, o_m2) result (o_m3)
        type (organic_mass), intent (in) :: o_m1
        type (organic_mass), intent (in) :: o_m2
        type (organic_mass) :: o_m3
        o_m3%m = o_m1%m + o_m2%m
        o_m3%c = o_m1%c + o_m2%c
        o_m3%n = o_m1%n + o_m2%n
        o_m3%p = o_m1%p + o_m2%p
      end function om_add1
            
      !! subtract organic mass
      function om_subtract (o_m1, o_m2) result (o_m3)
        type (organic_mass), intent (in) :: o_m1
        type (organic_mass), intent (in) :: o_m2
        type (organic_mass) :: o_m3
        o_m3%m = o_m1%m - o_m2%m
        o_m3%c = o_m1%c - o_m2%c
        o_m3%n = o_m1%n - o_m2%n
        o_m3%p = o_m1%p - o_m2%p
      end function om_subtract
                           
      !! multiply organic mass by a constant
      function om_mult_const (const, o_m1) result (o_m2)
        real, intent (in) :: const
        type (organic_mass), intent (in) :: o_m1
        type (organic_mass) :: o_m2
        o_m2%m = const * o_m1%m
        o_m2%c = const * o_m1%c
        o_m2%n = const * o_m1%n
        o_m2%p = const * o_m1%p
      end function om_mult_const
                          
      !! divide organic mass by a constant
      function om_divide (o_m1, const) result (o_m2)
        type (organic_mass), intent (in) :: o_m1
        real, intent (in) :: const 
        type (organic_mass) :: o_m2
        o_m2%m = o_m1%m / const
        o_m2%c = o_m1%c / const
        o_m2%n = o_m1%n / const
        o_m2%p = o_m1%p / const
      end function om_divide
      
      !! add org_flux
      function org_flux_add1 (org_flux1, org_flux2) result (org_flux3)
        type (organic_flux), intent (in) :: org_flux1
        type (organic_flux), intent (in) :: org_flux2
        type (organic_flux) :: org_flux3
        org_flux3%cfmets1 = org_flux1%cfmets1 + org_flux2%cfmets1
        org_flux3%cfstrs1 = org_flux1%cfstrs1 + org_flux2%cfstrs1
        org_flux3%cfstrs2 = org_flux1%cfstrs2 + org_flux2%cfstrs2
        org_flux3%efmets1 = org_flux1%efmets1 + org_flux2%efmets1
        org_flux3%efstrs1 = org_flux1%efstrs1 + org_flux2%efstrs1
        org_flux3%efstrs2 = org_flux1%efstrs2 + org_flux2%efstrs2
        org_flux3%immmets1 = org_flux1%immmets1 + org_flux2%immmets1
        org_flux3%immstrs1 = org_flux1%immstrs1 + org_flux2%immstrs1
        org_flux3%immstrs2 = org_flux1%immstrs2 + org_flux2%immstrs2
        org_flux3%mnrmets1 = org_flux1%mnrmets1 + org_flux2%mnrmets1
        org_flux3%mnrstrs1 = org_flux1%mnrstrs1 + org_flux2%mnrstrs1
        org_flux3%mnrstrs1 = org_flux1%mnrstrs2 + org_flux2%mnrstrs2
        org_flux3%co2fmet = org_flux1%co2fmet + org_flux2%co2fmet
        org_flux3%co2fstr = org_flux1%co2fstr + org_flux2%co2fstr
        org_flux3%cfs1s2 = org_flux1%cfs1s2 + org_flux2%cfs1s2
        org_flux3%cfs1s3 = org_flux1%cfs1s3 + org_flux2%cfs1s3
        org_flux3%cfs2s1 = org_flux1%cfs2s1 + org_flux2%cfs2s1
        org_flux3%cfs2s3 = org_flux1%cfs2s3 + org_flux2%cfs2s3
        org_flux3%cfs3s1 = org_flux1%cfs3s1 + org_flux2%cfs3s1
        org_flux3%efs1s2 = org_flux1%efs1s2 + org_flux2%efs1s2
        org_flux3%efs1s3 = org_flux1%efs1s3 + org_flux2%efs1s3
        org_flux3%efs2s1 = org_flux1%efs2s1 + org_flux2%efs2s1
        org_flux3%efs2s3 = org_flux1%efs2s3 + org_flux2%efs2s3
        org_flux3%efs3s1 = org_flux1%efs3s1 + org_flux2%efs3s1
        org_flux3%imms1s2 = org_flux1%imms1s2 + org_flux2%imms1s2
        org_flux3%imms1s3 = org_flux1%imms1s3 + org_flux2%imms1s3
        org_flux3%imms2s1 = org_flux1%imms2s1 + org_flux2%imms2s1
        org_flux3%imms2s3 = org_flux1%imms2s3 + org_flux2%imms2s3
        org_flux3%imms3s1 = org_flux1%imms3s1 + org_flux2%imms3s1
        org_flux3%mnrs1s2 = org_flux1%mnrs1s2 + org_flux2%mnrs1s2
        org_flux3%mnrs1s3 = org_flux1%mnrs1s3 + org_flux2%mnrs1s3
        org_flux3%mnrs2s1 = org_flux1%mnrs2s1 + org_flux2%mnrs2s1
        org_flux3%mnrs2s3 = org_flux1%mnrs2s3 + org_flux2%mnrs2s3
        org_flux3%mnrs3s1 = org_flux1%mnrs3s1 + org_flux2%mnrs3s1
        org_flux3%co2fs1 = org_flux1%co2fs1 + org_flux2%co2fs1
        org_flux3%co2fs2 = org_flux1%co2fs2 + org_flux2%co2fs2
        org_flux3%co2fs3 = org_flux1%co2fs3 + org_flux2%co2fs3
      end function org_flux_add1
      
      end module organic_mineral_mass_module