120 integer function init_vac(vac,style,n_bnd,prim_X,n_ang,jq)
result(ierr)
128 character(*),
parameter :: rout_name =
'init_vac'
131 class(
vac_type),
intent(inout) :: vac
132 integer,
intent(in) :: style
133 integer,
intent(in) :: n_bnd
134 integer,
intent(in) ::
prim_x
135 integer,
intent(in) :: n_ang(2)
136 real(
dp),
intent(in) :: jq
139 character(len=max_str_ln) :: err_msg
142 integer,
allocatable :: proc_map(:,:)
153 if (product(n_ang).ne.n_bnd)
then
155 err_msg =
'The total number of angles along B, '//&
156 &trim(
i2str(product(n_ang)))//
', is not equal to n_bnd = '//&
163 if (
n_procs.eq.1) vac%bs = n_bnd
170 vac%n_p(1)=floor(sqrt(
n_procs*1._dp))
172 allocate(proc_map(vac%n_p(1),vac%n_p(2)))
173 proc_map = transpose(reshape(&
174 &[(jd+
n_procs-1-product(vac%n_p),jd=1,product(vac%n_p))],vac%n_p))
175 call blacs_get(0,0,vac%ctxt_HG)
176 call blacs_gridmap(vac%ctxt_HG,proc_map,vac%n_p(1),vac%n_p(1),&
178 call blacs_gridinfo(vac%ctxt_HG,vac%n_p(1),vac%n_p(2),vac%ind_p(1),&
180 if(minval(vac%ind_p).ge.0)
then
182 vac%n_loc(jd) = numroc(vac%n_bnd,vac%bs,vac%ind_p(jd),0,&
185 call descinit(vac%desc_H,n_bnd,n_bnd,vac%bs,vac%bs,0,0,vac%ctxt_HG,&
186 &max(1,vac%n_loc(1)),ierr)
187 chckerr(
'descinit failed')
188 call descinit(vac%desc_G,n_bnd,n_bnd,vac%bs,vac%bs,0,0,vac%ctxt_HG,&
189 &max(1,vac%n_loc(1)),ierr)
190 chckerr(
'descinit failed')
191 call mpi_comm_split(mpi_comm_world,1,
rank,vac%MPI_Comm,ierr)
195 call mpi_comm_split(mpi_comm_world,mpi_undefined,
rank,&
201 call set_loc_lims(vac%n_loc(1),vac%bs,vac%ind_p(1),vac%n_p(1),&
203 call set_loc_lims(vac%n_loc(2),vac%bs,vac%ind_p(2),vac%n_p(2),&
208 select case (vac%style)
215 err_msg =
'No vacuum style '//trim(
i2str(vac%style))//&
221 allocate(vac%norm(vac%n_bnd,n_dims))
222 allocate(vac%x_vec(vac%n_bnd,n_dims))
225 select case (vac%style)
227 allocate(vac%h_fac(vac%n_bnd,4))
229 allocate(vac%ang(n_ang(1),n_ang(2)))
230 allocate(vac%dnorm(vac%n_bnd,n_dims))
237 allocate(vac%G(vac%n_loc(1),vac%n_loc(2)))
238 allocate(vac%H(vac%n_loc(1),vac%n_loc(2)))
245 &vac%estim_mem_usage +
size(vac%G) +
n_mod_x**2
252 &
' - Expected memory usage of vac: '//&
262 integer,
intent(in) :: n_loc
263 integer,
intent(in) :: bs
264 integer,
intent(in) :: ind_p
265 integer,
intent(in) :: n_p
266 integer,
intent(inout),
allocatable :: lims(:,:)
273 allocate(lims(2,ceiling(n_loc*1._dp/bs)))
274 do jd = 1,
size(lims,2)
275 lims(1,jd) = indxl2g((jd-1)*bs+1,bs,ind_p,0,n_p)
276 lims(2,jd) = indxl2g(min(jd*bs,n_loc),bs,ind_p,0,n_p)
subroutine, public writo(input_str, persistent, error, warning, alert)
Write output to file identified by output_i.