5 SUBROUTINE intrptau(PXIN,PYIN,PYINNEW,PY2,KNIN,PXOUT,PYOUT,PYOUTP,
6 + pyoutpp,knout,kopt,ptaus,pwork,pamat,mdamat,pbclft,pbcrgt)
30 IMPLICIT REAL*8(a-h,o-z)
32 dimension pxin(knin), pyin(knin), pxout(knout), pyout(knout),
33 + pyoutp(knout), pyoutpp(knout), py2(knin), pwork(knin),
34 + pamat(mdamat,knin), pyinnew(knin)
44 IF (abs(pbclft - 1.d0) .LE. zeps) zyp1 = -1.d+32
45 IF (abs(pbclft - 2.d0) .LE. zeps) zyp1 = 1.d+32
46 IF (abs(pbclft - 3.d0) .LE. zeps) zyp1 = -1.d+34
51 IF (abs(pbcrgt - 1.d0) .LE. zeps) zypn = -1.d+32
52 IF (abs(pbcrgt - 2.d0) .LE. zeps) zypn= 1.d+32
53 IF (abs(pbcrgt - 3.d0) .LE. zeps) zypn = -1.d+34
55 CALL
cubsplfit(pxin,pyin,pyinnew,knin,zyp1,zypn,py2,ptaus
56 + ,pwork,pamat,mdamat)
61 IF (ptaus .EQ. 0.d0)
THEN
63 CALL
splintend(pxin,pyin,py2,knin,pxout(i),zy,zyp,zypp,1)
66 CALL
splintend(pxin,pyinnew,py2,knin,pxout(i),zy,zyp,zypp,1)
69 IF (kopt .GE. 1) pyoutp(i) = zyp
70 IF (kopt .EQ. 2) pyoutpp(i) = zypp
76 SUBROUTINE cubsplfit(X,Y,YNEW,N,YP1,YPN,Y2,TAUS,WORK,AMAT,
92 IMPLICIT REAL*8(a-h,o-z)
94 parameter(mnonsym=501)
95 dimension x(n), y(n), y2(n), work(n),
96 + amat(mdamat,n), ynew(n)
97 + ,anonsym(mnonsym*7), ipivot(mnonsym)
112 fa3(a1,a2,a3,a4,b1,
b2,b3,b4) =
113 f(a1-a2) / ((b1-
b2)*(
b2-b4)*(
b2-b3)) +
114 f(a1-a3) / ((b4-b3)*(b3-b1)*(b3-
b2)) +
115 f(a1-a4) / ((b1-b4)*(
b2-b4)*(b3-b4))
116 fa2(a1,a2,a3,a4,b1,
b2,b3,b4) =
117 f(a1-a2) / ((
b2-b1)*(b3-
b2)) +
118 f(a3-a1) / ((b3-b1)*(b3-
b2)) -
119 f(b1+
b2+b3) * fa3(a1,a2,a3,a4,b1,
b2,b3,b4)
120 fa1(a1,a2,a3,a4,b1,
b2,b3,b4) =
122 f(b1+
b2) * fa2(a1,a2,a3,a4,b1,
b2,b3,b4) -
123 f(b1*b1+b1*
b2+
b2*
b2) * fa3(a1,a2,a3,a4,b1,
b2,b3,b4)
124 fa0(a1,a2,a3,a4,b1,
b2,b3,b4) =
126 f b1 * (fa1(a1,a2,a3,a4,b1,
b2,b3,b4) +
127 f b1 * (fa2(a1,a2,a3,a4,b1,
b2,b3,b4) +
128 f b1 * fa3(a1,a2,a3,a4,b1,
b2,b3,b4)))
133 fcccc0(a1,a2,a3,a4,b1,
b2,b3,b4,px) =
134 f fa0(a1,a2,a3,a4,b1,
b2,b3,b4) +
135 f px * (fa1(a1,a2,a3,a4,b1,
b2,b3,b4) +
136 f px * (fa2(a1,a2,a3,a4,b1,
b2,b3,b4) +
137 f px * fa3(a1,a2,a3,a4,b1,
b2,b3,b4)))
142 fcccc1(a1,a2,a3,a4,b1,
b2,b3,b4,px) =
143 f fa1(a1,a2,a3,a4,b1,
b2,b3,b4) +
144 f px * (2.d0 * fa2(a1,a2,a3,a4,b1,
b2,b3,b4) +
145 f 3.d0 * px * fa3(a1,a2,a3,a4,b1,
b2,b3,b4))
150 fcccc2(a1,a2,a3,a4,b1,
b2,b3,b4,px) =
151 f 2.d0 * fa2(a1,a2,a3,a4,b1,
b2,b3,b4) +
152 f 6.d0 * fa3(a1,a2,a3,a4,b1,
b2,b3,b4) * px
157 fcccc3(a1,a2,a3,a4,b1,
b2,b3,b4,px) =
158 f 6.d0* fa3(a1,a2,a3,a4,b1,
b2,b3,b4)
176 work(k) = 1.d0/ (x(k+1) - x(k))
184 IF (ztaueff .EQ. 0.d0) iup = 1
193 IF (mnonsym*7 .LT. (3*iup+1)*n)
THEN
194 print *,
' MMNONSYM*7= ',mnonsym*7,
' < (3*IUP+1)*N= ',(3*iup+1)*n
208 amat(idiag,k) = (1.d0/work(k)+1.d0/work(k-1)) / 3.d0
209 + + 2.d0*ztaueff*(work(k)**2 + work(k)*work(k-1)+work(k-1)**2)
211 amat(idiag-1,k+1) = 1.d0/work(k)/6.d0
212 + - ztaueff*work(k)*(work(k+1)+2.d0*work(k)+work(k-1))
214 IF (iup .EQ. 2) amat(idiag-2,k+2) = ztaueff*work(k+1)*work(k)
216 y2(k) = (y(k+1)-y(k))*work(k) - (y(k)-y(k-1))*work(k-1)
225 amat(idiag,k) = 1.d0/work(k) / 3.d0
226 + + 2.d0*ztaueff*work(k)**2
227 amat(idiag-1,k+1) = 1.d0/work(k)/6.d0
228 + - ztaueff*work(k)*(work(k+1)+2.d0*work(k))
229 IF (iup .EQ. 2) amat(idiag-2,k+2) = ztaueff*work(k+1)*work(k)
230 y2(k) = (y(k+1)-y(k))*work(k)
235 amat(idiag,k) = (1.d0/work(k)+1.d0/work(k-1)) / 3.d0
236 + + 2.d0*ztaueff*(work(k)**2 + work(k)*work(k-1)+work(k-1)**2)
237 amat(idiag-1,k+1) = 1.d0/work(k)/6.d0
238 + - ztaueff*work(k)*(2.d0*work(k)+work(k-1))
239 y2(k) = (y(k+1)-y(k))*work(k) - (y(k)-y(k-1))*work(k-1)
244 amat(idiag,k) = 1.d0/work(k-1) / 3.d0
245 + + 2.d0*ztaueff*work(k-1)**2
246 y2(k) = - (y(k)-y(k-1))*work(k-1)
251 IF (yp1 .GT. .99d30)
THEN
255 amat(idiag-1,2) = 0.d0
256 IF (iup .EQ. 2) amat(idiag-2,3) = 0.d0
258 ELSE IF (-yp1 .GT. .99d+34)
THEN
259 zyp1 = (y(2)-y(1))/(x(2)-x(1))
260 ELSE IF (-yp1 .GT. .99d+30)
THEN
261 zyp1 = fcccc1(y(1),y(2),y(3),y(4),x(1),x(2),x(3),x(4),x(1))
265 IF (ypn .GT. .99d30)
THEN
269 amat(idiag-1,n) = 0.d0
270 IF (iup .EQ. 2) amat(idiag-2,n) = 0.d0
272 ELSE IF (-ypn .GT. .99d+34)
THEN
273 zypn = (y(n)-y(n-1))/(x(n)-x(n-1))
274 ELSE IF (-ypn .GT. .99d+30)
THEN
275 zypn = fcccc1(y(n-3),y(n-2),y(n-1),y(n),
276 + x(n-3),x(n-2),x(n-1),x(n),x(n))
309 DO j=max(1,i),min(i+iup,n)
310 anonsym((i-1)*iband+j-i+iup+1) = amat(idiag+i-j,j)
313 DO j=max(1,i-iup),min(i-1,n-1)
314 anonsym((i-1)*iband+j-i+iup+1) = amat(idiag+j-i,i)
317 CALL
nonsym(anonsym,amat,y2,n,iup,iup,1.0d-06,info2)
322 IF (ztaueff .NE. 0.d0)
THEN
325 ynew(k) = y(k) - ztaueff* ((y2(k+1)-y2(k))*work(k)
326 + - (y2(k)-y2(k-1))*work(k-1))
328 ynew(1) = y(1) - ztaueff * (y2(2)-y2(1))*work(1)
329 ynew(n) = y(n) + ztaueff * (y2(n)-y2(n-1))*work(n-1)
333 IF (info2 .LT. 0)
THEN
334 print *,
' ERROR IN SPBTRS: INFO2 = ',info2
343 IMPLICIT REAL*8(a-h,o-z)
346 dimension x(n),y(n),y2(n),u(nmax)
349 print *,
' NMAX TOO SMALL IN SPLINE: N,NMAX= ',n,nmax
352 IF (yp1.GT..99d30)
THEN
357 IF (-yp1 .GT. .99d+30)
THEN
358 yp1 = (y(2)-y(1))/(x(2)-x(1))
362 u(1)=(3.d0/(x(2)-x(1)))*((y(2)-y(1))/(x(2)-x(1))-yp1)
365 sig=(x(i)-x(i-1))/(x(i+1)-x(i-1))
368 u(i)=(6.d0*((y(i+1)-y(i))/(x(i+1)-x(i))-(y(i)-y(i-1))
369 * /(x(i)-x(i-1)))/(x(i+1)-x(i-1))-sig*u(i-1))/
p
371 IF (ypn.GT..99d30)
THEN
376 IF (-ypn .GT. .99d+30)
THEN
377 ypn = (y(n)-y(n-1))/(x(n)-x(n-1))
381 un=(3./(x(n)-x(n-1)))*(ypn-(y(n)-y(n-1))/(x(n)-x(n-1)))
383 y2(n)=(un-qn*u(n-1))/(qn*y2(n-1)+1.)
385 y2(k)=y2(k)*y2(k+1)+u(k)
390 SUBROUTINE splint(XA,YA,Y2A,N,X,Y,YP,YPP)
392 IMPLICIT REAL*8(a-h,o-z)
394 dimension xa(n),ya(n),y2a(n)
397 1
IF (khi-klo.GT.1)
THEN
407 IF (h.EQ.0.) stop
'BAD XA INPUT.'
410 y=a*ya(klo)+b*ya(khi)+
411 * ((a**3-a)*y2a(klo)+(b**3-b)*y2a(khi))*(h**2)/6.
412 yp=(ya(khi)-ya(klo))/h -
413 - ( (3.*a*a-1.)*y2a(klo) - (3.*b*b-1.)*y2a(khi) )*h/6.
414 ypp=a*y2a(klo)+b*y2a(khi)
420 IMPLICIT REAL*8(a-h,o-z)
422 dimension xa(n),ya(n),y2a(n)
437 fc3(x1,f1,p1,x2,f2,p2) =
438 = (2.d0* (f2 - f1) / (x1 - x2) + (p1 + p2)) /
439 / ((x1 - x2) * (x1 - x2))
440 fc2(x1,f1,p1,x2,f2,p2) =
441 = (3.d0* (x1 + x2) * (f1 - f2) / (x1 - x2) -
442 * p1 * (x1 + 2.d0* x2) - p2 * (x2 + 2.d0* x1)) /
443 / ((x1 - x2) * (x1 - x2))
444 fc1(x1,f1,p1,x2,f2,p2) =
445 = (6.d0* x1 * x2 * (f2 - f1) / (x1 - x2) +
446 * x2 * p1 * (2 * x1 + x2) + x1 * p2 * (x1 + 2.d0* x2)) /
447 / ((x1 - x2) * (x1 - x2))
448 fc0(x1,f1,p1,x2,f2,p2) =
449 = (f1 * x2**2 + f2 * x1**2 - x1 * x2 * (x2 * p1 + x1 * p2) +
450 + 2.d0* x1 * x2 * (f1 * x2 - f2 * x1) / (x1 - x2)) /
451 / ((x1 - x2) * (x1 - x2))
456 fcdcd0(x1,f1,p1,x2,f2,p2,px) =
457 = fc0(x1,f1,p1,x2,f2,p2) +
458 + px * (fc1(x1,f1,p1,x2,f2,p2) +
459 + px * (fc2(x1,f1,p1,x2,f2,p2) +
460 + px * fc3(x1,f1,p1,x2,f2,p2)))
465 fcdcd1(x1,f1,p1,x2,f2,p2,px) =
466 = fc1(x1,f1,p1,x2,f2,p2) +
467 + px * (2.d0* fc2(x1,f1,p1,x2,f2,p2) +
468 + 3.d0* px * fc3(x1,f1,p1,x2,f2,p2))
473 fcdcd2(x1,f1,p1,x2,f2,p2,px) =
474 = 2.d0* fc2(x1,f1,p1,x2,f2,p2) +
475 + 6.d0* fc3(x1,f1,p1,x2,f2,p2) * px
480 fcdcd3(x1,f1,p1,x2,f2,p2,px) =
481 = 6.d0* fc3(x1,f1,p1,x2,f2,p2)
493 fd2(x1,f1,p1,x2,f2) = ((f2-f1)/(x2-x1) - p1) / (x2-x1)
494 fd1(x1,f1,p1,x2,f2) = p1 - 2.*x1*fd2(x1,f1,p1,x2,f2)
495 fd0(x1,f1,p1,x2,f2) = f1 - x1*(x1*fd2(x1,f1,p1,x2,f2) +
496 + fd1(x1,f1,p1,x2,f2))
501 fqdq0(x1,f1,p1,x2,f2,px) = fd0(x1,f1,p1,x2,f2) +
502 f px * (fd1(x1,f1,p1,x2,f2) +
503 f px * fd2(x1,f1,p1,x2,f2))
508 fqdq1(x1,f1,p1,x2,f2,px) = fd1(x1,f1,p1,x2,f2) +
509 f 2.* px * fd2(x1,f1,p1,x2,f2)
514 fqdq2(x1,f1,p1,x2,f2) = 2.d0* fd2(x1,f1,p1,x2,f2)
519 1
IF (khi-klo.GT.1)
THEN
529 IF (h.EQ.0.) stop
'BAD XA INPUT.'
532 y=a*ya(klo)+b*ya(khi)+
533 * ((a**3-a)*y2a(klo)+(b**3-b)*y2a(khi))*(h**2)/6.
534 yp=(ya(khi)-ya(klo))/h -
535 - ( (3.*a*a-1.)*y2a(klo) - (3.*b*b-1.)*y2a(khi) )*h/6.
536 ypp=a*y2a(klo)+b*y2a(khi)
538 IF (kopt .EQ. 0)
RETURN
546 IF (kopt .EQ. 1)
THEN
548 if (b.lt. -zepsilon)
then
549 print *,
' warning points outside interval at left.',
550 +
' Use quadratic interpolation'
553 ypaklo=(ya(khi)-ya(klo))/h -
554 - ( (3.d0*a*a-1.d0)*y2a(klo) - (3.d0*b*b-1.d0)*y2a(khi) )*h/6.d0
557 ypakhi=(ya(khi)-ya(klo))/h -
558 - ( (3.d0*a*a-1.d0)*y2a(klo) - (3.d0*b*b-1.d0)*y2a(khi) )*h/6.d0
559 y=fqdq0(xa(klo),ya(klo),ypaklo,xa(khi),ya(khi),x)
560 yp=fqdq1(xa(klo),ya(klo),ypaklo,xa(khi),ya(khi),x)
561 ypp=fqdq2(xa(klo),ya(klo),ypaklo,xa(khi),ya(khi))
564 if (a .lt. -zepsilon)
then
565 print *,
' warning points outside interval at right.',
566 +
' Use quadratic interpolation'
569 ypaklo=(ya(khi)-ya(klo))/h -
570 - ( (3.d0*a*a-1.d0)*y2a(klo) - (3.d0*b*b-1.d0)*y2a(khi) )*h/6.d0
573 ypakhi=(ya(khi)-ya(klo))/h -
574 - ( (3.d0*a*a-1.d0)*y2a(klo) - (3.d0*b*b-1.d0)*y2a(khi) )*h/6.d0
575 y=fqdq0(xa(khi),ya(khi),ypakhi,xa(klo),ya(klo),x)
576 yp=fqdq1(xa(khi),ya(khi),ypakhi,xa(klo),ya(klo),x)
577 ypp=fqdq2(xa(khi),ya(khi),ypakhi,xa(klo),ya(klo))
585 IF (kopt .EQ. 2)
THEN
587 if (a.lt.-zepsilon .OR. b.LT.-zepsilon)
then
588 print *,
' warning points outside interval.',
589 +
' Use cubic interpolation'
592 ypaklo=(ya(khi)-ya(klo))/h -
593 - ( (3.d0*a*a-1.d0)*y2a(klo) - (3.d0*b*b-1.d0)*y2a(khi) )*h/6.d0
596 ypakhi=(ya(khi)-ya(klo))/h -
597 - ( (3.d0*a*a-1.d0)*y2a(klo) - (3.d0*b*b-1.d0)*y2a(khi) )*h/6.d0
598 y=fcdcd0(xa(klo),ya(klo),ypaklo,xa(khi),ya(khi),ypakhi,x)
599 yp=fcdcd1(xa(klo),ya(klo),ypaklo,xa(khi),ya(khi),ypakhi,x)
600 ypp=fcdcd2(xa(klo),ya(klo),ypaklo,xa(khi),ya(khi),ypakhi,x)
610 SUBROUTINE nonsym(A,X,C,N,MLEFT,MRIGHT,EPS,NCOND)
620 IMPLICIT REAL*8(a-h,o-z)
622 dimension a(n*(mleft+mright+1)), x(n), c(n)
624 REAL*8 a, x, c, zpivot, zsum, ztop
664 ipiv2=ipiv1+(n-1)*mband
665 DO 10 j=ipiv1,ipiv2,mband
667 IF( abs(a(j)) .EQ. 0.d0) go to 510
674 jpabs=(mleft+1)+(jp-1)*mband
676 x(jp)=sqrt(abs(a(jpabs)))
679 DO 110 j=-mleft,mright
680 a(jpabs+j)=a(jpabs+j)/x(jp)
685 DO 120 ja=jpabs-mright*moffdi,jpabs+mleft*moffdi,moffdi
686 IF (ja.GE.ipiv1 .AND. ja.LE.ipiv2) a(ja)=a(ja)/x(jp)
696 incmpl=(n-mleft)*mband+mleft+1
699 ipiv2=ipiv1+(n-2)*mband
701 DO 220 jpivot=ipiv1,ipiv2,mband
703 IF(jpivot.GE.incmpl) idown=idown-1
710 DO 205 jhoriz=ihor1,ihor2
712 zmax=amax1(zmax, abs(a(jhoriz)))
715 IF( abs(zpivot).EQ.0.d0) go to 510
717 ratio=amax1(ratio,zmax/ abs(zpivot))
719 DO 210 jhoriz=ihor1,ihor2
720 ztop=-a(jhoriz)/zpivot
730 a(ielem)=a(ielem)+ztop*a(icorn)
735 iconst=jpivot/mband+1
736 ztop=-c(iconst)/zpivot
744 c(iconst)=c(iconst)+ztop*a(icorn)
759 IF( abs(a(jpivot)).EQ.0.d0) go to 510
761 c(isolut)=c(isolut)/a(jpivot)
773 DO 310 jhoriz=ihor1,ihor2
775 IF(iknown.GT.n) go to 310
776 zsum=zsum+a(jhoriz)*c(iknown)
792 IF(ratio .LT. 1.d0/eps)
RETURN
796 IF(imess.LE.10) print 9500, ratio
802 stop
'ZERO PIVOT IN NONCYM'
808 9500
FORMAT(/////20x,10(1h*),21h message from noncym,2x,10(1h*)///
809 + 20x,
'BAD PIVOT ENCOUNTERED, RATIO: ',1pe12.3///
811 9510
FORMAT(/////20x,10(1h*),
' ZERO PIVOT IN NONCYM'///)
subroutine splintend(XA, YA, Y2A, N, X, Y, YP, YPP, KOPT)
subroutine nonsym(A, X, C, N, MLEFT, MRIGHT, EPS, NCOND)
subroutine spline(N, X, Y, ALFA, BETA, TYP, A, B, C, D)
subroutine cubsplfit(X, Y, YNEW, N, YP1, YPN, Y2, TAUS, WORK, AMAT, MDAMAT)
real(r8) function b2(a, x, xr, xs, yr, ys, psi, psir, F_dia)
real(r8) function p(a, x, xr, xs, yr, ys, psi, psir, F_dia)
subroutine splint(XA, YA, Y2A, N, X, Y, YP, YPP)
subroutine intrptau(PXIN, PYIN, PYINNEW, PY2, KNIN, PXOUT, PYOUT, PYOUTP, PYOUTPP, KNOUT, KOPT, PTAUS, PWORK, PAMAT, MDAMAT, PBCLFT, PBCRGT)