Add some basic letsimp tests based on bug #3950
[maxima.git] / share / colnew / fortran / skale.f
blob780af966f6e62fbd346c01d600d6c81852eb15bf
1 SUBROUTINE SKALE (N, MSTAR, KD, Z, XI, SCALE, DSCALE)
3 C**********************************************************************
5 C purpose
6 C provide a proper scaling of the state variables, used
7 C to control the damping factor for a newton iteration [2].
9 C variables
11 C n = number of mesh subintervals
12 C mstar = number of unknomns in z(u(x))
13 C kd = number of unknowns in dmz
14 C z = the global unknown vector
15 C xi = the current mesh
16 C scale = scaling vector for z
17 C dscale = scaling vector for dmz
19 C**********************************************************************
21 IMPLICIT REAL*8 (A-H,O-Z)
22 DIMENSION Z(MSTAR,1), SCALE(MSTAR,1), DSCALE(KD,1)
23 DIMENSION XI(1), BASM(5)
25 COMMON /COLORD/ K, NCOMP, ID1, ID2, MMAX, M(20)
27 BASM(1) = 1.D0
28 DO 50 J=1,N
29 IZ = 1
30 H = XI(J+1) - XI(J)
31 DO 10 L = 1, MMAX
32 BASM(L+1) = BASM(L) * H / DFLOAT(L)
33 10 CONTINUE
34 DO 40 ICOMP = 1, NCOMP
35 SCAL = (DABS(Z(IZ,J)) + DABS(Z(IZ,J+1))) * .5D0 + 1.D0
36 MJ = M(ICOMP)
37 DO 20 L = 1, MJ
38 SCALE(IZ,J) = BASM(L) / SCAL
39 IZ = IZ + 1
40 20 CONTINUE
41 SCAL = BASM(MJ+1) / SCAL
42 DO 30 IDMZ = ICOMP, KD, NCOMP
43 DSCALE(IDMZ,J) = SCAL
44 30 CONTINUE
45 40 CONTINUE
46 50 CONTINUE
47 NP1 = N + 1
48 DO 60 IZ = 1, MSTAR
49 SCALE(IZ,NP1) = SCALE(IZ,N)
50 60 CONTINUE
51 RETURN
52 END