Statistiques
| Révision :

root / src / Check_step.f90 @ 2

Historique | Voir | Annoter | Télécharger (4,88 ko)

1 1 pfleura2
! This subroutine checks that the required step fulfills some conditions:
2 1 pfleura2
! v1.0
3 1 pfleura2
! Only valence angles are checked to remain in to 0:Pi range.
4 1 pfleura2
5 2 pfleura2
SUBROUTINE Check_step(Coord,Nat,NCoord,GeomOld,Step)
6 1 pfleura2
7 1 pfleura2
  Use Path_module, only : pi,ncart
8 1 pfleura2
9 1 pfleura2
  IMPLICIT NONE
10 1 pfleura2
11 1 pfleura2
12 1 pfleura2
  INTEGER, PARAMETER :: KINT=KIND(1)
13 1 pfleura2
  INTEGER, PARAMETER :: KREAL=KIND(1.D0)
14 1 pfleura2
15 2 pfleura2
  INTEGER(KINT), INTENT(IN) :: Nat,NCoord
16 1 pfleura2
  CHARACTER(32), INTENT(IN) :: Coord
17 1 pfleura2
  REAL(KREAL), INTENT(INOUT) :: Step(NCoord)
18 1 pfleura2
  REAL(KREAL), INTENT(IN) :: GeomOld(NCoord)
19 1 pfleura2
20 1 pfleura2
  ! As this subroutine is here for debugging, debug=T !
21 1 pfleura2
  LOGICAL, PARAMETER :: debug=.TRUE.
22 1 pfleura2
23 2 pfleura2
24 1 pfleura2
  ! Variables
25 1 pfleura2
  INTEGER(KINT) :: IBeg, Idx,Iat
26 1 pfleura2
  REAL(KREAL) ::  Fact
27 1 pfleura2
28 1 pfleura2
  ! Parameters
29 1 pfleura2
  REAL(KREAL),PARAMETER :: eps=1e-8
30 1 pfleura2
31 1 pfleura2
  INTERFACE
32 1 pfleura2
     function valid(string) result (isValid)
33 1 pfleura2
       CHARACTER(*), intent(in) :: string
34 1 pfleura2
       logical                  :: isValid
35 1 pfleura2
     END function VALID
36 1 pfleura2
  END INTERFACE
37 1 pfleura2
38 1 pfleura2
  if (.NOT.Valid("CheckStep")) RETURN
39 1 pfleura2
40 1 pfleura2
  if (nat.LE.2) THEN
41 1 pfleura2
     if (debug) WRITE(*,*) "Check-Step useless for 2 or less atoms !"
42 1 pfleura2
     return
43 1 pfleura2
  END IF
44 1 pfleura2
45 1 pfleura2
  if (debug) WRITE(*,*) "=========================== Entering Check_Step ===================="
46 1 pfleura2
47 1 pfleura2
  Fact=1.d0
48 1 pfleura2
49 1 pfleura2
  SELECT CASE(COORD)
50 1 pfleura2
  CASE ('ZMAT')
51 1 pfleura2
     Idx=3
52 1 pfleura2
     IF (STEP(Idx).GT.Eps) THEN
53 1 pfleura2
        If (GeomOld(Idx)+Step(Idx).GE.Pi) THEN
54 1 pfleura2
           Fact=min(Fact,0.999d0*(Pi-GeomOld(Idx))/Step(Idx))
55 1 pfleura2
           WRITE(*,*) "WARNING: Step reduced to prevent valence angle >=180. Idx=",Idx
56 1 pfleura2
        END IF
57 1 pfleura2
        If (GeomOld(Idx)+Step(Idx).LE.0) THEN
58 1 pfleura2
           Fact=min(Fact,abs(0.999d0*GeomOld(Idx)/Step(Idx)))
59 1 pfleura2
           WRITE(*,*) "WARNING: Step reduced to prevent valence angle <=0. Idx=",Idx
60 1 pfleura2
        END IF
61 1 pfleura2
     END IF
62 1 pfleura2
     If (Nat.GT.3) THEN
63 1 pfleura2
        Idx=5
64 1 pfleura2
        IF (STEP(Idx).GE.Eps) THEN
65 1 pfleura2
           If (GeomOld(Idx)+Step(Idx).GE.Pi) THEN
66 1 pfleura2
              Fact=min(Fact,0.999d0*(Pi-GeomOld(Idx))/Step(Idx))
67 1 pfleura2
              WRITE(*,*) "WARNING: Step reduced to prevent valence angle >=180. Idx=",Idx
68 1 pfleura2
           END IF
69 1 pfleura2
           If (GeomOld(Idx)+Step(Idx).LE.0) THEN
70 1 pfleura2
              Fact=min(Fact,abs(0.999d0*GeomOld(Idx)/Step(Idx)))
71 1 pfleura2
              WRITE(*,*) "WARNING: Step reduced to prevent valence angle <=0. Idx=",Idx
72 1 pfleura2
           END IF
73 1 pfleura2
        END IF
74 1 pfleura2
        DO Iat=5,Nat
75 1 pfleura2
           Idx=Idx+3
76 1 pfleura2
           IF (STEP(Idx).GE.Eps) THEN
77 1 pfleura2
              If (GeomOld(Idx)+Step(Idx).GE.Pi) THEN
