! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! 
! The ODE Function of Chemical Model File
! 
! Generated by KPP-2.2.1_rs5 symbolic chemistry Kinetics PreProcessor
!       (http://www.cs.vt.edu/~asandu/Software/KPP)
! KPP is distributed under GPL, the general public licence
!       (http://www.gnu.org/copyleft/gpl.html)
! (C) 1995-1997, V. Damian & A. Sandu, CGRER, Univ. Iowa
! (C) 1997-2005, A. Sandu, Michigan Tech, Virginia Tech
!     With important contributions from:
!        M. Damian, Villanova University, USA
!        R. Sander, Max-Planck Institute for Chemistry, Mainz, Germany
! 
! File                 : messy_mecca_kpp_Function.f90
! Time                 : Sun Dec 21 18:36:06 2014
! Working directory    : /.statelite/tmpfs/gpfs/projects/bsc32/bsc32771/MN3/NMMB/test/KPP/caaba_3.0gmdd/mecca
! Equation file        : messy_mecca_kpp.kpp
! Output root filename : messy_mecca_kpp
! 
! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



MODULE messy_mecca_kpp_Function

  USE messy_mecca_kpp_Parameters
  IMPLICIT NONE

! A - Rate for each equation
  REAL(kind=dp) :: A(NREACT)

CONTAINS


! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! 
! Fun - time derivatives of variables - Agregate form
!   Arguments :
!      V         - Concentrations of variable species (local)
!      F         - Concentrations of fixed species (local)
!      RCT       - Rate constants (local)
!      Vdot      - Time derivative of variable species concentrations
! 
! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

SUBROUTINE Fun ( V, F, RCT, Vdot )

! V - Concentrations of variable species (local)
  REAL(kind=dp) :: V(NVAR)
! F - Concentrations of fixed species (local)
  REAL(kind=dp) :: F(NFIX)
! RCT - Rate constants (local)
  REAL(kind=dp) :: RCT(NREACT)
! Vdot - Time derivative of variable species concentrations
  REAL(kind=dp) :: Vdot(NVAR)


! Computation of equation rates
  A(1) = RCT(1)*F(4)*F(4)
  A(2) = 1.8e-12*V(6)*F(3)
  A(3) = RCT(3)*V(5)*F(3)
  A(4) = RCT(4)*V(6)
  A(5) = RCT(5)*V(1)*F(3)
  A(6) = RCT(6)*V(1)*F(3)
  A(7) = RCT(7)*V(11)*V(12)
  A(8) = RCT(8)*V(10)*V(12)
  A(9) = RCT(9)*V(7)*V(10)
  A(10) = RCT(10)*F(2)
  A(11) = RCT(11)*V(12)
  A(12) = RCT(12)*V(6)
  A(13) = RCT(13)*V(7)
  A(14) = RCT(14)*V(5)
  A(15) = RCT(15)*V(8)
  A(16) = RCT(16)*V(8)
  A(17) = RCT(17)*V(9)*V(10)
  A(18) = RCT(18)*V(10)
  A(19) = RCT(19)*V(9)*V(11)

! Aggregate function
  Vdot(1) = -A(5)-A(6)
  Vdot(2) = A(2)
  Vdot(3) = A(3)
  Vdot(4) = A(7)+A(8)+A(9)
  Vdot(5) = -A(3)+A(5)+0.5*A(6)-A(14)+A(15)
  Vdot(6) = A(1)-A(2)-A(4)-A(12)+A(13)
  Vdot(7) = -A(9)+A(12)-A(13)
  Vdot(8) = A(14)-A(15)-A(16)+A(17)
  Vdot(9) = A(8)+A(9)+A(16)-A(17)+A(18)-A(19)
  Vdot(10) = -A(8)-A(9)+A(16)-A(17)-A(18)+A(19)
  Vdot(11) = -A(7)+A(18)-A(19)
  Vdot(12) = -A(7)-A(8)+A(10)-A(11)
      
END SUBROUTINE Fun

! End of Fun function
! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



END MODULE messy_mecca_kpp_Function

