root / src / Expand.f90 @ 3
Historique | Voir | Annoter | Télécharger (1,14 ko)
| 1 | 1 | pfleura2 | SUBROUTINE Expand(List,Idx,Dim) |
|---|---|---|---|
| 2 | 1 | pfleura2 | |
| 3 | 1 | pfleura2 | ! This subroutine expands a list entered in a compacted form |
| 4 | 1 | pfleura2 | ! ie 1 -10 => 1 2 3 4 5 6 7 8 9 10 |
| 5 | 1 | pfleura2 | |
| 6 | 1 | pfleura2 | use VarTypes |
| 7 | 1 | pfleura2 | |
| 8 | 1 | pfleura2 | INTEGER(KINT), INTENT(IN) :: Dim |
| 9 | 1 | pfleura2 | INTEGER(KINT), INTENT(INOUT) :: List(Dim) |
| 10 | 1 | pfleura2 | INTEGER(KINT), INTENT(INOUT) :: Idx |
| 11 | 1 | pfleura2 | |
| 12 | 1 | pfleura2 | LOGICAL, ALLOCATABLE :: FTmp(:) ! Dim |
| 13 | 1 | pfleura2 | LOGICAL :: Debug |
| 14 | 1 | pfleura2 | INTEGER(KINT) :: i |
| 15 | 1 | pfleura2 | |
| 16 | 1 | pfleura2 | INTERFACE |
| 17 | 1 | pfleura2 | function valid(string) result (isValid) |
| 18 | 1 | pfleura2 | CHARACTER(*), intent(in) :: string |
| 19 | 1 | pfleura2 | logical :: isValid |
| 20 | 1 | pfleura2 | END function VALID |
| 21 | 1 | pfleura2 | |
| 22 | 1 | pfleura2 | END INTERFACE |
| 23 | 1 | pfleura2 | |
| 24 | 1 | pfleura2 | Debug=valid('Expand')
|
| 25 | 1 | pfleura2 | |
| 26 | 1 | pfleura2 | Allocate(FTmp(Dim)) |
| 27 | 1 | pfleura2 | FTmp=.FALSE. |
| 28 | 1 | pfleura2 | |
| 29 | 1 | pfleura2 | Idx=1 |
| 30 | 1 | pfleura2 | |
| 31 | 1 | pfleura2 | DO WHILE (List(Idx).NE.0) |
| 32 | 1 | pfleura2 | If (List(Idx).LT.0) THEN |
| 33 | 1 | pfleura2 | DO I=List(Idx-1),abs(List(Idx)) |
| 34 | 1 | pfleura2 | IF (.NOT.FTmp(I)) THEN |
| 35 | 1 | pfleura2 | FTmp(I)=.TRUE. |
| 36 | 1 | pfleura2 | END IF |
| 37 | 1 | pfleura2 | END DO |
| 38 | 1 | pfleura2 | ELSEIF (.NOT.FTmp(List(Idx))) THEN |
| 39 | 1 | pfleura2 | FTmp(List(Idx))=.TRUE. |
| 40 | 1 | pfleura2 | END IF |
| 41 | 1 | pfleura2 | Idx=Idx+1 |
| 42 | 1 | pfleura2 | END DO |
| 43 | 1 | pfleura2 | |
| 44 | 1 | pfleura2 | if (debug) WRITE(*,*) "DBG Expand, List",List |
| 45 | 1 | pfleura2 | |
| 46 | 1 | pfleura2 | ! We convert List into non compacted form |
| 47 | 1 | pfleura2 | Idx=1 |
| 48 | 1 | pfleura2 | DO I=1,Dim |
| 49 | 1 | pfleura2 | If(Ftmp(I)) THEN |
| 50 | 1 | pfleura2 | List(Idx)=I |
| 51 | 1 | pfleura2 | Idx=Idx+1 |
| 52 | 1 | pfleura2 | END IF |
| 53 | 1 | pfleura2 | END DO |
| 54 | 1 | pfleura2 | List(Idx)=0 |
| 55 | 1 | pfleura2 | Idx=Idx-1 |
| 56 | 1 | pfleura2 | |
| 57 | 1 | pfleura2 | DEALLOCATE(Ftmp) |
| 58 | 1 | pfleura2 | |
| 59 | 1 | pfleura2 | END SUBROUTINE Expand |