root / src / Calc_zmat_constr_frag.f90
Historique | Voir | Annoter | Télécharger (68,26 ko)
1 | 1 | pfleura2 | SUBROUTINE Calc_Zmat_const_frag(na,atome,ind_zmat,val_zmat,x,y,z, & |
---|---|---|---|
2 | 1 | pfleura2 | r_cov,fact,frozen) |
3 | 1 | pfleura2 | |
4 | 1 | pfleura2 | ! |
5 | 1 | pfleura2 | ! This second version enables the user to freeze some atoms |
6 | 1 | pfleura2 | ! the frozen atoms indices are listed in the frozen array. |
7 | 1 | pfleura2 | ! |
8 | 1 | pfleura2 | ! The idea is surely too stupid to work all the time... but here it is |
9 | 1 | pfleura2 | ! we first construct the zmat using only the frozen atoms, and then |
10 | 1 | pfleura2 | ! we add the other atoms on top of the first ones... |
11 | 1 | pfleura2 | ! |
12 | 12 | pfleura2 | |
13 | 12 | pfleura2 | !---------------------------------------------------------------------- |
14 | 12 | pfleura2 | ! Copyright 2003-2014 Ecole Normale Sup?rieure de Lyon, |
15 | 12 | pfleura2 | ! Centre National de la Recherche Scientifique, |
16 | 12 | pfleura2 | ! Universit? Claude Bernard Lyon 1. All rights reserved. |
17 | 12 | pfleura2 | ! |
18 | 12 | pfleura2 | ! This work is registered with the Agency for the Protection of Programs |
19 | 12 | pfleura2 | ! as IDDN.FR.001.100009.000.S.P.2014.000.30625 |
20 | 12 | pfleura2 | ! |
21 | 12 | pfleura2 | ! Authors: P. Fleurat-Lessard, P. Dayal |
22 | 12 | pfleura2 | ! Contact: optnpath@gmail.com |
23 | 12 | pfleura2 | ! |
24 | 12 | pfleura2 | ! This file is part of "Opt'n Path". |
25 | 12 | pfleura2 | ! |
26 | 12 | pfleura2 | ! "Opt'n Path" is free software: you can redistribute it and/or modify |
27 | 12 | pfleura2 | ! it under the terms of the GNU Affero General Public License as |
28 | 12 | pfleura2 | ! published by the Free Software Foundation, either version 3 of the License, |
29 | 12 | pfleura2 | ! or (at your option) any later version. |
30 | 12 | pfleura2 | ! |
31 | 12 | pfleura2 | ! "Opt'n Path" is distributed in the hope that it will be useful, |
32 | 12 | pfleura2 | ! but WITHOUT ANY WARRANTY; without even the implied warranty of |
33 | 12 | pfleura2 | ! |
34 | 12 | pfleura2 | ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
35 | 12 | pfleura2 | ! GNU Affero General Public License for more details. |
36 | 12 | pfleura2 | ! |
37 | 12 | pfleura2 | ! You should have received a copy of the GNU Affero General Public License |
38 | 12 | pfleura2 | ! along with "Opt'n Path". If not, see <http://www.gnu.org/licenses/>. |
39 | 12 | pfleura2 | ! |
40 | 12 | pfleura2 | ! Contact The Office of Technology Licensing, valorisation@ens-lyon.fr, |
41 | 12 | pfleura2 | ! for commercial licensing opportunities. |
42 | 12 | pfleura2 | !---------------------------------------------------------------------- |
43 | 12 | pfleura2 | |
44 | 8 | pfleura2 | Use Path_module, only : max_Z, NMaxL, Nom |
45 | 1 | pfleura2 | Use Io_module |
46 | 1 | pfleura2 | |
47 | 1 | pfleura2 | IMPLICIT NONE |
48 | 1 | pfleura2 | |
49 | 1 | pfleura2 | |
50 | 1 | pfleura2 | CHARACTER(5) :: AtName |
51 | 1 | pfleura2 | integer(KINT) :: na,atome(na),ind_zmat(Na,5) |
52 | 1 | pfleura2 | INTEGER(KINT) :: idx_zmat(NA) |
53 | 1 | pfleura2 | real(KREAL) :: x(Na),y(Na),z(Na),fact |
54 | 1 | pfleura2 | real(KREAL) :: val_zmat(Na,3) |
55 | 1 | pfleura2 | real(KREAL) :: r_cov(0:Max_Z) |
56 | 1 | pfleura2 | ! Frozen contains the indices of frozen atoms |
57 | 1 | pfleura2 | INTEGER(KINT) :: Frozen(*),NFroz |
58 | 1 | pfleura2 | INTEGER(KINT), ALLOCATABLE :: FrozDist(:) ! na |
59 | 1 | pfleura2 | INTEGER(KINT) :: NbFrag,IdxFrag |
60 | 1 | pfleura2 | INTEGER(KINT), ALLOCATABLE :: Fragment(:),NbAtFrag(:) !na |
61 | 1 | pfleura2 | INTEGER(KINT), ALLOCATABLE :: FragAt(:,:) !na,na |
62 | 1 | pfleura2 | INTEGER(KINT), ALLOCATABLE :: FrozFrag(:,:) !na,3 |
63 | 1 | pfleura2 | ! INTEGER(KINT), ALLOCATABLE :: IdxFragAt(:) !na |
64 | 1 | pfleura2 | INTEGER(KINT), ALLOCATABLE :: FrozBlock(:,:) !(na,0:na) |
65 | 1 | pfleura2 | REAL(KREAL), ALLOCATABLE :: DistFroz(:) !na |
66 | 1 | pfleura2 | |
67 | 1 | pfleura2 | INTEGER(KINT) :: IdxCaFaire, IAfaire |
68 | 1 | pfleura2 | INTEGER(KINT), ALLOCATABLE :: LIAISONS(:,:) ! (Na,0:NMaxL) |
69 | 1 | pfleura2 | INTEGER(KINT), ALLOCATABLE :: LiaisonsBis(:,:) ! (Na,0:NMaxL) |
70 | 1 | pfleura2 | INTEGER(KINT), ALLOCATABLE :: LiaisonsIni(:,:) ! (Na,0:NMaxL) |
71 | 1 | pfleura2 | INTEGER(KINT), ALLOCATABLE :: CAFaire(:) ! (Na) |
72 | 1 | pfleura2 | |
73 | 1 | pfleura2 | |
74 | 1 | pfleura2 | real(KREAL) :: vx1,vy1,vz1,norm1 |
75 | 1 | pfleura2 | real(KREAL) :: vx2,vy2,vz2,norm2 |
76 | 1 | pfleura2 | real(KREAL) :: vx3,vy3,vz3,norm3 |
77 | 1 | pfleura2 | real(KREAL) :: vx4,vy4,vz4,norm4 |
78 | 1 | pfleura2 | real(KREAL) :: vx5,vy5,vz5,norm5 |
79 | 1 | pfleura2 | real(KREAL) :: val,val_d, d12, d13,d23,d |
80 | 12 | pfleura2 | Logical Debug, DebugGaussian |
81 | 1 | pfleura2 | LOGICAL, ALLOCATABLE :: DejaFait(:), FCaf(:) !(na) |
82 | 1 | pfleura2 | Logical, ALLOCATABLE :: FrozAt(:) !T if this atom is frozen |
83 | 1 | pfleura2 | LOGICAL F1213, F1223,F1323 |
84 | 1 | pfleura2 | |
85 | 1 | pfleura2 | |
86 | 1 | pfleura2 | INTEGER(KINT) :: I,J,n0,n1,n2,n3,n4,IAt,IL,JL,IFrag,ITmp, K, KMax |
87 | 1 | pfleura2 | INTEGER(KINT) :: IMax, I3,I1,Ip, IFragFroz |
88 | 1 | pfleura2 | INTEGER(KINT) :: I0, Izm, JAt,Izm0 |
89 | 1 | pfleura2 | |
90 | 12 | pfleura2 | REAL(KREAL), PARAMETER :: LocalNCart=0.d0 |
91 | 1 | pfleura2 | REAL(KREAL) :: sDihe, Pi |
92 | 1 | pfleura2 | |
93 | 1 | pfleura2 | INTERFACE |
94 | 1 | pfleura2 | function valid(string) result (isValid) |
95 | 1 | pfleura2 | CHARACTER(*), intent(in) :: string |
96 | 1 | pfleura2 | logical :: isValid |
97 | 1 | pfleura2 | END function VALID |
98 | 1 | pfleura2 | |
99 | 1 | pfleura2 | FUNCTION angle(v1x,v1y,v1z,norm1,v2x,v2y,v2z,norm2) |
100 | 1 | pfleura2 | use Path_module, only : Pi,KINT, KREAL |
101 | 1 | pfleura2 | real(KREAL) :: v1x,v1y,v1z,norm1 |
102 | 1 | pfleura2 | real(KREAL) :: v2x,v2y,v2z,norm2 |
103 | 1 | pfleura2 | real(KREAL) :: angle |
104 | 1 | pfleura2 | END FUNCTION ANGLE |
105 | 1 | pfleura2 | |
106 | 1 | pfleura2 | FUNCTION SinAngle(v1x,v1y,v1z,norm1,v2x,v2y,v2z,norm2) |
107 | 1 | pfleura2 | use Path_module, only : Pi,KINT, KREAL |
108 | 1 | pfleura2 | real(KREAL) :: v1x,v1y,v1z,norm1 |
109 | 1 | pfleura2 | real(KREAL) :: v2x,v2y,v2z,norm2 |
110 | 1 | pfleura2 | real(KREAL) :: SinAngle |
111 | 1 | pfleura2 | END FUNCTION SINANGLE |
112 | 1 | pfleura2 | |
113 | 1 | pfleura2 | |
114 | 1 | pfleura2 | FUNCTION angle_d(v1x,v1y,v1z,norm1,v2x,v2y,v2z,norm2,v3x,v3y,v3z,norm3) |
115 | 1 | pfleura2 | use Path_module, only : Pi,KINT, KREAL |
116 | 1 | pfleura2 | real(KREAL) :: v1x,v1y,v1z,norm1 |
117 | 1 | pfleura2 | real(KREAL) :: v2x,v2y,v2z,norm2 |
118 | 1 | pfleura2 | real(KREAL) :: v3x,v3y,v3z,norm3 |
119 | 1 | pfleura2 | real(KREAL) :: angle_d,ca,sa |
120 | 1 | pfleura2 | END FUNCTION ANGLE_D |
121 | 1 | pfleura2 | |
122 | 1 | pfleura2 | END INTERFACE |
123 | 1 | pfleura2 | |
124 | 1 | pfleura2 | |
125 | 1 | pfleura2 | |
126 | 1 | pfleura2 | Pi=dacos(-1.d0) |
127 | 1 | pfleura2 | debug=valid("calc_zmat_constr").OR.valid("calc_zmat_contr_frag") |
128 | 12 | pfleura2 | debugGaussian=valid("zmat_gaussian") |
129 | 1 | pfleura2 | |
130 | 1 | pfleura2 | if (debug) WRITE(*,*) "=============================== Entering Calc_zmat_contr_frag ========================" |
131 | 1 | pfleura2 | if (na.le.2) THEN |
132 | 1 | pfleura2 | WRITE(*,*) "I do not work for less than 2 atoms :-p" |
133 | 1 | pfleura2 | RETURN |
134 | 1 | pfleura2 | END IF |
135 | 1 | pfleura2 | |
136 | 1 | pfleura2 | ALLOCATE(FrozDist(Na),Fragment(na), NbAtFrag(na),FragAt(na,na)) |
137 | 1 | pfleura2 | ! ALLOCATE(FrozFrag(na,3), IdxFragAt(na), FrozBlock(na,0:na)) |
138 | 1 | pfleura2 | ALLOCATE(FrozFrag(na,3), FrozBlock(na,0:na)) |
139 | 1 | pfleura2 | ALLOCATE(DistFroz(na),Liaisons(na,0:NMaxL)) |
140 | 1 | pfleura2 | ALLOCATE(LiaisonsBis(na,0:NMaxL),LiaisonsIni(na,0:NMaxL)) |
141 | 1 | pfleura2 | ALLOCATE(CaFaire(na),DejaFait(Na),FCaf(na),FrozAt(na)) |
142 | 1 | pfleura2 | |
143 | 1 | pfleura2 | DO i=1,na |
144 | 1 | pfleura2 | DO J=1,5 |
145 | 1 | pfleura2 | Ind_Zmat(i,J)=0 |
146 | 1 | pfleura2 | END DO |
147 | 1 | pfleura2 | END DO |
148 | 1 | pfleura2 | |
149 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
150 | 1 | pfleura2 | ! |
151 | 1 | pfleura2 | ! Easy case : 3 or less atoms |
152 | 1 | pfleura2 | ! |
153 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
154 | 1 | pfleura2 | if (Na.eq.3) THEN |
155 | 1 | pfleura2 | d12=sqrt((x(1)-x(2))**2+(y(1)-y(2))**2+(z(1)-z(2))**2) |
156 | 1 | pfleura2 | d13=sqrt((x(1)-x(3))**2+(y(1)-y(3))**2+(z(1)-z(3))**2) |
157 | 1 | pfleura2 | d23=sqrt((x(3)-x(2))**2+(y(3)-y(2))**2+(z(3)-z(2))**2) |
158 | 1 | pfleura2 | F1213=(d12<=d13) |
159 | 1 | pfleura2 | F1323=(d13<=d23) |
160 | 1 | pfleura2 | F1223=(d12<=d23) |
161 | 1 | pfleura2 | if (debug) THEN |
162 | 1 | pfleura2 | WRITE(*,*) "DEBUG Calc_Zmat 3 atoms" |
163 | 1 | pfleura2 | WRITE(*,*) "d12,d13,d23:",d12,d13,d23 |
164 | 1 | pfleura2 | WRITE(*,*) "F1213,F1323,F1223:",F1213,F1323,F1223 |
165 | 1 | pfleura2 | END IF |
166 | 1 | pfleura2 | if (F1213) THEN |
167 | 1 | pfleura2 | if (F1323) THEN |
168 | 1 | pfleura2 | ind_zmat(1,1)=3 |
169 | 1 | pfleura2 | ind_zmat(2,1)=1 |
170 | 1 | pfleura2 | ind_zmat(2,2)=3 |
171 | 1 | pfleura2 | ind_zmat(3,1)=2 |
172 | 1 | pfleura2 | ind_zmat(3,2)=1 |
173 | 1 | pfleura2 | ind_zmat(3,3)=3 |
174 | 1 | pfleura2 | ELSE |
175 | 1 | pfleura2 | ind_zmat(1,1)=1 |
176 | 1 | pfleura2 | ind_zmat(2,1)=2 |
177 | 1 | pfleura2 | ind_zmat(2,2)=1 |
178 | 1 | pfleura2 | ind_zmat(3,1)=3 |
179 | 1 | pfleura2 | ind_zmat(3,2)=2 |
180 | 1 | pfleura2 | ind_zmat(3,3)=1 |
181 | 1 | pfleura2 | END IF |
182 | 1 | pfleura2 | ELSE |
183 | 1 | pfleura2 | IF (F1223) THEN |
184 | 1 | pfleura2 | ind_zmat(1,1)=2 |
185 | 1 | pfleura2 | ind_zmat(2,1)=1 |
186 | 1 | pfleura2 | ind_zmat(2,2)=2 |
187 | 1 | pfleura2 | ind_zmat(3,1)=3 |
188 | 1 | pfleura2 | ind_zmat(3,2)=1 |
189 | 1 | pfleura2 | ind_zmat(3,3)=2 |
190 | 1 | pfleura2 | ELSE |
191 | 1 | pfleura2 | ind_zmat(1,1)=2 |
192 | 1 | pfleura2 | ind_zmat(2,1)=3 |
193 | 1 | pfleura2 | ind_zmat(2,2)=2 |
194 | 1 | pfleura2 | ind_zmat(3,1)=1 |
195 | 1 | pfleura2 | ind_zmat(3,2)=3 |
196 | 1 | pfleura2 | ind_zmat(3,3)=2 |
197 | 1 | pfleura2 | END IF |
198 | 1 | pfleura2 | END IF |
199 | 1 | pfleura2 | IF (debug) THEN |
200 | 1 | pfleura2 | DO i=1,na |
201 | 1 | pfleura2 | WRITE(*,'(1X,5(1X,I5))') (ind_zmat(i,j),j=1,5) |
202 | 1 | pfleura2 | END DO |
203 | 1 | pfleura2 | END IF |
204 | 1 | pfleura2 | |
205 | 1 | pfleura2 | ! We have ind_zmat, we fill val_zmat |
206 | 1 | pfleura2 | val_zmat(1,1)=0. |
207 | 1 | pfleura2 | val_zmat(1,2)=0. |
208 | 1 | pfleura2 | val_zmat(1,3)=0. |
209 | 1 | pfleura2 | n2=ind_zmat(2,1) |
210 | 1 | pfleura2 | n1=ind_zmat(2,2) |
211 | 1 | pfleura2 | d=sqrt((x(n1)-x(n2))**2+(y(n1)-y(n2))**2+(z(n1)-z(n2))**2) |
212 | 1 | pfleura2 | val_zmat(2,1)=d |
213 | 1 | pfleura2 | val_zmat(2,2)=0. |
214 | 1 | pfleura2 | val_zmat(2,3)=0. |
215 | 1 | pfleura2 | n1=ind_zmat(3,1) |
216 | 1 | pfleura2 | n2=ind_zmat(3,2) |
217 | 1 | pfleura2 | n3=ind_zmat(3,3) |
218 | 1 | pfleura2 | CALL vecteur(n2,n1,x,y,z,vx1,vy1,vz1,norm1) |
219 | 1 | pfleura2 | if (debug) write(*,*) n1,n2,norm1 |
220 | 1 | pfleura2 | val_zmat(3,1)=norm1 |
221 | 1 | pfleura2 | |
222 | 1 | pfleura2 | CALL vecteur(n2,n3,x,y,z,vx2,vy2,vz2,norm2) |
223 | 1 | pfleura2 | val=angle(vx1,vy1,vz1,norm1,vx2,vy2,vz2,norm2) |
224 | 1 | pfleura2 | if (debug) write(*,*) n2,n3,norm2,val |
225 | 1 | pfleura2 | val_zmat(3,2)=val |
226 | 1 | pfleura2 | val_zmat(3,3)=0. |
227 | 1 | pfleura2 | |
228 | 1 | pfleura2 | RETURN |
229 | 1 | pfleura2 | END IF |
230 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
231 | 1 | pfleura2 | ! |
232 | 1 | pfleura2 | ! End of Easy case : 3 or less atoms |
233 | 1 | pfleura2 | ! |
234 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
235 | 1 | pfleura2 | ! |
236 | 1 | pfleura2 | ! General Case |
237 | 1 | pfleura2 | ! |
238 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
239 | 1 | pfleura2 | ! |
240 | 1 | pfleura2 | ! 1 - Frozen Atoms |
241 | 1 | pfleura2 | |
242 | 1 | pfleura2 | ! Initialization |
243 | 1 | pfleura2 | DejaFait=.False. |
244 | 1 | pfleura2 | FrozAt=.False. |
245 | 1 | pfleura2 | Liaisons=0 |
246 | 1 | pfleura2 | LiaisonsBis=0 |
247 | 1 | pfleura2 | ind_zmat=0 |
248 | 1 | pfleura2 | val_zmat=0.d0 |
249 | 1 | pfleura2 | |
250 | 1 | pfleura2 | NFroz=0 |
251 | 1 | pfleura2 | I=1 |
252 | 1 | pfleura2 | DO WHILE (Frozen(I).NE.0) |
253 | 1 | pfleura2 | If (Frozen(I).LT.0) THEN |
254 | 1 | pfleura2 | DO J=Frozen(I-1),abs(Frozen(I)) |
255 | 1 | pfleura2 | IF (.NOT.FrozAt(J)) THEN |
256 | 1 | pfleura2 | NFroz=NFroz+1 |
257 | 1 | pfleura2 | FrozAt(J)=.TRUE. |
258 | 1 | pfleura2 | END IF |
259 | 1 | pfleura2 | END DO |
260 | 1 | pfleura2 | ELSEIF (.NOT.FrozAt(Frozen(I))) THEN |
261 | 1 | pfleura2 | FrozAt(Frozen(I))=.TRUE. |
262 | 1 | pfleura2 | NFroz=NFroz+1 |
263 | 1 | pfleura2 | END IF |
264 | 1 | pfleura2 | I=I+1 |
265 | 1 | pfleura2 | END DO |
266 | 1 | pfleura2 | |
267 | 1 | pfleura2 | if (debug) WRITE(*,*) 'DGB zmtc NFroz=', NFroz |
268 | 1 | pfleura2 | if (debug) WRITE(*,*) 'DGB zmtc FrozAt=',(FrozAt(I),I=1,na) |
269 | 1 | pfleura2 | |
270 | 1 | pfleura2 | if (debug) THEN |
271 | 1 | pfleura2 | WRITE(*,*) "Liaisons initialized" |
272 | 1 | pfleura2 | WRITE(*,*) 'Covalent radii used' |
273 | 1 | pfleura2 | DO iat=1,na |
274 | 1 | pfleura2 | i=atome(iat) |
275 | 1 | pfleura2 | WRITE(*,*) Nom(I),Iat,r_cov(i),r_cov(i)*fact |
276 | 1 | pfleura2 | END DO |
277 | 1 | pfleura2 | END IF |
278 | 1 | pfleura2 | |
279 | 1 | pfleura2 | 1003 FORMAT(1X,I4,' - ',25(I5)) |
280 | 1 | pfleura2 | ! DO IL=1,na |
281 | 1 | pfleura2 | ! WRITE(IOOUT,1003) Il,(LIAISONS(IL,JL),JL=0,NMaxL) |
282 | 1 | pfleura2 | ! WRITE(IOOUT,1003) Il,(LIAISONSBis(IL,JL),JL=0,NMaxL) |
283 | 1 | pfleura2 | ! END DO |
284 | 1 | pfleura2 | ! First step : connectivity are calculated |
285 | 1 | pfleura2 | |
286 | 1 | pfleura2 | Call CalcCnct(na,atome,x,y,z,LIAISONS,r_cov,fact) |
287 | 1 | pfleura2 | |
288 | 1 | pfleura2 | if (debug) THEN |
289 | 1 | pfleura2 | WRITE(*,*) "Connections calculated" |
290 | 1 | pfleura2 | DO IL=1,na |
291 | 1 | pfleura2 | WRITE(IOOUT,1003) Il,(LIAISONS(IL,JL),JL=0,NMaxL) |
292 | 1 | pfleura2 | END DO |
293 | 1 | pfleura2 | END IF |
294 | 1 | pfleura2 | |
295 | 1 | pfleura2 | FCaf=.TRUE. |
296 | 1 | pfleura2 | Call Decomp_frag(na,liaisons,FCaf,nbfrag,Fragment,NbAtFrag,FragAt) |
297 | 1 | pfleura2 | |
298 | 1 | pfleura2 | IF (debug) THEN |
299 | 1 | pfleura2 | WRITE(*,*) 'I found ',NbFrag, 'fragments' |
300 | 1 | pfleura2 | WRITE(*,'(20(1X,I4))') (NbAtFrag(I),I=1,NbFrag) |
301 | 1 | pfleura2 | DO I=1,NbFrag |
302 | 1 | pfleura2 | WRITE(*,*) NbAtFrag(I) |
303 | 1 | pfleura2 | WRITE(*,*) 'Fragment ', i |
304 | 1 | pfleura2 | DO J=1,Na |
305 | 1 | pfleura2 | IF (Fragment(J).EQ.I) THEN |
306 | 1 | pfleura2 | if (FrozAt(J)) THEN |
307 | 1 | pfleura2 | WRITE(*,'(1X,I3,"f",1X,A5,3(1X,F10.6))') J,Nom(Atome(J)) & |
308 | 1 | pfleura2 | ,X(J),Y(J),Z(J) |
309 | 1 | pfleura2 | ELSE |
310 | 1 | pfleura2 | WRITE(*,'(1X,I3,2X,A5,3(1X,F10.6))') J,Nom(Atome(J)) & |
311 | 1 | pfleura2 | ,X(J),Y(J),Z(J) |
312 | 1 | pfleura2 | END IF |
313 | 1 | pfleura2 | END IF |
314 | 1 | pfleura2 | END DO |
315 | 1 | pfleura2 | WRITE(*,*) "FragAt:",(FragAt(I,j),j=1,NbAtFrag(I)) |
316 | 1 | pfleura2 | END DO |
317 | 1 | pfleura2 | END IF |
318 | 1 | pfleura2 | |
319 | 1 | pfleura2 | |
320 | 1 | pfleura2 | ! First, we decompose the connectivity into Frozen atoms and non frozen atoms |
321 | 1 | pfleura2 | DO I=1,na |
322 | 1 | pfleura2 | LiaisonsBis(I,0)=0 |
323 | 1 | pfleura2 | DO J=1,Liaisons(I,0) |
324 | 1 | pfleura2 | IF (FrozAt(Liaisons(I,J))) THEN |
325 | 1 | pfleura2 | LiaisonsBis(I,0)=LiaisonsBis(I,0)+1 |
326 | 1 | pfleura2 | LiaisonsBis(I,LiaisonsBis(I,0))=Liaisons(I,J) |
327 | 1 | pfleura2 | END IF |
328 | 1 | pfleura2 | END DO |
329 | 1 | pfleura2 | IMax=LiaisonsBis(I,0)+1 |
330 | 1 | pfleura2 | LiaisonsBis(I,Imax)=0 |
331 | 1 | pfleura2 | DO J=1,Liaisons(I,0) |
332 | 1 | pfleura2 | IF (.NOT.FrozAt(Liaisons(I,J))) THEN |
333 | 1 | pfleura2 | LiaisonsBis(I,IMax)=LiaisonsBis(I,Imax)+1 |
334 | 1 | pfleura2 | LiaisonsBis(I,LiaisonsBis(I,Imax)+Imax)=Liaisons(I,J) |
335 | 1 | pfleura2 | END IF |
336 | 1 | pfleura2 | END DO |
337 | 1 | pfleura2 | END DO |
338 | 1 | pfleura2 | |
339 | 1 | pfleura2 | if (debug) THEN |
340 | 1 | pfleura2 | WRITE(*,*) "Liaisons and LiaisonsBis" |
341 | 1 | pfleura2 | DO I=1,Na |
342 | 1 | pfleura2 | WRITE(*,'(1X,I3," -",I3,":",15(1X,I3))') I, & |
343 | 1 | pfleura2 | (Liaisons(I,J),J=0,NMaxL) |
344 | 1 | pfleura2 | WRITE(*,'(1X,I3," +",I3,":",15(1X,I3))') I, & |
345 | 1 | pfleura2 | (LiaisonsBis(I,J),J=0,NMaxL) |
346 | 1 | pfleura2 | END DO |
347 | 1 | pfleura2 | END IF |
348 | 1 | pfleura2 | |
349 | 1 | pfleura2 | ! Now, for each frozen atom, we count the length of the frozen block |
350 | 1 | pfleura2 | ! FrozBlock(I,0) contains the number of frozen atoms forming a frozen |
351 | 1 | pfleura2 | ! fragment containing atom I |
352 | 1 | pfleura2 | ! FrozBlock(I,:) is the list of the frozen atoms of this fragment. |
353 | 1 | pfleura2 | Do I=1,na |
354 | 1 | pfleura2 | FrozBlock(I,0)=-1 |
355 | 1 | pfleura2 | END DO |
356 | 1 | pfleura2 | DO I=1,na |
357 | 1 | pfleura2 | IF (FrozAt(I).AND.(FrozBlock(I,0).EQ.-1)) THEN |
358 | 1 | pfleura2 | if (debug) WRITE(*,*) 'Treating atom ',I |
359 | 1 | pfleura2 | FrozBlock(I,0)=1 |
360 | 1 | pfleura2 | FrozBlock(I,1)=I |
361 | 1 | pfleura2 | DO J=1,na |
362 | 1 | pfleura2 | DejaFait(J)=.FALSE. |
363 | 1 | pfleura2 | END DO |
364 | 1 | pfleura2 | DejaFait(I)=.TRUE. |
365 | 1 | pfleura2 | DO J=1,LiaisonsBis(I,0) |
366 | 1 | pfleura2 | CaFaire(J)=LiaisonsBis(I,J) |
367 | 1 | pfleura2 | END DO |
368 | 1 | pfleura2 | IdxCaFaire=LiaisonsBis(I,0)+1 |
369 | 1 | pfleura2 | CaFaire(IdxCaFaire)=0 |
370 | 1 | pfleura2 | IAfaire=1 |
371 | 1 | pfleura2 | FCaf=DejaFait |
372 | 1 | pfleura2 | DO WHILE (CaFaire(IAfaire).NE.0) |
373 | 1 | pfleura2 | Iat=CaFaire(IAFAire) |
374 | 1 | pfleura2 | if (debug) WRITE(*,*) 'IaFaire; Iat:', IaFaire, Iat, DejaFait(Iat) |
375 | 1 | pfleura2 | IF (.NOT.DejaFait(Iat)) THEN |
376 | 1 | pfleura2 | FrozBlock(I,0)=FrozBlock(I,0)+1 |
377 | 1 | pfleura2 | FrozBlock(I,FrozBlock(I,0))=Iat |
378 | 1 | pfleura2 | DO J=1,LiaisonsBis(Iat,0) |
379 | 1 | pfleura2 | IF ((.NOT.DejaFait(LiaisonsBis(Iat,J))).AND.(.NOT.FCaf(LiaisonsBis(Iat,J)))) THEN |
380 | 1 | pfleura2 | CaFaire(IdxCaFaire)=LiaisonsBis(Iat,J) |
381 | 1 | pfleura2 | IdxCaFaire=IdxCaFaire+1 |
382 | 1 | pfleura2 | CaFaire(IdxCaFaire)=0 |
383 | 1 | pfleura2 | FCaf(LiaisonsBis(Iat,J))=.TRUE. |
384 | 1 | pfleura2 | END IF |
385 | 1 | pfleura2 | END DO |
386 | 1 | pfleura2 | ! WRITE(*,*) 'liaisonbis(Iat,0),FrozBlick(I,0)',& |
387 | 1 | pfleura2 | ! LiaisonsBis(Iat,0), FrozBlock(I,0) |
388 | 1 | pfleura2 | END IF |
389 | 1 | pfleura2 | DejaFait(Iat)=.TRUE. |
390 | 1 | pfleura2 | IaFaire=IaFaire+1 |
391 | 1 | pfleura2 | END DO |
392 | 1 | pfleura2 | if (debug) WRITE(*,*) 'I,FrozBlock(0),IaFaire',I,FrozBlock(I,0),IaFaire |
393 | 1 | pfleura2 | if (debug) WRITE(*,*) 'FrozBlock:',FrozBlock(I,1:FrozBlock(I,0)) |
394 | 1 | pfleura2 | ! FrozBlock(I,1)=I |
395 | 1 | pfleura2 | ! DO J=2,IaFaire |
396 | 1 | pfleura2 | ! FrozBlock(I,J)=CaFaire(J-1) |
397 | 1 | pfleura2 | ! END DO |
398 | 1 | pfleura2 | ! We copy this block into all frozen atoms that belongs to it |
399 | 1 | pfleura2 | DO J=2,Frozblock(I,0) |
400 | 1 | pfleura2 | Iat=FrozBlock(I,J) |
401 | 1 | pfleura2 | DO K=0,FrozBlock(I,0) |
402 | 1 | pfleura2 | FrozBlock(Iat,K)=FrozBlock(I,K) |
403 | 1 | pfleura2 | END DO |
404 | 1 | pfleura2 | END DO |
405 | 1 | pfleura2 | ELSE |
406 | 1 | pfleura2 | IF (.NOT.FrozAt(I)) FrozBlock(I,0)=0 |
407 | 1 | pfleura2 | END IF |
408 | 1 | pfleura2 | END DO |
409 | 1 | pfleura2 | |
410 | 1 | pfleura2 | if (debug) THEN |
411 | 1 | pfleura2 | WRITE(*,*) "FrozBlock" |
412 | 1 | pfleura2 | DO I=1,Na |
413 | 1 | pfleura2 | If (FrozAt(I)) WRITE(*,'(1X,I3," -",I3,":",15(1X,I3))') I, & |
414 | 1 | pfleura2 | (FrozBlock(I,J),J=0,FrozBlock(I,0)) |
415 | 1 | pfleura2 | END DO |
416 | 1 | pfleura2 | END IF |
417 | 1 | pfleura2 | |
418 | 1 | pfleura2 | DO I=1,NbFrag |
419 | 1 | pfleura2 | FrozFrag(I,1)=0 |
420 | 1 | pfleura2 | FrozFrag(I,2)=0 |
421 | 1 | pfleura2 | DO J=1,NbAtFrag(I) |
422 | 1 | pfleura2 | IF (FrozAt(FragAt(I,J))) THEN |
423 | 1 | pfleura2 | FrozFrag(I,1)=FrozFrag(I,1)+1 |
424 | 1 | pfleura2 | IF (FrozBlock(FragAt(I,J),0).GE.FrozFrag(I,2)) & |
425 | 1 | pfleura2 | FrozFrag(I,2)=FrozBlock(FragAt(I,J),0) |
426 | 1 | pfleura2 | if (FrozFrag(I,3).LE.LiaisonsBis(FragAt(I,J),0))& |
427 | 1 | pfleura2 | FrozFrag(I,3)=LiaisonsBis(FragAt(I,J),0) |
428 | 1 | pfleura2 | END IF |
429 | 1 | pfleura2 | END DO |
430 | 1 | pfleura2 | IF (debug) WRITE(*,*) 'Frag :',I,FrozFrag(I,1), & |
431 | 1 | pfleura2 | ' frozen atoms,max linked:' & |
432 | 1 | pfleura2 | ,FrozFrag(I,2),' with at most',FrozFrag(I,3),' frozen' |
433 | 1 | pfleura2 | END DO |
434 | 1 | pfleura2 | |
435 | 1 | pfleura2 | ! We will now build the molecule fragment by fragment |
436 | 1 | pfleura2 | ! First the frozen atoms, then the rest of the fragment |
437 | 1 | pfleura2 | ! We choose the starting fragment with two criteria: |
438 | 1 | pfleura2 | ! 1- Number of linked frozen atoms: |
439 | 1 | pfleura2 | ! * >=3 is good as it fully defines the coordinate space |
440 | 1 | pfleura2 | ! * 2 is ok as we can either use a 3rd atom from the same fragment |
441 | 1 | pfleura2 | ! or add a X atom somewhere but this complicates quite a lot the way |
442 | 1 | pfleura2 | ! to treat the conversion from cartesian to zmat latter |
443 | 1 | pfleura2 | ! * 1 is bad... |
444 | 1 | pfleura2 | ! 2- Max number of linked frozen atoms |
445 | 1 | pfleura2 | ! this allows us to deal more easily with cases 1- when number of |
446 | 1 | pfleura2 | ! directly linked frozen atoms is less than 3 |
447 | 1 | pfleura2 | |
448 | 1 | pfleura2 | IFrag=0 |
449 | 1 | pfleura2 | I0=0 |
450 | 1 | pfleura2 | I1=0 |
451 | 1 | pfleura2 | DO I=1,NbFrag |
452 | 1 | pfleura2 | SELECT CASE(FrozFrag(I,3)-I0) |
453 | 1 | pfleura2 | CASE (1:) |
454 | 1 | pfleura2 | IFrag=I |
455 | 1 | pfleura2 | I0=FrozFrag(I,3) |
456 | 1 | pfleura2 | I1=FrozFrag(I,2) |
457 | 1 | pfleura2 | CASE (0) |
458 | 1 | pfleura2 | if (FrozFrag(I,2).GT.I1) THEN |
459 | 1 | pfleura2 | IFrag=I |
460 | 1 | pfleura2 | I0=FrozFrag(I,3) |
461 | 1 | pfleura2 | I1=FrozFrag(I,2) |
462 | 1 | pfleura2 | END IF |
463 | 1 | pfleura2 | END SELECT |
464 | 1 | pfleura2 | END DO |
465 | 1 | pfleura2 | |
466 | 1 | pfleura2 | if (debug) WRITE(*,'(1X,A,I5,A,I5,A,I5,A)') 'Starting with fragment:',IFrag,' with ',I0,' frozen linked and overall',I1,' linked' |
467 | 1 | pfleura2 | |
468 | 1 | pfleura2 | ! We will build the first fragment in a special way, as it will |
469 | 1 | pfleura2 | ! set the coordinates system |
470 | 1 | pfleura2 | ! We look for the frozen atom that is linked to the maximum frozen atom, |
471 | 1 | pfleura2 | ! and belongs to the longer fragment |
472 | 1 | pfleura2 | I0=0 |
473 | 1 | pfleura2 | I1=0 |
474 | 1 | pfleura2 | DO I=1,NbAtFrag(IFrag) |
475 | 1 | pfleura2 | IF (FrozAt(FragAt(IFrag,I))) THEN |
476 | 1 | pfleura2 | SELECT CASE(LiaisonsBis(FragAt(IFrag,I),0)-I0) |
477 | 1 | pfleura2 | CASE (1:) |
478 | 1 | pfleura2 | IAt=FragAt(IFrag,I) |
479 | 1 | pfleura2 | I0=LiaisonsBis(IAt,0) |
480 | 1 | pfleura2 | I1=FrozBlock(IAt,0) |
481 | 1 | pfleura2 | CASE (0) |
482 | 1 | pfleura2 | IF (FrozBlock(FragAt(IFrag,I),0).GT.I1) THEN |
483 | 1 | pfleura2 | IAt=FragAt(IFrag,I) |
484 | 1 | pfleura2 | I0=LiaisonsBis(Iat,0) |
485 | 1 | pfleura2 | I1=FrozBlock(Iat,0) |
486 | 1 | pfleura2 | END IF |
487 | 1 | pfleura2 | END SELECT |
488 | 1 | pfleura2 | END IF |
489 | 1 | pfleura2 | if (debug) WRITE(*,*) 'DBG: I,FragAt(IFrag,I),IAt,I0,I1',I,FragAt(IFrag,I),IAt,I0,I1 |
490 | 1 | pfleura2 | END DO |
491 | 1 | pfleura2 | |
492 | 1 | pfleura2 | if (debug) WRITE(*,*) 'Fragment 1, starting with atom:',IAt,I0,I1 |
493 | 1 | pfleura2 | |
494 | 1 | pfleura2 | DO I=1,na |
495 | 1 | pfleura2 | DejaFait(I)=.FALSE. |
496 | 1 | pfleura2 | FCaf(I)=.FALSE. |
497 | 1 | pfleura2 | END DO |
498 | 1 | pfleura2 | |
499 | 1 | pfleura2 | izm=0 |
500 | 1 | pfleura2 | SELECT CASE (I0) |
501 | 1 | pfleura2 | CASE(3:) |
502 | 1 | pfleura2 | if (debug) WRITE(*,*) 'DBG select case I0 3' |
503 | 1 | pfleura2 | n0=Iat |
504 | 1 | pfleura2 | ! We search for the fourth atom while making sure that the dihedral angle |
505 | 1 | pfleura2 | ! is not 0 or Pi |
506 | 1 | pfleura2 | ITmp=2 |
507 | 1 | pfleura2 | sDihe=0. |
508 | 1 | pfleura2 | n2=IAt |
509 | 1 | pfleura2 | n3=LiaisonsBis(Iat,1) |
510 | 1 | pfleura2 | ! We search for the third atom while making sure that it is not aligned with first two ! |
511 | 1 | pfleura2 | DO While ((ITmp.LE.LiaisonsBis(Iat,0)).AND.(sDihe.LE.0.09d0)) |
512 | 1 | pfleura2 | n4=LiaisonsBis(Iat,Itmp) |
513 | 1 | pfleura2 | CALL vecteur(n2,n3,x,y,z,vx2,vy2,vz2,norm2) |
514 | 1 | pfleura2 | CALL vecteur(n3,n4,x,y,z,vx3,vy3,vz3,norm3) |
515 | 1 | pfleura2 | val_d=angle(vx3,vy3,vz3,norm3,vx2,vy2,vz2,norm2) |
516 | 1 | pfleura2 | sDiHe=abs(sin(val_d*pi/180.d0)) |
517 | 1 | pfleura2 | if (debug) Write(*,*) 'Trying n2,n3,n4,sdihe,val_d',n2,n3,n4,sdihe,val_d |
518 | 1 | pfleura2 | Itmp=Itmp+1 |
519 | 1 | pfleura2 | END DO |
520 | 1 | pfleura2 | If (debug) WRITE(*,*) 'Itmp,LiaisonsBis',Itmp,LiaisonsBis(Iat,1:NMaxL) |
521 | 1 | pfleura2 | LiaisonsBis(Iat,Itmp-1)=LiaisonsBis(iat,2) |
522 | 1 | pfleura2 | LiaisonsBis(Iat,2)=n4 |
523 | 1 | pfleura2 | If (debug) WRITE(*,*) 'Itmp,LiaisonsBis',Itmp,LiaisonsBis(Iat,1:NMaxL) |
524 | 1 | pfleura2 | |
525 | 1 | pfleura2 | if (sDihe.LE.0.09d0) THEN |
526 | 1 | pfleura2 | WRITE(*,*) "Dans le caca car tous les atoms de ce block sont align?s!" |
527 | 1 | pfleura2 | END IF |
528 | 1 | pfleura2 | |
529 | 2 | pfleura2 | CALL produit_vect(vx3,vy3,vz3,vx2,vy2,vz2, & |
530 | 1 | pfleura2 | vx5,vy5,vz5,norm5) |
531 | 1 | pfleura2 | |
532 | 1 | pfleura2 | |
533 | 1 | pfleura2 | Itmp=2 |
534 | 1 | pfleura2 | sDiHe=0. |
535 | 1 | pfleura2 | |
536 | 1 | pfleura2 | DO While ((ITmp.LT.LiaisonsBis(Iat,0)).AND.(sDihe.LE.0.09d0)) |
537 | 1 | pfleura2 | ITmp=ITmp+1 |
538 | 1 | pfleura2 | n1=LiaisonsBis(Iat,Itmp) |
539 | 1 | pfleura2 | if (debug) WRITe(*,*) 'trying n1,n2,n3,n4',n1,n2,n3,n4 |
540 | 1 | pfleura2 | CALL vecteur(n2,n1,x,y,z,vx1,vy1,vz1,norm1) |
541 | 1 | pfleura2 | ! Is this atom aligned with n2-n3 ? |
542 | 1 | pfleura2 | val_d=angle(vx1,vy1,vz1,norm1,vx2,vy2,vz2,norm2) |
543 | 1 | pfleura2 | sDiHe=abs(sin(val_d*pi/180.d0)) |
544 | 1 | pfleura2 | if (debug) Write(*,*) 'Angle n3-n2-n1',val_d |
545 | 1 | pfleura2 | if (sDiHe.le.0.09d0) THEN |
546 | 1 | pfleura2 | ! As atoms n2,n3 and n4 are not aligned, we interchange n3 and n4 so that n1,n2 and n3 are not aligned |
547 | 1 | pfleura2 | if (debug) WRITE(*,*) "n3-n2-n1 aligned, we interchange n3 and n4" |
548 | 1 | pfleura2 | n1=n3 |
549 | 1 | pfleura2 | n3=n4 |
550 | 1 | pfleura2 | n4=n1 |
551 | 1 | pfleura2 | n1=LiaisonsBis(Iat,ITmp) |
552 | 1 | pfleura2 | CALL vecteur(n2,n3,x,y,z,vx2,vy2,vz2,norm2) |
553 | 1 | pfleura2 | CALL vecteur(n2,n4,x,y,z,vx3,vy3,vz3,norm3) |
554 | 1 | pfleura2 | val_d=angle(vx1,vy1,vz1,norm1,vx2,vy2,vz2,norm2) |
555 | 1 | pfleura2 | if (debug) Write(*,*) 'NEW Angle n3-n2-n1',val_d |
556 | 1 | pfleura2 | END IF |
557 | 1 | pfleura2 | |
558 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
559 | 1 | pfleura2 | ! avant de tester l'angle diedre, il faut verifier que ce 4e atome n'est pas |
560 | 1 | pfleura2 | ! aligne avec les 2 premiers. |
561 | 1 | pfleura2 | ! comme on a deja test? que les 3 premiers ne sont pas alignes, |
562 | 1 | pfleura2 | ! s'il est align? avec les 2 premiers, on peut inverser le role de 2 et 3. |
563 | 1 | pfleura2 | ! On pourrait tout simplier en faisant une bete recherche parmi tous les atomes geles |
564 | 1 | pfleura2 | ! de ce bloc (au moins 4 ?) avec le critere 1) on les range par distance croissante |
565 | 1 | pfleura2 | ! 2) on les scanne tant que l'angle valence n'est pas bon, puis tant que diehedre pas bon |
566 | 1 | pfleura2 | ! puis les atomes des autres fragment par distance croissante. |
567 | 1 | pfleura2 | ! les autres fragments ne seraient additonn?s que si l'on ne trouve pas notre bonheur dans le premier bloc |
568 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
569 | 1 | pfleura2 | |
570 | 2 | pfleura2 | CALL produit_vect(vx1,vy1,vz1,vx2,vy2,vz2, & |
571 | 1 | pfleura2 | vx4,vy4,vz4,norm4) |
572 | 1 | pfleura2 | val_d=angle_d(vx4,vy4,vz4,norm4,vx5,vy5,vz5,norm5, & |
573 | 1 | pfleura2 | vx2,vy2,vz2,norm2) |
574 | 1 | pfleura2 | sDihe=abs(sin(val_d*pi/180.d0)) |
575 | 1 | pfleura2 | if (debug) WRITE(*,*) 'n2,n3,n4,n1, angle_d',n2,n3,n4,n1,val_d |
576 | 1 | pfleura2 | END DO |
577 | 1 | pfleura2 | |
578 | 1 | pfleura2 | DejaFait(n2)=.TRUE. |
579 | 1 | pfleura2 | DejaFait(n3)=.TRUE. |
580 | 1 | pfleura2 | DejaFait(n4)=.TRUE. |
581 | 1 | pfleura2 | |
582 | 1 | pfleura2 | if (sDihe.LE.0.09d0) THEN |
583 | 1 | pfleura2 | ! None of the frozen atoms linked to IAt are good to define the third |
584 | 1 | pfleura2 | ! direction in space... |
585 | 1 | pfleura2 | ! We will look at the other frozen atoms |
586 | 1 | pfleura2 | ! we might improve the search so as to take the atom closest to IAt |
587 | 1 | pfleura2 | if (debug) WRITE(*,*) "All atoms linked to ",Iat," are in a plane. Looking for other frozen atoms" |
588 | 1 | pfleura2 | ITmp=0 |
589 | 1 | pfleura2 | DO I=1,NbAtFrag(IFrag) |
590 | 1 | pfleura2 | JAt=FragAt(IFrag,I) |
591 | 1 | pfleura2 | if (FrozAt(Jat).AND.(.NOT.DejaFait(JAt))) THEN |
592 | 1 | pfleura2 | n1=JAt |
593 | 1 | pfleura2 | CALL vecteur(n2,n1,x,y,z,vx1,vy1,vz1,norm1) |
594 | 2 | pfleura2 | CALL produit_vect(vx1,vy1,vz1,vx2,vy2,vz2, & |
595 | 1 | pfleura2 | vx4,vy4,vz4,norm4) |
596 | 1 | pfleura2 | val_d=angle_d(vx4,vy4,vz4,norm4, & |
597 | 1 | pfleura2 | vx5,vy5,vz5,norm5, & |
598 | 1 | pfleura2 | vx2,vy2,vz2,norm2) |
599 | 1 | pfleura2 | if (abs(sin(val_d)).GE.0.09D0) THEN |
600 | 1 | pfleura2 | ITmp=ITmp+1 |
601 | 1 | pfleura2 | DistFroz(ITmp)=Norm1 |
602 | 1 | pfleura2 | FrozDist(ITmp)=JAt |
603 | 1 | pfleura2 | END IF |
604 | 1 | pfleura2 | END IF |
605 | 1 | pfleura2 | END DO |
606 | 1 | pfleura2 | IF (ITmp.EQ.0) THEN |
607 | 1 | pfleura2 | ! All dihedral angles between frozen atoms are less than 5? |
608 | 1 | pfleura2 | ! (or more than 175?). We have to look at other fragments :-( |
609 | 1 | pfleura2 | DO I=1,NFroz |
610 | 1 | pfleura2 | Jat=Frozen(I) |
611 | 1 | pfleura2 | if (.NOT.DejaFait(JAt)) THEN |
612 | 1 | pfleura2 | n1=JAt |
613 | 1 | pfleura2 | CALL vecteur(n2,n1,x,y,z,vx1,vy1,vz1,norm1) |
614 | 2 | pfleura2 | CALL produit_vect(vx1,vy1,vz1,vx2,vy2,vz2, & |
615 | 1 | pfleura2 | vx4,vy4,vz4,norm4) |
616 | 1 | pfleura2 | val_d=angle_d(vx4,vy4,vz4,norm4, & |
617 | 1 | pfleura2 | vx5,vy5,vz5,norm5, & |
618 | 1 | pfleura2 | vx2,vy2,vz2,norm2) |
619 | 1 | pfleura2 | if (abs(sin(val_d)).GE.0.09D0) THEN |
620 | 1 | pfleura2 | ITmp=ITmp+1 |
621 | 1 | pfleura2 | DistFroz(ITmp)=Norm1 |
622 | 1 | pfleura2 | FrozDist(ITmp)=JAt |
623 | 1 | pfleura2 | END IF |
624 | 1 | pfleura2 | END IF |
625 | 1 | pfleura2 | END DO |
626 | 1 | pfleura2 | IF (ITmp.EQ.0) THEN |
627 | 1 | pfleura2 | ! All frozen atoms are in a plane... too bad |
628 | 1 | pfleura2 | WRITE(*,*) 'ERROR: It seems that all frozen atoms are in a plane' |
629 | 1 | pfleura2 | WRITE(*,*) 'For now, I do not treat this case' |
630 | 1 | pfleura2 | STOP |
631 | 1 | pfleura2 | END IF |
632 | 1 | pfleura2 | END IF |
633 | 1 | pfleura2 | I1=0 |
634 | 1 | pfleura2 | d=1e9 |
635 | 1 | pfleura2 | DO I=1,ITmp |
636 | 1 | pfleura2 | IF (DistFroz(I).LE.d) THEN |
637 | 1 | pfleura2 | d=DistFroz(I) |
638 | 1 | pfleura2 | I1=FrozDist(I) |
639 | 1 | pfleura2 | END IF |
640 | 1 | pfleura2 | END DO |
641 | 1 | pfleura2 | ELSE !(sDihe.LE.0.09d0) |
642 | 1 | pfleura2 | I1=FrozBlock(IAt,ITmp) |
643 | 1 | pfleura2 | if (debug) WRITE(*,*) 'I1,n1:',I1,n1 |
644 | 1 | pfleura2 | END IF !(sDihe.LE.0.09d0) |
645 | 1 | pfleura2 | ! we now have the atom that is closer to the first one and that |
646 | 1 | pfleura2 | ! forms a non 0/Pi dihedral angle |
647 | 1 | pfleura2 | |
648 | 1 | pfleura2 | ind_zmat(1,1)=n2 |
649 | 1 | pfleura2 | ind_zmat(2,1)=n3 |
650 | 1 | pfleura2 | ind_zmat(2,2)=n2 |
651 | 1 | pfleura2 | ind_zmat(3,1)=n4 |
652 | 1 | pfleura2 | ind_zmat(3,2)=n2 |
653 | 1 | pfleura2 | ind_zmat(3,3)=n3 |
654 | 1 | pfleura2 | DejaFait(n2)=.TRUE. |
655 | 1 | pfleura2 | DejaFait(n3)=.TRUE. |
656 | 1 | pfleura2 | DejaFait(n4)=.TRUE. |
657 | 1 | pfleura2 | CaFaire(1)=n3 |
658 | 1 | pfleura2 | CaFaire(2)=n4 |
659 | 1 | pfleura2 | |
660 | 1 | pfleura2 | ind_zmat(4,1)=I1 |
661 | 1 | pfleura2 | ind_zmat(4,2)=n2 |
662 | 1 | pfleura2 | ind_zmat(4,3)=n3 |
663 | 1 | pfleura2 | ind_zmat(4,4)=n4 |
664 | 1 | pfleura2 | DejaFait(I1)=.TRUE. |
665 | 1 | pfleura2 | CaFaire(3)=I1 |
666 | 1 | pfleura2 | CaFaire(4)=0 |
667 | 1 | pfleura2 | IdxCaFaire=4 |
668 | 1 | pfleura2 | |
669 | 1 | pfleura2 | FCaf(n2)=.TRUE. |
670 | 1 | pfleura2 | FCaf(n3)=.TRUE. |
671 | 1 | pfleura2 | FCaf(I1)=.TRUE. |
672 | 1 | pfleura2 | izm=4 |
673 | 1 | pfleura2 | DO I=3,LiaisonsBis(Iat,0) |
674 | 1 | pfleura2 | IF (.NOT.DejaFait(LiaisonsBis(Iat,I))) THEN |
675 | 1 | pfleura2 | izm=izm+1 |
676 | 1 | pfleura2 | ! ind_zmat(izm,1)=LiaisonsBis(Iat,I) |
677 | 1 | pfleura2 | ! ind_zmat(izm,2)=n2 |
678 | 1 | pfleura2 | ! ind_zmat(izm,3)=n3 |
679 | 1 | pfleura2 | ! ind_zmat(izm,4)=n4 |
680 | 1 | pfleura2 | Call add2indzmat(na,izm,LiaisonsBis(Iat,I),n2,n3,n4,ind_zmat,x,y,z) |
681 | 1 | pfleura2 | IF (.NOT.FCaf(LiaisonsBis(Iat,I))) THEN |
682 | 1 | pfleura2 | CaFaire(IdxCaFaire)=LiaisonsBis(Iat,I) |
683 | 1 | pfleura2 | IdxCaFaire=IdxCaFaire+1 |
684 | 1 | pfleura2 | CaFaire(IdxCaFaire)=0 |
685 | 1 | pfleura2 | FCaf(LiaisonsBis(Iat,I))=.TRUE. |
686 | 1 | pfleura2 | END IF |
687 | 1 | pfleura2 | DejaFait(LiaisonsBis(Iat,I))=.TRUE. |
688 | 1 | pfleura2 | END IF |
689 | 1 | pfleura2 | END DO |
690 | 1 | pfleura2 | |
691 | 1 | pfleura2 | if (debug) THEN |
692 | 1 | pfleura2 | WRITE(*,*) "Ind_zmat 0 - SELECT CASE I0 3: -- izm=",izm |
693 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(1,1) |
694 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(2,1), ind_zmat(2,2) |
695 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(3,1), ind_zmat(3,2), ind_zmat(3,3) |
696 | 1 | pfleura2 | DO I=4,izm |
697 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(I,1), ind_zmat(I,2), & |
698 | 1 | pfleura2 | ind_zmat(I,3), ind_zmat(I,4) |
699 | 1 | pfleura2 | END DO |
700 | 1 | pfleura2 | END IF |
701 | 1 | pfleura2 | |
702 | 1 | pfleura2 | |
703 | 1 | pfleura2 | ! First four atoms (at least) have been put we go on with next parts |
704 | 1 | pfleura2 | ! of this fragment... later |
705 | 1 | pfleura2 | |
706 | 1 | pfleura2 | |
707 | 1 | pfleura2 | CASE(2) |
708 | 1 | pfleura2 | if (debug) WRITE(*,*) 'DBG select case I0 2' |
709 | 1 | pfleura2 | if (debug) WRITE(*,*) 'ATTENTION For now, case with only 3 frozen atoms non treated' |
710 | 1 | pfleura2 | ind_zmat(1,1)=IAt |
711 | 1 | pfleura2 | ind_zmat(2,1)=liaisonsBis(IAt,1) |
712 | 1 | pfleura2 | ind_zmat(2,2)=IAt |
713 | 1 | pfleura2 | ind_zmat(3,1)=LiaisonsBis(IAt,2) |
714 | 1 | pfleura2 | ind_zmat(3,2)=IAt |
715 | 1 | pfleura2 | ind_zmat(3,3)=LiaisonsBis(IAt,1) |
716 | 1 | pfleura2 | DejaFait(IAt)=.TRUE. |
717 | 1 | pfleura2 | DejaFait(LiaisonsBis(Iat,1))=.TRUE. |
718 | 1 | pfleura2 | DejaFait(LiaisonsBis(Iat,2))=.TRUE. |
719 | 1 | pfleura2 | CaFaire(1)=LiaisonsBis(Iat,1) |
720 | 1 | pfleura2 | CaFaire(2)=LiaisonsBis(Iat,2) |
721 | 1 | pfleura2 | FCaf(LiaisonsBis(Iat,1))=.TRUE. |
722 | 1 | pfleura2 | FCaf(LiaisonsBis(Iat,2))=.TRUE. |
723 | 1 | pfleura2 | |
724 | 1 | pfleura2 | ! We search for a fourth atom, first in the FrozBlock atoms |
725 | 1 | pfleura2 | ITmp=2 |
726 | 1 | pfleura2 | sDihe=0. |
727 | 1 | pfleura2 | n2=IAt |
728 | 1 | pfleura2 | n3=LiaisonsBis(Iat,1) |
729 | 1 | pfleura2 | n4=LiaisonsBis(Iat,2) |
730 | 1 | pfleura2 | CALL vecteur(n2,n3,x,y,z,vx2,vy2,vz2,norm2) |
731 | 1 | pfleura2 | CALL vecteur(n3,n4,x,y,z,vx3,vy3,vz3,norm3) |
732 | 2 | pfleura2 | CALL produit_vect(vx3,vy3,vz3,vx2,vy2,vz2, & |
733 | 1 | pfleura2 | vx5,vy5,vz5,norm5) |
734 | 1 | pfleura2 | |
735 | 1 | pfleura2 | DO While ((ITmp.LE.FrozBlock(Iat,0)).AND.(sDihe.LE.0.09d0)) |
736 | 1 | pfleura2 | ITmp=ITmp+1 |
737 | 1 | pfleura2 | n1=FrozBlock(Iat,Itmp) |
738 | 1 | pfleura2 | CALL vecteur(n2,n1,x,y,z,vx1,vy1,vz1,norm1) |
739 | 2 | pfleura2 | CALL produit_vect(vx1,vy1,vz1, vx2,vy2,vz2, & |
740 | 1 | pfleura2 | vx4,vy4,vz4,norm4) |
741 | 1 | pfleura2 | val_d=angle_d(vx4,vy4,vz4,norm4, & |
742 | 1 | pfleura2 | vx5,vy5,vz5,norm5, & |
743 | 1 | pfleura2 | vx2,vy2,vz2,norm2) |
744 | 1 | pfleura2 | sDihe=abs(sin(val_d)) |
745 | 1 | pfleura2 | END DO |
746 | 1 | pfleura2 | IF (debug) WRITE(*,*) 'DBG 4th atom, ITmp, sDihe',ITmp, sDihe |
747 | 1 | pfleura2 | if (sDihe.LE.0.09d0) THEN |
748 | 1 | pfleura2 | ! None of the frozen atoms linked to IAt are good to define the third |
749 | 1 | pfleura2 | ! direction in space... |
750 | 1 | pfleura2 | ! We will look at the other frozen atoms |
751 | 1 | pfleura2 | ! we might improve the search so as to take the atom closest to IAt |
752 | 1 | pfleura2 | ITmp=0 |
753 | 1 | pfleura2 | DO I=1,NbAtFrag(IFrag) |
754 | 1 | pfleura2 | JAt=FragAt(IFrag,I) |
755 | 1 | pfleura2 | if (FrozAt(Jat).AND.(.NOT.DejaFait(JAt))) THEN |
756 | 1 | pfleura2 | n1=JAt |
757 | 1 | pfleura2 | CALL vecteur(n2,n1,x,y,z,vx1,vy1,vz1,norm1) |
758 | 2 | pfleura2 | CALL produit_vect(vx1,vy1,vz1, vx2,vy2,vz2, & |
759 | 1 | pfleura2 | vx4,vy4,vz4,norm4) |
760 | 1 | pfleura2 | val_d=angle_d(vx4,vy4,vz4,norm4, & |
761 | 1 | pfleura2 | vx5,vy5,vz5,norm5, & |
762 | 1 | pfleura2 | vx2,vy2,vz2,norm2) |
763 | 1 | pfleura2 | if (abs(sin(val_d)).GE.0.09D0) THEN |
764 | 1 | pfleura2 | ITmp=ITmp+1 |
765 | 1 | pfleura2 | DistFroz(ITmp)=Norm1 |
766 | 1 | pfleura2 | FrozDist(ITmp)=JAt |
767 | 1 | pfleura2 | END IF |
768 | 1 | pfleura2 | END IF |
769 | 1 | pfleura2 | END DO |
770 | 1 | pfleura2 | IF (ITmp.EQ.0) THEN |
771 | 1 | pfleura2 | ! All dihedral angles between frozen atoms are less than 5? |
772 | 1 | pfleura2 | ! (or more than 175?). We have to look at other fragments :-( |
773 | 1 | pfleura2 | DO I=1,NFroz |
774 | 1 | pfleura2 | Jat=Frozen(I) |
775 | 1 | pfleura2 | if (.NOT.DejaFait(JAt)) THEN |
776 | 1 | pfleura2 | n1=JAt |
777 | 1 | pfleura2 | CALL vecteur(n2,n1,x,y,z,vx1,vy1,vz1,norm1) |
778 | 2 | pfleura2 | CALL produit_vect(vx1,vy1,vz1, vx2,vy2,vz2, & |
779 | 1 | pfleura2 | vx4,vy4,vz4,norm4) |
780 | 1 | pfleura2 | val_d=angle_d(vx4,vy4,vz4,norm4, & |
781 | 1 | pfleura2 | vx5,vy5,vz5,norm5, & |
782 | 1 | pfleura2 | vx2,vy2,vz2,norm2) |
783 | 1 | pfleura2 | if (abs(sin(val_d)).GE.0.09D0) THEN |
784 | 1 | pfleura2 | ITmp=ITmp+1 |
785 | 1 | pfleura2 | DistFroz(ITmp)=Norm1 |
786 | 1 | pfleura2 | FrozDist(ITmp)=JAt |
787 | 1 | pfleura2 | END IF |
788 | 1 | pfleura2 | END IF |
789 | 1 | pfleura2 | END DO |
790 | 1 | pfleura2 | IF (ITmp.EQ.0) THEN |
791 | 1 | pfleura2 | ! All frozen atoms are in a plane... too bad |
792 | 1 | pfleura2 | WRITE(*,*) 'ERROR: It seems that all frozen atoms are in a plane' |
793 | 1 | pfleura2 | WRITE(*,*) 'For now, I do not treat this case' |
794 | 1 | pfleura2 | STOP |
795 | 1 | pfleura2 | END IF |
796 | 1 | pfleura2 | END IF |
797 | 1 | pfleura2 | I1=0 |
798 | 1 | pfleura2 | d=1e9 |
799 | 1 | pfleura2 | DO I=1,ITmp |
800 | 1 | pfleura2 | IF (DistFroz(I).LE.d) THEN |
801 | 1 | pfleura2 | d=DistFroz(I) |
802 | 1 | pfleura2 | I1=FrozDist(I) |
803 | 1 | pfleura2 | END IF |
804 | 1 | pfleura2 | END DO |
805 | 1 | pfleura2 | ELSE !(sDihe.LE.0.09d0) |
806 | 1 | pfleura2 | I1=FrozBlock(IAt,ITmp) |
807 | 1 | pfleura2 | END IF !(sDihe.LE.0.09d0) |
808 | 1 | pfleura2 | ! we now have the atom that is closer to the first one and that |
809 | 1 | pfleura2 | ! forms a non 0/Pi dihedral angle |
810 | 1 | pfleura2 | ! ind_zmat(4,1)=I1 |
811 | 1 | pfleura2 | ! ind_zmat(4,2)=IAt |
812 | 1 | pfleura2 | ! ind_zmat(4,3)=LiaisonsBis(Iat,1) |
813 | 1 | pfleura2 | ! ind_zmat(4,4)=LiaisonsBis(Iat,2) |
814 | 1 | pfleura2 | n3=LiaisonsBis(Iat,1) |
815 | 1 | pfleura2 | n4=LiaisonsBis(Iat,2) |
816 | 1 | pfleura2 | Call add2indzmat(na,4,I1,Iat,n3,n4,ind_zmat,x,y,z) |
817 | 1 | pfleura2 | LiaisonsBis(Iat,1)=n3 |
818 | 1 | pfleura2 | LiaisonsBis(Iat,2)=n4 |
819 | 1 | pfleura2 | DejaFait(I1)=.TRUE. |
820 | 1 | pfleura2 | CaFaire(3)=I1 |
821 | 1 | pfleura2 | CaFaire(4)=0 |
822 | 1 | pfleura2 | IdxCaFaire=4 |
823 | 1 | pfleura2 | izm=4 |
824 | 1 | pfleura2 | FCaf(I1)=.TRUE. |
825 | 1 | pfleura2 | |
826 | 1 | pfleura2 | CASE(1) |
827 | 1 | pfleura2 | if (debug) WRITE(*,*) 'DBG select case I0 1' |
828 | 1 | pfleura2 | ind_zmat(1,1)=IAt |
829 | 1 | pfleura2 | ind_zmat(2,1)=liaisonsBis(IAt,1) |
830 | 1 | pfleura2 | ind_zmat(2,2)=IAt |
831 | 1 | pfleura2 | DejaFait(IAt)=.TRUE. |
832 | 1 | pfleura2 | DejaFait(LiaisonsBis(Iat,1))=.TRUE. |
833 | 1 | pfleura2 | IdxCaFaire=2 |
834 | 1 | pfleura2 | CaFaire(1)=LiaisonsBis(Iat,1) |
835 | 1 | pfleura2 | CaFaire(2)=0 |
836 | 1 | pfleura2 | FCaf(LiaisonsBis(Iat,1))=.TRUE. |
837 | 1 | pfleura2 | |
838 | 1 | pfleura2 | ! We search for a third and fourth atoms, first in the FrozBlock atoms |
839 | 1 | pfleura2 | ! It should not be possible to have (FrozBlock(Iat,0).GT.2) and |
840 | 1 | pfleura2 | ! iat linked to only one atom ! |
841 | 1 | pfleura2 | |
842 | 1 | pfleura2 | IF (FrozBlock(Iat,0).GT.2) THEN |
843 | 1 | pfleura2 | WRITE(*,*) 'I found some inconsistancy: IAt linked to 1' |
844 | 1 | pfleura2 | WRITE(*,*) 'Atom only, but belongs to a frozblock of at ' |
845 | 1 | pfleura2 | WRITE(*,*) 'least 3 atoms. IAt, FrozBlock' |
846 | 1 | pfleura2 | WRITE(*,*) Iat,(FrozBlock(IAt,J),J=0,FrozBlock(Iat,0)) |
847 | 1 | pfleura2 | STOP |
848 | 1 | pfleura2 | END IF |
849 | 1 | pfleura2 | |
850 | 1 | pfleura2 | ! we calculate the distances between Iat and all other frozen |
851 | 1 | pfleura2 | ! atoms of this fragment, and store only those for which |
852 | 1 | pfleura2 | ! valence angles are not too close to 0/Pi. (limit:5?) |
853 | 1 | pfleura2 | |
854 | 1 | pfleura2 | ITmp=0 |
855 | 1 | pfleura2 | CALL vecteur(LiaisonsBis(Iat,1),IAt,x,y,z,vx2,vy2,vz2,norm2) |
856 | 1 | pfleura2 | |
857 | 1 | pfleura2 | DO I=1,NbAtFrag(IFrag) |
858 | 1 | pfleura2 | JAt=FragAt(IFrag,I) |
859 | 1 | pfleura2 | if (FrozAt(Jat).AND.(.NOT.DejaFait(JAt))) THEN |
860 | 1 | pfleura2 | CALL vecteur(JAt,IAt,x,y,z,vx1,vy1,vz1,norm1) |
861 | 1 | pfleura2 | if (abs(cos(angle(vx1,vy1,vz1,norm1, & |
862 | 1 | pfleura2 | vx2,vy2,vz2,norm2))).LE.0.996d0) THEN |
863 | 1 | pfleura2 | ITmp=ITmp+1 |
864 | 1 | pfleura2 | DistFroz(ITmp)=Norm1 |
865 | 1 | pfleura2 | FrozDist(ITmp)=JAt |
866 | 1 | pfleura2 | END IF |
867 | 1 | pfleura2 | END IF |
868 | 1 | pfleura2 | END DO |
869 | 1 | pfleura2 | |
870 | 1 | pfleura2 | IF (ITMP.EQ.0) THEN |
871 | 1 | pfleura2 | ! We have no frozen atoms correct in this fragment, we use |
872 | 1 | pfleura2 | ! atoms from other fragments |
873 | 1 | pfleura2 | DO I=1,NFroz |
874 | 1 | pfleura2 | Jat=Frozen(I) |
875 | 1 | pfleura2 | if (.NOT.DejaFait(JAt)) THEN |
876 | 1 | pfleura2 | CALL vecteur(JAt,IAt,x,y,z,vx1,vy1,vz1,norm1) |
877 | 1 | pfleura2 | if (abs(cos(angle(vx1,vy1,vz1,norm1, & |
878 | 1 | pfleura2 | vx2,vy2,vz2,norm2))).LE.0.996d0) THEN |
879 | 1 | pfleura2 | ITmp=ITmp+1 |
880 | 1 | pfleura2 | DistFroz(ITmp)=Norm1 |
881 | 1 | pfleura2 | FrozDist(ITmp)=JAt |
882 | 1 | pfleura2 | END IF |
883 | 1 | pfleura2 | END IF |
884 | 1 | pfleura2 | END DO |
885 | 1 | pfleura2 | IF (ITMP.EQ.0) THEN |
886 | 1 | pfleura2 | WRITE(*,*) 'It seems all frozen atoms are aligned' |
887 | 1 | pfleura2 | WRITE(*,*) 'Case non treated for now :-( ' |
888 | 1 | pfleura2 | STOP |
889 | 1 | pfleura2 | END IF |
890 | 1 | pfleura2 | END IF |
891 | 1 | pfleura2 | |
892 | 1 | pfleura2 | I1=0 |
893 | 1 | pfleura2 | d=1e9 |
894 | 1 | pfleura2 | DO I=1,ITmp |
895 | 1 | pfleura2 | IF (DistFroz(I).LE.d) THEN |
896 | 1 | pfleura2 | I1=FrozDist(I) |
897 | 1 | pfleura2 | d=DistFroz(I) |
898 | 1 | pfleura2 | END IF |
899 | 1 | pfleura2 | END DO |
900 | 1 | pfleura2 | |
901 | 1 | pfleura2 | ! we now have the atom that is closer to the first one and that |
902 | 1 | pfleura2 | ! forms a non 0/Pi valence angle |
903 | 1 | pfleura2 | ind_zmat(3,1)=I1 |
904 | 1 | pfleura2 | ind_zmat(3,2)=IAt |
905 | 1 | pfleura2 | ind_zmat(3,3)=LiaisonsBis(Iat,1) |
906 | 1 | pfleura2 | DejaFait(I1)=.TRUE. |
907 | 1 | pfleura2 | CaFaire(2)=I1 |
908 | 1 | pfleura2 | FCaf(I1)=.TRUE. |
909 | 1 | pfleura2 | |
910 | 1 | pfleura2 | |
911 | 1 | pfleura2 | ! we search for a fourth atom ! |
912 | 1 | pfleura2 | ! We search for a fourth atom, first in the FrozBlock atoms |
913 | 1 | pfleura2 | ITmp=2 |
914 | 1 | pfleura2 | sDihe=0. |
915 | 1 | pfleura2 | n2=IAt |
916 | 1 | pfleura2 | n3=LiaisonsBis(Iat,1) |
917 | 1 | pfleura2 | n4=I1 |
918 | 1 | pfleura2 | CALL vecteur(n2,n3,x,y,z,vx2,vy2,vz2,norm2) |
919 | 1 | pfleura2 | CALL vecteur(n3,n4,x,y,z,vx3,vy3,vz3,norm3) |
920 | 2 | pfleura2 | CALL produit_vect(vx3,vy3,vz3, vx2,vy2,vz2, & |
921 | 1 | pfleura2 | vx5,vy5,vz5,norm5) |
922 | 1 | pfleura2 | |
923 | 1 | pfleura2 | ! We will look at the other frozen atoms |
924 | 1 | pfleura2 | ! we might improve the search so as to take the atom closest to IAt |
925 | 1 | pfleura2 | ITmp=0 |
926 | 1 | pfleura2 | DO I=1,NbAtFrag(IFrag) |
927 | 1 | pfleura2 | JAt=FragAt(IFrag,I) |
928 | 1 | pfleura2 | if (FrozAt(Jat).AND.(.NOT.DejaFait(JAt))) THEN |
929 | 1 | pfleura2 | n1=JAt |
930 | 1 | pfleura2 | CALL vecteur(n2,n1,x,y,z,vx1,vy1,vz1,norm1) |
931 | 2 | pfleura2 | CALL produit_vect(vx1,vy1,vz1, vx2,vy2,vz2, & |
932 | 1 | pfleura2 | vx4,vy4,vz4,norm4) |
933 | 1 | pfleura2 | val_d=angle_d(vx4,vy4,vz4,norm4, & |
934 | 1 | pfleura2 | vx5,vy5,vz5,norm5, & |
935 | 1 | pfleura2 | vx2,vy2,vz2,norm2) |
936 | 1 | pfleura2 | if (abs(sin(val_d)).GE.0.09D0) THEN |
937 | 1 | pfleura2 | ITmp=ITmp+1 |
938 | 1 | pfleura2 | DistFroz(ITmp)=Norm1 |
939 | 1 | pfleura2 | FrozDist(ITmp)=JAt |
940 | 1 | pfleura2 | END IF |
941 | 1 | pfleura2 | END IF |
942 | 1 | pfleura2 | END DO |
943 | 1 | pfleura2 | IF (ITmp.EQ.0) THEN |
944 | 1 | pfleura2 | ! All dihedral angles between frozen atoms are less than 5? |
945 | 1 | pfleura2 | ! (or more than 175?). We have to look at other fragments :-( |
946 | 1 | pfleura2 | DO I=1,NFroz |
947 | 1 | pfleura2 | Jat=Frozen(I) |
948 | 1 | pfleura2 | if (.NOT.DejaFait(JAt)) THEN |
949 | 1 | pfleura2 | n1=JAt |
950 | 1 | pfleura2 | CALL vecteur(n2,n1,x,y,z,vx1,vy1,vz1,norm1) |
951 | 2 | pfleura2 | CALL produit_vect(vx1,vy1,vz1, vx2,vy2,vz2, & |
952 | 1 | pfleura2 | vx4,vy4,vz4,norm4) |
953 | 1 | pfleura2 | val_d=angle_d(vx4,vy4,vz4,norm4, & |
954 | 1 | pfleura2 | vx5,vy5,vz5,norm5, & |
955 | 1 | pfleura2 | vx2,vy2,vz2,norm2) |
956 | 1 | pfleura2 | if (abs(sin(val_d)).GE.0.09D0) THEN |
957 | 1 | pfleura2 | ITmp=ITmp+1 |
958 | 1 | pfleura2 | DistFroz(ITmp)=Norm1 |
959 | 1 | pfleura2 | FrozDist(ITmp)=JAt |
960 | 1 | pfleura2 | END IF |
961 | 1 | pfleura2 | END IF |
962 | 1 | pfleura2 | END DO |
963 | 1 | pfleura2 | IF (ITmp.EQ.0) THEN |
964 | 1 | pfleura2 | ! All frozen atoms are in a plane... too bad |
965 | 1 | pfleura2 | WRITE(*,*) 'ERROR: It seems that all frozen atoms are in a plane' |
966 | 1 | pfleura2 | WRITE(*,*) 'For now, I do not treat this case' |
967 | 1 | pfleura2 | STOP |
968 | 1 | pfleura2 | END IF |
969 | 1 | pfleura2 | END IF ! ITmp.EQ.0 after scaning fragment |
970 | 1 | pfleura2 | I1=0 |
971 | 1 | pfleura2 | d=1e9 |
972 | 1 | pfleura2 | DO I=1,ITmp |
973 | 1 | pfleura2 | IF (DistFroz(I).LE.d) THEN |
974 | 1 | pfleura2 | d=DistFroz(I) |
975 | 1 | pfleura2 | I1=FrozDist(I) |
976 | 1 | pfleura2 | END IF |
977 | 1 | pfleura2 | END DO |
978 | 1 | pfleura2 | |
979 | 1 | pfleura2 | ! we now have the atom that is closer to the first one and that |
980 | 1 | pfleura2 | ! forms a non 0/Pi dihedral angle |
981 | 1 | pfleura2 | ! ind_zmat(4,1)=I1 |
982 | 1 | pfleura2 | ! ind_zmat(4,2)=IAt |
983 | 1 | pfleura2 | ! ind_zmat(4,3)=ind_zmat(2,1) |
984 | 1 | pfleura2 | ! ind_zmat(4,4)=ind_zmat(3,1) |
985 | 1 | pfleura2 | n3=ind_zmat(2,1) |
986 | 1 | pfleura2 | n4=ind_zmat(3,1) |
987 | 1 | pfleura2 | Call add2indzmat(na,4,I1,IAt,n3,n4,ind_zmat,x,y,z) |
988 | 1 | pfleura2 | ind_zmat(2,1)=n3 |
989 | 1 | pfleura2 | ind_zmat(3,1)=n4 |
990 | 1 | pfleura2 | DejaFait(I1)=.TRUE. |
991 | 1 | pfleura2 | CaFaire(3)=I1 |
992 | 1 | pfleura2 | CaFaire(4)=0 |
993 | 1 | pfleura2 | IdxCaFaire=4 |
994 | 1 | pfleura2 | izm=4 |
995 | 1 | pfleura2 | FCaf(I1)=.TRUE. |
996 | 1 | pfleura2 | |
997 | 1 | pfleura2 | CASE(0) |
998 | 1 | pfleura2 | WRITE(*,*) 'All frozen atoms are separated .. ' |
999 | 1 | pfleura2 | WRITE(*,*) 'this case should be treated separately !' |
1000 | 1 | pfleura2 | STOP |
1001 | 1 | pfleura2 | END SELECT |
1002 | 1 | pfleura2 | |
1003 | 1 | pfleura2 | if (debug) THEN |
1004 | 1 | pfleura2 | WRITE(*,*) 'ind_zmat 1' |
1005 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(1,1) |
1006 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(2,1), ind_zmat(2,2) |
1007 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(3,1), ind_zmat(3,2), ind_zmat(3,3) |
1008 | 1 | pfleura2 | DO I=4,izm |
1009 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(I,1), ind_zmat(I,2), & |
1010 | 1 | pfleura2 | ind_zmat(I,3), ind_zmat(I,4) |
1011 | 1 | pfleura2 | END DO |
1012 | 1 | pfleura2 | END IF |
1013 | 1 | pfleura2 | |
1014 | 1 | pfleura2 | DO I=1,izm |
1015 | 1 | pfleura2 | Idx_zmat(ind_zmat(I,1))=i |
1016 | 1 | pfleura2 | END Do |
1017 | 1 | pfleura2 | |
1018 | 1 | pfleura2 | ! at least first four (frozen) atoms of this fragment done... |
1019 | 1 | pfleura2 | ! we empty the 'cafaire' array before pursuing |
1020 | 1 | pfleura2 | IAFaire=1 |
1021 | 1 | pfleura2 | DO WHILE (CaFaire(IaFaire).NE.0) |
1022 | 1 | pfleura2 | n1=CaFaire(IaFaire) |
1023 | 1 | pfleura2 | n2=ind_zmat(idx_zmat(N1),2) |
1024 | 1 | pfleura2 | if (idx_zmat(N1).EQ.2) THEN |
1025 | 1 | pfleura2 | ! We have a (small) problem: we have to add atoms linked to the 2nd |
1026 | 1 | pfleura2 | ! atom of the zmat. This is a pb because we do not know |
1027 | 1 | pfleura2 | ! which atom to use to define the dihedral angle |
1028 | 1 | pfleura2 | ! we take the third atom of the zmat |
1029 | 1 | pfleura2 | n3=ind_zmat(3,1) |
1030 | 1 | pfleura2 | ELSE |
1031 | 1 | pfleura2 | n3=ind_zmat(idx_zmat(n1),3) |
1032 | 1 | pfleura2 | END IF |
1033 | 1 | pfleura2 | IF (LiaisonsBis(n1,0).GE.1) THEN |
1034 | 1 | pfleura2 | IAt=LiaisonsBis(n1,1) |
1035 | 1 | pfleura2 | if (.NOT.DejaFait(Iat)) THEN |
1036 | 1 | pfleura2 | izm=izm+1 |
1037 | 1 | pfleura2 | if (debug) WRITE(*,*) ">0< Adding atom ",Iat,"position izm=",izm |
1038 | 1 | pfleura2 | ! ind_zmat(izm,1)=iat |
1039 | 1 | pfleura2 | ! ind_zmat(izm,2)=n1 |
1040 | 1 | pfleura2 | ! ind_zmat(izm,3)=n2 |
1041 | 1 | pfleura2 | ! ind_zmat(izm,4)=n3 |
1042 | 1 | pfleura2 | Call add2indzmat(na,izm,iat,n1,n2,n3,ind_zmat,x,y,z) |
1043 | 1 | pfleura2 | Idx_zmat(iat)=izm |
1044 | 1 | pfleura2 | n3=iat |
1045 | 1 | pfleura2 | IF (.NOT.FCaf(Iat)) THEN |
1046 | 1 | pfleura2 | CaFaire(IdxCaFaire)=iat |
1047 | 1 | pfleura2 | IdxCaFaire=IdxCaFaire+1 |
1048 | 1 | pfleura2 | CaFaire(IdxCaFaire)=0 |
1049 | 1 | pfleura2 | FCaf(Iat)=.TRUE. |
1050 | 1 | pfleura2 | END IF |
1051 | 1 | pfleura2 | DejaFait(iat)=.TRUE. |
1052 | 1 | pfleura2 | END IF |
1053 | 1 | pfleura2 | END IF |
1054 | 1 | pfleura2 | DO I=2,LiaisonsBis(n1,0) |
1055 | 1 | pfleura2 | IAt=LiaisonsBis(n1,I) |
1056 | 1 | pfleura2 | ! PFL 29.Aug.2008 -> |
1057 | 1 | pfleura2 | ! We dissociate the test on 'DejaFait' that indicates that this atom |
1058 | 1 | pfleura2 | ! has already been put in the Zmat |
1059 | 1 | pfleura2 | ! from the test on FCaf that indicates that this atom has been put in the |
1060 | 1 | pfleura2 | ! 'CAFaire' list that deals with identifying its connectivity. |
1061 | 1 | pfleura2 | ! Those two test might differ for a frozen atom linked to non frozen atoms. |
1062 | 1 | pfleura2 | IF (.NOT.DejaFait(Iat)) THEN |
1063 | 1 | pfleura2 | izm=izm+1 |
1064 | 1 | pfleura2 | if (debug) WRITE(*,*) ">1< Adding atom ",Iat,"position izm=",izm |
1065 | 1 | pfleura2 | ! ind_zmat(izm,1)=iat |
1066 | 1 | pfleura2 | ! ind_zmat(izm,2)=n1 |
1067 | 1 | pfleura2 | ! ind_zmat(izm,3)=n2 |
1068 | 1 | pfleura2 | ! ind_zmat(izm,4)=n3 |
1069 | 1 | pfleura2 | Call add2indzmat(na,izm,iat,n1,n2,n3,ind_zmat,x,y,z) |
1070 | 1 | pfleura2 | idx_zmat(iat)=izm |
1071 | 1 | pfleura2 | DejaFait(iat)=.TRUE. |
1072 | 1 | pfleura2 | END IF |
1073 | 1 | pfleura2 | IF (.NOT.FCaf(Iat)) THEN |
1074 | 1 | pfleura2 | CaFaire(IdxCaFaire)=iat |
1075 | 1 | pfleura2 | IdxCaFaire=IdxCaFaire+1 |
1076 | 1 | pfleura2 | CaFaire(IdxCaFaire)=0 |
1077 | 1 | pfleura2 | FCaf(Iat)=.TRUE. |
1078 | 1 | pfleura2 | END IF |
1079 | 1 | pfleura2 | ! <- PFL 29.Aug.2008 |
1080 | 1 | pfleura2 | END DO |
1081 | 1 | pfleura2 | IaFaire=IaFaire+1 |
1082 | 1 | pfleura2 | END Do ! DO WHILE CaFaire |
1083 | 1 | pfleura2 | |
1084 | 1 | pfleura2 | if (debug) THEN |
1085 | 1 | pfleura2 | WRITE(*,*) 'ind_zmat 2, izm=',izm |
1086 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(1,1) |
1087 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(2,1), ind_zmat(2,2) |
1088 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(3,1), ind_zmat(3,2), ind_zmat(3,3) |
1089 | 1 | pfleura2 | DO I=4,izm |
1090 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(I,1), ind_zmat(I,2), & |
1091 | 1 | pfleura2 | ind_zmat(I,3), ind_zmat(I,4) |
1092 | 1 | pfleura2 | END DO |
1093 | 1 | pfleura2 | END IF |
1094 | 1 | pfleura2 | |
1095 | 1 | pfleura2 | ! We have finished putting atoms linked to the first one |
1096 | 1 | pfleura2 | ! we will add other frozen atoms of this fragment |
1097 | 1 | pfleura2 | DO I=1,NbAtFrag(IFrag) |
1098 | 1 | pfleura2 | Iat=FragAt(IFrag,I) |
1099 | 1 | pfleura2 | if (debug) WRITE(*,*) "DBG: I,Iat,Frozat,dejafait,frozbloc",I,Iat,FrozAt(Iat), DejaFait(Iat),FrozBlock(Iat,0) |
1100 | 1 | pfleura2 | IF (FrozAt(Iat).AND.(.NOT.DejaFait(Iat))) THEN |
1101 | 1 | pfleura2 | ! in order to have the zmat as connected as possible, |
1102 | 1 | pfleura2 | ! we look if this atom belongs to a frozblock |
1103 | 1 | pfleura2 | if (debug) WRITE(*,*) 'Treating atom I,Iat, FrozBlock ',I,Iat, FrozBlock(Iat,0) |
1104 | 1 | pfleura2 | IF (FrozBlock(Iat,0).EQ.1) THEN |
1105 | 1 | pfleura2 | ! it is a lonely atom :-) |
1106 | 1 | pfleura2 | d=1e9 |
1107 | 1 | pfleura2 | DO J=1,izm |
1108 | 1 | pfleura2 | Call vecteur(iat,ind_zmat(j,1),x,y,z,vx1,vy1,vz1,norm1) |
1109 | 1 | pfleura2 | if (norm1.le.d) THEN |
1110 | 1 | pfleura2 | Jat=j |
1111 | 1 | pfleura2 | d=norm1 |
1112 | 1 | pfleura2 | END IF |
1113 | 1 | pfleura2 | END DO |
1114 | 1 | pfleura2 | n2=ind_zmat(jat,1) |
1115 | 1 | pfleura2 | SELECT CASE(jat) |
1116 | 1 | pfleura2 | CASE (1) |
1117 | 1 | pfleura2 | n3=ind_zmat(2,1) |
1118 | 1 | pfleura2 | n4=ind_zmat(3,1) |
1119 | 1 | pfleura2 | CASE (2) |
1120 | 1 | pfleura2 | n3=ind_zmat(1,1) |
1121 | 1 | pfleura2 | n4=ind_zmat(3,1) |
1122 | 1 | pfleura2 | CASE DEFAULT |
1123 | 1 | pfleura2 | n3=ind_zmat(jAt,2) |
1124 | 1 | pfleura2 | n4=ind_zmat(jat,3) |
1125 | 1 | pfleura2 | END SELECT |
1126 | 1 | pfleura2 | izm=izm+1 |
1127 | 1 | pfleura2 | ! ind_zmat(izm,1)=iat |
1128 | 1 | pfleura2 | ! ind_zmat(izm,2)=n2 |
1129 | 1 | pfleura2 | ! ind_zmat(izm,3)=n3 |
1130 | 1 | pfleura2 | ! ind_zmat(izm,4)=n4 |
1131 | 1 | pfleura2 | Call add2indzmat(na,izm,iat,n2,n3,n4,ind_zmat,x,y,z) |
1132 | 1 | pfleura2 | DejaFait(iat)=.TRUE. |
1133 | 1 | pfleura2 | idx_zmat(iat)=iat |
1134 | 1 | pfleura2 | ELSE !(FrozBlock(Iat,0).EQ.1) |
1135 | 1 | pfleura2 | ! we have a group of atoms |
1136 | 1 | pfleura2 | ! We search for the atom of the group with the most links |
1137 | 1 | pfleura2 | ITmp=-1 |
1138 | 1 | pfleura2 | DO J=1,FrozBlock(Iat,0) |
1139 | 1 | pfleura2 | Jat=FrozBlock(Iat,J) |
1140 | 1 | pfleura2 | IF ((.NOT.DejaFait(Jat)).AND. & |
1141 | 1 | pfleura2 | (LiaisonsBis(Jat,0).GT.ITMP)) THEN |
1142 | 1 | pfleura2 | JL=Jat |
1143 | 1 | pfleura2 | ITmp=LiaisonsBis(Jat,0) |
1144 | 1 | pfleura2 | END IF |
1145 | 1 | pfleura2 | END DO |
1146 | 1 | pfleura2 | if (debug) WRITE(*,*) 'JL,ITmp:',JL,ITmp |
1147 | 1 | pfleura2 | Iat=JL |
1148 | 1 | pfleura2 | d=1e9 |
1149 | 1 | pfleura2 | DO J=1,izm |
1150 | 1 | pfleura2 | Call vecteur(iat,ind_zmat(j,1),x,y,z, vx1,vy1,vz1,norm1) |
1151 | 1 | pfleura2 | if (norm1.le.d) THEN |
1152 | 1 | pfleura2 | Jat=j |
1153 | 1 | pfleura2 | d=norm1 |
1154 | 1 | pfleura2 | END IF |
1155 | 1 | pfleura2 | END DO |
1156 | 1 | pfleura2 | if (debug) WRITE(*,*) 'Jat,d:',Jat,d |
1157 | 1 | pfleura2 | n2=ind_zmat(jat,1) |
1158 | 1 | pfleura2 | SELECT CASE(jat) |
1159 | 1 | pfleura2 | CASE (1) |
1160 | 1 | pfleura2 | n3=ind_zmat(2,1) |
1161 | 1 | pfleura2 | n4=ind_zmat(3,1) |
1162 | 1 | pfleura2 | CASE (2) |
1163 | 1 | pfleura2 | n3=ind_zmat(1,1) |
1164 | 1 | pfleura2 | n4=ind_zmat(3,1) |
1165 | 1 | pfleura2 | CASE DEFAULT |
1166 | 1 | pfleura2 | n3=ind_zmat(jAt,2) |
1167 | 1 | pfleura2 | n4=ind_zmat(jat,3) |
1168 | 1 | pfleura2 | END SELECT |
1169 | 1 | pfleura2 | izm=izm+1 |
1170 | 1 | pfleura2 | ! ind_zmat(izm,1)=iat |
1171 | 1 | pfleura2 | ! ind_zmat(izm,2)=n2 |
1172 | 1 | pfleura2 | ! ind_zmat(izm,3)=n3 |
1173 | 1 | pfleura2 | ! ind_zmat(izm,4)=n4 |
1174 | 1 | pfleura2 | Call add2indzmat(na,izm,iat,n2,n3,n4,ind_zmat,x,y,z) |
1175 | 1 | pfleura2 | idx_zmat(iat)=izm |
1176 | 1 | pfleura2 | DejaFait(iat)=.TRUE. |
1177 | 1 | pfleura2 | IdxCaFaire=2 |
1178 | 1 | pfleura2 | CaFaire(1)=iat |
1179 | 1 | pfleura2 | CaFaire(2)=0 |
1180 | 1 | pfleura2 | FCaf(Iat)=.TRUE. |
1181 | 1 | pfleura2 | |
1182 | 1 | pfleura2 | if (debug) WRITE(*,*) izm,iat,n2,n3,n4 |
1183 | 1 | pfleura2 | |
1184 | 1 | pfleura2 | IaFaire=1 |
1185 | 1 | pfleura2 | DO WHILE (CaFaire(IaFaire).NE.0) |
1186 | 1 | pfleura2 | n1=CaFaire(IaFaire) |
1187 | 1 | pfleura2 | n2=ind_zmat(idx_zmat(N1),2) |
1188 | 1 | pfleura2 | if (debug) WRITE(*,*) 'DBG Cafaire, Iafaire,n1,n2',Iafaire,n1,n2 |
1189 | 1 | pfleura2 | if (idx_zmat(N1).EQ.2) THEN |
1190 | 1 | pfleura2 | ! We have a (small) problem: we have to add atoms linked to the 2nd |
1191 | 1 | pfleura2 | ! atom of the zmat. This is a pb because we do not know |
1192 | 1 | pfleura2 | ! which atom to use to define the dihedral angle |
1193 | 1 | pfleura2 | ! we take the third atom of the zmat |
1194 | 1 | pfleura2 | n3=ind_zmat(3,1) |
1195 | 1 | pfleura2 | ELSE |
1196 | 1 | pfleura2 | n3=ind_zmat(idx_zmat(n1),3) |
1197 | 1 | pfleura2 | END IF |
1198 | 1 | pfleura2 | if (debug) WRITe(*,*) 'DBG :n3,liaisonBis',n3,LiaisonsBis(n1,0) |
1199 | 1 | pfleura2 | DO I3=1,LiaisonsBis(n1,0) |
1200 | 1 | pfleura2 | ! PFL 29.Aug.2008 -> |
1201 | 1 | pfleura2 | ! We dissociate the test on 'DejaFait' that indicates that this atom |
1202 | 1 | pfleura2 | ! has already been put in the Zmat |
1203 | 1 | pfleura2 | ! from the test on FCaf that indicates that this atom has been put in the |
1204 | 1 | pfleura2 | ! 'CAFaire' list that deals with identifying its connectivity. |
1205 | 1 | pfleura2 | ! Those two test might differ for a frozen atom linked to non frozen atoms. |
1206 | 1 | pfleura2 | IAt=LiaisonsBis(n1,I3) |
1207 | 1 | pfleura2 | if (.NOT.DejaFait(Iat)) THEN |
1208 | 1 | pfleura2 | izm=izm+1 |
1209 | 1 | pfleura2 | ! ind_zmat(izm,1)=iat |
1210 | 1 | pfleura2 | ! ind_zmat(izm,2)=n1 |
1211 | 1 | pfleura2 | ! ind_zmat(izm,3)=n2 |
1212 | 1 | pfleura2 | ! ind_zmat(izm,4)=n3 |
1213 | 1 | pfleura2 | Call add2indzmat(na,izm,iat,n1,n2,n3,ind_zmat,x,y,z) |
1214 | 1 | pfleura2 | idx_zmat(iat)=izm |
1215 | 1 | pfleura2 | if (I3.EQ.1) n3=ind_zmat(izm,1) |
1216 | 1 | pfleura2 | DejaFait(Iat)=.TRUE. |
1217 | 1 | pfleura2 | END IF |
1218 | 1 | pfleura2 | If (.NOT.FCaf(Iat)) THEN |
1219 | 1 | pfleura2 | CaFaire(IdxCaFaire)=iat |
1220 | 1 | pfleura2 | IdxCaFaire=IdxCaFaire+1 |
1221 | 1 | pfleura2 | CaFaire(IdxCaFaire)=0 |
1222 | 1 | pfleura2 | FCaf(Iat)=.TRUE. |
1223 | 1 | pfleura2 | END IF |
1224 | 1 | pfleura2 | ! <- PFL 29.Aug.2008 |
1225 | 1 | pfleura2 | END DO |
1226 | 1 | pfleura2 | IaFaire=IaFaire+1 |
1227 | 1 | pfleura2 | END Do ! DO WHILE CaFaire |
1228 | 1 | pfleura2 | END IF |
1229 | 1 | pfleura2 | END IF |
1230 | 1 | pfleura2 | if (debug) THEN |
1231 | 1 | pfleura2 | WRITE(*,*) 'ind_zmat 3' |
1232 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(1,1) |
1233 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(2,1), ind_zmat(2,2) |
1234 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(3,1), ind_zmat(3,2), ind_zmat(3,3) |
1235 | 1 | pfleura2 | DO Ip=4,izm |
1236 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(Ip,1), ind_zmat(Ip,2), & |
1237 | 1 | pfleura2 | ind_zmat(Ip,3), ind_zmat(Ip,4) |
1238 | 1 | pfleura2 | END DO |
1239 | 1 | pfleura2 | END IF |
1240 | 1 | pfleura2 | |
1241 | 1 | pfleura2 | END DO |
1242 | 1 | pfleura2 | |
1243 | 1 | pfleura2 | FrozFrag(IFrag,1)=-1 |
1244 | 1 | pfleura2 | FrozFrag(IFrag,2)=-1 |
1245 | 1 | pfleura2 | FrozFrag(IFrag,3)=-1 |
1246 | 1 | pfleura2 | |
1247 | 1 | pfleura2 | ! we start again with the rest of the molecule... |
1248 | 1 | pfleura2 | ! v 1.01 We add the fragment in the order corresponding to FrozFrag |
1249 | 1 | pfleura2 | KMax=0 |
1250 | 1 | pfleura2 | DO I=1,NbFrag |
1251 | 1 | pfleura2 | IF (FrozFrag(I,1).NE.0) KMax=KMax+1 |
1252 | 1 | pfleura2 | END DO |
1253 | 1 | pfleura2 | |
1254 | 1 | pfleura2 | IF (DEBUG) WRITE(*,*) "Adding the",Kmax,"fragments with frozen atoms" |
1255 | 1 | pfleura2 | DO K=1, KMax-1 |
1256 | 1 | pfleura2 | IFrag=0 |
1257 | 1 | pfleura2 | I0=0 |
1258 | 1 | pfleura2 | I1=0 |
1259 | 1 | pfleura2 | DO I=1,NbFrag |
1260 | 1 | pfleura2 | SELECT CASE(FrozFrag(I,3)-I0) |
1261 | 1 | pfleura2 | CASE (1:) |
1262 | 1 | pfleura2 | IFrag=I |
1263 | 1 | pfleura2 | I0=FrozFrag(I,3) |
1264 | 1 | pfleura2 | I1=FrozFrag(I,2) |
1265 | 1 | pfleura2 | CASE (0) |
1266 | 1 | pfleura2 | if (FrozFrag(I,2).GT.I1) THEN |
1267 | 1 | pfleura2 | IFrag=I |
1268 | 1 | pfleura2 | I0=FrozFrag(I,3) |
1269 | 1 | pfleura2 | I1=FrozFrag(I,2) |
1270 | 1 | pfleura2 | END IF |
1271 | 1 | pfleura2 | END SELECT |
1272 | 1 | pfleura2 | END DO |
1273 | 1 | pfleura2 | |
1274 | 1 | pfleura2 | FrozFrag(IFrag,1)=-1 |
1275 | 1 | pfleura2 | FrozFrag(IFrag,2)=-1 |
1276 | 1 | pfleura2 | FrozFrag(IFrag,3)=-1 |
1277 | 1 | pfleura2 | |
1278 | 1 | pfleura2 | if (debug) WRITE(*,*) "Adding Fragment ",IFrag,K |
1279 | 1 | pfleura2 | |
1280 | 1 | pfleura2 | DO I=1,NbAtFrag(IFrag) |
1281 | 1 | pfleura2 | Iat=FragAt(IFrag,I) |
1282 | 1 | pfleura2 | IF (FrozAt(Iat).AND.(.NOT.DejaFait(Iat))) THEN |
1283 | 1 | pfleura2 | ! in order to have the zmat as connected as possible, |
1284 | 1 | pfleura2 | ! we look if this atom belongs to a frozblock |
1285 | 1 | pfleura2 | IF (FrozBlock(Iat,0).EQ.1) THEN |
1286 | 1 | pfleura2 | ! it is a lonely atom :-) |
1287 | 1 | pfleura2 | if (debug) write(*,*) "DBG 4: Lonely atom",Iat |
1288 | 1 | pfleura2 | d=1e9 |
1289 | 1 | pfleura2 | DO J=1,izm |
1290 | 1 | pfleura2 | Call vecteur(iat,ind_zmat(j,1),x,y,z,vx1,vy1,vz1,norm1) |
1291 | 1 | pfleura2 | if (norm1.le.d) THEN |
1292 | 1 | pfleura2 | Jat=j |
1293 | 1 | pfleura2 | d=norm1 |
1294 | 1 | pfleura2 | END IF |
1295 | 1 | pfleura2 | END DO |
1296 | 1 | pfleura2 | n2=ind_zmat(jat,1) |
1297 | 1 | pfleura2 | SELECT CASE(jat) |
1298 | 1 | pfleura2 | CASE (1) |
1299 | 1 | pfleura2 | n3=ind_zmat(2,1) |
1300 | 1 | pfleura2 | n4=ind_zmat(3,1) |
1301 | 1 | pfleura2 | CASE (2) |
1302 | 1 | pfleura2 | n3=ind_zmat(1,1) |
1303 | 1 | pfleura2 | n4=ind_zmat(3,1) |
1304 | 1 | pfleura2 | CASE DEFAULT |
1305 | 1 | pfleura2 | n3=ind_zmat(jAt,2) |
1306 | 1 | pfleura2 | n4=ind_zmat(jat,3) |
1307 | 1 | pfleura2 | END SELECT |
1308 | 1 | pfleura2 | izm=izm+1 |
1309 | 1 | pfleura2 | ! ind_zmat(izm,1)=iat |
1310 | 1 | pfleura2 | ! ind_zmat(izm,2)=n2 |
1311 | 1 | pfleura2 | ! ind_zmat(izm,3)=n3 |
1312 | 1 | pfleura2 | ! ind_zmat(izm,4)=n4 |
1313 | 1 | pfleura2 | Call add2indzmat(na,izm,iat,n2,n3,n4,ind_zmat,x,y,z) |
1314 | 1 | pfleura2 | idx_zmat(iat)=izm |
1315 | 1 | pfleura2 | DejaFait(iat)=.TRUE. |
1316 | 1 | pfleura2 | ELSE |
1317 | 1 | pfleura2 | ! we have a group of atoms |
1318 | 1 | pfleura2 | ! We search for the atom of the group with the most links |
1319 | 1 | pfleura2 | if (debug) write(*,*) "DBG 4b: ",Iat," belong to frozblock",FrozBlock(Iat,0) |
1320 | 1 | pfleura2 | ITmp=-1 |
1321 | 1 | pfleura2 | DO J=1,FrozBlock(Iat,0) |
1322 | 1 | pfleura2 | Jat=FrozBlock(Iat,J) |
1323 | 1 | pfleura2 | IF ((.NOT.DejaFait(Jat)).AND. & |
1324 | 1 | pfleura2 | (LiaisonsBis(Jat,0).GT.ITMP)) THEN |
1325 | 1 | pfleura2 | JL=Jat |
1326 | 1 | pfleura2 | ITmp=LiaisonsBis(Jat,0) |
1327 | 1 | pfleura2 | END IF |
1328 | 1 | pfleura2 | END DO |
1329 | 1 | pfleura2 | Iat=JL |
1330 | 1 | pfleura2 | d=1e9 |
1331 | 1 | pfleura2 | DO J=1,izm |
1332 | 1 | pfleura2 | Call vecteur(iat,ind_zmat(j,1),x,y,z,vx1,vy1,vz1,norm1) |
1333 | 1 | pfleura2 | if (norm1.le.d) THEN |
1334 | 1 | pfleura2 | Jat=j |
1335 | 1 | pfleura2 | d=norm1 |
1336 | 1 | pfleura2 | END IF |
1337 | 1 | pfleura2 | END DO |
1338 | 1 | pfleura2 | n2=ind_zmat(jat,1) |
1339 | 1 | pfleura2 | SELECT CASE(jat) |
1340 | 1 | pfleura2 | CASE (1) |
1341 | 1 | pfleura2 | n3=ind_zmat(2,1) |
1342 | 1 | pfleura2 | n4=ind_zmat(3,1) |
1343 | 1 | pfleura2 | CASE (2) |
1344 | 1 | pfleura2 | n3=ind_zmat(1,1) |
1345 | 1 | pfleura2 | n4=ind_zmat(3,1) |
1346 | 1 | pfleura2 | CASE DEFAULT |
1347 | 1 | pfleura2 | n3=ind_zmat(jAt,2) |
1348 | 1 | pfleura2 | n4=ind_zmat(jat,3) |
1349 | 1 | pfleura2 | END SELECT |
1350 | 1 | pfleura2 | izm=izm+1 |
1351 | 1 | pfleura2 | ! ind_zmat(izm,1)=iat |
1352 | 1 | pfleura2 | ! ind_zmat(izm,2)=n2 |
1353 | 1 | pfleura2 | ! ind_zmat(izm,3)=n3 |
1354 | 1 | pfleura2 | ! ind_zmat(izm,4)=n4 |
1355 | 1 | pfleura2 | Call add2indzmat(na,izm,Iat,n2,n3,n4,ind_zmat,x,y,z) |
1356 | 1 | pfleura2 | idx_zmat(iat)=izm |
1357 | 1 | pfleura2 | DejaFait(iat)=.TRUE. |
1358 | 1 | pfleura2 | IdxCaFaire=2 |
1359 | 1 | pfleura2 | CaFaire(1)=iat |
1360 | 1 | pfleura2 | CaFaire(2)=0 |
1361 | 1 | pfleura2 | FCaf(Iat)=.TRUE. |
1362 | 1 | pfleura2 | IaFaire=1 |
1363 | 1 | pfleura2 | DO WHILE (CaFaire(IaFaire).NE.0) |
1364 | 1 | pfleura2 | n1=CaFaire(IaFaire) |
1365 | 1 | pfleura2 | n2=ind_zmat(idx_zmat(N1),2) |
1366 | 1 | pfleura2 | if (idx_zmat(N1).EQ.2) THEN |
1367 | 1 | pfleura2 | ! We have a (small) problem: we have to add atoms linked to the 2nd |
1368 | 1 | pfleura2 | ! atom of the zmat. This is a pb because we do not know |
1369 | 1 | pfleura2 | ! which atom to use to define the dihedral angle |
1370 | 1 | pfleura2 | ! we take the third atom of the zmat |
1371 | 1 | pfleura2 | n3=ind_zmat(3,1) |
1372 | 1 | pfleura2 | ELSE |
1373 | 1 | pfleura2 | n3=ind_zmat(idx_zmat(n1),3) |
1374 | 1 | pfleura2 | END IF |
1375 | 1 | pfleura2 | DO I3=1,LiaisonsBis(n1,0) |
1376 | 1 | pfleura2 | IAt=LiaisonsBis(n1,I3) |
1377 | 1 | pfleura2 | ! PFL 29.Aug.2008 -> |
1378 | 1 | pfleura2 | ! We dissociate the test on 'DejaFait' that indicates that this atom |
1379 | 1 | pfleura2 | ! has already been put in the Zmat |
1380 | 1 | pfleura2 | ! from the test on FCaf that indicates that this atom has been put in the |
1381 | 1 | pfleura2 | ! 'CAFaire' list that deals with identifying its connectivity. |
1382 | 1 | pfleura2 | ! Those two test might differ for a frozen atom linked to non frozen atoms. |
1383 | 1 | pfleura2 | IF (.NOT.DejaFait(Iat)) THEN |
1384 | 1 | pfleura2 | izm=izm+1 |
1385 | 1 | pfleura2 | Call add2indzmat(na,izm,Iat,n1,n2,n3,ind_zmat,x,y,z) |
1386 | 1 | pfleura2 | idx_zmat(iat)=izm |
1387 | 1 | pfleura2 | n3=iat |
1388 | 1 | pfleura2 | DejaFait(Iat)=.TRUE. |
1389 | 1 | pfleura2 | END IF |
1390 | 1 | pfleura2 | IF (.NOT.FCaf(Iat)) THEN |
1391 | 1 | pfleura2 | CaFaire(IdxCaFaire)=iat |
1392 | 1 | pfleura2 | IdxCaFaire=IdxCaFaire+1 |
1393 | 1 | pfleura2 | CaFaire(IdxCaFaire)=0 |
1394 | 1 | pfleura2 | FCaf(Iat)=.TRUE. |
1395 | 1 | pfleura2 | END IF |
1396 | 1 | pfleura2 | ! <- PFL 29.Aug.2008 |
1397 | 1 | pfleura2 | END DO |
1398 | 1 | pfleura2 | IaFaire=IaFaire+1 |
1399 | 1 | pfleura2 | END Do ! DO WHILE CaFaire |
1400 | 1 | pfleura2 | END IF |
1401 | 1 | pfleura2 | END IF |
1402 | 1 | pfleura2 | |
1403 | 1 | pfleura2 | if (debug) THEN |
1404 | 1 | pfleura2 | WRITE(*,*) 'ind_zmat 4' |
1405 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(1,1) |
1406 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(2,1), ind_zmat(2,2) |
1407 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(3,1), ind_zmat(3,2), ind_zmat(3,3) |
1408 | 1 | pfleura2 | DO Ip=4,izm |
1409 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(Ip,1), ind_zmat(Ip,2), & |
1410 | 1 | pfleura2 | ind_zmat(Ip,3), ind_zmat(Ip,4) |
1411 | 1 | pfleura2 | END DO |
1412 | 1 | pfleura2 | END IF |
1413 | 1 | pfleura2 | |
1414 | 1 | pfleura2 | END DO ! loop on atoms of fragment IFrag |
1415 | 1 | pfleura2 | END DO ! Loop on all fragments |
1416 | 1 | pfleura2 | |
1417 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1418 | 1 | pfleura2 | ! |
1419 | 1 | pfleura2 | ! General case |
1420 | 1 | pfleura2 | ! |
1421 | 1 | pfleura2 | ! 2 - we have all frozen atoms done... now comes the non frozen atoms |
1422 | 1 | pfleura2 | ! and we should fragment the fragments ! |
1423 | 1 | pfleura2 | ! |
1424 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1425 | 1 | pfleura2 | |
1426 | 1 | pfleura2 | ! First, we get rid of bonds between frozen atoms |
1427 | 1 | pfleura2 | ! the trick is to do this on liaisons while keeping LiaisonsBis ok. |
1428 | 1 | pfleura2 | |
1429 | 1 | pfleura2 | if (debug) THEN |
1430 | 1 | pfleura2 | WRITE(*,*) 'Frozen',NFroz |
1431 | 1 | pfleura2 | WRITE(*,'(20(1X,I3))') (Frozen(I),I=1,NFroz) |
1432 | 1 | pfleura2 | END IF |
1433 | 1 | pfleura2 | |
1434 | 1 | pfleura2 | DO I=1,na |
1435 | 1 | pfleura2 | DO J=0,NMAxL |
1436 | 1 | pfleura2 | LiaisonsIni(I,J)=LiaisonsBis(I,J) |
1437 | 1 | pfleura2 | END DO |
1438 | 1 | pfleura2 | ! PFL 29.Aug.2008 -> |
1439 | 1 | pfleura2 | ! We re-initialize FCaf in order to add frozen atoms that are connected |
1440 | 1 | pfleura2 | ! to non frozen atoms |
1441 | 1 | pfleura2 | FCaf(I)=.FALSE. |
1442 | 1 | pfleura2 | ! <- 29.Aug.2008 |
1443 | 1 | pfleura2 | END DO |
1444 | 1 | pfleura2 | |
1445 | 1 | pfleura2 | DO I=1,Na |
1446 | 1 | pfleura2 | IF (FrozAt(I)) THEN |
1447 | 1 | pfleura2 | Iat=I |
1448 | 1 | pfleura2 | if (debug) WRITE(*,'(20(1X,I3))') I,Iat, & |
1449 | 1 | pfleura2 | (LiaisonsIni(Iat,Itmp),ITmp=0,LiaisonsIni(Iat,0)) |
1450 | 1 | pfleura2 | DO J=1,LiaisonsIni(Iat,0) |
1451 | 1 | pfleura2 | Jat=LiaisonsIni(Iat,J) |
1452 | 1 | pfleura2 | Call Annul(Liaisons,Iat,Jat) |
1453 | 1 | pfleura2 | Call Annul(Liaisons,Jat,Iat) |
1454 | 1 | pfleura2 | Call Annul(LiaisonsIni,Jat,Iat) |
1455 | 1 | pfleura2 | Liaisons(Iat,0)=Liaisons(Iat,0)-1 |
1456 | 1 | pfleura2 | Liaisons(Jat,0)=Liaisons(Jat,0)-1 |
1457 | 1 | pfleura2 | LiaisonsIni(Jat,0)=LiaisonsIni(Jat,0)-1 |
1458 | 1 | pfleura2 | END DO |
1459 | 1 | pfleura2 | END IF |
1460 | 1 | pfleura2 | END DO |
1461 | 1 | pfleura2 | |
1462 | 1 | pfleura2 | if (debug) THEN |
1463 | 1 | pfleura2 | WRITE(*,*) "Connections calculees" |
1464 | 1 | pfleura2 | DO IL=1,na |
1465 | 1 | pfleura2 | WRITE(IOOUT,1003) Il,(LIAISONS(IL,JL),JL=0,NMaxL) |
1466 | 1 | pfleura2 | END DO |
1467 | 1 | pfleura2 | END IF |
1468 | 1 | pfleura2 | |
1469 | 1 | pfleura2 | |
1470 | 1 | pfleura2 | |
1471 | 1 | pfleura2 | ! We re-decompose the system into fragments, but we omit on purpuse |
1472 | 1 | pfleura2 | ! fragments consisting only of frozen atoms |
1473 | 1 | pfleura2 | ! Now, frozblock will contain the frozen atom indices in a given fragment |
1474 | 1 | pfleura2 | |
1475 | 1 | pfleura2 | DO I=1,na |
1476 | 1 | pfleura2 | Fragment(I)=0 |
1477 | 1 | pfleura2 | NbAtFrag(I)=0 |
1478 | 1 | pfleura2 | FrozBlock(I,0)=0 |
1479 | 1 | pfleura2 | END DO |
1480 | 1 | pfleura2 | IdxFrag=0 |
1481 | 1 | pfleura2 | NbFrag=0 |
1482 | 1 | pfleura2 | |
1483 | 1 | pfleura2 | DO I=1,na |
1484 | 1 | pfleura2 | IdxCAfaire=1 |
1485 | 1 | pfleura2 | CaFaire(IdxCaFaire)=0 |
1486 | 1 | pfleura2 | |
1487 | 1 | pfleura2 | if (debug) WRITE(*,*) 'Treating atom I, fragment(I)',I,Fragment(I) |
1488 | 1 | pfleura2 | IF (.NOT.FrozAt(I).OR.(Liaisons(I,0).NE.0)) THEN |
1489 | 1 | pfleura2 | IF (Fragment(I).EQ.0) THEN |
1490 | 1 | pfleura2 | IdxFrag=IdxFrag+1 |
1491 | 1 | pfleura2 | NbFrag=NbFrag+1 |
1492 | 1 | pfleura2 | IFrag=IdxFrag |
1493 | 1 | pfleura2 | Fragment(I)=IFrag |
1494 | 1 | pfleura2 | NbAtFrag(IFrag)=NbAtFrag(IFrag)+1 |
1495 | 1 | pfleura2 | FragAt(IFrag,NbAtFrag(IFrag))=I |
1496 | 1 | pfleura2 | ELSE ! fragment(I).EQ.0 |
1497 | 1 | pfleura2 | IFrag=Fragment(I) |
1498 | 1 | pfleura2 | END IF ! fragment(I).EQ.0 |
1499 | 1 | pfleura2 | DO J=1,Liaisons(I,0) |
1500 | 1 | pfleura2 | Iat=Liaisons(I,J) |
1501 | 1 | pfleura2 | IF ((Fragment(Iat).NE.0).AND.(Fragment(Iat).NE.IFrag)) THEN |
1502 | 1 | pfleura2 | WRITE(*,*) 'Error : Atoms ',I,' and ',Iat |
1503 | 1 | pfleura2 | WRITE(*,*) 'are linked, but belongs to fragments ',IFrag,' and ',Fragment(Iat) |
1504 | 1 | pfleura2 | STOP |
1505 | 1 | pfleura2 | END IF |
1506 | 1 | pfleura2 | IF (Fragment(Iat).EQ.0) THEN |
1507 | 1 | pfleura2 | IF (.NOT.FCaf(IAt)) THEN |
1508 | 1 | pfleura2 | CaFaire(IdxCaFaire)=Iat |
1509 | 1 | pfleura2 | IdxCAfaire=IdxCAFaire+1 |
1510 | 1 | pfleura2 | FCaf(IAt)=.TRUE. |
1511 | 1 | pfleura2 | END IF |
1512 | 1 | pfleura2 | Fragment(Iat)=IFrag |
1513 | 1 | pfleura2 | NbAtFrag(IFrag)=NbAtFrag(IFrag)+1 |
1514 | 1 | pfleura2 | FragAt(IFrag,NbAtFrag(IFrag))=Iat |
1515 | 1 | pfleura2 | END IF |
1516 | 1 | pfleura2 | END DO |
1517 | 1 | pfleura2 | CaFaire(IdxCaFaire)=0 |
1518 | 1 | pfleura2 | |
1519 | 1 | pfleura2 | If (debug) WRITE(*,'(1X,A,1000I4)') 'Cafaire:',CaFaire(1:IdxCaFaire) |
1520 | 1 | pfleura2 | If (debug) WRITE(*,*) 'IFrag=',IFrag |
1521 | 1 | pfleura2 | |
1522 | 1 | pfleura2 | IAfaire=1 |
1523 | 1 | pfleura2 | DO WHILE (CaFaire(IAfaire).NE.0) |
1524 | 1 | pfleura2 | Iat=CaFaire(IaFaire) |
1525 | 1 | pfleura2 | IF (.NOT.FrozAt(Iat).OR.(Liaisons(Iat,0).NE.0)) THEN |
1526 | 1 | pfleura2 | if (debug) WRITE(*,*) 'Cafaire treating ',Iat |
1527 | 1 | pfleura2 | IF (Fragment(Iat).EQ.0) THEN |
1528 | 1 | pfleura2 | WRITE(*,*) 'Error: Atom ',Iat,' does not belong to any fragment !' |
1529 | 1 | pfleura2 | STOP |
1530 | 1 | pfleura2 | END IF |
1531 | 1 | pfleura2 | |
1532 | 1 | pfleura2 | DO J=1,Liaisons(Iat,0) |
1533 | 1 | pfleura2 | Jat=Liaisons(Iat,J) |
1534 | 1 | pfleura2 | IF ((Fragment(Jat).NE.0).AND.(Fragment(Jat).NE.IFrag)) THEN |
1535 | 1 | pfleura2 | WRITE(*,*) 'Error: Atoms ',Iat,' and ',Liaisons(Iat,J) |
1536 | 1 | pfleura2 | WRITE(*,*) 'are linked, but belongs to fragments ',IFrag,' and ',Fragment(Liaisons(Iat,J)) |
1537 | 1 | pfleura2 | STOP |
1538 | 1 | pfleura2 | END IF |
1539 | 1 | pfleura2 | IF (Fragment(Jat).EQ.0) THEN |
1540 | 1 | pfleura2 | IF (.NOT.FCaf(Liaisons(Iat,J))) THEN |
1541 | 1 | pfleura2 | CaFaire(IdxCaFaire)=Liaisons(Iat,J) |
1542 | 1 | pfleura2 | IdxCAfaire=IdxCAFaire+1 |
1543 | 1 | pfleura2 | FCaf(Liaisons(Iat,J))=.TRUE. |
1544 | 1 | pfleura2 | END IF |
1545 | 1 | pfleura2 | Fragment(Jat)=IFrag |
1546 | 1 | pfleura2 | NbAtFrag(IFrag)=NbAtFrag(IFrag)+1 |
1547 | 1 | pfleura2 | FragAt(IFrag,NbAtFrag(IFrag))=Jat |
1548 | 1 | pfleura2 | END IF |
1549 | 1 | pfleura2 | END DO |
1550 | 1 | pfleura2 | CaFaire(IdxCaFaire)=0 |
1551 | 1 | pfleura2 | If (debug) WRITE(*,*) 'IAfaire, IdxCaFaire,Cafaire :',IAfaire,IdxCafaire,' == ',CaFaire(IaFaire+1:IdxCaFaire) |
1552 | 1 | pfleura2 | IAFaire=IAFaire+1 |
1553 | 1 | pfleura2 | END IF |
1554 | 1 | pfleura2 | END DO |
1555 | 1 | pfleura2 | END IF |
1556 | 1 | pfleura2 | END DO |
1557 | 1 | pfleura2 | |
1558 | 1 | pfleura2 | ! We compute FrozBlock now |
1559 | 1 | pfleura2 | DO IFrag=1,NbFrag |
1560 | 1 | pfleura2 | DO I=1,NbAtFrag(IFrag) |
1561 | 1 | pfleura2 | Iat=FragAt(IFrag,I) |
1562 | 1 | pfleura2 | IF (FrozAt(Iat)) THEN |
1563 | 1 | pfleura2 | FrozBlock(IFrag,0)=FrozBlock(IFrag,0)+1 |
1564 | 1 | pfleura2 | FrozBlock(IFrag,FrozBlock(IFrag,0))=IAt |
1565 | 1 | pfleura2 | END IF |
1566 | 1 | pfleura2 | END DO |
1567 | 1 | pfleura2 | END DO |
1568 | 1 | pfleura2 | |
1569 | 1 | pfleura2 | |
1570 | 1 | pfleura2 | if (debug) THEN |
1571 | 1 | pfleura2 | WRITE(*,*) 'I found ',NbFrag, 'fragments with respectively ' |
1572 | 1 | pfleura2 | WRITE(*,*) (NbAtFrag(I),I=1,NbFrag), 'atoms' |
1573 | 1 | pfleura2 | WRITE(*,*) "Fragments atoms are now listed as F in the following" |
1574 | 1 | pfleura2 | DO I=1,NbFrag |
1575 | 1 | pfleura2 | WRITE(*,*) Na |
1576 | 1 | pfleura2 | WRITE(*,*) 'Fragment ', i |
1577 | 1 | pfleura2 | DO J=1,Na |
1578 | 1 | pfleura2 | AtName=Nom(Atome(J)) |
1579 | 1 | pfleura2 | IF (Fragment(J).EQ.I) AtName='F' |
1580 | 1 | pfleura2 | WRITE(*,'(1X,A5,3(1X,F10.6))') AtName,X(J),Y(J),Z(J) |
1581 | 1 | pfleura2 | END DO |
1582 | 1 | pfleura2 | ! WRITE(*,*) "FragAt:",(FragAt(I,j),j=1,NbAtFrag(I)) |
1583 | 1 | pfleura2 | END DO |
1584 | 1 | pfleura2 | |
1585 | 1 | pfleura2 | DO I=1,NbFrag |
1586 | 1 | pfleura2 | WRITE(*,*) 'Fragment ', i |
1587 | 1 | pfleura2 | WRITE(*,'(A,20(1X,I3))') "FragAt:",(FragAt(I,j),j=1,NbAtFrag(I)) |
1588 | 1 | pfleura2 | WRITE(*,'(A,20(1X,I3))') "FrozBlock:",(FrozBlock(I,j),j=0,FrozBlock(I,0)) |
1589 | 1 | pfleura2 | END DO |
1590 | 1 | pfleura2 | END IF |
1591 | 1 | pfleura2 | |
1592 | 1 | pfleura2 | |
1593 | 1 | pfleura2 | NFroz=0 |
1594 | 1 | pfleura2 | DO IFrag=1,NbFrag |
1595 | 1 | pfleura2 | If (FrozBlock(IFrag,0).NE.0) NFroz=NFroz+1 |
1596 | 1 | pfleura2 | END DO |
1597 | 1 | pfleura2 | |
1598 | 1 | pfleura2 | IF (DEBUG) WRITE(*,'(1X,A,I4,A,I4,A)') "Found ",NFroz," fragmenst with frozen atoms, out of",NbFrag," fragments" |
1599 | 1 | pfleura2 | |
1600 | 1 | pfleura2 | ! We will now add the fragments containing non frozen atoms. |
1601 | 1 | pfleura2 | ! I am not sure that there is a best strategy to add them... |
1602 | 1 | pfleura2 | ! so we add them in the order they were created :-( |
1603 | 1 | pfleura2 | ! First only block with frozen atoms are added |
1604 | 1 | pfleura2 | izm0=-1 |
1605 | 1 | pfleura2 | IFrag=1 |
1606 | 1 | pfleura2 | FCaf=.FALSE. |
1607 | 1 | pfleura2 | |
1608 | 1 | pfleura2 | DO IFragFroz=1,NFroz |
1609 | 1 | pfleura2 | DO WHILE (FrozBlock(IFrag,0).EQ.0) |
1610 | 1 | pfleura2 | IFrag=IFrag+1 |
1611 | 1 | pfleura2 | END DO |
1612 | 1 | pfleura2 | ! each atom has at least one frozen atom that will serve as the seed |
1613 | 1 | pfleura2 | ! of this fragment. |
1614 | 1 | pfleura2 | if (debug) WRITE(*,*) 'Adding fragment :', ifrag,'with',FrozBlock(IFrag,0),' frozen atoms' |
1615 | 1 | pfleura2 | IF (FrozBlock(IFrag,0).EQ.1) THEN |
1616 | 1 | pfleura2 | ! There is only one frozen atom, easy case ... |
1617 | 1 | pfleura2 | Iat=FrozBlock(IFrag,1) |
1618 | 1 | pfleura2 | if (debug) WRITE(*,*) 'Only frozen atom of frag',iat |
1619 | 1 | pfleura2 | DejaFait(iat)=.TRUE. |
1620 | 1 | pfleura2 | IdxCaFaire=2 |
1621 | 1 | pfleura2 | CaFaire(1)=iat |
1622 | 1 | pfleura2 | CaFaire(2)=0 |
1623 | 1 | pfleura2 | FCaf(Iat)=.TRUE. |
1624 | 1 | pfleura2 | IaFaire=1 |
1625 | 1 | pfleura2 | DO WHILE (CaFaire(IaFaire).NE.0) |
1626 | 1 | pfleura2 | n1=CaFaire(IaFaire) |
1627 | 1 | pfleura2 | SELECT CASE(idx_zmat(n1)) |
1628 | 1 | pfleura2 | CASE (1) |
1629 | 1 | pfleura2 | n2=ind_zmat(2,1) |
1630 | 1 | pfleura2 | n3=ind_zmat(3,1) |
1631 | 1 | pfleura2 | CASE (2) |
1632 | 1 | pfleura2 | n2=ind_zmat(1,1) |
1633 | 1 | pfleura2 | n3=ind_zmat(3,1) |
1634 | 1 | pfleura2 | CASE (3:) |
1635 | 1 | pfleura2 | n2=ind_zmat(idx_zmat(n1),2) |
1636 | 1 | pfleura2 | n3=ind_zmat(idx_zmat(n1),3) |
1637 | 1 | pfleura2 | END SELECT |
1638 | 1 | pfleura2 | |
1639 | 1 | pfleura2 | DO I3=1,Liaisons(n1,0) |
1640 | 1 | pfleura2 | IAt=Liaisons(n1,I3) |
1641 | 1 | pfleura2 | ! PFL 2007.Apr.16 -> |
1642 | 1 | pfleura2 | ! We add ALL atoms linked to n1 to CaFaire |
1643 | 1 | pfleura2 | ! But we delete their link to n1 |
1644 | 1 | pfleura2 | IF (.NOT.FCaf(Iat)) THEN |
1645 | 1 | pfleura2 | CaFaire(IdxCaFaire)=Iat |
1646 | 1 | pfleura2 | IdxCaFaire=IdxCaFaire+1 |
1647 | 1 | pfleura2 | CaFaire(IdxCaFaire)=0 |
1648 | 1 | pfleura2 | END IF |
1649 | 1 | pfleura2 | Call Annul(Liaisons,Iat,n1) |
1650 | 1 | pfleura2 | Liaisons(iat,0)=Liaisons(Iat,0)-1 |
1651 | 1 | pfleura2 | ! <- PFL 2007.Apr.16 |
1652 | 1 | pfleura2 | IF (.NOT.DejaFait(Iat)) THEN |
1653 | 1 | pfleura2 | ! we add it to the Zmat |
1654 | 1 | pfleura2 | izm=izm+1 |
1655 | 1 | pfleura2 | ! ind_zmat(izm,1)=iat |
1656 | 1 | pfleura2 | ! ind_zmat(izm,2)=n1 |
1657 | 1 | pfleura2 | ! ind_zmat(izm,3)=n2 |
1658 | 1 | pfleura2 | ! ind_zmat(izm,4)=n3 |
1659 | 1 | pfleura2 | Call add2indzmat(na,izm,Iat,n1,n2,n3,ind_zmat,x,y,z) |
1660 | 1 | pfleura2 | idx_zmat(iat)=izm |
1661 | 1 | pfleura2 | ! Call Annul(Liaisons,n1,iat) |
1662 | 1 | pfleura2 | n3=iat |
1663 | 1 | pfleura2 | DejaFait(Iat)=.TRUE. |
1664 | 1 | pfleura2 | END IF |
1665 | 1 | pfleura2 | END DO |
1666 | 1 | pfleura2 | IaFaire=IaFaire+1 |
1667 | 1 | pfleura2 | |
1668 | 1 | pfleura2 | if (debug) THEN |
1669 | 1 | pfleura2 | WRITE(*,*) 'ind_zmat 5' |
1670 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(1,1) |
1671 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(2,1), ind_zmat(2,2) |
1672 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(3,1), ind_zmat(3,2), ind_zmat(3,3) |
1673 | 1 | pfleura2 | DO Ip=4,izm |
1674 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(Ip,1), & |
1675 | 1 | pfleura2 | ind_zmat(Ip,2),ind_zmat(Ip,3), ind_zmat(Ip,4) |
1676 | 1 | pfleura2 | END DO |
1677 | 1 | pfleura2 | END IF |
1678 | 1 | pfleura2 | |
1679 | 1 | pfleura2 | END Do ! DO WHILE CaFaire |
1680 | 1 | pfleura2 | |
1681 | 1 | pfleura2 | |
1682 | 1 | pfleura2 | ELSE ! FrozBlock(I,0)==1 |
1683 | 1 | pfleura2 | if (debug) WRITE(*,*) 'IFrag=',IFrag,'Frozblock(I,0)/=1',Frozblock(IFrag,0) |
1684 | 1 | pfleura2 | ! We have many frozen atoms for one fragment. We will have to choose |
1685 | 1 | pfleura2 | ! the first one, and then to decide when to swich... |
1686 | 1 | pfleura2 | Iat=0 |
1687 | 1 | pfleura2 | I0=-1 |
1688 | 1 | pfleura2 | DO I=1,FrozBlock(IFrag,0) |
1689 | 1 | pfleura2 | JAt=FrozBlock(IFrag,I) |
1690 | 1 | pfleura2 | if (debug) WRITE(*,*) Jat, & |
1691 | 1 | pfleura2 | (LiaisonsBis(Jat,Itmp),Itmp=0,LiaisonsBis(Jat,0)) |
1692 | 1 | pfleura2 | IF (LiaisonsBis(Jat,0).GT.I0) THEN |
1693 | 1 | pfleura2 | I0=LiaisonsBis(Jat,0) |
1694 | 1 | pfleura2 | Iat=Jat |
1695 | 1 | pfleura2 | END IF |
1696 | 1 | pfleura2 | END DO |
1697 | 1 | pfleura2 | ! Iat is the starting frozen atom |
1698 | 1 | pfleura2 | IF (debug) WRITE(*,*) 'Choosing atom ',iat,'as a starting atom for frag',ifrag |
1699 | 1 | pfleura2 | DejaFait(iat)=.TRUE. |
1700 | 1 | pfleura2 | IdxCaFaire=2 |
1701 | 1 | pfleura2 | CaFaire(1)=iat |
1702 | 1 | pfleura2 | CaFaire(2)=0 |
1703 | 1 | pfleura2 | IaFaire=1 |
1704 | 1 | pfleura2 | FCaf(Iat)=.TRUE. |
1705 | 1 | pfleura2 | DO WHILE (CaFaire(IaFaire).NE.0) |
1706 | 1 | pfleura2 | n1=CaFaire(IaFaire) |
1707 | 1 | pfleura2 | if (debug) WRITE(*,*) 'Iafaire,n1,dejafait,idx_zmat', & |
1708 | 1 | pfleura2 | IaFaire,n1, DejaFait(n1),idx_zmat(n1) |
1709 | 1 | pfleura2 | if (debug) WRITE(*,*) 'Cafaire', & |
1710 | 1 | pfleura2 | (CaFaire(J),J=Iafaire,IdxCAfaire) |
1711 | 1 | pfleura2 | SELECT CASE(idx_zmat(n1)) |
1712 | 1 | pfleura2 | CASE (1) |
1713 | 1 | pfleura2 | n2=ind_zmat(2,1) |
1714 | 1 | pfleura2 | n3=ind_zmat(3,1) |
1715 | 1 | pfleura2 | CASE (2) |
1716 | 1 | pfleura2 | n2=ind_zmat(1,1) |
1717 | 1 | pfleura2 | n3=ind_zmat(3,1) |
1718 | 1 | pfleura2 | CASE (3:) |
1719 | 1 | pfleura2 | n2=ind_zmat(idx_zmat(n1),2) |
1720 | 1 | pfleura2 | n3=ind_zmat(idx_zmat(n1),3) |
1721 | 1 | pfleura2 | END SELECT |
1722 | 1 | pfleura2 | |
1723 | 1 | pfleura2 | if (debug) WRITE(*,*) "DBG n1,Liaisons(n1,0)",n1,Liaisons(n1,0) |
1724 | 1 | pfleura2 | DO I3=1,Liaisons(n1,0) |
1725 | 1 | pfleura2 | IAt=Liaisons(n1,I3) |
1726 | 1 | pfleura2 | if (debug) WRITE(*,*) "DBG I3,Iat",I3,Iat |
1727 | 1 | pfleura2 | ! PFL 2007.Apr.16 -> |
1728 | 1 | pfleura2 | ! We add ALL atoms linked to n1 to CaFaire |
1729 | 1 | pfleura2 | ! But we delete their link to n1 |
1730 | 1 | pfleura2 | !! PFL 2007.Aug.28 -> |
1731 | 1 | pfleura2 | ! re-add the test on FCaf in order not to put the same atom more than once in |
1732 | 1 | pfleura2 | ! CaFaire array. |
1733 | 1 | pfleura2 | IF (.NOT.FCaf(Iat)) THEN |
1734 | 1 | pfleura2 | CaFaire(IdxCaFaire)=Iat |
1735 | 1 | pfleura2 | IdxCaFaire=IdxCaFaire+1 |
1736 | 1 | pfleura2 | CaFaire(IdxCaFaire)=0 |
1737 | 1 | pfleura2 | FCaf(Iat)=.TRUE. |
1738 | 1 | pfleura2 | if (debug) WRITE(*,*) 'Adding ',iat,' to CaFaire. I3=',I3,'IdxCafaire=',IdxCafaire |
1739 | 1 | pfleura2 | if (debug) WRITE(*,*) 'Cafaire',(CaFaire(J),J=Iafaire,IdxCAfaire) |
1740 | 1 | pfleura2 | |
1741 | 1 | pfleura2 | END IF |
1742 | 1 | pfleura2 | !! <-- PFL 2007.Aug.28 |
1743 | 1 | pfleura2 | |
1744 | 1 | pfleura2 | Call Annul(Liaisons,Iat,n1) |
1745 | 1 | pfleura2 | Liaisons(iat,0)=Liaisons(Iat,0)-1 |
1746 | 1 | pfleura2 | ! <- PFL 2007.Apr.16 |
1747 | 1 | pfleura2 | IF (.NOT.DejaFait(Iat)) THEN |
1748 | 1 | pfleura2 | izm=izm+1 |
1749 | 1 | pfleura2 | ! ind_zmat(izm,1)=iat |
1750 | 1 | pfleura2 | ! ind_zmat(izm,2)=n1 |
1751 | 1 | pfleura2 | ! ind_zmat(izm,3)=n2 |
1752 | 1 | pfleura2 | ! ind_zmat(izm,4)=n3 |
1753 | 1 | pfleura2 | Call add2indzmat(na,izm,Iat,n1,n2,n3,ind_zmat,x,y,z) |
1754 | 1 | pfleura2 | idx_zmat(iat)=izm |
1755 | 1 | pfleura2 | ! Call Annul(Liaisons,n1,iat) |
1756 | 1 | pfleura2 | |
1757 | 1 | pfleura2 | n3=iat |
1758 | 1 | pfleura2 | DejaFait(Iat)=.TRUE. |
1759 | 1 | pfleura2 | END IF |
1760 | 1 | pfleura2 | END DO |
1761 | 1 | pfleura2 | |
1762 | 1 | pfleura2 | if (debug) WRITE(*,*) 'I3,n1,Liaisons(n1,:)', & |
1763 | 1 | pfleura2 | I3,n1,(Liaisons(n1,J),J=0,Liaisons(n1,0)) |
1764 | 1 | pfleura2 | |
1765 | 1 | pfleura2 | |
1766 | 1 | pfleura2 | if (debug.AND.(izm.GT.izm0)) THEN |
1767 | 1 | pfleura2 | WRITE(*,*) 'ind_zmat 6, izm=',izm |
1768 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(1,1) |
1769 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(2,1), ind_zmat(2,2) |
1770 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(3,1), ind_zmat(3,2), & |
1771 | 1 | pfleura2 | ind_zmat(3,3) |
1772 | 1 | pfleura2 | DO Ip=4,izm |
1773 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(Ip,1), & |
1774 | 1 | pfleura2 | ind_zmat(Ip,2),ind_zmat(Ip,3), ind_zmat(Ip,4) |
1775 | 1 | pfleura2 | END DO |
1776 | 1 | pfleura2 | izm0=izm |
1777 | 1 | pfleura2 | END IF |
1778 | 1 | pfleura2 | |
1779 | 1 | pfleura2 | IaFaire=IaFaire+1 |
1780 | 1 | pfleura2 | |
1781 | 1 | pfleura2 | |
1782 | 1 | pfleura2 | END Do ! DO WHILE CaFaire |
1783 | 1 | pfleura2 | |
1784 | 1 | pfleura2 | END IF ! FrozBlock(I,0)==1 |
1785 | 1 | pfleura2 | |
1786 | 1 | pfleura2 | IFrag=IFrag+1 |
1787 | 1 | pfleura2 | END DO ! Loop on all fragments |
1788 | 1 | pfleura2 | |
1789 | 1 | pfleura2 | |
1790 | 1 | pfleura2 | DO IFrag=1,NbFrag |
1791 | 1 | pfleura2 | IF (FrozBlock(IFrag,0).EQ.0) THEN |
1792 | 1 | pfleura2 | if (debug) WRITE(*,*) 'Adding fragment :', ifrag,'with no frozen atoms' |
1793 | 1 | pfleura2 | ! We have no frozen atoms for this fragment. We will have to choose |
1794 | 1 | pfleura2 | ! the first atom to put. |
1795 | 1 | pfleura2 | ! For now, we do not care of the 'central' atom (ie the one with |
1796 | 1 | pfleura2 | ! no CP atoms...) |
1797 | 1 | pfleura2 | ! We just take the atom that is the closest to the already placed |
1798 | 1 | pfleura2 | ! atoms ! |
1799 | 1 | pfleura2 | |
1800 | 1 | pfleura2 | |
1801 | 1 | pfleura2 | I0=0 |
1802 | 1 | pfleura2 | I1=0 |
1803 | 1 | pfleura2 | d=1e9 |
1804 | 1 | pfleura2 | DO J=1,izm |
1805 | 1 | pfleura2 | Jat=ind_zmat(J,1) |
1806 | 1 | pfleura2 | DO I=1,NbAtfrag(IFrag) |
1807 | 1 | pfleura2 | IAt=FragAt(IFrag,I) |
1808 | 1 | pfleura2 | IF (.NOT.DejaFait(Iat)) THEN |
1809 | 1 | pfleura2 | Call vecteur(Iat,Jat,x,y,z,vx1,vy1,vz1,norm1) |
1810 | 1 | pfleura2 | IF (norm1.LT.d) THEN |
1811 | 1 | pfleura2 | I1=Jat |
1812 | 1 | pfleura2 | I0=Iat |
1813 | 1 | pfleura2 | d=Norm1 |
1814 | 1 | pfleura2 | END IF |
1815 | 1 | pfleura2 | END IF |
1816 | 1 | pfleura2 | END DO |
1817 | 1 | pfleura2 | END DO |
1818 | 1 | pfleura2 | |
1819 | 1 | pfleura2 | Iat=I0 |
1820 | 1 | pfleura2 | n1=I1 |
1821 | 1 | pfleura2 | |
1822 | 1 | pfleura2 | IF (debug) WRITE(*,*) Iat,' starting atom for frag',ifrag |
1823 | 1 | pfleura2 | |
1824 | 1 | pfleura2 | |
1825 | 1 | pfleura2 | SELECT CASE(idx_zmat(n1)) |
1826 | 1 | pfleura2 | CASE (1) |
1827 | 1 | pfleura2 | n2=ind_zmat(2,1) |
1828 | 1 | pfleura2 | n3=ind_zmat(3,1) |
1829 | 1 | pfleura2 | CASE (2) |
1830 | 1 | pfleura2 | n2=ind_zmat(1,1) |
1831 | 1 | pfleura2 | n3=ind_zmat(3,1) |
1832 | 1 | pfleura2 | CASE (3:) |
1833 | 1 | pfleura2 | n2=ind_zmat(idx_zmat(n1),2) |
1834 | 1 | pfleura2 | n3=ind_zmat(idx_zmat(n1),3) |
1835 | 1 | pfleura2 | END SELECT |
1836 | 1 | pfleura2 | |
1837 | 1 | pfleura2 | izm=izm+1 |
1838 | 1 | pfleura2 | ! ind_zmat(izm,1)=iat |
1839 | 1 | pfleura2 | ! ind_zmat(izm,2)=n1 |
1840 | 1 | pfleura2 | ! ind_zmat(izm,3)=n2 |
1841 | 1 | pfleura2 | ! ind_zmat(izm,4)=n3 |
1842 | 1 | pfleura2 | Call add2indzmat(na,izm,Iat,n1,n2,n3,ind_zmat,x,y,z) |
1843 | 1 | pfleura2 | idx_zmat(iat)=izm |
1844 | 1 | pfleura2 | |
1845 | 1 | pfleura2 | |
1846 | 1 | pfleura2 | DejaFait(iat)=.TRUE. |
1847 | 1 | pfleura2 | IdxCaFaire=2 |
1848 | 1 | pfleura2 | CaFaire(1)=iat |
1849 | 1 | pfleura2 | CaFaire(2)=0 |
1850 | 1 | pfleura2 | IaFaire=1 |
1851 | 1 | pfleura2 | FCaf(Iat)=.TRUE. |
1852 | 1 | pfleura2 | DO WHILE (CaFaire(IaFaire).NE.0) |
1853 | 1 | pfleura2 | n1=CaFaire(IaFaire) |
1854 | 1 | pfleura2 | if (debug) WRITE(*,*) 'Iafaire,n1',IaFaire,n1, & |
1855 | 1 | pfleura2 | DejaFait(n1),idx_zmat(n1) |
1856 | 1 | pfleura2 | if (debug) WRITE(*,*) 'Cafaire', & |
1857 | 1 | pfleura2 | (CaFaire(J),J=Iafaire,IdxCAfaire) |
1858 | 1 | pfleura2 | SELECT CASE(idx_zmat(n1)) |
1859 | 1 | pfleura2 | CASE (1) |
1860 | 1 | pfleura2 | n2=ind_zmat(2,1) |
1861 | 1 | pfleura2 | n3=ind_zmat(3,1) |
1862 | 1 | pfleura2 | CASE (2) |
1863 | 1 | pfleura2 | n2=ind_zmat(1,1) |
1864 | 1 | pfleura2 | n3=ind_zmat(3,1) |
1865 | 1 | pfleura2 | CASE (3:) |
1866 | 1 | pfleura2 | n2=ind_zmat(idx_zmat(n1),2) |
1867 | 1 | pfleura2 | n3=ind_zmat(idx_zmat(n1),3) |
1868 | 1 | pfleura2 | END SELECT |
1869 | 1 | pfleura2 | |
1870 | 1 | pfleura2 | |
1871 | 1 | pfleura2 | DO I3=1,Liaisons(n1,0) |
1872 | 1 | pfleura2 | IAt=Liaisons(n1,I3) |
1873 | 1 | pfleura2 | ! PFL 2007.Apr.16 -> |
1874 | 1 | pfleura2 | ! We add ALL atoms linked to n1 to CaFaire |
1875 | 1 | pfleura2 | ! But we delete their link to n1 |
1876 | 1 | pfleura2 | !! PFL 2007.Aug.28 -> |
1877 | 1 | pfleura2 | ! re-add the test on FCaf in order not to put the same atom more than once in |
1878 | 1 | pfleura2 | ! CaFaire array. |
1879 | 1 | pfleura2 | IF (.NOT.FCaf(Iat)) THEN |
1880 | 1 | pfleura2 | CaFaire(IdxCaFaire)=Iat |
1881 | 1 | pfleura2 | IdxCaFaire=IdxCaFaire+1 |
1882 | 1 | pfleura2 | CaFaire(IdxCaFaire)=0 |
1883 | 1 | pfleura2 | FCaf(Iat)=.TRUE. |
1884 | 1 | pfleura2 | END IF |
1885 | 1 | pfleura2 | !! <-- PFL 2007.Aug.28 |
1886 | 1 | pfleura2 | |
1887 | 1 | pfleura2 | Call Annul(Liaisons,Iat,n1) |
1888 | 1 | pfleura2 | Liaisons(iat,0)=Liaisons(Iat,0)-1 |
1889 | 1 | pfleura2 | if (debug) WRITE(*,*) 'Adding ',iat,' to CaFaire. I3=',I3 |
1890 | 1 | pfleura2 | if (debug) WRITE(*,*) 'Cafaire',(CaFaire(J),J=Iafaire,IdxCAfaire) |
1891 | 1 | pfleura2 | |
1892 | 1 | pfleura2 | ! <- PFL 2007.Apr.16 |
1893 | 1 | pfleura2 | IF (.NOT.DejaFait(Liaisons(n1,i3))) THEN |
1894 | 1 | pfleura2 | IAt=Liaisons(n1,I3) |
1895 | 1 | pfleura2 | izm=izm+1 |
1896 | 1 | pfleura2 | ! ind_zmat(izm,1)=iat |
1897 | 1 | pfleura2 | ! ind_zmat(izm,2)=n1 |
1898 | 1 | pfleura2 | ! ind_zmat(izm,3)=n2 |
1899 | 1 | pfleura2 | ! ind_zmat(izm,4)=n3 |
1900 | 1 | pfleura2 | Call add2indzmat(na,izm,Iat,n1,n2,n3,ind_zmat,x,y,z) |
1901 | 1 | pfleura2 | idx_zmat(iat)=izm |
1902 | 1 | pfleura2 | |
1903 | 1 | pfleura2 | n3=iat |
1904 | 1 | pfleura2 | DejaFait(Iat)=.TRUE. |
1905 | 1 | pfleura2 | END IF |
1906 | 1 | pfleura2 | |
1907 | 1 | pfleura2 | if (debug) WRITE(*,*) 'I3,n1,Liaisons(n1,:)', & |
1908 | 1 | pfleura2 | I3,n1,(Liaisons(n1,J),J=0,Liaisons(n1,0)) |
1909 | 1 | pfleura2 | END DO |
1910 | 1 | pfleura2 | IaFaire=IaFaire+1 |
1911 | 1 | pfleura2 | |
1912 | 1 | pfleura2 | if (debug) THEN |
1913 | 1 | pfleura2 | WRITE(*,*) 'ind_zmat 7', izm |
1914 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(1,1) |
1915 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(2,1), ind_zmat(2,2) |
1916 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(3,1), ind_zmat(3,2),ind_zmat(3,3) |
1917 | 1 | pfleura2 | DO Ip=4,izm |
1918 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(Ip,1), & |
1919 | 1 | pfleura2 | ind_zmat(Ip,2), & |
1920 | 1 | pfleura2 | ind_zmat(Ip,3), ind_zmat(Ip,4) |
1921 | 1 | pfleura2 | END DO |
1922 | 1 | pfleura2 | END IF |
1923 | 1 | pfleura2 | |
1924 | 1 | pfleura2 | END Do ! DO WHILE CaFaire |
1925 | 1 | pfleura2 | END IF ! FrozBlock(IFrag,0).EQ.0 |
1926 | 1 | pfleura2 | |
1927 | 1 | pfleura2 | END DO ! Loop on all fragments without frozen atoms |
1928 | 1 | pfleura2 | |
1929 | 1 | pfleura2 | if (debug) THEN |
1930 | 1 | pfleura2 | WRITE(*,*) Na+Izm |
1931 | 1 | pfleura2 | WRITE(*,*) 'Done... ', izm |
1932 | 1 | pfleura2 | DO J=1,Na |
1933 | 1 | pfleura2 | WRITE(*,'(1X,A5,3(1X,F10.6))') Nom(Atome(J)),X(J),Y(J),Z(J) |
1934 | 1 | pfleura2 | END DO |
1935 | 1 | pfleura2 | DO I=1,Izm |
1936 | 1 | pfleura2 | J=ind_zmat(I,1) |
1937 | 1 | pfleura2 | WRITE(*,'(1X,A5,3(1X,F10.6))') 'X ',X(J),Y(J),Z(J) |
1938 | 1 | pfleura2 | END DO |
1939 | 1 | pfleura2 | IF (izm.NE.Na) THEN |
1940 | 1 | pfleura2 | WRITE(*,*) "Atoms not done:" |
1941 | 1 | pfleura2 | DO I=1,Na |
1942 | 1 | pfleura2 | IF (.NOT.DejaFait(I)) WRITE(*,'(I5)',ADVANCE='NO') I |
1943 | 1 | pfleura2 | END DO |
1944 | 1 | pfleura2 | END IF |
1945 | 1 | pfleura2 | END IF |
1946 | 1 | pfleura2 | |
1947 | 1 | pfleura2 | |
1948 | 1 | pfleura2 | ! We have ind_zmat. We calculate val_zmat :-) |
1949 | 1 | pfleura2 | if (debug) WRITE(*,*) "Calculating val_zmat" |
1950 | 1 | pfleura2 | |
1951 | 1 | pfleura2 | val_zmat(1,1)=0.d0 |
1952 | 1 | pfleura2 | val_zmat(1,2)=0.d0 |
1953 | 1 | pfleura2 | val_zmat(1,3)=0.d0 |
1954 | 1 | pfleura2 | val_zmat(2,2)=0.d0 |
1955 | 1 | pfleura2 | val_zmat(2,3)=0.d0 |
1956 | 1 | pfleura2 | val_zmat(3,3)=0.d0 |
1957 | 1 | pfleura2 | |
1958 | 1 | pfleura2 | n1=ind_zmat(2,1) |
1959 | 1 | pfleura2 | n2=ind_zmat(2,2) |
1960 | 1 | pfleura2 | |
1961 | 1 | pfleura2 | CALL vecteur(n2,n1,x,y,z,vx1,vy1,vz1,norm1) |
1962 | 1 | pfleura2 | |
1963 | 1 | pfleura2 | val_zmat(2,1)=norm1 |
1964 | 1 | pfleura2 | |
1965 | 1 | pfleura2 | |
1966 | 1 | pfleura2 | n1=ind_zmat(3,1) |
1967 | 1 | pfleura2 | n2=ind_zmat(3,2) |
1968 | 1 | pfleura2 | n3=ind_zmat(3,3) |
1969 | 1 | pfleura2 | |
1970 | 1 | pfleura2 | CALL vecteur(n2,n1,x,y,z,vx1,vy1,vz1,norm1) |
1971 | 1 | pfleura2 | |
1972 | 1 | pfleura2 | val_zmat(3,1)=norm1 |
1973 | 1 | pfleura2 | |
1974 | 1 | pfleura2 | CALL vecteur(n2,n3,x,y,z,vx2,vy2,vz2,norm2) |
1975 | 1 | pfleura2 | val=angle(vx1,vy1,vz1,norm1,vx2,vy2,vz2,norm2) |
1976 | 1 | pfleura2 | |
1977 | 1 | pfleura2 | val_zmat(3,2)=val |
1978 | 1 | pfleura2 | |
1979 | 1 | pfleura2 | DO i=4,na |
1980 | 1 | pfleura2 | |
1981 | 1 | pfleura2 | n1=ind_zmat(i,1) |
1982 | 1 | pfleura2 | n2=ind_zmat(i,2) |
1983 | 1 | pfleura2 | n3=ind_zmat(i,3) |
1984 | 1 | pfleura2 | n4=ind_zmat(i,4) |
1985 | 1 | pfleura2 | |
1986 | 1 | pfleura2 | if (debug) WRITE(*,*) "Doing i,n1,n2,n3,n4",i,n1,n2,n3,n4 |
1987 | 1 | pfleura2 | CALL vecteur(n2,n1,x,y,z,vx1,vy1,vz1,norm1) |
1988 | 1 | pfleura2 | |
1989 | 1 | pfleura2 | CALL vecteur(n2,n3,x,y,z,vx2,vy2,vz2,norm2) |
1990 | 1 | pfleura2 | val=angle(vx1,vy1,vz1,norm1,vx2,vy2,vz2,norm2) |
1991 | 1 | pfleura2 | |
1992 | 1 | pfleura2 | CALL vecteur(n3,n4,x,y,z,vx3,vy3,vz3,norm3) |
1993 | 2 | pfleura2 | CALL produit_vect(vx1,vy1,vz1,vx2,vy2,vz2, & |
1994 | 1 | pfleura2 | vx4,vy4,vz4,norm4) |
1995 | 2 | pfleura2 | CALL produit_vect(vx3,vy3,vz3,vx2,vy2,vz2, & |
1996 | 1 | pfleura2 | vx5,vy5,vz5,norm5) |
1997 | 1 | pfleura2 | |
1998 | 1 | pfleura2 | val_d=angle_d(vx4,vy4,vz4,norm4, vx5,vy5,vz5,norm5, & |
1999 | 1 | pfleura2 | vx2,vy2,vz2,norm2) |
2000 | 1 | pfleura2 | |
2001 | 1 | pfleura2 | ! write(*,11) n1,n2,norm1,n3,val,n4,val_d |
2002 | 1 | pfleura2 | !11 format (2(1x,i3),1x,f8.4,2(1x,i3,1x,f8.3)) |
2003 | 1 | pfleura2 | |
2004 | 1 | pfleura2 | val_zmat(i,1)=norm1 |
2005 | 1 | pfleura2 | val_zmat(i,2)=val |
2006 | 1 | pfleura2 | val_zmat(i,3)=val_d |
2007 | 1 | pfleura2 | |
2008 | 1 | pfleura2 | END DO |
2009 | 1 | pfleura2 | |
2010 | 1 | pfleura2 | if (debug) THEN |
2011 | 1 | pfleura2 | WRITE(*,*) 'DBG Cre_Zmat_Constr: ind_zmat' |
2012 | 1 | pfleura2 | DO I=1,na |
2013 | 1 | pfleura2 | WRITE(*,'(1X,5I5)') (ind_zmat(i,j),j=1,5) |
2014 | 1 | pfleura2 | END DO |
2015 | 1 | pfleura2 | |
2016 | 1 | pfleura2 | WRITE(*,*) 'DBG Cre_Zmat_Constr: Full zmat' |
2017 | 1 | pfleura2 | DO I=1,na |
2018 | 1 | pfleura2 | WRITE(*,'(1X,I5,1X,I5,F8.4,2(1X,I5,1X,F7.2))') ind_zmat(i,1),(ind_zmat(i,j+1),val_zmat(i,j),j=1,3) |
2019 | 1 | pfleura2 | END DO |
2020 | 1 | pfleura2 | |
2021 | 1 | pfleura2 | END IF |
2022 | 1 | pfleura2 | |
2023 | 1 | pfleura2 | if (debug) WRITE(*,*) "Deallocate (FrozDist,Fragment, NbAtFrag,FragAt)" |
2024 | 1 | pfleura2 | DEALLOCATE(FrozDist,Fragment, NbAtFrag,FragAt) |
2025 | 1 | pfleura2 | if (debug) WRITE(*,*) "Deallocate FrozFrag, IdxFragAt, FrozBlock" |
2026 | 1 | pfleura2 | ! DEALLOCATE(FrozFrag, IdxFragAt, FrozBlock) |
2027 | 1 | pfleura2 | DEALLOCATE(FrozFrag,FrozBlock) |
2028 | 1 | pfleura2 | if (debug) WRITE(*,*) "Deallocate (DistFroz,Liaisons)" |
2029 | 1 | pfleura2 | DEALLOCATE(DistFroz,Liaisons) |
2030 | 1 | pfleura2 | if (debug) WRITE(*,*) "Deallocate (LiaisonsIni)" |
2031 | 1 | pfleura2 | DEALLOCATE(LiaisonsIni) |
2032 | 1 | pfleura2 | if (debug) WRITE(*,*) "Deallocate(CaFaire,DejaFait,FrozAt)" |
2033 | 1 | pfleura2 | DEALLOCATE(CaFaire,DejaFait,FrozAt) |
2034 | 1 | pfleura2 | if (debug) WRITE(*,*) "Deallocate (LiaisonsBis" |
2035 | 1 | pfleura2 | DEALLOCATE(LiaisonsBis) |
2036 | 1 | pfleura2 | |
2037 | 12 | pfleura2 | if (debugGaussian) THEN |
2038 | 12 | pfleura2 | WRITE(*,*) 'DBG Cre_Zmat_Constr_Frag: Gaussian Zmat - START' |
2039 | 12 | pfleura2 | Call WriteMixed_Gaussian(na,atome,LocalNCart,ind_zmat,val_zmat) |
2040 | 12 | pfleura2 | WRITE(*,*) 'DBG Cre_Zmat_Constr_Frag: Gaussian Zmat - END' |
2041 | 12 | pfleura2 | END IF |
2042 | 1 | pfleura2 | |
2043 | 12 | pfleura2 | |
2044 | 12 | pfleura2 | |
2045 | 1 | pfleura2 | if (debug) WRITE(*,*) "=============================== Exiting Calc_zmat_contr_frag ========================" |
2046 | 1 | pfleura2 | |
2047 | 1 | pfleura2 | END SUBROUTINE Calc_Zmat_const_frag |
2048 | 1 | pfleura2 |