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