root / src / Int2cart.f90
Historique | Voir | Annoter | Télécharger (4,04 ko)
1 | 1 | pfleura2 | SUBROUTINE Int2Cart(Nat,IndZmat,IntCoord,XyzCoord) |
---|---|---|---|
2 | 1 | pfleura2 | |
3 | 12 | pfleura2 | !---------------------------------------------------------------------- |
4 | 12 | pfleura2 | ! Copyright 2003-2014 Ecole Normale Supérieure de Lyon, |
5 | 12 | pfleura2 | ! Centre National de la Recherche Scientifique, |
6 | 12 | pfleura2 | ! Université Claude Bernard Lyon 1. All rights reserved. |
7 | 12 | pfleura2 | ! |
8 | 12 | pfleura2 | ! This work is registered with the Agency for the Protection of Programs |
9 | 12 | pfleura2 | ! as IDDN.FR.001.100009.000.S.P.2014.000.30625 |
10 | 12 | pfleura2 | ! |
11 | 12 | pfleura2 | ! Authors: P. Fleurat-Lessard, P. Dayal |
12 | 12 | pfleura2 | ! Contact: optnpath@gmail.com |
13 | 12 | pfleura2 | ! |
14 | 12 | pfleura2 | ! This file is part of "Opt'n Path". |
15 | 12 | pfleura2 | ! |
16 | 12 | pfleura2 | ! "Opt'n Path" is free software: you can redistribute it and/or modify |
17 | 12 | pfleura2 | ! it under the terms of the GNU Affero General Public License as |
18 | 12 | pfleura2 | ! published by the Free Software Foundation, either version 3 of the License, |
19 | 12 | pfleura2 | ! or (at your option) any later version. |
20 | 12 | pfleura2 | ! |
21 | 12 | pfleura2 | ! "Opt'n Path" is distributed in the hope that it will be useful, |
22 | 12 | pfleura2 | ! but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | 12 | pfleura2 | ! |
24 | 12 | pfleura2 | ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | 12 | pfleura2 | ! GNU Affero General Public License for more details. |
26 | 12 | pfleura2 | ! |
27 | 12 | pfleura2 | ! You should have received a copy of the GNU Affero General Public License |
28 | 12 | pfleura2 | ! along with "Opt'n Path". If not, see <http://www.gnu.org/licenses/>. |
29 | 12 | pfleura2 | ! |
30 | 12 | pfleura2 | ! Contact The Office of Technology Licensing, valorisation@ens-lyon.fr, |
31 | 12 | pfleura2 | ! for commercial licensing opportunities. |
32 | 12 | pfleura2 | !---------------------------------------------------------------------- |
33 | 12 | pfleura2 | |
34 | 1 | pfleura2 | Use Path_module, ONLY : Pi |
35 | 1 | pfleura2 | |
36 | 1 | pfleura2 | IMPLICIT NONE |
37 | 1 | pfleura2 | |
38 | 1 | pfleura2 | INTEGER, PARAMETER :: Kint=Kind(1) |
39 | 1 | pfleura2 | INTEGER, PARAMETER :: KREAL=Kind(1.0D0) |
40 | 1 | pfleura2 | |
41 | 1 | pfleura2 | INTEGER(KINT), INTENT(IN) :: Nat |
42 | 1 | pfleura2 | INTEGER(KINT), INTENT(IN) :: IndZmat(Nat,5) |
43 | 1 | pfleura2 | REAL(KREAL), INTENT(IN) :: IntCoord(3*Nat-6) |
44 | 1 | pfleura2 | REAL(KREAL), INTENT(OUT) :: XyzCoord(Nat,3) |
45 | 1 | pfleura2 | |
46 | 2 | pfleura2 | INTEGER(KINT) :: I |
47 | 1 | pfleura2 | REAl(KREAL), ALLOCATABLE :: ValZmat(:,:),XyzTmp(:,:) |
48 | 1 | pfleura2 | REAL(KREAL) :: d, a_val |
49 | 1 | pfleura2 | LOGICAL :: debug |
50 | 1 | pfleura2 | |
51 | 1 | pfleura2 | INTERFACE |
52 | 1 | pfleura2 | function valid(string) result (isValid) |
53 | 1 | pfleura2 | CHARACTER(*), intent(in) :: string |
54 | 1 | pfleura2 | logical :: isValid |
55 | 1 | pfleura2 | END function VALID |
56 | 1 | pfleura2 | |
57 | 1 | pfleura2 | END INTERFACE |
58 | 1 | pfleura2 | |
59 | 1 | pfleura2 | debug=valid('int2cart') |
60 | 1 | pfleura2 | |
61 | 1 | pfleura2 | if (debug) WRITE(*,*) '================ Entering Int2Cart ===================' |
62 | 1 | pfleura2 | |
63 | 1 | pfleura2 | ALLOCATE(ValZmat(Nat,3),XyzTmp(Nat,3)) |
64 | 1 | pfleura2 | |
65 | 1 | pfleura2 | ValZmat=0.d0 |
66 | 1 | pfleura2 | ValZmat(2,1)=IntCoord(1) |
67 | 1 | pfleura2 | ValZmat(3,1)=IntCoord(2) |
68 | 1 | pfleura2 | ValZmat(3,2)=IntCoord(3)*180./Pi |
69 | 1 | pfleura2 | DO I=4,Nat |
70 | 1 | pfleura2 | ValZmat(I,1)=IntCoord(3*I-8) |
71 | 1 | pfleura2 | ValZmat(I,2)=IntCoord(3*I-7)*180./Pi |
72 | 1 | pfleura2 | ValZmat(I,3)=IntCoord(3*I-6)*180./Pi |
73 | 1 | pfleura2 | END DO |
74 | 1 | pfleura2 | |
75 | 1 | pfleura2 | IF (debug) THEN |
76 | 1 | pfleura2 | WRITE(*,*) 'DBG Int2Cart' |
77 | 1 | pfleura2 | DO I=1,Nat |
78 | 1 | pfleura2 | WRITe(*,'(1X,I3,3(1X,I3,1X,F10.4))') IndZmat(I,1), IndZmat(I,2), ValZmat(I,1), IndZmat(I,3),& |
79 | 1 | pfleura2 | ValZmat(I,2), IndZmat(I,4), Valzmat(I,3) |
80 | 1 | pfleura2 | END DO |
81 | 1 | pfleura2 | END IF |
82 | 1 | pfleura2 | |
83 | 1 | pfleura2 | Xyztmp=0.d0 |
84 | 1 | pfleura2 | Xyztmp(2,1)=valzmat(2,1) |
85 | 1 | pfleura2 | d=valzmat(3,1) |
86 | 1 | pfleura2 | a_val=valzmat(3,2)/180.*Pi |
87 | 1 | pfleura2 | ! write(*,*) "aval,pi",a_val,valzmat(3,2),pi |
88 | 1 | pfleura2 | if (Nat.GE.3) THEN |
89 | 1 | pfleura2 | if (IndZmat(3,2).EQ.1) THEN |
90 | 1 | pfleura2 | Xyztmp(3,1)=Xyztmp(1,1)+d*cos(a_val) |
91 | 1 | pfleura2 | ELSE |
92 | 1 | pfleura2 | Xyztmp(3,1)=Xyztmp(2,1)-d*cos(a_val) |
93 | 1 | pfleura2 | ENDIF |
94 | 1 | pfleura2 | Xyztmp(3,2)=d*sin(a_val) |
95 | 1 | pfleura2 | ENDIF |
96 | 1 | pfleura2 | ! i=1 |
97 | 1 | pfleura2 | ! WRITE(*,*) 'TOTOCart:',i, (Xyztmp(I,J),J=1,3) |
98 | 1 | pfleura2 | ! WRITE(*,*) 'TOTOZma:',i, (valzmat(I,J),J=1,3) |
99 | 1 | pfleura2 | ! i=2 |
100 | 1 | pfleura2 | ! WRITE(*,*) 'TOTOCart:',i, (Xyztmp(I,J),J=1,3) |
101 | 1 | pfleura2 | ! WRITE(*,*) 'TOTOZma:',i, (valzmat(I,J),J=1,3) |
102 | 1 | pfleura2 | ! i=3 |
103 | 1 | pfleura2 | ! WRITE(*,*) 'TOTOCart:',i, (Xyztmp(I,J),J=1,3) |
104 | 1 | pfleura2 | ! WRITE(*,*) 'TOTOZma:',i, (valzmat(I,J),J=1,3) |
105 | 1 | pfleura2 | |
106 | 1 | pfleura2 | DO i=4,Nat |
107 | 1 | pfleura2 | call ConvertZmat_cart(i,IndZmat,valzmat, & |
108 | 1 | pfleura2 | Xyztmp(1,1), Xyztmp(1,2),Xyztmp(1,3)) |
109 | 1 | pfleura2 | ! WRITE(*,*) 'TOTOZma:',i,IndZmat(I,1), & |
110 | 1 | pfleura2 | ! (IndZmat(I,J+1),valzmat(I,J),J=1,3) |
111 | 1 | pfleura2 | ! WRITE(*,*) 'TOTOCart:',i, (Xyztmp(I,J),J=1,3) |
112 | 1 | pfleura2 | END DO |
113 | 1 | pfleura2 | |
114 | 1 | pfleura2 | IF (debug) THEN |
115 | 1 | pfleura2 | WRITE(*,*) 'DBG Int2Cart XyzTmp' |
116 | 1 | pfleura2 | DO I=1,Nat |
117 | 1 | pfleura2 | WRITe(*,'(1X,I3,3(1X,F10.4))') I, XyzTmp(I,1:3) |
118 | 1 | pfleura2 | END DO |
119 | 1 | pfleura2 | END IF |
120 | 1 | pfleura2 | |
121 | 1 | pfleura2 | |
122 | 1 | pfleura2 | ! XyzCoord=Reshape(XyzTmp,(/3,Nat/),ORDER=(/2,1/)) |
123 | 1 | pfleura2 | XyzCoord=XyzTmp |
124 | 1 | pfleura2 | |
125 | 1 | pfleura2 | DEALLOCATE(valzmat,xyztmp) |
126 | 1 | pfleura2 | if (debug) WRITE(*,*) '================ Exiting Int2cart ===================' |
127 | 1 | pfleura2 | |
128 | 1 | pfleura2 | END SUBROUTINE Int2Cart |