The Elk Code
genpmat.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2015 J. K. Dewhurst, S. Sharma and E. K. U. Gross.
3 ! This file is distributed under the terms of the GNU General Public License.
4 ! See the file COPYING for license details.
5 
6 subroutine genpmat
7 use modmain
8 use modmpi
9 use modomp
10 implicit none
11 ! local variables
12 integer ik,nthd
13 ! allocatable arrays
14 complex(8), allocatable :: pmat(:,:,:)
15 if (mp_mpi) write(*,*)
16 ! synchronise MPI processes
17 call mpi_barrier(mpicom,ierror)
18 call holdthd(nkpt/np_mpi,nthd)
19 !$OMP PARALLEL DEFAULT(SHARED) &
20 !$OMP PRIVATE(pmat) &
21 !$OMP NUM_THREADS(nthd)
22 allocate(pmat(nstsv,nstsv,3))
23 !$OMP DO SCHEDULE(DYNAMIC)
24 do ik=1,nkpt
25 ! distribute among MPI processes
26  if (mod(ik-1,np_mpi) /= lp_mpi) cycle
27 !$OMP CRITICAL(genpmat_)
28  write(*,'("Info(genpmat): ",I0," of ",I0," k-points")') ik,nkpt
29 !$OMP END CRITICAL(genpmat_)
30 ! generate the momentum matrix elements for k-point ik
31  call genpmatk(ik,pmat)
32 ! write the matrix elements to file
33  call putpmat(ik,pmat)
34 end do
35 !$OMP END DO
36 deallocate(pmat)
37 !$OMP END PARALLEL
38 call freethd(nthd)
39 ! synchronise MPI processes
40 call mpi_barrier(mpicom,ierror)
41 end subroutine
42 
logical mp_mpi
Definition: modmpi.f90:17
integer nkpt
Definition: modmain.f90:464
Definition: modomp.f90:6
integer np_mpi
Definition: modmpi.f90:13
integer nstsv
Definition: modmain.f90:885
Definition: modmpi.f90:6
subroutine genpmat
Definition: genpmat.f90:7
integer lp_mpi
Definition: modmpi.f90:15
subroutine freethd(nthd)
Definition: modomp.f90:112
subroutine holdthd(nloop, nthd)
Definition: modomp.f90:78
subroutine genpmatk(ik, pmat)
Definition: genpmatk.f90:7
subroutine putpmat(ik, pmat)
Definition: putpmat.f90:7
integer mpicom
Definition: modmpi.f90:11
integer ierror
Definition: modmpi.f90:19