Commit c7cb86b1 authored by Uliana Alekseeva's avatar Uliana Alekseeva

OpenMP parallelization that also works with theIntel 18 compiler.

parent 510cc289
...@@ -43,6 +43,7 @@ CONTAINS ...@@ -43,6 +43,7 @@ CONTAINS
! .. ! ..
! .. Local Arrays .. ! .. Local Arrays ..
COMPLEX vtl(0:sphhar%nlhd,atoms%ntype) COMPLEX vtl(0:sphhar%nlhd,atoms%ntype)
!$ COMPLEX vtl_loc(0:sphhar%nlhd,atoms%ntype)
COMPLEX pylm( (atoms%lmaxd+1)**2 ,atoms%ntype ) COMPLEX pylm( (atoms%lmaxd+1)**2 ,atoms%ntype )
REAL f1r(atoms%jmtd),f2r(atoms%jmtd),x1r(atoms%jmtd),x2r(atoms%jmtd) REAL f1r(atoms%jmtd),f2r(atoms%jmtd),x1r(atoms%jmtd),x2r(atoms%jmtd)
REAL sbf(0:atoms%lmaxd),rrl(atoms%jmtd),rrl1(atoms%jmtd) REAL sbf(0:atoms%lmaxd),rrl(atoms%jmtd),rrl1(atoms%jmtd)
...@@ -54,6 +55,7 @@ CONTAINS ...@@ -54,6 +55,7 @@ CONTAINS
! .. External Subroutines ! .. External Subroutines
EXTERNAL MPI_REDUCE EXTERNAL MPI_REDUCE
#endif #endif
integer :: OMP_GET_NUM_THREADS, OMP_GET_THREAD_NUM
! .. ! ..
! .. ! ..
! ----> calculate lattice harmonics expansion coefficients of the ! ----> calculate lattice harmonics expansion coefficients of the
...@@ -78,10 +80,12 @@ CONTAINS ...@@ -78,10 +80,12 @@ CONTAINS
ENDDO ENDDO
ENDIF ENDIF
! ----> g.ne.0 components ! ----> g.ne.0 components
! I commented out the OMP parallelization for the following loop since !$OMP PARALLEL DEFAULT(NONE) &
! it produced wrong results with the ifort 18 compiler. !$OMP& SHARED(mpi,stars,vpw,oneD,atoms,sym,cell,sphhar,vtl) &
!!$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(cp,pylm,nat,n,sbf,nd,lh,& !$OMP& PRIVATE(k,cp,pylm,nat,n,sbf,nd,lh,sm,jm,m,lm,l)&
!!$OMP& sm,jm,m,lm,l) REDUCTION(+:vtl) !$OMP& PRIVATE(vtl_loc)
!$ vtl_loc(:,:) = CMPLX(0.d0,0.d0)
!$OMP DO
DO k = mpi%irank+2, stars%ng3, mpi%isize DO k = mpi%irank+2, stars%ng3, mpi%isize
cp = vpw(k,1)*stars%nstr(k) cp = vpw(k,1)*stars%nstr(k)
IF (.NOT.oneD%odi%d1) THEN IF (.NOT.oneD%odi%d1) THEN
...@@ -91,13 +95,13 @@ CONTAINS ...@@ -91,13 +95,13 @@ CONTAINS
& pylm) & pylm)
ELSE ELSE
!-odim !-odim
CALL od_phasy(& CALL od_phasy(&
& atoms%ntype,stars%ng3,atoms%nat,atoms%lmaxd,atoms%ntype,atoms%neq,atoms%lmax,& & atoms%ntype,stars%ng3,atoms%nat,atoms%lmaxd,atoms%ntype,atoms%neq,atoms%lmax,&
& atoms%taual,cell%bmat,stars%kv3,k,oneD%odi,oneD%ods,& & atoms%taual,cell%bmat,stars%kv3,k,oneD%odi,oneD%ods,&
& pylm) & pylm)
!+odim !+odim
END IF END IF
!
nat = 1 nat = 1
DO n = 1,atoms%ntype DO n = 1,atoms%ntype
CALL sphbes(atoms%lmax(n),stars%sk3(k)*atoms%rmt(n),sbf) CALL sphbes(atoms%lmax(n),stars%sk3(k)*atoms%rmt(n),sbf)
...@@ -110,12 +114,20 @@ CALL od_phasy(& ...@@ -110,12 +114,20 @@ CALL od_phasy(&
lm = l*(l+1) + m + 1 lm = l*(l+1) + m + 1
sm = sm + CONJG(sphhar%clnu(jm,lh,nd))*pylm(lm,n) sm = sm + CONJG(sphhar%clnu(jm,lh,nd))*pylm(lm,n)
ENDDO ENDDO
!$ IF (.false.) THEN
vtl(lh,n) = vtl(lh,n) + cp*sbf(l)*sm vtl(lh,n) = vtl(lh,n) + cp*sbf(l)*sm
!$ ENDIF
vtl_loc(lh,n) = vtl_loc(lh,n) + cp*sbf(l)*sm
ENDDO ENDDO
nat = nat + atoms%neq(n) nat = nat + atoms%neq(n)
ENDDO ENDDO
ENDDO ENDDO
!!$OMP END PARALLEL DO !$OMP END DO
!$OMP CRITICAL
!$ vtl = vtl + vtl_loc
!$OMP END CRITICAL
!$OMP END PARALLEL
#ifdef CPP_MPI #ifdef CPP_MPI
n1 = (sphhar%nlhd+1)*atoms%ntype n1 = (sphhar%nlhd+1)*atoms%ntype
ALLOCATE(c_b(n1)) ALLOCATE(c_b(n1))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment