1C> \ingroup nwxc
2C> @{
3C>
4C> \file nwxcm_c_pkzb99.F
5C> The nwxcm_c_pkzb99 functional
6C>
7C> @}
8C>
9C> \ingroup nwxc_priv
10C> @{
11C>
12C> \brief Evaluate the nwxcm_c_pkzb99 functional [1]
13C>
14C> \f{eqnarray*}{
15C>   {\it t_1} &=& \rho_\beta+\rho_\alpha\\\\
16C>   {\it t_2} &=& {\it param}\left(1\right)\\\\
17C>   {\it t_3} &=& {{1}\over{\rho_\alpha}}\\\\
18C>   {\it t_4} &=& {{1}\over{{\it t_1}}}\\\\
19C>   {\it t_5} &=& {{1}\over{\rho_\beta}}\\\\
20C>   f &=& 1.0\,{\it t_1}\,\left({\it nwxc\_c\_mpbe}\left({\it t_2}
21C>    , \rho_\alpha , \rho_\beta , \sigma_{\alpha\alpha} ,
22C>    \sigma_{\alpha\beta} , \sigma_{\beta\beta}\right)\,
23C>    \left({{0.53\,\left(0.125\,{\it t_5}\,\sigma_{\beta\beta}
24C>    +0.125\,{\it t_3}\,\sigma_{\alpha\alpha}\right)^2}\over{
25C>    \left(\tau_\beta+\tau_\alpha\right)^2}}+1.0\right)
26C>    -{{0.02390625\,{\it nwxc\_c\_mpbe}\left({\it t_2} , 0.0
27C>    , \rho_\beta , 0.0 , 0.0 , \sigma_{\beta\beta}\right)\,{
28C>    \it t_5}\,{\it t_4}\,\sigma_{\beta\beta}^2}\over{\tau_\beta^2}}
29C>    -{{0.02390625\,{\it nwxc\_c\_mpbe}\left({\it t_2}
30C>    , \rho_\alpha , 0.0 , \sigma_{\alpha\alpha} , 0.0 , 0.0\right)
31C>    \,{\it t_3}\,{\it t_4}\,\sigma_{\alpha\alpha}^2}
32C>    \over{\tau_\alpha^2}}\right)\\\\
33C>   g &=& 0\\\\
34C>   G &=& 0.0\\\\
35C> \f}
36C>
37C> Code generated with Maxima 5.34.0 [2,3]
38C> driven by autoxc-Ds [4,5,6].
39C>
40C> ### References ###
41C>
42C> [1] JP Perdew, S Kurth, A Zupan, P Blaha, Phys.Rev.Lett. 82
43C>    , 2544 (1999)  , DOI:
44C> <a href="https://doi.org/10.1103/PhysRevLett.82.2544 ">
45C> 10.1103/PhysRevLett.82.2544 </a>
46C>
47C> [2] Maxima, a computer algebra system,
48C> <a href="http://maxima.sourceforge.net/">
49C> http://maxima.sourceforge.net/</a>
50C>
51C> [3] CLISP 2.49 (2010-07-07)
52C>
53C> [4] autoxc-Ds, revision 27701 2015-10-10
54C>
55C> [5] rewrap.py revision 27697 2015-10-10
56C>
57C> [6] call_subroutine.py revision 27339 2015-08-13
58C>
59      subroutine nwxcm_c_pkzb99(param,tol_rho,ipol,nq,wght, rho,
60     +   rgamma,tau,fnc,Amat,Cmat,Mmat)
61c $Id: $
62#ifdef NWXC_QUAD_PREC
63      implicit real(kind=selected_real_kind(30))(a-h,o-z),integer(i-n)
64      integer, parameter :: rk=selected_real_kind(30)
65#else
66      implicit real(kind=selected_real_kind(15))(a-h,o-z),integer(i-n)
67      integer, parameter :: rk=selected_real_kind(15)
68#endif
69#include "nwxc_param.fh"
70      double precision sr(NCOL_RHO)
71      double precision sg(NCOL_GAMMA)
72      double precision st(NCOL_TAU)
73      double precision s1f
74      double precision s1a(NCOL_AMAT)
75      double precision s1c(NCOL_CMAT)
76      double precision s1m(NCOL_MMAT)
77      double precision s2f
78      double precision s2a(NCOL_AMAT)
79      double precision s2c(NCOL_CMAT)
80      double precision s2m(NCOL_MMAT)
81      double precision s3f
82      double precision s3a(NCOL_AMAT)
83      double precision s3c(NCOL_CMAT)
84      double precision s3m(NCOL_MMAT)
85      double precision param(*)     !< [Input] Parameters of functional
86      double precision tol_rho      !< [Input] The lower limit on the
87                                    !< density
88      integer ipol                  !< [Input] The number of spin
89                                    !< channels
90      integer nq                    !< [Input] The number of points
91      double precision wght         !< [Input] The weight of the
92                                    !< functional
93      double precision rho(nq,NCOL_RHO)      !< [Input] The density
94      double precision rgamma(nq,NCOL_GAMMA) !< [Input] The norm of the
95                                             !< density gradients
96      double precision tau(nq,NCOL_TAU)      !< [Input] The kinetic
97                                             !< energy density
98      double precision fnc(nq)      !< [Output] The value of the
99                                    !< functional
100c
101c     Sampling Matrices for the XC Kernel
102c
103      double precision Amat(nq,NCOL_AMAT)   !< [Output] The derivative
104                                            !< wrt rho
105      double precision Cmat(nq,NCOL_CMAT)   !< [Output] The derivative
106                                            !< wrt rgamma
107      double precision Mmat(nq,NCOL_MMAT)   !< [Output] The derivative
108                                            !< wrt tau
109      integer iq
110      double precision tmp
111      double precision rhoa,rhob
112      double precision gammaaa,gammaab,gammabb
113      double precision taua,taub
114      double precision nwxcm_heaviside
115      external         nwxcm_heaviside
116CDIR$ NOVECTOR
117      do iq = 1, nq
118        if (ipol.eq.1) then
119          rhoa    = 0.5d0*rho(iq,R_T)
120          gammaaa = 0.25d0*rgamma(iq,G_TT)
121          taua    = 0.5d0*tau(iq,T_T)
122          if (rhoa.gt.tol_rho) then
123            if (taua.gt.tol_rho) then
124              t1 = param(1)
125              sr(R_A) = 0.0d+0
126              sr(R_B) = rhoa
127              sg(G_AA) = 0.0d+0
128              sg(G_AB) = 0.0d+0
129              sg(G_BB) = gammaaa
130              s1f = 0.0d0
131              call dcopy(NCOL_AMAT,0.0d0,0,s1a,1)
132              call dcopy(NCOL_CMAT,0.0d0,0,s1c,1)
133              call nwxcm_c_mpbe(t1,tol_rho,2,1,1.0d0,sr,sg,s1f,s1a,s1c)
134              t2 = s1f
135              t3 = gammaaa**2
136              t4 = 1/rhoa**2
137              t5 = 1/taua**2
138              sr(R_A) = rhoa
139              sr(R_B) = 0.0d+0
140              sg(G_AA) = gammaaa
141              sg(G_AB) = 0.0d+0
142              sg(G_BB) = 0.0d+0
143              s2f = 0.0d0
144              call dcopy(NCOL_AMAT,0.0d0,0,s2a,1)
145              call dcopy(NCOL_CMAT,0.0d0,0,s2c,1)
146              call nwxcm_c_mpbe(t1,tol_rho,2,1,1.0d0,sr,sg,s2f,s2a,s2c)
147              t6 = s2f
148              sr(R_T) = 2.0d0*rhoa
149              sg(G_TT) = 4.0d0*gammaaa
150              s3f = 0.0d0
151              call dcopy(NCOL_AMAT,0.0d0,0,s3a,1)
152              call dcopy(NCOL_CMAT,0.0d0,0,s3c,1)
153              call nwxcm_c_mpbe(t1,tol_rho,ipol,1,1.0d0,sr,sg,s3f,s3a,
154     +          s3c)
155              t7 = s3f
156              t8 = 8.28125d-3*t3*t4*t5+1.0d+0
157              t9 = s3f*t8-1.1953125d-2*t3*t4*t5*s2f-1.1953125d-2*s1f
158     +          *t3*t4*t5
159              t10 = 1/rhoa**3
160              t11 = 1/taua**3
161              fnc(iq) = 2.0d+0*rhoa*t9*wght+fnc(iq)
162              Amat(iq,D1_RA) = 1.0d+0*t9*wght+2.0d+0*rhoa*(s3a(D1_RA)
163     +          *t8-8.28125d-3*t10*t3*t5*s3f-1.1953125d-2*t3*t4*t5*s2a
164     +          (D1_RA)+1.79296875d-2*t10*t3*t5*s2f+5.9765625d-3*t10
165     +          *s1f*t3*t5)*wght+Amat(iq,D1_RA)
166              Cmat(iq,D1_GAA) = 2.0d+0*rhoa*(s3c(D1_GAA)*t8+8.28125d-3
167     +          *gammaaa*t4*t5*s3f+5.0d-1*t4*t5*(-2.390625d-2*t3*s2c
168     +          (D1_GAA)-4.78125d-2*gammaaa*s2f))*wght+Cmat(iq,D1_GAA)
169              Cmat(iq,D1_GAB) = 2.0d+0*rhoa*s3c(D1_GAB)*t8*wght+Cmat
170     +          (iq,D1_GAB)
171              Mmat(iq,D1_TA) = 2.0d+0*rhoa*(2.390625d-2*t11*t3*t4*s2f
172     +          -8.28125d-3*t11*t3*t4*s3f)*wght+Mmat(iq,D1_TA)
173            else
174              t1 = param(1)
175              t2 = 4.0d-50*rhoa
176              sr(R_A) = 0.0d+0
177              sr(R_B) = rhoa
178              sg(G_AA) = 0.0d+0
179              sg(G_AB) = 0.0d+0
180              sg(G_BB) = t2
181              s1f = 0.0d0
182              call dcopy(NCOL_AMAT,0.0d0,0,s1a,1)
183              call dcopy(NCOL_CMAT,0.0d0,0,s1c,1)
184              call nwxcm_c_mpbe(t1,tol_rho,2,1,1.0d0,sr,sg,s1f,s1a,s1c)
185              t3 = s1f
186              sr(R_A) = rhoa
187              sr(R_B) = 0.0d+0
188              sg(G_AA) = t2
189              sg(G_AB) = 0.0d+0
190              sg(G_BB) = 0.0d+0
191              s2f = 0.0d0
192              call dcopy(NCOL_AMAT,0.0d0,0,s2a,1)
193              call dcopy(NCOL_CMAT,0.0d0,0,s2c,1)
194              call nwxcm_c_mpbe(t1,tol_rho,2,1,1.0d0,sr,sg,s2f,s2a,s2c)
195              t4 = s2f
196              sr(R_T) = 2.0d0*rhoa
197              sg(G_TT) = 4.0d0*t2
198              s3f = 0.0d0
199              call dcopy(NCOL_AMAT,0.0d0,0,s3a,1)
200              call dcopy(NCOL_CMAT,0.0d0,0,s3c,1)
201              call nwxcm_c_mpbe(t1,tol_rho,ipol,1,1.0d0,sr,sg,s3f,s3a,
202     +          s3c)
203              t5 = s3f
204              t6 = 1.1325d+0*s3f-1.9125d-1*s2f-1.9125d-1*s1f
205              t7 = 1/rhoa
206              fnc(iq) = 2.0d+0*rhoa*t6*wght+fnc(iq)
207              Amat(iq,D1_RA) = 2.0d+0*rhoa*(-9.5625d-2*s2f*t7
208     +          +9.5625d-2*s1f*t7+1.1325d+0*s3a(D1_RA)-1.9125d-1*s2a
209     +          (D1_RA))*wght+1.0d+0*t6*wght+Amat(iq,D1_RA)
210              Cmat(iq,D1_GAA) = Cmat(iq,D1_GAA)
211              Cmat(iq,D1_GAB) = Cmat(iq,D1_GAB)
212              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
213            endif
214          endif ! rhoa.gt.tol_rho
215        else  ! ipol.eq.1
216          rhoa    = rho(iq,R_A)
217          rhob    = rho(iq,R_B)
218          gammaaa = rgamma(iq,G_AA)
219          gammaab = rgamma(iq,G_AB)
220          gammabb = rgamma(iq,G_BB)
221          taua    = tau(iq,T_A)
222          taub    = tau(iq,T_B)
223          if (rhoa.gt.tol_rho.and.rhob.gt.tol_rho) then
224            if (taua.gt.tol_rho.and.taub.gt.tol_rho) then
225              t1 = rhob+rhoa
226              t2 = param(1)
227              sr(R_A) = rhoa
228              sr(R_B) = 0.0d+0
229              sg(G_AA) = gammaaa
230              sg(G_AB) = 0.0d+0
231              sg(G_BB) = 0.0d+0
232              s1f = 0.0d0
233              call dcopy(NCOL_AMAT,0.0d0,0,s1a,1)
234              call dcopy(NCOL_CMAT,0.0d0,0,s1c,1)
235              call nwxcm_c_mpbe(t2,tol_rho,2,1,1.0d0,sr,sg,s1f,s1a,s1c)
236              t3 = s1f
237              t4 = gammaaa**2
238              t5 = 1/rhoa
239              t6 = 1/t1
240              t7 = 1/taua**2
241              sr(R_A) = 0.0d+0
242              sr(R_B) = rhob
243              sg(G_AA) = 0.0d+0
244              sg(G_AB) = 0.0d+0
245              sg(G_BB) = gammabb
246              s2f = 0.0d0
247              call dcopy(NCOL_AMAT,0.0d0,0,s2a,1)
248              call dcopy(NCOL_CMAT,0.0d0,0,s2c,1)
249              call nwxcm_c_mpbe(t2,tol_rho,2,1,1.0d0,sr,sg,s2f,s2a,s2c)
250              t8 = s2f
251              t9 = gammabb**2
252              t10 = 1/rhob
253              t11 = 1/taub**2
254              sr(R_A) = rhoa
255              sr(R_B) = rhob
256              sg(G_AA) = gammaaa
257              sg(G_AB) = gammaab
258              sg(G_BB) = gammabb
259              s3f = 0.0d0
260              call dcopy(NCOL_AMAT,0.0d0,0,s3a,1)
261              call dcopy(NCOL_CMAT,0.0d0,0,s3c,1)
262              call nwxcm_c_mpbe(t2,tol_rho,ipol,1,1.0d0,sr,sg,s3f,s3a,
263     +          s3c)
264              t12 = s3f
265              t13 = 1.25d-1*gammaaa*t5+1.25d-1*gammabb*t10
266              t14 = t13**2
267              t15 = taub+taua
268              t16 = 1/t15**2
269              t17 = 5.3d-1*t14*t16+1.0d+0
270              t18 = -2.390625d-2*t10*t11*t6*s2f*t9-2.390625d-2*s1f*t4
271     +          *t5*t6*t7+s3f*t17
272              t19 = 1.0d+0*t18*wght
273              t20 = 1/t1**2
274              t21 = 2.390625d-2*t20*s1f*t4*t5*t7
275              t22 = 1/rhoa**2
276              t23 = 2.390625d-2*t10*t11*t20*s2f*t9
277              t24 = 1/rhob**2
278              t25 = -1.0600000000000001d+0*s3f*t14/t15**3
279              fnc(iq) = 1.0d+0*t1*t18*wght+fnc(iq)
280              Amat(iq,D1_RA) = 1.0d+0*t1*(-2.390625d-2*s1a(D1_RA)*t4
281     +          *t5*t6*t7+2.390625d-2*t22*s1f*t4*t6*t7+t23-1.325d-1
282     +          *gammaaa*s3f*t13*t16*t22+t21+s3a(D1_RA)*t17)*wght+t19
283     +          +Amat(iq,D1_RA)
284              Amat(iq,D1_RB) = 1.0d+0*t1*(-2.390625d-2*t10*t11*t6*s2a
285     +          (D1_RB)*t9+2.390625d-2*t11*t24*t6*s2f*t9-1.325d-1
286     +          *gammabb*s3f*t13*t16*t24+t23+t21+s3a(D1_RB)*t17)*wght
287     +          +t19+Amat(iq,D1_RB)
288              Cmat(iq,D1_GAA) = 1.0d+0*t1*((-2.390625d-2*s1c(D1_GAA)
289     +          *t4-4.78125d-2*gammaaa*s1f)*t5*t6*t7+1.325d-1*s3f*t13
290     +          *t16*t5+s3c(D1_GAA)*t17)*wght+Cmat(iq,D1_GAA)
291              Cmat(iq,D1_GAB) = 1.0d+0*t1*s3c(D1_GAB)*t17*wght+Cmat
292     +          (iq,D1_GAB)
293              Cmat(iq,D1_GBB) = 1.0d+0*t1*(t10*t11*t6*(-2.390625d-2
294     +          *s2c(D1_GBB)*t9-4.78125d-2*gammabb*s2f)+s3c(D1_GBB)
295     +          *t17+1.325d-1*t10*s3f*t13*t16)*wght+Cmat(iq,D1_GBB)
296              Mmat(iq,D1_TA) = 1.0d+0*t1*(4.78125d-2*s1f*t4*t5*t6/taua
297     +          **3+t25)*wght+Mmat(iq,D1_TA)
298              Mmat(iq,D1_TB) = 1.0d+0*t1*(4.78125d-2*t10*t6*s2f*t9
299     +          /taub**3+t25)*wght+Mmat(iq,D1_TB)
300            elseif (taua.gt.tol_rho.and.taub.le.tol_rho) then
301              t1 = rhob+rhoa
302              t2 = param(1)
303              t3 = 4.0d-50*rhob
304              sr(R_A) = 0.0d+0
305              sr(R_B) = rhob
306              sg(G_AA) = 0.0d+0
307              sg(G_AB) = 0.0d+0
308              sg(G_BB) = t3
309              s1f = 0.0d0
310              call dcopy(NCOL_AMAT,0.0d0,0,s1a,1)
311              call dcopy(NCOL_CMAT,0.0d0,0,s1c,1)
312              call nwxcm_c_mpbe(t2,tol_rho,2,1,1.0d0,sr,sg,s1f,s1a,s1c)
313              t4 = s1f
314              t5 = 1/t1
315              sr(R_A) = rhoa
316              sr(R_B) = 0.0d+0
317              sg(G_AA) = gammaaa
318              sg(G_AB) = 0.0d+0
319              sg(G_BB) = 0.0d+0
320              s2f = 0.0d0
321              call dcopy(NCOL_AMAT,0.0d0,0,s2a,1)
322              call dcopy(NCOL_CMAT,0.0d0,0,s2c,1)
323              call nwxcm_c_mpbe(t2,tol_rho,2,1,1.0d0,sr,sg,s2f,s2a,s2c)
324              t6 = s2f
325              t7 = gammaaa**2
326              t8 = 1/rhoa
327              t9 = 1/taua**2
328              sr(R_A) = rhoa
329              sr(R_B) = rhob
330              sg(G_AA) = gammaaa
331              sg(G_AB) = 0
332              sg(G_BB) = t3
333              s3f = 0.0d0
334              call dcopy(NCOL_AMAT,0.0d0,0,s3a,1)
335              call dcopy(NCOL_CMAT,0.0d0,0,s3c,1)
336              call nwxcm_c_mpbe(t2,tol_rho,ipol,1,1.0d0,sr,sg,s3f,s3a,
337     +          s3c)
338              t10 = s3f
339              t11 = 1.25d-1*gammaaa*t8+5.0d-51
340              t12 = t11**2
341              t13 = taua+1.0d-50
342              t14 = 1/t13**2
343              t15 = 5.3d-1*t12*t14+1.0d+0
344              t16 = -2.390625d-2*t5*s2f*t7*t8*t9-3.825d-1*rhob*s1f*t5
345     +          +s3f*t15
346              t17 = 1.0d+0*t16*wght
347              t18 = 1/t1**2
348              t19 = 3.825d-1*rhob*t18*s1f
349              t20 = 2.390625d-2*t18*s2f*t7*t8*t9
350              t21 = 1/rhoa**2
351              fnc(iq) = 1.0d+0*t1*t16*wght+fnc(iq)
352              Amat(iq,D1_RA) = 1.0d+0*t1*(-2.390625d-2*t5*s2a(D1_RA)
353     +          *t7*t8*t9+2.390625d-2*t21*t5*s2f*t7*t9-1.325d-1
354     +          *gammaaa*s3f*t11*t14*t21+t20+t19+s3a(D1_RA)*t15)*wght
355     +          +t17+Amat(iq,D1_RA)
356              Amat(iq,D1_RB) = 1.0d+0*t1*(-3.825d-1*rhob*s1a(D1_RB)*t5
357     +          -3.825d-1*s1f*t5+t20+t19+s3a(D1_RB)*t15)*wght+t17+Amat
358     +          (iq,D1_RB)
359              Cmat(iq,D1_GAA) = 1.0d+0*t1*(t5*(-2.390625d-2*s2c(D1_GAA
360     +          )*t7-4.78125d-2*gammaaa*s2f)*t8*t9+1.325d-1*s3f*t11
361     +          *t14*t8+s3c(D1_GAA)*t15)*wght+Cmat(iq,D1_GAA)
362              Cmat(iq,D1_GAB) = Cmat(iq,D1_GAB)
363              Cmat(iq,D1_GBB) = Cmat(iq,D1_GBB)
364              Mmat(iq,D1_TA) = 1.0d+0*t1*(4.78125d-2*t5*s2f*t7*t8/taua
365     +          **3-1.0600000000000001d+0*s3f*t12/t13**3)*wght+Mmat
366     +          (iq,D1_TA)
367              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
368            elseif (taua.le.tol_rho.and.taub.gt.tol_rho) then
369              t1 = rhob+rhoa
370              t2 = param(1)
371              t3 = 4.0d-50*rhoa
372              sr(R_A) = rhoa
373              sr(R_B) = 0.0d+0
374              sg(G_AA) = t3
375              sg(G_AB) = 0.0d+0
376              sg(G_BB) = 0.0d+0
377              s1f = 0.0d0
378              call dcopy(NCOL_AMAT,0.0d0,0,s1a,1)
379              call dcopy(NCOL_CMAT,0.0d0,0,s1c,1)
380              call nwxcm_c_mpbe(t2,tol_rho,2,1,1.0d0,sr,sg,s1f,s1a,s1c)
381              t4 = s1f
382              t5 = 1/t1
383              sr(R_A) = 0.0d+0
384              sr(R_B) = rhob
385              sg(G_AA) = 0.0d+0
386              sg(G_AB) = 0.0d+0
387              sg(G_BB) = gammabb
388              s2f = 0.0d0
389              call dcopy(NCOL_AMAT,0.0d0,0,s2a,1)
390              call dcopy(NCOL_CMAT,0.0d0,0,s2c,1)
391              call nwxcm_c_mpbe(t2,tol_rho,2,1,1.0d0,sr,sg,s2f,s2a,s2c)
392              t6 = s2f
393              t7 = gammabb**2
394              t8 = 1/rhob
395              t9 = 1/taub**2
396              sr(R_A) = rhoa
397              sr(R_B) = rhob
398              sg(G_AA) = t3
399              sg(G_AB) = 0
400              sg(G_BB) = gammabb
401              s3f = 0.0d0
402              call dcopy(NCOL_AMAT,0.0d0,0,s3a,1)
403              call dcopy(NCOL_CMAT,0.0d0,0,s3c,1)
404              call nwxcm_c_mpbe(t2,tol_rho,ipol,1,1.0d0,sr,sg,s3f,s3a,
405     +          s3c)
406              t10 = s3f
407              t11 = 1.25d-1*gammabb*t8+5.0d-51
408              t12 = t11**2
409              t13 = taub+1.0d-50
410              t14 = 1/t13**2
411              t15 = 5.3d-1*t12*t14+1.0d+0
412              t16 = -2.390625d-2*t5*s2f*t7*t8*t9-3.825d-1*rhoa*s1f*t5
413     +          +s3f*t15
414              t17 = 1.0d+0*t16*wght
415              t18 = 1/t1**2
416              t19 = 3.825d-1*rhoa*t18*s1f
417              t20 = 2.390625d-2*t18*s2f*t7*t8*t9
418              t21 = 1/rhob**2
419              fnc(iq) = 1.0d+0*t1*t16*wght+fnc(iq)
420              Amat(iq,D1_RA) = 1.0d+0*t1*(-3.825d-1*rhoa*s1a(D1_RA)*t5
421     +          -3.825d-1*s1f*t5+t20+t19+s3a(D1_RA)*t15)*wght+t17+Amat
422     +          (iq,D1_RA)
423              Amat(iq,D1_RB) = 1.0d+0*t1*(-2.390625d-2*t5*s2a(D1_RB)
424     +          *t7*t8*t9+2.390625d-2*t21*t5*s2f*t7*t9-1.325d-1
425     +          *gammabb*s3f*t11*t14*t21+t20+t19+s3a(D1_RB)*t15)*wght
426     +          +t17+Amat(iq,D1_RB)
427              Cmat(iq,D1_GAA) = Cmat(iq,D1_GAA)
428              Cmat(iq,D1_GAB) = Cmat(iq,D1_GAB)
429              Cmat(iq,D1_GBB) = 1.0d+0*t1*(t5*(-2.390625d-2*s2c(D1_GBB
430     +          )*t7-4.78125d-2*gammabb*s2f)*t8*t9+1.325d-1*s3f*t11
431     +          *t14*t8+s3c(D1_GBB)*t15)*wght+Cmat(iq,D1_GBB)
432              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
433              Mmat(iq,D1_TB) = 1.0d+0*t1*(4.78125d-2*t5*s2f*t7*t8/taub
434     +          **3-1.0600000000000001d+0*s3f*t12/t13**3)*wght+Mmat
435     +          (iq,D1_TB)
436            else
437              t1 = rhob+rhoa
438              t2 = param(1)
439              t3 = 4.0d-50*rhoa
440              t4 = 4.0d-50*rhob
441              sr(R_A) = rhoa
442              sr(R_B) = rhob
443              sg(G_AA) = t3
444              sg(G_AB) = 0
445              sg(G_BB) = t4
446              s1f = 0.0d0
447              call dcopy(NCOL_AMAT,0.0d0,0,s1a,1)
448              call dcopy(NCOL_CMAT,0.0d0,0,s1c,1)
449              call nwxcm_c_mpbe(t2,tol_rho,ipol,1,1.0d0,sr,sg,s1f,s1a,
450     +          s1c)
451              t5 = s1f
452              sr(R_A) = rhoa
453              sr(R_B) = 0.0d+0
454              sg(G_AA) = t3
455              sg(G_AB) = 0.0d+0
456              sg(G_BB) = 0.0d+0
457              s2f = 0.0d0
458              call dcopy(NCOL_AMAT,0.0d0,0,s2a,1)
459              call dcopy(NCOL_CMAT,0.0d0,0,s2c,1)
460              call nwxcm_c_mpbe(t2,tol_rho,2,1,1.0d0,sr,sg,s2f,s2a,s2c)
461              t6 = s2f
462              t7 = 1/t1
463              sr(R_A) = 0.0d+0
464              sr(R_B) = rhob
465              sg(G_AA) = 0.0d+0
466              sg(G_AB) = 0.0d+0
467              sg(G_BB) = t4
468              s3f = 0.0d0
469              call dcopy(NCOL_AMAT,0.0d0,0,s3a,1)
470              call dcopy(NCOL_CMAT,0.0d0,0,s3c,1)
471              call nwxcm_c_mpbe(t2,tol_rho,2,1,1.0d0,sr,sg,s3f,s3a,s3c)
472              t8 = s3f
473              t9 = -3.825d-1*rhob*t7*s3f-3.825d-1*rhoa*s2f*t7
474     +          +1.1325d+0*s1f
475              t10 = 1/t1**2
476              t11 = 3.825d-1*rhoa*t10*s2f
477              t12 = 3.825d-1*rhob*t10*s3f
478              t13 = 1.0d+0*t9*wght
479              fnc(iq) = 1.0d+0*t1*t9*wght+fnc(iq)
480              Amat(iq,D1_RA) = 1.0d+0*t1*(-3.825d-1*rhoa*s2a(D1_RA)*t7
481     +          -3.825d-1*s2f*t7+1.1325d+0*s1a(D1_RA)+t12+t11)*wght
482     +          +t13+Amat(iq,D1_RA)
483              Amat(iq,D1_RB) = 1.0d+0*t1*(-3.825d-1*rhob*t7*s3a(D1_RB)
484     +          -3.825d-1*t7*s3f+1.1325d+0*s1a(D1_RB)+t12+t11)*wght
485     +          +t13+Amat(iq,D1_RB)
486              Cmat(iq,D1_GAA) = Cmat(iq,D1_GAA)
487              Cmat(iq,D1_GAB) = Cmat(iq,D1_GAB)
488              Cmat(iq,D1_GBB) = Cmat(iq,D1_GBB)
489              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
490              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
491            endif
492          elseif (rhoa.gt.tol_rho.and.rhob.le.tol_rho) then
493            if (taua.gt.tol_rho.and.taub.gt.tol_rho) then
494              fnc(iq) = fnc(iq)
495              Amat(iq,D1_RA) = Amat(iq,D1_RA)
496              Cmat(iq,D1_GAA) = Cmat(iq,D1_GAA)
497              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
498              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
499            elseif (taua.gt.tol_rho.and.taub.le.tol_rho) then
500              fnc(iq) = fnc(iq)
501              Amat(iq,D1_RA) = Amat(iq,D1_RA)
502              Cmat(iq,D1_GAA) = Cmat(iq,D1_GAA)
503              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
504              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
505            elseif (taua.le.tol_rho.and.taub.gt.tol_rho) then
506              fnc(iq) = fnc(iq)
507              Amat(iq,D1_RA) = Amat(iq,D1_RA)
508              Cmat(iq,D1_GAA) = Cmat(iq,D1_GAA)
509              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
510              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
511            else
512              fnc(iq) = fnc(iq)
513              Amat(iq,D1_RA) = Amat(iq,D1_RA)
514              Cmat(iq,D1_GAA) = Cmat(iq,D1_GAA)
515              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
516              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
517            endif
518          elseif (rhoa.le.tol_rho.and.rhob.gt.tol_rho) then
519            if (taua.gt.tol_rho.and.taub.gt.tol_rho) then
520              fnc(iq) = fnc(iq)
521              Amat(iq,D1_RB) = Amat(iq,D1_RB)
522              Cmat(iq,D1_GBB) = Cmat(iq,D1_GBB)
523              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
524              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
525            elseif (taua.gt.tol_rho.and.taub.le.tol_rho) then
526              fnc(iq) = fnc(iq)
527              Amat(iq,D1_RB) = Amat(iq,D1_RB)
528              Cmat(iq,D1_GBB) = Cmat(iq,D1_GBB)
529              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
530              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
531            elseif (taua.le.tol_rho.and.taub.gt.tol_rho) then
532              fnc(iq) = fnc(iq)
533              Amat(iq,D1_RB) = Amat(iq,D1_RB)
534              Cmat(iq,D1_GBB) = Cmat(iq,D1_GBB)
535              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
536              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
537            else
538              fnc(iq) = fnc(iq)
539              Amat(iq,D1_RB) = Amat(iq,D1_RB)
540              Cmat(iq,D1_GBB) = Cmat(iq,D1_GBB)
541              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
542              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
543            endif
544          endif ! rhoa.gt.tol_rho.and.rhob.gt.tol_rho
545        endif ! ipol.eq.1
546      enddo ! iq
547      end subroutine nwxcm_c_pkzb99
548C>
549C> \brief Evaluate the nwxcm_c_pkzb99 functional [1]
550C>
551C> \f{eqnarray*}{
552C>   {\it t_1} &=& \rho_\beta+\rho_\alpha\\\\
553C>   {\it t_2} &=& {\it param}\left(1\right)\\\\
554C>   {\it t_3} &=& {{1}\over{\rho_\alpha}}\\\\
555C>   {\it t_4} &=& {{1}\over{{\it t_1}}}\\\\
556C>   {\it t_5} &=& {{1}\over{\rho_\beta}}\\\\
557C>   f &=& 1.0\,{\it t_1}\,\left({\it nwxc\_c\_mpbe}\left({\it t_2}
558C>    , \rho_\alpha , \rho_\beta , \sigma_{\alpha\alpha} ,
559C>    \sigma_{\alpha\beta} , \sigma_{\beta\beta}\right)\,
560C>    \left({{0.53\,\left(0.125\,{\it t_5}\,\sigma_{\beta\beta}
561C>    +0.125\,{\it t_3}\,\sigma_{\alpha\alpha}\right)^2}\over{
562C>    \left(\tau_\beta+\tau_\alpha\right)^2}}+1.0\right)
563C>    -{{0.02390625\,{\it nwxc\_c\_mpbe}\left({\it t_2} , 0.0
564C>    , \rho_\beta , 0.0 , 0.0 , \sigma_{\beta\beta}\right)\,{
565C>    \it t_5}\,{\it t_4}\,\sigma_{\beta\beta}^2}\over{\tau_\beta^2}}
566C>    -{{0.02390625\,{\it nwxc\_c\_mpbe}\left({\it t_2}
567C>    , \rho_\alpha , 0.0 , \sigma_{\alpha\alpha} , 0.0 , 0.0\right)
568C>    \,{\it t_3}\,{\it t_4}\,\sigma_{\alpha\alpha}^2}
569C>    \over{\tau_\alpha^2}}\right)\\\\
570C>   g &=& 0\\\\
571C>   G &=& 0.0\\\\
572C> \f}
573C>
574C> Code generated with Maxima 5.34.0 [2,3]
575C> driven by autoxc-Ds [4,5,6].
576C>
577C> ### References ###
578C>
579C> [1] JP Perdew, S Kurth, A Zupan, P Blaha, Phys.Rev.Lett. 82
580C>    , 2544 (1999)  , DOI:
581C> <a href="https://doi.org/10.1103/PhysRevLett.82.2544 ">
582C> 10.1103/PhysRevLett.82.2544 </a>
583C>
584C> [2] Maxima, a computer algebra system,
585C> <a href="http://maxima.sourceforge.net/">
586C> http://maxima.sourceforge.net/</a>
587C>
588C> [3] CLISP 2.49 (2010-07-07)
589C>
590C> [4] autoxc-Ds, revision 27701 2015-10-10
591C>
592C> [5] rewrap.py revision 27697 2015-10-10
593C>
594C> [6] call_subroutine.py revision 27339 2015-08-13
595C>
596      subroutine nwxcm_c_pkzb99_d2(param,tol_rho,ipol,nq,wght, rho,
597     +   rgamma,tau,fnc,Amat,Amat2,Cmat,Cmat2,Mmat,Mmat2)
598c $Id: $
599#ifdef NWXC_QUAD_PREC
600      implicit real(kind=selected_real_kind(30))(a-h,o-z),integer(i-n)
601      integer, parameter :: rk=selected_real_kind(30)
602#else
603      implicit real(kind=selected_real_kind(15))(a-h,o-z),integer(i-n)
604      integer, parameter :: rk=selected_real_kind(15)
605#endif
606#include "nwxc_param.fh"
607      double precision sr(NCOL_RHO)
608      double precision sg(NCOL_GAMMA)
609      double precision st(NCOL_TAU)
610      double precision s1f
611      double precision s1a(NCOL_AMAT)
612      double precision s1c(NCOL_CMAT)
613      double precision s1m(NCOL_MMAT)
614      double precision s1a2(NCOL_AMAT2)
615      double precision s1c2(NCOL_CMAT2)
616      double precision s1m2(NCOL_MMAT2)
617      double precision s2f
618      double precision s2a(NCOL_AMAT)
619      double precision s2c(NCOL_CMAT)
620      double precision s2m(NCOL_MMAT)
621      double precision s2a2(NCOL_AMAT2)
622      double precision s2c2(NCOL_CMAT2)
623      double precision s2m2(NCOL_MMAT2)
624      double precision s3f
625      double precision s3a(NCOL_AMAT)
626      double precision s3c(NCOL_CMAT)
627      double precision s3m(NCOL_MMAT)
628      double precision s3a2(NCOL_AMAT2)
629      double precision s3c2(NCOL_CMAT2)
630      double precision s3m2(NCOL_MMAT2)
631      double precision param(*)     !< [Input] Parameters of functional
632      double precision tol_rho      !< [Input] The lower limit on the
633                                    !< density
634      integer ipol                  !< [Input] The number of spin
635                                    !< channels
636      integer nq                    !< [Input] The number of points
637      double precision wght         !< [Input] The weight of the
638                                    !< functional
639      double precision rho(nq,NCOL_RHO)      !< [Input] The density
640      double precision rgamma(nq,NCOL_GAMMA) !< [Input] The norm of the
641                                             !< density gradients
642      double precision tau(nq,NCOL_TAU)      !< [Input] The kinetic
643                                             !< energy density
644      double precision fnc(nq)      !< [Output] The value of the
645                                    !< functional
646c
647c     Sampling Matrices for the XC Kernel
648c
649      double precision Amat(nq,NCOL_AMAT)   !< [Output] The derivative
650                                            !< wrt rho
651      double precision Cmat(nq,NCOL_CMAT)   !< [Output] The derivative
652                                            !< wrt rgamma
653      double precision Mmat(nq,NCOL_MMAT)   !< [Output] The derivative
654                                            !< wrt tau
655c
656c     Sampling Matrices for the XC Kernel
657c
658      double precision Amat2(nq,NCOL_AMAT2)  !< [Output] The 2nd
659                                             !< derivative wrt rho
660      double precision Cmat2(nq,NCOL_CMAT2)  !< [Output] The 2nd
661                                             !< derivative wrt rgamma
662                                             !< and possibly rho
663      double precision Mmat2(nq,NCOL_MMAT2)  !< [Output] The 2nd
664                                             !< derivative wrt tau and
665                                             !< possibly rho or rgamma
666      integer iq
667      double precision tmp
668      double precision rhoa,rhob
669      double precision gammaaa,gammaab,gammabb
670      double precision taua,taub
671      double precision nwxcm_heaviside
672      external         nwxcm_heaviside
673CDIR$ NOVECTOR
674      do iq = 1, nq
675        if (ipol.eq.1) then
676          rhoa    = 0.5d0*rho(iq,R_T)
677          gammaaa = 0.25d0*rgamma(iq,G_TT)
678          taua    = 0.5d0*tau(iq,T_T)
679          if (rhoa.gt.tol_rho) then
680            if (taua.gt.tol_rho) then
681              t1 = param(1)
682              sr(R_A) = 0.0d+0
683              sr(R_B) = rhoa
684              sg(G_AA) = 0.0d+0
685              sg(G_AB) = 0.0d+0
686              sg(G_BB) = gammaaa
687              s1f = 0.0d0
688              call dcopy(NCOL_AMAT,0.0d0,0,s1a,1)
689              call dcopy(NCOL_AMAT2,0.0d0,0,s1a2,1)
690              call dcopy(NCOL_CMAT,0.0d0,0,s1c,1)
691              call dcopy(NCOL_CMAT2,0.0d0,0,s1c2,1)
692              call nwxcm_c_mpbe_d2(t1,tol_rho,2,1,1.0d0,sr,sg,s1f,s1a,
693     +          s1a2,s1c,s1c2)
694              t2 = s1f
695              t3 = gammaaa**2
696              t4 = 1/rhoa**2
697              t5 = 1/taua**2
698              sr(R_A) = rhoa
699              sr(R_B) = 0.0d+0
700              sg(G_AA) = gammaaa
701              sg(G_AB) = 0.0d+0
702              sg(G_BB) = 0.0d+0
703              s2f = 0.0d0
704              call dcopy(NCOL_AMAT,0.0d0,0,s2a,1)
705              call dcopy(NCOL_AMAT2,0.0d0,0,s2a2,1)
706              call dcopy(NCOL_CMAT,0.0d0,0,s2c,1)
707              call dcopy(NCOL_CMAT2,0.0d0,0,s2c2,1)
708              call nwxcm_c_mpbe_d2(t1,tol_rho,2,1,1.0d0,sr,sg,s2f,s2a,
709     +          s2a2,s2c,s2c2)
710              t6 = s2f
711              sr(R_T) = 2.0d0*rhoa
712              sg(G_TT) = 4.0d0*gammaaa
713              s3f = 0.0d0
714              call dcopy(NCOL_AMAT,0.0d0,0,s3a,1)
715              call dcopy(NCOL_AMAT2,0.0d0,0,s3a2,1)
716              call dcopy(NCOL_CMAT,0.0d0,0,s3c,1)
717              call dcopy(NCOL_CMAT2,0.0d0,0,s3c2,1)
718              call nwxcm_c_mpbe_d2(t1,tol_rho,ipol,1,1.0d0,sr,sg,s3f,
719     +          s3a,s3a2,s3c,s3c2)
720              t7 = s3f
721              t8 = 8.28125d-3*t3*t4*t5+1.0d+0
722              t9 = s3f*t8-1.1953125d-2*t3*t4*t5*s2f-1.1953125d-2*s1f
723     +          *t3*t4*t5
724              t10 = 1/rhoa**3
725              t11 = -8.28125d-3*t10*t3*t5*s3f
726              t12 = s2a(D1_RA)
727              t13 = s3a(D1_RA)
728              t14 = t13*t8
729              t15 = 1.79296875d-2*t10*t3*t5*s2f-1.1953125d-2*t12*t3*t4
730     +          *t5+5.9765625d-3*t10*s1f*t3*t5+t14+t11
731              t16 = 8.28125d-3*gammaaa*t4*t5*s3f
732              t17 = s2c(D1_GAA)
733              t18 = -4.78125d-2*gammaaa*s2f-2.390625d-2*t17*t3
734              t19 = s3c(D1_GAA)
735              t20 = t19*t8
736              t21 = s3c(D1_GAB)
737              t22 = 1/taua**3
738              t23 = -8.28125d-3*t22*t3*t4*s3f
739              t24 = 2.390625d-2*t22*t3*t4*s2f+t23
740              t25 = 1/rhoa**4
741              t26 = -1.6562500000000002d-2*t10*t13*t3*t5
742              t27 = s1a(D1_RA)
743              t28 = -8.28125d-3*t10*t19*t3*t5
744              t29 = 8.28125d-3*gammaaa*t13*t4*t5
745              t30 = s1c(D1_GAA)
746              t31 = 4.140625d-3*t4*t5*s3f
747              t32 = 1.6562500000000002d-2*gammaaa*t19*t4*t5
748              t33 = 8.28125d-3*t10*t22*t3*s3f
749              t34 = -8.28125d-3*t13*t22*t3*t4
750              t35 = -8.28125d-3*gammaaa*t22*t4*s3f
751              t36 = -8.28125d-3*t19*t22*t3*t4
752              t37 = 1/rhoa
753              t38 = 1/taua**4
754              fnc(iq) = 2.0d+0*rhoa*t9*wght+fnc(iq)
755              Amat(iq,D1_RA) = 1.0d+0*t9*wght+2.0d+0*rhoa*t15*wght
756     +          +Amat(iq,D1_RA)
757              Cmat(iq,D1_GAA) = 2.0d+0*rhoa*(5.0d-1*t18*t4*t5+t20+t16)
758     +          *wght+Cmat(iq,D1_GAA)
759              Cmat(iq,D1_GAB) = 2.0d+0*rhoa*t21*t8*wght+Cmat(iq,D1_GAB)
760              Mmat(iq,D1_TA) = 2.0d+0*rhoa*t24*wght+Mmat(iq,D1_TA)
761              Amat2(iq,D2_RA_RA) = 2.0d+0*rhoa*(s3a2(D2_RA_RA)*t8
762     +          +2.0703125000000003d-2*t25*t3*t5*s3f-1.1953125d-2*t3
763     +          *t4*t5*s2a2(D2_RA_RA)-4.1835937500000003d-2*t25*t3*t5
764     +          *s2f-5.9765625d-3*s1f*t25*t3*t5+3.5859375d-2*t10*t12
765     +          *t3*t5+t26)*wght+2.0d+0*t15*wght+Amat2(iq,D2_RA_RA)
766              Amat2(iq,D2_RA_RB) = 2.0d+0*rhoa*(s3a2(D2_RA_RB)*t8
767     +          +4.140625d-3*t25*t3*t5*s3f-1.1953125d-2*t25*t3*t5*s2f
768     +          +5.9765625d-3*t10*t27*t3*t5-1.1953125d-2*s1f*t25*t3*t5
769     +          +5.9765625d-3*t10*t12*t3*t5+t26)*wght+1.0d+0*
770     +          (5.9765625d-3*t10*t3*t5*s2f-1.1953125d-2*t27*t3*t4*t5
771     +          +1.79296875d-2*t10*s1f*t3*t5+t14+t11)*wght+1.0d+0*t15
772     +          *wght+Amat2(iq,D2_RA_RB)
773              Cmat2(iq,D2_RA_GAA) = 2.0d+0*rhoa*(s3c2(D2_RA_GAA)*t8
774     +          -1.2421875d-2*gammaaa*t10*t5*s3f-1.1953125d-2*t3*t4*t5
775     +          *s2c2(D2_RA_GAA)+3.5859375d-2*gammaaa*t10*t5*s2f
776     +          -2.390625d-2*gammaaa*t12*t4*t5+1.79296875d-2*t10*t17
777     +          *t3*t5+t29+t28)*wght+1.0d+0*(-2.390625d-2*gammaaa*t4
778     +          *t5*s2f-1.1953125d-2*t17*t3*t4*t5+t20+t16)*wght+Cmat2
779     +          (iq,D2_RA_GAA)
780              Cmat2(iq,D2_RA_GAB) = 2.0d+0*rhoa*(s3c2(D2_RA_GAB)*t8
781     +          -8.28125d-3*t10*t21*t3*t5)*wght+1.0d+0*t21*t8*wght
782     +          +Cmat2(iq,D2_RA_GAB)
783              Cmat2(iq,D2_RA_GBB) = 2.0d+0*rhoa*(s3c2(D2_RA_GBB)*t8
784     +          -4.140625d-3*gammaaa*t10*t5*s3f+5.9765625d-3*t10*t3
785     +          *t30*t5+1.1953125d-2*gammaaa*t10*s1f*t5+t29+t28)*wght
786     +          +1.0d+0*(-1.1953125d-2*t3*t30*t4*t5-2.390625d-2
787     +          *gammaaa*s1f*t4*t5+t20+t16)*wght+Cmat2(iq,D2_RA_GBB)
788              Cmat2(iq,D2_GAA_GAA) = 2.0d+0*rhoa*(s3c2(D2_GAA_GAA)*t8
789     +          +5.0d-1*t4*t5*(-2.390625d-2*t3*s2c2(D2_GAA_GAA)
790     +          -4.78125d-2*s2f-9.5625d-2*gammaaa*t17)+t32+t31)*wght
791     +          +Cmat2(iq,D2_GAA_GAA)
792              Cmat2(iq,D2_GAA_GAB) = 2.0d+0*rhoa*(s3c2(D2_GAA_GAB)*t8
793     +          +8.28125d-3*gammaaa*t21*t4*t5)*wght+Cmat2(iq,D2_GAA_GAB)
794              Cmat2(iq,D2_GAA_GBB) = 2.0d+0*rhoa*(s3c2(D2_GAA_GBB)*t8
795     +          +t32+t31)*wght+Cmat2(iq,D2_GAA_GBB)
796              Cmat2(iq,D2_GAB_GAB) = 2.0d+0*rhoa*s3c2(D2_GAB_GAB)*t8
797     +          *wght+Cmat2(iq,D2_GAB_GAB)
798              Mmat2(iq,D2_RA_TA) = 2.0d+0*rhoa*(-3.5859375d-2*t10*t22
799     +          *t3*s2f+2.390625d-2*t12*t22*t3*t4+t34+t33)*wght+1.0d+0
800     +          *t24*wght+Mmat2(iq,D2_RA_TA)
801              Mmat2(iq,D2_RA_TB) = 1.0d+0*(2.390625d-2*s1f*t22*t3*t4
802     +          +t23)*wght+2.0d+0*rhoa*(t34+t33-1.1953125d-2*t10*s1f
803     +          *t22*t3)*wght+Mmat2(iq,D2_RA_TB)
804              Mmat2(iq,D2_GAA_TA) = 2.0d+0*rhoa*(-t18*t22*t4+t36+t35)
805     +          *wght+Mmat2(iq,D2_GAA_TA)
806              Mmat2(iq,D2_GAA_TB) = 2.0d+0*rhoa*(t36+t35)*wght+Mmat2
807     +          (iq,D2_GAA_TB)
808              Mmat2(iq,D2_GAB_TA) = Mmat2(iq,D2_GAB_TA)
809     +          -1.6562500000000002d-2*t21*t22*t3*t37*wght
810              Mmat2(iq,D2_TA_TA) = 2.0d+0*rhoa*(1.2421875d-2*t3*t38*t4
811     +          *s3f-7.171875d-2*t3*t38*t4*s2f)*wght+Mmat2(iq,D2_TA_TA)
812              Mmat2(iq,D2_TA_TB) = 2.484375d-2*t3*t37*t38*s3f*wght
813     +          +Mmat2(iq,D2_TA_TB)
814            else
815              t1 = param(1)
816              t2 = 4.0d-50*rhoa
817              sr(R_A) = 0.0d+0
818              sr(R_B) = rhoa
819              sg(G_AA) = 0.0d+0
820              sg(G_AB) = 0.0d+0
821              sg(G_BB) = t2
822              s1f = 0.0d0
823              call dcopy(NCOL_AMAT,0.0d0,0,s1a,1)
824              call dcopy(NCOL_AMAT2,0.0d0,0,s1a2,1)
825              call dcopy(NCOL_CMAT,0.0d0,0,s1c,1)
826              call dcopy(NCOL_CMAT2,0.0d0,0,s1c2,1)
827              call nwxcm_c_mpbe_d2(t1,tol_rho,2,1,1.0d0,sr,sg,s1f,s1a,
828     +          s1a2,s1c,s1c2)
829              t3 = s1f
830              sr(R_A) = rhoa
831              sr(R_B) = 0.0d+0
832              sg(G_AA) = t2
833              sg(G_AB) = 0.0d+0
834              sg(G_BB) = 0.0d+0
835              s2f = 0.0d0
836              call dcopy(NCOL_AMAT,0.0d0,0,s2a,1)
837              call dcopy(NCOL_AMAT2,0.0d0,0,s2a2,1)
838              call dcopy(NCOL_CMAT,0.0d0,0,s2c,1)
839              call dcopy(NCOL_CMAT2,0.0d0,0,s2c2,1)
840              call nwxcm_c_mpbe_d2(t1,tol_rho,2,1,1.0d0,sr,sg,s2f,s2a,
841     +          s2a2,s2c,s2c2)
842              t4 = s2f
843              sr(R_T) = 2.0d0*rhoa
844              sg(G_TT) = 4.0d0*t2
845              s3f = 0.0d0
846              call dcopy(NCOL_AMAT,0.0d0,0,s3a,1)
847              call dcopy(NCOL_AMAT2,0.0d0,0,s3a2,1)
848              call dcopy(NCOL_CMAT,0.0d0,0,s3c,1)
849              call dcopy(NCOL_CMAT2,0.0d0,0,s3c2,1)
850              call nwxcm_c_mpbe_d2(t1,tol_rho,ipol,1,1.0d0,sr,sg,s3f,
851     +          s3a,s3a2,s3c,s3c2)
852              t5 = s3f
853              t6 = 1.1325d+0*s3f-1.9125d-1*s2f-1.9125d-1*s1f
854              t7 = s2a(D1_RA)
855              t8 = 1.1325d+0*s3a(D1_RA)
856              t9 = 1/rhoa
857              t10 = -9.5625d-2*s2f*t9+9.5625d-2*s1f*t9+t8-1.9125d-1*t7
858              t11 = 1/rhoa**2
859              t12 = s1a(D1_RA)
860              fnc(iq) = 2.0d+0*rhoa*t6*wght+fnc(iq)
861              Amat(iq,D1_RA) = 1.0d+0*t6*wght+2.0d+0*rhoa*t10*wght
862     +          +Amat(iq,D1_RA)
863              Cmat(iq,D1_GAA) = Cmat(iq,D1_GAA)
864              Cmat(iq,D1_GAB) = Cmat(iq,D1_GAB)
865              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
866              Amat2(iq,D2_RA_RA) = 2.0d+0*rhoa*(-1.9125d-1*t7*t9
867     +          +1.1325d+0*s3a2(D2_RA_RA)-1.9125d-1*s2a2(D2_RA_RA)
868     +          +9.5625d-2*t11*s2f-9.5625d-2*t11*s1f)*wght+2.0d+0*t10
869     +          *wght+Amat2(iq,D2_RA_RA)
870              Amat2(iq,D2_RA_RB) = 2.0d+0*rhoa*(9.5625d-2*t7*t9
871     +          +9.5625d-2*t12*t9+1.1325d+0*s3a2(D2_RA_RB))*wght
872     +          +1.0d+0*(9.5625d-2*s2f*t9-9.5625d-2*s1f*t9+t8
873     +          -1.9125d-1*t12)*wght+1.0d+0*t10*wght+Amat2(iq,D2_RA_RB)
874              Cmat2(iq,D2_RA_GAA) = Cmat2(iq,D2_RA_GAA)
875              Cmat2(iq,D2_RA_GAB) = Cmat2(iq,D2_RA_GAB)
876              Cmat2(iq,D2_RA_GBB) = Cmat2(iq,D2_RA_GBB)
877              Cmat2(iq,D2_GAA_GAA) = Cmat2(iq,D2_GAA_GAA)
878              Cmat2(iq,D2_GAA_GAB) = Cmat2(iq,D2_GAA_GAB)
879              Cmat2(iq,D2_GAA_GBB) = Cmat2(iq,D2_GAA_GBB)
880              Cmat2(iq,D2_GAB_GAB) = Cmat2(iq,D2_GAB_GAB)
881              Mmat2(iq,D2_RA_TA) = Mmat2(iq,D2_RA_TA)
882              Mmat2(iq,D2_RA_TB) = Mmat2(iq,D2_RA_TB)
883              Mmat2(iq,D2_GAA_TA) = Mmat2(iq,D2_GAA_TA)
884              Mmat2(iq,D2_GAA_TB) = Mmat2(iq,D2_GAA_TB)
885              Mmat2(iq,D2_GAB_TA) = Mmat2(iq,D2_GAB_TA)
886              Mmat2(iq,D2_TA_TA) = Mmat2(iq,D2_TA_TA)
887              Mmat2(iq,D2_TA_TB) = Mmat2(iq,D2_TA_TB)
888            endif
889          endif ! rhoa.gt.tol_rho
890        else  ! ipol.eq.1
891          rhoa    = rho(iq,R_A)
892          rhob    = rho(iq,R_B)
893          gammaaa = rgamma(iq,G_AA)
894          gammaab = rgamma(iq,G_AB)
895          gammabb = rgamma(iq,G_BB)
896          taua    = tau(iq,T_A)
897          taub    = tau(iq,T_B)
898          if (rhoa.gt.tol_rho.and.rhob.gt.tol_rho) then
899            if (taua.gt.tol_rho.and.taub.gt.tol_rho) then
900              t1 = rhob+rhoa
901              t2 = param(1)
902              sr(R_A) = rhoa
903              sr(R_B) = 0.0d+0
904              sg(G_AA) = gammaaa
905              sg(G_AB) = 0.0d+0
906              sg(G_BB) = 0.0d+0
907              s1f = 0.0d0
908              call dcopy(NCOL_AMAT,0.0d0,0,s1a,1)
909              call dcopy(NCOL_AMAT2,0.0d0,0,s1a2,1)
910              call dcopy(NCOL_CMAT,0.0d0,0,s1c,1)
911              call dcopy(NCOL_CMAT2,0.0d0,0,s1c2,1)
912              call nwxcm_c_mpbe_d2(t2,tol_rho,2,1,1.0d0,sr,sg,s1f,s1a,
913     +          s1a2,s1c,s1c2)
914              t3 = s1f
915              t4 = gammaaa**2
916              t5 = 1/rhoa
917              t6 = 1/t1
918              t7 = 1/taua**2
919              sr(R_A) = 0.0d+0
920              sr(R_B) = rhob
921              sg(G_AA) = 0.0d+0
922              sg(G_AB) = 0.0d+0
923              sg(G_BB) = gammabb
924              s2f = 0.0d0
925              call dcopy(NCOL_AMAT,0.0d0,0,s2a,1)
926              call dcopy(NCOL_AMAT2,0.0d0,0,s2a2,1)
927              call dcopy(NCOL_CMAT,0.0d0,0,s2c,1)
928              call dcopy(NCOL_CMAT2,0.0d0,0,s2c2,1)
929              call nwxcm_c_mpbe_d2(t2,tol_rho,2,1,1.0d0,sr,sg,s2f,s2a,
930     +          s2a2,s2c,s2c2)
931              t8 = s2f
932              t9 = gammabb**2
933              t10 = 1/rhob
934              t11 = 1/taub**2
935              sr(R_A) = rhoa
936              sr(R_B) = rhob
937              sg(G_AA) = gammaaa
938              sg(G_AB) = gammaab
939              sg(G_BB) = gammabb
940              s3f = 0.0d0
941              call dcopy(NCOL_AMAT,0.0d0,0,s3a,1)
942              call dcopy(NCOL_AMAT2,0.0d0,0,s3a2,1)
943              call dcopy(NCOL_CMAT,0.0d0,0,s3c,1)
944              call dcopy(NCOL_CMAT2,0.0d0,0,s3c2,1)
945              call nwxcm_c_mpbe_d2(t2,tol_rho,ipol,1,1.0d0,sr,sg,s3f,
946     +          s3a,s3a2,s3c,s3c2)
947              t12 = s3f
948              t13 = 1.25d-1*gammaaa*t5+1.25d-1*gammabb*t10
949              t14 = t13**2
950              t15 = taub+taua
951              t16 = 1/t15**2
952              t17 = 5.3d-1*t14*t16+1.0d+0
953              t18 = -2.390625d-2*t10*t11*t6*s2f*t9-2.390625d-2*s1f*t4
954     +          *t5*t6*t7+s3f*t17
955              t19 = 1.0d+0*t18*wght
956              t20 = 1/t1**2
957              t21 = 2.390625d-2*t20*s1f*t4*t5*t7
958              t22 = 1/rhoa**2
959              t23 = s1a(D1_RA)
960              t24 = 2.390625d-2*t10*t11*t20*s2f*t9
961              t25 = s3a(D1_RA)
962              t26 = -2.390625d-2*t23*t4*t5*t6*t7+2.390625d-2*t22*s1f
963     +          *t4*t6*t7+t17*t25+t24-1.325d-1*gammaaa*s3f*t13*t16*t22
964     +          +t21
965              t27 = 1/rhob**2
966              t28 = s2a(D1_RB)
967              t29 = s3a(D1_RB)
968              t30 = 2.390625d-2*t11*t27*t6*s2f*t9-2.390625d-2*t10*t11
969     +          *t28*t6*t9+t17*t29-1.325d-1*gammabb*s3f*t13*t16*t27
970     +          +t24+t21
971              t31 = s1c(D1_GAA)
972              t32 = -2.390625d-2*t31*t4-4.78125d-2*gammaaa*s1f
973              t33 = 1.325d-1*s3f*t13*t16*t5
974              t34 = s3c(D1_GAA)
975              t35 = t17*t34
976              t36 = s3c(D1_GAB)
977              t37 = s2c(D1_GBB)
978              t38 = -2.390625d-2*t37*t9-4.78125d-2*gammabb*s2f
979              t39 = 1.325d-1*t10*s3f*t13*t16
980              t40 = s3c(D1_GBB)
981              t41 = t17*t40
982              t42 = 1/taua**3
983              t43 = 1/t15**3
984              t44 = -1.0600000000000001d+0*s3f*t14*t43
985              t45 = 4.78125d-2*s1f*t4*t42*t5*t6+t44
986              t46 = 1/taub**3
987              t47 = 4.78125d-2*t10*t46*t6*s2f*t9+t44
988              t48 = 1/t1**3
989              t49 = -4.78125d-2*s1f*t4*t48*t5*t7
990              t50 = 1/rhoa**3
991              t51 = -4.78125d-2*t10*t11*t48*s2f*t9
992              t52 = 1/rhob**3
993              t53 = 1.0d+0*(-2.390625d-2*t31*t4*t5*t6*t7-4.78125d-2
994     +          *gammaaa*s1f*t5*t6*t7+t35+t33)*wght
995              t54 = 4.78125d-2*gammaaa*t20*s1f*t5*t7
996              t55 = 2.390625d-2*t20*t31*t4*t5*t7
997              t56 = 1.0d+0*t17*t36*wght
998              t57 = 1.0d+0*(-2.390625d-2*t10*t11*t37*t6*t9-4.78125d-2
999     +          *gammabb*t10*t11*t6*s2f+t41+t39)*wght
1000              t58 = 4.78125d-2*gammabb*t10*t11*t20*s2f
1001              t59 = 2.390625d-2*t10*t11*t20*t37*t9
1002              t60 = 1.0d+0*t45*wght
1003              t61 = -4.78125d-2*t20*s1f*t4*t42*t5
1004              t62 = -1.0600000000000001d+0*t14*t25*t43
1005              t63 = 2.65d-1*gammaaa*s3f*t13*t22*t43
1006              t64 = 1.0d+0*t47*wght
1007              t65 = -4.78125d-2*t10*t20*t46*s2f*t9
1008              t66 = -1.0600000000000001d+0*t14*t29*t43
1009              t67 = 2.65d-1*gammabb*s3f*t13*t27*t43
1010              t68 = -1.0600000000000001d+0*t14*t34*t43
1011              t69 = -2.65d-1*s3f*t13*t43*t5
1012              t70 = -1.0600000000000001d+0*t1*t14*t36*t43*wght
1013              t71 = -1.0600000000000001d+0*t14*t40*t43
1014              t72 = -2.65d-1*t10*s3f*t13*t43
1015              t73 = 1/t15**4
1016              t74 = 3.18d+0*s3f*t14*t73
1017              fnc(iq) = 1.0d+0*t1*t18*wght+fnc(iq)
1018              Amat(iq,D1_RA) = 1.0d+0*t1*t26*wght+t19+Amat(iq,D1_RA)
1019              Amat(iq,D1_RB) = 1.0d+0*t1*t30*wght+t19+Amat(iq,D1_RB)
1020              Cmat(iq,D1_GAA) = 1.0d+0*t1*(t32*t5*t6*t7+t35+t33)*wght
1021     +          +Cmat(iq,D1_GAA)
1022              Cmat(iq,D1_GAB) = 1.0d+0*t1*t17*t36*wght+Cmat(iq,D1_GAB)
1023              Cmat(iq,D1_GBB) = 1.0d+0*t1*(t10*t11*t38*t6+t41+t39)
1024     +          *wght+Cmat(iq,D1_GBB)
1025              Mmat(iq,D1_TA) = 1.0d+0*t1*t45*wght+Mmat(iq,D1_TA)
1026              Mmat(iq,D1_TB) = 1.0d+0*t1*t47*wght+Mmat(iq,D1_TB)
1027              Amat2(iq,D2_RA_RA) = 1.0d+0*t1*(-4.78125d-2*s1f*t4*t50
1028     +          *t6*t7-2.390625d-2*s1a2(D2_RA_RA)*t4*t5*t6*t7
1029     +          +4.78125d-2*t22*t23*t4*t6*t7+4.78125d-2*t20*t23*t4*t5
1030     +          *t7-4.78125d-2*t20*t22*s1f*t4*t7+t51+2.65d-1*gammaaa
1031     +          *s3f*t13*t16*t50+t49+1.6562500000000002d-2*s3f*t16*t4
1032     +          /rhoa**4-2.65d-1*gammaaa*t13*t16*t22*t25+s3a2(D2_RA_RA
1033     +          )*t17)*wght+2.0d+0*t26*wght+Amat2(iq,D2_RA_RA)
1034              Amat2(iq,D2_RA_RB) = 1.0d+0*t1*(-2.390625d-2*t11*t20*t27
1035     +          *s2f*t9+2.390625d-2*t10*t11*t20*t28*t9+2.390625d-2*t20
1036     +          *t23*t4*t5*t7-2.390625d-2*t20*t22*s1f*t4*t7+t51+t49
1037     +          -1.325d-1*gammaaa*t13*t16*t22*t29-1.325d-1*gammabb*t13
1038     +          *t16*t25*t27+1.6562500000000002d-2*gammaaa*gammabb*s3f
1039     +          *t16*t22*t27+s3a2(D2_RA_RB)*t17)*wght+1.0d+0*t30*wght
1040     +          +1.0d+0*t26*wght+Amat2(iq,D2_RA_RB)
1041              Amat2(iq,D2_RB_RB) = 1.0d+0*t1*(-2.390625d-2*t10*t11*t6
1042     +          *s2a2(D2_RB_RB)*t9-4.78125d-2*t11*t52*t6*s2f*t9
1043     +          -4.78125d-2*t11*t20*t27*s2f*t9+4.78125d-2*t11*t27*t28
1044     +          *t6*t9+4.78125d-2*t10*t11*t20*t28*t9
1045     +          +1.6562500000000002d-2*s3f*t16*t9/rhob**4+2.65d-1
1046     +          *gammabb*s3f*t13*t16*t52+t51+t49-2.65d-1*gammabb*t13
1047     +          *t16*t27*t29+s3a2(D2_RB_RB)*t17)*wght+2.0d+0*t30*wght
1048     +          +Amat2(iq,D2_RB_RB)
1049              Cmat2(iq,D2_RA_GAA) = 1.0d+0*t1*(-2.390625d-2*s1c2
1050     +          (D2_RA_GAA)*t4*t5*t6*t7-4.78125d-2*gammaaa*t23*t5*t6
1051     +          *t7+2.390625d-2*t22*t31*t4*t6*t7+4.78125d-2*gammaaa
1052     +          *t22*s1f*t6*t7+t55+t54-1.6562500000000002d-2*gammaaa
1053     +          *s3f*t16*t50+1.325d-1*t13*t16*t25*t5-1.325d-1*gammaaa
1054     +          *t13*t16*t22*t34-1.325d-1*s3f*t13*t16*t22+s3c2
1055     +          (D2_RA_GAA)*t17)*wght+t53+Cmat2(iq,D2_RA_GAA)
1056              Cmat2(iq,D2_RA_GAB) = 1.0d+0*t1*(s3c2(D2_RA_GAB)*t17
1057     +          -1.325d-1*gammaaa*t13*t16*t22*t36)*wght+t56+Cmat2(iq,
1058     +          D2_RA_GAB)
1059              Cmat2(iq,D2_RA_GBB) = 1.0d+0*t1*(t59+t58-1.325d-1
1060     +          *gammaaa*t13*t16*t22*t40+1.325d-1*t10*t13*t16*t25
1061     +          -1.6562500000000002d-2*gammaaa*t10*s3f*t16*t22+s3c2
1062     +          (D2_RA_GBB)*t17)*wght+t57+Cmat2(iq,D2_RA_GBB)
1063              Cmat2(iq,D2_RB_GAA) = 1.0d+0*t1*(t55+t54+1.325d-1*t13
1064     +          *t16*t29*t5-1.6562500000000002d-2*gammabb*s3f*t16*t27
1065     +          *t5-1.325d-1*gammabb*t13*t16*t27*t34+s3c2(D2_RB_GAA)
1066     +          *t17)*wght+t53+Cmat2(iq,D2_RB_GAA)
1067              Cmat2(iq,D2_RB_GAB) = 1.0d+0*t1*(s3c2(D2_RB_GAB)*t17
1068     +          -1.325d-1*gammabb*t13*t16*t27*t36)*wght+t56+Cmat2(iq,
1069     +          D2_RB_GAB)
1070              Cmat2(iq,D2_RB_GBB) = 1.0d+0*t1*(-2.390625d-2*t10*t11*t6
1071     +          *s2c2(D2_RB_GBB)*t9+2.390625d-2*t11*t27*t37*t6*t9
1072     +          +4.78125d-2*gammabb*t11*t27*t6*s2f-4.78125d-2*gammabb
1073     +          *t10*t11*t28*t6+t59+t58-1.6562500000000002d-2*gammabb
1074     +          *s3f*t16*t52-1.325d-1*gammabb*t13*t16*t27*t40+1.325d-1
1075     +          *t10*t13*t16*t29-1.325d-1*s3f*t13*t16*t27+s3c2
1076     +          (D2_RB_GBB)*t17)*wght+t57+Cmat2(iq,D2_RB_GBB)
1077              Cmat2(iq,D2_GAA_GAA) = 1.0d+0*t1*((-2.390625d-2*s1c2
1078     +          (D2_GAA_GAA)*t4-9.5625d-2*gammaaa*t31-4.78125d-2*s1f)
1079     +          *t5*t6*t7+2.65d-1*t13*t16*t34*t5+1.6562500000000002d-2
1080     +          *s3f*t16*t22+s3c2(D2_GAA_GAA)*t17)*wght+Cmat2(iq,
1081     +          D2_GAA_GAA)
1082              Cmat2(iq,D2_GAA_GAB) = 1.0d+0*t1*(1.325d-1*t13*t16*t36
1083     +          *t5+s3c2(D2_GAA_GAB)*t17)*wght+Cmat2(iq,D2_GAA_GAB)
1084              Cmat2(iq,D2_GAA_GBB) = 1.0d+0*t1*(1.325d-1*t13*t16*t40
1085     +          *t5+1.6562500000000002d-2*t10*s3f*t16*t5+1.325d-1*t10
1086     +          *t13*t16*t34+s3c2(D2_GAA_GBB)*t17)*wght+Cmat2(iq,
1087     +          D2_GAA_GBB)
1088              Cmat2(iq,D2_GAB_GAB) = 1.0d+0*t1*s3c2(D2_GAB_GAB)*t17
1089     +          *wght+Cmat2(iq,D2_GAB_GAB)
1090              Cmat2(iq,D2_GAB_GBB) = 1.325d-1*t1*t10*t13*t16*t36*wght
1091     +          +1.0d+0*t1*s3c2(D2_GAB_GBB)*t17*wght+Cmat2(iq,
1092     +          D2_GAB_GBB)
1093              Cmat2(iq,D2_GBB_GBB) = 1.0d+0*t1*(t10*t11*t6*(
1094     +          -2.390625d-2*s2c2(D2_GBB_GBB)*t9-4.78125d-2*s2f
1095     +          -9.5625d-2*gammabb*t37)+2.65d-1*t10*t13*t16*t40
1096     +          +1.6562500000000002d-2*s3f*t16*t27+s3c2(D2_GBB_GBB)
1097     +          *t17)*wght+Cmat2(iq,D2_GBB_GBB)
1098              Mmat2(iq,D2_RA_TA) = 1.0d+0*t1*(t63+t62+t61+4.78125d-2
1099     +          *t23*t4*t42*t5*t6-4.78125d-2*t22*s1f*t4*t42*t6)*wght
1100     +          +t60+Mmat2(iq,D2_RA_TA)
1101              Mmat2(iq,D2_RA_TB) = 1.0d+0*t1*(t65+t63+t62)*wght+t64
1102     +          +Mmat2(iq,D2_RA_TB)
1103              Mmat2(iq,D2_RB_TA) = 1.0d+0*t1*(t67+t66+t61)*wght+t60
1104     +          +Mmat2(iq,D2_RB_TA)
1105              Mmat2(iq,D2_RB_TB) = 1.0d+0*t1*(-4.78125d-2*t27*t46*t6
1106     +          *s2f*t9+4.78125d-2*t10*t28*t46*t6*t9+t67+t66+t65)*wght
1107     +          +t64+Mmat2(iq,D2_RB_TB)
1108              Mmat2(iq,D2_GAA_TA) = 1.0d+0*t1*(t69+t68-2*t32*t42*t5*t6
1109     +          )*wght+Mmat2(iq,D2_GAA_TA)
1110              Mmat2(iq,D2_GAA_TB) = 1.0d+0*t1*(t69+t68)*wght+Mmat2(iq,
1111     +          D2_GAA_TB)
1112              Mmat2(iq,D2_GAB_TA) = t70+Mmat2(iq,D2_GAB_TA)
1113              Mmat2(iq,D2_GAB_TB) = t70+Mmat2(iq,D2_GAB_TB)
1114              Mmat2(iq,D2_GBB_TA) = 1.0d+0*t1*(t72+t71)*wght+Mmat2(iq,
1115     +          D2_GBB_TA)
1116              Mmat2(iq,D2_GBB_TB) = 1.0d+0*t1*(t72+t71-2*t10*t38*t46
1117     +          *t6)*wght+Mmat2(iq,D2_GBB_TB)
1118              Mmat2(iq,D2_TA_TA) = 1.0d+0*t1*(t74-1.434375d-1*s1f*t4
1119     +          *t5*t6/taua**4)*wght+Mmat2(iq,D2_TA_TA)
1120              Mmat2(iq,D2_TA_TB) = 3.18d+0*t1*s3f*t14*t73*wght+Mmat2
1121     +          (iq,D2_TA_TB)
1122              Mmat2(iq,D2_TB_TB) = 1.0d+0*t1*(t74-1.434375d-1*t10*t6
1123     +          *s2f*t9/taub**4)*wght+Mmat2(iq,D2_TB_TB)
1124            elseif (taua.gt.tol_rho.and.taub.le.tol_rho) then
1125              t1 = rhob+rhoa
1126              t2 = param(1)
1127              t3 = 4.0d-50*rhob
1128              sr(R_A) = 0.0d+0
1129              sr(R_B) = rhob
1130              sg(G_AA) = 0.0d+0
1131              sg(G_AB) = 0.0d+0
1132              sg(G_BB) = t3
1133              s1f = 0.0d0
1134              call dcopy(NCOL_AMAT,0.0d0,0,s1a,1)
1135              call dcopy(NCOL_AMAT2,0.0d0,0,s1a2,1)
1136              call dcopy(NCOL_CMAT,0.0d0,0,s1c,1)
1137              call dcopy(NCOL_CMAT2,0.0d0,0,s1c2,1)
1138              call nwxcm_c_mpbe_d2(t2,tol_rho,2,1,1.0d0,sr,sg,s1f,s1a,
1139     +          s1a2,s1c,s1c2)
1140              t4 = s1f
1141              t5 = 1/t1
1142              sr(R_A) = rhoa
1143              sr(R_B) = 0.0d+0
1144              sg(G_AA) = gammaaa
1145              sg(G_AB) = 0.0d+0
1146              sg(G_BB) = 0.0d+0
1147              s2f = 0.0d0
1148              call dcopy(NCOL_AMAT,0.0d0,0,s2a,1)
1149              call dcopy(NCOL_AMAT2,0.0d0,0,s2a2,1)
1150              call dcopy(NCOL_CMAT,0.0d0,0,s2c,1)
1151              call dcopy(NCOL_CMAT2,0.0d0,0,s2c2,1)
1152              call nwxcm_c_mpbe_d2(t2,tol_rho,2,1,1.0d0,sr,sg,s2f,s2a,
1153     +          s2a2,s2c,s2c2)
1154              t6 = s2f
1155              t7 = gammaaa**2
1156              t8 = 1/rhoa
1157              t9 = 1/taua**2
1158              sr(R_A) = rhoa
1159              sr(R_B) = rhob
1160              sg(G_AA) = gammaaa
1161              sg(G_AB) = 0
1162              sg(G_BB) = t3
1163              s3f = 0.0d0
1164              call dcopy(NCOL_AMAT,0.0d0,0,s3a,1)
1165              call dcopy(NCOL_AMAT2,0.0d0,0,s3a2,1)
1166              call dcopy(NCOL_CMAT,0.0d0,0,s3c,1)
1167              call dcopy(NCOL_CMAT2,0.0d0,0,s3c2,1)
1168              call nwxcm_c_mpbe_d2(t2,tol_rho,ipol,1,1.0d0,sr,sg,s3f,
1169     +          s3a,s3a2,s3c,s3c2)
1170              t10 = s3f
1171              t11 = 1.25d-1*gammaaa*t8+5.0d-51
1172              t12 = t11**2
1173              t13 = taua+1.0d-50
1174              t14 = 1/t13**2
1175              t15 = 5.3d-1*t12*t14+1.0d+0
1176              t16 = -2.390625d-2*t5*s2f*t7*t8*t9-3.825d-1*rhob*s1f*t5
1177     +          +s3f*t15
1178              t17 = 1.0d+0*t16*wght
1179              t18 = 1/t1**2
1180              t19 = 3.825d-1*rhob*t18*s1f
1181              t20 = 2.390625d-2*t18*s2f*t7*t8*t9
1182              t21 = 1/rhoa**2
1183              t22 = s2a(D1_RA)
1184              t23 = s3a(D1_RA)
1185              t24 = -2.390625d-2*t22*t5*t7*t8*t9+2.390625d-2*t21*t5
1186     +          *s2f*t7*t9+t15*t23-1.325d-1*gammaaa*s3f*t11*t14*t21
1187     +          +t20+t19
1188              t25 = s1a(D1_RB)
1189              t26 = s3a(D1_RB)
1190              t27 = -3.825d-1*s1f*t5-3.825d-1*rhob*t25*t5+t15*t26+t20
1191     +          +t19
1192              t28 = s2c(D1_GAA)
1193              t29 = -2.390625d-2*t28*t7-4.78125d-2*gammaaa*s2f
1194              t30 = 1.325d-1*s3f*t11*t14*t8
1195              t31 = s3c(D1_GAA)
1196              t32 = t15*t31
1197              t33 = 1/taua**3
1198              t34 = 1/t13**3
1199              t35 = 4.78125d-2*t33*t5*s2f*t7*t8-1.0600000000000001d+0
1200     +          *s3f*t12*t34
1201              t36 = 1/t1**3
1202              t37 = -7.65d-1*rhob*t36*s1f
1203              t38 = -4.78125d-2*t36*s2f*t7*t8*t9
1204              t39 = 1/rhoa**3
1205              t40 = 1.0d+0*(-2.390625d-2*t28*t5*t7*t8*t9-4.78125d-2
1206     +          *gammaaa*t5*s2f*t8*t9+t32+t30)*wght
1207              t41 = 4.78125d-2*gammaaa*t18*s2f*t8*t9
1208              t42 = 2.390625d-2*t18*t28*t7*t8*t9
1209              t43 = 1.0d+0*t35*wght
1210              t44 = -4.78125d-2*t18*t33*s2f*t7*t8
1211              fnc(iq) = 1.0d+0*t1*t16*wght+fnc(iq)
1212              Amat(iq,D1_RA) = 1.0d+0*t1*t24*wght+t17+Amat(iq,D1_RA)
1213              Amat(iq,D1_RB) = 1.0d+0*t1*t27*wght+t17+Amat(iq,D1_RB)
1214              Cmat(iq,D1_GAA) = 1.0d+0*t1*(t29*t5*t8*t9+t32+t30)*wght
1215     +          +Cmat(iq,D1_GAA)
1216              Cmat(iq,D1_GAB) = Cmat(iq,D1_GAB)
1217              Cmat(iq,D1_GBB) = Cmat(iq,D1_GBB)
1218              Mmat(iq,D1_TA) = 1.0d+0*t1*t35*wght+Mmat(iq,D1_TA)
1219              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
1220              Amat2(iq,D2_RA_RA) = 1.0d+0*t1*(-2.390625d-2*t5*s2a2
1221     +          (D2_RA_RA)*t7*t8*t9+4.78125d-2*t18*t22*t7*t8*t9
1222     +          -4.78125d-2*t39*t5*s2f*t7*t9-4.78125d-2*t18*t21*s2f*t7
1223     +          *t9+4.78125d-2*t21*t22*t5*t7*t9+1.6562500000000002d-2
1224     +          *s3f*t14*t7/rhoa**4+2.65d-1*gammaaa*s3f*t11*t14*t39
1225     +          +t38+t37-2.65d-1*gammaaa*t11*t14*t21*t23+s3a2(D2_RA_RA
1226     +          )*t15)*wght+2.0d+0*t24*wght+Amat2(iq,D2_RA_RA)
1227              Amat2(iq,D2_RA_RB) = 1.0d+0*t1*(2.390625d-2*t18*t22*t7
1228     +          *t8*t9-2.390625d-2*t18*t21*s2f*t7*t9+3.825d-1*t18*s1f
1229     +          +t38+t37-1.325d-1*gammaaa*t11*t14*t21*t26+3.825d-1
1230     +          *rhob*t18*t25+s3a2(D2_RA_RB)*t15)*wght+1.0d+0*t27*wght
1231     +          +1.0d+0*t24*wght+Amat2(iq,D2_RA_RB)
1232              Amat2(iq,D2_RB_RB) = 1.0d+0*t1*(-3.825d-1*rhob*s1a2
1233     +          (D2_RB_RB)*t5-7.65d-1*t25*t5+7.65d-1*t18*s1f+t38+t37
1234     +          +7.65d-1*rhob*t18*t25+s3a2(D2_RB_RB)*t15)*wght+2.0d+0
1235     +          *t27*wght+Amat2(iq,D2_RB_RB)
1236              Cmat2(iq,D2_RA_GAA) = 1.0d+0*t1*(-2.390625d-2*t5*s2c2
1237     +          (D2_RA_GAA)*t7*t8*t9-4.78125d-2*gammaaa*t22*t5*t8*t9
1238     +          +2.390625d-2*t21*t28*t5*t7*t9+4.78125d-2*gammaaa*t21
1239     +          *t5*s2f*t9+1.325d-1*t11*t14*t23*t8+t42+t41
1240     +          -1.6562500000000002d-2*gammaaa*s3f*t14*t39-1.325d-1
1241     +          *gammaaa*t11*t14*t21*t31-1.325d-1*s3f*t11*t14*t21+s3c2
1242     +          (D2_RA_GAA)*t15)*wght+t40+Cmat2(iq,D2_RA_GAA)
1243              Cmat2(iq,D2_RA_GAB) = Cmat2(iq,D2_RA_GAB)
1244              Cmat2(iq,D2_RA_GBB) = Cmat2(iq,D2_RA_GBB)
1245              Cmat2(iq,D2_RB_GAA) = 1.0d+0*t1*(1.325d-1*t11*t14*t26*t8
1246     +          +t42+t41+s3c2(D2_RB_GAA)*t15)*wght+t40+Cmat2(iq,
1247     +          D2_RB_GAA)
1248              Cmat2(iq,D2_RB_GAB) = Cmat2(iq,D2_RB_GAB)
1249              Cmat2(iq,D2_RB_GBB) = Cmat2(iq,D2_RB_GBB)
1250              Cmat2(iq,D2_GAA_GAA) = 1.0d+0*t1*(t5*(-2.390625d-2*s2c2
1251     +          (D2_GAA_GAA)*t7-4.78125d-2*s2f-9.5625d-2*gammaaa*t28)
1252     +          *t8*t9+2.65d-1*t11*t14*t31*t8+1.6562500000000002d-2
1253     +          *s3f*t14*t21+s3c2(D2_GAA_GAA)*t15)*wght+Cmat2(iq,
1254     +          D2_GAA_GAA)
1255              Cmat2(iq,D2_GAA_GAB) = Cmat2(iq,D2_GAA_GAB)
1256              Cmat2(iq,D2_GAA_GBB) = Cmat2(iq,D2_GAA_GBB)
1257              Cmat2(iq,D2_GAB_GAB) = Cmat2(iq,D2_GAB_GAB)
1258              Cmat2(iq,D2_GAB_GBB) = Cmat2(iq,D2_GAB_GBB)
1259              Cmat2(iq,D2_GBB_GBB) = Cmat2(iq,D2_GBB_GBB)
1260              Mmat2(iq,D2_RA_TA) = 1.0d+0*t1*(4.78125d-2*t22*t33*t5*t7
1261     +          *t8-4.78125d-2*t21*t33*t5*s2f*t7+t44
1262     +          -1.0600000000000001d+0*t12*t23*t34+2.65d-1*gammaaa*s3f
1263     +          *t11*t21*t34)*wght+t43+Mmat2(iq,D2_RA_TA)
1264              Mmat2(iq,D2_RA_TB) = Mmat2(iq,D2_RA_TB)
1265              Mmat2(iq,D2_RB_TA) = 1.0d+0*t1*(t44
1266     +          -1.0600000000000001d+0*t12*t26*t34)*wght+t43+Mmat2(iq,
1267     +          D2_RB_TA)
1268              Mmat2(iq,D2_RB_TB) = Mmat2(iq,D2_RB_TB)
1269              Mmat2(iq,D2_GAA_TA) = 1.0d+0*t1*(-2*t29*t33*t5*t8
1270     +          -2.65d-1*s3f*t11*t34*t8-1.0600000000000001d+0*t12*t31
1271     +          *t34)*wght+Mmat2(iq,D2_GAA_TA)
1272              Mmat2(iq,D2_GAA_TB) = Mmat2(iq,D2_GAA_TB)
1273              Mmat2(iq,D2_GAB_TA) = Mmat2(iq,D2_GAB_TA)
1274              Mmat2(iq,D2_GAB_TB) = Mmat2(iq,D2_GAB_TB)
1275              Mmat2(iq,D2_GBB_TA) = Mmat2(iq,D2_GBB_TA)
1276              Mmat2(iq,D2_GBB_TB) = Mmat2(iq,D2_GBB_TB)
1277              Mmat2(iq,D2_TA_TA) = 1.0d+0*t1*(3.18d+0*s3f*t12/t13**4
1278     +          -1.434375d-1*t5*s2f*t7*t8/taua**4)*wght+Mmat2(iq,
1279     +          D2_TA_TA)
1280              Mmat2(iq,D2_TA_TB) = Mmat2(iq,D2_TA_TB)
1281              Mmat2(iq,D2_TB_TB) = Mmat2(iq,D2_TB_TB)
1282            elseif (taua.le.tol_rho.and.taub.gt.tol_rho) then
1283              t1 = rhob+rhoa
1284              t2 = param(1)
1285              t3 = 4.0d-50*rhoa
1286              sr(R_A) = rhoa
1287              sr(R_B) = 0.0d+0
1288              sg(G_AA) = t3
1289              sg(G_AB) = 0.0d+0
1290              sg(G_BB) = 0.0d+0
1291              s1f = 0.0d0
1292              call dcopy(NCOL_AMAT,0.0d0,0,s1a,1)
1293              call dcopy(NCOL_AMAT2,0.0d0,0,s1a2,1)
1294              call dcopy(NCOL_CMAT,0.0d0,0,s1c,1)
1295              call dcopy(NCOL_CMAT2,0.0d0,0,s1c2,1)
1296              call nwxcm_c_mpbe_d2(t2,tol_rho,2,1,1.0d0,sr,sg,s1f,s1a,
1297     +          s1a2,s1c,s1c2)
1298              t4 = s1f
1299              t5 = 1/t1
1300              sr(R_A) = 0.0d+0
1301              sr(R_B) = rhob
1302              sg(G_AA) = 0.0d+0
1303              sg(G_AB) = 0.0d+0
1304              sg(G_BB) = gammabb
1305              s2f = 0.0d0
1306              call dcopy(NCOL_AMAT,0.0d0,0,s2a,1)
1307              call dcopy(NCOL_AMAT2,0.0d0,0,s2a2,1)
1308              call dcopy(NCOL_CMAT,0.0d0,0,s2c,1)
1309              call dcopy(NCOL_CMAT2,0.0d0,0,s2c2,1)
1310              call nwxcm_c_mpbe_d2(t2,tol_rho,2,1,1.0d0,sr,sg,s2f,s2a,
1311     +          s2a2,s2c,s2c2)
1312              t6 = s2f
1313              t7 = gammabb**2
1314              t8 = 1/rhob
1315              t9 = 1/taub**2
1316              sr(R_A) = rhoa
1317              sr(R_B) = rhob
1318              sg(G_AA) = t3
1319              sg(G_AB) = 0
1320              sg(G_BB) = gammabb
1321              s3f = 0.0d0
1322              call dcopy(NCOL_AMAT,0.0d0,0,s3a,1)
1323              call dcopy(NCOL_AMAT2,0.0d0,0,s3a2,1)
1324              call dcopy(NCOL_CMAT,0.0d0,0,s3c,1)
1325              call dcopy(NCOL_CMAT2,0.0d0,0,s3c2,1)
1326              call nwxcm_c_mpbe_d2(t2,tol_rho,ipol,1,1.0d0,sr,sg,s3f,
1327     +          s3a,s3a2,s3c,s3c2)
1328              t10 = s3f
1329              t11 = 1.25d-1*gammabb*t8+5.0d-51
1330              t12 = t11**2
1331              t13 = taub+1.0d-50
1332              t14 = 1/t13**2
1333              t15 = 5.3d-1*t12*t14+1.0d+0
1334              t16 = -2.390625d-2*t5*s2f*t7*t8*t9-3.825d-1*rhoa*s1f*t5
1335     +          +s3f*t15
1336              t17 = 1.0d+0*t16*wght
1337              t18 = 1/t1**2
1338              t19 = 3.825d-1*rhoa*t18*s1f
1339              t20 = s1a(D1_RA)
1340              t21 = 2.390625d-2*t18*s2f*t7*t8*t9
1341              t22 = s3a(D1_RA)
1342              t23 = -3.825d-1*s1f*t5-3.825d-1*rhoa*t20*t5+t15*t22+t21
1343     +          +t19
1344              t24 = 1/rhob**2
1345              t25 = s2a(D1_RB)
1346              t26 = s3a(D1_RB)
1347              t27 = -2.390625d-2*t25*t5*t7*t8*t9+2.390625d-2*t24*t5
1348     +          *s2f*t7*t9+t15*t26-1.325d-1*gammabb*s3f*t11*t14*t24
1349     +          +t21+t19
1350              t28 = s2c(D1_GBB)
1351              t29 = -2.390625d-2*t28*t7-4.78125d-2*gammabb*s2f
1352              t30 = 1.325d-1*s3f*t11*t14*t8
1353              t31 = s3c(D1_GBB)
1354              t32 = t15*t31
1355              t33 = 1/taub**3
1356              t34 = 1/t13**3
1357              t35 = 4.78125d-2*t33*t5*s2f*t7*t8-1.0600000000000001d+0
1358     +          *s3f*t12*t34
1359              t36 = 1/t1**3
1360              t37 = -7.65d-1*rhoa*t36*s1f
1361              t38 = -4.78125d-2*t36*s2f*t7*t8*t9
1362              t39 = 1/rhob**3
1363              t40 = 1.0d+0*(-2.390625d-2*t28*t5*t7*t8*t9-4.78125d-2
1364     +          *gammabb*t5*s2f*t8*t9+t32+t30)*wght
1365              t41 = 4.78125d-2*gammabb*t18*s2f*t8*t9
1366              t42 = 2.390625d-2*t18*t28*t7*t8*t9
1367              t43 = 1.0d+0*t35*wght
1368              t44 = -4.78125d-2*t18*t33*s2f*t7*t8
1369              fnc(iq) = 1.0d+0*t1*t16*wght+fnc(iq)
1370              Amat(iq,D1_RA) = 1.0d+0*t1*t23*wght+t17+Amat(iq,D1_RA)
1371              Amat(iq,D1_RB) = 1.0d+0*t1*t27*wght+t17+Amat(iq,D1_RB)
1372              Cmat(iq,D1_GAA) = Cmat(iq,D1_GAA)
1373              Cmat(iq,D1_GAB) = Cmat(iq,D1_GAB)
1374              Cmat(iq,D1_GBB) = 1.0d+0*t1*(t29*t5*t8*t9+t32+t30)*wght
1375     +          +Cmat(iq,D1_GBB)
1376              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
1377              Mmat(iq,D1_TB) = 1.0d+0*t1*t35*wght+Mmat(iq,D1_TB)
1378              Amat2(iq,D2_RA_RA) = 1.0d+0*t1*(-3.825d-1*rhoa*s1a2
1379     +          (D2_RA_RA)*t5-7.65d-1*t20*t5+7.65d-1*t18*s1f+t38+t37
1380     +          +7.65d-1*rhoa*t18*t20+s3a2(D2_RA_RA)*t15)*wght+2.0d+0
1381     +          *t23*wght+Amat2(iq,D2_RA_RA)
1382              Amat2(iq,D2_RA_RB) = 1.0d+0*t1*(2.390625d-2*t18*t25*t7
1383     +          *t8*t9-2.390625d-2*t18*t24*s2f*t7*t9+3.825d-1*t18*s1f
1384     +          +t38+t37-1.325d-1*gammabb*t11*t14*t22*t24+3.825d-1
1385     +          *rhoa*t18*t20+s3a2(D2_RA_RB)*t15)*wght+1.0d+0*t27*wght
1386     +          +1.0d+0*t23*wght+Amat2(iq,D2_RA_RB)
1387              Amat2(iq,D2_RB_RB) = 1.0d+0*t1*(-2.390625d-2*t5*s2a2
1388     +          (D2_RB_RB)*t7*t8*t9+4.78125d-2*t18*t25*t7*t8*t9
1389     +          -4.78125d-2*t39*t5*s2f*t7*t9-4.78125d-2*t18*t24*s2f*t7
1390     +          *t9+4.78125d-2*t24*t25*t5*t7*t9+1.6562500000000002d-2
1391     +          *s3f*t14*t7/rhob**4+2.65d-1*gammabb*s3f*t11*t14*t39
1392     +          +t38+t37-2.65d-1*gammabb*t11*t14*t24*t26+s3a2(D2_RB_RB
1393     +          )*t15)*wght+2.0d+0*t27*wght+Amat2(iq,D2_RB_RB)
1394              Cmat2(iq,D2_RA_GAA) = Cmat2(iq,D2_RA_GAA)
1395              Cmat2(iq,D2_RA_GAB) = Cmat2(iq,D2_RA_GAB)
1396              Cmat2(iq,D2_RA_GBB) = 1.0d+0*t1*(1.325d-1*t11*t14*t22*t8
1397     +          +t42+t41+s3c2(D2_RA_GBB)*t15)*wght+t40+Cmat2(iq,
1398     +          D2_RA_GBB)
1399              Cmat2(iq,D2_RB_GAA) = Cmat2(iq,D2_RB_GAA)
1400              Cmat2(iq,D2_RB_GAB) = Cmat2(iq,D2_RB_GAB)
1401              Cmat2(iq,D2_RB_GBB) = 1.0d+0*t1*(-2.390625d-2*t5*s2c2
1402     +          (D2_RB_GBB)*t7*t8*t9-4.78125d-2*gammabb*t25*t5*t8*t9
1403     +          +2.390625d-2*t24*t28*t5*t7*t9+4.78125d-2*gammabb*t24
1404     +          *t5*s2f*t9+1.325d-1*t11*t14*t26*t8+t42+t41
1405     +          -1.6562500000000002d-2*gammabb*s3f*t14*t39-1.325d-1
1406     +          *gammabb*t11*t14*t24*t31-1.325d-1*s3f*t11*t14*t24+s3c2
1407     +          (D2_RB_GBB)*t15)*wght+t40+Cmat2(iq,D2_RB_GBB)
1408              Cmat2(iq,D2_GAA_GAA) = Cmat2(iq,D2_GAA_GAA)
1409              Cmat2(iq,D2_GAA_GAB) = Cmat2(iq,D2_GAA_GAB)
1410              Cmat2(iq,D2_GAA_GBB) = Cmat2(iq,D2_GAA_GBB)
1411              Cmat2(iq,D2_GAB_GAB) = Cmat2(iq,D2_GAB_GAB)
1412              Cmat2(iq,D2_GAB_GBB) = Cmat2(iq,D2_GAB_GBB)
1413              Cmat2(iq,D2_GBB_GBB) = 1.0d+0*t1*(t5*(-2.390625d-2*s2c2
1414     +          (D2_GBB_GBB)*t7-4.78125d-2*s2f-9.5625d-2*gammabb*t28)
1415     +          *t8*t9+2.65d-1*t11*t14*t31*t8+1.6562500000000002d-2
1416     +          *s3f*t14*t24+s3c2(D2_GBB_GBB)*t15)*wght+Cmat2(iq,
1417     +          D2_GBB_GBB)
1418              Mmat2(iq,D2_RA_TA) = Mmat2(iq,D2_RA_TA)
1419              Mmat2(iq,D2_RA_TB) = 1.0d+0*t1*(t44
1420     +          -1.0600000000000001d+0*t12*t22*t34)*wght+t43+Mmat2(iq,
1421     +          D2_RA_TB)
1422              Mmat2(iq,D2_RB_TA) = Mmat2(iq,D2_RB_TA)
1423              Mmat2(iq,D2_RB_TB) = 1.0d+0*t1*(4.78125d-2*t25*t33*t5*t7
1424     +          *t8-4.78125d-2*t24*t33*t5*s2f*t7+t44
1425     +          -1.0600000000000001d+0*t12*t26*t34+2.65d-1*gammabb*s3f
1426     +          *t11*t24*t34)*wght+t43+Mmat2(iq,D2_RB_TB)
1427              Mmat2(iq,D2_GAA_TA) = Mmat2(iq,D2_GAA_TA)
1428              Mmat2(iq,D2_GAA_TB) = Mmat2(iq,D2_GAA_TB)
1429              Mmat2(iq,D2_GAB_TA) = Mmat2(iq,D2_GAB_TA)
1430              Mmat2(iq,D2_GAB_TB) = Mmat2(iq,D2_GAB_TB)
1431              Mmat2(iq,D2_GBB_TA) = Mmat2(iq,D2_GBB_TA)
1432              Mmat2(iq,D2_GBB_TB) = 1.0d+0*t1*(-2*t29*t33*t5*t8
1433     +          -2.65d-1*s3f*t11*t34*t8-1.0600000000000001d+0*t12*t31
1434     +          *t34)*wght+Mmat2(iq,D2_GBB_TB)
1435              Mmat2(iq,D2_TA_TA) = Mmat2(iq,D2_TA_TA)
1436              Mmat2(iq,D2_TA_TB) = Mmat2(iq,D2_TA_TB)
1437              Mmat2(iq,D2_TB_TB) = 1.0d+0*t1*(3.18d+0*s3f*t12/t13**4
1438     +          -1.434375d-1*t5*s2f*t7*t8/taub**4)*wght+Mmat2(iq,
1439     +          D2_TB_TB)
1440            else
1441              t1 = rhob+rhoa
1442              t2 = param(1)
1443              t3 = 4.0d-50*rhoa
1444              t4 = 4.0d-50*rhob
1445              sr(R_A) = rhoa
1446              sr(R_B) = rhob
1447              sg(G_AA) = t3
1448              sg(G_AB) = 0
1449              sg(G_BB) = t4
1450              s1f = 0.0d0
1451              call dcopy(NCOL_AMAT,0.0d0,0,s1a,1)
1452              call dcopy(NCOL_AMAT2,0.0d0,0,s1a2,1)
1453              call dcopy(NCOL_CMAT,0.0d0,0,s1c,1)
1454              call dcopy(NCOL_CMAT2,0.0d0,0,s1c2,1)
1455              call nwxcm_c_mpbe_d2(t2,tol_rho,ipol,1,1.0d0,sr,sg,s1f,
1456     +          s1a,s1a2,s1c,s1c2)
1457              t5 = s1f
1458              sr(R_A) = rhoa
1459              sr(R_B) = 0.0d+0
1460              sg(G_AA) = t3
1461              sg(G_AB) = 0.0d+0
1462              sg(G_BB) = 0.0d+0
1463              s2f = 0.0d0
1464              call dcopy(NCOL_AMAT,0.0d0,0,s2a,1)
1465              call dcopy(NCOL_AMAT2,0.0d0,0,s2a2,1)
1466              call dcopy(NCOL_CMAT,0.0d0,0,s2c,1)
1467              call dcopy(NCOL_CMAT2,0.0d0,0,s2c2,1)
1468              call nwxcm_c_mpbe_d2(t2,tol_rho,2,1,1.0d0,sr,sg,s2f,s2a,
1469     +          s2a2,s2c,s2c2)
1470              t6 = s2f
1471              t7 = 1/t1
1472              sr(R_A) = 0.0d+0
1473              sr(R_B) = rhob
1474              sg(G_AA) = 0.0d+0
1475              sg(G_AB) = 0.0d+0
1476              sg(G_BB) = t4
1477              s3f = 0.0d0
1478              call dcopy(NCOL_AMAT,0.0d0,0,s3a,1)
1479              call dcopy(NCOL_AMAT2,0.0d0,0,s3a2,1)
1480              call dcopy(NCOL_CMAT,0.0d0,0,s3c,1)
1481              call dcopy(NCOL_CMAT2,0.0d0,0,s3c2,1)
1482              call nwxcm_c_mpbe_d2(t2,tol_rho,2,1,1.0d0,sr,sg,s3f,s3a,
1483     +          s3a2,s3c,s3c2)
1484              t8 = s3f
1485              t9 = -3.825d-1*rhob*t7*s3f-3.825d-1*rhoa*s2f*t7
1486     +          +1.1325d+0*s1f
1487              t10 = 1/t1**2
1488              t11 = 3.825d-1*rhoa*t10*s2f
1489              t12 = 3.825d-1*rhob*t10*s3f
1490              t13 = s2a(D1_RA)
1491              t14 = -3.825d-1*s2f*t7-3.825d-1*rhoa*t13*t7+1.1325d+0
1492     +          *s1a(D1_RA)+t12+t11
1493              t15 = 1.0d+0*t9*wght
1494              t16 = s3a(D1_RB)
1495              t17 = -3.825d-1*t7*s3f-3.825d-1*rhob*t16*t7+1.1325d+0
1496     +          *s1a(D1_RB)+t12+t11
1497              t18 = 1/t1**3
1498              t19 = -7.65d-1*rhoa*t18*s2f
1499              t20 = -7.65d-1*rhob*t18*s3f
1500              fnc(iq) = 1.0d+0*t1*t9*wght+fnc(iq)
1501              Amat(iq,D1_RA) = 1.0d+0*t1*t14*wght+t15+Amat(iq,D1_RA)
1502              Amat(iq,D1_RB) = 1.0d+0*t1*t17*wght+t15+Amat(iq,D1_RB)
1503              Cmat(iq,D1_GAA) = Cmat(iq,D1_GAA)
1504              Cmat(iq,D1_GAB) = Cmat(iq,D1_GAB)
1505              Cmat(iq,D1_GBB) = Cmat(iq,D1_GBB)
1506              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
1507              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
1508              Amat2(iq,D2_RA_RA) = 1.0d+0*t1*(-3.825d-1*rhoa*s2a2
1509     +          (D2_RA_RA)*t7-7.65d-1*t13*t7+7.65d-1*t10*s2f+1.1325d+0
1510     +          *s1a2(D2_RA_RA)+t20+t19+7.65d-1*rhoa*t10*t13)*wght
1511     +          +2.0d+0*t14*wght+Amat2(iq,D2_RA_RA)
1512              Amat2(iq,D2_RA_RB) = 1.0d+0*t1*(3.825d-1*t10*s3f
1513     +          +3.825d-1*t10*s2f+1.1325d+0*s1a2(D2_RA_RB)+t20+t19
1514     +          +3.825d-1*rhob*t10*t16+3.825d-1*rhoa*t10*t13)*wght
1515     +          +1.0d+0*t17*wght+1.0d+0*t14*wght+Amat2(iq,D2_RA_RB)
1516              Amat2(iq,D2_RB_RB) = 1.0d+0*t1*(-3.825d-1*rhob*t7*s3a2
1517     +          (D2_RB_RB)+7.65d-1*t10*s3f-7.65d-1*t16*t7+1.1325d+0
1518     +          *s1a2(D2_RB_RB)+t20+t19+7.65d-1*rhob*t10*t16)*wght
1519     +          +2.0d+0*t17*wght+Amat2(iq,D2_RB_RB)
1520              Cmat2(iq,D2_RA_GAA) = Cmat2(iq,D2_RA_GAA)
1521              Cmat2(iq,D2_RA_GAB) = Cmat2(iq,D2_RA_GAB)
1522              Cmat2(iq,D2_RA_GBB) = Cmat2(iq,D2_RA_GBB)
1523              Cmat2(iq,D2_RB_GAA) = Cmat2(iq,D2_RB_GAA)
1524              Cmat2(iq,D2_RB_GAB) = Cmat2(iq,D2_RB_GAB)
1525              Cmat2(iq,D2_RB_GBB) = Cmat2(iq,D2_RB_GBB)
1526              Cmat2(iq,D2_GAA_GAA) = Cmat2(iq,D2_GAA_GAA)
1527              Cmat2(iq,D2_GAA_GAB) = Cmat2(iq,D2_GAA_GAB)
1528              Cmat2(iq,D2_GAA_GBB) = Cmat2(iq,D2_GAA_GBB)
1529              Cmat2(iq,D2_GAB_GAB) = Cmat2(iq,D2_GAB_GAB)
1530              Cmat2(iq,D2_GAB_GBB) = Cmat2(iq,D2_GAB_GBB)
1531              Cmat2(iq,D2_GBB_GBB) = Cmat2(iq,D2_GBB_GBB)
1532              Mmat2(iq,D2_RA_TA) = Mmat2(iq,D2_RA_TA)
1533              Mmat2(iq,D2_RA_TB) = Mmat2(iq,D2_RA_TB)
1534              Mmat2(iq,D2_RB_TA) = Mmat2(iq,D2_RB_TA)
1535              Mmat2(iq,D2_RB_TB) = Mmat2(iq,D2_RB_TB)
1536              Mmat2(iq,D2_GAA_TA) = Mmat2(iq,D2_GAA_TA)
1537              Mmat2(iq,D2_GAA_TB) = Mmat2(iq,D2_GAA_TB)
1538              Mmat2(iq,D2_GAB_TA) = Mmat2(iq,D2_GAB_TA)
1539              Mmat2(iq,D2_GAB_TB) = Mmat2(iq,D2_GAB_TB)
1540              Mmat2(iq,D2_GBB_TA) = Mmat2(iq,D2_GBB_TA)
1541              Mmat2(iq,D2_GBB_TB) = Mmat2(iq,D2_GBB_TB)
1542              Mmat2(iq,D2_TA_TA) = Mmat2(iq,D2_TA_TA)
1543              Mmat2(iq,D2_TA_TB) = Mmat2(iq,D2_TA_TB)
1544              Mmat2(iq,D2_TB_TB) = Mmat2(iq,D2_TB_TB)
1545            endif
1546          elseif (rhoa.gt.tol_rho.and.rhob.le.tol_rho) then
1547            if (taua.gt.tol_rho.and.taub.gt.tol_rho) then
1548              fnc(iq) = fnc(iq)
1549              Amat(iq,D1_RA) = Amat(iq,D1_RA)
1550              Cmat(iq,D1_GAA) = Cmat(iq,D1_GAA)
1551              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
1552              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
1553              Amat2(iq,D2_RA_RA) = Amat2(iq,D2_RA_RA)
1554              Cmat2(iq,D2_RA_GAA) = Cmat2(iq,D2_RA_GAA)
1555              Cmat2(iq,D2_GAA_GAA) = Cmat2(iq,D2_GAA_GAA)
1556              Mmat2(iq,D2_RA_TA) = Mmat2(iq,D2_RA_TA)
1557              Mmat2(iq,D2_RA_TB) = Mmat2(iq,D2_RA_TB)
1558              Mmat2(iq,D2_GAA_TA) = Mmat2(iq,D2_GAA_TA)
1559              Mmat2(iq,D2_GAA_TB) = Mmat2(iq,D2_GAA_TB)
1560              Mmat2(iq,D2_TA_TA) = Mmat2(iq,D2_TA_TA)
1561              Mmat2(iq,D2_TA_TB) = Mmat2(iq,D2_TA_TB)
1562              Mmat2(iq,D2_TB_TB) = Mmat2(iq,D2_TB_TB)
1563            elseif (taua.gt.tol_rho.and.taub.le.tol_rho) then
1564              fnc(iq) = fnc(iq)
1565              Amat(iq,D1_RA) = Amat(iq,D1_RA)
1566              Cmat(iq,D1_GAA) = Cmat(iq,D1_GAA)
1567              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
1568              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
1569              Amat2(iq,D2_RA_RA) = Amat2(iq,D2_RA_RA)
1570              Cmat2(iq,D2_RA_GAA) = Cmat2(iq,D2_RA_GAA)
1571              Cmat2(iq,D2_GAA_GAA) = Cmat2(iq,D2_GAA_GAA)
1572              Mmat2(iq,D2_RA_TA) = Mmat2(iq,D2_RA_TA)
1573              Mmat2(iq,D2_RA_TB) = Mmat2(iq,D2_RA_TB)
1574              Mmat2(iq,D2_GAA_TA) = Mmat2(iq,D2_GAA_TA)
1575              Mmat2(iq,D2_GAA_TB) = Mmat2(iq,D2_GAA_TB)
1576              Mmat2(iq,D2_TA_TA) = Mmat2(iq,D2_TA_TA)
1577              Mmat2(iq,D2_TA_TB) = Mmat2(iq,D2_TA_TB)
1578              Mmat2(iq,D2_TB_TB) = Mmat2(iq,D2_TB_TB)
1579            elseif (taua.le.tol_rho.and.taub.gt.tol_rho) then
1580              fnc(iq) = fnc(iq)
1581              Amat(iq,D1_RA) = Amat(iq,D1_RA)
1582              Cmat(iq,D1_GAA) = Cmat(iq,D1_GAA)
1583              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
1584              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
1585              Amat2(iq,D2_RA_RA) = Amat2(iq,D2_RA_RA)
1586              Cmat2(iq,D2_RA_GAA) = Cmat2(iq,D2_RA_GAA)
1587              Cmat2(iq,D2_GAA_GAA) = Cmat2(iq,D2_GAA_GAA)
1588              Mmat2(iq,D2_RA_TA) = Mmat2(iq,D2_RA_TA)
1589              Mmat2(iq,D2_RA_TB) = Mmat2(iq,D2_RA_TB)
1590              Mmat2(iq,D2_GAA_TA) = Mmat2(iq,D2_GAA_TA)
1591              Mmat2(iq,D2_GAA_TB) = Mmat2(iq,D2_GAA_TB)
1592              Mmat2(iq,D2_TA_TA) = Mmat2(iq,D2_TA_TA)
1593              Mmat2(iq,D2_TA_TB) = Mmat2(iq,D2_TA_TB)
1594              Mmat2(iq,D2_TB_TB) = Mmat2(iq,D2_TB_TB)
1595            else
1596              fnc(iq) = fnc(iq)
1597              Amat(iq,D1_RA) = Amat(iq,D1_RA)
1598              Cmat(iq,D1_GAA) = Cmat(iq,D1_GAA)
1599              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
1600              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
1601              Amat2(iq,D2_RA_RA) = Amat2(iq,D2_RA_RA)
1602              Cmat2(iq,D2_RA_GAA) = Cmat2(iq,D2_RA_GAA)
1603              Cmat2(iq,D2_GAA_GAA) = Cmat2(iq,D2_GAA_GAA)
1604              Mmat2(iq,D2_RA_TA) = Mmat2(iq,D2_RA_TA)
1605              Mmat2(iq,D2_RA_TB) = Mmat2(iq,D2_RA_TB)
1606              Mmat2(iq,D2_GAA_TA) = Mmat2(iq,D2_GAA_TA)
1607              Mmat2(iq,D2_GAA_TB) = Mmat2(iq,D2_GAA_TB)
1608              Mmat2(iq,D2_TA_TA) = Mmat2(iq,D2_TA_TA)
1609              Mmat2(iq,D2_TA_TB) = Mmat2(iq,D2_TA_TB)
1610              Mmat2(iq,D2_TB_TB) = Mmat2(iq,D2_TB_TB)
1611            endif
1612          elseif (rhoa.le.tol_rho.and.rhob.gt.tol_rho) then
1613            if (taua.gt.tol_rho.and.taub.gt.tol_rho) then
1614              fnc(iq) = fnc(iq)
1615              Amat(iq,D1_RB) = Amat(iq,D1_RB)
1616              Cmat(iq,D1_GBB) = Cmat(iq,D1_GBB)
1617              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
1618              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
1619              Amat2(iq,D2_RB_RB) = Amat2(iq,D2_RB_RB)
1620              Cmat2(iq,D2_RB_GBB) = Cmat2(iq,D2_RB_GBB)
1621              Cmat2(iq,D2_GBB_GBB) = Cmat2(iq,D2_GBB_GBB)
1622              Mmat2(iq,D2_RB_TA) = Mmat2(iq,D2_RB_TA)
1623              Mmat2(iq,D2_RB_TB) = Mmat2(iq,D2_RB_TB)
1624              Mmat2(iq,D2_GBB_TA) = Mmat2(iq,D2_GBB_TA)
1625              Mmat2(iq,D2_GBB_TB) = Mmat2(iq,D2_GBB_TB)
1626              Mmat2(iq,D2_TA_TA) = Mmat2(iq,D2_TA_TA)
1627              Mmat2(iq,D2_TA_TB) = Mmat2(iq,D2_TA_TB)
1628              Mmat2(iq,D2_TB_TB) = Mmat2(iq,D2_TB_TB)
1629            elseif (taua.gt.tol_rho.and.taub.le.tol_rho) then
1630              fnc(iq) = fnc(iq)
1631              Amat(iq,D1_RB) = Amat(iq,D1_RB)
1632              Cmat(iq,D1_GBB) = Cmat(iq,D1_GBB)
1633              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
1634              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
1635              Amat2(iq,D2_RB_RB) = Amat2(iq,D2_RB_RB)
1636              Cmat2(iq,D2_RB_GBB) = Cmat2(iq,D2_RB_GBB)
1637              Cmat2(iq,D2_GBB_GBB) = Cmat2(iq,D2_GBB_GBB)
1638              Mmat2(iq,D2_RB_TA) = Mmat2(iq,D2_RB_TA)
1639              Mmat2(iq,D2_RB_TB) = Mmat2(iq,D2_RB_TB)
1640              Mmat2(iq,D2_GBB_TA) = Mmat2(iq,D2_GBB_TA)
1641              Mmat2(iq,D2_GBB_TB) = Mmat2(iq,D2_GBB_TB)
1642              Mmat2(iq,D2_TA_TA) = Mmat2(iq,D2_TA_TA)
1643              Mmat2(iq,D2_TA_TB) = Mmat2(iq,D2_TA_TB)
1644              Mmat2(iq,D2_TB_TB) = Mmat2(iq,D2_TB_TB)
1645            elseif (taua.le.tol_rho.and.taub.gt.tol_rho) then
1646              fnc(iq) = fnc(iq)
1647              Amat(iq,D1_RB) = Amat(iq,D1_RB)
1648              Cmat(iq,D1_GBB) = Cmat(iq,D1_GBB)
1649              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
1650              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
1651              Amat2(iq,D2_RB_RB) = Amat2(iq,D2_RB_RB)
1652              Cmat2(iq,D2_RB_GBB) = Cmat2(iq,D2_RB_GBB)
1653              Cmat2(iq,D2_GBB_GBB) = Cmat2(iq,D2_GBB_GBB)
1654              Mmat2(iq,D2_RB_TA) = Mmat2(iq,D2_RB_TA)
1655              Mmat2(iq,D2_RB_TB) = Mmat2(iq,D2_RB_TB)
1656              Mmat2(iq,D2_GBB_TA) = Mmat2(iq,D2_GBB_TA)
1657              Mmat2(iq,D2_GBB_TB) = Mmat2(iq,D2_GBB_TB)
1658              Mmat2(iq,D2_TA_TA) = Mmat2(iq,D2_TA_TA)
1659              Mmat2(iq,D2_TA_TB) = Mmat2(iq,D2_TA_TB)
1660              Mmat2(iq,D2_TB_TB) = Mmat2(iq,D2_TB_TB)
1661            else
1662              fnc(iq) = fnc(iq)
1663              Amat(iq,D1_RB) = Amat(iq,D1_RB)
1664              Cmat(iq,D1_GBB) = Cmat(iq,D1_GBB)
1665              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
1666              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
1667              Amat2(iq,D2_RB_RB) = Amat2(iq,D2_RB_RB)
1668              Cmat2(iq,D2_RB_GBB) = Cmat2(iq,D2_RB_GBB)
1669              Cmat2(iq,D2_GBB_GBB) = Cmat2(iq,D2_GBB_GBB)
1670              Mmat2(iq,D2_RB_TA) = Mmat2(iq,D2_RB_TA)
1671              Mmat2(iq,D2_RB_TB) = Mmat2(iq,D2_RB_TB)
1672              Mmat2(iq,D2_GBB_TA) = Mmat2(iq,D2_GBB_TA)
1673              Mmat2(iq,D2_GBB_TB) = Mmat2(iq,D2_GBB_TB)
1674              Mmat2(iq,D2_TA_TA) = Mmat2(iq,D2_TA_TA)
1675              Mmat2(iq,D2_TA_TB) = Mmat2(iq,D2_TA_TB)
1676              Mmat2(iq,D2_TB_TB) = Mmat2(iq,D2_TB_TB)
1677            endif
1678          endif ! rhoa.gt.tol_rho.and.rhob.gt.tol_rho
1679        endif ! ipol.eq.1
1680      enddo ! iq
1681      end subroutine nwxcm_c_pkzb99_d2
1682C>
1683C> \brief Evaluate the nwxcm_c_pkzb99 functional [1]
1684C>
1685C> \f{eqnarray*}{
1686C>   {\it t_1} &=& \rho_\beta+\rho_\alpha\\\\
1687C>   {\it t_2} &=& {\it param}\left(1\right)\\\\
1688C>   {\it t_3} &=& {{1}\over{\rho_\alpha}}\\\\
1689C>   {\it t_4} &=& {{1}\over{{\it t_1}}}\\\\
1690C>   {\it t_5} &=& {{1}\over{\rho_\beta}}\\\\
1691C>   f &=& 1.0\,{\it t_1}\,\left({\it nwxc\_c\_mpbe}\left({\it t_2}
1692C>    , \rho_\alpha , \rho_\beta , \sigma_{\alpha\alpha} ,
1693C>    \sigma_{\alpha\beta} , \sigma_{\beta\beta}\right)\,
1694C>    \left({{0.53\,\left(0.125\,{\it t_5}\,\sigma_{\beta\beta}
1695C>    +0.125\,{\it t_3}\,\sigma_{\alpha\alpha}\right)^2}\over{
1696C>    \left(\tau_\beta+\tau_\alpha\right)^2}}+1.0\right)
1697C>    -{{0.02390625\,{\it nwxc\_c\_mpbe}\left({\it t_2} , 0.0
1698C>    , \rho_\beta , 0.0 , 0.0 , \sigma_{\beta\beta}\right)\,{
1699C>    \it t_5}\,{\it t_4}\,\sigma_{\beta\beta}^2}\over{\tau_\beta^2}}
1700C>    -{{0.02390625\,{\it nwxc\_c\_mpbe}\left({\it t_2}
1701C>    , \rho_\alpha , 0.0 , \sigma_{\alpha\alpha} , 0.0 , 0.0\right)
1702C>    \,{\it t_3}\,{\it t_4}\,\sigma_{\alpha\alpha}^2}
1703C>    \over{\tau_\alpha^2}}\right)\\\\
1704C>   g &=& 0\\\\
1705C>   G &=& 0.0\\\\
1706C> \f}
1707C>
1708C> Code generated with Maxima 5.34.0 [2,3]
1709C> driven by autoxc-Ds [4,5,6].
1710C>
1711C> ### References ###
1712C>
1713C> [1] JP Perdew, S Kurth, A Zupan, P Blaha, Phys.Rev.Lett. 82
1714C>    , 2544 (1999)  , DOI:
1715C> <a href="https://doi.org/10.1103/PhysRevLett.82.2544 ">
1716C> 10.1103/PhysRevLett.82.2544 </a>
1717C>
1718C> [2] Maxima, a computer algebra system,
1719C> <a href="http://maxima.sourceforge.net/">
1720C> http://maxima.sourceforge.net/</a>
1721C>
1722C> [3] CLISP 2.49 (2010-07-07)
1723C>
1724C> [4] autoxc-Ds, revision 27701 2015-10-10
1725C>
1726C> [5] rewrap.py revision 27697 2015-10-10
1727C>
1728C> [6] call_subroutine.py revision 27339 2015-08-13
1729C>
1730      subroutine nwxcm_c_pkzb99_d3(param,tol_rho,ipol,nq,wght, rho,
1731     +   rgamma,tau,fnc,Amat,Amat2,Amat3, Cmat,Cmat2,Cmat3,Mmat,Mmat2,
1732     +   Mmat3)
1733c $Id: $
1734#ifdef NWXC_QUAD_PREC
1735      implicit real(kind=selected_real_kind(30))(a-h,o-z),integer(i-n)
1736      integer, parameter :: rk=selected_real_kind(30)
1737#else
1738      implicit real(kind=selected_real_kind(15))(a-h,o-z),integer(i-n)
1739      integer, parameter :: rk=selected_real_kind(15)
1740#endif
1741#include "nwxc_param.fh"
1742      double precision sr(NCOL_RHO)
1743      double precision sg(NCOL_GAMMA)
1744      double precision st(NCOL_TAU)
1745      double precision s1f
1746      double precision s1a(NCOL_AMAT)
1747      double precision s1c(NCOL_CMAT)
1748      double precision s1m(NCOL_MMAT)
1749      double precision s1a2(NCOL_AMAT2)
1750      double precision s1c2(NCOL_CMAT2)
1751      double precision s1m2(NCOL_MMAT2)
1752      double precision s1a3(NCOL_AMAT3)
1753      double precision s1c3(NCOL_CMAT3)
1754      double precision s1m3(NCOL_MMAT3)
1755      double precision s2f
1756      double precision s2a(NCOL_AMAT)
1757      double precision s2c(NCOL_CMAT)
1758      double precision s2m(NCOL_MMAT)
1759      double precision s2a2(NCOL_AMAT2)
1760      double precision s2c2(NCOL_CMAT2)
1761      double precision s2m2(NCOL_MMAT2)
1762      double precision s2a3(NCOL_AMAT3)
1763      double precision s2c3(NCOL_CMAT3)
1764      double precision s2m3(NCOL_MMAT3)
1765      double precision s3f
1766      double precision s3a(NCOL_AMAT)
1767      double precision s3c(NCOL_CMAT)
1768      double precision s3m(NCOL_MMAT)
1769      double precision s3a2(NCOL_AMAT2)
1770      double precision s3c2(NCOL_CMAT2)
1771      double precision s3m2(NCOL_MMAT2)
1772      double precision s3a3(NCOL_AMAT3)
1773      double precision s3c3(NCOL_CMAT3)
1774      double precision s3m3(NCOL_MMAT3)
1775      double precision param(*)     !< [Input] Parameters of functional
1776      double precision tol_rho      !< [Input] The lower limit on the
1777                                    !< density
1778      integer ipol                  !< [Input] The number of spin
1779                                    !< channels
1780      integer nq                    !< [Input] The number of points
1781      double precision wght         !< [Input] The weight of the
1782                                    !< functional
1783      double precision rho(nq,NCOL_RHO)      !< [Input] The density
1784      double precision rgamma(nq,NCOL_GAMMA) !< [Input] The norm of the
1785                                             !< density gradients
1786      double precision tau(nq,NCOL_TAU)      !< [Input] The kinetic
1787                                             !< energy density
1788      double precision fnc(nq)      !< [Output] The value of the
1789                                    !< functional
1790c
1791c     Sampling Matrices for the XC Kernel
1792c
1793      double precision Amat(nq,NCOL_AMAT)   !< [Output] The derivative
1794                                            !< wrt rho
1795      double precision Cmat(nq,NCOL_CMAT)   !< [Output] The derivative
1796                                            !< wrt rgamma
1797      double precision Mmat(nq,NCOL_MMAT)   !< [Output] The derivative
1798                                            !< wrt tau
1799c
1800c     Sampling Matrices for the XC Kernel
1801c
1802      double precision Amat2(nq,NCOL_AMAT2)  !< [Output] The 2nd
1803                                             !< derivative wrt rho
1804      double precision Cmat2(nq,NCOL_CMAT2)  !< [Output] The 2nd
1805                                             !< derivative wrt rgamma
1806                                             !< and possibly rho
1807      double precision Mmat2(nq,NCOL_MMAT2)  !< [Output] The 2nd
1808                                             !< derivative wrt tau and
1809                                             !< possibly rho or rgamma
1810c
1811c     Sampling Matrices for the XC Kernel
1812c
1813      double precision Amat3(nq,NCOL_AMAT3)  !< [Output] The 3rd
1814                                             !< derivative wrt rho
1815      double precision Cmat3(nq,NCOL_CMAT3)  !< [Output] The 3rd
1816                                             !< derivative wrt rgamma
1817                                             !< and possibly rho
1818      double precision Mmat3(nq,NCOL_MMAT3)  !< [Output] The 3rd
1819                                             !< derivative wrt tau and
1820                                             !< possibly rho or rgamma
1821      integer iq
1822      double precision tmp
1823      double precision rhoa,rhob
1824      double precision gammaaa,gammaab,gammabb
1825      double precision taua,taub
1826      double precision nwxcm_heaviside
1827      external         nwxcm_heaviside
1828CDIR$ NOVECTOR
1829      do iq = 1, nq
1830        if (ipol.eq.1) then
1831          rhoa    = 0.5d0*rho(iq,R_T)
1832          gammaaa = 0.25d0*rgamma(iq,G_TT)
1833          taua    = 0.5d0*tau(iq,T_T)
1834          if (rhoa.gt.tol_rho) then
1835            if (taua.gt.tol_rho) then
1836              t1 = param(1)
1837              sr(R_A) = 0.0d+0
1838              sr(R_B) = rhoa
1839              sg(G_AA) = 0.0d+0
1840              sg(G_AB) = 0.0d+0
1841              sg(G_BB) = gammaaa
1842              s1f = 0.0d0
1843              call dcopy(NCOL_AMAT,0.0d0,0,s1a,1)
1844              call dcopy(NCOL_AMAT2,0.0d0,0,s1a2,1)
1845              call dcopy(NCOL_AMAT3,0.0d0,0,s1a3,1)
1846              call dcopy(NCOL_CMAT,0.0d0,0,s1c,1)
1847              call dcopy(NCOL_CMAT2,0.0d0,0,s1c2,1)
1848              call dcopy(NCOL_CMAT3,0.0d0,0,s1c3,1)
1849              call nwxcm_c_mpbe_d3(t1,tol_rho,2,1,1.0d0,sr,sg,s1f,s1a,
1850     +          s1a2,s1a3,s1c,s1c2,s1c3)
1851              t2 = s1f
1852              t3 = gammaaa**2
1853              t4 = 1/rhoa**2
1854              t5 = 1/taua**2
1855              sr(R_A) = rhoa
1856              sr(R_B) = 0.0d+0
1857              sg(G_AA) = gammaaa
1858              sg(G_AB) = 0.0d+0
1859              sg(G_BB) = 0.0d+0
1860              s2f = 0.0d0
1861              call dcopy(NCOL_AMAT,0.0d0,0,s2a,1)
1862              call dcopy(NCOL_AMAT2,0.0d0,0,s2a2,1)
1863              call dcopy(NCOL_AMAT3,0.0d0,0,s2a3,1)
1864              call dcopy(NCOL_CMAT,0.0d0,0,s2c,1)
1865              call dcopy(NCOL_CMAT2,0.0d0,0,s2c2,1)
1866              call dcopy(NCOL_CMAT3,0.0d0,0,s2c3,1)
1867              call nwxcm_c_mpbe_d3(t1,tol_rho,2,1,1.0d0,sr,sg,s2f,s2a,
1868     +          s2a2,s2a3,s2c,s2c2,s2c3)
1869              t6 = s2f
1870              sr(R_T) = 2.0d0*rhoa
1871              sg(G_TT) = 4.0d0*gammaaa
1872              s3f = 0.0d0
1873              call dcopy(NCOL_AMAT,0.0d0,0,s3a,1)
1874              call dcopy(NCOL_AMAT2,0.0d0,0,s3a2,1)
1875              call dcopy(NCOL_AMAT3,0.0d0,0,s3a3,1)
1876              call dcopy(NCOL_CMAT,0.0d0,0,s3c,1)
1877              call dcopy(NCOL_CMAT2,0.0d0,0,s3c2,1)
1878              call dcopy(NCOL_CMAT3,0.0d0,0,s3c3,1)
1879              call nwxcm_c_mpbe_d3(t1,tol_rho,ipol,1,1.0d0,sr,sg,s3f,
1880     +          s3a,s3a2,s3a3,s3c,s3c2,s3c3)
1881              t7 = s3f
1882              t8 = 8.28125d-3*t3*t4*t5+1.0d+0
1883              t9 = s3f*t8-1.1953125d-2*t3*t4*t5*s2f-1.1953125d-2*s1f
1884     +          *t3*t4*t5
1885              t10 = 1/rhoa**3
1886              t11 = -8.28125d-3*t10*t3*t5*s3f
1887              t12 = s2a(D1_RA)
1888              t13 = s3a(D1_RA)
1889              t14 = t13*t8
1890              t15 = 1.79296875d-2*t10*t3*t5*s2f-1.1953125d-2*t12*t3*t4
1891     +          *t5+5.9765625d-3*t10*s1f*t3*t5+t14+t11
1892              t16 = 8.28125d-3*gammaaa*t4*t5*s3f
1893              t17 = s2c(D1_GAA)
1894              t18 = -4.78125d-2*gammaaa*s2f-2.390625d-2*t17*t3
1895              t19 = s3c(D1_GAA)
1896              t20 = t19*t8
1897              t21 = s3c(D1_GAB)
1898              t22 = 1/taua**3
1899              t23 = -8.28125d-3*t22*t3*t4*s3f
1900              t24 = 2.390625d-2*t22*t3*t4*s2f+t23
1901              t25 = 1/rhoa**4
1902              t26 = -1.6562500000000002d-2*t10*t13*t3*t5
1903              t27 = s2a2(D2_RA_RA)
1904              t28 = s3a2(D2_RA_RA)
1905              t29 = t28*t8+2.0703125000000003d-2*t25*t3*t5*s3f
1906     +          -4.1835937500000003d-2*t25*t3*t5*s2f-1.1953125d-2*t27
1907     +          *t3*t4*t5-5.9765625d-3*s1f*t25*t3*t5+3.5859375d-2*t10
1908     +          *t12*t3*t5+t26
1909              t30 = s1a(D1_RA)
1910              t31 = s3a2(D2_RA_RB)
1911              t32 = t31*t8+4.140625d-3*t25*t3*t5*s3f-1.1953125d-2*t25
1912     +          *t3*t5*s2f+5.9765625d-3*t10*t3*t30*t5-1.1953125d-2*s1f
1913     +          *t25*t3*t5+5.9765625d-3*t10*t12*t3*t5+t26
1914              t33 = -8.28125d-3*t10*t19*t3*t5
1915              t34 = 8.28125d-3*gammaaa*t13*t4*t5
1916              t35 = s2c2(D2_RA_GAA)
1917              t36 = s3c2(D2_RA_GAA)
1918              t37 = t36*t8-1.2421875d-2*gammaaa*t10*t5*s3f
1919     +          +3.5859375d-2*gammaaa*t10*t5*s2f-1.1953125d-2*t3*t35
1920     +          *t4*t5-2.390625d-2*gammaaa*t12*t4*t5+1.79296875d-2*t10
1921     +          *t17*t3*t5+t34+t33
1922              t38 = -8.28125d-3*t10*t21*t3*t5
1923              t39 = s3c2(D2_RA_GAB)
1924              t40 = t39*t8+t38
1925              t41 = s1c(D1_GAA)
1926              t42 = -4.140625d-3*gammaaa*t10*t5*s3f
1927              t43 = s3c2(D2_RA_GBB)
1928              t44 = t43*t8+5.9765625d-3*t10*t3*t41*t5+1.1953125d-2
1929     +          *gammaaa*t10*s1f*t5+t42+t34+t33
1930              t45 = 4.140625d-3*t4*t5*s3f
1931              t46 = 1.6562500000000002d-2*gammaaa*t19*t4*t5
1932              t47 = s2c2(D2_GAA_GAA)
1933              t48 = -4.78125d-2*s2f-2.390625d-2*t3*t47-9.5625d-2
1934     +          *gammaaa*t17
1935              t49 = s3c2(D2_GAA_GAA)
1936              t50 = t49*t8
1937              t51 = s3c2(D2_GAA_GAB)
1938              t52 = t51*t8+8.28125d-3*gammaaa*t21*t4*t5
1939              t53 = s3c2(D2_GAA_GBB)
1940              t54 = t53*t8+t46+t45
1941              t55 = s3c2(D2_GAB_GAB)
1942              t56 = 8.28125d-3*t10*t22*t3*s3f
1943              t57 = -8.28125d-3*t13*t22*t3*t4
1944              t58 = -3.5859375d-2*t10*t22*t3*s2f+t57+t56+2.390625d-2
1945     +          *t12*t22*t3*t4
1946              t59 = t57+t56-1.1953125d-2*t10*s1f*t22*t3
1947              t60 = -8.28125d-3*gammaaa*t22*t4*s3f
1948              t61 = -8.28125d-3*t19*t22*t3*t4
1949              t62 = t61+t60
1950              t63 = 1/rhoa
1951              t64 = 1/taua**4
1952              t65 = 1/rhoa**5
1953              t66 = 2.0703125000000003d-2*t19*t25*t3*t5
1954              t67 = 8.28125d-3*gammaaa*t28*t4*t5
1955              t68 = s3c2(D2_RB_GAA)
1956              t69 = s3c2(D2_RB_GAB)
1957              t70 = -8.28125d-3*t10*t3*t49*t5
1958              t71 = 4.140625d-3*t13*t4*t5
1959              t72 = -8.28125d-3*t10*t3*t5*t51
1960              t73 = 8.28125d-3*gammaaa*t39*t4*t5
1961              t74 = s1c2(D2_GAA_GAA)
1962              t75 = 1.2421875d-2*t19*t4*t5
1963              t76 = 4.140625d-3*t21*t4*t5
1964              t77 = 1.6562500000000002d-2*gammaaa*t4*t5*t51
1965              t78 = -2.0703125000000003d-2*t22*t25*t3*s3f
1966              t79 = 1.6562500000000002d-2*t10*t13*t22*t3
1967              t80 = -8.28125d-3*t22*t28*t3*t4
1968              t81 = 1.2421875d-2*gammaaa*t10*t22*s3f
1969              t82 = 8.28125d-3*t10*t19*t22*t3
1970              t83 = -8.28125d-3*gammaaa*t13*t22*t4
1971              t84 = -8.28125d-3*t22*t3*t36*t4
1972              t85 = 1.0d+0*t62*wght
1973              t86 = 2.0d+0*rhoa*(8.28125d-3*t10*t21*t22*t3-8.28125d-3
1974     +          *t22*t3*t39*t4)*wght-8.28125d-3*t21*t22*t3*t4*wght
1975              t87 = 4.140625d-3*gammaaa*t10*t22*s3f
1976              t88 = -8.28125d-3*t22*t3*t4*t43
1977              t89 = -4.140625d-3*t22*t4*s3f
1978              t90 = -1.6562500000000002d-2*gammaaa*t19*t22*t4
1979              t91 = -8.28125d-3*t22*t3*t4*t49
1980              t92 = 2.0d+0*rhoa*(-8.28125d-3*t22*t3*t4*t51-8.28125d-3
1981     +          *gammaaa*t21*t22*t4)*wght
1982              t93 = 1/taua**5
1983              fnc(iq) = 2.0d+0*rhoa*t9*wght+fnc(iq)
1984              Amat(iq,D1_RA) = 1.0d+0*t9*wght+2.0d+0*rhoa*t15*wght
1985     +          +Amat(iq,D1_RA)
1986              Cmat(iq,D1_GAA) = 2.0d+0*rhoa*(5.0d-1*t18*t4*t5+t20+t16)
1987     +          *wght+Cmat(iq,D1_GAA)
1988              Cmat(iq,D1_GAB) = 2.0d+0*rhoa*t21*t8*wght+Cmat(iq,D1_GAB)
1989              Mmat(iq,D1_TA) = 2.0d+0*rhoa*t24*wght+Mmat(iq,D1_TA)
1990              Amat2(iq,D2_RA_RA) = 2.0d+0*rhoa*t29*wght+2.0d+0*t15
1991     +          *wght+Amat2(iq,D2_RA_RA)
1992              Amat2(iq,D2_RA_RB) = 1.0d+0*(5.9765625d-3*t10*t3*t5*s2f
1993     +          -1.1953125d-2*t3*t30*t4*t5+1.79296875d-2*t10*s1f*t3*t5
1994     +          +t14+t11)*wght+2.0d+0*rhoa*t32*wght+1.0d+0*t15*wght
1995     +          +Amat2(iq,D2_RA_RB)
1996              Cmat2(iq,D2_RA_GAA) = 1.0d+0*(-2.390625d-2*gammaaa*t4*t5
1997     +          *s2f-1.1953125d-2*t17*t3*t4*t5+t20+t16)*wght+2.0d+0
1998     +          *rhoa*t37*wght+Cmat2(iq,D2_RA_GAA)
1999              Cmat2(iq,D2_RA_GAB) = 1.0d+0*t21*t8*wght+2.0d+0*rhoa*t40
2000     +          *wght+Cmat2(iq,D2_RA_GAB)
2001              Cmat2(iq,D2_RA_GBB) = 1.0d+0*(-1.1953125d-2*t3*t4*t41*t5
2002     +          -2.390625d-2*gammaaa*s1f*t4*t5+t20+t16)*wght+2.0d+0
2003     +          *rhoa*t44*wght+Cmat2(iq,D2_RA_GBB)
2004              Cmat2(iq,D2_GAA_GAA) = 2.0d+0*rhoa*(t50+5.0d-1*t4*t48*t5
2005     +          +t46+t45)*wght+Cmat2(iq,D2_GAA_GAA)
2006              Cmat2(iq,D2_GAA_GAB) = 2.0d+0*rhoa*t52*wght+Cmat2(iq,
2007     +          D2_GAA_GAB)
2008              Cmat2(iq,D2_GAA_GBB) = 2.0d+0*rhoa*t54*wght+Cmat2(iq,
2009     +          D2_GAA_GBB)
2010              Cmat2(iq,D2_GAB_GAB) = 2.0d+0*rhoa*t55*t8*wght+Cmat2(iq,
2011     +          D2_GAB_GAB)
2012              Mmat2(iq,D2_RA_TA) = 2.0d+0*rhoa*t58*wght+1.0d+0*t24
2013     +          *wght+Mmat2(iq,D2_RA_TA)
2014              Mmat2(iq,D2_RA_TB) = 2.0d+0*rhoa*t59*wght+1.0d+0*
2015     +          (2.390625d-2*s1f*t22*t3*t4+t23)*wght+Mmat2(iq,D2_RA_TB)
2016              Mmat2(iq,D2_GAA_TA) = 2.0d+0*rhoa*(t61+t60-t18*t22*t4)
2017     +          *wght+Mmat2(iq,D2_GAA_TA)
2018              Mmat2(iq,D2_GAA_TB) = 2.0d+0*rhoa*t62*wght+Mmat2(iq,
2019     +          D2_GAA_TB)
2020              Mmat2(iq,D2_GAB_TA) = Mmat2(iq,D2_GAB_TA)
2021     +          -1.6562500000000002d-2*t21*t22*t3*t63*wght
2022              Mmat2(iq,D2_TA_TA) = 2.0d+0*rhoa*(1.2421875d-2*t3*t4*t64
2023     +          *s3f-7.171875d-2*t3*t4*s2f*t64)*wght+Mmat2(iq,D2_TA_TA)
2024              Mmat2(iq,D2_TA_TB) = 2.484375d-2*t3*t63*t64*s3f*wght
2025     +          +Mmat2(iq,D2_TA_TB)
2026              Amat3(iq,D3_RA_RA_RA) = 2.0d+0*rhoa*(s3a3(D3_RA_RA_RA)
2027     +          *t8-7.453125d-2*t3*t5*t65*s3f+1.3447265625d-1*t3*t5
2028     +          *s2f*t65+8.96484375d-3*s1f*t3*t5*t65-1.1953125d-2*t3
2029     +          *t4*t5*s2a3(D3_RA_RA_RA)-2.484375d-2*t10*t28*t3*t5
2030     +          +5.37890625d-2*t10*t27*t3*t5+6.2109375d-2*t13*t25*t3
2031     +          *t5-1.2550781249999998d-1*t12*t25*t3*t5)*wght+3.0d+0
2032     +          *t29*wght+Amat3(iq,D3_RA_RA_RA)
2033              Amat3(iq,D3_RA_RA_RB) = 2.0d+0*rhoa*(s3a3(D3_RA_RA_RB)
2034     +          *t8-8.28125d-3*t3*t5*t65*s3f+3.287109375d-2*t3*t5*s2f
2035     +          *t65+1.494140625d-2*s1f*t3*t5*t65
2036     +          -1.6562500000000002d-2*t10*t3*t31*t5-5.9765625d-3*t25
2037     +          *t3*t30*t5-8.28125d-3*t10*t28*t3*t5+5.9765625d-3*t10
2038     +          *t27*t3*t5+2.8984375d-2*t13*t25*t3*t5-2.390625d-2*t12
2039     +          *t25*t3*t5)*wght+2.0d+0*t32*wght+1.0d+0*t29*wght+Amat3
2040     +          (iq,D3_RA_RA_RB)
2041              Cmat3(iq,D3_RA_RA_GAA) = 2.0d+0*rhoa*(s3c3(D3_RA_RA_GAA)
2042     +          *t8+3.3125000000000004d-2*gammaaa*t25*t5*s3f+t67+t66
2043     +          -1.1953125d-2*t3*t4*t5*s2c3(D3_RA_RA_GAA)
2044     +          -8.367187500000001d-2*gammaaa*t25*t5*s2f-2.390625d-2
2045     +          *gammaaa*t27*t4*t5-1.6562500000000002d-2*t10*t3*t36*t5
2046     +          +3.5859375d-2*t10*t3*t35*t5-4.1835937500000003d-2*t17
2047     +          *t25*t3*t5-2.484375d-2*gammaaa*t10*t13*t5+7.171875d-2
2048     +          *gammaaa*t10*t12*t5)*wght+2.0d+0*t37*wght+Cmat3(iq,
2049     +          D3_RA_RA_GAA)
2050              Cmat3(iq,D3_RA_RA_GAB) = 2.0d+0*rhoa*(s3c3(D3_RA_RA_GAB)
2051     +          *t8-1.6562500000000002d-2*t10*t3*t39*t5
2052     +          +2.0703125000000003d-2*t21*t25*t3*t5)*wght+2.0d+0*t40
2053     +          *wght+Cmat3(iq,D3_RA_RA_GAB)
2054              Cmat3(iq,D3_RA_RA_GBB) = 2.0d+0*rhoa*(s3c3(D3_RA_RA_GBB)
2055     +          *t8+8.28125d-3*gammaaa*t25*t5*s3f+t67+t66
2056     +          -1.6562500000000002d-2*t10*t3*t43*t5-5.9765625d-3*t25
2057     +          *t3*t41*t5-1.1953125d-2*gammaaa*s1f*t25*t5-8.28125d-3
2058     +          *gammaaa*t10*t13*t5)*wght+2.0d+0*t44*wght+Cmat3(iq,
2059     +          D3_RA_RA_GBB)
2060              Cmat3(iq,D3_RA_RB_GAA) = 2.0d+0*rhoa*(s3c3(D3_RA_RB_GAA)
2061     +          *t8+4.140625d-3*gammaaa*t25*t5*s3f-8.28125d-3*t10*t3
2062     +          *t5*t68-2.390625d-2*gammaaa*t25*t5*s2f+8.28125d-3
2063     +          *gammaaa*t31*t4*t5-8.28125d-3*t10*t3*t36*t5
2064     +          +5.9765625d-3*t10*t3*t35*t5+4.140625d-3*t19*t25*t3*t5
2065     +          -1.1953125d-2*t17*t25*t3*t5-1.6562500000000002d-2
2066     +          *gammaaa*t10*t13*t5+1.1953125d-2*gammaaa*t10*t12*t5)
2067     +          *wght+1.0d+0*(t68*t8+1.1953125d-2*gammaaa*t10*t5*s2f
2068     +          +5.9765625d-3*t10*t17*t3*t5+t42+t34+t33)*wght+1.0d+0
2069     +          *t37*wght+Cmat3(iq,D3_RA_RB_GAA)
2070              Cmat3(iq,D3_RA_RB_GAB) = 2.0d+0*rhoa*(s3c3(D3_RA_RB_GAB)
2071     +          *t8-8.28125d-3*t10*t3*t5*t69-8.28125d-3*t10*t3*t39*t5
2072     +          +4.140625d-3*t21*t25*t3*t5)*wght+1.0d+0*(t69*t8+t38)
2073     +          *wght+1.0d+0*t40*wght+Cmat3(iq,D3_RA_RB_GAB)
2074              Cmat3(iq,D3_RA_GAA_GAA) = 2.0d+0*rhoa*(s3c3
2075     +          (D3_RA_GAA_GAA)*t8+t71+t70-8.28125d-3*t10*t5*s3f
2076     +          -1.1953125d-2*t3*t4*t5*s2c3(D3_RA_GAA_GAA)
2077     +          +3.5859375d-2*t10*t5*s2f+1.79296875d-2*t10*t3*t47*t5
2078     +          +1.6562500000000002d-2*gammaaa*t36*t4*t5-4.78125d-2
2079     +          *gammaaa*t35*t4*t5-2.390625d-2*t12*t4*t5-2.484375d-2
2080     +          *gammaaa*t10*t19*t5+7.171875d-2*gammaaa*t10*t17*t5)
2081     +          *wght+1.0d+0*(-2.390625d-2*t4*t5*s2f+t50-1.1953125d-2
2082     +          *t3*t4*t47*t5-4.78125d-2*gammaaa*t17*t4*t5+t46+t45)
2083     +          *wght+Cmat3(iq,D3_RA_GAA_GAA)
2084              Cmat3(iq,D3_RA_GAA_GAB) = 2.0d+0*rhoa*(s3c3
2085     +          (D3_RA_GAA_GAB)*t8+t73+t72-1.2421875d-2*gammaaa*t10
2086     +          *t21*t5)*wght+1.0d+0*t52*wght+Cmat3(iq,D3_RA_GAA_GAB)
2087              Cmat3(iq,D3_RA_GAA_GBB) = 2.0d+0*rhoa*(s3c3
2088     +          (D3_RA_GAA_GBB)*t8+t71-4.140625d-3*t10*t5*s3f
2089     +          -8.28125d-3*t10*t3*t5*t53+8.28125d-3*gammaaa*t4*t43*t5
2090     +          +8.28125d-3*gammaaa*t36*t4*t5-1.6562500000000002d-2
2091     +          *gammaaa*t10*t19*t5)*wght+1.0d+0*t54*wght+Cmat3(iq,
2092     +          D3_RA_GAA_GBB)
2093              Cmat3(iq,D3_RA_GAB_GAB) = 2.0d+0*rhoa*(s3c3
2094     +          (D3_RA_GAB_GAB)*t8-8.28125d-3*t10*t3*t5*t55)*wght
2095     +          +1.0d+0*t55*t8*wght+Cmat3(iq,D3_RA_GAB_GAB)
2096              Cmat3(iq,D3_RA_GAB_GBB) = 2.0d+0*rhoa*(s3c3
2097     +          (D3_RA_GAB_GBB)*t8+t73+t72-4.140625d-3*gammaaa*t10*t21
2098     +          *t5)*wght+1.0d+0*t51*t8*wght+8.28125d-3*gammaaa*t21*t4
2099     +          *t5*wght+Cmat3(iq,D3_RA_GAB_GBB)
2100              Cmat3(iq,D3_RA_GBB_GBB) = 2.0d+0*rhoa*(s3c3
2101     +          (D3_RA_GBB_GBB)*t8+5.9765625d-3*t10*t3*t5*t74+t71+t70
2102     +          +1.6562500000000002d-2*gammaaa*t4*t43*t5+2.390625d-2
2103     +          *gammaaa*t10*t41*t5+1.1953125d-2*t10*s1f*t5-8.28125d-3
2104     +          *gammaaa*t10*t19*t5)*wght+1.0d+0*(-1.1953125d-2*t3*t4
2105     +          *t5*t74+t50-4.78125d-2*gammaaa*t4*t41*t5-2.390625d-2
2106     +          *s1f*t4*t5+t46+t45)*wght+Cmat3(iq,D3_RA_GBB_GBB)
2107              Cmat3(iq,D3_GAA_GAA_GAA) = 2.0d+0*rhoa*(s3c3
2108     +          (D3_GAA_GAA_GAA)*t8+t75+5.0d-1*t4*t5*(-2.390625d-2*t3
2109     +          *s2c3(D3_GAA_GAA_GAA)-1.434375d-1*gammaaa*t47
2110     +          -1.434375d-1*t17)+2.484375d-2*gammaaa*t4*t49*t5)*wght
2111     +          +Cmat3(iq,D3_GAA_GAA_GAA)
2112              Cmat3(iq,D3_GAA_GAA_GAB) = 2.0d+0*rhoa*(s3c3
2113     +          (D3_GAA_GAA_GAB)*t8+t77+t76)*wght+Cmat3(iq,
2114     +          D3_GAA_GAA_GAB)
2115              Cmat3(iq,D3_GAA_GAA_GBB) = 2.0d+0*rhoa*(s3c3
2116     +          (D3_GAA_GAA_GBB)*t8+t75+1.6562500000000002d-2*gammaaa
2117     +          *t4*t5*t53+8.28125d-3*gammaaa*t4*t49*t5)*wght+Cmat3
2118     +          (iq,D3_GAA_GAA_GBB)
2119              Cmat3(iq,D3_GAA_GAB_GAB) = 2.0d+0*rhoa*(s3c3
2120     +          (D3_GAA_GAB_GAB)*t8+8.28125d-3*gammaaa*t4*t5*t55)*wght
2121     +          +Cmat3(iq,D3_GAA_GAB_GAB)
2122              Cmat3(iq,D3_GAA_GAB_GBB) = 2.0d+0*rhoa*(s3c3
2123     +          (D3_GAA_GAB_GBB)*t8+t77+t76)*wght+Cmat3(iq,
2124     +          D3_GAA_GAB_GBB)
2125              Cmat3(iq,D3_GAB_GAB_GAB) = 2.0d+0*rhoa*s3c3
2126     +          (D3_GAB_GAB_GAB)*t8*wght+Cmat3(iq,D3_GAB_GAB_GAB)
2127              Mmat3(iq,D3_RA_RA_TA) = 2.0d+0*rhoa*(t80+t79+t78
2128     +          +8.367187500000001d-2*t22*t25*t3*s2f+2.390625d-2*t22
2129     +          *t27*t3*t4-7.171875d-2*t10*t12*t22*t3)*wght+2.0d+0*t58
2130     +          *wght+Mmat3(iq,D3_RA_RA_TA)
2131              Mmat3(iq,D3_RA_RA_TB) = 2.0d+0*rhoa*(t80+t79+t78
2132     +          +1.1953125d-2*s1f*t22*t25*t3)*wght+2.0d+0*t59*wght
2133     +          +Mmat3(iq,D3_RA_RA_TB)
2134              Mmat3(iq,D3_RA_RB_TA) = 2.0d+0*rhoa*(t79-4.140625d-3*t22
2135     +          *t25*t3*s3f+2.390625d-2*t22*t25*t3*s2f-8.28125d-3*t22
2136     +          *t3*t31*t4-1.1953125d-2*t10*t12*t22*t3)*wght+1.0d+0*(
2137     +          -1.1953125d-2*t10*t22*t3*s2f+t57+t56)*wght+1.0d+0*t58
2138     +          *wght+Mmat3(iq,D3_RA_RB_TA)
2139              Mmat3(iq,D3_RA_GAA_TA) = 2.0d+0*rhoa*(t84+t83+t82+t81
2140     +          -7.171875d-2*gammaaa*t10*t22*s2f+2.390625d-2*t22*t3
2141     +          *t35*t4+4.78125d-2*gammaaa*t12*t22*t4-3.5859375d-2*t10
2142     +          *t17*t22*t3)*wght+1.0d+0*(t61+t60+4.78125d-2*gammaaa
2143     +          *t22*t4*s2f+2.390625d-2*t17*t22*t3*t4)*wght+Mmat3(iq,
2144     +          D3_RA_GAA_TA)
2145              Mmat3(iq,D3_RA_GAA_TB) = 2.0d+0*rhoa*(t84+t83+t82+t81)
2146     +          *wght+t85+Mmat3(iq,D3_RA_GAA_TB)
2147              Mmat3(iq,D3_RA_GAB_TA) = t86+Mmat3(iq,D3_RA_GAB_TA)
2148              Mmat3(iq,D3_RA_GAB_TB) = t86+Mmat3(iq,D3_RA_GAB_TB)
2149              Mmat3(iq,D3_RA_GBB_TA) = 2.0d+0*rhoa*(t88+t87+t83+t82)
2150     +          *wght+t85+Mmat3(iq,D3_RA_GBB_TA)
2151              Mmat3(iq,D3_RA_GBB_TB) = 2.0d+0*rhoa*(t88+t87+t83+t82
2152     +          -1.1953125d-2*t10*t22*t3*t41-2.390625d-2*gammaaa*t10
2153     +          *s1f*t22)*wght+1.0d+0*(t61+t60+2.390625d-2*t22*t3*t4
2154     +          *t41+4.78125d-2*gammaaa*s1f*t22*t4)*wght+Mmat3(iq,
2155     +          D3_RA_GBB_TB)
2156              Mmat3(iq,D3_GAA_GAA_TA) = 2.0d+0*rhoa*(t91+t90+t89-t22
2157     +          *t4*t48)*wght+Mmat3(iq,D3_GAA_GAA_TA)
2158              Mmat3(iq,D3_GAA_GAA_TB) = 2.0d+0*rhoa*(t91+t90+t89)*wght
2159     +          +Mmat3(iq,D3_GAA_GAA_TB)
2160              Mmat3(iq,D3_GAA_GAB_TA) = t92+Mmat3(iq,D3_GAA_GAB_TA)
2161              Mmat3(iq,D3_GAA_GAB_TB) = t92+Mmat3(iq,D3_GAA_GAB_TB)
2162              Mmat3(iq,D3_GAA_GBB_TA) = 2.0d+0*rhoa*(t90+t89
2163     +          -8.28125d-3*t22*t3*t4*t53)*wght+Mmat3(iq,D3_GAA_GBB_TA)
2164              Mmat3(iq,D3_GAB_GAB_TA) = Mmat3(iq,D3_GAB_GAB_TA)
2165     +          -1.6562500000000002d-2*t22*t3*t55*t63*wght
2166              Mmat3(iq,D3_TA_TA_TA) = 2.0d+0*rhoa*(2.86875d-1*t3*t4
2167     +          *s2f*t93-2.484375d-2*t3*t4*s3f*t93)*wght+Mmat3(iq,
2168     +          D3_TA_TA_TA)
2169              Mmat3(iq,D3_TA_TA_TB) = Mmat3(iq,D3_TA_TA_TB)-4.96875d-2
2170     +          *t3*t63*s3f*t93*wght
2171            else
2172              t1 = param(1)
2173              t2 = 4.0d-50*rhoa
2174              sr(R_A) = 0.0d+0
2175              sr(R_B) = rhoa
2176              sg(G_AA) = 0.0d+0
2177              sg(G_AB) = 0.0d+0
2178              sg(G_BB) = t2
2179              s1f = 0.0d0
2180              call dcopy(NCOL_AMAT,0.0d0,0,s1a,1)
2181              call dcopy(NCOL_AMAT2,0.0d0,0,s1a2,1)
2182              call dcopy(NCOL_AMAT3,0.0d0,0,s1a3,1)
2183              call dcopy(NCOL_CMAT,0.0d0,0,s1c,1)
2184              call dcopy(NCOL_CMAT2,0.0d0,0,s1c2,1)
2185              call dcopy(NCOL_CMAT3,0.0d0,0,s1c3,1)
2186              call nwxcm_c_mpbe_d3(t1,tol_rho,2,1,1.0d0,sr,sg,s1f,s1a,
2187     +          s1a2,s1a3,s1c,s1c2,s1c3)
2188              t3 = s1f
2189              sr(R_A) = rhoa
2190              sr(R_B) = 0.0d+0
2191              sg(G_AA) = t2
2192              sg(G_AB) = 0.0d+0
2193              sg(G_BB) = 0.0d+0
2194              s2f = 0.0d0
2195              call dcopy(NCOL_AMAT,0.0d0,0,s2a,1)
2196              call dcopy(NCOL_AMAT2,0.0d0,0,s2a2,1)
2197              call dcopy(NCOL_AMAT3,0.0d0,0,s2a3,1)
2198              call dcopy(NCOL_CMAT,0.0d0,0,s2c,1)
2199              call dcopy(NCOL_CMAT2,0.0d0,0,s2c2,1)
2200              call dcopy(NCOL_CMAT3,0.0d0,0,s2c3,1)
2201              call nwxcm_c_mpbe_d3(t1,tol_rho,2,1,1.0d0,sr,sg,s2f,s2a,
2202     +          s2a2,s2a3,s2c,s2c2,s2c3)
2203              t4 = s2f
2204              sr(R_T) = 2.0d0*rhoa
2205              sg(G_TT) = 4.0d0*t2
2206              s3f = 0.0d0
2207              call dcopy(NCOL_AMAT,0.0d0,0,s3a,1)
2208              call dcopy(NCOL_AMAT2,0.0d0,0,s3a2,1)
2209              call dcopy(NCOL_AMAT3,0.0d0,0,s3a3,1)
2210              call dcopy(NCOL_CMAT,0.0d0,0,s3c,1)
2211              call dcopy(NCOL_CMAT2,0.0d0,0,s3c2,1)
2212              call dcopy(NCOL_CMAT3,0.0d0,0,s3c3,1)
2213              call nwxcm_c_mpbe_d3(t1,tol_rho,ipol,1,1.0d0,sr,sg,s3f,
2214     +          s3a,s3a2,s3a3,s3c,s3c2,s3c3)
2215              t5 = s3f
2216              t6 = 1.1325d+0*s3f-1.9125d-1*s2f-1.9125d-1*s1f
2217              t7 = s2a(D1_RA)
2218              t8 = 1.1325d+0*s3a(D1_RA)
2219              t9 = 1/rhoa
2220              t10 = -9.5625d-2*s2f*t9+9.5625d-2*s1f*t9+t8-1.9125d-1*t7
2221              t11 = s2a2(D2_RA_RA)
2222              t12 = 1/rhoa**2
2223              t13 = -1.9125d-1*t7*t9+1.1325d+0*s3a2(D2_RA_RA)
2224     +          +9.5625d-2*t12*s2f-9.5625d-2*t12*s1f-1.9125d-1*t11
2225              t14 = s1a(D1_RA)
2226              t15 = 9.5625d-2*t7*t9+9.5625d-2*t14*t9+1.1325d+0*s3a2
2227     +          (D2_RA_RB)
2228              t16 = 1/rhoa**3
2229              fnc(iq) = 2.0d+0*rhoa*t6*wght+fnc(iq)
2230              Amat(iq,D1_RA) = 1.0d+0*t6*wght+2.0d+0*rhoa*t10*wght
2231     +          +Amat(iq,D1_RA)
2232              Cmat(iq,D1_GAA) = Cmat(iq,D1_GAA)
2233              Cmat(iq,D1_GAB) = Cmat(iq,D1_GAB)
2234              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
2235              Amat2(iq,D2_RA_RA) = 2.0d+0*rhoa*t13*wght+2.0d+0*t10
2236     +          *wght+Amat2(iq,D2_RA_RA)
2237              Amat2(iq,D2_RA_RB) = 1.0d+0*(9.5625d-2*s2f*t9-9.5625d-2
2238     +          *s1f*t9+t8-1.9125d-1*t14)*wght+2.0d+0*rhoa*t15*wght
2239     +          +1.0d+0*t10*wght+Amat2(iq,D2_RA_RB)
2240              Cmat2(iq,D2_RA_GAA) = Cmat2(iq,D2_RA_GAA)
2241              Cmat2(iq,D2_RA_GAB) = Cmat2(iq,D2_RA_GAB)
2242              Cmat2(iq,D2_RA_GBB) = Cmat2(iq,D2_RA_GBB)
2243              Cmat2(iq,D2_GAA_GAA) = Cmat2(iq,D2_GAA_GAA)
2244              Cmat2(iq,D2_GAA_GAB) = Cmat2(iq,D2_GAA_GAB)
2245              Cmat2(iq,D2_GAA_GBB) = Cmat2(iq,D2_GAA_GBB)
2246              Cmat2(iq,D2_GAB_GAB) = Cmat2(iq,D2_GAB_GAB)
2247              Mmat2(iq,D2_RA_TA) = Mmat2(iq,D2_RA_TA)
2248              Mmat2(iq,D2_RA_TB) = Mmat2(iq,D2_RA_TB)
2249              Mmat2(iq,D2_GAA_TA) = Mmat2(iq,D2_GAA_TA)
2250              Mmat2(iq,D2_GAA_TB) = Mmat2(iq,D2_GAA_TB)
2251              Mmat2(iq,D2_GAB_TA) = Mmat2(iq,D2_GAB_TA)
2252              Mmat2(iq,D2_TA_TA) = Mmat2(iq,D2_TA_TA)
2253              Mmat2(iq,D2_TA_TB) = Mmat2(iq,D2_TA_TB)
2254              Amat3(iq,D3_RA_RA_RA) = 2.0d+0*rhoa*(-2.86875d-1*t11*t9
2255     +          +2.86875d-1*t12*t7+1.1325d+0*s3a3(D3_RA_RA_RA)
2256     +          -1.9125d-1*s2a3(D3_RA_RA_RA)-1.434375d-1*t16*s2f
2257     +          +1.434375d-1*t16*s1f)*wght+3.0d+0*t13*wght+Amat3(iq,
2258     +          D3_RA_RA_RA)
2259              Amat3(iq,D3_RA_RA_RB) = 2.0d+0*rhoa*(9.5625d-2*t11*t9
2260     +          +1.1325d+0*s3a3(D3_RA_RA_RB)-4.781250000000001d-2*t16
2261     +          *s2f+4.781249999999999d-2*t16*s1f-9.5625d-2*t12*t14)
2262     +          *wght+2.0d+0*t15*wght+1.0d+0*t13*wght+Amat3(iq,
2263     +          D3_RA_RA_RB)
2264              Cmat3(iq,D3_RA_RA_GAA) = Cmat3(iq,D3_RA_RA_GAA)
2265              Cmat3(iq,D3_RA_RA_GAB) = Cmat3(iq,D3_RA_RA_GAB)
2266              Cmat3(iq,D3_RA_RA_GBB) = Cmat3(iq,D3_RA_RA_GBB)
2267              Cmat3(iq,D3_RA_RB_GAA) = Cmat3(iq,D3_RA_RB_GAA)
2268              Cmat3(iq,D3_RA_RB_GAB) = Cmat3(iq,D3_RA_RB_GAB)
2269              Cmat3(iq,D3_RA_GAA_GAA) = Cmat3(iq,D3_RA_GAA_GAA)
2270              Cmat3(iq,D3_RA_GAA_GAB) = Cmat3(iq,D3_RA_GAA_GAB)
2271              Cmat3(iq,D3_RA_GAA_GBB) = Cmat3(iq,D3_RA_GAA_GBB)
2272              Cmat3(iq,D3_RA_GAB_GAB) = Cmat3(iq,D3_RA_GAB_GAB)
2273              Cmat3(iq,D3_RA_GAB_GBB) = Cmat3(iq,D3_RA_GAB_GBB)
2274              Cmat3(iq,D3_RA_GBB_GBB) = Cmat3(iq,D3_RA_GBB_GBB)
2275              Cmat3(iq,D3_GAA_GAA_GAA) = Cmat3(iq,D3_GAA_GAA_GAA)
2276              Cmat3(iq,D3_GAA_GAA_GAB) = Cmat3(iq,D3_GAA_GAA_GAB)
2277              Cmat3(iq,D3_GAA_GAA_GBB) = Cmat3(iq,D3_GAA_GAA_GBB)
2278              Cmat3(iq,D3_GAA_GAB_GAB) = Cmat3(iq,D3_GAA_GAB_GAB)
2279              Cmat3(iq,D3_GAA_GAB_GBB) = Cmat3(iq,D3_GAA_GAB_GBB)
2280              Cmat3(iq,D3_GAB_GAB_GAB) = Cmat3(iq,D3_GAB_GAB_GAB)
2281              Mmat3(iq,D3_RA_RA_TA) = Mmat3(iq,D3_RA_RA_TA)
2282              Mmat3(iq,D3_RA_RA_TB) = Mmat3(iq,D3_RA_RA_TB)
2283              Mmat3(iq,D3_RA_RB_TA) = Mmat3(iq,D3_RA_RB_TA)
2284              Mmat3(iq,D3_RA_GAA_TA) = Mmat3(iq,D3_RA_GAA_TA)
2285              Mmat3(iq,D3_RA_GAA_TB) = Mmat3(iq,D3_RA_GAA_TB)
2286              Mmat3(iq,D3_RA_GAB_TA) = Mmat3(iq,D3_RA_GAB_TA)
2287              Mmat3(iq,D3_RA_GAB_TB) = Mmat3(iq,D3_RA_GAB_TB)
2288              Mmat3(iq,D3_RA_GBB_TA) = Mmat3(iq,D3_RA_GBB_TA)
2289              Mmat3(iq,D3_RA_GBB_TB) = Mmat3(iq,D3_RA_GBB_TB)
2290              Mmat3(iq,D3_GAA_GAA_TA) = Mmat3(iq,D3_GAA_GAA_TA)
2291              Mmat3(iq,D3_GAA_GAA_TB) = Mmat3(iq,D3_GAA_GAA_TB)
2292              Mmat3(iq,D3_GAA_GAB_TA) = Mmat3(iq,D3_GAA_GAB_TA)
2293              Mmat3(iq,D3_GAA_GAB_TB) = Mmat3(iq,D3_GAA_GAB_TB)
2294              Mmat3(iq,D3_GAA_GBB_TA) = Mmat3(iq,D3_GAA_GBB_TA)
2295              Mmat3(iq,D3_GAB_GAB_TA) = Mmat3(iq,D3_GAB_GAB_TA)
2296              Mmat3(iq,D3_TA_TA_TA) = Mmat3(iq,D3_TA_TA_TA)
2297              Mmat3(iq,D3_TA_TA_TB) = Mmat3(iq,D3_TA_TA_TB)
2298            endif
2299          endif ! rhoa.gt.tol_rho
2300        else  ! ipol.eq.1
2301          rhoa    = rho(iq,R_A)
2302          rhob    = rho(iq,R_B)
2303          gammaaa = rgamma(iq,G_AA)
2304          gammaab = rgamma(iq,G_AB)
2305          gammabb = rgamma(iq,G_BB)
2306          taua    = tau(iq,T_A)
2307          taub    = tau(iq,T_B)
2308          if (rhoa.gt.tol_rho.and.rhob.gt.tol_rho) then
2309            if (taua.gt.tol_rho.and.taub.gt.tol_rho) then
2310              t1 = rhob+rhoa
2311              t2 = param(1)
2312              sr(R_A) = rhoa
2313              sr(R_B) = 0.0d+0
2314              sg(G_AA) = gammaaa
2315              sg(G_AB) = 0.0d+0
2316              sg(G_BB) = 0.0d+0
2317              s1f = 0.0d0
2318              call dcopy(NCOL_AMAT,0.0d0,0,s1a,1)
2319              call dcopy(NCOL_AMAT2,0.0d0,0,s1a2,1)
2320              call dcopy(NCOL_AMAT3,0.0d0,0,s1a3,1)
2321              call dcopy(NCOL_CMAT,0.0d0,0,s1c,1)
2322              call dcopy(NCOL_CMAT2,0.0d0,0,s1c2,1)
2323              call dcopy(NCOL_CMAT3,0.0d0,0,s1c3,1)
2324              call nwxcm_c_mpbe_d3(t2,tol_rho,2,1,1.0d0,sr,sg,s1f,s1a,
2325     +          s1a2,s1a3,s1c,s1c2,s1c3)
2326              t3 = s1f
2327              t4 = gammaaa**2
2328              t5 = 1/rhoa
2329              t6 = 1/t1
2330              t7 = 1/taua**2
2331              sr(R_A) = 0.0d+0
2332              sr(R_B) = rhob
2333              sg(G_AA) = 0.0d+0
2334              sg(G_AB) = 0.0d+0
2335              sg(G_BB) = gammabb
2336              s2f = 0.0d0
2337              call dcopy(NCOL_AMAT,0.0d0,0,s2a,1)
2338              call dcopy(NCOL_AMAT2,0.0d0,0,s2a2,1)
2339              call dcopy(NCOL_AMAT3,0.0d0,0,s2a3,1)
2340              call dcopy(NCOL_CMAT,0.0d0,0,s2c,1)
2341              call dcopy(NCOL_CMAT2,0.0d0,0,s2c2,1)
2342              call dcopy(NCOL_CMAT3,0.0d0,0,s2c3,1)
2343              call nwxcm_c_mpbe_d3(t2,tol_rho,2,1,1.0d0,sr,sg,s2f,s2a,
2344     +          s2a2,s2a3,s2c,s2c2,s2c3)
2345              t8 = s2f
2346              t9 = gammabb**2
2347              t10 = 1/rhob
2348              t11 = 1/taub**2
2349              sr(R_A) = rhoa
2350              sr(R_B) = rhob
2351              sg(G_AA) = gammaaa
2352              sg(G_AB) = gammaab
2353              sg(G_BB) = gammabb
2354              s3f = 0.0d0
2355              call dcopy(NCOL_AMAT,0.0d0,0,s3a,1)
2356              call dcopy(NCOL_AMAT2,0.0d0,0,s3a2,1)
2357              call dcopy(NCOL_AMAT3,0.0d0,0,s3a3,1)
2358              call dcopy(NCOL_CMAT,0.0d0,0,s3c,1)
2359              call dcopy(NCOL_CMAT2,0.0d0,0,s3c2,1)
2360              call dcopy(NCOL_CMAT3,0.0d0,0,s3c3,1)
2361              call nwxcm_c_mpbe_d3(t2,tol_rho,ipol,1,1.0d0,sr,sg,s3f,
2362     +          s3a,s3a2,s3a3,s3c,s3c2,s3c3)
2363              t12 = s3f
2364              t13 = 1.25d-1*gammaaa*t5+1.25d-1*gammabb*t10
2365              t14 = t13**2
2366              t15 = taub+taua
2367              t16 = 1/t15**2
2368              t17 = 5.3d-1*t14*t16+1.0d+0
2369              t18 = -2.390625d-2*t10*t11*t6*s2f*t9-2.390625d-2*s1f*t4
2370     +          *t5*t6*t7+s3f*t17
2371              t19 = 1.0d+0*t18*wght
2372              t20 = 1/t1**2
2373              t21 = 2.390625d-2*t20*s1f*t4*t5*t7
2374              t22 = 1/rhoa**2
2375              t23 = s1a(D1_RA)
2376              t24 = 2.390625d-2*t10*t11*t20*s2f*t9
2377              t25 = s3a(D1_RA)
2378              t26 = -2.390625d-2*t23*t4*t5*t6*t7+2.390625d-2*t22*s1f
2379     +          *t4*t6*t7+t17*t25+t24-1.325d-1*gammaaa*s3f*t13*t16*t22
2380     +          +t21
2381              t27 = 1/rhob**2
2382              t28 = s2a(D1_RB)
2383              t29 = s3a(D1_RB)
2384              t30 = 2.390625d-2*t11*t27*t6*s2f*t9-2.390625d-2*t10*t11
2385     +          *t28*t6*t9+t17*t29-1.325d-1*gammabb*s3f*t13*t16*t27
2386     +          +t24+t21
2387              t31 = s1c(D1_GAA)
2388              t32 = -2.390625d-2*t31*t4-4.78125d-2*gammaaa*s1f
2389              t33 = 1.325d-1*s3f*t13*t16*t5
2390              t34 = s3c(D1_GAA)
2391              t35 = t17*t34
2392              t36 = s3c(D1_GAB)
2393              t37 = s2c(D1_GBB)
2394              t38 = -2.390625d-2*t37*t9-4.78125d-2*gammabb*s2f
2395              t39 = 1.325d-1*t10*s3f*t13*t16
2396              t40 = s3c(D1_GBB)
2397              t41 = t17*t40
2398              t42 = 1/taua**3
2399              t43 = 1/t15**3
2400              t44 = -1.0600000000000001d+0*s3f*t14*t43
2401              t45 = 4.78125d-2*s1f*t4*t42*t5*t6+t44
2402              t46 = 1/taub**3
2403              t47 = 4.78125d-2*t10*t46*t6*s2f*t9+t44
2404              t48 = 1/t1**3
2405              t49 = -4.78125d-2*s1f*t4*t48*t5*t7
2406              t50 = 1/rhoa**3
2407              t51 = s1a2(D2_RA_RA)
2408              t52 = -4.78125d-2*t10*t11*t48*s2f*t9
2409              t53 = 1/rhoa**4
2410              t54 = s3a2(D2_RA_RA)
2411              t55 = -2.390625d-2*t4*t5*t51*t6*t7-4.78125d-2*s1f*t4*t50
2412     +          *t6*t7+4.78125d-2*t22*t23*t4*t6*t7+4.78125d-2*t20*t23
2413     +          *t4*t5*t7-4.78125d-2*t20*t22*s1f*t4*t7+t17*t54
2414     +          +1.6562500000000002d-2*s3f*t16*t4*t53+t52+2.65d-1
2415     +          *gammaaa*s3f*t13*t16*t50+t49-2.65d-1*gammaaa*t13*t16
2416     +          *t22*t25
2417              t56 = s3a2(D2_RA_RB)
2418              t57 = -2.390625d-2*t11*t20*t27*s2f*t9+2.390625d-2*t10
2419     +          *t11*t20*t28*t9+2.390625d-2*t20*t23*t4*t5*t7
2420     +          -2.390625d-2*t20*t22*s1f*t4*t7+t17*t56+t52+t49
2421     +          -1.325d-1*gammaaa*t13*t16*t22*t29-1.325d-1*gammabb*t13
2422     +          *t16*t25*t27+1.6562500000000002d-2*gammaaa*gammabb*s3f
2423     +          *t16*t22*t27
2424              t58 = 1/rhob**3
2425              t59 = s2a2(D2_RB_RB)
2426              t60 = 1/rhob**4
2427              t61 = s3a2(D2_RB_RB)
2428              t62 = -4.78125d-2*t11*t58*t6*s2f*t9-4.78125d-2*t11*t20
2429     +          *t27*s2f*t9+1.6562500000000002d-2*s3f*t16*t60*t9
2430     +          -2.390625d-2*t10*t11*t59*t6*t9+4.78125d-2*t11*t27*t28
2431     +          *t6*t9+4.78125d-2*t10*t11*t20*t28*t9+t17*t61+2.65d-1
2432     +          *gammabb*s3f*t13*t16*t58+t52+t49-2.65d-1*gammabb*t13
2433     +          *t16*t27*t29
2434              t63 = 1.0d+0*(-2.390625d-2*t31*t4*t5*t6*t7-4.78125d-2
2435     +          *gammaaa*s1f*t5*t6*t7+t35+t33)*wght
2436              t64 = 4.78125d-2*gammaaa*t20*s1f*t5*t7
2437              t65 = 2.390625d-2*t20*t31*t4*t5*t7
2438              t66 = s1c2(D2_RA_GAA)
2439              t67 = s3c2(D2_RA_GAA)
2440              t68 = -2.390625d-2*t4*t5*t6*t66*t7-4.78125d-2*gammaaa
2441     +          *t23*t5*t6*t7+2.390625d-2*t22*t31*t4*t6*t7+4.78125d-2
2442     +          *gammaaa*t22*s1f*t6*t7+t17*t67+t65+t64
2443     +          -1.6562500000000002d-2*gammaaa*s3f*t16*t50+1.325d-1
2444     +          *t13*t16*t25*t5-1.325d-1*gammaaa*t13*t16*t22*t34
2445     +          -1.325d-1*s3f*t13*t16*t22
2446              t69 = 1.0d+0*t17*t36*wght
2447              t70 = s3c2(D2_RA_GAB)
2448              t71 = t17*t70-1.325d-1*gammaaa*t13*t16*t22*t36
2449              t72 = 1.0d+0*(-2.390625d-2*t10*t11*t37*t6*t9-4.78125d-2
2450     +          *gammabb*t10*t11*t6*s2f+t41+t39)*wght
2451              t73 = 4.78125d-2*gammabb*t10*t11*t20*s2f
2452              t74 = 2.390625d-2*t10*t11*t20*t37*t9
2453              t75 = s3c2(D2_RA_GBB)
2454              t76 = t17*t75+t74+t73-1.325d-1*gammaaa*t13*t16*t22*t40
2455     +          +1.325d-1*t10*t13*t16*t25-1.6562500000000002d-2
2456     +          *gammaaa*t10*s3f*t16*t22
2457              t77 = s3c2(D2_RB_GAA)
2458              t78 = t17*t77+t65+t64+1.325d-1*t13*t16*t29*t5
2459     +          -1.6562500000000002d-2*gammabb*s3f*t16*t27*t5-1.325d-1
2460     +          *gammabb*t13*t16*t27*t34
2461              t79 = s3c2(D2_RB_GAB)
2462              t80 = t17*t79-1.325d-1*gammabb*t13*t16*t27*t36
2463              t81 = s2c2(D2_RB_GBB)
2464              t82 = s3c2(D2_RB_GBB)
2465              t83 = -2.390625d-2*t10*t11*t6*t81*t9+2.390625d-2*t11*t27
2466     +          *t37*t6*t9+t17*t82+4.78125d-2*gammabb*t11*t27*t6*s2f
2467     +          +t74+t73-4.78125d-2*gammabb*t10*t11*t28*t6
2468     +          -1.6562500000000002d-2*gammabb*s3f*t16*t58-1.325d-1
2469     +          *gammabb*t13*t16*t27*t40+1.325d-1*t10*t13*t16*t29
2470     +          -1.325d-1*s3f*t13*t16*t27
2471              t84 = s1c2(D2_GAA_GAA)
2472              t85 = -2.390625d-2*t4*t84-9.5625d-2*gammaaa*t31
2473     +          -4.78125d-2*s1f
2474              t86 = 1.6562500000000002d-2*s3f*t16*t22
2475              t87 = 2.65d-1*t13*t16*t34*t5
2476              t88 = s3c2(D2_GAA_GAA)
2477              t89 = t17*t88
2478              t90 = s3c2(D2_GAA_GAB)
2479              t91 = t17*t90+1.325d-1*t13*t16*t36*t5
2480              t92 = s3c2(D2_GAA_GBB)
2481              t93 = t17*t92+1.325d-1*t13*t16*t40*t5
2482     +          +1.6562500000000002d-2*t10*s3f*t16*t5+1.325d-1*t10*t13
2483     +          *t16*t34
2484              t94 = s3c2(D2_GAB_GAB)
2485              t95 = s3c2(D2_GAB_GBB)
2486              t96 = s2c2(D2_GBB_GBB)
2487              t97 = -2.390625d-2*t9*t96-4.78125d-2*s2f-9.5625d-2
2488     +          *gammabb*t37
2489              t98 = 1.6562500000000002d-2*s3f*t16*t27
2490              t99 = 2.65d-1*t10*t13*t16*t40
2491              t100 = s3c2(D2_GBB_GBB)
2492              t101 = t100*t17
2493              t102 = 1.0d+0*t45*wght
2494              t103 = -4.78125d-2*t20*s1f*t4*t42*t5
2495              t104 = -1.0600000000000001d+0*t14*t25*t43
2496              t105 = 2.65d-1*gammaaa*s3f*t13*t22*t43
2497              t106 = 4.78125d-2*t23*t4*t42*t5*t6-4.78125d-2*t22*s1f*t4
2498     +          *t42*t6+t105+t104+t103
2499              t107 = 1.0d+0*t47*wght
2500              t108 = -4.78125d-2*t10*t20*t46*s2f*t9
2501              t109 = t108+t105+t104
2502              t110 = -1.0600000000000001d+0*t14*t29*t43
2503              t111 = 2.65d-1*gammabb*s3f*t13*t27*t43
2504              t112 = t111+t110+t103
2505              t113 = -4.78125d-2*t27*t46*t6*s2f*t9+4.78125d-2*t10*t28
2506     +          *t46*t6*t9+t111+t110+t108
2507              t114 = -1.0600000000000001d+0*t14*t34*t43
2508              t115 = -2.65d-1*s3f*t13*t43*t5
2509              t116 = t115+t114
2510              t117 = -1.0600000000000001d+0*t1*t14*t36*t43*wght
2511              t118 = -1.0600000000000001d+0*t14*t40*t43
2512              t119 = -2.65d-1*t10*s3f*t13*t43
2513              t120 = t119+t118
2514              t121 = 1/taua**4
2515              t122 = 1/t15**4
2516              t123 = 3.18d+0*s3f*t122*t14
2517              t124 = 1/taub**4
2518              t125 = 1/t1**4
2519              t126 = 1.434375d-1*t125*s1f*t4*t5*t7
2520              t127 = 1.434375d-1*t10*t11*t125*s2f*t9
2521              t128 = 2.0d+0*t57*wght
2522              t129 = -9.5625d-2*gammaaa*s1f*t48*t5*t7
2523              t130 = -4.78125d-2*t31*t4*t48*t5*t7
2524              t131 = -9.5625d-2*gammabb*t10*t11*t48*s2f
2525              t132 = -4.78125d-2*t10*t11*t37*t48*t9
2526              t133 = 1.0d+0*(t89+t87+t86-2.390625d-2*t4*t5*t6*t7*t84
2527     +          -9.5625d-2*gammaaa*t31*t5*t6*t7-4.78125d-2*s1f*t5*t6
2528     +          *t7)*wght
2529              t134 = 4.78125d-2*t20*s1f*t5*t7
2530              t135 = 9.5625d-2*gammaaa*t20*t31*t5*t7
2531              t136 = 2.390625d-2*t20*t4*t5*t7*t84
2532              t137 = 1.0d+0*t91*wght
2533              t138 = 1.0d+0*t93*wght
2534              t139 = 1.0d+0*t17*t94*wght
2535              t140 = 1.325d-1*t10*t13*t16*t36*wght
2536              t141 = 1.0d+0*t17*t95*wght
2537              t142 = 1.0d+0*(t99+t98-2.390625d-2*t10*t11*t6*t9*t96
2538     +          -4.78125d-2*t10*t11*t6*s2f-9.5625d-2*gammabb*t10*t11
2539     +          *t37*t6+t101)*wght
2540              t143 = 4.78125d-2*t10*t11*t20*s2f
2541              t144 = 9.5625d-2*gammabb*t10*t11*t20*t37
2542              t145 = 2.390625d-2*t10*t11*t20*t9*t96
2543              t146 = 9.5625d-2*s1f*t4*t42*t48*t5
2544              t147 = -3.3125000000000004d-2*s3f*t4*t43*t53
2545              t148 = -1.0600000000000001d+0*t14*t43*t54
2546              t149 = -5.3d-1*gammaaa*s3f*t13*t43*t50
2547              t150 = 5.3d-1*gammaaa*t13*t22*t25*t43
2548              t151 = 9.5625d-2*t10*t46*t48*s2f*t9
2549              t152 = -1.0600000000000001d+0*t14*t43*t56
2550              t153 = -3.3125000000000004d-2*gammaaa*gammabb*s3f*t22
2551     +          *t27*t43
2552              t154 = 2.65d-1*gammabb*t13*t25*t27*t43
2553              t155 = 2.65d-1*gammaaa*t13*t22*t29*t43
2554              t156 = -1.0600000000000001d+0*t14*t43*t61
2555              t157 = -3.3125000000000004d-2*s3f*t43*t60*t9
2556              t158 = -5.3d-1*gammabb*s3f*t13*t43*t58
2557              t159 = 5.3d-1*gammabb*t13*t27*t29*t43
2558              t160 = 1.0d+0*(4.78125d-2*t31*t4*t42*t5*t6+9.5625d-2
2559     +          *gammaaa*s1f*t42*t5*t6+t115+t114)*wght
2560              t161 = -9.5625d-2*gammaaa*t20*s1f*t42*t5
2561              t162 = -4.78125d-2*t20*t31*t4*t42*t5
2562              t163 = 3.3125000000000004d-2*gammaaa*s3f*t43*t50
2563              t164 = -1.0600000000000001d+0*t14*t43*t67
2564              t165 = 2.65d-1*s3f*t13*t22*t43
2565              t166 = 2.65d-1*gammaaa*t13*t22*t34*t43
2566              t167 = -2.65d-1*t13*t25*t43*t5
2567              t168 = 1.0d+0*t116*wght
2568              t169 = -1.0600000000000001d+0*t14*t36*t43*wght
2569              t170 = 1.0d+0*t1*(2.65d-1*gammaaa*t13*t22*t36*t43
2570     +          -1.0600000000000001d+0*t14*t43*t70)*wght+t169
2571              t171 = 1.0d+0*t120*wght
2572              t172 = -1.0600000000000001d+0*t14*t43*t75
2573              t173 = 3.3125000000000004d-2*gammaaa*t10*s3f*t22*t43
2574              t174 = -2.65d-1*t10*t13*t25*t43
2575              t175 = 2.65d-1*gammaaa*t13*t22*t40*t43
2576              t176 = 1.0d+0*(4.78125d-2*t10*t37*t46*t6*t9+9.5625d-2
2577     +          *gammabb*t10*t46*t6*s2f+t119+t118)*wght
2578              t177 = -9.5625d-2*gammabb*t10*t20*t46*s2f
2579              t178 = -4.78125d-2*t10*t20*t37*t46*t9
2580              t179 = -1.0600000000000001d+0*t14*t43*t77
2581              t180 = 3.3125000000000004d-2*gammabb*s3f*t27*t43*t5
2582              t181 = 2.65d-1*gammabb*t13*t27*t34*t43
2583              t182 = -2.65d-1*t13*t29*t43*t5
2584              t183 = 1.0d+0*t1*(2.65d-1*gammabb*t13*t27*t36*t43
2585     +          -1.0600000000000001d+0*t14*t43*t79)*wght+t169
2586              t184 = -1.0600000000000001d+0*t14*t43*t82
2587              t185 = 3.3125000000000004d-2*gammabb*s3f*t43*t58
2588              t186 = 2.65d-1*s3f*t13*t27*t43
2589              t187 = 2.65d-1*gammabb*t13*t27*t40*t43
2590              t188 = -2.65d-1*t10*t13*t29*t43
2591              t189 = -3.3125000000000004d-2*s3f*t22*t43
2592              t190 = -1.0600000000000001d+0*t14*t43*t88
2593              t191 = -5.3d-1*t13*t34*t43*t5
2594              t192 = 1.0d+0*t1*(-1.0600000000000001d+0*t14*t43*t90
2595     +          -2.65d-1*t13*t36*t43*t5)*wght
2596              t193 = 1.0d+0*t1*(-1.0600000000000001d+0*t14*t43*t92
2597     +          -2.65d-1*t13*t40*t43*t5-3.3125000000000004d-2*t10*s3f
2598     +          *t43*t5-2.65d-1*t10*t13*t34*t43)*wght
2599              t194 = -1.0600000000000001d+0*t1*t14*t43*t94*wght
2600              t195 = -1.0600000000000001d+0*t1*t14*t43*t95*wght
2601     +          -2.65d-1*t1*t10*t13*t36*t43*wght
2602              t196 = -1.0600000000000001d+0*t100*t14*t43
2603              t197 = -3.3125000000000004d-2*s3f*t27*t43
2604              t198 = -5.3d-1*t10*t13*t40*t43
2605              t199 = 3.18d+0*t122*t14*t34
2606              t200 = 7.95d-1*s3f*t122*t13*t5
2607              t201 = 1.0d+0*t1*(t200+t199)*wght
2608              t202 = 3.18d+0*t1*t122*t14*t36*wght
2609              t203 = 3.18d+0*t122*t14*t40
2610              t204 = 7.95d-1*t10*s3f*t122*t13
2611              t205 = 1.0d+0*t1*(t204+t203)*wght
2612              t206 = 1/t15**5
2613              t207 = -1.272d+1*s3f*t14*t206
2614              t208 = -1.272d+1*t1*s3f*t14*t206*wght
2615              fnc(iq) = 1.0d+0*t1*t18*wght+fnc(iq)
2616              Amat(iq,D1_RA) = 1.0d+0*t1*t26*wght+t19+Amat(iq,D1_RA)
2617              Amat(iq,D1_RB) = 1.0d+0*t1*t30*wght+t19+Amat(iq,D1_RB)
2618              Cmat(iq,D1_GAA) = 1.0d+0*t1*(t32*t5*t6*t7+t35+t33)*wght
2619     +          +Cmat(iq,D1_GAA)
2620              Cmat(iq,D1_GAB) = 1.0d+0*t1*t17*t36*wght+Cmat(iq,D1_GAB)
2621              Cmat(iq,D1_GBB) = 1.0d+0*t1*(t10*t11*t38*t6+t41+t39)
2622     +          *wght+Cmat(iq,D1_GBB)
2623              Mmat(iq,D1_TA) = 1.0d+0*t1*t45*wght+Mmat(iq,D1_TA)
2624              Mmat(iq,D1_TB) = 1.0d+0*t1*t47*wght+Mmat(iq,D1_TB)
2625              Amat2(iq,D2_RA_RA) = 1.0d+0*t1*t55*wght+2.0d+0*t26*wght
2626     +          +Amat2(iq,D2_RA_RA)
2627              Amat2(iq,D2_RA_RB) = 1.0d+0*t1*t57*wght+1.0d+0*t30*wght
2628     +          +1.0d+0*t26*wght+Amat2(iq,D2_RA_RB)
2629              Amat2(iq,D2_RB_RB) = 1.0d+0*t1*t62*wght+2.0d+0*t30*wght
2630     +          +Amat2(iq,D2_RB_RB)
2631              Cmat2(iq,D2_RA_GAA) = 1.0d+0*t1*t68*wght+t63+Cmat2(iq,
2632     +          D2_RA_GAA)
2633              Cmat2(iq,D2_RA_GAB) = 1.0d+0*t1*t71*wght+t69+Cmat2(iq,
2634     +          D2_RA_GAB)
2635              Cmat2(iq,D2_RA_GBB) = 1.0d+0*t1*t76*wght+t72+Cmat2(iq,
2636     +          D2_RA_GBB)
2637              Cmat2(iq,D2_RB_GAA) = 1.0d+0*t1*t78*wght+t63+Cmat2(iq,
2638     +          D2_RB_GAA)
2639              Cmat2(iq,D2_RB_GAB) = 1.0d+0*t1*t80*wght+t69+Cmat2(iq,
2640     +          D2_RB_GAB)
2641              Cmat2(iq,D2_RB_GBB) = 1.0d+0*t1*t83*wght+t72+Cmat2(iq,
2642     +          D2_RB_GBB)
2643              Cmat2(iq,D2_GAA_GAA) = 1.0d+0*t1*(t89+t87+t86+t5*t6*t7
2644     +          *t85)*wght+Cmat2(iq,D2_GAA_GAA)
2645              Cmat2(iq,D2_GAA_GAB) = 1.0d+0*t1*t91*wght+Cmat2(iq,
2646     +          D2_GAA_GAB)
2647              Cmat2(iq,D2_GAA_GBB) = 1.0d+0*t1*t93*wght+Cmat2(iq,
2648     +          D2_GAA_GBB)
2649              Cmat2(iq,D2_GAB_GAB) = 1.0d+0*t1*t17*t94*wght+Cmat2(iq,
2650     +          D2_GAB_GAB)
2651              Cmat2(iq,D2_GAB_GBB) = 1.0d+0*t1*t17*t95*wght+1.325d-1
2652     +          *t1*t10*t13*t16*t36*wght+Cmat2(iq,D2_GAB_GBB)
2653              Cmat2(iq,D2_GBB_GBB) = 1.0d+0*t1*(t99+t98+t10*t11*t6*t97
2654     +          +t101)*wght+Cmat2(iq,D2_GBB_GBB)
2655              Mmat2(iq,D2_RA_TA) = 1.0d+0*t1*t106*wght+t102+Mmat2(iq,
2656     +          D2_RA_TA)
2657              Mmat2(iq,D2_RA_TB) = 1.0d+0*t1*t109*wght+t107+Mmat2(iq,
2658     +          D2_RA_TB)
2659              Mmat2(iq,D2_RB_TA) = 1.0d+0*t1*t112*wght+t102+Mmat2(iq,
2660     +          D2_RB_TA)
2661              Mmat2(iq,D2_RB_TB) = 1.0d+0*t1*t113*wght+t107+Mmat2(iq,
2662     +          D2_RB_TB)
2663              Mmat2(iq,D2_GAA_TA) = 1.0d+0*t1*(-2*t32*t42*t5*t6+t115
2664     +          +t114)*wght+Mmat2(iq,D2_GAA_TA)
2665              Mmat2(iq,D2_GAA_TB) = 1.0d+0*t1*t116*wght+Mmat2(iq,
2666     +          D2_GAA_TB)
2667              Mmat2(iq,D2_GAB_TA) = t117+Mmat2(iq,D2_GAB_TA)
2668              Mmat2(iq,D2_GAB_TB) = t117+Mmat2(iq,D2_GAB_TB)
2669              Mmat2(iq,D2_GBB_TA) = 1.0d+0*t1*t120*wght+Mmat2(iq,
2670     +          D2_GBB_TA)
2671              Mmat2(iq,D2_GBB_TB) = 1.0d+0*t1*(-2*t10*t38*t46*t6+t119
2672     +          +t118)*wght+Mmat2(iq,D2_GBB_TB)
2673              Mmat2(iq,D2_TA_TA) = 1.0d+0*t1*(t123-1.434375d-1*t121
2674     +          *s1f*t4*t5*t6)*wght+Mmat2(iq,D2_TA_TA)
2675              Mmat2(iq,D2_TA_TB) = 3.18d+0*t1*s3f*t122*t14*wght+Mmat2
2676     +          (iq,D2_TA_TB)
2677              Mmat2(iq,D2_TB_TB) = 1.0d+0*t1*(t123-1.434375d-1*t10
2678     +          *t124*t6*s2f*t9)*wght+Mmat2(iq,D2_TB_TB)
2679              Amat3(iq,D3_RA_RA_RA) = 1.0d+0*t1*(1.434375d-1*s1f*t4
2680     +          *t53*t6*t7+7.171875d-2*t22*t4*t51*t6*t7-1.434375d-1
2681     +          *t23*t4*t50*t6*t7-2.390625d-2*s1a3(D3_RA_RA_RA)*t4*t5
2682     +          *t6*t7+7.171875d-2*t20*t4*t5*t51*t7+1.434375d-1*t20
2683     +          *s1f*t4*t50*t7-1.434375d-1*t23*t4*t48*t5*t7
2684     +          +1.434375d-1*t22*s1f*t4*t48*t7-1.434375d-1*t20*t22*t23
2685     +          *t4*t7-3.975d-1*gammaaa*t13*t16*t22*t54+4.96875d-2*t16
2686     +          *t25*t4*t53-7.95d-1*gammaaa*s3f*t13*t16*t53+7.95d-1
2687     +          *gammaaa*t13*t16*t25*t50-9.9375d-2*s3f*t16*t4/rhoa**5
2688     +          +s3a3(D3_RA_RA_RA)*t17+t127+t126)*wght+3.0d+0*t55*wght
2689     +          +Amat3(iq,D3_RA_RA_RA)
2690              Amat3(iq,D3_RA_RA_RB) = 1.0d+0*t1*(4.78125d-2*t11*t27
2691     +          *t48*s2f*t9-4.78125d-2*t10*t11*t28*t48*t9+2.390625d-2
2692     +          *t20*t4*t5*t51*t7+4.78125d-2*t20*s1f*t4*t50*t7
2693     +          -9.5625d-2*t23*t4*t48*t5*t7+9.5625d-2*t22*s1f*t4*t48
2694     +          *t7-4.78125d-2*t20*t22*t23*t4*t7-2.65d-1*gammaaa*t13
2695     +          *t16*t22*t56-1.325d-1*gammabb*t13*t16*t27*t54
2696     +          +1.6562500000000002d-2*t16*t29*t4*t53+2.65d-1*gammaaa
2697     +          *t13*t16*t29*t50-3.3125000000000004d-2*gammaaa*gammabb
2698     +          *s3f*t16*t27*t50+3.3125000000000004d-2*gammaaa*gammabb
2699     +          *t16*t22*t25*t27+s3a3(D3_RA_RA_RB)*t17+t127+t126)*wght
2700     +          +1.0d+0*t55*wght+t128+Amat3(iq,D3_RA_RA_RB)
2701              Amat3(iq,D3_RA_RB_RB) = 1.0d+0*t1*(4.78125d-2*t11*t20
2702     +          *t58*s2f*t9+9.5625d-2*t11*t27*t48*s2f*t9
2703     +          +1.6562500000000002d-2*t16*t25*t60*t9+2.390625d-2*t10
2704     +          *t11*t20*t59*t9-9.5625d-2*t10*t11*t28*t48*t9
2705     +          -4.78125d-2*t11*t20*t27*t28*t9-4.78125d-2*t23*t4*t48
2706     +          *t5*t7+4.78125d-2*t22*s1f*t4*t48*t7-1.325d-1*gammaaa
2707     +          *t13*t16*t22*t61+2.65d-1*gammabb*t13*t16*t25*t58
2708     +          -3.3125000000000004d-2*gammaaa*gammabb*s3f*t16*t22*t58
2709     +          -2.65d-1*gammabb*t13*t16*t27*t56+3.3125000000000004d-2
2710     +          *gammaaa*gammabb*t16*t22*t27*t29+s3a3(D3_RA_RB_RB)*t17
2711     +          +t127+t126)*wght+1.0d+0*t62*wght+t128+Amat3(iq,
2712     +          D3_RA_RB_RB)
2713              Amat3(iq,D3_RB_RB_RB) = 1.0d+0*t1*(-2.390625d-2*t10*t11
2714     +          *t6*s2a3(D3_RB_RB_RB)*t9+1.434375d-1*t11*t6*t60*s2f*t9
2715     +          +1.434375d-1*t11*t20*t58*s2f*t9+1.434375d-1*t11*t27
2716     +          *t48*s2f*t9+4.96875d-2*t16*t29*t60*t9+7.171875d-2*t11
2717     +          *t27*t59*t6*t9-1.434375d-1*t11*t28*t58*t6*t9
2718     +          +7.171875d-2*t10*t11*t20*t59*t9-1.434375d-1*t10*t11
2719     +          *t28*t48*t9-1.434375d-1*t11*t20*t27*t28*t9-9.9375d-2
2720     +          *s3f*t16*t9/rhob**5-3.975d-1*gammabb*t13*t16*t27*t61
2721     +          -7.95d-1*gammabb*s3f*t13*t16*t60+7.95d-1*gammabb*t13
2722     +          *t16*t29*t58+s3a3(D3_RB_RB_RB)*t17+t127+t126)*wght
2723     +          +3.0d+0*t62*wght+Amat3(iq,D3_RB_RB_RB)
2724              Cmat3(iq,D3_RA_RA_GAA) = 1.0d+0*t1*(4.78125d-2*t22*t4*t6
2725     +          *t66*t7+4.78125d-2*t20*t4*t5*t66*t7-4.78125d-2*gammaaa
2726     +          *t5*t51*t6*t7-4.78125d-2*t31*t4*t50*t6*t7-9.5625d-2
2727     +          *gammaaa*s1f*t50*t6*t7-2.390625d-2*s1c3(D3_RA_RA_GAA)
2728     +          *t4*t5*t6*t7+9.5625d-2*gammaaa*t22*t23*t6*t7+9.5625d-2
2729     +          *gammaaa*t20*t23*t5*t7-4.78125d-2*t20*t22*t31*t4*t7
2730     +          -9.5625d-2*gammaaa*t20*t22*s1f*t7-2.65d-1*gammaaa*t13
2731     +          *t16*t22*t67+1.325d-1*t13*t16*t5*t54
2732     +          +1.6562500000000002d-2*t16*t34*t4*t53
2733     +          +6.625000000000001d-2*gammaaa*s3f*t16*t53+2.65d-1
2734     +          *gammaaa*t13*t16*t34*t50-3.3125000000000004d-2*gammaaa
2735     +          *t16*t25*t50+2.65d-1*s3f*t13*t16*t50-2.65d-1*t13*t16
2736     +          *t22*t25+s3c3(D3_RA_RA_GAA)*t17+t130+t129)*wght+2.0d+0
2737     +          *t68*wght+Cmat3(iq,D3_RA_RA_GAA)
2738              Cmat3(iq,D3_RA_RA_GAB) = 2.0d+0*t71*wght+1.0d+0*t1*(
2739     +          -2.65d-1*gammaaa*t13*t16*t22*t70+1.6562500000000002d-2
2740     +          *t16*t36*t4*t53+2.65d-1*gammaaa*t13*t16*t36*t50+s3c3
2741     +          (D3_RA_RA_GAB)*t17)*wght+Cmat3(iq,D3_RA_RA_GAB)
2742              Cmat3(iq,D3_RA_RA_GBB) = 2.0d+0*t76*wght+1.0d+0*t1*(
2743     +          -2.65d-1*gammaaa*t13*t16*t22*t75+1.325d-1*t10*t13*t16
2744     +          *t54+1.6562500000000002d-2*t16*t4*t40*t53+2.65d-1
2745     +          *gammaaa*t13*t16*t40*t50+3.3125000000000004d-2*gammaaa
2746     +          *t10*s3f*t16*t50-3.3125000000000004d-2*gammaaa*t10*t16
2747     +          *t22*t25+s3c3(D3_RA_RA_GBB)*t17+t132+t131)*wght+Cmat3
2748     +          (iq,D3_RA_RA_GBB)
2749              Cmat3(iq,D3_RA_RB_GAA) = 1.0d+0*t78*wght+1.0d+0*t1*(
2750     +          -1.325d-1*gammaaa*t13*t16*t22*t77+2.390625d-2*t20*t4
2751     +          *t5*t66*t7+4.78125d-2*gammaaa*t20*t23*t5*t7
2752     +          -2.390625d-2*t20*t22*t31*t4*t7-4.78125d-2*gammaaa*t20
2753     +          *t22*s1f*t7-1.325d-1*gammabb*t13*t16*t27*t67+1.325d-1
2754     +          *t13*t16*t5*t56-1.6562500000000002d-2*gammaaa*t16*t29
2755     +          *t50-1.6562500000000002d-2*gammabb*t16*t25*t27*t5
2756     +          +1.6562500000000002d-2*gammaaa*gammabb*t16*t22*t27*t34
2757     +          -1.325d-1*t13*t16*t22*t29+1.6562500000000002d-2
2758     +          *gammabb*s3f*t16*t22*t27+s3c3(D3_RA_RB_GAA)*t17+t130
2759     +          +t129)*wght+1.0d+0*t68*wght+Cmat3(iq,D3_RA_RB_GAA)
2760              Cmat3(iq,D3_RA_RB_GAB) = 1.0d+0*t80*wght+1.0d+0*t1*(
2761     +          -1.325d-1*gammaaa*t13*t16*t22*t79-1.325d-1*gammabb*t13
2762     +          *t16*t27*t70+1.6562500000000002d-2*gammaaa*gammabb*t16
2763     +          *t22*t27*t36+s3c3(D3_RA_RB_GAB)*t17)*wght+1.0d+0*t71
2764     +          *wght+Cmat3(iq,D3_RA_RB_GAB)
2765              Cmat3(iq,D3_RA_RB_GBB) = 1.0d+0*t1*(2.390625d-2*t10*t11
2766     +          *t20*t81*t9-2.390625d-2*t11*t20*t27*t37*t9-1.325d-1
2767     +          *gammaaa*t13*t16*t22*t82-4.78125d-2*gammabb*t11*t20
2768     +          *t27*s2f-1.325d-1*gammabb*t13*t16*t27*t75
2769     +          -1.6562500000000002d-2*gammabb*t16*t25*t58+1.325d-1
2770     +          *t10*t13*t16*t56+1.6562500000000002d-2*gammaaa*gammabb
2771     +          *t16*t22*t27*t40-1.6562500000000002d-2*gammaaa*t10*t16
2772     +          *t22*t29+4.78125d-2*gammabb*t10*t11*t20*t28-1.325d-1
2773     +          *t13*t16*t25*t27+1.6562500000000002d-2*gammaaa*s3f*t16
2774     +          *t22*t27+s3c3(D3_RA_RB_GBB)*t17+t132+t131)*wght+1.0d+0
2775     +          *t83*wght+1.0d+0*t76*wght+Cmat3(iq,D3_RA_RB_GBB)
2776              Cmat3(iq,D3_RB_RB_GAA) = 1.0d+0*t1*
2777     +          (1.6562500000000002d-2*t16*t34*t60*t9-2.65d-1*gammabb
2778     +          *t13*t16*t27*t77+1.325d-1*t13*t16*t5*t61
2779     +          +3.3125000000000004d-2*gammabb*s3f*t16*t5*t58+2.65d-1
2780     +          *gammabb*t13*t16*t34*t58-3.3125000000000004d-2*gammabb
2781     +          *t16*t27*t29*t5+s3c3(D3_RB_RB_GAA)*t17+t130+t129)*wght
2782     +          +2.0d+0*t78*wght+Cmat3(iq,D3_RB_RB_GAA)
2783              Cmat3(iq,D3_RB_RB_GAB) = 1.0d+0*t1*
2784     +          (1.6562500000000002d-2*t16*t36*t60*t9-2.65d-1*gammabb
2785     +          *t13*t16*t27*t79+2.65d-1*gammabb*t13*t16*t36*t58+s3c3
2786     +          (D3_RB_RB_GAB)*t17)*wght+2.0d+0*t80*wght+Cmat3(iq,
2787     +          D3_RB_RB_GAB)
2788              Cmat3(iq,D3_RB_RB_GBB) = 1.0d+0*t1*(4.78125d-2*t11*t27
2789     +          *t6*t81*t9+4.78125d-2*t10*t11*t20*t81*t9-2.390625d-2
2790     +          *t10*t11*t6*s2c3(D3_RB_RB_GBB)*t9
2791     +          +1.6562500000000002d-2*t16*t40*t60*t9-4.78125d-2*t11
2792     +          *t37*t58*t6*t9-4.78125d-2*t11*t20*t27*t37*t9-2.65d-1
2793     +          *gammabb*t13*t16*t27*t82-9.5625d-2*gammabb*t11*t58*t6
2794     +          *s2f-9.5625d-2*gammabb*t11*t20*t27*s2f+1.325d-1*t10
2795     +          *t13*t16*t61+6.625000000000001d-2*gammabb*s3f*t16*t60
2796     +          -4.78125d-2*gammabb*t10*t11*t59*t6+9.5625d-2*gammabb
2797     +          *t11*t27*t28*t6+2.65d-1*gammabb*t13*t16*t40*t58
2798     +          -3.3125000000000004d-2*gammabb*t16*t29*t58+2.65d-1*s3f
2799     +          *t13*t16*t58-2.65d-1*t13*t16*t27*t29+9.5625d-2*gammabb
2800     +          *t10*t11*t20*t28+s3c3(D3_RB_RB_GBB)*t17+t132+t131)
2801     +          *wght+2.0d+0*t83*wght+Cmat3(iq,D3_RB_RB_GBB)
2802              Cmat3(iq,D3_RA_GAA_GAA) = 1.0d+0*t1*(-1.325d-1*gammaaa
2803     +          *t13*t16*t22*t88+2.390625d-2*t22*t4*t6*t7*t84
2804     +          -9.5625d-2*gammaaa*t5*t6*t66*t7-2.390625d-2*s1c3
2805     +          (D3_RA_GAA_GAA)*t4*t5*t6*t7-4.78125d-2*t23*t5*t6*t7
2806     +          +9.5625d-2*gammaaa*t22*t31*t6*t7+4.78125d-2*t22*s1f*t6
2807     +          *t7+2.65d-1*t13*t16*t5*t67-3.3125000000000004d-2
2808     +          *gammaaa*t16*t34*t50-3.3125000000000004d-2*s3f*t16*t50
2809     +          -2.65d-1*t13*t16*t22*t34+1.6562500000000002d-2*t16*t22
2810     +          *t25+s3c3(D3_RA_GAA_GAA)*t17+t136+t135+t134)*wght+t133
2811     +          +Cmat3(iq,D3_RA_GAA_GAA)
2812              Cmat3(iq,D3_RA_GAA_GAB) = 1.0d+0*t1*(-1.325d-1*gammaaa
2813     +          *t13*t16*t22*t90+1.325d-1*t13*t16*t5*t70
2814     +          -1.6562500000000002d-2*gammaaa*t16*t36*t50-1.325d-1
2815     +          *t13*t16*t22*t36+s3c3(D3_RA_GAA_GAB)*t17)*wght+t137
2816     +          +Cmat3(iq,D3_RA_GAA_GAB)
2817              Cmat3(iq,D3_RA_GAA_GBB) = 1.0d+0*t1*(-1.325d-1*gammaaa
2818     +          *t13*t16*t22*t92+1.325d-1*t13*t16*t5*t75+1.325d-1*t10
2819     +          *t13*t16*t67-1.6562500000000002d-2*gammaaa*t16*t40*t50
2820     +          +1.6562500000000002d-2*t10*t16*t25*t5-1.325d-1*t13*t16
2821     +          *t22*t40-1.6562500000000002d-2*gammaaa*t10*t16*t22*t34
2822     +          -1.6562500000000002d-2*t10*s3f*t16*t22+s3c3
2823     +          (D3_RA_GAA_GBB)*t17)*wght+t138+Cmat3(iq,D3_RA_GAA_GBB)
2824              Cmat3(iq,D3_RA_GAB_GAB) = 1.0d+0*t1*(s3c3(D3_RA_GAB_GAB)
2825     +          *t17-1.325d-1*gammaaa*t13*t16*t22*t94)*wght+t139+Cmat3
2826     +          (iq,D3_RA_GAB_GAB)
2827              Cmat3(iq,D3_RA_GAB_GBB) = 1.0d+0*t1*(-1.325d-1*gammaaa
2828     +          *t13*t16*t22*t95+1.325d-1*t10*t13*t16*t70
2829     +          -1.6562500000000002d-2*gammaaa*t10*t16*t22*t36+s3c3
2830     +          (D3_RA_GAB_GBB)*t17)*wght+t141+t140+Cmat3(iq,
2831     +          D3_RA_GAB_GBB)
2832              Cmat3(iq,D3_RA_GBB_GBB) = 1.0d+0*t1*(2.65d-1*t10*t13*t16
2833     +          *t75-3.3125000000000004d-2*gammaaa*t10*t16*t22*t40
2834     +          +1.6562500000000002d-2*t16*t25*t27-1.325d-1*gammaaa
2835     +          *t100*t13*t16*t22+s3c3(D3_RA_GBB_GBB)*t17+t145+t144
2836     +          +t143)*wght+t142+Cmat3(iq,D3_RA_GBB_GBB)
2837              Cmat3(iq,D3_RB_GAA_GAA) = 1.0d+0*t1*(-1.325d-1*gammabb
2838     +          *t13*t16*t27*t88+2.65d-1*t13*t16*t5*t77
2839     +          -3.3125000000000004d-2*gammabb*t16*t27*t34*t5
2840     +          +1.6562500000000002d-2*t16*t22*t29+s3c3(D3_RB_GAA_GAA)
2841     +          *t17+t136+t135+t134)*wght+t133+Cmat3(iq,D3_RB_GAA_GAA)
2842              Cmat3(iq,D3_RB_GAA_GAB) = 1.0d+0*t1*(-1.325d-1*gammabb
2843     +          *t13*t16*t27*t90+1.325d-1*t13*t16*t5*t79
2844     +          -1.6562500000000002d-2*gammabb*t16*t27*t36*t5+s3c3
2845     +          (D3_RB_GAA_GAB)*t17)*wght+t137+Cmat3(iq,D3_RB_GAA_GAB)
2846              Cmat3(iq,D3_RB_GAA_GBB) = 1.0d+0*t1*(-1.325d-1*gammabb
2847     +          *t13*t16*t27*t92+1.325d-1*t13*t16*t5*t82+1.325d-1*t10
2848     +          *t13*t16*t77-1.6562500000000002d-2*gammabb*t16*t34*t58
2849     +          -1.6562500000000002d-2*gammabb*t16*t27*t40*t5
2850     +          +1.6562500000000002d-2*t10*t16*t29*t5
2851     +          -1.6562500000000002d-2*s3f*t16*t27*t5-1.325d-1*t13*t16
2852     +          *t27*t34+s3c3(D3_RB_GAA_GBB)*t17)*wght+t138+Cmat3(iq,
2853     +          D3_RB_GAA_GBB)
2854              Cmat3(iq,D3_RB_GAB_GAB) = 1.0d+0*t1*(s3c3(D3_RB_GAB_GAB)
2855     +          *t17-1.325d-1*gammabb*t13*t16*t27*t94)*wght+t139+Cmat3
2856     +          (iq,D3_RB_GAB_GAB)
2857              Cmat3(iq,D3_RB_GAB_GBB) = 1.0d+0*t1*(-1.325d-1*gammabb
2858     +          *t13*t16*t27*t95+1.325d-1*t10*t13*t16*t79
2859     +          -1.6562500000000002d-2*gammabb*t16*t36*t58-1.325d-1
2860     +          *t13*t16*t27*t36+s3c3(D3_RB_GAB_GBB)*t17)*wght+t141
2861     +          +t140+Cmat3(iq,D3_RB_GAB_GBB)
2862              Cmat3(iq,D3_RB_GBB_GBB) = 1.0d+0*t1*(2.390625d-2*t11*t27
2863     +          *t6*t9*t96-2.390625d-2*t10*t11*t6*s2c3(D3_RB_GBB_GBB)
2864     +          *t9+2.65d-1*t10*t13*t16*t82-9.5625d-2*gammabb*t10*t11
2865     +          *t6*t81+4.78125d-2*t11*t27*t6*s2f+9.5625d-2*gammabb
2866     +          *t11*t27*t37*t6-4.78125d-2*t10*t11*t28*t6
2867     +          -3.3125000000000004d-2*gammabb*t16*t40*t58
2868     +          -3.3125000000000004d-2*s3f*t16*t58-2.65d-1*t13*t16*t27
2869     +          *t40+1.6562500000000002d-2*t16*t27*t29-1.325d-1
2870     +          *gammabb*t100*t13*t16*t27+s3c3(D3_RB_GBB_GBB)*t17+t145
2871     +          +t144+t143)*wght+t142+Cmat3(iq,D3_RB_GBB_GBB)
2872              Cmat3(iq,D3_GAA_GAA_GAA) = 1.0d+0*t1*(3.975d-1*t13*t16
2873     +          *t5*t88+t5*t6*t7*(-1.434375d-1*gammaaa*t84-2.390625d-2
2874     +          *s1c3(D3_GAA_GAA_GAA)*t4-1.434375d-1*t31)+4.96875d-2
2875     +          *t16*t22*t34+s3c3(D3_GAA_GAA_GAA)*t17)*wght+Cmat3(iq,
2876     +          D3_GAA_GAA_GAA)
2877              Cmat3(iq,D3_GAA_GAA_GAB) = 1.0d+0*t1*(2.65d-1*t13*t16*t5
2878     +          *t90+1.6562500000000002d-2*t16*t22*t36+s3c3
2879     +          (D3_GAA_GAA_GAB)*t17)*wght+Cmat3(iq,D3_GAA_GAA_GAB)
2880              Cmat3(iq,D3_GAA_GAA_GBB) = 1.0d+0*t1*(2.65d-1*t13*t16*t5
2881     +          *t92+1.325d-1*t10*t13*t16*t88+3.3125000000000004d-2
2882     +          *t10*t16*t34*t5+1.6562500000000002d-2*t16*t22*t40+s3c3
2883     +          (D3_GAA_GAA_GBB)*t17)*wght+Cmat3(iq,D3_GAA_GAA_GBB)
2884              Cmat3(iq,D3_GAA_GAB_GAB) = 1.0d+0*t1*(1.325d-1*t13*t16
2885     +          *t5*t94+s3c3(D3_GAA_GAB_GAB)*t17)*wght+Cmat3(iq,
2886     +          D3_GAA_GAB_GAB)
2887              Cmat3(iq,D3_GAA_GAB_GBB) = 1.0d+0*t1*(1.325d-1*t13*t16
2888     +          *t5*t95+1.325d-1*t10*t13*t16*t90+1.6562500000000002d-2
2889     +          *t10*t16*t36*t5+s3c3(D3_GAA_GAB_GBB)*t17)*wght+Cmat3
2890     +          (iq,D3_GAA_GAB_GBB)
2891              Cmat3(iq,D3_GAA_GBB_GBB) = 1.0d+0*t1*(2.65d-1*t10*t13
2892     +          *t16*t92+3.3125000000000004d-2*t10*t16*t40*t5+1.325d-1
2893     +          *t100*t13*t16*t5+1.6562500000000002d-2*t16*t27*t34
2894     +          +s3c3(D3_GAA_GBB_GBB)*t17)*wght+Cmat3(iq,D3_GAA_GBB_GBB)
2895              Cmat3(iq,D3_GAB_GAB_GAB) = 1.0d+0*t1*s3c3(D3_GAB_GAB_GAB
2896     +          )*t17*wght+Cmat3(iq,D3_GAB_GAB_GAB)
2897              Cmat3(iq,D3_GAB_GAB_GBB) = 1.325d-1*t1*t10*t13*t16*t94
2898     +          *wght+1.0d+0*t1*s3c3(D3_GAB_GAB_GBB)*t17*wght+Cmat3
2899     +          (iq,D3_GAB_GAB_GBB)
2900              Cmat3(iq,D3_GAB_GBB_GBB) = 2.65d-1*t1*t10*t13*t16*t95
2901     +          *wght+1.6562500000000002d-2*t1*t16*t27*t36*wght+1.0d+0
2902     +          *t1*s3c3(D3_GAB_GBB_GBB)*t17*wght+Cmat3(iq,
2903     +          D3_GAB_GBB_GBB)
2904              Cmat3(iq,D3_GBB_GBB_GBB) = 1.0d+0*t1*(t10*t11*t6*(
2905     +          -1.434375d-1*gammabb*t96-2.390625d-2*s2c3
2906     +          (D3_GBB_GBB_GBB)*t9-1.434375d-1*t37)+4.96875d-2*t16
2907     +          *t27*t40+s3c3(D3_GBB_GBB_GBB)*t17+3.975d-1*t10*t100
2908     +          *t13*t16)*wght+Cmat3(iq,D3_GBB_GBB_GBB)
2909              Mmat3(iq,D3_RA_RA_TA) = 1.0d+0*t1*(4.78125d-2*t4*t42*t5
2910     +          *t51*t6+9.5625d-2*s1f*t4*t42*t50*t6-9.5625d-2*t22*t23
2911     +          *t4*t42*t6-9.5625d-2*t20*t23*t4*t42*t5+9.5625d-2*t20
2912     +          *t22*s1f*t4*t42+t150+t149+t148+t147+t146)*wght+2.0d+0
2913     +          *t106*wght+Mmat3(iq,D3_RA_RA_TA)
2914              Mmat3(iq,D3_RA_RA_TB) = 1.0d+0*t1*(t151+t150+t149+t148
2915     +          +t147)*wght+2.0d+0*t109*wght+Mmat3(iq,D3_RA_RA_TB)
2916              Mmat3(iq,D3_RA_RB_TA) = 1.0d+0*t1*(-4.78125d-2*t20*t23
2917     +          *t4*t42*t5+4.78125d-2*t20*t22*s1f*t4*t42+t155+t154
2918     +          +t153+t152+t146)*wght+1.0d+0*t112*wght+1.0d+0*t106
2919     +          *wght+Mmat3(iq,D3_RA_RB_TA)
2920              Mmat3(iq,D3_RA_RB_TB) = 1.0d+0*t1*(4.78125d-2*t20*t27
2921     +          *t46*s2f*t9-4.78125d-2*t10*t20*t28*t46*t9+t155+t154
2922     +          +t153+t152+t151)*wght+1.0d+0*t113*wght+1.0d+0*t109
2923     +          *wght+Mmat3(iq,D3_RA_RB_TB)
2924              Mmat3(iq,D3_RB_RB_TA) = 1.0d+0*t1*(t159+t158+t157+t156
2925     +          +t146)*wght+2.0d+0*t112*wght+Mmat3(iq,D3_RB_RB_TA)
2926              Mmat3(iq,D3_RB_RB_TB) = 1.0d+0*t1*(9.5625d-2*t46*t58*t6
2927     +          *s2f*t9+9.5625d-2*t20*t27*t46*s2f*t9+4.78125d-2*t10
2928     +          *t46*t59*t6*t9-9.5625d-2*t27*t28*t46*t6*t9-9.5625d-2
2929     +          *t10*t20*t28*t46*t9+t159+t158+t157+t156+t151)*wght
2930     +          +2.0d+0*t113*wght+Mmat3(iq,D3_RB_RB_TB)
2931              Mmat3(iq,D3_RA_GAA_TA) = 1.0d+0*t1*(4.78125d-2*t4*t42*t5
2932     +          *t6*t66+9.5625d-2*gammaaa*t23*t42*t5*t6-4.78125d-2*t22
2933     +          *t31*t4*t42*t6-9.5625d-2*gammaaa*t22*s1f*t42*t6+t167
2934     +          +t166+t165+t164+t163+t162+t161)*wght+t160+Mmat3(iq,
2935     +          D3_RA_GAA_TA)
2936              Mmat3(iq,D3_RA_GAA_TB) = 1.0d+0*t1*(t167+t166+t165+t164
2937     +          +t163)*wght+t168+Mmat3(iq,D3_RA_GAA_TB)
2938              Mmat3(iq,D3_RA_GAB_TA) = t170+Mmat3(iq,D3_RA_GAB_TA)
2939              Mmat3(iq,D3_RA_GAB_TB) = t170+Mmat3(iq,D3_RA_GAB_TB)
2940              Mmat3(iq,D3_RA_GBB_TA) = 1.0d+0*t1*(t175+t174+t173+t172)
2941     +          *wght+t171+Mmat3(iq,D3_RA_GBB_TA)
2942              Mmat3(iq,D3_RA_GBB_TB) = 1.0d+0*t1*(t178+t177+t175+t174
2943     +          +t173+t172)*wght+t176+Mmat3(iq,D3_RA_GBB_TB)
2944              Mmat3(iq,D3_RB_GAA_TA) = 1.0d+0*t1*(t182+t181+t180+t179
2945     +          +t162+t161)*wght+t160+Mmat3(iq,D3_RB_GAA_TA)
2946              Mmat3(iq,D3_RB_GAA_TB) = 1.0d+0*t1*(t182+t181+t180+t179)
2947     +          *wght+t168+Mmat3(iq,D3_RB_GAA_TB)
2948              Mmat3(iq,D3_RB_GAB_TA) = t183+Mmat3(iq,D3_RB_GAB_TA)
2949              Mmat3(iq,D3_RB_GAB_TB) = t183+Mmat3(iq,D3_RB_GAB_TB)
2950              Mmat3(iq,D3_RB_GBB_TA) = 1.0d+0*t1*(t188+t187+t186+t185
2951     +          +t184)*wght+t171+Mmat3(iq,D3_RB_GBB_TA)
2952              Mmat3(iq,D3_RB_GBB_TB) = 1.0d+0*t1*(4.78125d-2*t10*t46
2953     +          *t6*t81*t9-4.78125d-2*t27*t37*t46*t6*t9-9.5625d-2
2954     +          *gammabb*t27*t46*t6*s2f+9.5625d-2*gammabb*t10*t28*t46
2955     +          *t6+t188+t187+t186+t185+t184+t178+t177)*wght+t176
2956     +          +Mmat3(iq,D3_RB_GBB_TB)
2957              Mmat3(iq,D3_RA_TA_TA) = 1.0d+0*t1*(-2*t42*t5*t6*t85+t191
2958     +          +t190+t189)*wght+Mmat3(iq,D3_RA_TA_TA)
2959              Mmat3(iq,D3_RA_TA_TB) = 1.0d+0*t1*(t191+t190+t189)*wght
2960     +          +Mmat3(iq,D3_RA_TA_TB)
2961              Mmat3(iq,D3_RA_TB_TB) = t192+Mmat3(iq,D3_RA_TB_TB)
2962              Mmat3(iq,D3_RB_TA_TA) = t192+Mmat3(iq,D3_RB_TA_TA)
2963              Mmat3(iq,D3_RB_TA_TB) = t193+Mmat3(iq,D3_RB_TA_TB)
2964              Mmat3(iq,D3_RB_TB_TB) = t193+Mmat3(iq,D3_RB_TB_TB)
2965              Mmat3(iq,D3_GAA_GAA_TA) = t194+Mmat3(iq,D3_GAA_GAA_TA)
2966              Mmat3(iq,D3_GAA_GAA_TB) = t194+Mmat3(iq,D3_GAA_GAA_TB)
2967              Mmat3(iq,D3_GAA_GAB_TA) = t195+Mmat3(iq,D3_GAA_GAB_TA)
2968              Mmat3(iq,D3_GAA_GAB_TB) = t195+Mmat3(iq,D3_GAA_GAB_TB)
2969              Mmat3(iq,D3_GAA_GBB_TA) = 1.0d+0*t1*(t198+t197+t196)
2970     +          *wght+Mmat3(iq,D3_GAA_GBB_TA)
2971              Mmat3(iq,D3_GAA_GBB_TB) = 1.0d+0*t1*(-2*t10*t46*t6*t97
2972     +          +t198+t197+t196)*wght+Mmat3(iq,D3_GAA_GBB_TB)
2973              Mmat3(iq,D3_GAB_GAB_TA) = 1.0d+0*t1*(6*t121*t32*t5*t6
2974     +          +t200+t199)*wght+Mmat3(iq,D3_GAB_GAB_TA)
2975              Mmat3(iq,D3_GAB_GAB_TB) = t201+Mmat3(iq,D3_GAB_GAB_TB)
2976              Mmat3(iq,D3_GAB_GBB_TA) = t201+Mmat3(iq,D3_GAB_GBB_TA)
2977              Mmat3(iq,D3_GAB_GBB_TB) = t202+Mmat3(iq,D3_GAB_GBB_TB)
2978              Mmat3(iq,D3_GBB_GBB_TA) = t202+Mmat3(iq,D3_GBB_GBB_TA)
2979              Mmat3(iq,D3_GBB_GBB_TB) = t202+Mmat3(iq,D3_GBB_GBB_TB)
2980              Mmat3(iq,D3_GAA_TA_TA) = t205+Mmat3(iq,D3_GAA_TA_TA)
2981              Mmat3(iq,D3_GAA_TA_TB) = t205+Mmat3(iq,D3_GAA_TA_TB)
2982              Mmat3(iq,D3_GAA_TB_TB) = 1.0d+0*t1*(6*t10*t124*t38*t6
2983     +          +t204+t203)*wght+Mmat3(iq,D3_GAA_TB_TB)
2984              Mmat3(iq,D3_GAB_TA_TA) = 1.0d+0*t1*(5.7375d-1*s1f*t4*t5
2985     +          *t6/taua**5+t207)*wght+Mmat3(iq,D3_GAB_TA_TA)
2986              Mmat3(iq,D3_GAB_TA_TB) = t208+Mmat3(iq,D3_GAB_TA_TB)
2987              Mmat3(iq,D3_GAB_TB_TB) = t208+Mmat3(iq,D3_GAB_TB_TB)
2988              Mmat3(iq,D3_GBB_TA_TA) = 1.0d+0*t1*(5.7375d-1*t10*t6*s2f
2989     +          *t9/taub**5+t207)*wght+Mmat3(iq,D3_GBB_TA_TA)
2990            elseif (taua.gt.tol_rho.and.taub.le.tol_rho) then
2991              t1 = rhob+rhoa
2992              t2 = param(1)
2993              t3 = 4.0d-50*rhob
2994              sr(R_A) = 0.0d+0
2995              sr(R_B) = rhob
2996              sg(G_AA) = 0.0d+0
2997              sg(G_AB) = 0.0d+0
2998              sg(G_BB) = t3
2999              s1f = 0.0d0
3000              call dcopy(NCOL_AMAT,0.0d0,0,s1a,1)
3001              call dcopy(NCOL_AMAT2,0.0d0,0,s1a2,1)
3002              call dcopy(NCOL_AMAT3,0.0d0,0,s1a3,1)
3003              call dcopy(NCOL_CMAT,0.0d0,0,s1c,1)
3004              call dcopy(NCOL_CMAT2,0.0d0,0,s1c2,1)
3005              call dcopy(NCOL_CMAT3,0.0d0,0,s1c3,1)
3006              call nwxcm_c_mpbe_d3(t2,tol_rho,2,1,1.0d0,sr,sg,s1f,s1a,
3007     +          s1a2,s1a3,s1c,s1c2,s1c3)
3008              t4 = s1f
3009              t5 = 1/t1
3010              sr(R_A) = rhoa
3011              sr(R_B) = 0.0d+0
3012              sg(G_AA) = gammaaa
3013              sg(G_AB) = 0.0d+0
3014              sg(G_BB) = 0.0d+0
3015              s2f = 0.0d0
3016              call dcopy(NCOL_AMAT,0.0d0,0,s2a,1)
3017              call dcopy(NCOL_AMAT2,0.0d0,0,s2a2,1)
3018              call dcopy(NCOL_AMAT3,0.0d0,0,s2a3,1)
3019              call dcopy(NCOL_CMAT,0.0d0,0,s2c,1)
3020              call dcopy(NCOL_CMAT2,0.0d0,0,s2c2,1)
3021              call dcopy(NCOL_CMAT3,0.0d0,0,s2c3,1)
3022              call nwxcm_c_mpbe_d3(t2,tol_rho,2,1,1.0d0,sr,sg,s2f,s2a,
3023     +          s2a2,s2a3,s2c,s2c2,s2c3)
3024              t6 = s2f
3025              t7 = gammaaa**2
3026              t8 = 1/rhoa
3027              t9 = 1/taua**2
3028              sr(R_A) = rhoa
3029              sr(R_B) = rhob
3030              sg(G_AA) = gammaaa
3031              sg(G_AB) = 0
3032              sg(G_BB) = t3
3033              s3f = 0.0d0
3034              call dcopy(NCOL_AMAT,0.0d0,0,s3a,1)
3035              call dcopy(NCOL_AMAT2,0.0d0,0,s3a2,1)
3036              call dcopy(NCOL_AMAT3,0.0d0,0,s3a3,1)
3037              call dcopy(NCOL_CMAT,0.0d0,0,s3c,1)
3038              call dcopy(NCOL_CMAT2,0.0d0,0,s3c2,1)
3039              call dcopy(NCOL_CMAT3,0.0d0,0,s3c3,1)
3040              call nwxcm_c_mpbe_d3(t2,tol_rho,ipol,1,1.0d0,sr,sg,s3f,
3041     +          s3a,s3a2,s3a3,s3c,s3c2,s3c3)
3042              t10 = s3f
3043              t11 = 1.25d-1*gammaaa*t8+5.0d-51
3044              t12 = t11**2
3045              t13 = taua+1.0d-50
3046              t14 = 1/t13**2
3047              t15 = 5.3d-1*t12*t14+1.0d+0
3048              t16 = -2.390625d-2*t5*s2f*t7*t8*t9-3.825d-1*rhob*s1f*t5
3049     +          +s3f*t15
3050              t17 = 1.0d+0*t16*wght
3051              t18 = 1/t1**2
3052              t19 = 3.825d-1*rhob*t18*s1f
3053              t20 = 2.390625d-2*t18*s2f*t7*t8*t9
3054              t21 = 1/rhoa**2
3055              t22 = s2a(D1_RA)
3056              t23 = s3a(D1_RA)
3057              t24 = -2.390625d-2*t22*t5*t7*t8*t9+2.390625d-2*t21*t5
3058     +          *s2f*t7*t9+t15*t23-1.325d-1*gammaaa*s3f*t11*t14*t21
3059     +          +t20+t19
3060              t25 = s1a(D1_RB)
3061              t26 = s3a(D1_RB)
3062              t27 = -3.825d-1*s1f*t5-3.825d-1*rhob*t25*t5+t15*t26+t20
3063     +          +t19
3064              t28 = s2c(D1_GAA)
3065              t29 = -2.390625d-2*t28*t7-4.78125d-2*gammaaa*s2f
3066              t30 = 1.325d-1*s3f*t11*t14*t8
3067              t31 = s3c(D1_GAA)
3068              t32 = t15*t31
3069              t33 = 1/taua**3
3070              t34 = 1/t13**3
3071              t35 = 4.78125d-2*t33*t5*s2f*t7*t8-1.0600000000000001d+0
3072     +          *s3f*t12*t34
3073              t36 = 1/t1**3
3074              t37 = -7.65d-1*rhob*t36*s1f
3075              t38 = -4.78125d-2*t36*s2f*t7*t8*t9
3076              t39 = 1/rhoa**3
3077              t40 = s2a2(D2_RA_RA)
3078              t41 = 1/rhoa**4
3079              t42 = s3a2(D2_RA_RA)
3080              t43 = -2.390625d-2*t40*t5*t7*t8*t9+4.78125d-2*t18*t22*t7
3081     +          *t8*t9-4.78125d-2*t39*t5*s2f*t7*t9-4.78125d-2*t18*t21
3082     +          *s2f*t7*t9+4.78125d-2*t21*t22*t5*t7*t9
3083     +          +1.6562500000000002d-2*s3f*t14*t41*t7+t15*t42+2.65d-1
3084     +          *gammaaa*s3f*t11*t14*t39+t38+t37-2.65d-1*gammaaa*t11
3085     +          *t14*t21*t23
3086              t44 = s3a2(D2_RA_RB)
3087              t45 = 2.390625d-2*t18*t22*t7*t8*t9-2.390625d-2*t18*t21
3088     +          *s2f*t7*t9+t15*t44+3.825d-1*t18*s1f+t38+t37-1.325d-1
3089     +          *gammaaa*t11*t14*t21*t26+3.825d-1*rhob*t18*t25
3090              t46 = s1a2(D2_RB_RB)
3091              t47 = s3a2(D2_RB_RB)
3092              t48 = -3.825d-1*rhob*t46*t5-7.65d-1*t25*t5+t15*t47
3093     +          +7.65d-1*t18*s1f+t38+t37+7.65d-1*rhob*t18*t25
3094              t49 = 1.0d+0*(-2.390625d-2*t28*t5*t7*t8*t9-4.78125d-2
3095     +          *gammaaa*t5*s2f*t8*t9+t32+t30)*wght
3096              t50 = 4.78125d-2*gammaaa*t18*s2f*t8*t9
3097              t51 = 2.390625d-2*t18*t28*t7*t8*t9
3098              t52 = s2c2(D2_RA_GAA)
3099              t53 = s3c2(D2_RA_GAA)
3100              t54 = -2.390625d-2*t5*t52*t7*t8*t9-4.78125d-2*gammaaa
3101     +          *t22*t5*t8*t9+2.390625d-2*t21*t28*t5*t7*t9+4.78125d-2
3102     +          *gammaaa*t21*t5*s2f*t9+1.325d-1*t11*t14*t23*t8+t15*t53
3103     +          +t51+t50-1.6562500000000002d-2*gammaaa*s3f*t14*t39
3104     +          -1.325d-1*gammaaa*t11*t14*t21*t31-1.325d-1*s3f*t11*t14
3105     +          *t21
3106              t55 = s3c2(D2_RB_GAA)
3107              t56 = 1.325d-1*t11*t14*t26*t8+t15*t55+t51+t50
3108              t57 = s2c2(D2_GAA_GAA)
3109              t58 = -2.390625d-2*t57*t7-4.78125d-2*s2f-9.5625d-2
3110     +          *gammaaa*t28
3111              t59 = 1.6562500000000002d-2*s3f*t14*t21
3112              t60 = 2.65d-1*t11*t14*t31*t8
3113              t61 = s3c2(D2_GAA_GAA)
3114              t62 = t15*t61
3115              t63 = 1.0d+0*t35*wght
3116              t64 = -4.78125d-2*t18*t33*s2f*t7*t8
3117              t65 = 4.78125d-2*t22*t33*t5*t7*t8-4.78125d-2*t21*t33*t5
3118     +          *s2f*t7+t64-1.0600000000000001d+0*t12*t23*t34+2.65d-1
3119     +          *gammaaa*s3f*t11*t21*t34
3120              t66 = t64-1.0600000000000001d+0*t12*t26*t34
3121              t67 = -1.0600000000000001d+0*t12*t31*t34
3122              t68 = -2.65d-1*s3f*t11*t34*t8
3123              t69 = 1/taua**4
3124              t70 = 1/t13**4
3125              t71 = 1/t1**4
3126              t72 = 2.2949999999999998d+0*rhob*s1f*t71
3127              t73 = 1.434375d-1*s2f*t7*t71*t8*t9
3128              t74 = 2.0d+0*t45*wght
3129              t75 = -9.5625d-2*gammaaa*t36*s2f*t8*t9
3130              t76 = -4.78125d-2*t28*t36*t7*t8*t9
3131              t77 = 1.0d+0*(-2.390625d-2*t5*t57*t7*t8*t9-4.78125d-2*t5
3132     +          *s2f*t8*t9-9.5625d-2*gammaaa*t28*t5*t8*t9+t62+t60+t59)
3133     +          *wght
3134              t78 = 4.78125d-2*t18*s2f*t8*t9
3135              t79 = 9.5625d-2*gammaaa*t18*t28*t8*t9
3136              t80 = 2.390625d-2*t18*t57*t7*t8*t9
3137              t81 = 9.5625d-2*t33*t36*s2f*t7*t8
3138              t82 = 1.0d+0*(4.78125d-2*t28*t33*t5*t7*t8+9.5625d-2
3139     +          *gammaaa*t33*t5*s2f*t8+t68+t67)*wght
3140              t83 = -9.5625d-2*gammaaa*t18*t33*s2f*t8
3141              t84 = -4.78125d-2*t18*t28*t33*t7*t8
3142              fnc(iq) = 1.0d+0*t1*t16*wght+fnc(iq)
3143              Amat(iq,D1_RA) = 1.0d+0*t1*t24*wght+t17+Amat(iq,D1_RA)
3144              Amat(iq,D1_RB) = 1.0d+0*t1*t27*wght+t17+Amat(iq,D1_RB)
3145              Cmat(iq,D1_GAA) = 1.0d+0*t1*(t29*t5*t8*t9+t32+t30)*wght
3146     +          +Cmat(iq,D1_GAA)
3147              Cmat(iq,D1_GAB) = Cmat(iq,D1_GAB)
3148              Cmat(iq,D1_GBB) = Cmat(iq,D1_GBB)
3149              Mmat(iq,D1_TA) = 1.0d+0*t1*t35*wght+Mmat(iq,D1_TA)
3150              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
3151              Amat2(iq,D2_RA_RA) = 1.0d+0*t1*t43*wght+2.0d+0*t24*wght
3152     +          +Amat2(iq,D2_RA_RA)
3153              Amat2(iq,D2_RA_RB) = 1.0d+0*t1*t45*wght+1.0d+0*t27*wght
3154     +          +1.0d+0*t24*wght+Amat2(iq,D2_RA_RB)
3155              Amat2(iq,D2_RB_RB) = 1.0d+0*t1*t48*wght+2.0d+0*t27*wght
3156     +          +Amat2(iq,D2_RB_RB)
3157              Cmat2(iq,D2_RA_GAA) = 1.0d+0*t1*t54*wght+t49+Cmat2(iq,
3158     +          D2_RA_GAA)
3159              Cmat2(iq,D2_RA_GAB) = Cmat2(iq,D2_RA_GAB)
3160              Cmat2(iq,D2_RA_GBB) = Cmat2(iq,D2_RA_GBB)
3161              Cmat2(iq,D2_RB_GAA) = 1.0d+0*t1*t56*wght+t49+Cmat2(iq,
3162     +          D2_RB_GAA)
3163              Cmat2(iq,D2_RB_GAB) = Cmat2(iq,D2_RB_GAB)
3164              Cmat2(iq,D2_RB_GBB) = Cmat2(iq,D2_RB_GBB)
3165              Cmat2(iq,D2_GAA_GAA) = 1.0d+0*t1*(t5*t58*t8*t9+t62+t60
3166     +          +t59)*wght+Cmat2(iq,D2_GAA_GAA)
3167              Cmat2(iq,D2_GAA_GAB) = Cmat2(iq,D2_GAA_GAB)
3168              Cmat2(iq,D2_GAA_GBB) = Cmat2(iq,D2_GAA_GBB)
3169              Cmat2(iq,D2_GAB_GAB) = Cmat2(iq,D2_GAB_GAB)
3170              Cmat2(iq,D2_GAB_GBB) = Cmat2(iq,D2_GAB_GBB)
3171              Cmat2(iq,D2_GBB_GBB) = Cmat2(iq,D2_GBB_GBB)
3172              Mmat2(iq,D2_RA_TA) = 1.0d+0*t1*t65*wght+t63+Mmat2(iq,
3173     +          D2_RA_TA)
3174              Mmat2(iq,D2_RA_TB) = Mmat2(iq,D2_RA_TB)
3175              Mmat2(iq,D2_RB_TA) = 1.0d+0*t1*t66*wght+t63+Mmat2(iq,
3176     +          D2_RB_TA)
3177              Mmat2(iq,D2_RB_TB) = Mmat2(iq,D2_RB_TB)
3178              Mmat2(iq,D2_GAA_TA) = 1.0d+0*t1*(-2*t29*t33*t5*t8+t68
3179     +          +t67)*wght+Mmat2(iq,D2_GAA_TA)
3180              Mmat2(iq,D2_GAA_TB) = Mmat2(iq,D2_GAA_TB)
3181              Mmat2(iq,D2_GAB_TA) = Mmat2(iq,D2_GAB_TA)
3182              Mmat2(iq,D2_GAB_TB) = Mmat2(iq,D2_GAB_TB)
3183              Mmat2(iq,D2_GBB_TA) = Mmat2(iq,D2_GBB_TA)
3184              Mmat2(iq,D2_GBB_TB) = Mmat2(iq,D2_GBB_TB)
3185              Mmat2(iq,D2_TA_TA) = 1.0d+0*t1*(3.18d+0*s3f*t12*t70
3186     +          -1.434375d-1*t5*s2f*t69*t7*t8)*wght+Mmat2(iq,D2_TA_TA)
3187              Mmat2(iq,D2_TA_TB) = Mmat2(iq,D2_TA_TB)
3188              Mmat2(iq,D2_TB_TB) = Mmat2(iq,D2_TB_TB)
3189              Amat3(iq,D3_RA_RA_RA) = 1.0d+0*t1*(-2.390625d-2*t5*s2a3
3190     +          (D3_RA_RA_RA)*t7*t8*t9+7.171875d-2*t18*t40*t7*t8*t9
3191     +          -1.434375d-1*t22*t36*t7*t8*t9+1.434375d-1*t41*t5*s2f
3192     +          *t7*t9+1.434375d-1*t18*t39*s2f*t7*t9+1.434375d-1*t21
3193     +          *t36*s2f*t7*t9+7.171875d-2*t21*t40*t5*t7*t9
3194     +          -1.434375d-1*t22*t39*t5*t7*t9-1.434375d-1*t18*t21*t22
3195     +          *t7*t9+t73+t72+4.96875d-2*t14*t23*t41*t7-9.9375d-2*s3f
3196     +          *t14*t7/rhoa**5-3.975d-1*gammaaa*t11*t14*t21*t42
3197     +          -7.95d-1*gammaaa*s3f*t11*t14*t41+7.95d-1*gammaaa*t11
3198     +          *t14*t23*t39+s3a3(D3_RA_RA_RA)*t15)*wght+3.0d+0*t43
3199     +          *wght+Amat3(iq,D3_RA_RA_RA)
3200              Amat3(iq,D3_RA_RA_RB) = 1.0d+0*t1*(2.390625d-2*t18*t40
3201     +          *t7*t8*t9-9.5625d-2*t22*t36*t7*t8*t9+4.78125d-2*t18
3202     +          *t39*s2f*t7*t9+9.5625d-2*t21*t36*s2f*t7*t9-4.78125d-2
3203     +          *t18*t21*t22*t7*t9+t73+t72+1.6562500000000002d-2*t14
3204     +          *t26*t41*t7-2.65d-1*gammaaa*t11*t14*t21*t44-7.65d-1
3205     +          *t36*s1f+2.65d-1*gammaaa*t11*t14*t26*t39-7.65d-1*rhob
3206     +          *t25*t36+s3a3(D3_RA_RA_RB)*t15)*wght+1.0d+0*t43*wght
3207     +          +t74+Amat3(iq,D3_RA_RA_RB)
3208              Amat3(iq,D3_RA_RB_RB) = 1.0d+0*t1*(-4.78125d-2*t22*t36
3209     +          *t7*t8*t9+4.78125d-2*t21*t36*s2f*t7*t9+t73+t72
3210     +          -1.325d-1*gammaaa*t11*t14*t21*t47+3.825d-1*rhob*t18
3211     +          *t46-1.53d+0*t36*s1f-1.53d+0*rhob*t25*t36+7.65d-1*t18
3212     +          *t25+s3a3(D3_RA_RB_RB)*t15)*wght+1.0d+0*t48*wght+t74
3213     +          +Amat3(iq,D3_RA_RB_RB)
3214              Amat3(iq,D3_RB_RB_RB) = 1.0d+0*t1*(t73+t72
3215     +          -1.1474999999999999d+0*t46*t5-3.825d-1*rhob*s1a3
3216     +          (D3_RB_RB_RB)*t5+1.1474999999999999d+0*rhob*t18*t46
3217     +          -2.2949999999999998d+0*t36*s1f-2.2949999999999998d+0
3218     +          *rhob*t25*t36+2.2949999999999998d+0*t18*t25+s3a3
3219     +          (D3_RB_RB_RB)*t15)*wght+3.0d+0*t48*wght+Amat3(iq,
3220     +          D3_RB_RB_RB)
3221              Cmat3(iq,D3_RA_RA_GAA) = 1.0d+0*t1*(-2.390625d-2*t5*s2c3
3222     +          (D3_RA_RA_GAA)*t7*t8*t9+4.78125d-2*t18*t52*t7*t8*t9
3223     +          -4.78125d-2*gammaaa*t40*t5*t8*t9+9.5625d-2*gammaaa*t18
3224     +          *t22*t8*t9+4.78125d-2*t21*t5*t52*t7*t9-4.78125d-2*t28
3225     +          *t39*t5*t7*t9-4.78125d-2*t18*t21*t28*t7*t9-9.5625d-2
3226     +          *gammaaa*t39*t5*s2f*t9-9.5625d-2*gammaaa*t18*t21*s2f
3227     +          *t9+9.5625d-2*gammaaa*t21*t22*t5*t9+1.325d-1*t11*t14
3228     +          *t42*t8+t76+t75+1.6562500000000002d-2*t14*t31*t41*t7
3229     +          -2.65d-1*gammaaa*t11*t14*t21*t53+6.625000000000001d-2
3230     +          *gammaaa*s3f*t14*t41+2.65d-1*gammaaa*t11*t14*t31*t39
3231     +          -3.3125000000000004d-2*gammaaa*t14*t23*t39+2.65d-1*s3f
3232     +          *t11*t14*t39-2.65d-1*t11*t14*t21*t23+s3c3(D3_RA_RA_GAA
3233     +          )*t15)*wght+2.0d+0*t54*wght+Cmat3(iq,D3_RA_RA_GAA)
3234              Cmat3(iq,D3_RA_RA_GAB) = Cmat3(iq,D3_RA_RA_GAB)
3235              Cmat3(iq,D3_RA_RA_GBB) = Cmat3(iq,D3_RA_RA_GBB)
3236              Cmat3(iq,D3_RA_RB_GAA) = 1.0d+0*t1*(2.390625d-2*t18*t52
3237     +          *t7*t8*t9+4.78125d-2*gammaaa*t18*t22*t8*t9-2.390625d-2
3238     +          *t18*t21*t28*t7*t9-4.78125d-2*gammaaa*t18*t21*s2f*t9
3239     +          +1.325d-1*t11*t14*t44*t8+t76+t75-1.325d-1*gammaaa*t11
3240     +          *t14*t21*t55-1.6562500000000002d-2*gammaaa*t14*t26*t39
3241     +          -1.325d-1*t11*t14*t21*t26+s3c3(D3_RA_RB_GAA)*t15)*wght
3242     +          +1.0d+0*t56*wght+1.0d+0*t54*wght+Cmat3(iq,D3_RA_RB_GAA)
3243              Cmat3(iq,D3_RA_RB_GAB) = Cmat3(iq,D3_RA_RB_GAB)
3244              Cmat3(iq,D3_RA_RB_GBB) = Cmat3(iq,D3_RA_RB_GBB)
3245              Cmat3(iq,D3_RB_RB_GAA) = 1.0d+0*t1*(1.325d-1*t11*t14*t47
3246     +          *t8+t76+t75+s3c3(D3_RB_RB_GAA)*t15)*wght+2.0d+0*t56
3247     +          *wght+Cmat3(iq,D3_RB_RB_GAA)
3248              Cmat3(iq,D3_RB_RB_GAB) = Cmat3(iq,D3_RB_RB_GAB)
3249              Cmat3(iq,D3_RB_RB_GBB) = Cmat3(iq,D3_RB_RB_GBB)
3250              Cmat3(iq,D3_RA_GAA_GAA) = 1.0d+0*t1*(-2.390625d-2*t5
3251     +          *s2c3(D3_RA_GAA_GAA)*t7*t8*t9-9.5625d-2*gammaaa*t5*t52
3252     +          *t8*t9-4.78125d-2*t22*t5*t8*t9+2.390625d-2*t21*t5*t57
3253     +          *t7*t9+4.78125d-2*t21*t5*s2f*t9+9.5625d-2*gammaaa*t21
3254     +          *t28*t5*t9+t80+2.65d-1*t11*t14*t53*t8+t79+t78-1.325d-1
3255     +          *gammaaa*t11*t14*t21*t61-3.3125000000000004d-2*gammaaa
3256     +          *t14*t31*t39-3.3125000000000004d-2*s3f*t14*t39-2.65d-1
3257     +          *t11*t14*t21*t31+1.6562500000000002d-2*t14*t21*t23
3258     +          +s3c3(D3_RA_GAA_GAA)*t15)*wght+t77+Cmat3(iq,
3259     +          D3_RA_GAA_GAA)
3260              Cmat3(iq,D3_RA_GAA_GAB) = Cmat3(iq,D3_RA_GAA_GAB)
3261              Cmat3(iq,D3_RA_GAA_GBB) = Cmat3(iq,D3_RA_GAA_GBB)
3262              Cmat3(iq,D3_RA_GAB_GAB) = Cmat3(iq,D3_RA_GAB_GAB)
3263              Cmat3(iq,D3_RA_GAB_GBB) = Cmat3(iq,D3_RA_GAB_GBB)
3264              Cmat3(iq,D3_RA_GBB_GBB) = Cmat3(iq,D3_RA_GBB_GBB)
3265              Cmat3(iq,D3_RB_GAA_GAA) = 1.0d+0*t1*(t80+2.65d-1*t11*t14
3266     +          *t55*t8+t79+t78+1.6562500000000002d-2*t14*t21*t26+s3c3
3267     +          (D3_RB_GAA_GAA)*t15)*wght+t77+Cmat3(iq,D3_RB_GAA_GAA)
3268              Cmat3(iq,D3_RB_GAA_GAB) = Cmat3(iq,D3_RB_GAA_GAB)
3269              Cmat3(iq,D3_RB_GAA_GBB) = Cmat3(iq,D3_RB_GAA_GBB)
3270              Cmat3(iq,D3_RB_GAB_GAB) = Cmat3(iq,D3_RB_GAB_GAB)
3271              Cmat3(iq,D3_RB_GAB_GBB) = Cmat3(iq,D3_RB_GAB_GBB)
3272              Cmat3(iq,D3_RB_GBB_GBB) = Cmat3(iq,D3_RB_GBB_GBB)
3273              Cmat3(iq,D3_GAA_GAA_GAA) = 1.0d+0*t1*(t5*(-2.390625d-2
3274     +          *s2c3(D3_GAA_GAA_GAA)*t7-1.434375d-1*gammaaa*t57
3275     +          -1.434375d-1*t28)*t8*t9+3.975d-1*t11*t14*t61*t8
3276     +          +4.96875d-2*t14*t21*t31+s3c3(D3_GAA_GAA_GAA)*t15)*wght
3277     +          +Cmat3(iq,D3_GAA_GAA_GAA)
3278              Cmat3(iq,D3_GAA_GAA_GAB) = Cmat3(iq,D3_GAA_GAA_GAB)
3279              Cmat3(iq,D3_GAA_GAA_GBB) = Cmat3(iq,D3_GAA_GAA_GBB)
3280              Cmat3(iq,D3_GAA_GAB_GAB) = Cmat3(iq,D3_GAA_GAB_GAB)
3281              Cmat3(iq,D3_GAA_GAB_GBB) = Cmat3(iq,D3_GAA_GAB_GBB)
3282              Cmat3(iq,D3_GAA_GBB_GBB) = Cmat3(iq,D3_GAA_GBB_GBB)
3283              Cmat3(iq,D3_GAB_GAB_GAB) = Cmat3(iq,D3_GAB_GAB_GAB)
3284              Cmat3(iq,D3_GAB_GAB_GBB) = Cmat3(iq,D3_GAB_GAB_GBB)
3285              Cmat3(iq,D3_GAB_GBB_GBB) = Cmat3(iq,D3_GAB_GBB_GBB)
3286              Cmat3(iq,D3_GBB_GBB_GBB) = Cmat3(iq,D3_GBB_GBB_GBB)
3287              Mmat3(iq,D3_RA_RA_TA) = 1.0d+0*t1*(t81+4.78125d-2*t33
3288     +          *t40*t5*t7*t8-9.5625d-2*t18*t22*t33*t7*t8+9.5625d-2
3289     +          *t33*t39*t5*s2f*t7+9.5625d-2*t18*t21*t33*s2f*t7
3290     +          -9.5625d-2*t21*t22*t33*t5*t7-3.3125000000000004d-2*s3f
3291     +          *t34*t41*t7-1.0600000000000001d+0*t12*t34*t42-5.3d-1
3292     +          *gammaaa*s3f*t11*t34*t39+5.3d-1*gammaaa*t11*t21*t23
3293     +          *t34)*wght+2.0d+0*t65*wght+Mmat3(iq,D3_RA_RA_TA)
3294              Mmat3(iq,D3_RA_RA_TB) = Mmat3(iq,D3_RA_RA_TB)
3295              Mmat3(iq,D3_RA_RB_TA) = 1.0d+0*t1*(t81-4.78125d-2*t18
3296     +          *t22*t33*t7*t8+4.78125d-2*t18*t21*t33*s2f*t7
3297     +          -1.0600000000000001d+0*t12*t34*t44+2.65d-1*gammaaa*t11
3298     +          *t21*t26*t34)*wght+1.0d+0*t66*wght+1.0d+0*t65*wght
3299     +          +Mmat3(iq,D3_RA_RB_TA)
3300              Mmat3(iq,D3_RA_RB_TB) = Mmat3(iq,D3_RA_RB_TB)
3301              Mmat3(iq,D3_RB_RB_TA) = 1.0d+0*t1*(t81
3302     +          -1.0600000000000001d+0*t12*t34*t47)*wght+2.0d+0*t66
3303     +          *wght+Mmat3(iq,D3_RB_RB_TA)
3304              Mmat3(iq,D3_RB_RB_TB) = Mmat3(iq,D3_RB_RB_TB)
3305              Mmat3(iq,D3_RA_GAA_TA) = 1.0d+0*t1*(t84+t83+4.78125d-2
3306     +          *t33*t5*t52*t7*t8+9.5625d-2*gammaaa*t22*t33*t5*t8
3307     +          -2.65d-1*t11*t23*t34*t8-4.78125d-2*t21*t28*t33*t5*t7
3308     +          -9.5625d-2*gammaaa*t21*t33*t5*s2f
3309     +          -1.0600000000000001d+0*t12*t34*t53
3310     +          +3.3125000000000004d-2*gammaaa*s3f*t34*t39+2.65d-1
3311     +          *gammaaa*t11*t21*t31*t34+2.65d-1*s3f*t11*t21*t34)*wght
3312     +          +t82+Mmat3(iq,D3_RA_GAA_TA)
3313              Mmat3(iq,D3_RA_GAA_TB) = Mmat3(iq,D3_RA_GAA_TB)
3314              Mmat3(iq,D3_RA_GAB_TA) = Mmat3(iq,D3_RA_GAB_TA)
3315              Mmat3(iq,D3_RA_GAB_TB) = Mmat3(iq,D3_RA_GAB_TB)
3316              Mmat3(iq,D3_RA_GBB_TA) = Mmat3(iq,D3_RA_GBB_TA)
3317              Mmat3(iq,D3_RA_GBB_TB) = Mmat3(iq,D3_RA_GBB_TB)
3318              Mmat3(iq,D3_RB_GAA_TA) = 1.0d+0*t1*(t84+t83-2.65d-1*t11
3319     +          *t26*t34*t8-1.0600000000000001d+0*t12*t34*t55)*wght
3320     +          +t82+Mmat3(iq,D3_RB_GAA_TA)
3321              Mmat3(iq,D3_RB_GAA_TB) = Mmat3(iq,D3_RB_GAA_TB)
3322              Mmat3(iq,D3_RB_GAB_TA) = Mmat3(iq,D3_RB_GAB_TA)
3323              Mmat3(iq,D3_RB_GAB_TB) = Mmat3(iq,D3_RB_GAB_TB)
3324              Mmat3(iq,D3_RB_GBB_TA) = Mmat3(iq,D3_RB_GBB_TA)
3325              Mmat3(iq,D3_RB_GBB_TB) = Mmat3(iq,D3_RB_GBB_TB)
3326              Mmat3(iq,D3_RA_TA_TA) = 1.0d+0*t1*(-2*t33*t5*t58*t8
3327     +          -5.3d-1*t11*t31*t34*t8-1.0600000000000001d+0*t12*t34
3328     +          *t61-3.3125000000000004d-2*s3f*t21*t34)*wght+Mmat3(iq,
3329     +          D3_RA_TA_TA)
3330              Mmat3(iq,D3_RA_TA_TB) = Mmat3(iq,D3_RA_TA_TB)
3331              Mmat3(iq,D3_RA_TB_TB) = Mmat3(iq,D3_RA_TB_TB)
3332              Mmat3(iq,D3_RB_TA_TA) = Mmat3(iq,D3_RB_TA_TA)
3333              Mmat3(iq,D3_RB_TA_TB) = Mmat3(iq,D3_RB_TA_TB)
3334              Mmat3(iq,D3_RB_TB_TB) = Mmat3(iq,D3_RB_TB_TB)
3335              Mmat3(iq,D3_GAA_GAA_TA) = Mmat3(iq,D3_GAA_GAA_TA)
3336              Mmat3(iq,D3_GAA_GAA_TB) = Mmat3(iq,D3_GAA_GAA_TB)
3337              Mmat3(iq,D3_GAA_GAB_TA) = Mmat3(iq,D3_GAA_GAB_TA)
3338              Mmat3(iq,D3_GAA_GAB_TB) = Mmat3(iq,D3_GAA_GAB_TB)
3339              Mmat3(iq,D3_GAA_GBB_TA) = Mmat3(iq,D3_GAA_GBB_TA)
3340              Mmat3(iq,D3_GAA_GBB_TB) = Mmat3(iq,D3_GAA_GBB_TB)
3341              Mmat3(iq,D3_GAB_GAB_TA) = 1.0d+0*t1*(7.95d-1*s3f*t11*t70
3342     +          *t8+6*t29*t5*t69*t8+3.18d+0*t12*t31*t70)*wght+Mmat3
3343     +          (iq,D3_GAB_GAB_TA)
3344              Mmat3(iq,D3_GAB_GAB_TB) = Mmat3(iq,D3_GAB_GAB_TB)
3345              Mmat3(iq,D3_GAB_GBB_TA) = Mmat3(iq,D3_GAB_GBB_TA)
3346              Mmat3(iq,D3_GAB_GBB_TB) = Mmat3(iq,D3_GAB_GBB_TB)
3347              Mmat3(iq,D3_GBB_GBB_TA) = Mmat3(iq,D3_GBB_GBB_TA)
3348              Mmat3(iq,D3_GBB_GBB_TB) = Mmat3(iq,D3_GBB_GBB_TB)
3349              Mmat3(iq,D3_GAA_TA_TA) = Mmat3(iq,D3_GAA_TA_TA)
3350              Mmat3(iq,D3_GAA_TA_TB) = Mmat3(iq,D3_GAA_TA_TB)
3351              Mmat3(iq,D3_GAA_TB_TB) = Mmat3(iq,D3_GAA_TB_TB)
3352              Mmat3(iq,D3_GAB_TA_TA) = 1.0d+0*t1*(5.7375d-1*t5*s2f*t7
3353     +          *t8/taua**5-1.272d+1*s3f*t12/t13**5)*wght+Mmat3(iq,
3354     +          D3_GAB_TA_TA)
3355              Mmat3(iq,D3_GAB_TA_TB) = Mmat3(iq,D3_GAB_TA_TB)
3356              Mmat3(iq,D3_GAB_TB_TB) = Mmat3(iq,D3_GAB_TB_TB)
3357              Mmat3(iq,D3_GBB_TA_TA) = Mmat3(iq,D3_GBB_TA_TA)
3358            elseif (taua.le.tol_rho.and.taub.gt.tol_rho) then
3359              t1 = rhob+rhoa
3360              t2 = param(1)
3361              t3 = 4.0d-50*rhoa
3362              sr(R_A) = rhoa
3363              sr(R_B) = 0.0d+0
3364              sg(G_AA) = t3
3365              sg(G_AB) = 0.0d+0
3366              sg(G_BB) = 0.0d+0
3367              s1f = 0.0d0
3368              call dcopy(NCOL_AMAT,0.0d0,0,s1a,1)
3369              call dcopy(NCOL_AMAT2,0.0d0,0,s1a2,1)
3370              call dcopy(NCOL_AMAT3,0.0d0,0,s1a3,1)
3371              call dcopy(NCOL_CMAT,0.0d0,0,s1c,1)
3372              call dcopy(NCOL_CMAT2,0.0d0,0,s1c2,1)
3373              call dcopy(NCOL_CMAT3,0.0d0,0,s1c3,1)
3374              call nwxcm_c_mpbe_d3(t2,tol_rho,2,1,1.0d0,sr,sg,s1f,s1a,
3375     +          s1a2,s1a3,s1c,s1c2,s1c3)
3376              t4 = s1f
3377              t5 = 1/t1
3378              sr(R_A) = 0.0d+0
3379              sr(R_B) = rhob
3380              sg(G_AA) = 0.0d+0
3381              sg(G_AB) = 0.0d+0
3382              sg(G_BB) = gammabb
3383              s2f = 0.0d0
3384              call dcopy(NCOL_AMAT,0.0d0,0,s2a,1)
3385              call dcopy(NCOL_AMAT2,0.0d0,0,s2a2,1)
3386              call dcopy(NCOL_AMAT3,0.0d0,0,s2a3,1)
3387              call dcopy(NCOL_CMAT,0.0d0,0,s2c,1)
3388              call dcopy(NCOL_CMAT2,0.0d0,0,s2c2,1)
3389              call dcopy(NCOL_CMAT3,0.0d0,0,s2c3,1)
3390              call nwxcm_c_mpbe_d3(t2,tol_rho,2,1,1.0d0,sr,sg,s2f,s2a,
3391     +          s2a2,s2a3,s2c,s2c2,s2c3)
3392              t6 = s2f
3393              t7 = gammabb**2
3394              t8 = 1/rhob
3395              t9 = 1/taub**2
3396              sr(R_A) = rhoa
3397              sr(R_B) = rhob
3398              sg(G_AA) = t3
3399              sg(G_AB) = 0
3400              sg(G_BB) = gammabb
3401              s3f = 0.0d0
3402              call dcopy(NCOL_AMAT,0.0d0,0,s3a,1)
3403              call dcopy(NCOL_AMAT2,0.0d0,0,s3a2,1)
3404              call dcopy(NCOL_AMAT3,0.0d0,0,s3a3,1)
3405              call dcopy(NCOL_CMAT,0.0d0,0,s3c,1)
3406              call dcopy(NCOL_CMAT2,0.0d0,0,s3c2,1)
3407              call dcopy(NCOL_CMAT3,0.0d0,0,s3c3,1)
3408              call nwxcm_c_mpbe_d3(t2,tol_rho,ipol,1,1.0d0,sr,sg,s3f,
3409     +          s3a,s3a2,s3a3,s3c,s3c2,s3c3)
3410              t10 = s3f
3411              t11 = 1.25d-1*gammabb*t8+5.0d-51
3412              t12 = t11**2
3413              t13 = taub+1.0d-50
3414              t14 = 1/t13**2
3415              t15 = 5.3d-1*t12*t14+1.0d+0
3416              t16 = -2.390625d-2*t5*s2f*t7*t8*t9-3.825d-1*rhoa*s1f*t5
3417     +          +s3f*t15
3418              t17 = 1.0d+0*t16*wght
3419              t18 = 1/t1**2
3420              t19 = 3.825d-1*rhoa*t18*s1f
3421              t20 = s1a(D1_RA)
3422              t21 = 2.390625d-2*t18*s2f*t7*t8*t9
3423              t22 = s3a(D1_RA)
3424              t23 = -3.825d-1*s1f*t5-3.825d-1*rhoa*t20*t5+t15*t22+t21
3425     +          +t19
3426              t24 = 1/rhob**2
3427              t25 = s2a(D1_RB)
3428              t26 = s3a(D1_RB)
3429              t27 = -2.390625d-2*t25*t5*t7*t8*t9+2.390625d-2*t24*t5
3430     +          *s2f*t7*t9+t15*t26-1.325d-1*gammabb*s3f*t11*t14*t24
3431     +          +t21+t19
3432              t28 = s2c(D1_GBB)
3433              t29 = -2.390625d-2*t28*t7-4.78125d-2*gammabb*s2f
3434              t30 = 1.325d-1*s3f*t11*t14*t8
3435              t31 = s3c(D1_GBB)
3436              t32 = t15*t31
3437              t33 = 1/taub**3
3438              t34 = 1/t13**3
3439              t35 = 4.78125d-2*t33*t5*s2f*t7*t8-1.0600000000000001d+0
3440     +          *s3f*t12*t34
3441              t36 = 1/t1**3
3442              t37 = -7.65d-1*rhoa*t36*s1f
3443              t38 = s1a2(D2_RA_RA)
3444              t39 = -4.78125d-2*t36*s2f*t7*t8*t9
3445              t40 = s3a2(D2_RA_RA)
3446              t41 = -3.825d-1*rhoa*t38*t5-7.65d-1*t20*t5+t15*t40
3447     +          +7.65d-1*t18*s1f+t39+t37+7.65d-1*rhoa*t18*t20
3448              t42 = s3a2(D2_RA_RB)
3449              t43 = 2.390625d-2*t18*t25*t7*t8*t9-2.390625d-2*t18*t24
3450     +          *s2f*t7*t9+t15*t42+3.825d-1*t18*s1f+t39+t37-1.325d-1
3451     +          *gammabb*t11*t14*t22*t24+3.825d-1*rhoa*t18*t20
3452              t44 = 1/rhob**3
3453              t45 = s2a2(D2_RB_RB)
3454              t46 = 1/rhob**4
3455              t47 = s3a2(D2_RB_RB)
3456              t48 = -2.390625d-2*t45*t5*t7*t8*t9+4.78125d-2*t18*t25*t7
3457     +          *t8*t9-4.78125d-2*t44*t5*s2f*t7*t9-4.78125d-2*t18*t24
3458     +          *s2f*t7*t9+4.78125d-2*t24*t25*t5*t7*t9
3459     +          +1.6562500000000002d-2*s3f*t14*t46*t7+t15*t47+2.65d-1
3460     +          *gammabb*s3f*t11*t14*t44+t39+t37-2.65d-1*gammabb*t11
3461     +          *t14*t24*t26
3462              t49 = 1.0d+0*(-2.390625d-2*t28*t5*t7*t8*t9-4.78125d-2
3463     +          *gammabb*t5*s2f*t8*t9+t32+t30)*wght
3464              t50 = 4.78125d-2*gammabb*t18*s2f*t8*t9
3465              t51 = 2.390625d-2*t18*t28*t7*t8*t9
3466              t52 = s3c2(D2_RA_GBB)
3467              t53 = 1.325d-1*t11*t14*t22*t8+t15*t52+t51+t50
3468              t54 = s2c2(D2_RB_GBB)
3469              t55 = s3c2(D2_RB_GBB)
3470              t56 = -2.390625d-2*t5*t54*t7*t8*t9-4.78125d-2*gammabb
3471     +          *t25*t5*t8*t9+2.390625d-2*t24*t28*t5*t7*t9+4.78125d-2
3472     +          *gammabb*t24*t5*s2f*t9+1.325d-1*t11*t14*t26*t8+t15*t55
3473     +          +t51+t50-1.6562500000000002d-2*gammabb*s3f*t14*t44
3474     +          -1.325d-1*gammabb*t11*t14*t24*t31-1.325d-1*s3f*t11*t14
3475     +          *t24
3476              t57 = s2c2(D2_GBB_GBB)
3477              t58 = -2.390625d-2*t57*t7-4.78125d-2*s2f-9.5625d-2
3478     +          *gammabb*t28
3479              t59 = 1.6562500000000002d-2*s3f*t14*t24
3480              t60 = 2.65d-1*t11*t14*t31*t8
3481              t61 = s3c2(D2_GBB_GBB)
3482              t62 = t15*t61
3483              t63 = 1.0d+0*t35*wght
3484              t64 = -4.78125d-2*t18*t33*s2f*t7*t8
3485              t65 = t64-1.0600000000000001d+0*t12*t22*t34
3486              t66 = 4.78125d-2*t25*t33*t5*t7*t8-4.78125d-2*t24*t33*t5
3487     +          *s2f*t7+t64-1.0600000000000001d+0*t12*t26*t34+2.65d-1
3488     +          *gammabb*s3f*t11*t24*t34
3489              t67 = -1.0600000000000001d+0*t12*t31*t34
3490              t68 = -2.65d-1*s3f*t11*t34*t8
3491              t69 = 1/taub**4
3492              t70 = 1/t13**4
3493              t71 = 1/t1**4
3494              t72 = 2.2949999999999998d+0*rhoa*s1f*t71
3495              t73 = 1.434375d-1*s2f*t7*t71*t8*t9
3496              t74 = 2.0d+0*t43*wght
3497              t75 = -9.5625d-2*gammabb*t36*s2f*t8*t9
3498              t76 = -4.78125d-2*t28*t36*t7*t8*t9
3499              t77 = 1.0d+0*(-2.390625d-2*t5*t57*t7*t8*t9-4.78125d-2*t5
3500     +          *s2f*t8*t9-9.5625d-2*gammabb*t28*t5*t8*t9+t62+t60+t59)
3501     +          *wght
3502              t78 = 4.78125d-2*t18*s2f*t8*t9
3503              t79 = 9.5625d-2*gammabb*t18*t28*t8*t9
3504              t80 = 2.390625d-2*t18*t57*t7*t8*t9
3505              t81 = 9.5625d-2*t33*t36*s2f*t7*t8
3506              t82 = 1.0d+0*(4.78125d-2*t28*t33*t5*t7*t8+9.5625d-2
3507     +          *gammabb*t33*t5*s2f*t8+t68+t67)*wght
3508              t83 = -9.5625d-2*gammabb*t18*t33*s2f*t8
3509              t84 = -4.78125d-2*t18*t28*t33*t7*t8
3510              fnc(iq) = 1.0d+0*t1*t16*wght+fnc(iq)
3511              Amat(iq,D1_RA) = 1.0d+0*t1*t23*wght+t17+Amat(iq,D1_RA)
3512              Amat(iq,D1_RB) = 1.0d+0*t1*t27*wght+t17+Amat(iq,D1_RB)
3513              Cmat(iq,D1_GAA) = Cmat(iq,D1_GAA)
3514              Cmat(iq,D1_GAB) = Cmat(iq,D1_GAB)
3515              Cmat(iq,D1_GBB) = 1.0d+0*t1*(t29*t5*t8*t9+t32+t30)*wght
3516     +          +Cmat(iq,D1_GBB)
3517              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
3518              Mmat(iq,D1_TB) = 1.0d+0*t1*t35*wght+Mmat(iq,D1_TB)
3519              Amat2(iq,D2_RA_RA) = 1.0d+0*t1*t41*wght+2.0d+0*t23*wght
3520     +          +Amat2(iq,D2_RA_RA)
3521              Amat2(iq,D2_RA_RB) = 1.0d+0*t1*t43*wght+1.0d+0*t27*wght
3522     +          +1.0d+0*t23*wght+Amat2(iq,D2_RA_RB)
3523              Amat2(iq,D2_RB_RB) = 1.0d+0*t1*t48*wght+2.0d+0*t27*wght
3524     +          +Amat2(iq,D2_RB_RB)
3525              Cmat2(iq,D2_RA_GAA) = Cmat2(iq,D2_RA_GAA)
3526              Cmat2(iq,D2_RA_GAB) = Cmat2(iq,D2_RA_GAB)
3527              Cmat2(iq,D2_RA_GBB) = 1.0d+0*t1*t53*wght+t49+Cmat2(iq,
3528     +          D2_RA_GBB)
3529              Cmat2(iq,D2_RB_GAA) = Cmat2(iq,D2_RB_GAA)
3530              Cmat2(iq,D2_RB_GAB) = Cmat2(iq,D2_RB_GAB)
3531              Cmat2(iq,D2_RB_GBB) = 1.0d+0*t1*t56*wght+t49+Cmat2(iq,
3532     +          D2_RB_GBB)
3533              Cmat2(iq,D2_GAA_GAA) = Cmat2(iq,D2_GAA_GAA)
3534              Cmat2(iq,D2_GAA_GAB) = Cmat2(iq,D2_GAA_GAB)
3535              Cmat2(iq,D2_GAA_GBB) = Cmat2(iq,D2_GAA_GBB)
3536              Cmat2(iq,D2_GAB_GAB) = Cmat2(iq,D2_GAB_GAB)
3537              Cmat2(iq,D2_GAB_GBB) = Cmat2(iq,D2_GAB_GBB)
3538              Cmat2(iq,D2_GBB_GBB) = 1.0d+0*t1*(t5*t58*t8*t9+t62+t60
3539     +          +t59)*wght+Cmat2(iq,D2_GBB_GBB)
3540              Mmat2(iq,D2_RA_TA) = Mmat2(iq,D2_RA_TA)
3541              Mmat2(iq,D2_RA_TB) = 1.0d+0*t1*t65*wght+t63+Mmat2(iq,
3542     +          D2_RA_TB)
3543              Mmat2(iq,D2_RB_TA) = Mmat2(iq,D2_RB_TA)
3544              Mmat2(iq,D2_RB_TB) = 1.0d+0*t1*t66*wght+t63+Mmat2(iq,
3545     +          D2_RB_TB)
3546              Mmat2(iq,D2_GAA_TA) = Mmat2(iq,D2_GAA_TA)
3547              Mmat2(iq,D2_GAA_TB) = Mmat2(iq,D2_GAA_TB)
3548              Mmat2(iq,D2_GAB_TA) = Mmat2(iq,D2_GAB_TA)
3549              Mmat2(iq,D2_GAB_TB) = Mmat2(iq,D2_GAB_TB)
3550              Mmat2(iq,D2_GBB_TA) = Mmat2(iq,D2_GBB_TA)
3551              Mmat2(iq,D2_GBB_TB) = 1.0d+0*t1*(-2*t29*t33*t5*t8+t68
3552     +          +t67)*wght+Mmat2(iq,D2_GBB_TB)
3553              Mmat2(iq,D2_TA_TA) = Mmat2(iq,D2_TA_TA)
3554              Mmat2(iq,D2_TA_TB) = Mmat2(iq,D2_TA_TB)
3555              Mmat2(iq,D2_TB_TB) = 1.0d+0*t1*(3.18d+0*s3f*t12*t70
3556     +          -1.434375d-1*t5*s2f*t69*t7*t8)*wght+Mmat2(iq,D2_TB_TB)
3557              Amat3(iq,D3_RA_RA_RA) = 1.0d+0*t1*(t73+t72-3.825d-1*rhoa
3558     +          *s1a3(D3_RA_RA_RA)*t5-1.1474999999999999d+0*t38*t5
3559     +          -2.2949999999999998d+0*t36*s1f+1.1474999999999999d+0
3560     +          *rhoa*t18*t38-2.2949999999999998d+0*rhoa*t20*t36
3561     +          +2.2949999999999998d+0*t18*t20+s3a3(D3_RA_RA_RA)*t15)
3562     +          *wght+3.0d+0*t41*wght+Amat3(iq,D3_RA_RA_RA)
3563              Amat3(iq,D3_RA_RA_RB) = 1.0d+0*t1*(-4.78125d-2*t25*t36
3564     +          *t7*t8*t9+4.78125d-2*t24*t36*s2f*t7*t9+t73+t72
3565     +          -1.325d-1*gammabb*t11*t14*t24*t40-1.53d+0*t36*s1f
3566     +          +3.825d-1*rhoa*t18*t38-1.53d+0*rhoa*t20*t36+7.65d-1
3567     +          *t18*t20+s3a3(D3_RA_RA_RB)*t15)*wght+1.0d+0*t41*wght
3568     +          +t74+Amat3(iq,D3_RA_RA_RB)
3569              Amat3(iq,D3_RA_RB_RB) = 1.0d+0*t1*(2.390625d-2*t18*t45
3570     +          *t7*t8*t9-9.5625d-2*t25*t36*t7*t8*t9+4.78125d-2*t18
3571     +          *t44*s2f*t7*t9+9.5625d-2*t24*t36*s2f*t7*t9-4.78125d-2
3572     +          *t18*t24*t25*t7*t9+t73+t72+1.6562500000000002d-2*t14
3573     +          *t22*t46*t7+2.65d-1*gammabb*t11*t14*t22*t44-2.65d-1
3574     +          *gammabb*t11*t14*t24*t42-7.65d-1*t36*s1f-7.65d-1*rhoa
3575     +          *t20*t36+s3a3(D3_RA_RB_RB)*t15)*wght+1.0d+0*t48*wght
3576     +          +t74+Amat3(iq,D3_RA_RB_RB)
3577              Amat3(iq,D3_RB_RB_RB) = 1.0d+0*t1*(-2.390625d-2*t5*s2a3
3578     +          (D3_RB_RB_RB)*t7*t8*t9+7.171875d-2*t18*t45*t7*t8*t9
3579     +          -1.434375d-1*t25*t36*t7*t8*t9+1.434375d-1*t46*t5*s2f
3580     +          *t7*t9+1.434375d-1*t18*t44*s2f*t7*t9+1.434375d-1*t24
3581     +          *t36*s2f*t7*t9+7.171875d-2*t24*t45*t5*t7*t9
3582     +          -1.434375d-1*t25*t44*t5*t7*t9-1.434375d-1*t18*t24*t25
3583     +          *t7*t9+t73+t72+4.96875d-2*t14*t26*t46*t7-9.9375d-2*s3f
3584     +          *t14*t7/rhob**5-3.975d-1*gammabb*t11*t14*t24*t47
3585     +          -7.95d-1*gammabb*s3f*t11*t14*t46+7.95d-1*gammabb*t11
3586     +          *t14*t26*t44+s3a3(D3_RB_RB_RB)*t15)*wght+3.0d+0*t48
3587     +          *wght+Amat3(iq,D3_RB_RB_RB)
3588              Cmat3(iq,D3_RA_RA_GAA) = Cmat3(iq,D3_RA_RA_GAA)
3589              Cmat3(iq,D3_RA_RA_GAB) = Cmat3(iq,D3_RA_RA_GAB)
3590              Cmat3(iq,D3_RA_RA_GBB) = 1.0d+0*t1*(1.325d-1*t11*t14*t40
3591     +          *t8+t76+t75+s3c3(D3_RA_RA_GBB)*t15)*wght+2.0d+0*t53
3592     +          *wght+Cmat3(iq,D3_RA_RA_GBB)
3593              Cmat3(iq,D3_RA_RB_GAA) = Cmat3(iq,D3_RA_RB_GAA)
3594              Cmat3(iq,D3_RA_RB_GAB) = Cmat3(iq,D3_RA_RB_GAB)
3595              Cmat3(iq,D3_RA_RB_GBB) = 1.0d+0*t1*(2.390625d-2*t18*t54
3596     +          *t7*t8*t9+4.78125d-2*gammabb*t18*t25*t8*t9-2.390625d-2
3597     +          *t18*t24*t28*t7*t9-4.78125d-2*gammabb*t18*t24*s2f*t9
3598     +          +1.325d-1*t11*t14*t42*t8+t76+t75-1.325d-1*gammabb*t11
3599     +          *t14*t24*t52-1.6562500000000002d-2*gammabb*t14*t22*t44
3600     +          -1.325d-1*t11*t14*t22*t24+s3c3(D3_RA_RB_GBB)*t15)*wght
3601     +          +1.0d+0*t56*wght+1.0d+0*t53*wght+Cmat3(iq,D3_RA_RB_GBB)
3602              Cmat3(iq,D3_RB_RB_GAA) = Cmat3(iq,D3_RB_RB_GAA)
3603              Cmat3(iq,D3_RB_RB_GAB) = Cmat3(iq,D3_RB_RB_GAB)
3604              Cmat3(iq,D3_RB_RB_GBB) = 1.0d+0*t1*(-2.390625d-2*t5*s2c3
3605     +          (D3_RB_RB_GBB)*t7*t8*t9+4.78125d-2*t18*t54*t7*t8*t9
3606     +          -4.78125d-2*gammabb*t45*t5*t8*t9+9.5625d-2*gammabb*t18
3607     +          *t25*t8*t9+4.78125d-2*t24*t5*t54*t7*t9-4.78125d-2*t28
3608     +          *t44*t5*t7*t9-4.78125d-2*t18*t24*t28*t7*t9-9.5625d-2
3609     +          *gammabb*t44*t5*s2f*t9-9.5625d-2*gammabb*t18*t24*s2f
3610     +          *t9+9.5625d-2*gammabb*t24*t25*t5*t9+1.325d-1*t11*t14
3611     +          *t47*t8+t76+t75+1.6562500000000002d-2*t14*t31*t46*t7
3612     +          -2.65d-1*gammabb*t11*t14*t24*t55+6.625000000000001d-2
3613     +          *gammabb*s3f*t14*t46+2.65d-1*gammabb*t11*t14*t31*t44
3614     +          -3.3125000000000004d-2*gammabb*t14*t26*t44+2.65d-1*s3f
3615     +          *t11*t14*t44-2.65d-1*t11*t14*t24*t26+s3c3(D3_RB_RB_GBB
3616     +          )*t15)*wght+2.0d+0*t56*wght+Cmat3(iq,D3_RB_RB_GBB)
3617              Cmat3(iq,D3_RA_GAA_GAA) = Cmat3(iq,D3_RA_GAA_GAA)
3618              Cmat3(iq,D3_RA_GAA_GAB) = Cmat3(iq,D3_RA_GAA_GAB)
3619              Cmat3(iq,D3_RA_GAA_GBB) = Cmat3(iq,D3_RA_GAA_GBB)
3620              Cmat3(iq,D3_RA_GAB_GAB) = Cmat3(iq,D3_RA_GAB_GAB)
3621              Cmat3(iq,D3_RA_GAB_GBB) = Cmat3(iq,D3_RA_GAB_GBB)
3622              Cmat3(iq,D3_RA_GBB_GBB) = 1.0d+0*t1*(t80+2.65d-1*t11*t14
3623     +          *t52*t8+t79+t78+1.6562500000000002d-2*t14*t22*t24+s3c3
3624     +          (D3_RA_GBB_GBB)*t15)*wght+t77+Cmat3(iq,D3_RA_GBB_GBB)
3625              Cmat3(iq,D3_RB_GAA_GAA) = Cmat3(iq,D3_RB_GAA_GAA)
3626              Cmat3(iq,D3_RB_GAA_GAB) = Cmat3(iq,D3_RB_GAA_GAB)
3627              Cmat3(iq,D3_RB_GAA_GBB) = Cmat3(iq,D3_RB_GAA_GBB)
3628              Cmat3(iq,D3_RB_GAB_GAB) = Cmat3(iq,D3_RB_GAB_GAB)
3629              Cmat3(iq,D3_RB_GAB_GBB) = Cmat3(iq,D3_RB_GAB_GBB)
3630              Cmat3(iq,D3_RB_GBB_GBB) = 1.0d+0*t1*(-2.390625d-2*t5
3631     +          *s2c3(D3_RB_GBB_GBB)*t7*t8*t9-9.5625d-2*gammabb*t5*t54
3632     +          *t8*t9-4.78125d-2*t25*t5*t8*t9+2.390625d-2*t24*t5*t57
3633     +          *t7*t9+4.78125d-2*t24*t5*s2f*t9+9.5625d-2*gammabb*t24
3634     +          *t28*t5*t9+t80+2.65d-1*t11*t14*t55*t8+t79+t78-1.325d-1
3635     +          *gammabb*t11*t14*t24*t61-3.3125000000000004d-2*gammabb
3636     +          *t14*t31*t44-3.3125000000000004d-2*s3f*t14*t44-2.65d-1
3637     +          *t11*t14*t24*t31+1.6562500000000002d-2*t14*t24*t26
3638     +          +s3c3(D3_RB_GBB_GBB)*t15)*wght+t77+Cmat3(iq,
3639     +          D3_RB_GBB_GBB)
3640              Cmat3(iq,D3_GAA_GAA_GAA) = Cmat3(iq,D3_GAA_GAA_GAA)
3641              Cmat3(iq,D3_GAA_GAA_GAB) = Cmat3(iq,D3_GAA_GAA_GAB)
3642              Cmat3(iq,D3_GAA_GAA_GBB) = Cmat3(iq,D3_GAA_GAA_GBB)
3643              Cmat3(iq,D3_GAA_GAB_GAB) = Cmat3(iq,D3_GAA_GAB_GAB)
3644              Cmat3(iq,D3_GAA_GAB_GBB) = Cmat3(iq,D3_GAA_GAB_GBB)
3645              Cmat3(iq,D3_GAA_GBB_GBB) = Cmat3(iq,D3_GAA_GBB_GBB)
3646              Cmat3(iq,D3_GAB_GAB_GAB) = Cmat3(iq,D3_GAB_GAB_GAB)
3647              Cmat3(iq,D3_GAB_GAB_GBB) = Cmat3(iq,D3_GAB_GAB_GBB)
3648              Cmat3(iq,D3_GAB_GBB_GBB) = Cmat3(iq,D3_GAB_GBB_GBB)
3649              Cmat3(iq,D3_GBB_GBB_GBB) = 1.0d+0*t1*(t5*(-2.390625d-2
3650     +          *s2c3(D3_GBB_GBB_GBB)*t7-1.434375d-1*gammabb*t57
3651     +          -1.434375d-1*t28)*t8*t9+3.975d-1*t11*t14*t61*t8
3652     +          +4.96875d-2*t14*t24*t31+s3c3(D3_GBB_GBB_GBB)*t15)*wght
3653     +          +Cmat3(iq,D3_GBB_GBB_GBB)
3654              Mmat3(iq,D3_RA_RA_TA) = Mmat3(iq,D3_RA_RA_TA)
3655              Mmat3(iq,D3_RA_RA_TB) = 1.0d+0*t1*(t81
3656     +          -1.0600000000000001d+0*t12*t34*t40)*wght+2.0d+0*t65
3657     +          *wght+Mmat3(iq,D3_RA_RA_TB)
3658              Mmat3(iq,D3_RA_RB_TA) = Mmat3(iq,D3_RA_RB_TA)
3659              Mmat3(iq,D3_RA_RB_TB) = 1.0d+0*t1*(t81-4.78125d-2*t18
3660     +          *t25*t33*t7*t8+4.78125d-2*t18*t24*t33*s2f*t7
3661     +          -1.0600000000000001d+0*t12*t34*t42+2.65d-1*gammabb*t11
3662     +          *t22*t24*t34)*wght+1.0d+0*t66*wght+1.0d+0*t65*wght
3663     +          +Mmat3(iq,D3_RA_RB_TB)
3664              Mmat3(iq,D3_RB_RB_TA) = Mmat3(iq,D3_RB_RB_TA)
3665              Mmat3(iq,D3_RB_RB_TB) = 1.0d+0*t1*(t81+4.78125d-2*t33
3666     +          *t45*t5*t7*t8-9.5625d-2*t18*t25*t33*t7*t8+9.5625d-2
3667     +          *t33*t44*t5*s2f*t7+9.5625d-2*t18*t24*t33*s2f*t7
3668     +          -9.5625d-2*t24*t25*t33*t5*t7-3.3125000000000004d-2*s3f
3669     +          *t34*t46*t7-1.0600000000000001d+0*t12*t34*t47-5.3d-1
3670     +          *gammabb*s3f*t11*t34*t44+5.3d-1*gammabb*t11*t24*t26
3671     +          *t34)*wght+2.0d+0*t66*wght+Mmat3(iq,D3_RB_RB_TB)
3672              Mmat3(iq,D3_RA_GAA_TA) = Mmat3(iq,D3_RA_GAA_TA)
3673              Mmat3(iq,D3_RA_GAA_TB) = Mmat3(iq,D3_RA_GAA_TB)
3674              Mmat3(iq,D3_RA_GAB_TA) = Mmat3(iq,D3_RA_GAB_TA)
3675              Mmat3(iq,D3_RA_GAB_TB) = Mmat3(iq,D3_RA_GAB_TB)
3676              Mmat3(iq,D3_RA_GBB_TA) = Mmat3(iq,D3_RA_GBB_TA)
3677              Mmat3(iq,D3_RA_GBB_TB) = 1.0d+0*t1*(t84+t83-2.65d-1*t11
3678     +          *t22*t34*t8-1.0600000000000001d+0*t12*t34*t52)*wght
3679     +          +t82+Mmat3(iq,D3_RA_GBB_TB)
3680              Mmat3(iq,D3_RB_GAA_TA) = Mmat3(iq,D3_RB_GAA_TA)
3681              Mmat3(iq,D3_RB_GAA_TB) = Mmat3(iq,D3_RB_GAA_TB)
3682              Mmat3(iq,D3_RB_GAB_TA) = Mmat3(iq,D3_RB_GAB_TA)
3683              Mmat3(iq,D3_RB_GAB_TB) = Mmat3(iq,D3_RB_GAB_TB)
3684              Mmat3(iq,D3_RB_GBB_TA) = Mmat3(iq,D3_RB_GBB_TA)
3685              Mmat3(iq,D3_RB_GBB_TB) = 1.0d+0*t1*(t84+t83+4.78125d-2
3686     +          *t33*t5*t54*t7*t8+9.5625d-2*gammabb*t25*t33*t5*t8
3687     +          -2.65d-1*t11*t26*t34*t8-4.78125d-2*t24*t28*t33*t5*t7
3688     +          -9.5625d-2*gammabb*t24*t33*t5*s2f
3689     +          -1.0600000000000001d+0*t12*t34*t55
3690     +          +3.3125000000000004d-2*gammabb*s3f*t34*t44+2.65d-1
3691     +          *gammabb*t11*t24*t31*t34+2.65d-1*s3f*t11*t24*t34)*wght
3692     +          +t82+Mmat3(iq,D3_RB_GBB_TB)
3693              Mmat3(iq,D3_RA_TA_TA) = Mmat3(iq,D3_RA_TA_TA)
3694              Mmat3(iq,D3_RA_TA_TB) = Mmat3(iq,D3_RA_TA_TB)
3695              Mmat3(iq,D3_RA_TB_TB) = Mmat3(iq,D3_RA_TB_TB)
3696              Mmat3(iq,D3_RB_TA_TA) = Mmat3(iq,D3_RB_TA_TA)
3697              Mmat3(iq,D3_RB_TA_TB) = Mmat3(iq,D3_RB_TA_TB)
3698              Mmat3(iq,D3_RB_TB_TB) = Mmat3(iq,D3_RB_TB_TB)
3699              Mmat3(iq,D3_GAA_GAA_TA) = Mmat3(iq,D3_GAA_GAA_TA)
3700              Mmat3(iq,D3_GAA_GAA_TB) = Mmat3(iq,D3_GAA_GAA_TB)
3701              Mmat3(iq,D3_GAA_GAB_TA) = Mmat3(iq,D3_GAA_GAB_TA)
3702              Mmat3(iq,D3_GAA_GAB_TB) = Mmat3(iq,D3_GAA_GAB_TB)
3703              Mmat3(iq,D3_GAA_GBB_TA) = Mmat3(iq,D3_GAA_GBB_TA)
3704              Mmat3(iq,D3_GAA_GBB_TB) = 1.0d+0*t1*(-2*t33*t5*t58*t8
3705     +          -5.3d-1*t11*t31*t34*t8-1.0600000000000001d+0*t12*t34
3706     +          *t61-3.3125000000000004d-2*s3f*t24*t34)*wght+Mmat3(iq,
3707     +          D3_GAA_GBB_TB)
3708              Mmat3(iq,D3_GAB_GAB_TA) = Mmat3(iq,D3_GAB_GAB_TA)
3709              Mmat3(iq,D3_GAB_GAB_TB) = Mmat3(iq,D3_GAB_GAB_TB)
3710              Mmat3(iq,D3_GAB_GBB_TA) = Mmat3(iq,D3_GAB_GBB_TA)
3711              Mmat3(iq,D3_GAB_GBB_TB) = Mmat3(iq,D3_GAB_GBB_TB)
3712              Mmat3(iq,D3_GBB_GBB_TA) = Mmat3(iq,D3_GBB_GBB_TA)
3713              Mmat3(iq,D3_GBB_GBB_TB) = Mmat3(iq,D3_GBB_GBB_TB)
3714              Mmat3(iq,D3_GAA_TA_TA) = Mmat3(iq,D3_GAA_TA_TA)
3715              Mmat3(iq,D3_GAA_TA_TB) = Mmat3(iq,D3_GAA_TA_TB)
3716              Mmat3(iq,D3_GAA_TB_TB) = 1.0d+0*t1*(7.95d-1*s3f*t11*t70
3717     +          *t8+6*t29*t5*t69*t8+3.18d+0*t12*t31*t70)*wght+Mmat3
3718     +          (iq,D3_GAA_TB_TB)
3719              Mmat3(iq,D3_GAB_TA_TA) = Mmat3(iq,D3_GAB_TA_TA)
3720              Mmat3(iq,D3_GAB_TA_TB) = Mmat3(iq,D3_GAB_TA_TB)
3721              Mmat3(iq,D3_GAB_TB_TB) = Mmat3(iq,D3_GAB_TB_TB)
3722              Mmat3(iq,D3_GBB_TA_TA) = 1.0d+0*t1*(5.7375d-1*t5*s2f*t7
3723     +          *t8/taub**5-1.272d+1*s3f*t12/t13**5)*wght+Mmat3(iq,
3724     +          D3_GBB_TA_TA)
3725            else
3726              t1 = rhob+rhoa
3727              t2 = param(1)
3728              t3 = 4.0d-50*rhoa
3729              t4 = 4.0d-50*rhob
3730              sr(R_A) = rhoa
3731              sr(R_B) = rhob
3732              sg(G_AA) = t3
3733              sg(G_AB) = 0
3734              sg(G_BB) = t4
3735              s1f = 0.0d0
3736              call dcopy(NCOL_AMAT,0.0d0,0,s1a,1)
3737              call dcopy(NCOL_AMAT2,0.0d0,0,s1a2,1)
3738              call dcopy(NCOL_AMAT3,0.0d0,0,s1a3,1)
3739              call dcopy(NCOL_CMAT,0.0d0,0,s1c,1)
3740              call dcopy(NCOL_CMAT2,0.0d0,0,s1c2,1)
3741              call dcopy(NCOL_CMAT3,0.0d0,0,s1c3,1)
3742              call nwxcm_c_mpbe_d3(t2,tol_rho,ipol,1,1.0d0,sr,sg,s1f,
3743     +          s1a,s1a2,s1a3,s1c,s1c2,s1c3)
3744              t5 = s1f
3745              sr(R_A) = rhoa
3746              sr(R_B) = 0.0d+0
3747              sg(G_AA) = t3
3748              sg(G_AB) = 0.0d+0
3749              sg(G_BB) = 0.0d+0
3750              s2f = 0.0d0
3751              call dcopy(NCOL_AMAT,0.0d0,0,s2a,1)
3752              call dcopy(NCOL_AMAT2,0.0d0,0,s2a2,1)
3753              call dcopy(NCOL_AMAT3,0.0d0,0,s2a3,1)
3754              call dcopy(NCOL_CMAT,0.0d0,0,s2c,1)
3755              call dcopy(NCOL_CMAT2,0.0d0,0,s2c2,1)
3756              call dcopy(NCOL_CMAT3,0.0d0,0,s2c3,1)
3757              call nwxcm_c_mpbe_d3(t2,tol_rho,2,1,1.0d0,sr,sg,s2f,s2a,
3758     +          s2a2,s2a3,s2c,s2c2,s2c3)
3759              t6 = s2f
3760              t7 = 1/t1
3761              sr(R_A) = 0.0d+0
3762              sr(R_B) = rhob
3763              sg(G_AA) = 0.0d+0
3764              sg(G_AB) = 0.0d+0
3765              sg(G_BB) = t4
3766              s3f = 0.0d0
3767              call dcopy(NCOL_AMAT,0.0d0,0,s3a,1)
3768              call dcopy(NCOL_AMAT2,0.0d0,0,s3a2,1)
3769              call dcopy(NCOL_AMAT3,0.0d0,0,s3a3,1)
3770              call dcopy(NCOL_CMAT,0.0d0,0,s3c,1)
3771              call dcopy(NCOL_CMAT2,0.0d0,0,s3c2,1)
3772              call dcopy(NCOL_CMAT3,0.0d0,0,s3c3,1)
3773              call nwxcm_c_mpbe_d3(t2,tol_rho,2,1,1.0d0,sr,sg,s3f,s3a,
3774     +          s3a2,s3a3,s3c,s3c2,s3c3)
3775              t8 = s3f
3776              t9 = -3.825d-1*rhob*t7*s3f-3.825d-1*rhoa*s2f*t7
3777     +          +1.1325d+0*s1f
3778              t10 = 1/t1**2
3779              t11 = 3.825d-1*rhoa*t10*s2f
3780              t12 = 3.825d-1*rhob*t10*s3f
3781              t13 = s2a(D1_RA)
3782              t14 = -3.825d-1*s2f*t7-3.825d-1*rhoa*t13*t7+1.1325d+0
3783     +          *s1a(D1_RA)+t12+t11
3784              t15 = 1.0d+0*t9*wght
3785              t16 = s3a(D1_RB)
3786              t17 = -3.825d-1*t7*s3f-3.825d-1*rhob*t16*t7+1.1325d+0
3787     +          *s1a(D1_RB)+t12+t11
3788              t18 = 1/t1**3
3789              t19 = -7.65d-1*rhoa*t18*s2f
3790              t20 = -7.65d-1*rhob*t18*s3f
3791              t21 = s2a2(D2_RA_RA)
3792              t22 = -3.825d-1*rhoa*t21*t7-7.65d-1*t13*t7+7.65d-1*t10
3793     +          *s2f+1.1325d+0*s1a2(D2_RA_RA)+t20+t19+7.65d-1*rhoa*t10
3794     +          *t13
3795              t23 = 3.825d-1*t10*s3f+3.825d-1*t10*s2f+1.1325d+0*s1a2
3796     +          (D2_RA_RB)+t20+t19+3.825d-1*rhob*t10*t16+3.825d-1*rhoa
3797     +          *t10*t13
3798              t24 = s3a2(D2_RB_RB)
3799              t25 = 7.65d-1*t10*s3f-3.825d-1*rhob*t24*t7-7.65d-1*t16
3800     +          *t7+1.1325d+0*s1a2(D2_RB_RB)+t20+t19+7.65d-1*rhob*t10
3801     +          *t16
3802              t26 = 1/t1**4
3803              t27 = 2.2949999999999998d+0*rhoa*t26*s2f
3804              t28 = 2.2949999999999998d+0*rhob*t26*s3f
3805              t29 = 2.0d+0*t23*wght
3806              fnc(iq) = 1.0d+0*t1*t9*wght+fnc(iq)
3807              Amat(iq,D1_RA) = 1.0d+0*t1*t14*wght+t15+Amat(iq,D1_RA)
3808              Amat(iq,D1_RB) = 1.0d+0*t1*t17*wght+t15+Amat(iq,D1_RB)
3809              Cmat(iq,D1_GAA) = Cmat(iq,D1_GAA)
3810              Cmat(iq,D1_GAB) = Cmat(iq,D1_GAB)
3811              Cmat(iq,D1_GBB) = Cmat(iq,D1_GBB)
3812              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
3813              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
3814              Amat2(iq,D2_RA_RA) = 1.0d+0*t1*t22*wght+2.0d+0*t14*wght
3815     +          +Amat2(iq,D2_RA_RA)
3816              Amat2(iq,D2_RA_RB) = 1.0d+0*t1*t23*wght+1.0d+0*t17*wght
3817     +          +1.0d+0*t14*wght+Amat2(iq,D2_RA_RB)
3818              Amat2(iq,D2_RB_RB) = 1.0d+0*t1*t25*wght+2.0d+0*t17*wght
3819     +          +Amat2(iq,D2_RB_RB)
3820              Cmat2(iq,D2_RA_GAA) = Cmat2(iq,D2_RA_GAA)
3821              Cmat2(iq,D2_RA_GAB) = Cmat2(iq,D2_RA_GAB)
3822              Cmat2(iq,D2_RA_GBB) = Cmat2(iq,D2_RA_GBB)
3823              Cmat2(iq,D2_RB_GAA) = Cmat2(iq,D2_RB_GAA)
3824              Cmat2(iq,D2_RB_GAB) = Cmat2(iq,D2_RB_GAB)
3825              Cmat2(iq,D2_RB_GBB) = Cmat2(iq,D2_RB_GBB)
3826              Cmat2(iq,D2_GAA_GAA) = Cmat2(iq,D2_GAA_GAA)
3827              Cmat2(iq,D2_GAA_GAB) = Cmat2(iq,D2_GAA_GAB)
3828              Cmat2(iq,D2_GAA_GBB) = Cmat2(iq,D2_GAA_GBB)
3829              Cmat2(iq,D2_GAB_GAB) = Cmat2(iq,D2_GAB_GAB)
3830              Cmat2(iq,D2_GAB_GBB) = Cmat2(iq,D2_GAB_GBB)
3831              Cmat2(iq,D2_GBB_GBB) = Cmat2(iq,D2_GBB_GBB)
3832              Mmat2(iq,D2_RA_TA) = Mmat2(iq,D2_RA_TA)
3833              Mmat2(iq,D2_RA_TB) = Mmat2(iq,D2_RA_TB)
3834              Mmat2(iq,D2_RB_TA) = Mmat2(iq,D2_RB_TA)
3835              Mmat2(iq,D2_RB_TB) = Mmat2(iq,D2_RB_TB)
3836              Mmat2(iq,D2_GAA_TA) = Mmat2(iq,D2_GAA_TA)
3837              Mmat2(iq,D2_GAA_TB) = Mmat2(iq,D2_GAA_TB)
3838              Mmat2(iq,D2_GAB_TA) = Mmat2(iq,D2_GAB_TA)
3839              Mmat2(iq,D2_GAB_TB) = Mmat2(iq,D2_GAB_TB)
3840              Mmat2(iq,D2_GBB_TA) = Mmat2(iq,D2_GBB_TA)
3841              Mmat2(iq,D2_GBB_TB) = Mmat2(iq,D2_GBB_TB)
3842              Mmat2(iq,D2_TA_TA) = Mmat2(iq,D2_TA_TA)
3843              Mmat2(iq,D2_TA_TB) = Mmat2(iq,D2_TA_TB)
3844              Mmat2(iq,D2_TB_TB) = Mmat2(iq,D2_TB_TB)
3845              Amat3(iq,D3_RA_RA_RA) = 1.0d+0*t1*(-3.825d-1*rhoa*s2a3
3846     +          (D3_RA_RA_RA)*t7-1.1474999999999999d+0*t21*t7
3847     +          -2.2949999999999998d+0*t18*s2f+1.1325d+0*s1a3
3848     +          (D3_RA_RA_RA)+t28+t27+1.1474999999999999d+0*rhoa*t10
3849     +          *t21-2.2949999999999998d+0*rhoa*t13*t18
3850     +          +2.2949999999999998d+0*t10*t13)*wght+3.0d+0*t22*wght
3851     +          +Amat3(iq,D3_RA_RA_RA)
3852              Amat3(iq,D3_RA_RA_RB) = 1.0d+0*t1*(-7.65d-1*t18*s3f
3853     +          -1.53d+0*t18*s2f+1.1325d+0*s1a3(D3_RA_RA_RB)+t28+t27
3854     +          +3.825d-1*rhoa*t10*t21-7.65d-1*rhob*t16*t18-1.53d+0
3855     +          *rhoa*t13*t18+7.65d-1*t10*t13)*wght+1.0d+0*t22*wght
3856     +          +t29+Amat3(iq,D3_RA_RA_RB)
3857              Amat3(iq,D3_RA_RB_RB) = 1.0d+0*t1*(-1.53d+0*t18*s3f
3858     +          -7.65d-1*t18*s2f+1.1325d+0*s1a3(D3_RA_RB_RB)+t28+t27
3859     +          +3.825d-1*rhob*t10*t24-1.53d+0*rhob*t16*t18-7.65d-1
3860     +          *rhoa*t13*t18+7.65d-1*t10*t16)*wght+1.0d+0*t25*wght
3861     +          +t29+Amat3(iq,D3_RA_RB_RB)
3862              Amat3(iq,D3_RB_RB_RB) = 1.0d+0*t1*(-3.825d-1*rhob*t7
3863     +          *s3a3(D3_RB_RB_RB)-2.2949999999999998d+0*t18*s3f
3864     +          -1.1474999999999999d+0*t24*t7+1.1325d+0*s1a3
3865     +          (D3_RB_RB_RB)+t28+t27+1.1474999999999999d+0*rhob*t10
3866     +          *t24-2.2949999999999998d+0*rhob*t16*t18
3867     +          +2.2949999999999998d+0*t10*t16)*wght+3.0d+0*t25*wght
3868     +          +Amat3(iq,D3_RB_RB_RB)
3869              Cmat3(iq,D3_RA_RA_GAA) = Cmat3(iq,D3_RA_RA_GAA)
3870              Cmat3(iq,D3_RA_RA_GAB) = Cmat3(iq,D3_RA_RA_GAB)
3871              Cmat3(iq,D3_RA_RA_GBB) = Cmat3(iq,D3_RA_RA_GBB)
3872              Cmat3(iq,D3_RA_RB_GAA) = Cmat3(iq,D3_RA_RB_GAA)
3873              Cmat3(iq,D3_RA_RB_GAB) = Cmat3(iq,D3_RA_RB_GAB)
3874              Cmat3(iq,D3_RA_RB_GBB) = Cmat3(iq,D3_RA_RB_GBB)
3875              Cmat3(iq,D3_RB_RB_GAA) = Cmat3(iq,D3_RB_RB_GAA)
3876              Cmat3(iq,D3_RB_RB_GAB) = Cmat3(iq,D3_RB_RB_GAB)
3877              Cmat3(iq,D3_RB_RB_GBB) = Cmat3(iq,D3_RB_RB_GBB)
3878              Cmat3(iq,D3_RA_GAA_GAA) = Cmat3(iq,D3_RA_GAA_GAA)
3879              Cmat3(iq,D3_RA_GAA_GAB) = Cmat3(iq,D3_RA_GAA_GAB)
3880              Cmat3(iq,D3_RA_GAA_GBB) = Cmat3(iq,D3_RA_GAA_GBB)
3881              Cmat3(iq,D3_RA_GAB_GAB) = Cmat3(iq,D3_RA_GAB_GAB)
3882              Cmat3(iq,D3_RA_GAB_GBB) = Cmat3(iq,D3_RA_GAB_GBB)
3883              Cmat3(iq,D3_RA_GBB_GBB) = Cmat3(iq,D3_RA_GBB_GBB)
3884              Cmat3(iq,D3_RB_GAA_GAA) = Cmat3(iq,D3_RB_GAA_GAA)
3885              Cmat3(iq,D3_RB_GAA_GAB) = Cmat3(iq,D3_RB_GAA_GAB)
3886              Cmat3(iq,D3_RB_GAA_GBB) = Cmat3(iq,D3_RB_GAA_GBB)
3887              Cmat3(iq,D3_RB_GAB_GAB) = Cmat3(iq,D3_RB_GAB_GAB)
3888              Cmat3(iq,D3_RB_GAB_GBB) = Cmat3(iq,D3_RB_GAB_GBB)
3889              Cmat3(iq,D3_RB_GBB_GBB) = Cmat3(iq,D3_RB_GBB_GBB)
3890              Cmat3(iq,D3_GAA_GAA_GAA) = Cmat3(iq,D3_GAA_GAA_GAA)
3891              Cmat3(iq,D3_GAA_GAA_GAB) = Cmat3(iq,D3_GAA_GAA_GAB)
3892              Cmat3(iq,D3_GAA_GAA_GBB) = Cmat3(iq,D3_GAA_GAA_GBB)
3893              Cmat3(iq,D3_GAA_GAB_GAB) = Cmat3(iq,D3_GAA_GAB_GAB)
3894              Cmat3(iq,D3_GAA_GAB_GBB) = Cmat3(iq,D3_GAA_GAB_GBB)
3895              Cmat3(iq,D3_GAA_GBB_GBB) = Cmat3(iq,D3_GAA_GBB_GBB)
3896              Cmat3(iq,D3_GAB_GAB_GAB) = Cmat3(iq,D3_GAB_GAB_GAB)
3897              Cmat3(iq,D3_GAB_GAB_GBB) = Cmat3(iq,D3_GAB_GAB_GBB)
3898              Cmat3(iq,D3_GAB_GBB_GBB) = Cmat3(iq,D3_GAB_GBB_GBB)
3899              Cmat3(iq,D3_GBB_GBB_GBB) = Cmat3(iq,D3_GBB_GBB_GBB)
3900              Mmat3(iq,D3_RA_RA_TA) = Mmat3(iq,D3_RA_RA_TA)
3901              Mmat3(iq,D3_RA_RA_TB) = Mmat3(iq,D3_RA_RA_TB)
3902              Mmat3(iq,D3_RA_RB_TA) = Mmat3(iq,D3_RA_RB_TA)
3903              Mmat3(iq,D3_RA_RB_TB) = Mmat3(iq,D3_RA_RB_TB)
3904              Mmat3(iq,D3_RB_RB_TA) = Mmat3(iq,D3_RB_RB_TA)
3905              Mmat3(iq,D3_RB_RB_TB) = Mmat3(iq,D3_RB_RB_TB)
3906              Mmat3(iq,D3_RA_GAA_TA) = Mmat3(iq,D3_RA_GAA_TA)
3907              Mmat3(iq,D3_RA_GAA_TB) = Mmat3(iq,D3_RA_GAA_TB)
3908              Mmat3(iq,D3_RA_GAB_TA) = Mmat3(iq,D3_RA_GAB_TA)
3909              Mmat3(iq,D3_RA_GAB_TB) = Mmat3(iq,D3_RA_GAB_TB)
3910              Mmat3(iq,D3_RA_GBB_TA) = Mmat3(iq,D3_RA_GBB_TA)
3911              Mmat3(iq,D3_RA_GBB_TB) = Mmat3(iq,D3_RA_GBB_TB)
3912              Mmat3(iq,D3_RB_GAA_TA) = Mmat3(iq,D3_RB_GAA_TA)
3913              Mmat3(iq,D3_RB_GAA_TB) = Mmat3(iq,D3_RB_GAA_TB)
3914              Mmat3(iq,D3_RB_GAB_TA) = Mmat3(iq,D3_RB_GAB_TA)
3915              Mmat3(iq,D3_RB_GAB_TB) = Mmat3(iq,D3_RB_GAB_TB)
3916              Mmat3(iq,D3_RB_GBB_TA) = Mmat3(iq,D3_RB_GBB_TA)
3917              Mmat3(iq,D3_RB_GBB_TB) = Mmat3(iq,D3_RB_GBB_TB)
3918              Mmat3(iq,D3_RA_TA_TA) = Mmat3(iq,D3_RA_TA_TA)
3919              Mmat3(iq,D3_RA_TA_TB) = Mmat3(iq,D3_RA_TA_TB)
3920              Mmat3(iq,D3_RA_TB_TB) = Mmat3(iq,D3_RA_TB_TB)
3921              Mmat3(iq,D3_RB_TA_TA) = Mmat3(iq,D3_RB_TA_TA)
3922              Mmat3(iq,D3_RB_TA_TB) = Mmat3(iq,D3_RB_TA_TB)
3923              Mmat3(iq,D3_RB_TB_TB) = Mmat3(iq,D3_RB_TB_TB)
3924              Mmat3(iq,D3_GAA_GAA_TA) = Mmat3(iq,D3_GAA_GAA_TA)
3925              Mmat3(iq,D3_GAA_GAA_TB) = Mmat3(iq,D3_GAA_GAA_TB)
3926              Mmat3(iq,D3_GAA_GAB_TA) = Mmat3(iq,D3_GAA_GAB_TA)
3927              Mmat3(iq,D3_GAA_GAB_TB) = Mmat3(iq,D3_GAA_GAB_TB)
3928              Mmat3(iq,D3_GAA_GBB_TA) = Mmat3(iq,D3_GAA_GBB_TA)
3929              Mmat3(iq,D3_GAA_GBB_TB) = Mmat3(iq,D3_GAA_GBB_TB)
3930              Mmat3(iq,D3_GAB_GAB_TA) = Mmat3(iq,D3_GAB_GAB_TA)
3931              Mmat3(iq,D3_GAB_GAB_TB) = Mmat3(iq,D3_GAB_GAB_TB)
3932              Mmat3(iq,D3_GAB_GBB_TA) = Mmat3(iq,D3_GAB_GBB_TA)
3933              Mmat3(iq,D3_GAB_GBB_TB) = Mmat3(iq,D3_GAB_GBB_TB)
3934              Mmat3(iq,D3_GBB_GBB_TA) = Mmat3(iq,D3_GBB_GBB_TA)
3935              Mmat3(iq,D3_GBB_GBB_TB) = Mmat3(iq,D3_GBB_GBB_TB)
3936              Mmat3(iq,D3_GAA_TA_TA) = Mmat3(iq,D3_GAA_TA_TA)
3937              Mmat3(iq,D3_GAA_TA_TB) = Mmat3(iq,D3_GAA_TA_TB)
3938              Mmat3(iq,D3_GAA_TB_TB) = Mmat3(iq,D3_GAA_TB_TB)
3939              Mmat3(iq,D3_GAB_TA_TA) = Mmat3(iq,D3_GAB_TA_TA)
3940              Mmat3(iq,D3_GAB_TA_TB) = Mmat3(iq,D3_GAB_TA_TB)
3941              Mmat3(iq,D3_GAB_TB_TB) = Mmat3(iq,D3_GAB_TB_TB)
3942              Mmat3(iq,D3_GBB_TA_TA) = Mmat3(iq,D3_GBB_TA_TA)
3943            endif
3944          elseif (rhoa.gt.tol_rho.and.rhob.le.tol_rho) then
3945            if (taua.gt.tol_rho.and.taub.gt.tol_rho) then
3946              fnc(iq) = fnc(iq)
3947              Amat(iq,D1_RA) = Amat(iq,D1_RA)
3948              Cmat(iq,D1_GAA) = Cmat(iq,D1_GAA)
3949              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
3950              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
3951              Amat2(iq,D2_RA_RA) = Amat2(iq,D2_RA_RA)
3952              Cmat2(iq,D2_RA_GAA) = Cmat2(iq,D2_RA_GAA)
3953              Cmat2(iq,D2_GAA_GAA) = Cmat2(iq,D2_GAA_GAA)
3954              Mmat2(iq,D2_RA_TA) = Mmat2(iq,D2_RA_TA)
3955              Mmat2(iq,D2_RA_TB) = Mmat2(iq,D2_RA_TB)
3956              Mmat2(iq,D2_GAA_TA) = Mmat2(iq,D2_GAA_TA)
3957              Mmat2(iq,D2_GAA_TB) = Mmat2(iq,D2_GAA_TB)
3958              Mmat2(iq,D2_TA_TA) = Mmat2(iq,D2_TA_TA)
3959              Mmat2(iq,D2_TA_TB) = Mmat2(iq,D2_TA_TB)
3960              Mmat2(iq,D2_TB_TB) = Mmat2(iq,D2_TB_TB)
3961              Amat3(iq,D3_RA_RA_RA) = Amat3(iq,D3_RA_RA_RA)
3962              Cmat3(iq,D3_RA_RA_GAA) = Cmat3(iq,D3_RA_RA_GAA)
3963              Cmat3(iq,D3_RA_GAA_GAA) = Cmat3(iq,D3_RA_GAA_GAA)
3964              Cmat3(iq,D3_GAA_GAA_GAA) = Cmat3(iq,D3_GAA_GAA_GAA)
3965              Mmat3(iq,D3_RA_RA_TA) = Mmat3(iq,D3_RA_RA_TA)
3966              Mmat3(iq,D3_RA_RA_TB) = Mmat3(iq,D3_RA_RA_TB)
3967              Mmat3(iq,D3_RA_GAA_TA) = Mmat3(iq,D3_RA_GAA_TA)
3968              Mmat3(iq,D3_RA_GAA_TB) = Mmat3(iq,D3_RA_GAA_TB)
3969              Mmat3(iq,D3_GAA_GAA_TA) = Mmat3(iq,D3_GAA_GAA_TA)
3970              Mmat3(iq,D3_GAA_GAA_TB) = Mmat3(iq,D3_GAA_GAA_TB)
3971              Mmat3(iq,D3_RA_TA_TA) = Mmat3(iq,D3_RA_TA_TA)
3972              Mmat3(iq,D3_RA_TA_TB) = Mmat3(iq,D3_RA_TA_TB)
3973              Mmat3(iq,D3_RA_TB_TB) = Mmat3(iq,D3_RA_TB_TB)
3974              Mmat3(iq,D3_GAA_TA_TA) = Mmat3(iq,D3_GAA_TA_TA)
3975              Mmat3(iq,D3_GAA_TA_TB) = Mmat3(iq,D3_GAA_TA_TB)
3976              Mmat3(iq,D3_GAA_TB_TB) = Mmat3(iq,D3_GAA_TB_TB)
3977              Mmat3(iq,D3_TA_TA_TA) = Mmat3(iq,D3_TA_TA_TA)
3978              Mmat3(iq,D3_TA_TA_TB) = Mmat3(iq,D3_TA_TA_TB)
3979              Mmat3(iq,D3_TA_TB_TB) = Mmat3(iq,D3_TA_TB_TB)
3980              Mmat3(iq,D3_TB_TB_TB) = Mmat3(iq,D3_TB_TB_TB)
3981            elseif (taua.gt.tol_rho.and.taub.le.tol_rho) then
3982              fnc(iq) = fnc(iq)
3983              Amat(iq,D1_RA) = Amat(iq,D1_RA)
3984              Cmat(iq,D1_GAA) = Cmat(iq,D1_GAA)
3985              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
3986              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
3987              Amat2(iq,D2_RA_RA) = Amat2(iq,D2_RA_RA)
3988              Cmat2(iq,D2_RA_GAA) = Cmat2(iq,D2_RA_GAA)
3989              Cmat2(iq,D2_GAA_GAA) = Cmat2(iq,D2_GAA_GAA)
3990              Mmat2(iq,D2_RA_TA) = Mmat2(iq,D2_RA_TA)
3991              Mmat2(iq,D2_RA_TB) = Mmat2(iq,D2_RA_TB)
3992              Mmat2(iq,D2_GAA_TA) = Mmat2(iq,D2_GAA_TA)
3993              Mmat2(iq,D2_GAA_TB) = Mmat2(iq,D2_GAA_TB)
3994              Mmat2(iq,D2_TA_TA) = Mmat2(iq,D2_TA_TA)
3995              Mmat2(iq,D2_TA_TB) = Mmat2(iq,D2_TA_TB)
3996              Mmat2(iq,D2_TB_TB) = Mmat2(iq,D2_TB_TB)
3997              Amat3(iq,D3_RA_RA_RA) = Amat3(iq,D3_RA_RA_RA)
3998              Cmat3(iq,D3_RA_RA_GAA) = Cmat3(iq,D3_RA_RA_GAA)
3999              Cmat3(iq,D3_RA_GAA_GAA) = Cmat3(iq,D3_RA_GAA_GAA)
4000              Cmat3(iq,D3_GAA_GAA_GAA) = Cmat3(iq,D3_GAA_GAA_GAA)
4001              Mmat3(iq,D3_RA_RA_TA) = Mmat3(iq,D3_RA_RA_TA)
4002              Mmat3(iq,D3_RA_RA_TB) = Mmat3(iq,D3_RA_RA_TB)
4003              Mmat3(iq,D3_RA_GAA_TA) = Mmat3(iq,D3_RA_GAA_TA)
4004              Mmat3(iq,D3_RA_GAA_TB) = Mmat3(iq,D3_RA_GAA_TB)
4005              Mmat3(iq,D3_GAA_GAA_TA) = Mmat3(iq,D3_GAA_GAA_TA)
4006              Mmat3(iq,D3_GAA_GAA_TB) = Mmat3(iq,D3_GAA_GAA_TB)
4007              Mmat3(iq,D3_RA_TA_TA) = Mmat3(iq,D3_RA_TA_TA)
4008              Mmat3(iq,D3_RA_TA_TB) = Mmat3(iq,D3_RA_TA_TB)
4009              Mmat3(iq,D3_RA_TB_TB) = Mmat3(iq,D3_RA_TB_TB)
4010              Mmat3(iq,D3_GAA_TA_TA) = Mmat3(iq,D3_GAA_TA_TA)
4011              Mmat3(iq,D3_GAA_TA_TB) = Mmat3(iq,D3_GAA_TA_TB)
4012              Mmat3(iq,D3_GAA_TB_TB) = Mmat3(iq,D3_GAA_TB_TB)
4013              Mmat3(iq,D3_TA_TA_TA) = Mmat3(iq,D3_TA_TA_TA)
4014              Mmat3(iq,D3_TA_TA_TB) = Mmat3(iq,D3_TA_TA_TB)
4015              Mmat3(iq,D3_TA_TB_TB) = Mmat3(iq,D3_TA_TB_TB)
4016              Mmat3(iq,D3_TB_TB_TB) = Mmat3(iq,D3_TB_TB_TB)
4017            elseif (taua.le.tol_rho.and.taub.gt.tol_rho) then
4018              fnc(iq) = fnc(iq)
4019              Amat(iq,D1_RA) = Amat(iq,D1_RA)
4020              Cmat(iq,D1_GAA) = Cmat(iq,D1_GAA)
4021              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
4022              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
4023              Amat2(iq,D2_RA_RA) = Amat2(iq,D2_RA_RA)
4024              Cmat2(iq,D2_RA_GAA) = Cmat2(iq,D2_RA_GAA)
4025              Cmat2(iq,D2_GAA_GAA) = Cmat2(iq,D2_GAA_GAA)
4026              Mmat2(iq,D2_RA_TA) = Mmat2(iq,D2_RA_TA)
4027              Mmat2(iq,D2_RA_TB) = Mmat2(iq,D2_RA_TB)
4028              Mmat2(iq,D2_GAA_TA) = Mmat2(iq,D2_GAA_TA)
4029              Mmat2(iq,D2_GAA_TB) = Mmat2(iq,D2_GAA_TB)
4030              Mmat2(iq,D2_TA_TA) = Mmat2(iq,D2_TA_TA)
4031              Mmat2(iq,D2_TA_TB) = Mmat2(iq,D2_TA_TB)
4032              Mmat2(iq,D2_TB_TB) = Mmat2(iq,D2_TB_TB)
4033              Amat3(iq,D3_RA_RA_RA) = Amat3(iq,D3_RA_RA_RA)
4034              Cmat3(iq,D3_RA_RA_GAA) = Cmat3(iq,D3_RA_RA_GAA)
4035              Cmat3(iq,D3_RA_GAA_GAA) = Cmat3(iq,D3_RA_GAA_GAA)
4036              Cmat3(iq,D3_GAA_GAA_GAA) = Cmat3(iq,D3_GAA_GAA_GAA)
4037              Mmat3(iq,D3_RA_RA_TA) = Mmat3(iq,D3_RA_RA_TA)
4038              Mmat3(iq,D3_RA_RA_TB) = Mmat3(iq,D3_RA_RA_TB)
4039              Mmat3(iq,D3_RA_GAA_TA) = Mmat3(iq,D3_RA_GAA_TA)
4040              Mmat3(iq,D3_RA_GAA_TB) = Mmat3(iq,D3_RA_GAA_TB)
4041              Mmat3(iq,D3_GAA_GAA_TA) = Mmat3(iq,D3_GAA_GAA_TA)
4042              Mmat3(iq,D3_GAA_GAA_TB) = Mmat3(iq,D3_GAA_GAA_TB)
4043              Mmat3(iq,D3_RA_TA_TA) = Mmat3(iq,D3_RA_TA_TA)
4044              Mmat3(iq,D3_RA_TA_TB) = Mmat3(iq,D3_RA_TA_TB)
4045              Mmat3(iq,D3_RA_TB_TB) = Mmat3(iq,D3_RA_TB_TB)
4046              Mmat3(iq,D3_GAA_TA_TA) = Mmat3(iq,D3_GAA_TA_TA)
4047              Mmat3(iq,D3_GAA_TA_TB) = Mmat3(iq,D3_GAA_TA_TB)
4048              Mmat3(iq,D3_GAA_TB_TB) = Mmat3(iq,D3_GAA_TB_TB)
4049              Mmat3(iq,D3_TA_TA_TA) = Mmat3(iq,D3_TA_TA_TA)
4050              Mmat3(iq,D3_TA_TA_TB) = Mmat3(iq,D3_TA_TA_TB)
4051              Mmat3(iq,D3_TA_TB_TB) = Mmat3(iq,D3_TA_TB_TB)
4052              Mmat3(iq,D3_TB_TB_TB) = Mmat3(iq,D3_TB_TB_TB)
4053            else
4054              fnc(iq) = fnc(iq)
4055              Amat(iq,D1_RA) = Amat(iq,D1_RA)
4056              Cmat(iq,D1_GAA) = Cmat(iq,D1_GAA)
4057              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
4058              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
4059              Amat2(iq,D2_RA_RA) = Amat2(iq,D2_RA_RA)
4060              Cmat2(iq,D2_RA_GAA) = Cmat2(iq,D2_RA_GAA)
4061              Cmat2(iq,D2_GAA_GAA) = Cmat2(iq,D2_GAA_GAA)
4062              Mmat2(iq,D2_RA_TA) = Mmat2(iq,D2_RA_TA)
4063              Mmat2(iq,D2_RA_TB) = Mmat2(iq,D2_RA_TB)
4064              Mmat2(iq,D2_GAA_TA) = Mmat2(iq,D2_GAA_TA)
4065              Mmat2(iq,D2_GAA_TB) = Mmat2(iq,D2_GAA_TB)
4066              Mmat2(iq,D2_TA_TA) = Mmat2(iq,D2_TA_TA)
4067              Mmat2(iq,D2_TA_TB) = Mmat2(iq,D2_TA_TB)
4068              Mmat2(iq,D2_TB_TB) = Mmat2(iq,D2_TB_TB)
4069              Amat3(iq,D3_RA_RA_RA) = Amat3(iq,D3_RA_RA_RA)
4070              Cmat3(iq,D3_RA_RA_GAA) = Cmat3(iq,D3_RA_RA_GAA)
4071              Cmat3(iq,D3_RA_GAA_GAA) = Cmat3(iq,D3_RA_GAA_GAA)
4072              Cmat3(iq,D3_GAA_GAA_GAA) = Cmat3(iq,D3_GAA_GAA_GAA)
4073              Mmat3(iq,D3_RA_RA_TA) = Mmat3(iq,D3_RA_RA_TA)
4074              Mmat3(iq,D3_RA_RA_TB) = Mmat3(iq,D3_RA_RA_TB)
4075              Mmat3(iq,D3_RA_GAA_TA) = Mmat3(iq,D3_RA_GAA_TA)
4076              Mmat3(iq,D3_RA_GAA_TB) = Mmat3(iq,D3_RA_GAA_TB)
4077              Mmat3(iq,D3_GAA_GAA_TA) = Mmat3(iq,D3_GAA_GAA_TA)
4078              Mmat3(iq,D3_GAA_GAA_TB) = Mmat3(iq,D3_GAA_GAA_TB)
4079              Mmat3(iq,D3_RA_TA_TA) = Mmat3(iq,D3_RA_TA_TA)
4080              Mmat3(iq,D3_RA_TA_TB) = Mmat3(iq,D3_RA_TA_TB)
4081              Mmat3(iq,D3_RA_TB_TB) = Mmat3(iq,D3_RA_TB_TB)
4082              Mmat3(iq,D3_GAA_TA_TA) = Mmat3(iq,D3_GAA_TA_TA)
4083              Mmat3(iq,D3_GAA_TA_TB) = Mmat3(iq,D3_GAA_TA_TB)
4084              Mmat3(iq,D3_GAA_TB_TB) = Mmat3(iq,D3_GAA_TB_TB)
4085              Mmat3(iq,D3_TA_TA_TA) = Mmat3(iq,D3_TA_TA_TA)
4086              Mmat3(iq,D3_TA_TA_TB) = Mmat3(iq,D3_TA_TA_TB)
4087              Mmat3(iq,D3_TA_TB_TB) = Mmat3(iq,D3_TA_TB_TB)
4088              Mmat3(iq,D3_TB_TB_TB) = Mmat3(iq,D3_TB_TB_TB)
4089            endif
4090          elseif (rhoa.le.tol_rho.and.rhob.gt.tol_rho) then
4091            if (taua.gt.tol_rho.and.taub.gt.tol_rho) then
4092              fnc(iq) = fnc(iq)
4093              Amat(iq,D1_RB) = Amat(iq,D1_RB)
4094              Cmat(iq,D1_GBB) = Cmat(iq,D1_GBB)
4095              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
4096              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
4097              Amat2(iq,D2_RB_RB) = Amat2(iq,D2_RB_RB)
4098              Cmat2(iq,D2_RB_GBB) = Cmat2(iq,D2_RB_GBB)
4099              Cmat2(iq,D2_GBB_GBB) = Cmat2(iq,D2_GBB_GBB)
4100              Mmat2(iq,D2_RB_TA) = Mmat2(iq,D2_RB_TA)
4101              Mmat2(iq,D2_RB_TB) = Mmat2(iq,D2_RB_TB)
4102              Mmat2(iq,D2_GBB_TA) = Mmat2(iq,D2_GBB_TA)
4103              Mmat2(iq,D2_GBB_TB) = Mmat2(iq,D2_GBB_TB)
4104              Mmat2(iq,D2_TA_TA) = Mmat2(iq,D2_TA_TA)
4105              Mmat2(iq,D2_TA_TB) = Mmat2(iq,D2_TA_TB)
4106              Mmat2(iq,D2_TB_TB) = Mmat2(iq,D2_TB_TB)
4107              Amat3(iq,D3_RB_RB_RB) = Amat3(iq,D3_RB_RB_RB)
4108              Cmat3(iq,D3_RB_RB_GBB) = Cmat3(iq,D3_RB_RB_GBB)
4109              Cmat3(iq,D3_RB_GBB_GBB) = Cmat3(iq,D3_RB_GBB_GBB)
4110              Cmat3(iq,D3_GBB_GBB_GBB) = Cmat3(iq,D3_GBB_GBB_GBB)
4111              Mmat3(iq,D3_RB_RB_TA) = Mmat3(iq,D3_RB_RB_TA)
4112              Mmat3(iq,D3_RB_RB_TB) = Mmat3(iq,D3_RB_RB_TB)
4113              Mmat3(iq,D3_RB_GBB_TA) = Mmat3(iq,D3_RB_GBB_TA)
4114              Mmat3(iq,D3_RB_GBB_TB) = Mmat3(iq,D3_RB_GBB_TB)
4115              Mmat3(iq,D3_GBB_GBB_TA) = Mmat3(iq,D3_GBB_GBB_TA)
4116              Mmat3(iq,D3_GBB_GBB_TB) = Mmat3(iq,D3_GBB_GBB_TB)
4117              Mmat3(iq,D3_RB_TA_TA) = Mmat3(iq,D3_RB_TA_TA)
4118              Mmat3(iq,D3_RB_TA_TB) = Mmat3(iq,D3_RB_TA_TB)
4119              Mmat3(iq,D3_RB_TB_TB) = Mmat3(iq,D3_RB_TB_TB)
4120              Mmat3(iq,D3_GBB_TA_TA) = Mmat3(iq,D3_GBB_TA_TA)
4121              Mmat3(iq,D3_GBB_TA_TB) = Mmat3(iq,D3_GBB_TA_TB)
4122              Mmat3(iq,D3_GBB_TB_TB) = Mmat3(iq,D3_GBB_TB_TB)
4123              Mmat3(iq,D3_TA_TA_TA) = Mmat3(iq,D3_TA_TA_TA)
4124              Mmat3(iq,D3_TA_TA_TB) = Mmat3(iq,D3_TA_TA_TB)
4125              Mmat3(iq,D3_TA_TB_TB) = Mmat3(iq,D3_TA_TB_TB)
4126              Mmat3(iq,D3_TB_TB_TB) = Mmat3(iq,D3_TB_TB_TB)
4127            elseif (taua.gt.tol_rho.and.taub.le.tol_rho) then
4128              fnc(iq) = fnc(iq)
4129              Amat(iq,D1_RB) = Amat(iq,D1_RB)
4130              Cmat(iq,D1_GBB) = Cmat(iq,D1_GBB)
4131              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
4132              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
4133              Amat2(iq,D2_RB_RB) = Amat2(iq,D2_RB_RB)
4134              Cmat2(iq,D2_RB_GBB) = Cmat2(iq,D2_RB_GBB)
4135              Cmat2(iq,D2_GBB_GBB) = Cmat2(iq,D2_GBB_GBB)
4136              Mmat2(iq,D2_RB_TA) = Mmat2(iq,D2_RB_TA)
4137              Mmat2(iq,D2_RB_TB) = Mmat2(iq,D2_RB_TB)
4138              Mmat2(iq,D2_GBB_TA) = Mmat2(iq,D2_GBB_TA)
4139              Mmat2(iq,D2_GBB_TB) = Mmat2(iq,D2_GBB_TB)
4140              Mmat2(iq,D2_TA_TA) = Mmat2(iq,D2_TA_TA)
4141              Mmat2(iq,D2_TA_TB) = Mmat2(iq,D2_TA_TB)
4142              Mmat2(iq,D2_TB_TB) = Mmat2(iq,D2_TB_TB)
4143              Amat3(iq,D3_RB_RB_RB) = Amat3(iq,D3_RB_RB_RB)
4144              Cmat3(iq,D3_RB_RB_GBB) = Cmat3(iq,D3_RB_RB_GBB)
4145              Cmat3(iq,D3_RB_GBB_GBB) = Cmat3(iq,D3_RB_GBB_GBB)
4146              Cmat3(iq,D3_GBB_GBB_GBB) = Cmat3(iq,D3_GBB_GBB_GBB)
4147              Mmat3(iq,D3_RB_RB_TA) = Mmat3(iq,D3_RB_RB_TA)
4148              Mmat3(iq,D3_RB_RB_TB) = Mmat3(iq,D3_RB_RB_TB)
4149              Mmat3(iq,D3_RB_GBB_TA) = Mmat3(iq,D3_RB_GBB_TA)
4150              Mmat3(iq,D3_RB_GBB_TB) = Mmat3(iq,D3_RB_GBB_TB)
4151              Mmat3(iq,D3_GBB_GBB_TA) = Mmat3(iq,D3_GBB_GBB_TA)
4152              Mmat3(iq,D3_GBB_GBB_TB) = Mmat3(iq,D3_GBB_GBB_TB)
4153              Mmat3(iq,D3_RB_TA_TA) = Mmat3(iq,D3_RB_TA_TA)
4154              Mmat3(iq,D3_RB_TA_TB) = Mmat3(iq,D3_RB_TA_TB)
4155              Mmat3(iq,D3_RB_TB_TB) = Mmat3(iq,D3_RB_TB_TB)
4156              Mmat3(iq,D3_GBB_TA_TA) = Mmat3(iq,D3_GBB_TA_TA)
4157              Mmat3(iq,D3_GBB_TA_TB) = Mmat3(iq,D3_GBB_TA_TB)
4158              Mmat3(iq,D3_GBB_TB_TB) = Mmat3(iq,D3_GBB_TB_TB)
4159              Mmat3(iq,D3_TA_TA_TA) = Mmat3(iq,D3_TA_TA_TA)
4160              Mmat3(iq,D3_TA_TA_TB) = Mmat3(iq,D3_TA_TA_TB)
4161              Mmat3(iq,D3_TA_TB_TB) = Mmat3(iq,D3_TA_TB_TB)
4162              Mmat3(iq,D3_TB_TB_TB) = Mmat3(iq,D3_TB_TB_TB)
4163            elseif (taua.le.tol_rho.and.taub.gt.tol_rho) then
4164              fnc(iq) = fnc(iq)
4165              Amat(iq,D1_RB) = Amat(iq,D1_RB)
4166              Cmat(iq,D1_GBB) = Cmat(iq,D1_GBB)
4167              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
4168              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
4169              Amat2(iq,D2_RB_RB) = Amat2(iq,D2_RB_RB)
4170              Cmat2(iq,D2_RB_GBB) = Cmat2(iq,D2_RB_GBB)
4171              Cmat2(iq,D2_GBB_GBB) = Cmat2(iq,D2_GBB_GBB)
4172              Mmat2(iq,D2_RB_TA) = Mmat2(iq,D2_RB_TA)
4173              Mmat2(iq,D2_RB_TB) = Mmat2(iq,D2_RB_TB)
4174              Mmat2(iq,D2_GBB_TA) = Mmat2(iq,D2_GBB_TA)
4175              Mmat2(iq,D2_GBB_TB) = Mmat2(iq,D2_GBB_TB)
4176              Mmat2(iq,D2_TA_TA) = Mmat2(iq,D2_TA_TA)
4177              Mmat2(iq,D2_TA_TB) = Mmat2(iq,D2_TA_TB)
4178              Mmat2(iq,D2_TB_TB) = Mmat2(iq,D2_TB_TB)
4179              Amat3(iq,D3_RB_RB_RB) = Amat3(iq,D3_RB_RB_RB)
4180              Cmat3(iq,D3_RB_RB_GBB) = Cmat3(iq,D3_RB_RB_GBB)
4181              Cmat3(iq,D3_RB_GBB_GBB) = Cmat3(iq,D3_RB_GBB_GBB)
4182              Cmat3(iq,D3_GBB_GBB_GBB) = Cmat3(iq,D3_GBB_GBB_GBB)
4183              Mmat3(iq,D3_RB_RB_TA) = Mmat3(iq,D3_RB_RB_TA)
4184              Mmat3(iq,D3_RB_RB_TB) = Mmat3(iq,D3_RB_RB_TB)
4185              Mmat3(iq,D3_RB_GBB_TA) = Mmat3(iq,D3_RB_GBB_TA)
4186              Mmat3(iq,D3_RB_GBB_TB) = Mmat3(iq,D3_RB_GBB_TB)
4187              Mmat3(iq,D3_GBB_GBB_TA) = Mmat3(iq,D3_GBB_GBB_TA)
4188              Mmat3(iq,D3_GBB_GBB_TB) = Mmat3(iq,D3_GBB_GBB_TB)
4189              Mmat3(iq,D3_RB_TA_TA) = Mmat3(iq,D3_RB_TA_TA)
4190              Mmat3(iq,D3_RB_TA_TB) = Mmat3(iq,D3_RB_TA_TB)
4191              Mmat3(iq,D3_RB_TB_TB) = Mmat3(iq,D3_RB_TB_TB)
4192              Mmat3(iq,D3_GBB_TA_TA) = Mmat3(iq,D3_GBB_TA_TA)
4193              Mmat3(iq,D3_GBB_TA_TB) = Mmat3(iq,D3_GBB_TA_TB)
4194              Mmat3(iq,D3_GBB_TB_TB) = Mmat3(iq,D3_GBB_TB_TB)
4195              Mmat3(iq,D3_TA_TA_TA) = Mmat3(iq,D3_TA_TA_TA)
4196              Mmat3(iq,D3_TA_TA_TB) = Mmat3(iq,D3_TA_TA_TB)
4197              Mmat3(iq,D3_TA_TB_TB) = Mmat3(iq,D3_TA_TB_TB)
4198              Mmat3(iq,D3_TB_TB_TB) = Mmat3(iq,D3_TB_TB_TB)
4199            else
4200              fnc(iq) = fnc(iq)
4201              Amat(iq,D1_RB) = Amat(iq,D1_RB)
4202              Cmat(iq,D1_GBB) = Cmat(iq,D1_GBB)
4203              Mmat(iq,D1_TB) = Mmat(iq,D1_TB)
4204              Mmat(iq,D1_TA) = Mmat(iq,D1_TA)
4205              Amat2(iq,D2_RB_RB) = Amat2(iq,D2_RB_RB)
4206              Cmat2(iq,D2_RB_GBB) = Cmat2(iq,D2_RB_GBB)
4207              Cmat2(iq,D2_GBB_GBB) = Cmat2(iq,D2_GBB_GBB)
4208              Mmat2(iq,D2_RB_TA) = Mmat2(iq,D2_RB_TA)
4209              Mmat2(iq,D2_RB_TB) = Mmat2(iq,D2_RB_TB)
4210              Mmat2(iq,D2_GBB_TA) = Mmat2(iq,D2_GBB_TA)
4211              Mmat2(iq,D2_GBB_TB) = Mmat2(iq,D2_GBB_TB)
4212              Mmat2(iq,D2_TA_TA) = Mmat2(iq,D2_TA_TA)
4213              Mmat2(iq,D2_TA_TB) = Mmat2(iq,D2_TA_TB)
4214              Mmat2(iq,D2_TB_TB) = Mmat2(iq,D2_TB_TB)
4215              Amat3(iq,D3_RB_RB_RB) = Amat3(iq,D3_RB_RB_RB)
4216              Cmat3(iq,D3_RB_RB_GBB) = Cmat3(iq,D3_RB_RB_GBB)
4217              Cmat3(iq,D3_RB_GBB_GBB) = Cmat3(iq,D3_RB_GBB_GBB)
4218              Cmat3(iq,D3_GBB_GBB_GBB) = Cmat3(iq,D3_GBB_GBB_GBB)
4219              Mmat3(iq,D3_RB_RB_TA) = Mmat3(iq,D3_RB_RB_TA)
4220              Mmat3(iq,D3_RB_RB_TB) = Mmat3(iq,D3_RB_RB_TB)
4221              Mmat3(iq,D3_RB_GBB_TA) = Mmat3(iq,D3_RB_GBB_TA)
4222              Mmat3(iq,D3_RB_GBB_TB) = Mmat3(iq,D3_RB_GBB_TB)
4223              Mmat3(iq,D3_GBB_GBB_TA) = Mmat3(iq,D3_GBB_GBB_TA)
4224              Mmat3(iq,D3_GBB_GBB_TB) = Mmat3(iq,D3_GBB_GBB_TB)
4225              Mmat3(iq,D3_RB_TA_TA) = Mmat3(iq,D3_RB_TA_TA)
4226              Mmat3(iq,D3_RB_TA_TB) = Mmat3(iq,D3_RB_TA_TB)
4227              Mmat3(iq,D3_RB_TB_TB) = Mmat3(iq,D3_RB_TB_TB)
4228              Mmat3(iq,D3_GBB_TA_TA) = Mmat3(iq,D3_GBB_TA_TA)
4229              Mmat3(iq,D3_GBB_TA_TB) = Mmat3(iq,D3_GBB_TA_TB)
4230              Mmat3(iq,D3_GBB_TB_TB) = Mmat3(iq,D3_GBB_TB_TB)
4231              Mmat3(iq,D3_TA_TA_TA) = Mmat3(iq,D3_TA_TA_TA)
4232              Mmat3(iq,D3_TA_TA_TB) = Mmat3(iq,D3_TA_TA_TB)
4233              Mmat3(iq,D3_TA_TB_TB) = Mmat3(iq,D3_TA_TB_TB)
4234              Mmat3(iq,D3_TB_TB_TB) = Mmat3(iq,D3_TB_TB_TB)
4235            endif
4236          endif ! rhoa.gt.tol_rho.and.rhob.gt.tol_rho
4237        endif ! ipol.eq.1
4238      enddo ! iq
4239      end subroutine nwxcm_c_pkzb99_d3
4240C> @}
4241