slab_dim.f90 2.16 KB
Newer Older
1 2 3
MODULE m_slabdim
  USE m_juDFT
CONTAINS
4
  SUBROUTINE slab_dim(atoms,nsld)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
    !***********************************************************************
    !     This subroutine calculates  the number of layers in the slab 
    !     
    !                                   Yury Koroteev 2003-09-30
    !***********************************************************************
    !                     ABBREVIATIONS
    !
    ! natd                  : in, the number of atoms in the film
    ! pos(3,natd)         : in, the coordinates of atoms in the film
    ! ntypd,ntype           : in, the number of mt-sphere types
    ! neq(ntypd)            : in, the number of mt-spheres of the same type
    !-----------------------------------------------------------------------
    ! nsld                  : out, the number of layers in the film
    !-----------------------------------------------------------------------
    ! znz(nsl)              : work, the z-ordinate of mt-spheres in 
    !                               the nsl-layer 
    !-----------------------------------------------------------------------
    !
23
    USE m_types_setup
24 25 26 27 28 29 30 31 32 33 34 35 36 37
    IMPLICIT NONE

    TYPE(t_atoms),INTENT(IN)   :: atoms
    !	..
    !       ..Scalar Argument
    INTEGER, INTENT (OUT) :: nsld
    !       ..
    !       ..Array Arguments
    !       ..
    !       ..Local Scalars 
    INTEGER  iz,i,j,na,nz
    REAL    zs
    !       ..
    !       ..Local Arrays 
Daniel Wortmann's avatar
Daniel Wortmann committed
38
    REAL    znz(atoms%nat)
39 40 41 42 43 44 45 46 47 48 49
    !       ..
    !    ----------------------------------------------
    REAL,PARAMETER:: epsz=1.e-3 
    !    ----------------------------------------------
    !
    ! --->  Calculate the number of the film layers (nsld)
    !
    znz(1) = atoms%pos(3,1)
    nz = 1
    na = 0
    DO i=1,atoms%ntype
Daniel Wortmann's avatar
Daniel Wortmann committed
50
       equivAtomsLoop: DO j=1,atoms%neq(i)
51 52 53
          na = na + 1
          zs = atoms%pos(3,na)
          DO iz=1,nz
Daniel Wortmann's avatar
Daniel Wortmann committed
54 55
             IF(ABS(zs-znz(iz)).LT.epsz) CYCLE equivAtomsLoop
          END DO
56 57
          nz = nz+1
          znz(nz) = zs
Daniel Wortmann's avatar
Daniel Wortmann committed
58 59
       END DO equivAtomsLoop
    END DO
60
    nsld = nz
Daniel Wortmann's avatar
Daniel Wortmann committed
61
    IF(nsld>atoms%nat)   CALL juDFT_error("nsld.GT.atoms%nat ",calledby="slab_dim")
62 63 64 65
    !
  END SUBROUTINE slab_dim
END MODULE m_slabdim