added README_changes.txt
[wrffire.git] / wrfv2_fire / chem / KPP / kpp / kpp-2.1 / util / dJac_dRcoeff.f
blob7732104dbbabddafac3280fcbc707a70d2da1a94
1 C ------------------------------------------------------------------------------
2 C Subroutine for the derivative of Jac with respect to rate coefficients
3 C Times a user vector
4 C -----------------------------------------------------------------------------
6 SUBROUTINE dJac_dRcoeff( V, F, U, NCOEFF, JCOEFF, DJDR )
8 IMPLICIT NONE
9 INCLUDE 'KPP_ROOT_Parameters.h'
10 INCLUDE 'KPP_ROOT_Sparse.h'
12 C V - Concentrations of variable/radical/fixed species
13 KPP_REAL V(NVAR), F(NFIX)
14 C U - User-supplied Vector
15 KPP_REAL U(NVAR)
16 C NCOEFF - the number of rate coefficients with respect to which we differentiate
17 INTEGER NCOEFF
18 C JCOEFF - a vector of integers containing the indices of reactions (rate
19 C coefficients) with respect to which we differentiate
20 INTEGER JCOEFF(NCOEFF)
21 C DFDR - a matrix containg derivative values; specifically,
22 C column j contains d Jac(1:NVAR) / d RCT( JCOEFF(j) ) * U
23 C for each 1 <= j <= NCOEFF
24 C This matrix is stored in a column-wise linearized format
25 KPP_REAL DJDR(NVAR*NCOEFF)
27 C Local vector for Jacobian of reactant products
28 KPP_REAL JV_RPROD(NJVRP)
29 KPP_REAL aj
30 INTEGER i,j,k
32 C Compute the Jacobian of all reactant products
33 CALL JacReactantProd( V, F, JV_RPROD )
35 C Compute the derivatives by multiplying column JCOEFF(j) of the stoichiometric matrix with A_PROD
36 DO j=1,NCOEFF
37 C Initialize the j-th column of derivative matrix to zero
38 DO i=1,NVAR
39 DJDR(i+NVAR*(j-1)) = 0.0D0
40 END DO
41 C Column JCOEFF(j) in the stoichiometric matrix times the
42 C ( Gradient of reactant product of the JCOEFF(j)-th reaction X user vector )
43 C give the j-th column of the derivative matrix
45 C Row JCOEFF(j) of JV_RPROD times the user vector
46 aj = 0.d0
47 DO k=CROW_JVRP(JCOEFF(j)),CROW_JVRP(JCOEFF(j)+1)-1
48 aj = aj + JV_RPROD(k)*U(ICOL_JVRP(k))
49 END DO
50 C Column JCOEFF(j) of Stoichiom. matrix times aj
51 DO k=CCOL_STOICM(JCOEFF(j)),CCOL_STOICM(JCOEFF(j)+1)-1
52 DJDR(IROW_STOICM(k)+NVAR*(j-1)) = STOICM(k)*aj
53 END DO
54 END DO
56 RETURN
57 END