root / src / Calc_zmat_frag.f90 @ 2
Historique | Voir | Annoter | Télécharger (40,64 ko)
| 1 | 1 | pfleura2 | SUBROUTINE Calc_Zmat_frag(na,atome,ind_zmat,val_zmat,x,y,z,r_cov,fact) |
|---|---|---|---|
| 2 | 1 | pfleura2 | |
| 3 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 4 | 1 | pfleura2 | ! |
| 5 | 1 | pfleura2 | ! Goal: to compute a viable Z-Matrix starting from the |
| 6 | 1 | pfleura2 | ! cartesian coordinates of the atoms |
| 7 | 1 | pfleura2 | ! |
| 8 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 9 | 1 | pfleura2 | ! |
| 10 | 1 | pfleura2 | ! Input: |
| 11 | 1 | pfleura2 | ! na : Number or atoms |
| 12 | 1 | pfleura2 | ! atome : Mass number of the atoms (H=1, He=2,...) |
| 13 | 1 | pfleura2 | ! x,y,z : cartesian coordinates of the atoms |
| 14 | 1 | pfleura2 | ! r_cov : array containing the covalent radii of the atoms |
| 15 | 1 | pfleura2 | ! fact : multiplicative factor used to determine if two atoms are linked. |
| 16 | 1 | pfleura2 | ! see CalcCnct for more details. |
| 17 | 1 | pfleura2 | ! |
| 18 | 1 | pfleura2 | ! Output: |
| 19 | 1 | pfleura2 | ! ind_zmat : INTEGER(na,5) contains the indices of the Z-matrix |
| 20 | 1 | pfleura2 | ! val_zmat : REAL(na,3) contains the values of the Z-matrix |
| 21 | 1 | pfleura2 | ! |
| 22 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 23 | 1 | pfleura2 | ! History |
| 24 | 1 | pfleura2 | ! |
| 25 | 1 | pfleura2 | ! v1.0 written for Cart a long time ago. Does not use fragment analysis, but was quite good ! |
| 26 | 1 | pfleura2 | ! |
| 27 | 1 | pfleura2 | ! v2.0 12/2007 |
| 28 | 1 | pfleura2 | ! Comes from Calc_zmat_constr_frag, based on a fragment analysis of the |
| 29 | 1 | pfleura2 | ! system under study. |
| 30 | 1 | pfleura2 | ! It should be more flexible and robust. |
| 31 | 1 | pfleura2 | ! |
| 32 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 33 | 1 | pfleura2 | |
| 34 | 1 | pfleura2 | Use Path_module, only : max_Z, NMaxL, Nom,MaxFroz, Pi |
| 35 | 1 | pfleura2 | Use Io_module |
| 36 | 1 | pfleura2 | |
| 37 | 1 | pfleura2 | IMPLICIT NONE |
| 38 | 1 | pfleura2 | |
| 39 | 1 | pfleura2 | integer(KINT), INTENT(IN) :: na,atome(na) |
| 40 | 1 | pfleura2 | real(KREAL), INTENT(IN) :: x(Na),y(Na),z(Na),fact |
| 41 | 1 | pfleura2 | real(KREAL), INTENT(IN) :: r_cov(0:Max_Z) |
| 42 | 1 | pfleura2 | |
| 43 | 1 | pfleura2 | INTEGER(KINT), INTENT(OUT) :: ind_zmat(Na,5) |
| 44 | 1 | pfleura2 | real(KREAL), INTENT(OUT) :: val_zmat(Na,3) |
| 45 | 1 | pfleura2 | |
| 46 | 1 | pfleura2 | INTEGER(KINT) :: idx_zmat(NA) |
| 47 | 1 | pfleura2 | ! Frozen contains the indices of frozen atoms |
| 48 | 1 | pfleura2 | ! INTEGER(KINT) Frozen(*),NFroz |
| 49 | 1 | pfleura2 | ! Number of fragment, Index of the current fragment for loops |
| 50 | 2 | pfleura2 | INTEGER(KINT) :: NbFrag |
| 51 | 1 | pfleura2 | ! Fragment(I) contains the fragment index to which I belongs |
| 52 | 1 | pfleura2 | ! NbAtFrag(j) contains the number of atoms of fragment j |
| 53 | 1 | pfleura2 | INTEGER(KINT), ALLOCATABLE :: Fragment(:),NbAtFrag(:) !na |
| 54 | 1 | pfleura2 | ! FragAt(i,:) lists the atoms of fragment i |
| 55 | 1 | pfleura2 | INTEGER(KINT), ALLOCATABLE :: FragAt(:,:) !na,na |
| 56 | 1 | pfleura2 | ! MaxLFrag(i,1) contains the maximum of links for an atom for fragment i |
| 57 | 1 | pfleura2 | ! MaxLFrag(i,2) is the atom that has this number of linked atoms |
| 58 | 1 | pfleura2 | INTEGER(KINT), ALLOCATABLE :: MaxLFrag(:,:) !na,2 |
| 59 | 1 | pfleura2 | ! INTEGER(KINT), ALLOCATABLE :: IdxFragAt(:) !na |
| 60 | 1 | pfleura2 | ! INTEGER(KINT), ALLOCATABLE :: FrozBlock(:,:) !(na,0:na) |
| 61 | 1 | pfleura2 | ! DistFrag contains the distance between a given atom and some other atoms |
| 62 | 1 | pfleura2 | REAL(KREAL), ALLOCATABLE :: DistFrag(:) !na |
| 63 | 1 | pfleura2 | ! FragDist(I) contains the index of the atoms corresponding to DistFrag(I) |
| 64 | 1 | pfleura2 | INTEGER(KINT), ALLOCATABLE :: FragDist(:) ! na |
| 65 | 1 | pfleura2 | |
| 66 | 1 | pfleura2 | INTEGER(KINT) :: IdxCaFaire, IAfaire |
| 67 | 1 | pfleura2 | INTEGER(KINT), ALLOCATABLE :: LIAISONS(:,:) ! (Na,0:NMaxL) |
| 68 | 1 | pfleura2 | ! INTEGER(KINT), ALLOCATABLE :: LiaisonsIni(:,:) ! (Na,0:NMaxL) |
| 69 | 1 | pfleura2 | INTEGER(KINT), ALLOCATABLE :: CAFaire(:) ! (Na) |
| 70 | 1 | pfleura2 | |
| 71 | 1 | pfleura2 | real(KREAL) :: vx1,vy1,vz1,norm1 |
| 72 | 1 | pfleura2 | real(KREAL) :: vx2,vy2,vz2,norm2 |
| 73 | 1 | pfleura2 | real(KREAL) :: vx3,vy3,vz3,norm3 |
| 74 | 1 | pfleura2 | real(KREAL) :: vx4,vy4,vz4,norm4 |
| 75 | 1 | pfleura2 | real(KREAL) :: vx5,vy5,vz5,norm5 |
| 76 | 1 | pfleura2 | real(KREAL) :: val,val_d, d12, d13,d23,d |
| 77 | 2 | pfleura2 | Logical Debug, FirstAt, DebugGaussian |
| 78 | 1 | pfleura2 | LOGICAL, ALLOCATABLE :: DejaFait(:), FCaf(:) !(na) |
| 79 | 1 | pfleura2 | ! Logical, ALLOCATABLE :: FrozAt(:) !T if this atom is frozen |
| 80 | 1 | pfleura2 | LOGICAL F1213, F1223,F1323 |
| 81 | 1 | pfleura2 | |
| 82 | 1 | pfleura2 | INTEGER(KINT) :: I,J,n0,n1,n2,n3,n4,IAt,IL,JL,IFrag,ITmp, K, KMax |
| 83 | 2 | pfleura2 | INTEGER(KINT) :: I3, I1, Ip |
| 84 | 2 | pfleura2 | INTEGER(KINT) :: I0, Izm, JAt |
| 85 | 1 | pfleura2 | INTEGER(KINT) :: OrderZmat |
| 86 | 1 | pfleura2 | |
| 87 | 1 | pfleura2 | REAL(KREAL) :: sDihe |
| 88 | 1 | pfleura2 | |
| 89 | 1 | pfleura2 | INTERFACE |
| 90 | 1 | pfleura2 | function valid(string) result (isValid) |
| 91 | 1 | pfleura2 | CHARACTER(*), intent(in) :: string |
| 92 | 1 | pfleura2 | logical :: isValid |
| 93 | 1 | pfleura2 | END function VALID |
| 94 | 1 | pfleura2 | |
| 95 | 1 | pfleura2 | FUNCTION angle(v1x,v1y,v1z,norm1,v2x,v2y,v2z,norm2) |
| 96 | 1 | pfleura2 | INTEGER, PARAMETER :: KREAL=KIND(1.0D0) |
| 97 | 1 | pfleura2 | real(KREAL) :: v1x,v1y,v1z,norm1 |
| 98 | 1 | pfleura2 | real(KREAL) :: v2x,v2y,v2z,norm2 |
| 99 | 1 | pfleura2 | real(KREAL) :: angle |
| 100 | 1 | pfleura2 | END FUNCTION ANGLE |
| 101 | 1 | pfleura2 | |
| 102 | 1 | pfleura2 | FUNCTION SinAngle(v1x,v1y,v1z,norm1,v2x,v2y,v2z,norm2) |
| 103 | 1 | pfleura2 | INTEGER, PARAMETER :: KREAL=KIND(1.0D0) |
| 104 | 1 | pfleura2 | real(KREAL) :: v1x,v1y,v1z,norm1 |
| 105 | 1 | pfleura2 | real(KREAL) :: v2x,v2y,v2z,norm2 |
| 106 | 1 | pfleura2 | real(KREAL) :: SinAngle |
| 107 | 1 | pfleura2 | END FUNCTION SINANGLE |
| 108 | 1 | pfleura2 | |
| 109 | 1 | pfleura2 | FUNCTION angle_d(v1x,v1y,v1z,norm1,v2x,v2y,v2z,norm2,v3x,v3y,v3z,norm3) |
| 110 | 1 | pfleura2 | INTEGER, PARAMETER :: KREAL=KIND(1.0D0) |
| 111 | 1 | pfleura2 | real(KREAL) :: v1x,v1y,v1z,norm1 |
| 112 | 1 | pfleura2 | real(KREAL) :: v2x,v2y,v2z,norm2 |
| 113 | 1 | pfleura2 | real(KREAL) :: v3x,v3y,v3z,norm3 |
| 114 | 1 | pfleura2 | real(KREAL) :: angle_d,ca,sa |
| 115 | 1 | pfleura2 | END FUNCTION ANGLE_D |
| 116 | 1 | pfleura2 | END INTERFACE |
| 117 | 1 | pfleura2 | |
| 118 | 1 | pfleura2 | debug=valid("calc_zmat").OR.valid("calc_zmat_frag")
|
| 119 | 1 | pfleura2 | debugGaussian=valid("zmat_gaussian")
|
| 120 | 1 | pfleura2 | |
| 121 | 1 | pfleura2 | if (debug) WRITE(*,*) "=============================== Entering Calc_zmat_frag ========================" |
| 122 | 1 | pfleura2 | if (na.le.2) THEN |
| 123 | 1 | pfleura2 | WRITE(*,*) "I do not work for less than 2 atoms :-p" |
| 124 | 1 | pfleura2 | RETURN |
| 125 | 1 | pfleura2 | END IF |
| 126 | 1 | pfleura2 | |
| 127 | 1 | pfleura2 | ALLOCATE(FragDist(Na),Fragment(na), NbAtFrag(na),FragAt(na,na)) |
| 128 | 1 | pfleura2 | ! ALLOCATE(FrozFrag(na,3), IdxFragAt(na), FrozBlock(na,0:na)) |
| 129 | 1 | pfleura2 | ! ALLOCATE(FrozFrag(na,3)) |
| 130 | 1 | pfleura2 | ALLOCATE(DistFrag(na),Liaisons(na,0:NMaxL)) |
| 131 | 1 | pfleura2 | ! ALLOCATE(Liaisons(na,0:NMaxL),LiaisonsIni(na,0:NMaxL)) |
| 132 | 1 | pfleura2 | ! ALLOCATE(CaFaire(na),DejaFait(Na),FCaf(na),FrozAt(na)) |
| 133 | 1 | pfleura2 | ALLOCATE(CaFaire(na+1),DejaFait(Na),FCaf(na)) |
| 134 | 1 | pfleura2 | |
| 135 | 1 | pfleura2 | if (debug) THEN |
| 136 | 1 | pfleura2 | WRITE(*,*) "DBG Calc_zmat_frag - Cartesian coordinates" |
| 137 | 1 | pfleura2 | DO I=1,na |
| 138 | 1 | pfleura2 | WRITE(*,'(1X,A3,3(1X,F15.8))') Nom(atome(i)),x(i),y(i),z(i) |
| 139 | 1 | pfleura2 | END DO |
| 140 | 1 | pfleura2 | END if |
| 141 | 1 | pfleura2 | |
| 142 | 1 | pfleura2 | DO I=1,na |
| 143 | 1 | pfleura2 | DO J=1,5 |
| 144 | 1 | pfleura2 | Ind_Zmat(I,J)=0 |
| 145 | 1 | pfleura2 | END DO |
| 146 | 1 | pfleura2 | END DO |
| 147 | 1 | pfleura2 | |
| 148 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 149 | 1 | pfleura2 | ! |
| 150 | 1 | pfleura2 | ! Easy case : 3 or less atoms |
| 151 | 1 | pfleura2 | ! |
| 152 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 153 | 1 | pfleura2 | if (Na.eq.3) THEN |
| 154 | 1 | pfleura2 | d12=sqrt((x(1)-x(2))**2+(y(1)-y(2))**2+(z(1)-z(2))**2) |
| 155 | 1 | pfleura2 | d13=sqrt((x(1)-x(3))**2+(y(1)-y(3))**2+(z(1)-z(3))**2) |
| 156 | 1 | pfleura2 | d23=sqrt((x(3)-x(2))**2+(y(3)-y(2))**2+(z(3)-z(2))**2) |
| 157 | 1 | pfleura2 | F1213=(d12<=d13) |
| 158 | 1 | pfleura2 | F1323=(d13<=d23) |
| 159 | 1 | pfleura2 | F1223=(d12<=d23) |
| 160 | 1 | pfleura2 | if (debug) THEN |
| 161 | 1 | pfleura2 | WRITE(*,*) "DEBUG Calc_Zmat 3 atoms" |
| 162 | 1 | pfleura2 | WRITE(*,*) "d12,d13,d23:",d12,d13,d23 |
| 163 | 1 | pfleura2 | WRITE(*,*) "F1213,F1323,F1223:",F1213,F1323,F1223 |
| 164 | 1 | pfleura2 | END IF |
| 165 | 1 | pfleura2 | OrderZmat=0 |
| 166 | 1 | pfleura2 | if (F1213) orderZmat=OrderZmat+4 |
| 167 | 1 | pfleura2 | if (F1323) orderZmat=OrderZmat+2 |
| 168 | 1 | pfleura2 | if (F1223) orderZmat=OrderZmat+1 |
| 169 | 1 | pfleura2 | if (debug) WRITE(*,*) 'OrderZmat=',OrderZmat |
| 170 | 1 | pfleura2 | SELECT CASE (OrderZmat) |
| 171 | 1 | pfleura2 | CASE (0) |
| 172 | 1 | pfleura2 | ! F F F ordre 2-3----1 |
| 173 | 1 | pfleura2 | ind_zmat(1,1)=3 |
| 174 | 1 | pfleura2 | ind_zmat(2,1)=2 |
| 175 | 1 | pfleura2 | ind_zmat(2,2)=3 |
| 176 | 1 | pfleura2 | ind_zmat(3,1)=1 |
| 177 | 1 | pfleura2 | ind_zmat(3,2)=3 |
| 178 | 1 | pfleura2 | ind_zmat(3,3)=2 |
| 179 | 1 | pfleura2 | CASE (2) |
| 180 | 1 | pfleura2 | ! F T F ordre 1-3----2 |
| 181 | 1 | pfleura2 | ind_zmat(1,1)=3 |
| 182 | 1 | pfleura2 | ind_zmat(2,1)=1 |
| 183 | 1 | pfleura2 | ind_zmat(2,2)=3 |
| 184 | 1 | pfleura2 | ind_zmat(3,1)=2 |
| 185 | 1 | pfleura2 | ind_zmat(3,2)=3 |
| 186 | 1 | pfleura2 | ind_zmat(3,3)=1 |
| 187 | 1 | pfleura2 | CASE (3) |
| 188 | 1 | pfleura2 | ! F T T ordre 2---1-3 |
| 189 | 1 | pfleura2 | ind_zmat(1,1)=1 |
| 190 | 1 | pfleura2 | ind_zmat(2,1)=3 |
| 191 | 1 | pfleura2 | ind_zmat(2,2)=1 |
| 192 | 1 | pfleura2 | ind_zmat(3,1)=2 |
| 193 | 1 | pfleura2 | ind_zmat(3,2)=1 |
| 194 | 1 | pfleura2 | ind_zmat(3,3)=3 |
| 195 | 1 | pfleura2 | CASE (5) |
| 196 | 1 | pfleura2 | ! T F T ordre 1-2----3 |
| 197 | 1 | pfleura2 | ind_zmat(1,1)=2 |
| 198 | 1 | pfleura2 | ind_zmat(2,1)=1 |
| 199 | 1 | pfleura2 | ind_zmat(2,2)=2 |
| 200 | 1 | pfleura2 | ind_zmat(3,1)=3 |
| 201 | 1 | pfleura2 | ind_zmat(3,2)=2 |
| 202 | 1 | pfleura2 | ind_zmat(3,3)=1 |
| 203 | 1 | pfleura2 | CASE (7) |
| 204 | 1 | pfleura2 | ! T T T ordre 3----1-2 |
| 205 | 1 | pfleura2 | ind_zmat(1,1)=1 |
| 206 | 1 | pfleura2 | ind_zmat(2,1)=2 |
| 207 | 1 | pfleura2 | ind_zmat(2,2)=1 |
| 208 | 1 | pfleura2 | ind_zmat(3,1)=3 |
| 209 | 1 | pfleura2 | ind_zmat(3,2)=1 |
| 210 | 1 | pfleura2 | ind_zmat(3,3)=2 |
| 211 | 1 | pfleura2 | END SELECT |
| 212 | 1 | pfleura2 | |
| 213 | 1 | pfleura2 | IF (debug) THEN |
| 214 | 1 | pfleura2 | WRITE(*,*) "DBG Calc_zmat_frag - Nat=3 -" |
| 215 | 1 | pfleura2 | DO i=1,na |
| 216 | 1 | pfleura2 | WRITE(*,'(1X,A3,5(1X,I5))') Nom(Atome(ind_zmat(i,1))),(ind_zmat(i,j),j=1,5) |
| 217 | 1 | pfleura2 | END DO |
| 218 | 1 | pfleura2 | END IF |
| 219 | 1 | pfleura2 | |
| 220 | 1 | pfleura2 | ! We have ind_zmat, we fill val_zmat |
| 221 | 1 | pfleura2 | val_zmat=0.d0 |
| 222 | 1 | pfleura2 | n2=ind_zmat(2,1) |
| 223 | 1 | pfleura2 | n1=ind_zmat(2,2) |
| 224 | 1 | pfleura2 | d=sqrt((x(n1)-x(n2))**2+(y(n1)-y(n2))**2+(z(n1)-z(n2))**2) |
| 225 | 1 | pfleura2 | val_zmat(2,1)=d |
| 226 | 1 | pfleura2 | n1=ind_zmat(3,1) |
| 227 | 1 | pfleura2 | n2=ind_zmat(3,2) |
| 228 | 1 | pfleura2 | n3=ind_zmat(3,3) |
| 229 | 1 | pfleura2 | CALL vecteur(n2,n1,x,y,z,vx1,vy1,vz1,norm1) |
| 230 | 1 | pfleura2 | if (debug) write(*,*) n1,n2,norm1 |
| 231 | 1 | pfleura2 | val_zmat(3,1)=norm1 |
| 232 | 1 | pfleura2 | |
| 233 | 1 | pfleura2 | CALL vecteur(n2,n3,x,y,z,vx2,vy2,vz2,norm2) |
| 234 | 1 | pfleura2 | val=angle(vx1,vy1,vz1,norm1,vx2,vy2,vz2,norm2) |
| 235 | 1 | pfleura2 | if (debug) write(*,*) n2,n3,norm2,val |
| 236 | 1 | pfleura2 | val_zmat(3,2)=val |
| 237 | 1 | pfleura2 | |
| 238 | 1 | pfleura2 | RETURN |
| 239 | 1 | pfleura2 | END IF !matches if (Na.eq.3) THEN |
| 240 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 241 | 1 | pfleura2 | ! |
| 242 | 1 | pfleura2 | ! End of Easy case : 3 or less atoms |
| 243 | 1 | pfleura2 | ! |
| 244 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 245 | 1 | pfleura2 | ! |
| 246 | 1 | pfleura2 | ! General Case |
| 247 | 1 | pfleura2 | ! |
| 248 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 249 | 1 | pfleura2 | ! |
| 250 | 1 | pfleura2 | |
| 251 | 1 | pfleura2 | ! Initialization |
| 252 | 1 | pfleura2 | DejaFait=.False. |
| 253 | 1 | pfleura2 | Liaisons=0 |
| 254 | 1 | pfleura2 | ind_zmat=0 |
| 255 | 1 | pfleura2 | val_zmat=0.d0 |
| 256 | 1 | pfleura2 | |
| 257 | 1 | pfleura2 | if (debug) WRITE(*,*) "Coucou from Calc_zmat_frag.f90; L240" |
| 258 | 1 | pfleura2 | |
| 259 | 1 | pfleura2 | if (debug) THEN |
| 260 | 1 | pfleura2 | WRITE(*,*) "Bonds initialized" |
| 261 | 1 | pfleura2 | WRITE(*,*) 'Covalent radii used' |
| 262 | 1 | pfleura2 | DO iat=1,na |
| 263 | 1 | pfleura2 | i=atome(iat) |
| 264 | 1 | pfleura2 | WRITE(*,*) Nom(I),Iat,r_cov(i),r_cov(i)*fact |
| 265 | 1 | pfleura2 | END DO |
| 266 | 1 | pfleura2 | END IF |
| 267 | 1 | pfleura2 | |
| 268 | 1 | pfleura2 | 1003 FORMAT(1X,I4,' - ',25(I5)) |
| 269 | 1 | pfleura2 | |
| 270 | 1 | pfleura2 | ! First step : connectivity are calculated |
| 271 | 1 | pfleura2 | |
| 272 | 1 | pfleura2 | Call CalcCnct(na,atome,x,y,z,LIAISONS,r_cov,fact) |
| 273 | 1 | pfleura2 | |
| 274 | 1 | pfleura2 | if (debug) THEN |
| 275 | 1 | pfleura2 | WRITE(*,*) "Connections calculated" |
| 276 | 1 | pfleura2 | DO IL=1,na |
| 277 | 1 | pfleura2 | WRITE(IOOUT,1003) Il,(LIAISONS(IL,JL),JL=0,NMaxL) |
| 278 | 1 | pfleura2 | END DO |
| 279 | 1 | pfleura2 | END IF |
| 280 | 1 | pfleura2 | |
| 281 | 1 | pfleura2 | FCaf=.TRUE. |
| 282 | 1 | pfleura2 | Call Decomp_frag(na,liaisons,FCaf,nbfrag,Fragment,NbAtFrag,FragAt) |
| 283 | 1 | pfleura2 | |
| 284 | 1 | pfleura2 | IF (debug) THEN |
| 285 | 1 | pfleura2 | WRITE(*,*) 'I found ',NbFrag, 'fragments' |
| 286 | 1 | pfleura2 | WRITE(*,*) (NbAtFrag(I),I=1,NbFrag) |
| 287 | 1 | pfleura2 | DO I=1,NbFrag |
| 288 | 1 | pfleura2 | WRITE(*,*) NbAtFrag(I) |
| 289 | 1 | pfleura2 | WRITE(*,*) 'Fragment ', i |
| 290 | 1 | pfleura2 | DO J=1,Na |
| 291 | 1 | pfleura2 | IF (Fragment(J).EQ.I) WRITE(*,'(1X,I3,1X,A5,3(1X,F10.6))') J,Nom(Atome(J)) & |
| 292 | 1 | pfleura2 | ,X(J),Y(J),Z(J) |
| 293 | 1 | pfleura2 | END DO |
| 294 | 1 | pfleura2 | WRITE(*,*) "FragAt:",(FragAt(I,j),j=1,NbAtFrag(I)) |
| 295 | 1 | pfleura2 | END DO |
| 296 | 1 | pfleura2 | END IF |
| 297 | 1 | pfleura2 | |
| 298 | 1 | pfleura2 | ALLOCATE(MaxLFrag(NbFrag,2)) |
| 299 | 1 | pfleura2 | |
| 300 | 1 | pfleura2 | MaxLFrag=0 |
| 301 | 1 | pfleura2 | |
| 302 | 1 | pfleura2 | DO I=1,NbFrag |
| 303 | 1 | pfleura2 | MaxLFrag(I,1)=Liaisons(FragAt(I,1),0) |
| 304 | 1 | pfleura2 | MaxLFrag(I,2)=FragAt(I,1) |
| 305 | 1 | pfleura2 | |
| 306 | 1 | pfleura2 | DO J=1,NbAtFrag(I) |
| 307 | 1 | pfleura2 | Iat=FragAt(I,J) |
| 308 | 1 | pfleura2 | IF (Liaisons(IAt,0).GT.MaxLFrag(I,1)) THEN |
| 309 | 1 | pfleura2 | MaxLFrag(I,1)=Liaisons(Iat,0) |
| 310 | 1 | pfleura2 | MaxLFrag(I,2)=Iat |
| 311 | 1 | pfleura2 | END IF |
| 312 | 1 | pfleura2 | END DO |
| 313 | 1 | pfleura2 | IF (debug) WRITE(*,*) 'Frag :',I,', atom ',MaxLFrag(I,2), ' has ',MaxLFrag(I,2),' links' |
| 314 | 1 | pfleura2 | END DO |
| 315 | 1 | pfleura2 | |
| 316 | 1 | pfleura2 | ! We will now build the molecule fragment by fragment |
| 317 | 1 | pfleura2 | ! We choose the starting fragment with two criteria: |
| 318 | 1 | pfleura2 | ! 1- Number of linked atoms: |
| 319 | 1 | pfleura2 | ! * >=3 is good as it fully defines the coordinate space |
| 320 | 1 | pfleura2 | ! * 2 is ok as we can either use a 3rd atom from the same fragment |
| 321 | 1 | pfleura2 | ! or add a X atom somewhere but this complicates quite a lot the way |
| 322 | 1 | pfleura2 | ! to treat the conversion from cartesian to zmat latter |
| 323 | 1 | pfleura2 | ! * 1 is bad... |
| 324 | 1 | pfleura2 | ! 2- Size of the fragment |
| 325 | 1 | pfleura2 | ! this allows us to deal more easily with cases 1- when number of |
| 326 | 1 | pfleura2 | ! directly linked atoms is less than 3 |
| 327 | 1 | pfleura2 | |
| 328 | 1 | pfleura2 | IFrag=0 |
| 329 | 1 | pfleura2 | ! I0 is the number of connections of the best fragment |
| 330 | 1 | pfleura2 | I0=0 |
| 331 | 1 | pfleura2 | ! I1 is the number of atoms of the best fragment |
| 332 | 1 | pfleura2 | I1=0 |
| 333 | 1 | pfleura2 | IAt=0 |
| 334 | 1 | pfleura2 | DO I=1,NbFrag |
| 335 | 1 | pfleura2 | SELECT CASE(MaxLFrag(I,1)-I0) |
| 336 | 1 | pfleura2 | CASE (1:) |
| 337 | 1 | pfleura2 | IFrag=I |
| 338 | 1 | pfleura2 | I0=MaxLFrag(I,1) |
| 339 | 1 | pfleura2 | I1=NbAtFrag(I) |
| 340 | 1 | pfleura2 | IAt=MaxLFrag(I,2) |
| 341 | 1 | pfleura2 | CASE (0) |
| 342 | 1 | pfleura2 | if (NbAtFrag(I).GT.I1) THEN |
| 343 | 1 | pfleura2 | IFrag=I |
| 344 | 1 | pfleura2 | I0=MaxLFrag(I,1) |
| 345 | 1 | pfleura2 | I1=NbAtFrag(I) |
| 346 | 1 | pfleura2 | IAt=MaxLFrag(I,2) |
| 347 | 1 | pfleura2 | END IF |
| 348 | 1 | pfleura2 | END SELECT |
| 349 | 1 | pfleura2 | END DO |
| 350 | 1 | pfleura2 | |
| 351 | 1 | pfleura2 | if (debug) WRITE(*,'(1X,A,I5,A,I5,A,I5,A,I5)') 'Starting with fragment:',IFrag,' with ',I0 & |
| 352 | 1 | pfleura2 | ,' max links for atom',IAt,' fragment size',NbAtFrag(IFrag) |
| 353 | 1 | pfleura2 | |
| 354 | 1 | pfleura2 | ! We will build the first fragment in a special way, as it will |
| 355 | 1 | pfleura2 | ! set the coordinates system |
| 356 | 1 | pfleura2 | |
| 357 | 1 | pfleura2 | if (debug) WRITE(*,*) 'Fragment 1, starting with atom:',IAt, & |
| 358 | 1 | pfleura2 | 'with ',I0,' connections' |
| 359 | 1 | pfleura2 | |
| 360 | 1 | pfleura2 | DejaFait=.FALSE. |
| 361 | 1 | pfleura2 | FCaf=.FALSE. |
| 362 | 1 | pfleura2 | |
| 363 | 1 | pfleura2 | izm=0 |
| 364 | 1 | pfleura2 | SELECT CASE (I0) |
| 365 | 1 | pfleura2 | CASE(3:) |
| 366 | 1 | pfleura2 | if (debug) WRITE(*,*) 'DBG select case I0 3' |
| 367 | 1 | pfleura2 | n0=Iat |
| 368 | 1 | pfleura2 | |
| 369 | 1 | pfleura2 | ITmp=2 |
| 370 | 1 | pfleura2 | sDihe=0. |
| 371 | 1 | pfleura2 | n2=IAt |
| 372 | 1 | pfleura2 | n3=Liaisons(Iat,1) |
| 373 | 1 | pfleura2 | ! We search for the third atom while making sure that it is not aligned with first two ! |
| 374 | 1 | pfleura2 | DO While ((ITmp.LE.Liaisons(Iat,0)).AND.(sDihe.LE.0.09d0)) |
| 375 | 1 | pfleura2 | n4=Liaisons(Iat,Itmp) |
| 376 | 1 | pfleura2 | CALL vecteur(n2,n3,x,y,z,vx2,vy2,vz2,norm2) |
| 377 | 1 | pfleura2 | CALL vecteur(n3,n4,x,y,z,vx3,vy3,vz3,norm3) |
| 378 | 1 | pfleura2 | val_d=angle(vx3,vy3,vz3,norm3,vx2,vy2,vz2,norm2) |
| 379 | 1 | pfleura2 | sDiHe=abs(sin(val_d*pi/180.d0)) |
| 380 | 1 | pfleura2 | if (debug) Write(*,*) 'Trying n2,n3,n4,sdihe,val_d',n2,n3,n4,sdihe,val_d |
| 381 | 1 | pfleura2 | Itmp=Itmp+1 |
| 382 | 1 | pfleura2 | END DO |
| 383 | 1 | pfleura2 | If (debug) WRITE(*,*) 'Itmp,Liaisons',Itmp,Liaisons(Iat,1:NMaxL) |
| 384 | 1 | pfleura2 | Liaisons(Iat,Itmp-1)=Liaisons(iat,2) |
| 385 | 1 | pfleura2 | Liaisons(Iat,2)=n4 |
| 386 | 1 | pfleura2 | If (debug) WRITE(*,*) 'Itmp,Liaisons',Itmp,Liaisons(Iat,1:NMaxL) |
| 387 | 1 | pfleura2 | |
| 388 | 1 | pfleura2 | if (sDihe.LE.0.09d0) THEN |
| 389 | 1 | pfleura2 | WRITE(*,*) "PROBLEM !!! All atoms linked to ",n0," are aligned..." |
| 390 | 1 | pfleura2 | WRITE(*,*) "Surprising as this atom has at least three bonds... For NOW STOP" |
| 391 | 1 | pfleura2 | STOP |
| 392 | 1 | pfleura2 | END IF |
| 393 | 1 | pfleura2 | |
| 394 | 2 | pfleura2 | CALL produit_vect(vx3,vy3,vz3,vx2,vy2,vz2, vx5,vy5,vz5,norm5) |
| 395 | 1 | pfleura2 | |
| 396 | 1 | pfleura2 | |
| 397 | 1 | pfleura2 | ! We search for the fourth atom while checking that it is not aligned with 1st and 2nd atoms. |
| 398 | 1 | pfleura2 | Itmp=3 |
| 399 | 1 | pfleura2 | sDiHe=0. |
| 400 | 1 | pfleura2 | ! PFL 28 Dec 2007 -> |
| 401 | 1 | pfleura2 | ! I had a test on the dihedral angle, but I cannot see why it is important to have |
| 402 | 1 | pfleura2 | ! a non planar fragment at the begining... ethylene works and is fully planar |
| 403 | 1 | pfleura2 | ! I thus suppress this test |
| 404 | 1 | pfleura2 | ! |
| 405 | 1 | pfleura2 | ! DO While ((ITmp.LE.Liaisons(Iat,0)).AND.(sDihe.LE.0.09d0)) |
| 406 | 1 | pfleura2 | ! ITmp=ITmp+1 |
| 407 | 1 | pfleura2 | n1=Liaisons(Iat,Itmp) |
| 408 | 1 | pfleura2 | if (debug) WRITe(*,*) 'trying n1,n2,n3,n4',n1,n2,n3,n4 |
| 409 | 1 | pfleura2 | CALL vecteur(n2,n1,x,y,z,vx1,vy1,vz1,norm1) |
| 410 | 1 | pfleura2 | ! Is this atom aligned with n2-n3 ? |
| 411 | 1 | pfleura2 | val_d=angle(vx1,vy1,vz1,norm1,vx2,vy2,vz2,norm2) |
| 412 | 1 | pfleura2 | sDiHe=abs(sin(val_d*pi/180.d0)) |
| 413 | 1 | pfleura2 | if (debug) Write(*,*) 'Angle n3-n2-n1',val_d |
| 414 | 1 | pfleura2 | if (sDiHe.le.0.09d0) THEN |
| 415 | 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 |
| 416 | 1 | pfleura2 | if (debug) WRITE(*,*) "n3-n2-n1 aligned, we interchange n3 and n4" |
| 417 | 1 | pfleura2 | n1=n3 |
| 418 | 1 | pfleura2 | n3=n4 |
| 419 | 1 | pfleura2 | n4=n1 |
| 420 | 1 | pfleura2 | n1=Liaisons(Iat,ITmp) |
| 421 | 1 | pfleura2 | CALL vecteur(n2,n3,x,y,z,vx2,vy2,vz2,norm2) |
| 422 | 1 | pfleura2 | CALL vecteur(n2,n4,x,y,z,vx3,vy3,vz3,norm3) |
| 423 | 1 | pfleura2 | val_d=angle(vx1,vy1,vz1,norm1,vx2,vy2,vz2,norm2) |
| 424 | 1 | pfleura2 | if (debug) Write(*,*) 'NEW Angle n3-n2-n1',val_d |
| 425 | 1 | pfleura2 | END IF |
| 426 | 1 | pfleura2 | |
| 427 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 428 | 1 | pfleura2 | ! avant de tester l'angle diedre, il faut verifier que ce 4e atome n'est pas |
| 429 | 1 | pfleura2 | ! aligne avec les 2 premiers. |
| 430 | 1 | pfleura2 | ! comme on a deja test? que les 3 premiers ne sont pas alignes, |
| 431 | 1 | pfleura2 | ! s'il est align? avec les 2 premiers, on peut inverser le role de 2 et 3. |
| 432 | 1 | pfleura2 | ! On pourrait tout simplier en faisant une bete recherche parmi tous les atomes geles |
| 433 | 1 | pfleura2 | ! de ce bloc (au moins 4 ?) avec le critere 1) on les range par distance croissante |
| 434 | 1 | pfleura2 | ! 2) on les scanne tant que l'angle valence n'est pas bon, puis tant que diehedre pas bon |
| 435 | 1 | pfleura2 | ! puis les atomes des autres fragment par distance croissante. |
| 436 | 1 | pfleura2 | ! les autres fragments ne seraient additonn?s que si l'on ne trouve pas notre bonheur dans le premier bloc |
| 437 | 1 | pfleura2 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 438 | 1 | pfleura2 | |
| 439 | 2 | pfleura2 | CALL produit_vect(vx1,vy1,vz1,vx2,vy2,vz2, vx4,vy4,vz4,norm4) |
| 440 | 1 | pfleura2 | val_d=angle_d(vx4,vy4,vz4,norm4,vx5,vy5,vz5,norm5, & |
| 441 | 1 | pfleura2 | vx2,vy2,vz2,norm2) |
| 442 | 1 | pfleura2 | sDihe=abs(sin(val_d*pi/180.d0)) |
| 443 | 1 | pfleura2 | if (debug) WRITE(*,*) 'n2,n3,n4,n1, angle_d',n2,n3,n4,n1,val_d |
| 444 | 1 | pfleura2 | ! END DO |
| 445 | 1 | pfleura2 | |
| 446 | 1 | pfleura2 | DejaFait(n2)=.TRUE. |
| 447 | 1 | pfleura2 | DejaFait(n3)=.TRUE. |
| 448 | 1 | pfleura2 | DejaFait(n4)=.TRUE. |
| 449 | 1 | pfleura2 | |
| 450 | 1 | pfleura2 | ! if (sDihe.LE.0.09d0) THEN |
| 451 | 1 | pfleura2 | ! ! None of the atoms linked to IAt are good to define the third |
| 452 | 1 | pfleura2 | ! ! direction in space... |
| 453 | 1 | pfleura2 | ! ! We will look at the other atoms |
| 454 | 1 | pfleura2 | ! ! we might improve the search so as to take the atom closest to IAt |
| 455 | 1 | pfleura2 | ! if (debug) WRITE(*,*) "All atoms linked to ",Iat," are in a plane. Looking for other atoms" |
| 456 | 1 | pfleura2 | ! ITmp=0 |
| 457 | 1 | pfleura2 | ! DO I=1,NbAtFrag(IFrag) |
| 458 | 1 | pfleura2 | ! JAt=FragAt(IFrag,I) |
| 459 | 1 | pfleura2 | ! if (FrozAt(Jat).AND.(.NOT.DejaFait(JAt))) THEN |
| 460 | 1 | pfleura2 | ! n1=JAt |
| 461 | 1 | pfleura2 | ! CALL vecteur(n2,n1,x,y,z,vx1,vy1,vz1,norm1) |
| 462 | 2 | pfleura2 | ! CALL produit_vect(vx1,vy1,vz1,vx2,vy2,vz2,vx4,vy4,vz4,norm4) |
| 463 | 1 | pfleura2 | ! val_d=angle_d(vx4,vy4,vz4,norm4, & |
| 464 | 1 | pfleura2 | ! vx5,vy5,vz5,norm5, & |
| 465 | 1 | pfleura2 | ! vx2,vy2,vz2,norm2) |
| 466 | 1 | pfleura2 | ! if (abs(sin(val_d)).GE.0.09D0) THEN |
| 467 | 1 | pfleura2 | ! ITmp=ITmp+1 |
| 468 | 1 | pfleura2 | ! DistFrag(ITmp)=Norm1 |
| 469 | 1 | pfleura2 | ! FragDist(ITmp)=JAt |
| 470 | 1 | pfleura2 | ! END IF |
| 471 | 1 | pfleura2 | ! END IF |
| 472 | 1 | pfleura2 | ! END DO |
| 473 | 1 | pfleura2 | |
| 474 | 1 | pfleura2 | ! IF (ITmp.EQ.0) THEN |
| 475 | 1 | pfleura2 | ! ! All dihedral angles between frozen atoms are less than 5? |
| 476 | 1 | pfleura2 | ! ! (or more than 175?). We have to look at other fragments :-( |
| 477 | 1 | pfleura2 | ! DO I=1,NFroz |
| 478 | 1 | pfleura2 | ! Jat=Frozen(I) |
| 479 | 1 | pfleura2 | ! if (.NOT.DejaFait(JAt)) THEN |
| 480 | 1 | pfleura2 | ! n1=JAt |
| 481 | 1 | pfleura2 | ! CALL vecteur(n2,n1,x,y,z,vx1,vy1,vz1,norm1) |
| 482 | 2 | pfleura2 | ! CALL produit_vect(vx1,vy1,vz1,vx2,vy2,vz2,vx4,vy4,vz4,norm4) |
| 483 | 1 | pfleura2 | ! val_d=angle_d(vx4,vy4,vz4,norm4, & |
| 484 | 1 | pfleura2 | ! vx5,vy5,vz5,norm5, & |
| 485 | 1 | pfleura2 | ! vx2,vy2,vz2,norm2) |
| 486 | 1 | pfleura2 | ! if (abs(sin(val_d)).GE.0.09D0) THEN |
| 487 | 1 | pfleura2 | ! ITmp=ITmp+1 |
| 488 | 1 | pfleura2 | ! DistFrag(ITmp)=Norm1 |
| 489 | 1 | pfleura2 | ! FragDist(ITmp)=JAt |
| 490 | 1 | pfleura2 | ! END IF |
| 491 | 1 | pfleura2 | ! END IF |
| 492 | 1 | pfleura2 | ! END DO |
| 493 | 1 | pfleura2 | ! IF (ITmp.EQ.0) THEN |
| 494 | 1 | pfleura2 | ! ! All frozen atoms are in a plane... too bad |
| 495 | 1 | pfleura2 | ! WRITE(*,*) 'ERROR: It seems that all frozen atoms are in a plane' |
| 496 | 1 | pfleura2 | ! WRITE(*,*) 'For now, I do not treat this case' |
| 497 | 1 | pfleura2 | ! STOP |
| 498 | 1 | pfleura2 | ! END IF |
| 499 | 1 | pfleura2 | ! END IF |
| 500 | 1 | pfleura2 | ! I1=0 |
| 501 | 1 | pfleura2 | ! d=1e9 |
| 502 | 1 | pfleura2 | ! DO I=1,ITmp |
| 503 | 1 | pfleura2 | ! IF (DistFrag(I).LE.d) THEN |
| 504 | 1 | pfleura2 | ! d=DistFrag(I) |
| 505 | 1 | pfleura2 | ! I1=FragDist(I) |
| 506 | 1 | pfleura2 | ! END IF |
| 507 | 1 | pfleura2 | ! END DO |
| 508 | 1 | pfleura2 | ! ELSE !(sDihe.LE.0.09d0) |
| 509 | 1 | pfleura2 | ! I1=FrozBlock(IAt,ITmp) |
| 510 | 1 | pfleura2 | ! if (debug) WRITE(*,*) 'I1,n1:',I1,n1 |
| 511 | 1 | pfleura2 | ! END IF !(sDihe.LE.0.09d0) |
| 512 | 1 | pfleura2 | ! ! we now have the atom that is closer to the first one and that |
| 513 | 1 | pfleura2 | ! ! forms a non 0/Pi dihedral angle |
| 514 | 1 | pfleura2 | ! |
| 515 | 1 | pfleura2 | ! <- PFL 28 Dec 2007 |
| 516 | 1 | pfleura2 | |
| 517 | 1 | pfleura2 | ! We construct the begining of the Z-Matrix |
| 518 | 1 | pfleura2 | |
| 519 | 1 | pfleura2 | ind_zmat(1,1)=n2 |
| 520 | 1 | pfleura2 | ind_zmat(2,1)=n3 |
| 521 | 1 | pfleura2 | ind_zmat(2,2)=n2 |
| 522 | 1 | pfleura2 | ind_zmat(3,1)=n4 |
| 523 | 1 | pfleura2 | ind_zmat(3,2)=n2 |
| 524 | 1 | pfleura2 | ind_zmat(3,3)=n3 |
| 525 | 1 | pfleura2 | DejaFait(n2)=.TRUE. |
| 526 | 1 | pfleura2 | DejaFait(n3)=.TRUE. |
| 527 | 1 | pfleura2 | DejaFait(n4)=.TRUE. |
| 528 | 1 | pfleura2 | CaFaire(1)=n3 |
| 529 | 1 | pfleura2 | CaFaire(2)=n4 |
| 530 | 1 | pfleura2 | |
| 531 | 1 | pfleura2 | ! PFL 28 Dec 2007 |
| 532 | 1 | pfleura2 | ! We have not selected a fourth atom, so that the following is not needed |
| 533 | 1 | pfleura2 | ! ind_zmat(4,1)=I1 |
| 534 | 1 | pfleura2 | ! ind_zmat(4,2)=n2 |
| 535 | 1 | pfleura2 | ! ind_zmat(4,3)=n3 |
| 536 | 1 | pfleura2 | ! ind_zmat(4,4)=n4 |
| 537 | 1 | pfleura2 | ! DejaFait(I1)=.TRUE. |
| 538 | 1 | pfleura2 | ! CaFaire(3)=I1 |
| 539 | 1 | pfleura2 | ! CaFaire(4)=0 |
| 540 | 1 | pfleura2 | ! IdxCaFaire=4 |
| 541 | 1 | pfleura2 | ! izm=4 |
| 542 | 1 | pfleura2 | ! FCaf(I1)=.TRUE. |
| 543 | 1 | pfleura2 | !!!!!!! |
| 544 | 1 | pfleura2 | ! and replaced by: |
| 545 | 1 | pfleura2 | CaFaire(3)=0 |
| 546 | 1 | pfleura2 | IdxCaFaire=3 |
| 547 | 1 | pfleura2 | izm=3 |
| 548 | 1 | pfleura2 | ! |
| 549 | 1 | pfleura2 | ! <- PFL 28 Dec 2007 |
| 550 | 1 | pfleura2 | |
| 551 | 1 | pfleura2 | FCaf(n2)=.TRUE. |
| 552 | 1 | pfleura2 | FCaf(n3)=.TRUE. |
| 553 | 1 | pfleura2 | FirstAt=.TRUE. |
| 554 | 1 | pfleura2 | DO I=3,Liaisons(Iat,0) |
| 555 | 1 | pfleura2 | IF (.NOT.DejaFait(Liaisons(Iat,I))) THEN |
| 556 | 1 | pfleura2 | izm=izm+1 |
| 557 | 1 | pfleura2 | ! ind_zmat(izm,1)=Liaisons(Iat,I) |
| 558 | 1 | pfleura2 | ! ind_zmat(izm,2)=n2 |
| 559 | 1 | pfleura2 | ! ind_zmat(izm,3)=n3 |
| 560 | 1 | pfleura2 | ! ind_zmat(izm,4)=n4 |
| 561 | 1 | pfleura2 | Call add2indzmat(na,izm,Liaisons(Iat,I),n2,n3,n4,ind_zmat,x,y,z) |
| 562 | 1 | pfleura2 | if (FirstAt) THEN |
| 563 | 1 | pfleura2 | n4=Liaisons(Iat,I) |
| 564 | 1 | pfleura2 | FirstAt=.FALSE. |
| 565 | 1 | pfleura2 | END IF |
| 566 | 1 | pfleura2 | IF (.NOT.FCaf(Liaisons(Iat,I))) THEN |
| 567 | 1 | pfleura2 | CaFaire(IdxCaFaire)=Liaisons(Iat,I) |
| 568 | 1 | pfleura2 | IdxCaFaire=IdxCaFaire+1 |
| 569 | 1 | pfleura2 | CaFaire(IdxCaFaire)=0 |
| 570 | 1 | pfleura2 | FCaf(Liaisons(Iat,I))=.TRUE. |
| 571 | 1 | pfleura2 | END IF |
| 572 | 1 | pfleura2 | DejaFait(Liaisons(Iat,I))=.TRUE. |
| 573 | 1 | pfleura2 | END IF |
| 574 | 1 | pfleura2 | END DO |
| 575 | 1 | pfleura2 | |
| 576 | 1 | pfleura2 | if (debug) THEN |
| 577 | 1 | pfleura2 | WRITE(*,*) "Ind_zmat 0 - SELECT CASE I0 3: -- izm=",izm |
| 578 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(1,1) |
| 579 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(2,1), ind_zmat(2,2) |
| 580 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(3,1), ind_zmat(3,2), ind_zmat(3,3) |
| 581 | 1 | pfleura2 | DO I=4,izm |
| 582 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(I,1), ind_zmat(I,2), & |
| 583 | 1 | pfleura2 | ind_zmat(I,3), ind_zmat(I,4) |
| 584 | 1 | pfleura2 | END DO |
| 585 | 1 | pfleura2 | END IF |
| 586 | 1 | pfleura2 | |
| 587 | 1 | pfleura2 | |
| 588 | 1 | pfleura2 | ! First four atoms (at least) have been put we go on with next parts |
| 589 | 1 | pfleura2 | ! of this fragment... later |
| 590 | 1 | pfleura2 | |
| 591 | 1 | pfleura2 | |
| 592 | 1 | pfleura2 | CASE(2) |
| 593 | 1 | pfleura2 | if (debug) WRITE(*,*) 'DBG select case I0 2' |
| 594 | 1 | pfleura2 | WRITE(*,*) "PFL 28 Dec 2007: No test of alignment here :( TO DO TO DO TO DO" |
| 595 | 1 | pfleura2 | ind_zmat(1,1)=IAt |
| 596 | 1 | pfleura2 | ind_zmat(2,1)=Liaisons(IAt,1) |
| 597 | 1 | pfleura2 | ind_zmat(2,2)=IAt |
| 598 | 1 | pfleura2 | ind_zmat(3,1)=Liaisons(IAt,2) |
| 599 | 1 | pfleura2 | ind_zmat(3,2)=IAt |
| 600 | 1 | pfleura2 | ind_zmat(3,3)=Liaisons(IAt,1) |
| 601 | 1 | pfleura2 | DejaFait(IAt)=.TRUE. |
| 602 | 1 | pfleura2 | DejaFait(Liaisons(Iat,1))=.TRUE. |
| 603 | 1 | pfleura2 | DejaFait(Liaisons(Iat,2))=.TRUE. |
| 604 | 1 | pfleura2 | CaFaire(1)=Liaisons(Iat,1) |
| 605 | 1 | pfleura2 | CaFaire(2)=Liaisons(Iat,2) |
| 606 | 1 | pfleura2 | FCaf(Liaisons(Iat,1))=.TRUE. |
| 607 | 1 | pfleura2 | FCaf(Liaisons(Iat,2))=.TRUE. |
| 608 | 1 | pfleura2 | |
| 609 | 1 | pfleura2 | ! PFL 28 Dec 2007 -> |
| 610 | 1 | pfleura2 | ! We do NOT need a fourth atom !!! The third direction in space is defined by the cross |
| 611 | 1 | pfleura2 | ! product of the first two directions |
| 612 | 1 | pfleura2 | ! |
| 613 | 1 | pfleura2 | ! the following is thus commented |
| 614 | 1 | pfleura2 | ! |
| 615 | 1 | pfleura2 | ! ! We search for a fourth atom, first in the FrozBlock atoms |
| 616 | 1 | pfleura2 | ! ITmp=2 |
| 617 | 1 | pfleura2 | ! sDihe=0. |
| 618 | 1 | pfleura2 | ! n2=IAt |
| 619 | 1 | pfleura2 | ! n3=Liaisons(Iat,1) |
| 620 | 1 | pfleura2 | ! n4=Liaisons(Iat,2) |
| 621 | 1 | pfleura2 | ! CALL vecteur(n2,n3,x,y,z,vx2,vy2,vz2,norm2) |
| 622 | 1 | pfleura2 | ! CALL vecteur(n3,n4,x,y,z,vx3,vy3,vz3,norm3) |
| 623 | 2 | pfleura2 | ! CALL produit_vect(vx3,vy3,vz3, vx2,vy2,vz2, vx5,vy5,vz5,norm5) |
| 624 | 1 | pfleura2 | ! |
| 625 | 1 | pfleura2 | ! DO While ((ITmp.LE.FrozBlock(Iat,0)).AND.(sDihe.LE.0.09d0)) |
| 626 | 1 | pfleura2 | ! ITmp=ITmp+1 |
| 627 | 1 | pfleura2 | ! n1=FrozBlock(Iat,Itmp) |
| 628 | 1 | pfleura2 | ! CALL vecteur(n2,n1,x,y,z,vx1,vy1,vz1,norm1) |
| 629 | 2 | pfleura2 | ! CALL produit_vect(vx1,vy1,vz1,vx2,vy2,vz2, vx4,vy4,vz4,norm4) |
| 630 | 1 | pfleura2 | ! val_d=angle_d(vx4,vy4,vz4,norm4, & |
| 631 | 1 | pfleura2 | ! vx5,vy5,vz5,norm5, & |
| 632 | 1 | pfleura2 | ! vx2,vy2,vz2,norm2) |
| 633 | 1 | pfleura2 | ! sDihe=abs(sin(val_d)) |
| 634 | 1 | pfleura2 | ! END DO |
| 635 | 1 | pfleura2 | ! IF (debug) WRITE(*,*) 'DBG 4th atom, ITmp, sDihe',ITmp, sDihe |
| 636 | 1 | pfleura2 | ! if (sDihe.LE.0.09d0) THEN |
| 637 | 1 | pfleura2 | ! ! None of the frozen atoms linked to IAt are good to define the third |
| 638 | 1 | pfleura2 | ! ! direction in space... |
| 639 | 1 | pfleura2 | ! ! We will look at the other frozen atoms |
| 640 | 1 | pfleura2 | ! ! we might improve the search so as to take the atom closest to IAt |
| 641 | 1 | pfleura2 | ! ITmp=0 |
| 642 | 1 | pfleura2 | ! DO I=1,NbAtFrag(IFrag) |
| 643 | 1 | pfleura2 | ! JAt=FragAt(IFrag,I) |
| 644 | 1 | pfleura2 | ! if (FrozAt(Jat).AND.(.NOT.DejaFait(JAt))) THEN |
| 645 | 1 | pfleura2 | ! n1=JAt |
| 646 | 1 | pfleura2 | ! CALL vecteur(n2,n1,x,y,z,vx1,vy1,vz1,norm1) |
| 647 | 2 | pfleura2 | ! CALL produit_vect(vx1,vy1,vz1, vx2,vy2,vz2, vx4,vy4,vz4,norm4) |
| 648 | 1 | pfleura2 | ! val_d=angle_d(vx4,vy4,vz4,norm4, & |
| 649 | 1 | pfleura2 | ! vx5,vy5,vz5,norm5, & |
| 650 | 1 | pfleura2 | ! vx2,vy2,vz2,norm2) |
| 651 | 1 | pfleura2 | ! if (abs(sin(val_d)).GE.0.09D0) THEN |
| 652 | 1 | pfleura2 | ! ITmp=ITmp+1 |
| 653 | 1 | pfleura2 | ! DistFrag(ITmp)=Norm1 |
| 654 | 1 | pfleura2 | ! FragDist(ITmp)=JAt |
| 655 | 1 | pfleura2 | ! END IF |
| 656 | 1 | pfleura2 | ! END IF |
| 657 | 1 | pfleura2 | ! END DO |
| 658 | 1 | pfleura2 | ! IF (ITmp.EQ.0) THEN |
| 659 | 1 | pfleura2 | ! ! All dihedral angles between frozen atoms are less than 5? |
| 660 | 1 | pfleura2 | ! ! (or more than 175?). We have to look at other fragments :-( |
| 661 | 1 | pfleura2 | ! DO I=1,NFroz |
| 662 | 1 | pfleura2 | ! Jat=Frozen(I) |
| 663 | 1 | pfleura2 | ! if (.NOT.DejaFait(JAt)) THEN |
| 664 | 1 | pfleura2 | ! n1=JAt |
| 665 | 1 | pfleura2 | ! CALL vecteur(n2,n1,x,y,z,vx1,vy1,vz1,norm1) |
| 666 | 2 | pfleura2 | ! CALL produit_vect(vx1,vy1,vz1, vx2,vy2,vz2, vx4,vy4,vz4,norm4) |
| 667 | 1 | pfleura2 | ! val_d=angle_d(vx4,vy4,vz4,norm4, & |
| 668 | 1 | pfleura2 | ! vx5,vy5,vz5,norm5, & |
| 669 | 1 | pfleura2 | ! vx2,vy2,vz2,norm2) |
| 670 | 1 | pfleura2 | ! if (abs(sin(val_d)).GE.0.09D0) THEN |
| 671 | 1 | pfleura2 | ! ITmp=ITmp+1 |
| 672 | 1 | pfleura2 | ! DistFrag(ITmp)=Norm1 |
| 673 | 1 | pfleura2 | ! FragDist(ITmp)=JAt |
| 674 | 1 | pfleura2 | ! END IF |
| 675 | 1 | pfleura2 | ! END IF |
| 676 | 1 | pfleura2 | ! END DO |
| 677 | 1 | pfleura2 | ! IF (ITmp.EQ.0) THEN |
| 678 | 1 | pfleura2 | ! ! All frozen atoms are in a plane... too bad |
| 679 | 1 | pfleura2 | ! WRITE(*,*) 'ERROR: It seems that all frozen atoms are in a plane' |
| 680 | 1 | pfleura2 | ! WRITE(*,*) 'For now, I do not treat this case' |
| 681 | 1 | pfleura2 | ! STOP |
| 682 | 1 | pfleura2 | ! END IF |
| 683 | 1 | pfleura2 | ! END IF |
| 684 | 1 | pfleura2 | ! I1=0 |
| 685 | 1 | pfleura2 | ! d=1e9 |
| 686 | 1 | pfleura2 | ! DO I=1,ITmp |
| 687 | 1 | pfleura2 | ! IF (DistFrag(I).LE.d) THEN |
| 688 | 1 | pfleura2 | ! d=DistFrag(I) |
| 689 | 1 | pfleura2 | ! I1=FragDist(I) |
| 690 | 1 | pfleura2 | ! END IF |
| 691 | 1 | pfleura2 | ! END DO |
| 692 | 1 | pfleura2 | ! ELSE !(sDihe.LE.0.09d0) |
| 693 | 1 | pfleura2 | ! I1=FrozBlock(IAt,ITmp) |
| 694 | 1 | pfleura2 | ! END IF !(sDihe.LE.0.09d0) |
| 695 | 1 | pfleura2 | ! ! we now have the atom that is closer to the first one and that |
| 696 | 1 | pfleura2 | ! ! forms a non 0/Pi dihedral angle |
| 697 | 1 | pfleura2 | ! ! ind_zmat(4,1)=I1 |
| 698 | 1 | pfleura2 | ! ! ind_zmat(4,2)=IAt |
| 699 | 1 | pfleura2 | ! ! ind_zmat(4,3)=Liaisons(Iat,1) |
| 700 | 1 | pfleura2 | ! ! ind_zmat(4,4)=Liaisons(Iat,2) |
| 701 | 1 | pfleura2 | ! n3=Liaisons(Iat,1) |
| 702 | 1 | pfleura2 | ! n4=Liaisons(Iat,2) |
| 703 | 1 | pfleura2 | ! Call add2indzmat(na,4,I1,Iat,n3,n4,ind_zmat,x,y,z) |
| 704 | 1 | pfleura2 | ! Liaisons(Iat,1)=n3 |
| 705 | 1 | pfleura2 | ! Liaisons(Iat,2)=n4 |
| 706 | 1 | pfleura2 | ! DejaFait(I1)=.TRUE. |
| 707 | 1 | pfleura2 | ! CaFaire(3)=I1 |
| 708 | 1 | pfleura2 | ! CaFaire(4)=0 |
| 709 | 1 | pfleura2 | ! IdxCaFaire=4 |
| 710 | 1 | pfleura2 | ! izm=4 |
| 711 | 1 | pfleura2 | ! FCaf(I1)=.TRUE. |
| 712 | 1 | pfleura2 | ! |
| 713 | 1 | pfleura2 | !!!!!! <- PFL 28 Dec 2007 |
| 714 | 1 | pfleura2 | |
| 715 | 1 | pfleura2 | CaFaire(3)=0 |
| 716 | 1 | pfleura2 | IdxCaFaire=3 |
| 717 | 1 | pfleura2 | izm=3 |
| 718 | 1 | pfleura2 | |
| 719 | 1 | pfleura2 | CASE(1) |
| 720 | 1 | pfleura2 | if (debug) WRITE(*,*) 'DBG select case I0 1, NbAtFrag=',NbAtFrag(IFrag) |
| 721 | 1 | pfleura2 | ind_zmat(1,1)=IAt |
| 722 | 1 | pfleura2 | ind_zmat(2,1)=Liaisons(IAt,1) |
| 723 | 1 | pfleura2 | ind_zmat(2,2)=IAt |
| 724 | 1 | pfleura2 | DejaFait(IAt)=.TRUE. |
| 725 | 1 | pfleura2 | DejaFait(Liaisons(Iat,1))=.TRUE. |
| 726 | 1 | pfleura2 | IdxCaFaire=2 |
| 727 | 1 | pfleura2 | CaFaire(1)=Liaisons(Iat,1) |
| 728 | 1 | pfleura2 | CaFaire(2)=0 |
| 729 | 1 | pfleura2 | FCaf(Liaisons(Iat,1))=.TRUE. |
| 730 | 1 | pfleura2 | |
| 731 | 1 | pfleura2 | ! PFL 28 Dec 2007 -> |
| 732 | 1 | pfleura2 | ! We do NOT need a fourth atom. So we will look only for a third atom |
| 733 | 1 | pfleura2 | ! |
| 734 | 1 | pfleura2 | !!!! |
| 735 | 1 | pfleura2 | ! |
| 736 | 1 | pfleura2 | ! We search for a third and fourth atoms, first in the FrozBlock atoms |
| 737 | 1 | pfleura2 | ! It should not be possible to have (FrozBlock(Iat,0).GT.2) and |
| 738 | 1 | pfleura2 | ! iat linked to only one atom ! |
| 739 | 1 | pfleura2 | |
| 740 | 1 | pfleura2 | |
| 741 | 1 | pfleura2 | ! we calculate the distances between Iat and all other frozen |
| 742 | 1 | pfleura2 | ! atoms of this fragment, and store only those for which |
| 743 | 1 | pfleura2 | ! valence angles are not too close to 0/Pi. (limit:5?) |
| 744 | 1 | pfleura2 | |
| 745 | 1 | pfleura2 | ITmp=0 |
| 746 | 1 | pfleura2 | CALL vecteur(Liaisons(Iat,1),IAt,x,y,z,vx2,vy2,vz2,norm2) |
| 747 | 1 | pfleura2 | |
| 748 | 1 | pfleura2 | ! PFL 28 Dec 2007: As MaxL=1 I think that there is at most 2 atoms in this fragment... |
| 749 | 1 | pfleura2 | ! so that the following loop is useless... this should be tested more carefully |
| 750 | 1 | pfleura2 | DO I=1,NbAtFrag(IFrag) |
| 751 | 1 | pfleura2 | JAt=FragAt(IFrag,I) |
| 752 | 1 | pfleura2 | if (.NOT.DejaFait(JAt)) THEN |
| 753 | 1 | pfleura2 | CALL vecteur(JAt,IAt,x,y,z,vx1,vy1,vz1,norm1) |
| 754 | 1 | pfleura2 | if (abs(cos(angle(vx1,vy1,vz1,norm1, & |
| 755 | 1 | pfleura2 | vx2,vy2,vz2,norm2))).LE.0.996d0) THEN |
| 756 | 1 | pfleura2 | ITmp=ITmp+1 |
| 757 | 1 | pfleura2 | DistFrag(ITmp)=Norm1 |
| 758 | 1 | pfleura2 | FragDist(ITmp)=JAt |
| 759 | 1 | pfleura2 | END IF |
| 760 | 1 | pfleura2 | END IF |
| 761 | 1 | pfleura2 | END DO |
| 762 | 1 | pfleura2 | |
| 763 | 1 | pfleura2 | IF (ITMP.EQ.0) THEN |
| 764 | 1 | pfleura2 | ! We have no atoms correct in this fragment, we use |
| 765 | 1 | pfleura2 | ! atoms from other fragments |
| 766 | 1 | pfleura2 | DO Jat=1,Na |
| 767 | 1 | pfleura2 | ! DejaFait(Iat)=.TRUE. so that we do not need to test Jat/=Iat |
| 768 | 1 | pfleura2 | if (.NOT.DejaFait(JAt)) THEN |
| 769 | 1 | pfleura2 | CALL vecteur(JAt,IAt,x,y,z,vx1,vy1,vz1,norm1) |
| 770 | 1 | pfleura2 | if (abs(cos(angle(vx1,vy1,vz1,norm1, & |
| 771 | 1 | pfleura2 | vx2,vy2,vz2,norm2))).LE.0.996d0) THEN |
| 772 | 1 | pfleura2 | ITmp=ITmp+1 |
| 773 | 1 | pfleura2 | DistFrag(ITmp)=Norm1 |
| 774 | 1 | pfleura2 | FragDist(ITmp)=JAt |
| 775 | 1 | pfleura2 | END IF |
| 776 | 1 | pfleura2 | END IF |
| 777 | 1 | pfleura2 | END DO |
| 778 | 1 | pfleura2 | IF (ITMP.EQ.0) THEN |
| 779 | 1 | pfleura2 | WRITE(*,*) 'It seems all atoms are aligned' |
| 780 | 1 | pfleura2 | WRITE(*,*) 'Case non treated for now :-( ' |
| 781 | 1 | pfleura2 | STOP |
| 782 | 1 | pfleura2 | END IF |
| 783 | 1 | pfleura2 | END IF |
| 784 | 1 | pfleura2 | |
| 785 | 1 | pfleura2 | I1=0 |
| 786 | 1 | pfleura2 | d=1e9 |
| 787 | 1 | pfleura2 | ! PFL 28 Dec 2007: There exists some F90 intrinsics to find the smallest element of an array. |
| 788 | 1 | pfleura2 | ! The following loop should be replaced by it ! |
| 789 | 1 | pfleura2 | DO I=1,ITmp |
| 790 | 1 | pfleura2 | IF (DistFrag(I).LE.d) THEN |
| 791 | 1 | pfleura2 | I1=FragDist(I) |
| 792 | 1 | pfleura2 | d=DistFrag(I) |
| 793 | 1 | pfleura2 | END IF |
| 794 | 1 | pfleura2 | END DO |
| 795 | 1 | pfleura2 | |
| 796 | 1 | pfleura2 | ! we now have the atom that is closer to the first one and that |
| 797 | 1 | pfleura2 | ! forms a non 0/Pi valence angle |
| 798 | 1 | pfleura2 | ind_zmat(3,1)=I1 |
| 799 | 1 | pfleura2 | ind_zmat(3,2)=IAt |
| 800 | 1 | pfleura2 | ind_zmat(3,3)=Liaisons(Iat,1) |
| 801 | 1 | pfleura2 | DejaFait(I1)=.TRUE. |
| 802 | 1 | pfleura2 | CaFaire(2)=I1 |
| 803 | 1 | pfleura2 | FCaf(I1)=.TRUE. |
| 804 | 1 | pfleura2 | |
| 805 | 1 | pfleura2 | |
| 806 | 1 | pfleura2 | ! PFL 28 Dec 2007 -> |
| 807 | 1 | pfleura2 | ! We do NOT need a fourth atom so that the following is suppressed |
| 808 | 1 | pfleura2 | ! |
| 809 | 1 | pfleura2 | ! ! we search for a fourth atom ! |
| 810 | 1 | pfleura2 | ! ! We search for a fourth atom, first in the FrozBlock atoms |
| 811 | 1 | pfleura2 | ! ITmp=2 |
| 812 | 1 | pfleura2 | ! sDihe=0. |
| 813 | 1 | pfleura2 | ! n2=IAt |
| 814 | 1 | pfleura2 | ! n3=Liaisons(Iat,1) |
| 815 | 1 | pfleura2 | ! n4=I1 |
| 816 | 1 | pfleura2 | ! CALL vecteur(n2,n3,x,y,z,vx2,vy2,vz2,norm2) |
| 817 | 1 | pfleura2 | ! CALL vecteur(n3,n4,x,y,z,vx3,vy3,vz3,norm3) |
| 818 | 2 | pfleura2 | ! CALL produit_vect(vx3,vy3,vz3, vx2,vy2,vz2,vx5,vy5,vz5,norm5) |
| 819 | 1 | pfleura2 | ! |
| 820 | 1 | pfleura2 | ! ! We will look at the other frozen atoms |
| 821 | 1 | pfleura2 | ! ! we might improve the search so as to take the atom closest to IAt |
| 822 | 1 | pfleura2 | ! ITmp=0 |
| 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 | ! n1=JAt |
| 827 | 1 | pfleura2 | ! CALL vecteur(n2,n1,x,y,z,vx1,vy1,vz1,norm1) |
| 828 | 2 | pfleura2 | ! CALL produit_vect(vx1,vy1,vz1, vx2,vy2,vz2, vx4,vy4,vz4,norm4) |
| 829 | 1 | pfleura2 | ! val_d=angle_d(vx4,vy4,vz4,norm4, & |
| 830 | 1 | pfleura2 | ! vx5,vy5,vz5,norm5, & |
| 831 | 1 | pfleura2 | ! vx2,vy2,vz2,norm2) |
| 832 | 1 | pfleura2 | ! if (abs(sin(val_d)).GE.0.09D0) THEN |
| 833 | 1 | pfleura2 | ! ITmp=ITmp+1 |
| 834 | 1 | pfleura2 | ! DistFrag(ITmp)=Norm1 |
| 835 | 1 | pfleura2 | ! FragDist(ITmp)=JAt |
| 836 | 1 | pfleura2 | ! END IF |
| 837 | 1 | pfleura2 | ! END IF |
| 838 | 1 | pfleura2 | ! END DO |
| 839 | 1 | pfleura2 | ! IF (ITmp.EQ.0) THEN |
| 840 | 1 | pfleura2 | ! ! All dihedral angles between frozen atoms are less than 5? |
| 841 | 1 | pfleura2 | ! ! (or more than 175?). We have to look at other fragments :-( |
| 842 | 1 | pfleura2 | ! DO I=1,NFroz |
| 843 | 1 | pfleura2 | ! Jat=Frozen(I) |
| 844 | 1 | pfleura2 | ! if (.NOT.DejaFait(JAt)) THEN |
| 845 | 1 | pfleura2 | ! n1=JAt |
| 846 | 1 | pfleura2 | ! CALL vecteur(n2,n1,x,y,z,vx1,vy1,vz1,norm1) |
| 847 | 2 | pfleura2 | ! CALL produit_vect(vx1,vy1,vz1,vx2,vy2,vz2, vx4,vy4,vz4,norm4) |
| 848 | 1 | pfleura2 | ! val_d=angle_d(vx4,vy4,vz4,norm4, & |
| 849 | 1 | pfleura2 | ! vx5,vy5,vz5,norm5, & |
| 850 | 1 | pfleura2 | ! vx2,vy2,vz2,norm2) |
| 851 | 1 | pfleura2 | ! if (abs(sin(val_d)).GE.0.09D0) THEN |
| 852 | 1 | pfleura2 | ! ITmp=ITmp+1 |
| 853 | 1 | pfleura2 | ! DistFrag(ITmp)=Norm1 |
| 854 | 1 | pfleura2 | ! FragDist(ITmp)=JAt |
| 855 | 1 | pfleura2 | ! END IF |
| 856 | 1 | pfleura2 | ! END IF |
| 857 | 1 | pfleura2 | ! END DO |
| 858 | 1 | pfleura2 | ! IF (ITmp.EQ.0) THEN |
| 859 | 1 | pfleura2 | ! ! All frozen atoms are in a plane... too bad |
| 860 | 1 | pfleura2 | ! WRITE(*,*) 'ERROR: It seems that all frozen atoms are in a plane' |
| 861 | 1 | pfleura2 | ! WRITE(*,*) 'For now, I do not treat this case' |
| 862 | 1 | pfleura2 | ! STOP |
| 863 | 1 | pfleura2 | ! END IF |
| 864 | 1 | pfleura2 | ! END IF ! ITmp.EQ.0 after scaning fragment |
| 865 | 1 | pfleura2 | ! I1=0 |
| 866 | 1 | pfleura2 | ! d=1e9 |
| 867 | 1 | pfleura2 | ! DO I=1,ITmp |
| 868 | 1 | pfleura2 | ! IF (DistFrag(I).LE.d) THEN |
| 869 | 1 | pfleura2 | ! d=DistFrag(I) |
| 870 | 1 | pfleura2 | ! I1=FragDist(I) |
| 871 | 1 | pfleura2 | ! END IF |
| 872 | 1 | pfleura2 | ! END DO |
| 873 | 1 | pfleura2 | ! |
| 874 | 1 | pfleura2 | ! ! we now have the atom that is closer to the first one and that |
| 875 | 1 | pfleura2 | ! ! forms a non 0/Pi dihedral angle |
| 876 | 1 | pfleura2 | ! ! ind_zmat(4,1)=I1 |
| 877 | 1 | pfleura2 | ! ! ind_zmat(4,2)=IAt |
| 878 | 1 | pfleura2 | ! ! ind_zmat(4,3)=ind_zmat(2,1) |
| 879 | 1 | pfleura2 | ! ! ind_zmat(4,4)=ind_zmat(3,1) |
| 880 | 1 | pfleura2 | ! n3=ind_zmat(2,1) |
| 881 | 1 | pfleura2 | ! n4=ind_zmat(3,1) |
| 882 | 1 | pfleura2 | ! Call add2indzmat(na,4,I1,IAt,n3,n4,ind_zmat,x,y,z) |
| 883 | 1 | pfleura2 | ! ind_zmat(2,1)=n3 |
| 884 | 1 | pfleura2 | ! ind_zmat(3,1)=n4 |
| 885 | 1 | pfleura2 | ! DejaFait(I1)=.TRUE. |
| 886 | 1 | pfleura2 | ! CaFaire(3)=I1 |
| 887 | 1 | pfleura2 | ! CaFaire(4)=0 |
| 888 | 1 | pfleura2 | ! IdxCaFaire=4 |
| 889 | 1 | pfleura2 | ! izm=4 |
| 890 | 1 | pfleura2 | ! FCaf(I1)=.TRUE. |
| 891 | 1 | pfleura2 | !!!!!!!!!!! |
| 892 | 1 | pfleura2 | ! |
| 893 | 1 | pfleura2 | ! <- PFL 28 Dec 2007 |
| 894 | 1 | pfleura2 | |
| 895 | 1 | pfleura2 | CaFaire(3)=0 |
| 896 | 1 | pfleura2 | IdxCaFaire=3 |
| 897 | 1 | pfleura2 | |
| 898 | 1 | pfleura2 | CASE(0) |
| 899 | 1 | pfleura2 | WRITE(*,*) 'All atoms are separated .. ' |
| 900 | 1 | pfleura2 | WRITE(*,*) 'this case should be treated separately !' |
| 901 | 1 | pfleura2 | STOP |
| 902 | 1 | pfleura2 | END SELECT |
| 903 | 1 | pfleura2 | |
| 904 | 1 | pfleura2 | if (debug) THEN |
| 905 | 1 | pfleura2 | WRITE(*,*) 'ind_zmat 1 izm=',izm |
| 906 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(1,1) |
| 907 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(2,1), ind_zmat(2,2) |
| 908 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(3,1), ind_zmat(3,2), ind_zmat(3,3) |
| 909 | 1 | pfleura2 | DO I=4,izm |
| 910 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(I,1), ind_zmat(I,2), & |
| 911 | 1 | pfleura2 | ind_zmat(I,3), ind_zmat(I,4) |
| 912 | 1 | pfleura2 | END DO |
| 913 | 1 | pfleura2 | END IF |
| 914 | 1 | pfleura2 | |
| 915 | 1 | pfleura2 | DO I=1,izm |
| 916 | 1 | pfleura2 | Idx_zmat(ind_zmat(I,1))=i |
| 917 | 1 | pfleura2 | END Do |
| 918 | 1 | pfleura2 | |
| 919 | 1 | pfleura2 | ! at least first three atoms of this fragment done... |
| 920 | 1 | pfleura2 | ! we empty the 'cafaire' array before going on |
| 921 | 1 | pfleura2 | IAFaire=1 |
| 922 | 1 | pfleura2 | DO WHILE (CaFaire(IaFaire).NE.0) |
| 923 | 1 | pfleura2 | n1=CaFaire(IaFaire) |
| 924 | 1 | pfleura2 | n2=ind_zmat(idx_zmat(N1),2) |
| 925 | 1 | pfleura2 | if (idx_zmat(N1).EQ.2) THEN |
| 926 | 1 | pfleura2 | ! We have a (small) problem: we have to add atoms linked to the 2nd |
| 927 | 1 | pfleura2 | ! atom of the zmat. This is a pb because we do not know |
| 928 | 1 | pfleura2 | ! which atom to use to define the dihedral angle |
| 929 | 1 | pfleura2 | ! we take the third atom of the zmat |
| 930 | 1 | pfleura2 | n3=ind_zmat(3,1) |
| 931 | 1 | pfleura2 | ELSE |
| 932 | 1 | pfleura2 | n3=ind_zmat(idx_zmat(n1),3) |
| 933 | 1 | pfleura2 | END IF |
| 934 | 1 | pfleura2 | |
| 935 | 1 | pfleura2 | FirstAt=.TRUE. |
| 936 | 1 | pfleura2 | DO I=1,Liaisons(n1,0) |
| 937 | 1 | pfleura2 | IAt=Liaisons(n1,I) |
| 938 | 1 | pfleura2 | ! PFL 29.Aug.2008 -> |
| 939 | 1 | pfleura2 | ! We dissociate the test on 'DejaFait' that indicates that this atom |
| 940 | 1 | pfleura2 | ! has already been put in the Zmat |
| 941 | 1 | pfleura2 | ! from the test on FCaf that indicates that this atom has been put in the |
| 942 | 1 | pfleura2 | ! 'CAFaire' list that deals with identifying its connectivity. |
| 943 | 1 | pfleura2 | ! Those two test might differ in some cases. |
| 944 | 1 | pfleura2 | IF (.NOT.DejaFait(Iat)) THEN |
| 945 | 1 | pfleura2 | izm=izm+1 |
| 946 | 1 | pfleura2 | if (debug) WRITE(*,*) ">1< Adding atom ",Iat,"position izm=",izm |
| 947 | 1 | pfleura2 | ! ind_zmat(izm,1)=iat |
| 948 | 1 | pfleura2 | ! ind_zmat(izm,2)=n1 |
| 949 | 1 | pfleura2 | ! ind_zmat(izm,3)=n2 |
| 950 | 1 | pfleura2 | ! ind_zmat(izm,4)=n3 |
| 951 | 1 | pfleura2 | Call add2indzmat(na,izm,iat,n1,n2,n3,ind_zmat,x,y,z) |
| 952 | 1 | pfleura2 | if (FirstAt) THEN |
| 953 | 1 | pfleura2 | n3=Iat |
| 954 | 1 | pfleura2 | FirstAt=.FALSE. |
| 955 | 1 | pfleura2 | END IF |
| 956 | 1 | pfleura2 | idx_zmat(iat)=izm |
| 957 | 1 | pfleura2 | DejaFait(iat)=.TRUE. |
| 958 | 1 | pfleura2 | END IF |
| 959 | 1 | pfleura2 | IF (.NOT.FCaf(Iat)) THEN |
| 960 | 1 | pfleura2 | CaFaire(IdxCaFaire)=iat |
| 961 | 1 | pfleura2 | IdxCaFaire=IdxCaFaire+1 |
| 962 | 1 | pfleura2 | CaFaire(IdxCaFaire)=0 |
| 963 | 1 | pfleura2 | FCaf(Iat)=.TRUE. |
| 964 | 1 | pfleura2 | END IF |
| 965 | 1 | pfleura2 | ! <- PFL 29.Aug.2008 |
| 966 | 1 | pfleura2 | END DO |
| 967 | 1 | pfleura2 | IaFaire=IaFaire+1 |
| 968 | 1 | pfleura2 | END Do ! DO WHILE CaFaire |
| 969 | 1 | pfleura2 | |
| 970 | 1 | pfleura2 | if (debug) THEN |
| 971 | 1 | pfleura2 | WRITE(*,*) 'ind_zmat 2, izm=',izm |
| 972 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(1,1) |
| 973 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(2,1), ind_zmat(2,2) |
| 974 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(3,1), ind_zmat(3,2), ind_zmat(3,3) |
| 975 | 1 | pfleura2 | DO I=4,izm |
| 976 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(I,1), ind_zmat(I,2), & |
| 977 | 1 | pfleura2 | ind_zmat(I,3), ind_zmat(I,4) |
| 978 | 1 | pfleura2 | END DO |
| 979 | 1 | pfleura2 | END IF |
| 980 | 1 | pfleura2 | |
| 981 | 1 | pfleura2 | ! We have finished putting atoms linked to the first one |
| 982 | 1 | pfleura2 | ! There should not be any atom left from this fragment. We check: |
| 983 | 1 | pfleura2 | ! we will add other atoms of this fragment |
| 984 | 1 | pfleura2 | DO I=1,NbAtFrag(IFrag) |
| 985 | 1 | pfleura2 | Iat=FragAt(IFrag,I) |
| 986 | 1 | pfleura2 | if (debug) WRITE(*,*) "DBG: I,Iat,dejafait",I,Iat,DejaFait(Iat) |
| 987 | 1 | pfleura2 | IF (.NOT.DejaFait(Iat)) THEN |
| 988 | 1 | pfleura2 | WRITE(*,*) 'Treating atom I,Iat',I,Iat |
| 989 | 1 | pfleura2 | |
| 990 | 1 | pfleura2 | END IF |
| 991 | 1 | pfleura2 | |
| 992 | 1 | pfleura2 | END DO |
| 993 | 1 | pfleura2 | |
| 994 | 1 | pfleura2 | NbAtFrag(Ifrag)=0 |
| 995 | 1 | pfleura2 | MaxLFrag(IFrag,1)=0 |
| 996 | 1 | pfleura2 | |
| 997 | 1 | pfleura2 | ! we start again with the rest of the molecule... |
| 998 | 1 | pfleura2 | ! v 1.01 We add the fragment in the order corresponding to NbAtFrag |
| 999 | 1 | pfleura2 | KMax=NbFrag-1 |
| 1000 | 1 | pfleura2 | |
| 1001 | 1 | pfleura2 | IF (DEBUG) WRITE(*,*) "Adding the ",Kmax," remaining fragments" |
| 1002 | 1 | pfleura2 | DO K=1, KMax |
| 1003 | 1 | pfleura2 | IFrag=0 |
| 1004 | 1 | pfleura2 | I0=0 |
| 1005 | 1 | pfleura2 | IAt=0 |
| 1006 | 1 | pfleura2 | I1=0 |
| 1007 | 1 | pfleura2 | DO I=1,NbFrag |
| 1008 | 1 | pfleura2 | SELECT CASE(MaxLFrag(I,1)-I0) |
| 1009 | 1 | pfleura2 | CASE (1:) |
| 1010 | 1 | pfleura2 | IFrag=I |
| 1011 | 1 | pfleura2 | I0=MaxLFrag(I,1) |
| 1012 | 1 | pfleura2 | IAt=MaxLFrag(I,2) |
| 1013 | 1 | pfleura2 | I1=NbAtFrag(I) |
| 1014 | 1 | pfleura2 | CASE (0) |
| 1015 | 1 | pfleura2 | if (NbAtFrag(I).GT.I1) THEN |
| 1016 | 1 | pfleura2 | IFrag=I |
| 1017 | 1 | pfleura2 | I0=MaxLFrag(I,1) |
| 1018 | 1 | pfleura2 | IAt=MaxLFrag(I,2) |
| 1019 | 1 | pfleura2 | I1=NbAtFrag(I) |
| 1020 | 1 | pfleura2 | END IF |
| 1021 | 1 | pfleura2 | END SELECT |
| 1022 | 1 | pfleura2 | |
| 1023 | 1 | pfleura2 | END DO |
| 1024 | 1 | pfleura2 | |
| 1025 | 1 | pfleura2 | if (debug) WRITE(*,'(1X,A,I5,A,I5,A,I5,A,I5)') 'Adding fragment:',IFrag,' with ',I0 & |
| 1026 | 1 | pfleura2 | ,' max links for atom',IAt,' fragment size',NbAtFrag(IFrag) |
| 1027 | 1 | pfleura2 | |
| 1028 | 1 | pfleura2 | MaxLFrag(IFrag,1)=0 |
| 1029 | 1 | pfleura2 | |
| 1030 | 1 | pfleura2 | ! We search for the closest atoms of the previous fragments to the atom with max links |
| 1031 | 1 | pfleura2 | d=1e9 |
| 1032 | 1 | pfleura2 | DO J=1,izm |
| 1033 | 1 | pfleura2 | Call vecteur(iat,ind_zmat(j,1),x,y,z,vx1,vy1,vz1,norm1) |
| 1034 | 1 | pfleura2 | if (norm1.le.d) THEN |
| 1035 | 1 | pfleura2 | Jat=j |
| 1036 | 1 | pfleura2 | d=norm1 |
| 1037 | 1 | pfleura2 | END IF |
| 1038 | 1 | pfleura2 | END DO |
| 1039 | 1 | pfleura2 | n2=ind_zmat(jat,1) |
| 1040 | 1 | pfleura2 | SELECT CASE(jat) |
| 1041 | 1 | pfleura2 | CASE (1) |
| 1042 | 1 | pfleura2 | n3=ind_zmat(2,1) |
| 1043 | 1 | pfleura2 | n4=ind_zmat(3,1) |
| 1044 | 1 | pfleura2 | CASE (2) |
| 1045 | 1 | pfleura2 | n3=ind_zmat(1,1) |
| 1046 | 1 | pfleura2 | n4=ind_zmat(3,1) |
| 1047 | 1 | pfleura2 | CASE DEFAULT |
| 1048 | 1 | pfleura2 | n3=ind_zmat(jAt,2) |
| 1049 | 1 | pfleura2 | n4=ind_zmat(jat,3) |
| 1050 | 1 | pfleura2 | END SELECT |
| 1051 | 1 | pfleura2 | izm=izm+1 |
| 1052 | 1 | pfleura2 | Call add2indzmat(na,izm,iat,n2,n3,n4,ind_zmat,x,y,z) |
| 1053 | 1 | pfleura2 | idx_zmat(iat)=izm |
| 1054 | 1 | pfleura2 | DejaFait(iat)=.TRUE. |
| 1055 | 1 | pfleura2 | IdxCaFaire=2 |
| 1056 | 1 | pfleura2 | CaFaire(1)=iat |
| 1057 | 1 | pfleura2 | CaFaire(2)=0 |
| 1058 | 1 | pfleura2 | FCaf(Iat)=.TRUE. |
| 1059 | 1 | pfleura2 | IaFaire=1 |
| 1060 | 1 | pfleura2 | DO WHILE (CaFaire(IaFaire).NE.0) |
| 1061 | 1 | pfleura2 | n1=CaFaire(IaFaire) |
| 1062 | 1 | pfleura2 | n2=ind_zmat(idx_zmat(N1),2) |
| 1063 | 1 | pfleura2 | if (idx_zmat(N1).EQ.2) THEN |
| 1064 | 1 | pfleura2 | ! We have a (small) problem: we have to add atoms linked to the 2nd |
| 1065 | 1 | pfleura2 | ! atom of the zmat. This is a pb because we do not know |
| 1066 | 1 | pfleura2 | ! which atom to use to define the dihedral angle |
| 1067 | 1 | pfleura2 | ! we take the third atom of the zmat |
| 1068 | 1 | pfleura2 | n3=ind_zmat(3,1) |
| 1069 | 1 | pfleura2 | ELSE |
| 1070 | 1 | pfleura2 | n3=ind_zmat(idx_zmat(n1),3) |
| 1071 | 1 | pfleura2 | END IF |
| 1072 | 1 | pfleura2 | DO I3=1,Liaisons(n1,0) |
| 1073 | 1 | pfleura2 | IAt=Liaisons(n1,I3) |
| 1074 | 1 | pfleura2 | ! PFL 29.Aug.2008 -> |
| 1075 | 1 | pfleura2 | ! We dissociate the test on 'DejaFait' that indicates that this atom |
| 1076 | 1 | pfleura2 | ! has already been put in the Zmat |
| 1077 | 1 | pfleura2 | ! from the test on FCaf that indicates that this atom has been put in the |
| 1078 | 1 | pfleura2 | ! 'CAFaire' list that deals with identifying its connectivity. |
| 1079 | 1 | pfleura2 | ! Those two test might differ for a frozen atom linked to non frozen atoms. |
| 1080 | 1 | pfleura2 | IF (.NOT.DejaFait(Iat)) THEN |
| 1081 | 1 | pfleura2 | izm=izm+1 |
| 1082 | 1 | pfleura2 | Call add2indzmat(na,izm,Iat,n1,n2,n3,ind_zmat,x,y,z) |
| 1083 | 1 | pfleura2 | idx_zmat(iat)=izm |
| 1084 | 1 | pfleura2 | n3=iat |
| 1085 | 1 | pfleura2 | DejaFait(Iat)=.TRUE. |
| 1086 | 1 | pfleura2 | END IF |
| 1087 | 1 | pfleura2 | IF (.NOT.FCaf(Iat)) THEN |
| 1088 | 1 | pfleura2 | CaFaire(IdxCaFaire)=iat |
| 1089 | 1 | pfleura2 | IdxCaFaire=IdxCaFaire+1 |
| 1090 | 1 | pfleura2 | CaFaire(IdxCaFaire)=0 |
| 1091 | 1 | pfleura2 | FCaf(Iat)=.TRUE. |
| 1092 | 1 | pfleura2 | END IF |
| 1093 | 1 | pfleura2 | ! <- PFL 29.Aug.2008 |
| 1094 | 1 | pfleura2 | END DO |
| 1095 | 1 | pfleura2 | IaFaire=IaFaire+1 |
| 1096 | 1 | pfleura2 | END Do ! DO WHILE CaFaire |
| 1097 | 1 | pfleura2 | |
| 1098 | 1 | pfleura2 | if (debug) THEN |
| 1099 | 1 | pfleura2 | WRITE(*,*) 'ind_zmat 4' |
| 1100 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(1,1) |
| 1101 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(2,1), ind_zmat(2,2) |
| 1102 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(3,1), ind_zmat(3,2), ind_zmat(3,3) |
| 1103 | 1 | pfleura2 | DO Ip=4,izm |
| 1104 | 1 | pfleura2 | WRITE(*,'(1X,4(1X,I5))') ind_zmat(Ip,1), ind_zmat(Ip,2), & |
| 1105 | 1 | pfleura2 | ind_zmat(Ip,3), ind_zmat(Ip,4) |
| 1106 | 1 | pfleura2 | END DO |
| 1107 | 1 | pfleura2 | END IF |
| 1108 | 1 | pfleura2 | |
| 1109 | 1 | pfleura2 | END DO ! Loop on all fragments |
| 1110 | 1 | pfleura2 | |
| 1111 | 1 | pfleura2 | |
| 1112 | 1 | pfleura2 | ! We have ind_zmat. We calculate val_zmat :-) |
| 1113 | 1 | pfleura2 | if (debug) WRITE(*,*) "Calculating val_zmat" |
| 1114 | 1 | pfleura2 | |
| 1115 | 1 | pfleura2 | val_zmat(1,1)=0.d0 |
| 1116 | 1 | pfleura2 | val_zmat(1,2)=0.d0 |
| 1117 | 1 | pfleura2 | val_zmat(1,3)=0.d0 |
| 1118 | 1 | pfleura2 | val_zmat(2,2)=0.d0 |
| 1119 | 1 | pfleura2 | val_zmat(2,3)=0.d0 |
| 1120 | 1 | pfleura2 | val_zmat(3,3)=0.d0 |
| 1121 | 1 | pfleura2 | |
| 1122 | 1 | pfleura2 | n1=ind_zmat(2,1) |
| 1123 | 1 | pfleura2 | n2=ind_zmat(2,2) |
| 1124 | 1 | pfleura2 | |
| 1125 | 1 | pfleura2 | CALL vecteur(n2,n1,x,y,z,vx1,vy1,vz1,norm1) |
| 1126 | 1 | pfleura2 | |
| 1127 | 1 | pfleura2 | val_zmat(2,1)=norm1 |
| 1128 | 1 | pfleura2 | |
| 1129 | 1 | pfleura2 | |
| 1130 | 1 | pfleura2 | n1=ind_zmat(3,1) |
| 1131 | 1 | pfleura2 | n2=ind_zmat(3,2) |
| 1132 | 1 | pfleura2 | n3=ind_zmat(3,3) |
| 1133 | 1 | pfleura2 | |
| 1134 | 1 | pfleura2 | CALL vecteur(n2,n1,x,y,z,vx1,vy1,vz1,norm1) |
| 1135 | 1 | pfleura2 | |
| 1136 | 1 | pfleura2 | val_zmat(3,1)=norm1 |
| 1137 | 1 | pfleura2 | |
| 1138 | 1 | pfleura2 | CALL vecteur(n2,n3,x,y,z,vx2,vy2,vz2,norm2) |
| 1139 | 1 | pfleura2 | val=angle(vx1,vy1,vz1,norm1,vx2,vy2,vz2,norm2) |
| 1140 | 1 | pfleura2 | |
| 1141 | 1 | pfleura2 | val_zmat(3,2)=val |
| 1142 | 1 | pfleura2 | |
| 1143 | 1 | pfleura2 | DO i=4,na |
| 1144 | 1 | pfleura2 | |
| 1145 | 1 | pfleura2 | n1=ind_zmat(i,1) |
| 1146 | 1 | pfleura2 | n2=ind_zmat(i,2) |
| 1147 | 1 | pfleura2 | n3=ind_zmat(i,3) |
| 1148 | 1 | pfleura2 | n4=ind_zmat(i,4) |
| 1149 | 1 | pfleura2 | |
| 1150 | 1 | pfleura2 | if (debug) WRITE(*,*) "Doing i,n1,n2,n3,n4",i,n1,n2,n3,n4 |
| 1151 | 1 | pfleura2 | CALL vecteur(n2,n1,x,y,z,vx1,vy1,vz1,norm1) |
| 1152 | 1 | pfleura2 | |
| 1153 | 1 | pfleura2 | CALL vecteur(n2,n3,x,y,z,vx2,vy2,vz2,norm2) |
| 1154 | 1 | pfleura2 | val=angle(vx1,vy1,vz1,norm1,vx2,vy2,vz2,norm2) |
| 1155 | 1 | pfleura2 | |
| 1156 | 1 | pfleura2 | CALL vecteur(n3,n4,x,y,z,vx3,vy3,vz3,norm3) |
| 1157 | 2 | pfleura2 | CALL produit_vect(vx1,vy1,vz1,vx2,vy2,vz2,vx4,vy4,vz4,norm4) |
| 1158 | 2 | pfleura2 | CALL produit_vect(vx3,vy3,vz3,vx2,vy2,vz2,vx5,vy5,vz5,norm5) |
| 1159 | 1 | pfleura2 | |
| 1160 | 1 | pfleura2 | val_d=angle_d(vx4,vy4,vz4,norm4, vx5,vy5,vz5,norm5, & |
| 1161 | 1 | pfleura2 | vx2,vy2,vz2,norm2) |
| 1162 | 1 | pfleura2 | |
| 1163 | 1 | pfleura2 | ! write(*,11) n1,n2,norm1,n3,val,n4,val_d |
| 1164 | 1 | pfleura2 | !11 format (2(1x,i3),1x,f8.4,2(1x,i3,1x,f8.3)) |
| 1165 | 1 | pfleura2 | |
| 1166 | 1 | pfleura2 | val_zmat(i,1)=norm1 |
| 1167 | 1 | pfleura2 | val_zmat(i,2)=val |
| 1168 | 1 | pfleura2 | val_zmat(i,3)=val_d |
| 1169 | 1 | pfleura2 | |
| 1170 | 1 | pfleura2 | END DO |
| 1171 | 1 | pfleura2 | |
| 1172 | 1 | pfleura2 | if (debug) THEN |
| 1173 | 1 | pfleura2 | WRITE(*,*) 'DBG Cre_Zmat_Frag: ind_zmat' |
| 1174 | 1 | pfleura2 | DO I=1,na |
| 1175 | 1 | pfleura2 | WRITE(*,'(1X,5I5)') (ind_zmat(i,j),j=1,5) |
| 1176 | 1 | pfleura2 | END DO |
| 1177 | 1 | pfleura2 | |
| 1178 | 1 | pfleura2 | WRITE(*,*) 'DBG Cre_Zmat_Frag: Full zmat' |
| 1179 | 1 | pfleura2 | DO I=1,na |
| 1180 | 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) |
| 1181 | 1 | pfleura2 | END DO |
| 1182 | 1 | pfleura2 | |
| 1183 | 1 | pfleura2 | END IF |
| 1184 | 1 | pfleura2 | |
| 1185 | 1 | pfleura2 | if (debugGaussian) THEN |
| 1186 | 1 | pfleura2 | WRITE(*,*) 'DBG Cre_Zmat_Frag: Gaussian Zmat - START' |
| 1187 | 1 | pfleura2 | Call zmat_g92(na,atome,ind_zmat,val_zmat) |
| 1188 | 1 | pfleura2 | WRITE(*,*) 'DBG Cre_Zmat_Frag: Gaussian Zmat - END' |
| 1189 | 1 | pfleura2 | END IF |
| 1190 | 1 | pfleura2 | |
| 1191 | 1 | pfleura2 | |
| 1192 | 1 | pfleura2 | if (debug) WRITE(*,*) "Deallocate (FragDist,Fragment, NbAtFrag,FragAt)" |
| 1193 | 1 | pfleura2 | DEALLOCATE(FragDist,Fragment, NbAtFrag,FragAt) |
| 1194 | 1 | pfleura2 | if (debug) WRITE(*,*) "Deallocate (DistFrag,Liaisons)" |
| 1195 | 1 | pfleura2 | DEALLOCATE(DistFrag,Liaisons) |
| 1196 | 1 | pfleura2 | if (debug) WRITE(*,*) "Deallocate(CaFaire,DejaFait)" |
| 1197 | 1 | pfleura2 | DEALLOCATE(CaFaire,DejaFait,FCaf,MaxLFrag) |
| 1198 | 1 | pfleura2 | |
| 1199 | 1 | pfleura2 | |
| 1200 | 1 | pfleura2 | |
| 1201 | 1 | pfleura2 | if (debug) WRITE(*,*) "=============================== Exiting Calc_zmat_frag ========================" |
| 1202 | 1 | pfleura2 | |
| 1203 | 1 | pfleura2 | END SUBROUTINE Calc_Zmat_frag |
| 1204 | 1 | pfleura2 | |
| 1205 | 1 | pfleura2 | SUBROUTINE zmat_g92(na,atome,ind_zmat,val_zmat) |
| 1206 | 1 | pfleura2 | |
| 1207 | 1 | pfleura2 | ! This subroutine comes for Cart. Slightly modified to be f90 |
| 1208 | 1 | pfleura2 | |
| 1209 | 1 | pfleura2 | Use Path_module, only : max_Z, NMaxL, Nom,MaxFroz, Pi |
| 1210 | 1 | pfleura2 | Use Io_module |
| 1211 | 1 | pfleura2 | |
| 1212 | 1 | pfleura2 | IMPLICIT NONE |
| 1213 | 1 | pfleura2 | |
| 1214 | 1 | pfleura2 | integer(KINT), INTENT(IN) :: na,atome(na) |
| 1215 | 1 | pfleura2 | INTEGER(KINT), INTENT(IN) :: ind_zmat(Na,5) |
| 1216 | 1 | pfleura2 | real(KREAL), INTENT(IN) :: val_zmat(Na,3) |
| 1217 | 1 | pfleura2 | |
| 1218 | 2 | pfleura2 | character(6) :: at1, at2, at3, at4, d, a, dh |
| 1219 | 1 | pfleura2 | character(SCHARS), ALLOCATABLE :: tab(:) ! 3*na |
| 1220 | 1 | pfleura2 | character(LCHARS) :: ligne |
| 1221 | 1 | pfleura2 | |
| 1222 | 1 | pfleura2 | INTEGER(KINT) :: i,n1,n2,n3,n4 |
| 1223 | 1 | pfleura2 | |
| 1224 | 1 | pfleura2 | ALLOCATE(tab(3*na)) |
| 1225 | 1 | pfleura2 | |
| 1226 | 1 | pfleura2 | DO i=1,na |
| 1227 | 1 | pfleura2 | IF (i .GE. 1) THEN |
| 1228 | 1 | pfleura2 | n1=ind_zmat(i,1) |
| 1229 | 1 | pfleura2 | write(at1,11) nom(atome(n1)),n1 |
| 1230 | 1 | pfleura2 | 11 format(a2,i3) |
| 1231 | 1 | pfleura2 | Call ecris_sb(at1,at1) |
| 1232 | 1 | pfleura2 | write(ligne,4) at1 |
| 1233 | 1 | pfleura2 | END IF |
| 1234 | 1 | pfleura2 | IF (i .GE. 2) THEN |
| 1235 | 1 | pfleura2 | n2=ind_zmat(i,2) |
| 1236 | 1 | pfleura2 | write(at2,11) nom(atome(n2)),n2 |
| 1237 | 1 | pfleura2 | Call ecris_sb(At2,at2) |
| 1238 | 1 | pfleura2 | write(d,11) 'R',i-1 |
| 1239 | 1 | pfleura2 | Call ecris_sb(D,d) |
| 1240 | 1 | pfleura2 | write(ligne,4) at1,at2,d |
| 1241 | 1 | pfleura2 | write(tab(i-1),12) d,val_zmat(i,1) |
| 1242 | 1 | pfleura2 | 12 format(a8,f8.4) |
| 1243 | 1 | pfleura2 | END IF |
| 1244 | 1 | pfleura2 | IF (i .GE. 3) THEN |
| 1245 | 1 | pfleura2 | n3=ind_zmat(i,3) |
| 1246 | 1 | pfleura2 | write(at3,11) nom(atome(n3)),n3 |
| 1247 | 1 | pfleura2 | Call ecris_sb(At3,at3) |
| 1248 | 1 | pfleura2 | write(a,11) 'A',na+i-3 |
| 1249 | 1 | pfleura2 | Call ecris_sb(A,A) |
| 1250 | 1 | pfleura2 | write(ligne,4) at1,at2,d,at3,a |
| 1251 | 1 | pfleura2 | write(tab(na+i-3),13) a,val_zmat(i,2) |
| 1252 | 1 | pfleura2 | 13 format(a8,f8.3) |
| 1253 | 1 | pfleura2 | END IF |
| 1254 | 1 | pfleura2 | IF (i .GE. 4) THEN |
| 1255 | 1 | pfleura2 | n4=ind_zmat(i,4) |
| 1256 | 1 | pfleura2 | write(at4,11) nom(atome(n4)),n4 |
| 1257 | 1 | pfleura2 | Call ecris_sb(At4,at4) |
| 1258 | 1 | pfleura2 | write(dh,11) 'DH',na+na+i-6 |
| 1259 | 1 | pfleura2 | Call ecris_sb(dh,dh) |
| 1260 | 1 | pfleura2 | write(ligne,4) at1,at2,d,at3,a,at4,dh |
| 1261 | 1 | pfleura2 | 4 format(7a6) |
| 1262 | 1 | pfleura2 | write(tab(na+na+i-6),13) dh,val_zmat(i,3) |
| 1263 | 1 | pfleura2 | END IF |
| 1264 | 1 | pfleura2 | write(IOOUT,*) TRIM(ligne) |
| 1265 | 1 | pfleura2 | END DO |
| 1266 | 1 | pfleura2 | |
| 1267 | 1 | pfleura2 | write(IOOUT,*) |
| 1268 | 1 | pfleura2 | IF (na .EQ. 2) THEN |
| 1269 | 1 | pfleura2 | write(IOOUT,*) TRIM(tab(1)) |
| 1270 | 1 | pfleura2 | ELSE |
| 1271 | 1 | pfleura2 | DO i=1,3*na-6 |
| 1272 | 1 | pfleura2 | write(IOOUT,*) TRIM(tab(i)) |
| 1273 | 1 | pfleura2 | END DO |
| 1274 | 1 | pfleura2 | END IF |
| 1275 | 1 | pfleura2 | write(IOOUT,*) |
| 1276 | 1 | pfleura2 | |
| 1277 | 1 | pfleura2 | DEALLOCATE(Tab) |
| 1278 | 1 | pfleura2 | |
| 1279 | 1 | pfleura2 | END SUBROUTINE zmat_g92 |
| 1280 | 1 | pfleura2 | |
| 1281 | 1 | pfleura2 | SUBROUTINE ecris_sb(inter1,inter) |
| 1282 | 1 | pfleura2 | |
| 1283 | 1 | pfleura2 | character(6) :: inter,inter1 |
| 1284 | 1 | pfleura2 | |
| 1285 | 1 | pfleura2 | |
| 1286 | 1 | pfleura2 | k=1 |
| 1287 | 1 | pfleura2 | DO j=1,len(inter) |
| 1288 | 1 | pfleura2 | IF (inter(j:j) .NE. ' ' ) THEN |
| 1289 | 1 | pfleura2 | inter1(k:k)=inter(j:j) |
| 1290 | 1 | pfleura2 | k=k+1 |
| 1291 | 1 | pfleura2 | END IF |
| 1292 | 1 | pfleura2 | END DO |
| 1293 | 1 | pfleura2 | |
| 1294 | 1 | pfleura2 | inter1(k:6)=' ' |
| 1295 | 1 | pfleura2 | |
| 1296 | 1 | pfleura2 | END SUBROUTINE ecris_sb |