root / src / Mixed2cart.f90 @ 3
Historique | Voir | Annoter | Télécharger (2,38 ko)
| 1 | 1 | pfleura2 | SUBROUTINE Mixed2Cart(Nat,IndZmat,IntCoord,XyzCoord) |
|---|---|---|---|
| 2 | 1 | pfleura2 | |
| 3 | 1 | pfleura2 | Use Path_module, ONLY : Pi,NCart,NCoord |
| 4 | 1 | pfleura2 | |
| 5 | 1 | pfleura2 | IMPLICIT NONE |
| 6 | 1 | pfleura2 | |
| 7 | 1 | pfleura2 | INTEGER, PARAMETER :: Kint=Kind(1) |
| 8 | 1 | pfleura2 | INTEGER, PARAMETER :: KREAL=Kind(1.0D0) |
| 9 | 1 | pfleura2 | |
| 10 | 1 | pfleura2 | INTEGER(KINT), INTENT(IN) :: Nat |
| 11 | 1 | pfleura2 | INTEGER(KINT), INTENT(IN) :: IndZmat(Nat,5) |
| 12 | 1 | pfleura2 | REAL(KREAL), INTENT(IN) :: IntCoord(*) |
| 13 | 1 | pfleura2 | REAL(KREAL), INTENT(OUT) :: XyzCoord(Nat,3) |
| 14 | 1 | pfleura2 | |
| 15 | 2 | pfleura2 | INTEGER(KINT) :: I, J, Idx, IBeg, Iat |
| 16 | 1 | pfleura2 | REAl(KREAL), ALLOCATABLE :: ValZmat(:,:),XyzTmp(:,:) |
| 17 | 1 | pfleura2 | REAL(KREAL) :: d, a_val |
| 18 | 1 | pfleura2 | |
| 19 | 1 | pfleura2 | LOGICAL :: Debug |
| 20 | 1 | pfleura2 | |
| 21 | 1 | pfleura2 | INTERFACE |
| 22 | 1 | pfleura2 | function valid(string) result (isValid) |
| 23 | 1 | pfleura2 | CHARACTER(*), intent(in) :: string |
| 24 | 1 | pfleura2 | logical :: isValid |
| 25 | 1 | pfleura2 | END function VALID |
| 26 | 1 | pfleura2 | END INTERFACE |
| 27 | 1 | pfleura2 | |
| 28 | 1 | pfleura2 | debug=valid('mixed2cart')
|
| 29 | 1 | pfleura2 | |
| 30 | 1 | pfleura2 | if (debug) WRITE(*,*) "================ Entering Mixed2Cart ==================" |
| 31 | 1 | pfleura2 | |
| 32 | 1 | pfleura2 | |
| 33 | 1 | pfleura2 | ALLOCATE(ValZmat(Nat,3),XyzTmp(Nat,3)) |
| 34 | 1 | pfleura2 | |
| 35 | 1 | pfleura2 | if (debug) WRITE(*,*) "DBG Mixed2Cart, IntCoord:",IntCoord(1:NCoord) |
| 36 | 1 | pfleura2 | Idx=1 |
| 37 | 1 | pfleura2 | valzmat=0. |
| 38 | 1 | pfleura2 | XyzTmp=0. |
| 39 | 1 | pfleura2 | DO I=1,NCart |
| 40 | 1 | pfleura2 | XYZTmp(I,1:3)=IntCoord(Idx:Idx+2) |
| 41 | 1 | pfleura2 | valzmat(I,1:3)=IntCoord(Idx:Idx+2) |
| 42 | 1 | pfleura2 | Idx=Idx+3 |
| 43 | 1 | pfleura2 | END DO |
| 44 | 1 | pfleura2 | |
| 45 | 1 | pfleura2 | IBeg=NCart+1 |
| 46 | 1 | pfleura2 | SELECT CASE (NCart) |
| 47 | 1 | pfleura2 | CaSE (1) |
| 48 | 1 | pfleura2 | Idx=4 |
| 49 | 1 | pfleura2 | XyzTmp(2,1)=IntCoord(Idx) |
| 50 | 1 | pfleura2 | XyzTmp(2,1:3)= XyzTmp(2,1:3)+ XyzTmp(1,1:3) |
| 51 | 1 | pfleura2 | if (Nat.GE.3) THEN |
| 52 | 1 | pfleura2 | Idx=Idx+1 |
| 53 | 1 | pfleura2 | d=IntCoord(Idx) |
| 54 | 1 | pfleura2 | Idx=Idx+1 |
| 55 | 1 | pfleura2 | a_val=IntCoord(Idx) |
| 56 | 1 | pfleura2 | Idx=Idx+1 |
| 57 | 1 | pfleura2 | call ConvertZmat_cart_3(3,IndZmat,d,a_val, & |
| 58 | 1 | pfleura2 | XyzTmp(1,1), XyzTmp(1,2),XyzTmp(1,3)) |
| 59 | 1 | pfleura2 | ENDIF |
| 60 | 1 | pfleura2 | IBeg=4 |
| 61 | 1 | pfleura2 | CASE (2) |
| 62 | 1 | pfleura2 | Idx=7 |
| 63 | 1 | pfleura2 | if (Nat.GE.3) THEN |
| 64 | 1 | pfleura2 | d=IntCoord(Idx) |
| 65 | 1 | pfleura2 | idx=idx+1 |
| 66 | 1 | pfleura2 | a_val=IntCoord(Idx) |
| 67 | 1 | pfleura2 | Idx=Idx+1 |
| 68 | 1 | pfleura2 | call ConvertZmat_cart_3(3,IndZmat,d,a_val, & |
| 69 | 1 | pfleura2 | XyzTmp(1,1), XyzTmp(1,2),XyzTmp(1,3)) |
| 70 | 1 | pfleura2 | ENDIF |
| 71 | 1 | pfleura2 | IBeg=4 |
| 72 | 1 | pfleura2 | CASE DEFAULT |
| 73 | 1 | pfleura2 | Ibeg=NCart+1 |
| 74 | 1 | pfleura2 | END SELECT |
| 75 | 1 | pfleura2 | |
| 76 | 1 | pfleura2 | DO iat=IBeg,Nat |
| 77 | 1 | pfleura2 | ValZmat(iat,1)=IntCoord(idx) |
| 78 | 1 | pfleura2 | Idx=Idx+1 |
| 79 | 1 | pfleura2 | do j=2,3 |
| 80 | 1 | pfleura2 | ValZmat(iat,J)=IntCoord(idx)*180./Pi |
| 81 | 1 | pfleura2 | Idx=Idx+1 |
| 82 | 1 | pfleura2 | END DO |
| 83 | 1 | pfleura2 | END DO |
| 84 | 1 | pfleura2 | |
| 85 | 1 | pfleura2 | DO iat=iBeg,Nat |
| 86 | 1 | pfleura2 | call ConvertZmat_cart(iat,IndZmat,ValZmat, & |
| 87 | 1 | pfleura2 | XyzTmp(1,1), XyzTmp(1,2),XyzTmp(1,3)) |
| 88 | 1 | pfleura2 | END DO |
| 89 | 1 | pfleura2 | |
| 90 | 1 | pfleura2 | if (debug) THEN |
| 91 | 1 | pfleura2 | WRITE(*,*) 'DBG Mixed2Cart XyzTmp' |
| 92 | 1 | pfleura2 | DO I=1,Nat |
| 93 | 1 | pfleura2 | WRITe(*,'(1X,I3,3(1X,F10.4))') I, XyzTmp(I,1:3) |
| 94 | 1 | pfleura2 | END DO |
| 95 | 1 | pfleura2 | END IF |
| 96 | 1 | pfleura2 | |
| 97 | 1 | pfleura2 | ! XyzCoord=Reshape(XyzTmp,(/3,Nat/),ORDER=(/2,1/)) |
| 98 | 1 | pfleura2 | XyzCoord=XyzTmp |
| 99 | 1 | pfleura2 | |
| 100 | 1 | pfleura2 | DEALLOCATE(valzmat,xyztmp) |
| 101 | 1 | pfleura2 | if (debug) WRITE(*,*) "================ Mixed2Cart Over ==================" |
| 102 | 1 | pfleura2 | |
| 103 | 1 | pfleura2 | END SUBROUTINE Mixed2Cart |