organic_mineral_mass_module.f90 Source File


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_chsed.f90 calsoft_chsed.f90 sourcefile~calsoft_chsed.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_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~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~orgncswat2.f90 orgncswat2.f90 sourcefile~orgncswat2.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_drop.f90 pl_leaf_drop.f90 sourcefile~pl_leaf_drop.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_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~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
    
      implicit none 

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

      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_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 soil_profile_mass1
        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
        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
        type (organic_mass), dimension(:), allocatable :: tot       !       |total organic pool dimensioned 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
        type (organic_mass), dimension(:), allocatable :: hs        !       |slow humus dimensioned by layer
        type (organic_mass), dimension(:), allocatable :: hp        !       |passive humus dimensioned by layer
        type (organic_mass), dimension(:), allocatable :: rsd       !       |fresh residue-all plants in one pool 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_mass1
      
      !soil profile object - dimensioned to number of hrus, using the hru pointer
      type (soil_profile_mass1), dimension(:), allocatable, target :: soil1
      type (soil_profile_mass1), dimension(:), allocatable :: soil1_init
      type (soil_profile_mass1), pointer :: s1
      type (organic_mass) :: soil_prof_tot                          !       |total litter pool
      type (organic_mass) :: soil_prof_hact                         !       |total litter pool
      type (organic_mass) :: soil_prof_hsta                         !       |total litter pool
      type (organic_mass) :: soil_prof_str                          !       |total litter pool
      type (organic_mass) :: soil_prof_lig                          !       |total litter pool
      type (organic_mass) :: soil_prof_meta                         !       |total litter pool
      type (organic_mass) :: soil_prof_man                          !       |total litter pool
      type (organic_mass) :: soil_prof_hs                           !       |total litter pool
      type (organic_mass) :: soil_prof_hp                           !       |total litter pool
      type (organic_mass) :: soil_prof_microb                       !       |total litter pool
      type (organic_mass) :: soil_prof_somc
      type (organic_mass) :: soil_prof_water                        !       |total litter pool
      type (organic_mass) :: soil_org_z                             !       |total litter pool
      type (organic_mass) :: soil_prof_rsd                          !       |total litter pool
      type (mineral_nitrogen) :: soil_prof_mn                       !       |stable humus pool
      type (mineral_phosphorus) :: soil_prof_mp                     !       |active humus pool
      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 soil profile
      real :: bsn_mp = 0.                                           !       |mineral p pool (wsol+lab+act+sta) in soil profile

      type residue_mass1        !surface residue
        character (len=16) :: name = ""
        type (organic_mass), dimension(:), allocatable :: tot       !       |total mass surface residue litter pool-dimensioned by plant
        type (organic_mass), dimension(:), allocatable :: meta      !       |metabolic litter pool-dimensioned by plant
        type (organic_mass), dimension(:), allocatable :: str       !       |structural litter pool-dimensioned by plant
        type (organic_mass), dimension(:), allocatable :: lignin                   !       |lignin pool-dimensioned by plant
        type (organic_mass) :: tot_com                              !kg/ha  |total
        type (organic_mass) :: tot_meta                             !       |
        type (organic_mass) :: tot_str                              !       |
        type (organic_mass) :: tot_lignin                           !       |
        type (organic_mass) :: man                                  !       |
      end type residue_mass1
      !soil profile object - dimensioned to number of hrus, using the hru pointer
      type (residue_mass1), dimension(:), allocatable :: rsd1
      type (residue_mass1), dimension(:), allocatable :: rsd1_init

      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) :: plt_mass_z

      type organic_mineral_hydrograph1
        real :: vol = 0.                    ! m^3           |volume of water
        type (sediment) :: sed              !               |sediment
        type (organic_mass) :: algae        !               |algae
        type (organic_mass) :: biofilm      !               |biofilm
        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
      end type organic_mineral_hydrograph1
      
      !!end of new stuff
      
      
      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
      
      type soil_profile_mass
        character (len=16) :: name = ""
        type (organic_mineral_mass), dimension(:), allocatable :: sol       !soil matrix dimensioned by layer
        type (organic_mineral_mass), dimension(:), allocatable :: sw        !soil water dimensioned by layer
      end type soil_profile_mass
      !soil profile object - dimensioned to number of hrus, using the hru pointer
      !type (soil_profile_mass), dimension(:), allocatable :: soil
      
      !type plant_community_mass
      !  character (len=4) :: name                                !                 |same as plant_community object
      !  !live biomass
      !  type (organic_mass), dimension(:), allocatable :: tot    !kg/ha            |total biomass for individual plant in community
      !  type (organic_mass), dimension(:), allocatable :: veg    !kg/ha            |vegetative 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 :: grain  !kg/ha            |grain mass for individual plant in community
      !  type (organic_mass) :: tot_com                           !kg/ha            |total biomass for entire community
      !  type (organic_mass) :: veg_com                           !kg/ha            |vegetative mass for entire community
      !  type (organic_mass) :: root_com                          !kg/ha            |root mass for entire community
      !  type (organic_mass) :: grain_com                         !kg/ha            |grain mass for entire community
      !  !dead biomass - residue
      !  type (organic_mass), dimension(:,:), allocatable :: rsd  !kg/ha            |flat residue for individual plant in community (by soil layer)
      !  type (organic_mass), dimension(:), allocatable :: rsd_st !kg/ha            |standing residue for individual plant in community
      !end type plant_community_mass
      !plant community object - dimensioned to number of hrus, using the hru pointer
      !type (plant_community_mass), dimension(:), allocatable :: plnt

      !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 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_add
        end interface 

    contains

      
      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
      
      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

      !! 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
      

      
      end module organic_mineral_mass_module