78 1 pfleura2
                 Fact=min(Fact,0.999d0*(Pi-GeomOld(Idx))/Step(Idx))
79 1 pfleura2
                 WRITE(*,*) "WARNING: Step reduced to prevent valence angle >=180. Idx=",Idx
80 1 pfleura2
              END IF
81 1 pfleura2
              If (GeomOld(Idx)+Step(Idx).LE.0) THEN
82 1 pfleura2
                 Fact=min(Fact,abs(0.999d0*GeomOld(Idx)/Step(Idx)))
83 1 pfleura2
                 WRITE(*,*) "WARNING: Step reduced to prevent valence angle <=0. Idx=",Idx
84 1 pfleura2
              END IF
85 1 pfleura2
           END IF
86 1 pfleura2
        END DO
87 1 pfleura2
     END IF
88 1 pfleura2
89 1 pfleura2
  CASE ('MIXED')
90 1 pfleura2
     SELECT CASE (NCart)
91 1 pfleura2
     CASE (1:2)
92 1 pfleura2
        Idx=3
93 1 pfleura2
        IF (STEP(Idx).GE.Eps) THEN
94 1 pfleura2
           If (GeomOld(Idx)+Step(Idx).GE.Pi) THEN
95 1 pfleura2
              Fact=min(Fact,0.999d0*(Pi-GeomOld(Idx))/Step(Idx))
96 1 pfleura2
              WRITE(*,*) "WARNING: Step reduced to prevent valence angle >=180. Idx=",Idx
97 1 pfleura2
           END IF
98 1 pfleura2
           If (GeomOld(Idx)+Step(Idx).LE.0) THEN
99 1 pfleura2
              Fact=min(Fact,abs(0.999d0*GeomOld(Idx)/Step(Idx)))
100 1 pfleura2
              WRITE(*,*) "WARNING: Step reduced to prevent valence angle <=0. Idx=",Idx
101 1 pfleura2
           END IF
102 1 pfleura2
        END IF
103 1 pfleura2
        IF (Nat.GT.3) THEN
104 1 pfleura2
           Idx=5
105 1 pfleura2
           IF (STEP(Idx).GE.Eps) THEN
106 1 pfleura2
              If (GeomOld(Idx)+Step(Idx).GE.Pi) THEN
107 1 pfleura2
                 Fact=min(Fact,0.999d0*(Pi-GeomOld(Idx))/Step(Idx))
108 1 pfleura2
                 WRITE(*,*) "WARNING: Step reduced to prevent valence angle >=180. Idx=",Idx
109 1 pfleura2
              END IF
110 1 pfleura2
              If (GeomOld(Idx)+Step(Idx).LE.0) THEN
111 1 pfleura2
                 Fact=min(Fact,abs(0.999d0*GeomOld(Idx)/Step(Idx)))
112 1 pfleura2
                 WRITE(*,*) "WARNING: Step reduced to prevent valence angle <=0. Idx=",Idx
113 1 pfleura2
              END IF
114 1 pfleura2
           END IF
115 1 pfleura2
        END IF
116 1 pfleura2
        IBeg=5
117 1 pfleura2
     CASE (3:)
118 1 pfleura2
        IBeg=NCart+1
119 1 pfleura2
        Idx=3*Ncart+2
120 1 pfleura2
121 1 pfleura2
     END SELECT
122 1 pfleura2
     DO Iat=5,Nat
123 1 pfleura2
        IF (STEP(Idx).GE.Eps) THEN
124 1 pfleura2
           If (GeomOld(Idx)+Step(Idx).GE.Pi) THEN
125 1 pfleura2
              Fact=min(Fact,0.999d0*(Pi-GeomOld(Idx))/Step(Idx))
126 1 pfleura2
              WRITE(*,*) "WARNING: Step reduced to prevent valence angle >=180. Idx=",Idx
127 1 pfleura2
           END IF
128 1 pfleura2
           If (GeomOld(Idx)+Step(Idx).LE.0) THEN
129 1 pfleura2
              Fact=min(Fact,abs(0.999d0*GeomOld(Idx)/Step(Idx)))
130 1 pfleura2
              WRITE(*,*) "WARNING: Step reduced to prevent valence angle <=0. Idx=",Idx
131 1 pfleura2
           END IF
132 1 pfleura2
        END IF
133 1 pfleura2
        Idx=Idx+3
134 1 pfleura2
     END DO
135 1 pfleura2
136 1 pfleura2
  CASE ('CART','HYBRID','BAKER')
137 1 pfleura2
     if (debug) WRITE(*,*) "DBG Check_step:  Check useless for COORD=",TRIM(COORD)
138 1 pfleura2
  CASE DEFAULT
139 1 pfleura2
     WRITE(*,*) "COORD=",TRIM(COORD)," Not recognized in Check_step"
140 1 pfleura2
     STOP
141 1 pfleura2
  END SELECT
142 1 pfleura2
143 1 pfleura2
  If (debug) WRITE(*,*) "Check_Step: Fact=",Fact
144 1 pfleura2
  Step=Step*Fact
145 1 pfleura2
146 1 pfleura2
  if (debug) WRITE(*,*) "=========================== Exiting Check_Step ===================="
147 1 pfleura2
148 1 pfleura2
END SUBROUTINE Check_step