- Timestamp:
- Dec 18, 2009, 3:51:22 PM (15 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
LMDZ4/trunk/libf/filtrez/jacobi.F90
r1287 r1289 1 1 ! 2 ! $ Header$2 ! $Id$ 3 3 ! 4 4 SUBROUTINE JACOBI(A,N,NP,D,V,NROT) 5 PARAMETER (NMAX=400) 6 DIMENSION A(NP,NP),D(NP),V(NP,NP),B(NMAX),Z(NMAX) 7 IF (n.gt.nmax) THEN 8 print*, 'n, nmax=', n, nmax 9 print*, 'Surdimensionnement insuffisant dans jacobi' 10 CALL abort 11 ENDIF 12 DO 12 IP=1,N 13 DO 11 IQ=1,N 5 implicit none 6 ! Arguments: 7 integer,intent(in) :: N 8 integer,intent(in) :: NP 9 integer,intent(out) :: NROT 10 real,intent(inout) :: A(NP,NP) 11 real,intent(out) :: D(NP) 12 real,intent(out) :: V(NP,NP) 13 14 ! local variables: 15 integer :: IP,IQ,I,J 16 real :: SM,TRESH,G,H,T,THETA,C,S,TAU 17 real :: B(N) 18 real :: Z(N) 19 20 DO IP=1,N 21 DO IQ=1,N 14 22 V(IP,IQ)=0. 15 11 CONTINUE 23 ENDDO 16 24 V(IP,IP)=1. 17 12 CONTINUE 18 DO 13IP=1,N25 ENDDO 26 DO IP=1,N 19 27 B(IP)=A(IP,IP) 20 28 D(IP)=B(IP) 21 29 Z(IP)=0. 22 13 CONTINUE 30 ENDDO 23 31 NROT=0 24 DO 24 I=1,50 32 DO I=1,50 ! 50? I suspect this should be NP 33 ! but convergence is fast enough anyway 25 34 SM=0. 26 DO 15IP=1,N-127 DO 14IQ=IP+1,N35 DO IP=1,N-1 36 DO IQ=IP+1,N 28 37 SM=SM+ABS(A(IP,IQ)) 29 14 CONTINUE 30 15 CONTINUE 38 ENDDO 39 ENDDO 31 40 IF(SM.EQ.0.)RETURN 32 41 IF(I.LT.4)THEN … … 35 44 TRESH=0. 36 45 ENDIF 37 DO 22IP=1,N-138 DO 21IQ=IP+1,N46 DO IP=1,N-1 47 DO IQ=IP+1,N 39 48 G=100.*ABS(A(IP,IQ)) 40 IF((I.GT.4).AND.(ABS(D(IP))+G.EQ.ABS(D(IP))) 41 *.AND.(ABS(D(IQ))+G.EQ.ABS(D(IQ))))THEN49 IF((I.GT.4).AND.(ABS(D(IP))+G.EQ.ABS(D(IP))) & 50 .AND.(ABS(D(IQ))+G.EQ.ABS(D(IQ))))THEN 42 51 A(IP,IQ)=0. 43 52 ELSE IF(ABS(A(IP,IQ)).GT.TRESH)THEN … … 59 68 D(IQ)=D(IQ)+H 60 69 A(IP,IQ)=0. 61 DO 16J=1,IP-170 DO J=1,IP-1 62 71 G=A(J,IP) 63 72 H=A(J,IQ) 64 73 A(J,IP)=G-S*(H+G*TAU) 65 74 A(J,IQ)=H+S*(G-H*TAU) 66 16 CONTINUE 67 DO 17J=IP+1,IQ-175 ENDDO 76 DO J=IP+1,IQ-1 68 77 G=A(IP,J) 69 78 H=A(J,IQ) 70 79 A(IP,J)=G-S*(H+G*TAU) 71 80 A(J,IQ)=H+S*(G-H*TAU) 72 17 CONTINUE 73 DO 18J=IQ+1,N81 ENDDO 82 DO J=IQ+1,N 74 83 G=A(IP,J) 75 84 H=A(IQ,J) 76 85 A(IP,J)=G-S*(H+G*TAU) 77 86 A(IQ,J)=H+S*(G-H*TAU) 78 18 CONTINUE 79 DO 19J=1,N87 ENDDO 88 DO J=1,N 80 89 G=V(J,IP) 81 90 H=V(J,IQ) 82 91 V(J,IP)=G-S*(H+G*TAU) 83 92 V(J,IQ)=H+S*(G-H*TAU) 84 19 CONTINUE 93 ENDDO 85 94 NROT=NROT+1 86 95 ENDIF 87 21 CONTINUE 88 22 CONTINUE 89 DO 23IP=1,N96 ENDDO 97 ENDDO 98 DO IP=1,N 90 99 B(IP)=B(IP)+Z(IP) 91 100 D(IP)=B(IP) 92 101 Z(IP)=0. 93 23 CONTINUE 94 24 CONTINUE 95 STOP ' 50 iterations should never happen'102 ENDDO 103 ENDDO ! of DO I=1,50 104 STOP 'Jacobi: 50 iterations should never happen' 96 105 RETURN 97 END 106 END SUBROUTINE JACOBI
Note: See TracChangeset
for help on using the changeset viewer.