V3FIT
intdy.f
1  SUBROUTINE intdy(t, k, yh, nyh, dky, iflag)
2  USE stel_kinds
3  IMPLICIT NONE
4 C-----------------------------------------------
5 C D u m m y A r g u m e n t s
6 C-----------------------------------------------
7  INTEGER k, nyh, iflag
8  REAL(rprec) t
9  REAL(rprec), DIMENSION(nyh,*) :: yh
10  REAL(rprec), DIMENSION(*) :: dky
11 C-----------------------------------------------
12 C C o m m o n B l o c k s
13 C-----------------------------------------------
14 C... /ls0001/
15  COMMON /ls0001/ rowns(209), ccmax, el0, h, hmin, hmxi, hu, rc, tn
16  1 , uround, iownd(14), iowns(6), icf, ierpj, iersl, jcur, jstart
17  2 , kflag, l, meth, miter, maxord, maxcor, msbp, mxncf, n, nq,
18  3 nst, nfe, nje, nqu
19  INTEGER iownd, iowns, icf, ierpj, iersl, jcur, jstart, kflag, l
20  1 , meth, miter, maxord, maxcor, msbp, mxncf, n, nq, nst, nfe,
21  2 nje, nqu
22  REAL(rprec) ::rowns, ccmax, el0, h, hmin, hmxi, hu, rc, tn,
23  1 uround
24 C-----------------------------------------------
25 C L o c a l V a r i a b l e s
26 C-----------------------------------------------
27  REAL(rprec), PARAMETER :: zero = 0
28  INTEGER :: ic, j, jb, jb2, jj, jj1, jp1
29  REAL(rprec) :: c, r, s, tp
30 C-----------------------------------------------
31 clll. optimize
32 c-----------------------------------------------------------------------
33 c intdy computes interpolated values of the k-th derivative of the
34 c dependent variable vector y, and stores it in dky. this routine
35 c is called within the package with k = 0 and t = tout, but may
36 c also be called by the user for any k up to the current order.
37 c (see detailed instructions in the usage documentation.)
38 c-----------------------------------------------------------------------
39 c the computed values in dky are gotten by interpolation using the
40 c nordsieck history array yh. this array corresponds uniquely to a
41 c vector-valued polynomial of degree nqcur or less, and dky is set
42 c to the k-th derivative of this polynomial at t.
43 c the formula for dky is..
44 c q
45 c dky(i) = SUM c(j,k) * (t - tn)**(j-k) * h**(-j) * yh(i,j+1)
46 c j=k
47 c where c(j,k) = j*(j-1)*...*(j-k+1), q = nqcur, tn = tcur, h = hcur.
48 c the quantities nq = nqcur, l = nq+1, n = neq, tn, and h are
49 c communicated by common. the above sum is done in reverse order.
50 c iflag is returned negative if either k or t is out of bounds.
51 c-----------------------------------------------------------------------
52  iflag = 0
53  IF (k>=0 .and. k<=nq) THEN
54  tp = tn - hu - 100*uround*(tn + hu)
55  IF ((t - tp)*(t - tn) > zero) GOTO 90
56 c
57  s = (t - tn)/h
58  ic = 1
59  IF (k /= 0) THEN
60  jj1 = l - k
61  DO jj = jj1, nq
62  ic = ic*jj
63  END DO
64  END IF
65  c = ic
66  dky(:n) = c*yh(:n,l)
67  IF (k .ne. nq) THEN
68  jb2 = nq - k
69  DO jb = 1, jb2
70  j = nq - jb
71  jp1 = j + 1
72  ic = 1
73  IF (k /= 0) THEN
74  jj1 = jp1 - k
75  DO jj = jj1, j
76  ic = ic*jj
77  END DO
78  END IF
79  c = ic
80  dky(:n) = c*yh(:n,jp1) + s*dky(:n)
81  END DO
82  IF (k == 0) RETURN
83  END IF
84  r = h**(-k)
85  dky(:n) = r*dky(:n)
86  RETURN
87 c
88  END IF
89  CALL xerrwv ('intdy-- k (=i1) illegal ', 30, 51, 0, 1, k, 0
90  1 , 0, zero, zero)
91  iflag = -1
92  RETURN
93  90 CONTINUE
94  CALL xerrwv ('intdy-- t (=r1) illegal ', 30, 52, 0, 0, 0, 0
95  1 , 1, t, zero)
96  CALL xerrwv (
97  1' t not in interval tcur - hu (= r1) to tcur (=r2) ',
98  2 60, 52, 0, 0, 0, 0, 2, tp, tn)
99  iflag = -2
100 
101  END SUBROUTINE intdy