root / src / Decomp_frag.f90 @ 2
Historique | Voir | Annoter | Télécharger (3,66 ko)
| 1 | 1 | pfleura2 | !This subroutines decomposes a connectivity list into fragments. |
|---|---|---|---|
| 2 | 1 | pfleura2 | SUBROUTINE Decomp_Frag(na,ListConnect,ListAt,nbfrag,Fragment,NbAtFrag,FragAt) |
| 3 | 1 | pfleura2 | |
| 4 | 1 | pfleura2 | Use Path_module, only : NMaxL |
| 5 | 1 | pfleura2 | Use Io_module |
| 6 | 1 | pfleura2 | |
| 7 | 1 | pfleura2 | IMPLICIT NONE |
| 8 | 1 | pfleura2 | |
| 9 | 1 | pfleura2 | INTEGER(KINT), INTENT(IN) :: na |
| 10 | 1 | pfleura2 | INTEGER(KINT), INTENT(IN) :: ListConnect(na,0:NMaxL) |
| 11 | 1 | pfleura2 | LOGICAL, INTENT(IN) :: ListAt(na) |
| 12 | 1 | pfleura2 | INTEGER(KINT), INTENT(OUT) :: NbFrag,Fragment(na),NbAtFrag(na),FragAt(na,na) |
| 13 | 1 | pfleura2 | |
| 14 | 2 | pfleura2 | INTEGER(KINT) :: i, j, iat, jat |
| 15 | 1 | pfleura2 | INTEGER(KINT) :: IdxFrag, IdxtoDo, IFrag,IaFaire |
| 16 | 1 | pfleura2 | INTEGER(KINT), ALLOCATABLE :: ToDo(:) |
| 17 | 1 | pfleura2 | |
| 18 | 1 | pfleura2 | LOGICAL :: Debug |
| 19 | 1 | pfleura2 | |
| 20 | 1 | pfleura2 | INTERFACE |
| 21 | 1 | pfleura2 | function valid(string) result (isValid) |
| 22 | 1 | pfleura2 | CHARACTER(*), intent(in) :: string |
| 23 | 1 | pfleura2 | logical :: isValid |
| 24 | 1 | pfleura2 | END function VALID |
| 25 | 1 | pfleura2 | END INTERFACE |
| 26 | 1 | pfleura2 | |
| 27 | 1 | pfleura2 | |
| 28 | 1 | pfleura2 | debug=valid('decompfrag')
|
| 29 | 1 | pfleura2 | ! We analyse the connectivity in terms of fragments |
| 30 | 1 | pfleura2 | ALLOCATE(ToDo(na)) |
| 31 | 1 | pfleura2 | |
| 32 | 1 | pfleura2 | Fragment=0 |
| 33 | 1 | pfleura2 | ToDo=0 |
| 34 | 1 | pfleura2 | IdxFrag=0 |
| 35 | 1 | pfleura2 | NbFrag=0 |
| 36 | 1 | pfleura2 | NbAtFrag=0 |
| 37 | 1 | pfleura2 | Fragment=0 |
| 38 | 1 | pfleura2 | FragAt=0 |
| 39 | 1 | pfleura2 | |
| 40 | 1 | pfleura2 | DO I=1,na |
| 41 | 1 | pfleura2 | IdxToDo=1 |
| 42 | 1 | pfleura2 | ToDo(IdxToDo)=0 |
| 43 | 1 | pfleura2 | |
| 44 | 1 | pfleura2 | if (debug) WRITE(*,*) 'Treating atom I, fragment(I)',I,Fragment(I) |
| 45 | 1 | pfleura2 | IF (ListAt(I).OR.(ListConnect(I,0).NE.0)) THEN |
| 46 | 1 | pfleura2 | IF (Fragment(I).EQ.0) THEN |
| 47 | 1 | pfleura2 | IdxFrag=IdxFrag+1 |
| 48 | 1 | pfleura2 | NbFrag=NbFrag+1 |
| 49 | 1 | pfleura2 | IFrag=IdxFrag |
| 50 | 1 | pfleura2 | Fragment(I)=IFrag |
| 51 | 1 | pfleura2 | NbAtFrag(IFrag)=NbAtFrag(IFrag)+1 |
| 52 | 1 | pfleura2 | FragAt(IFrag,NbAtFrag(IFrag))=I |
| 53 | 1 | pfleura2 | ELSE |
| 54 | 1 | pfleura2 | IFrag=Fragment(I) |
| 55 | 1 | pfleura2 | END IF |
| 56 | 1 | pfleura2 | DO J=1,ListConnect(I,0) |
| 57 | 1 | pfleura2 | Iat=ListConnect(I,J) |
| 58 | 1 | pfleura2 | IF ((Fragment(Iat).NE.0).AND.(Fragment(Iat).NE.IFrag)) THEN |
| 59 | 1 | pfleura2 | WRITE(*,*) 'Error : Atoms ',I,' and ',Iat |
| 60 | 1 | pfleura2 | WRITE(*,*) 'are linked, but belongs to fragments ',IFrag,' and ',Fragment(Iat) |
| 61 | 1 | pfleura2 | STOP |
| 62 | 1 | pfleura2 | END IF |
| 63 | 1 | pfleura2 | IF (Fragment(Iat).EQ.0) THEN |
| 64 | 1 | pfleura2 | ToDo(IdxToDo)=Iat |
| 65 | 1 | pfleura2 | Fragment(Iat)=IFrag |
| 66 | 1 | pfleura2 | NbAtFrag(IFrag)=NbAtFrag(IFrag)+1 |
| 67 | 1 | pfleura2 | FragAt(IFrag,NbAtFrag(IFrag))=Iat |
| 68 | 1 | pfleura2 | IdxToDo=IdxToDo+1 |
| 69 | 1 | pfleura2 | END IF |
| 70 | 1 | pfleura2 | END DO |
| 71 | 1 | pfleura2 | ToDo(IdxToDo)=0 |
| 72 | 1 | pfleura2 | |
| 73 | 1 | pfleura2 | If (debug) WRITE(*,*) 'ToDo:',ToDo(1:IdxToDo) |
| 74 | 1 | pfleura2 | If (debug) WRITE(*,*) 'IFrag=',IFrag |
| 75 | 1 | pfleura2 | |
| 76 | 1 | pfleura2 | IAfaire=1 |
| 77 | 1 | pfleura2 | |
| 78 | 1 | pfleura2 | DO WHILE (ToDo(IAfaire).NE.0) |
| 79 | 1 | pfleura2 | Iat=ToDo(IaFaire) |
| 80 | 1 | pfleura2 | IF (ListAt(I).OR.(ListConnect(I,0).NE.0)) THEN |
| 81 | 1 | pfleura2 | if (debug) WRITE(*,*) 'ToDo treating ',Iat |
| 82 | 1 | pfleura2 | IF (Fragment(Iat).EQ.0) THEN |
| 83 | 1 | pfleura2 | WRITE(*,*) 'Error: Atom ',Iat,' does not belong to any fragment !' |
| 84 | 1 | pfleura2 | STOP |
| 85 | 1 | pfleura2 | END IF |
| 86 | 1 | pfleura2 | |
| 87 | 1 | pfleura2 | DO J=1,ListConnect(Iat,0) |
| 88 | 1 | pfleura2 | Jat=ListConnect(Iat,J) |
| 89 | 1 | pfleura2 | IF ((Fragment(ListConnect(Iat,J)).NE.0).AND.(Fragment(ListConnect(Iat,J)).NE.IFrag)) THEN |
| 90 | 1 | pfleura2 | WRITE(*,*) 'Error: Atoms ',Iat,' and ',ListConnect(Iat,J) |
| 91 | 1 | pfleura2 | WRITE(*,*) 'are linked, but belongs to fragments ',IFrag,' and ',Fragment(ListConnect(Iat,J)) |
| 92 | 1 | pfleura2 | STOP |
| 93 | 1 | pfleura2 | END IF |
| 94 | 1 | pfleura2 | IF (Fragment(Jat).EQ.0) THEN |
| 95 | 1 | pfleura2 | ToDo(IdxToDo)=ListConnect(Iat,J) |
| 96 | 1 | pfleura2 | Fragment(Jat)=IFrag |
| 97 | 1 | pfleura2 | NbAtFrag(IFrag)=NbAtFrag(IFrag)+1 |
| 98 | 1 | pfleura2 | FragAt(IFrag,NbAtFrag(IFrag))=Jat |
| 99 | 1 | pfleura2 | IdxToDo=IdxToDo+1 |
| 100 | 1 | pfleura2 | END IF |
| 101 | 1 | pfleura2 | END DO |
| 102 | 1 | pfleura2 | ToDo(IdxToDo)=0 |
| 103 | 1 | pfleura2 | If (debug) WRITE(*,*) 'IAfaire, IdxToDo,ToDo :',IAfaire,IdxToDo,' == ',ToDo(IaFaire+1:IdxToDo) |
| 104 | 1 | pfleura2 | IAFaire=IAFaire+1 |
| 105 | 1 | pfleura2 | END IF |
| 106 | 1 | pfleura2 | END DO |
| 107 | 1 | pfleura2 | END IF |
| 108 | 1 | pfleura2 | END DO |
| 109 | 1 | pfleura2 | |
| 110 | 1 | pfleura2 | IF (debug) THEN |
| 111 | 1 | pfleura2 | WRITE(*,*) 'DECOMP_FRAG: I found ',NbFrag, 'fragments' |
| 112 | 1 | pfleura2 | DO I=1,NbFrag |
| 113 | 1 | pfleura2 | WRITE(*,*) 'Fragment ', i,' with ',NbAtFrag(I),' atoms.' |
| 114 | 1 | pfleura2 | WRITE(*,*) "FragAt:",(FragAt(I,j),j=1,NbAtFrag(I)) |
| 115 | 1 | pfleura2 | END DO |
| 116 | 1 | pfleura2 | END IF |
| 117 | 1 | pfleura2 | |
| 118 | 1 | pfleura2 | |
| 119 | 1 | pfleura2 | END SUBROUTINE Decomp_Frag |