/[lmdze]/trunk/filtrez/jacobi.f
ViewVC logotype

Annotation of /trunk/filtrez/jacobi.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 81 - (hide annotations)
Wed Mar 5 14:38:41 2014 UTC (10 years, 2 months ago) by guez
Original Path: trunk/filtrez/jacobi.f90
File size: 2427 byte(s)
 Converted to free source form files which were still in fixed source
form. The conversion was done using the polish mode of the NAG Fortran
Compiler.

In addition to converting to free source form, the processing of the
files also:

-- indented the code (including comments);

-- set Fortran keywords to uppercase, and set all other identifiers
to lower case;

-- added qualifiers to end statements (for example "end subroutine
conflx", instead of "end");

-- changed the terminating statements of all DO loops so that each
loop ends with an ENDDO statement (instead of a labeled continue).

1 guez 81
2     ! $Header: /home/cvsroot/LMDZ4/libf/filtrez/jacobi.F,v 1.1.1.1 2004/05/19
3     ! 12:53:09 lmdzadmin Exp $
4    
5     SUBROUTINE jacobi(a, n, np, d, v, nrot)
6     PARAMETER (nmax=400)
7     DIMENSION a(np, np), d(np), v(np, np), b(nmax), z(nmax)
8    
9     IF (n>nmax) THEN
10     PRINT *, 'n, nmax=', n, nmax
11     PRINT *, 'Surdimensionnement insuffisant dans jacobi'
12     STOP 1
13     END IF
14     DO ip = 1, n
15     DO iq = 1, n
16     v(ip, iq) = 0.
17     END DO
18     v(ip, ip) = 1.
19     END DO
20     DO ip = 1, n
21     b(ip) = a(ip, ip)
22     d(ip) = b(ip)
23     z(ip) = 0.
24     END DO
25     nrot = 0
26     DO i = 1, 50
27     sm = 0.
28     DO ip = 1, n - 1
29     DO iq = ip + 1, n
30     sm = sm + abs(a(ip,iq))
31     END DO
32     END DO
33     IF (sm==0.) RETURN
34     IF (i<4) THEN
35     tresh = 0.2*sm/n**2
36     ELSE
37     tresh = 0.
38     END IF
39     DO ip = 1, n - 1
40     DO iq = ip + 1, n
41     g = 100.*abs(a(ip,iq))
42     IF ((i>4) .AND. (abs(d(ip))+g==abs(d(ip))) .AND. (abs(d(iq))+g==abs( &
43     d(iq)))) THEN
44     a(ip, iq) = 0.
45     ELSE IF (abs(a(ip,iq))>tresh) THEN
46     h = d(iq) - d(ip)
47     IF (abs(h)+g==abs(h)) THEN
48     t = a(ip, iq)/h
49     ELSE
50     theta = 0.5*h/a(ip, iq)
51     t = 1./(abs(theta)+sqrt(1.+theta**2))
52     IF (theta<0.) t = -t
53     END IF
54     c = 1./sqrt(1+t**2)
55     s = t*c
56     tau = s/(1.+c)
57     h = t*a(ip, iq)
58     z(ip) = z(ip) - h
59     z(iq) = z(iq) + h
60     d(ip) = d(ip) - h
61     d(iq) = d(iq) + h
62     a(ip, iq) = 0.
63     DO j = 1, ip - 1
64     g = a(j, ip)
65     h = a(j, iq)
66     a(j, ip) = g - s*(h+g*tau)
67     a(j, iq) = h + s*(g-h*tau)
68     END DO
69     DO j = ip + 1, iq - 1
70     g = a(ip, j)
71     h = a(j, iq)
72     a(ip, j) = g - s*(h+g*tau)
73     a(j, iq) = h + s*(g-h*tau)
74     END DO
75     DO j = iq + 1, n
76     g = a(ip, j)
77     h = a(iq, j)
78     a(ip, j) = g - s*(h+g*tau)
79     a(iq, j) = h + s*(g-h*tau)
80     END DO
81     DO j = 1, n
82     g = v(j, ip)
83     h = v(j, iq)
84     v(j, ip) = g - s*(h+g*tau)
85     v(j, iq) = h + s*(g-h*tau)
86     END DO
87     nrot = nrot + 1
88     END IF
89     END DO
90     END DO
91     DO ip = 1, n
92     b(ip) = b(ip) + z(ip)
93     d(ip) = b(ip)
94     z(ip) = 0.
95     END DO
96     END DO
97     STOP '50 iterations should never happen'
98     RETURN
99     END SUBROUTINE jacobi

  ViewVC Help
Powered by ViewVC 1.1.21