subroutine set_B0_grid(igrid)
use mod_global_parameters
integer, intent(in) :: igrid
integer :: ixCoGmin1,ixCoGmin2,ixCoGmin3,ixCoGmax1,ixCoGmax2,ixCoGmax3
ixCoGmin1=1;ixCoGmin2=1;ixCoGmin3=1;
ixCoGmax1=(ixGhi1-2*nghostcells)/2+2*nghostcells
ixCoGmax2=(ixGhi2-2*nghostcells)/2+2*nghostcells
ixCoGmax3=(ixGhi3-2*nghostcells)/2+2*nghostcells;
call set_B0_cell(ps(igrid)%B0(ixGlo1:ixGhi1,ixGlo2:ixGhi2,ixGlo3:ixGhi3,:,&
0),ps(igrid)%x,ixGlo1,ixGlo2,ixGlo3,ixGhi1,ixGhi2,ixGhi3,ixGlo1,ixGlo2,&
ixGlo3,ixGhi1,ixGhi2,ixGhi3)
if(B0fieldAllocCoarse) call set_B0_cell(psc(igrid)%B0(ixCoGmin1:ixCoGmax1,&
ixCoGmin2:ixCoGmax2,ixCoGmin3:ixCoGmax3,:,0),psc(igrid)%x,ixCoGmin1,&
ixCoGmin2,ixCoGmin3,ixCoGmax1,ixCoGmax2,ixCoGmax3,ixCoGmin1,ixCoGmin2,&
ixCoGmin3,ixCoGmax1,ixCoGmax2,ixCoGmax3)
call set_J0_cell(igrid,ps(igrid)%J0,ixGlo1,ixGlo2,ixGlo3,ixGhi1,ixGhi2,&
ixGhi3,ixMlo1-1,ixMlo2-1,ixMlo3-1,ixMhi1+1,ixMhi2+1,ixMhi3+1)
call set_B0_face(igrid,ps(igrid)%x,ixGlo1,ixGlo2,ixGlo3,ixGhi1,ixGhi2,&
ixGhi3,ixMlo1,ixMlo2,ixMlo3,ixMhi1,ixMhi2,ixMhi3)
end subroutine set_B0_grid