LCOV - code coverage report
Current view: top level - shared/libpaw/src - m_pawtab.F90 (source / functions) Coverage Total Hit
Test: coverage.info Lines: 67.6 % 1526 1032
Test Date: 2026-09-19 17:42:43 Functions: 45.0 % 20 9

            Line data    Source code
       1              : !!****m* ABINIT/m_pawtab
       2              : !! NAME
       3              : !!  m_pawtab
       4              : !!
       5              : !! FUNCTION
       6              : !!  This module contains the definition of the pawtab_type structured datatype,
       7              : !!  as well as related functions and methods.
       8              : !!  pawtab_type variables define TABulated data for PAW (from pseudopotential)
       9              : !!
      10              : !! COPYRIGHT
      11              : !! Copyright (C) 2013-2026 ABINIT group (MT)
      12              : !! This file is distributed under the terms of the
      13              : !! GNU General Public License, see ~abinit/COPYING
      14              : !! or http://www.gnu.org/copyleft/gpl.txt .
      15              : !!
      16              : !! NOTES
      17              : !!  FOR DEVELOPPERS: in order to preserve the portability of libPAW library,
      18              : !!  please consult ~abinit/src/??_libpaw/libpaw-coding-rules.txt
      19              : !!
      20              : !! SOURCE
      21              : 
      22              : #include "libpaw.h"
      23              : 
      24              : MODULE m_pawtab
      25              : 
      26              :  USE_DEFS
      27              :  USE_MSG_HANDLING
      28              :  USE_MPI_WRAPPERS
      29              :  USE_MEMORY_PROFILING
      30              : 
      31              :  implicit none
      32              : 
      33              :  private
      34              : !!***
      35              : 
      36              : !----------------------------------------------------------------------
      37              : 
      38              : !!****t* m_pawtab/wvlpaw_rholoc_type
      39              : !! NAME
      40              : !! wvlpaw_rholoc_type
      41              : !!
      42              : !! FUNCTION
      43              : !! Objects for WVL+PAW
      44              : !!
      45              : !! SOURCE
      46              : 
      47              :  type,public :: wvlpaw_rholoc_type
      48              : 
      49              :   integer :: msz
      50              : ! mesh size
      51              : 
      52              :   real(dp),allocatable :: d(:,:)
      53              : ! local rho and derivatives
      54              : 
      55              :   real(dp),allocatable :: rad(:)
      56              : ! radial mesh
      57              : 
      58              :  end type wvlpaw_rholoc_type
      59              : 
      60              :  public :: wvlpaw_rholoc_free    ! Free memory
      61              :  public :: wvlpaw_rholoc_nullify ! Nullify content
      62              : !!***
      63              : 
      64              : !----------------------------------------------------------------------
      65              : 
      66              : !!****t* m_pawtab/wvlpaw_type
      67              : !! NAME
      68              : !! wvlpaw_type
      69              : !!
      70              : !! FUNCTION
      71              : !! Objects for WVL+PAW
      72              : !!
      73              : !! SOURCE
      74              : 
      75              :  type,public :: wvlpaw_type
      76              : 
      77              : ! WARNING : if you modify this datatype, please check whether there might be creation/destruction/copy routines,
      78              : ! declared in another part of ABINIT, that might need to take into account your modification.
      79              : 
      80              : !Integer scalars
      81              : 
      82              :   integer :: npspcode_init_guess
      83              :    ! This is for the PAW-WVL case, only for the initial guess
      84              : 
      85              :   integer :: ptotgau
      86              :    ! total number of complex gaussians
      87              :    ! for tproj
      88              : 
      89              :   integer,allocatable :: pngau(:)
      90              :    ! number of complex gaussians per basis element
      91              :    ! for tproj
      92              : 
      93              : !Real pointers
      94              : 
      95              :   real(dp),allocatable :: parg(:,:)
      96              :    !argument of Gaussians
      97              : 
      98              :   real(dp),allocatable :: pfac(:,:)
      99              :    !factors of Gaussians
     100              : 
     101              : !Other scalars
     102              : 
     103              :   type(wvlpaw_rholoc_type) :: rholoc
     104              :    ! local density
     105              :    !   d(:,1): local rho
     106              :    !   d(:,2): local rho 2nd-derivative
     107              :    !   d(:,3): local pot
     108              :    !   d(:,4): local pot 2nd-derivative
     109              : 
     110              :  end type wvlpaw_type
     111              : 
     112              :  public :: wvlpaw_allocate  ! Allocate memory
     113              :  public :: wvlpaw_free   ! Free memory
     114              :  public :: wvlpaw_nullify
     115              : !!***
     116              : 
     117              : !----------------------------------------------------------------------
     118              : 
     119              : !!****t* m_pawtab/pawtab_type
     120              : !! NAME
     121              : !! pawtab_type
     122              : !!
     123              : !! FUNCTION
     124              : !! This structured datatype contains TABulated data for PAW (from pseudopotential)
     125              : !! used in PAW calculations.
     126              : !!
     127              : !! SOURCE
     128              : 
     129              :  type,public :: pawtab_type
     130              : 
     131              : ! WARNING : if you modify this datatype, please check whether there might be creation/destruction/copy routines,
     132              : ! declared in another part of ABINIT, that might need to take into account your modification.
     133              : 
     134              : !Integer scalars
     135              : 
     136              :   integer :: add_core_energy
     137              :    ! Flag controling addition of core energies in total energy
     138              :    ! add_core_energy=0 ; do not add core energy to PAW energy
     139              :    ! add_core_energy=1 ; add core energy to PAW energy
     140              : 
     141              :   integer :: basis_size
     142              :    ! Number of elements for the paw nl basis on the considered atom type
     143              : 
     144              :   integer :: has_coretau
     145              :    ! Flag controling use of core kinetic energy density (AE and pseudo)
     146              :    ! if 1, [t]coretau() is allocated.
     147              :    ! if 2, [t]coretau() is computed and stored.
     148              : 
     149              :   integer :: has_fock
     150              :    ! if 1, onsite matrix elements of the core-valence Fock operator are allocated
     151              :    ! if 2, onsite matrix elements of the core-valence Fock operator are computed and stored
     152              : 
     153              :   integer :: has_kij
     154              :    ! if 1, onsite matrix elements of the kinetic operator are allocated
     155              :    ! if 2, onsite matrix elements of the kinetic operator are computed and stored
     156              : 
     157              :   integer :: has_shapefncg
     158              :    ! if 1, the spherical Fourier transforms of the radial shape functions are allocated
     159              :    ! if 2, the spherical Fourier transforms of the radial shape functions are computed and stored
     160              : 
     161              :   integer :: has_nabla
     162              :    ! if 1, onsite matrix elements of the nabla operator are allocated.
     163              :    ! if 2, onsite matrix elements of the nabla operator are computed and stored.
     164              :    ! if 3, onsite matrix elements of the nabla operator between valence and core states are computed and stored.
     165              :    ! if 4, onsite matrix elements of the nabla operator between valence and core spinor states are are computed and stored.
     166              : 
     167              :   integer :: has_nablaphi
     168              :    ! if 1, nablaphi are allocated
     169              :    ! if 2, nablaphi are computed for MetaGGA and stored.
     170              : 
     171              :   integer :: has_tproj
     172              :    ! Flag controling use of projectors in real space (0 if tnval is unknown)
     173              :    ! if 1, tproj() is allocated.
     174              :    ! if 2, tproj() is computed and stored.
     175              : 
     176              :   integer :: has_tvale
     177              :    ! Flag controling use of pseudized valence density (0 if tnval is unknown)
     178              :    ! if 1, tvalespl() is allocated.
     179              :    ! if 2, tvalespl() is computed and stored.
     180              : 
     181              :   integer :: has_vhtnzc
     182              :    ! if 1, space for vhtnzc is allocated
     183              :    ! if 2, vhtnzc has been read from PAW file and stored
     184              : 
     185              :   integer :: has_vhnzc
     186              :    ! if 1, space for vhnzc is allocated
     187              :    ! if 2, vhnzc has been computed and stored
     188              : 
     189              :   integer :: has_vminushalf
     190              :    ! has_vminushalf=0 ; vminushal is not allocated
     191              :    ! has_vminushalf=1 ; vminushal is not allocated and stored
     192              : 
     193              :   integer :: has_wvl
     194              :    ! if 1, data for wavelets (pawwvl) are allocated
     195              :    ! if 2, data for wavelets (pawwvl) are computed and stored
     196              : 
     197              :   integer :: ij_proj
     198              :    ! Number of (i,j) elements for the orbitals on which U acts (PAW+U only)
     199              :    ! on the considered atom type (ij_proj=1 (1 projector), 3 (2 projectors)...)
     200              :    ! Also used for local exact-exchange
     201              : 
     202              :   integer :: ij_size
     203              :    ! Number of (i,j) elements for the symetric paw basis
     204              :    ! on the considered atom type (ij_size=basis_size*(basis_size+1)/2)
     205              : 
     206              :   integer :: lcut_size
     207              :    ! Maximum value of l+1 leading to non zero Gaunt coeffs
     208              :    ! modified by dtset%pawlcutd
     209              :    ! lcut_size=min(2*l_max,dtset%pawlcutd)+1
     210              : 
     211              :   integer :: l_size
     212              :    ! Maximum value of l+1 leading to non zero Gaunt coeffs
     213              :    ! l_size=2*l_max-1
     214              : 
     215              :   integer :: lexexch
     216              :    ! lexexch gives l on which local exact-exchange is applied for a given type of atom.
     217              : 
     218              :   integer :: lmn_size
     219              :    ! Number of (l,m,n) elements for the paw basis
     220              : 
     221              :   integer :: lmn2_size
     222              :    ! lmn2_size=lmn_size*(lmn_size+1)/2
     223              :    ! where lmn_size is the number of (l,m,n) elements for the paw basis
     224              : 
     225              :   integer :: lmnmix_sz
     226              :    ! lmnmix_sz=number of klmn=(lmn,lmn_prime) verifying l<=lmix and l_prime<=lmix
     227              : 
     228              :   integer :: lpawu
     229              :    ! lpawu gives l on which U is applied for a given type of atom.
     230              : 
     231              :   integer :: nproju
     232              :    ! nproju is the number of projectors for orbitals on which paw+u acts.
     233              :    ! Also used for local exact-exchange
     234              : 
     235              :   integer :: option_interaction_pawu
     236              :    ! Option for interaction energy (PAW+U) in case of non-collinear magnetism:
     237              :    ! 1: E_int=-J/4.N.(N-2)
     238              :    ! 2: E_int=-J/2.(Nup.(Nup-1)+Ndn.(Ndn-1))    (Nup and Ndn are ill-defined)
     239              :    ! 3: E_int=-J/4.( N.(N-2) + mx^2 + my^2 + mz^2 )
     240              : 
     241              :   integer :: mesh_size
     242              :    ! Dimension of radial mesh for generic arrays contained in this pawtab datastructure
     243              :    ! The mesh is usually defined up to the PAW augmentation region boundary
     244              :    ! (+ a few additional points). May be different from pawrad%mesh_size
     245              : 
     246              :   integer :: core_mesh_size
     247              :    ! Dimension of radial mesh for core density
     248              : 
     249              :   integer :: coretau_mesh_size
     250              :    ! Dimension of radial mesh for core density
     251              : 
     252              :   integer :: vminus_mesh_size
     253              :    ! Dimension of radial mesh for vminushalf
     254              : 
     255              :   integer :: partialwave_mesh_size
     256              :    ! Dimension of radial mesh for partial waves (phi, tphi)
     257              :    ! May be different from pawrad%mesh_size and pawtab%mesh_size
     258              : 
     259              :   integer :: tnvale_mesh_size
     260              :    ! Dimension of radial mesh for tnvale
     261              : 
     262              :   integer :: mqgrid
     263              :    ! Number of points in the reciprocal space grid on which
     264              :    ! the radial functions (tcorespl, tvalespl...) are specified
     265              :    ! Same as psps%mqgrid_vl
     266              : 
     267              :   integer :: mqgrid_shp
     268              :    ! Number of points in the reciprocal space grid on which
     269              :    ! the radial shape functions (shapefncg) are given
     270              : 
     271              :   integer :: usespnorb
     272              :    ! usespnorb=0 ; no spin-orbit coupling
     273              :    ! usespnorb=1 ; spin-orbit coupling
     274              : 
     275              :   integer :: shape_lambda
     276              :    ! Lambda parameter in gaussian shapefunction (shape_type=2)
     277              : 
     278              :   integer :: shape_type
     279              :    ! Radial shape function type
     280              :    ! shape_type=-1 ; g(r)=numeric (read from psp file)
     281              :    ! shape_type= 1 ; g(r)=[sin(pi*r/rshp)/(pi*r/rshp)]**2 if r<=rshp, zero if r>rshp
     282              :    ! shape_type= 2 ; g(r)=exp[-(r/sigma)**lambda]
     283              :    ! shape_type= 3 ; gl(r)=Alpha(1,l)*jl(q(1,l)*r)+Alpha(2,l)*jl(q(2,l)*r) for each l
     284              : 
     285              :   integer :: useexexch
     286              :    ! useexexch=0 ; do not use local exact-exchange
     287              :    ! useexexch=1 ; use local exact-exchange
     288              : 
     289              :   integer :: usepawu
     290              :    ! usepawu= 0 ; do not use PAW+U formalism
     291              :    ! usepawu= 1 ; use PAW+U formalism (Full localized limit)
     292              :    ! usepawu= 2 ; use PAW+U formalism (Around Mean Field)
     293              :    ! usepawu= 3 ; use PAW+U formalism (Around Mean Field) - Alternative
     294              :    ! usepawu= 4 ; use PAW+U formalism (FLL) without polarization in the XC
     295              :    ! usepawu=-1 ; use PAW+U formalism (FLL) - No use of the occupation matrix - Experimental
     296              :    ! usepawu=-2 ; use PAW+U formalism (AMF) - No use of the occupation matrix - Experimental
     297              :    ! usepawu=-4 ; use PAW+U formalism (FLL) without polarization in the XC - No use of the occupation matrix - Experimental
     298              :    ! usepawu=10 ; use PAW+U within DMFT
     299              :    ! usepawu=14 ; use PAW+U within DMFT without polarization in the XC
     300              : 
     301              :   integer :: usepotzero
     302              :    ! usepotzero=0 if it is the Kresse-Joubert convention
     303              :    ! usepotzero=1 if it is the new convention
     304              :    ! usepotzero=2 if it is the PWscf convention
     305              : 
     306              :   integer :: usetcore
     307              :    ! Flag controling use of pseudized core density (0 if tncore=zero)
     308              : 
     309              :   integer :: usexcnhat
     310              :    ! 0 if compensation charge density is not included in XC terms
     311              :    ! 1 if compensation charge density is included in XC terms
     312              : 
     313              : !Real (real(dp)) scalars
     314              : 
     315              :   real(dp) :: beta
     316              :    ! contains the integral of the difference between vH[nZc] and vH[tnZc]
     317              : 
     318              :   real(dp) :: dncdq0
     319              :    ! Gives 1/q d(tNcore(q))/dq for q=0
     320              :    ! (tNcore(q) = FT of pseudo core density)
     321              : 
     322              :   real(dp) :: d2ncdq0
     323              :    ! Gives contribution of d2(tNcore(q))/d2q for q=0
     324              :    ! \int{(16/15)*pi^5*n(r)*r^6* dr}
     325              :    ! (tNcore(q) = FT of pseudo core density)
     326              : 
     327              :   real(dp) :: dnvdq0
     328              :    ! Gives 1/q d(tNvale(q))/dq for q=0
     329              :    ! (tNvale(q) = FT of pseudo valence density)
     330              : 
     331              :   real(dp) :: dtaucdq0
     332              :    ! Gives 1/q d(tTAUcore(q))/dq for q=0
     333              :    ! (tTAUcore(q) = FT of pseudo core kinetic density)
     334              : 
     335              :   real(dp) :: ehnzc
     336              :    ! Hartree energy of core electrons + nucleus
     337              : 
     338              :   real(dp) :: eps
     339              :   ! Epsilon parameter for Yukawa potential (only used for the exact double counting)
     340              : 
     341              :   real(dp) :: ex_cc
     342              :    ! Exchange energy for the core-core interaction of the Fock operator
     343              : 
     344              :   real(dp) :: ekincore
     345              :    ! Kinetic energy for the core density
     346              : 
     347              :   real(dp) :: exccore
     348              :    ! Exchange-correlation energy for the core density
     349              : 
     350              :   real(dp) :: sxccore=zero
     351              :    ! Exchange-correlation entropy for the core density
     352              : 
     353              :   real(dp) :: exchmix
     354              :    ! mixing of exact exchange; default is 0.25 (PBE0)
     355              : 
     356              :   real(dp) :: f4of2_sla
     357              :    ! Ratio of Slater Integrals F4 and F2
     358              : 
     359              :   real(dp) :: f6of2_sla
     360              :    ! Ratio of Slater Integrals F6 and F4
     361              : 
     362              :   real(dp) :: jpawu
     363              :    ! Value of J parameter for paw+u for a given type.
     364              : 
     365              :    real(dp) :: lamb_shielding=0.0D0
     366              :    ! Lamb shielding used in NMR shielding calcs (see m_orbmag.F90)
     367              : 
     368              :   real(dp) :: lambda
     369              :   ! Lambda parameter for Yukawa potential (only used for the exact double counting)
     370              : 
     371              :   real(dp) :: rpaw
     372              :    ! Radius of PAW sphere
     373              : 
     374              :   real(dp) :: rshp
     375              :    ! Compensation charge radius (if r>rshp, g(r)=zero)
     376              : 
     377              :   real(dp) :: rcore
     378              :    ! Radius of core corrections (rcore >= rpaw)
     379              : 
     380              :   real(dp) :: rcoretau
     381              :    ! Radius of kinetic core corrections (rcoretau >= rpaw)
     382              : 
     383              :   real(dp) :: shape_sigma
     384              :    ! Sigma parameter in gaussian shapefunction (shape_type=2)
     385              : 
     386              :   real(dp) :: upawu
     387              :    ! Value of U parameter for paw+u for a given type.
     388              : 
     389              : !Objects
     390              :   type(wvlpaw_type), pointer :: wvl
     391              :    !variable containing objects needed
     392              :    !for wvl+paw implementation
     393              :    !Warning: it is a pointer; it has to be allocated before use
     394              : 
     395              : !Integer arrays
     396              : 
     397              :   integer, allocatable :: indklmn(:,:)
     398              :    ! indklmn(8,lmn2_size)
     399              :    ! Array giving klm, kln, abs(il-jl), (il+jl), ilm and jlm, ilmn and jlmn for each klmn=(ilmn,jlmn)
     400              :    ! Note: ilmn=(il,im,in) and ilmn<=jlmn
     401              : 
     402              :   integer, allocatable :: indlmn(:,:)
     403              :    ! indlmn(6,lmn_size)
     404              :    ! For each type of psp,
     405              :    ! array giving l,m,n,lm,ln,spin for i=lmn (if useylm=1)
     406              : 
     407              :   integer, allocatable :: klmntomn(:,:)
     408              :    ! klmntomn(4,lmn2_size)
     409              :    ! Array giving im, jm ,in, and jn for each klmn=(ilmn,jlmn)
     410              :    ! Note: ilmn=(il,im,in) and ilmn<=jlmn
     411              :    ! NB: klmntomn is an application and not a bijection
     412              : 
     413              :   integer, allocatable :: kmix(:)
     414              :    ! kmix(lmnmix_sz)
     415              :    ! Indirect array selecting the klmn=(lmn,lmn_prime) verifying l<=lmix and l_prime<=lmix
     416              : 
     417              :   integer, allocatable :: lnproju(:)
     418              :    ! lnproju(nproju) gives ln (index for phi) for each projectors on which U acts (PAW+U only)
     419              :    ! nproju is 1 or 2 and  is the number of projectors for correlated orbitals
     420              :    ! Also used for local exact-exchange
     421              : 
     422              :   integer, allocatable :: orbitals(:)
     423              :    ! (basis_size)
     424              :    ! gives the l quantum number per basis element
     425              : 
     426              : !Real (real(dp)) arrays
     427              : 
     428              :   real(dp), allocatable :: coredens(:)
     429              :    ! coredens(mesh_size)
     430              :    ! Gives the core density of the atom
     431              : 
     432              :   real(dp), allocatable :: coretau(:)
     433              :    ! coretau(mesh_size)
     434              :    ! Gives the kinetic energy density of the atom
     435              : 
     436              :   real(dp), allocatable :: dij0(:)
     437              :    ! dij0(lmn2_size)
     438              :    ! Part of the Dij term (non-local operator) completely
     439              :    ! calculated in the atomic data part
     440              : 
     441              :   real(dp), allocatable :: dltij(:)
     442              :    ! dltij(lmn2_size)
     443              :    ! Factor used to compute sums over klmn=(ilmn,jlmn)
     444              :    ! ((ilmn,ilmn) term has to be added once)
     445              :    ! dltij(klmn)=1 if ilmn=jlmn, else dltij(klmn)=2
     446              : 
     447              :   real(dp), allocatable :: dshpfunc(:,:,:)
     448              :    ! shapefunc(mesh_size,l_size,4)
     449              :    ! Gives the 4 first derivatives of  radial shape function
     450              :    ! for each l component; used only if shape_type=-1
     451              : 
     452              :   real(dp), allocatable :: eijkl(:,:)
     453              :    ! eijkl(lmn2_size,lmn2_size)
     454              :    ! Hartree kernel for the on-site terms (E_hartree=Sum_ijkl[rho_ij rho_kl e_ijkl])
     455              :    ! Used for Hartree and/or Fock contributions
     456              : 
     457              :   real(dp), allocatable :: eijkl_sr(:,:)
     458              :    ! eijkl_sr(lmn2_size,lmn2_size)
     459              :    ! Screened Hartree kernel for the on-site terms (E_hartree=Sum_ijkl[rho_ij rho_kl e_ijkl_sr])
     460              :    ! Used for screened Fock contributions
     461              : 
     462              :   real(dp), allocatable :: euijkl(:,:,:,:,:)
     463              :    ! euijkl(3,lmn_size,lmn_size,lmn_size,lmn_size)
     464              :    ! PAW+U kernel for the on-site terms ( E_PAW+U = 0.5 * Sum_ijkl Sum_s1s2 [rho_ij^s1 rho_kl^s2 euijkl(s1,s2)] )
     465              :    ! Contrary to eijkl and eijkl_sr, euijkl is not invariant with respect to the permutations i <--> j or k <--> l
     466              :    ! However, it is still invariant with respect to the permutation i,k <--> j,l, see pawpuxinit.F90
     467              :    ! Also, it depends on two spin indexes
     468              :    ! Used for PAW+U contributions
     469              : 
     470              :   real(dp), allocatable :: euij_fll(:)
     471              :    ! euij_fll(lmn2_size)
     472              :    ! Double counting part of the PAW+U kernel in the "fully localized limit".This term is only linear with respect to rho_ij,
     473              :    ! while euijkl is quadratic.
     474              :    ! Used for PAW+U contributions
     475              : 
     476              :   real(dp), allocatable :: ex_cvij(:)
     477              :   ! ex_cvij(lmn2_size))
     478              :   ! Onsite exact_exchange matrix elements for core-valence interactions of the Fock operator
     479              : 
     480              :   real(dp), allocatable :: fk(:,:)
     481              :    ! fk(6,4)
     482              :    ! Slater integrals used for local exact exchange
     483              : 
     484              :   real(dp), allocatable :: gammaij(:)
     485              :    ! gammaij(lmn2_size)
     486              :    ! background contribution from the densities
     487              : 
     488              :   real(dp), allocatable :: gnorm(:)
     489              :    ! gnorm(l_size)
     490              :    ! Give the the normalization factor of each radial shape function
     491              : 
     492              :   real(dp), allocatable :: kij(:)
     493              :   ! kij(lmn2_size))
     494              :   ! Onsite matrix elements <phi|\kinetic|phj>-<tphi|\kinetic|tphj>
     495              : 
     496              :   real(dp), allocatable :: nabla_ij(:,:,:)
     497              :    ! nabla_ij(3,lmn_size,lmn_size)
     498              :    ! Onsite matrix elements <phi|\nabla|phj>-<tphi|\nabla|tphj>
     499              : 
     500              :   real(dp), allocatable :: nabla_im_ij(:,:,:)
     501              :    ! nabla_im_ij(3,lmn_size,lmn_size)
     502              :    ! Imaginary part of onsite matrix elements <phi|\nabla|phj>-<tphi|\nabla|tphj>
     503              :    ! Used in case of core spinor wave functions
     504              : 
     505              :   real(dp), allocatable :: nablaphi(:,:)
     506              :    ! nablaphi(partialwave_mesh_size, basis_size)
     507              :    ! store the results of dphi/dr-(1/r)phi
     508              : 
     509              :   real(dp), allocatable :: phi(:,:)
     510              :    ! phi(partialwave_mesh_size, basis_size)
     511              :    ! Gives the paw electron wavefunctions on the radial grid
     512              : 
     513              :   real(dp), allocatable :: phiphj(:,:)
     514              :    ! phiphj(mesh_size,ij_size)
     515              :    ! Useful product Phi(:,i)*Phi(:,j)
     516              : 
     517              :   real(dp), allocatable :: phiphjint(:)
     518              :    ! phiphjint(ij_proj)
     519              :    ! Integration of Phi(:,i)*Phi(:,j) for DFT+U/local exact-exchange occupation matrix
     520              : 
     521              :   real(dp), allocatable :: ph0phiint(:)
     522              :    ! ph0phjint(ij_proj)
     523              :    ! Integration of Phi(:,1)*Phi(:,j) for LDA+DMFT projections
     524              : 
     525              :   real(dp), allocatable :: proj(:)
     526              :    ! proj(mesh_size)
     527              :    ! non-normalized DMFT orbital
     528              : 
     529              :   real(dp), allocatable :: proj2(:)
     530              :   ! proj2(mesh_size)
     531              :   ! square of the normalized DMFT orbital
     532              : 
     533              :   real(dp), allocatable :: qgrid_shp(:)
     534              :    ! qgrid_shp(mqgrid_shp)
     535              :    ! Grid of points in reciprocal space on which the shape functions are given
     536              : 
     537              :   real(dp), allocatable :: qijl(:,:)
     538              :    ! qijl(l_size**2,lmn2_size)
     539              :    ! The qijl are the moments of the charge density difference between
     540              :    ! the AE and PS partial wave for each channel (i,j). They take part
     541              :    ! to the building of the compensation charge
     542              : 
     543              :   real(dp), allocatable :: rad_for_spline(:)
     544              :    ! rad_for_spline(mesh_size)
     545              :    ! Radial mesh used to spline quantities on radial mesh;
     546              :    ! Allocated and used only when
     547              :    !     shape_type=-1 (numerical shape function)
     548              :    !  or usedvloc=1 (use of vloc derivative)
     549              : 
     550              :   real(dp), allocatable :: rhoij0(:)
     551              :    ! rhoij0(lmn2_size)
     552              :    ! Initial guess for rhoij
     553              : 
     554              :   real(dp), allocatable :: shape_alpha(:,:)
     555              :    ! shape_alpha(2,l_size)
     556              :    ! Alpha_i parameters in Bessel shapefunctions (shape_type=3)
     557              : 
     558              :   real(dp), allocatable :: shape_q(:,:)
     559              :    ! shape_q(2,l_size)
     560              :    ! Q_i parameters in Bessel shapefunctions (shape_type=3)
     561              : 
     562              :   real(dp), allocatable :: shapefunc(:,:)
     563              :    ! shapefunc(mesh_size,l_size)
     564              :    ! Gives the normalized radial shape function for each l component
     565              : 
     566              :   real(dp), allocatable :: shapefncg(:,:,:)
     567              :    ! shapefncg(mqgrid_shp,2,l_size)
     568              :    ! Gives the spherical Fourier transform of the radial shape function
     569              :    ! for each l component (for each qgrid_shp(i)) + second derivative
     570              : 
     571              :   real(dp), allocatable :: sij(:)
     572              :    ! sij(lmn2_size)
     573              :    ! Nonlocal part of the overlap operator
     574              : 
     575              :   real(dp), allocatable :: tcoredens(:,:)
     576              :    ! tcoredens(core_mesh_size,1)
     577              :    ! Gives the pseudo core density of the atom
     578              :    ! In PAW+WVL:
     579              :    !  tcoredens(core_mesh_size,2:6)
     580              :    !  are the first to the fifth derivatives of the pseudo core density.
     581              : 
     582              :  real(dp), allocatable :: tcoretau(:)
     583              :    ! tcoretau(coretau_mesh_size)
     584              :    ! Gives the pseudo core kinetic energy density of the atom
     585              : 
     586              :   real(dp), allocatable :: tcorespl(:,:)
     587              :    ! tcorespl(mqgrid,2)
     588              :    ! Gives the pseudo core density in reciprocal space on a regular grid
     589              : 
     590              :   real(dp), allocatable :: tcoretauspl(:,:)
     591              :    ! tcoretauspl(mqgrid,2)
     592              :    ! Gives the pseudo kinetic core density in reciprocal space on a regular grid
     593              : 
     594              :   real(dp), allocatable :: tnablaphi(:,:)
     595              :    ! tphi(partialwave_mesh_size,basis_size)
     596              :    ! Gives, on the radial grid, the paw atomic pseudowavefunctions
     597              : 
     598              :   real(dp), allocatable :: tphi(:,:)
     599              :    ! tphi(partialwave_mesh_size,basis_size)
     600              :    ! Gives, on the radial grid, the paw atomic pseudowavefunctions
     601              : 
     602              :   real(dp), allocatable :: tphitphj(:,:)
     603              :    ! tphitphj(mesh_size,ij_size)
     604              :    ! Useful product tPhi(:,i)*tPhi(:,j)
     605              : 
     606              :   real(dp), allocatable :: tproj(:,:)
     607              :    ! non-local projectors
     608              : 
     609              :   real(dp), allocatable :: tvalespl(:,:)
     610              :    ! tvalespl(mqgrid,2)
     611              :    ! Gives the pseudo valence density in reciprocal space on a regular grid
     612              : 
     613              :   real(dp), allocatable :: Vee(:,:,:,:)
     614              :    ! PAW+U:
     615              :    ! Screened interaction matrix deduced from U and J parameters
     616              :    ! computed on the basis of orbitals on which U acts.
     617              : 
     618              :   real(dp), allocatable :: Vex(:,:,:,:,:)
     619              :    ! Local exact-exchange:
     620              :    ! Screened interaction matrix deduced from calculation of Slater integrals
     621              :    ! computed on the basis of orbitals on which local exact exchange acts.
     622              : 
     623              :   real(dp), allocatable :: vhtnzc(:)
     624              :    ! vhtnzc(mesh_size)
     625              :    ! Hartree potential for pseudized Zc density, v_H[\tilde{n}_{Zc}]
     626              :    ! read in from PAW file
     627              : 
     628              :   real(dp), allocatable :: VHnZC(:)
     629              :    ! VHnZC(mesh_size)
     630              :    ! Hartree potential for Zc density, v_H[n_{Zc}]
     631              :    ! constructed from core density in PAW file (see psp7in.F90)
     632              : 
     633              :   real(dp), allocatable :: vminushalf(:)
     634              :    ! vminushalf(mesh_size)
     635              :    ! External potential for LDA minus half calculation
     636              :    ! read in from PAW file
     637              : 
     638              :   real(dp), allocatable :: zioneff(:)
     639              :    ! zioneff(ij_proj)
     640              :    ! "Effective charge"*n "seen" at r_paw, deduced from Phi at r_paw, n:
     641              :    ! pricipal quantum number
     642              :    ! good approximation to model wave function outside PAW-sphere through
     643              : 
     644              :  end type pawtab_type
     645              : 
     646              :  public :: pawtab_free         ! Free memory
     647              :  public :: pawtab_nullify      ! Nullify content
     648              :  public :: pawtab_get_lsize    ! Get the max. l for a product of 2 partial waves
     649              :  public :: pawtab_set_flags    ! Set the value of the internal flags
     650              :  public :: pawtab_print        ! Printout of the object
     651              :  public :: pawtab_bcast        ! MPI broadcast the object
     652              : !TODO: someone should implement a pawtab copy routine to get an independent identical copy of the object
     653              : 
     654              :  interface pawtab_nullify
     655              :    module procedure pawtab_nullify_0D
     656              :    module procedure pawtab_nullify_1D
     657              :  end interface pawtab_nullify
     658              : 
     659              :  interface pawtab_free
     660              :    module procedure pawtab_free_0D
     661              :    module procedure pawtab_free_1D
     662              :  end interface pawtab_free
     663              : 
     664              :  interface pawtab_set_flags
     665              :    module procedure pawtab_set_flags_0D
     666              :    module procedure pawtab_set_flags_1D
     667              :  end interface pawtab_set_flags
     668              : !!***
     669              : 
     670              : CONTAINS !===========================================================
     671              : !!***
     672              : 
     673              : !----------------------------------------------------------------------
     674              : 
     675              : !!****f* m_pawtab/pawtab_nullify_0D
     676              : !! NAME
     677              : !!  pawtab_nullify_0D
     678              : !!
     679              : !! FUNCTION
     680              : !!  Nullify pointers and flags in a pawtab structure
     681              : !!
     682              : !! SIDE EFFECTS
     683              : !!  Pawtab<type(pawtab_type)>=PAW arrays tabulated.
     684              : !!                            Nullified in output
     685              : !!
     686              : !! SOURCE
     687              : 
     688         1637 : subroutine pawtab_nullify_0D(Pawtab)
     689              : 
     690              : !Arguments ------------------------------------
     691              : !arrays
     692              :  type(Pawtab_type),intent(inout) :: Pawtab
     693              : 
     694              : !Local variables-------------------------------
     695              : 
     696              : ! *************************************************************************
     697              : 
     698              :  !@Pawtab_type
     699         1637 :  nullify(Pawtab%wvl)
     700              : 
     701              :  ! === Reset all flags and sizes ===
     702              : 
     703              : !Flags controlling optional arrays
     704         1637 :  Pawtab%has_fock=0
     705         1637 :  Pawtab%has_kij=0
     706         1637 :  Pawtab%has_tproj=0
     707         1637 :  Pawtab%has_tvale=0
     708         1637 :  Pawtab%has_coretau=0
     709         1637 :  Pawtab%has_vhtnzc=0
     710         1637 :  Pawtab%has_vhnzc=0
     711         1637 :  Pawtab%has_vminushalf=0
     712         1637 :  Pawtab%has_nabla=0
     713         1637 :  Pawtab%has_nablaphi=0
     714         1637 :  Pawtab%has_shapefncg=0
     715         1637 :  Pawtab%has_wvl=0
     716         1637 :  Pawtab%add_core_energy=0
     717              : 
     718         1637 :  Pawtab%usetcore=0
     719         1637 :  Pawtab%usexcnhat=0
     720         1637 :  Pawtab%useexexch=0
     721         1637 :  Pawtab%usepawu=0
     722         1637 :  Pawtab%usepotzero=0
     723         1637 :  Pawtab%usespnorb=0
     724         1637 :  Pawtab%mqgrid=0
     725         1637 :  Pawtab%mqgrid_shp=0
     726              : 
     727         1637 :  Pawtab%basis_size=0
     728         1637 :  Pawtab%ij_proj=0
     729         1637 :  Pawtab%ij_size=0
     730         1637 :  Pawtab%lcut_size=0
     731         1637 :  Pawtab%l_size=0
     732         1637 :  Pawtab%lexexch=-1
     733         1637 :  Pawtab%lmn_size=0
     734         1637 :  Pawtab%lmn2_size=0
     735         1637 :  Pawtab%lmnmix_sz=0
     736         1637 :  Pawtab%lpawu=-1
     737         1637 :  Pawtab%nproju=0
     738         1637 :  Pawtab%option_interaction_pawu=0
     739         1637 :  Pawtab%mesh_size=0
     740         1637 :  Pawtab%partialwave_mesh_size=0
     741         1637 :  Pawtab%core_mesh_size=0
     742         1637 :  Pawtab%coretau_mesh_size=0
     743         1637 :  Pawtab%vminus_mesh_size=0
     744         1637 :  Pawtab%tnvale_mesh_size=0
     745         1637 :  Pawtab%shape_type=-10
     746              : 
     747         1637 : end subroutine pawtab_nullify_0D
     748              : !!***
     749              : 
     750              : !----------------------------------------------------------------------
     751              : 
     752              : !!****f* m_pawtab/pawtab_nullify_1D
     753              : !! NAME
     754              : !!  pawtab_nullify_1D
     755              : !!
     756              : !! FUNCTION
     757              : !!  Nullify all pointers in an array of pawtab data structures
     758              : !!
     759              : !! SOURCE
     760              : 
     761         2516 : subroutine pawtab_nullify_1D(Pawtab)
     762              : 
     763              : !Arguments ------------------------------------
     764              :  type(pawtab_type),intent(inout) :: Pawtab(:)
     765              : 
     766              : !Local variables-------------------------------
     767              :  integer :: ii,nn
     768              : 
     769              : ! *************************************************************************
     770              : 
     771              :  !@pawtab_type
     772              : 
     773         2516 :  nn=size(Pawtab)
     774         2516 :  if (nn==0) return
     775              : 
     776         2713 :  do ii=1,nn
     777         2713 :    call pawtab_nullify_0D(Pawtab(ii))
     778              :  end do
     779              : 
     780              : end subroutine pawtab_nullify_1D
     781              : !!***
     782              : 
     783              : !----------------------------------------------------------------------
     784              : 
     785              : !!****f* m_pawtab/pawtab_free_0D
     786              : !! NAME
     787              : !!  pawtab_free_0D
     788              : !!
     789              : !! FUNCTION
     790              : !!  Deallocate pointers and nullify flags in a pawtab structure
     791              : !!
     792              : !! SIDE EFFECTS
     793              : !!  Pawtab<type(pawtab_type)>=PAW arrays tabulated.
     794              : !!  All allocated arrays in Pawtab are deallocated
     795              : !!
     796              : !! SOURCE
     797              : 
     798         2155 : subroutine pawtab_free_0D(Pawtab)
     799              : 
     800              : !Arguments ------------------------------------
     801              : !arrays
     802              :  type(Pawtab_type),intent(inout) :: Pawtab
     803              : 
     804              : ! *************************************************************************
     805              : 
     806              :  !@Pawtab_type
     807              : 
     808         2155 :  if (allocated(Pawtab%indklmn))  then
     809          739 :   LIBPAW_DEALLOCATE(Pawtab%indklmn)
     810              :  end if
     811         2155 :  if (allocated(Pawtab%indlmn))  then
     812          739 :   LIBPAW_DEALLOCATE(Pawtab%indlmn)
     813              :  end if
     814         2155 :  if (allocated(Pawtab%klmntomn))  then
     815           98 :    LIBPAW_DEALLOCATE(Pawtab%klmntomn)
     816              :  end if
     817         2155 :  if (allocated(Pawtab%kmix))  then
     818          721 :    LIBPAW_DEALLOCATE(Pawtab%kmix)
     819              :  end if
     820         2155 :  if (allocated(Pawtab%lnproju))  then
     821           98 :    LIBPAW_DEALLOCATE(Pawtab%lnproju)
     822              :  end if
     823         2155 :  if (allocated(Pawtab%coredens))  then
     824          721 :    LIBPAW_DEALLOCATE(Pawtab%coredens)
     825              :  end if
     826         2155 :  if (allocated(Pawtab%coretau))  then
     827           17 :    LIBPAW_DEALLOCATE(Pawtab%coretau)
     828              :  end if
     829         2155 :  if (allocated(Pawtab%dij0))  then
     830         1775 :    LIBPAW_DEALLOCATE(Pawtab%dij0)
     831              :  end if
     832         2155 :  if (allocated(Pawtab%dltij))  then
     833          721 :    LIBPAW_DEALLOCATE(Pawtab%dltij)
     834              :  end if
     835         2155 :  if (allocated(Pawtab%dshpfunc))  then
     836            3 :    LIBPAW_DEALLOCATE(Pawtab%dshpfunc)
     837              :  end if
     838         2155 :  if (allocated(Pawtab%eijkl))  then
     839          721 :    LIBPAW_DEALLOCATE(Pawtab%eijkl)
     840              :  end if
     841         2155 :  if (allocated(Pawtab%eijkl_sr))  then
     842            4 :    LIBPAW_DEALLOCATE(Pawtab%eijkl_sr)
     843              :  end if
     844         2155 :  if (allocated(Pawtab%euijkl))  then
     845            4 :    LIBPAW_DEALLOCATE(Pawtab%euijkl)
     846              :  end if
     847         2155 :  if (allocated(Pawtab%euij_fll))  then
     848            4 :    LIBPAW_DEALLOCATE(Pawtab%euij_fll)
     849              :  end if
     850         2155 :  if (allocated(Pawtab%fk))  then
     851            1 :    LIBPAW_DEALLOCATE(Pawtab%fk)
     852              :  end if
     853         2155 :  if (allocated(Pawtab%gammaij))  then
     854            2 :    LIBPAW_DEALLOCATE(Pawtab%gammaij)
     855              :  end if
     856         2155 :  if (allocated(Pawtab%gnorm))  then
     857          721 :    LIBPAW_DEALLOCATE(Pawtab%gnorm)
     858              :  end if
     859         2155 :  if (allocated(Pawtab%ex_cvij))  then
     860          358 :    LIBPAW_DEALLOCATE(Pawtab%ex_cvij)
     861              :  end if
     862         2155 :  if (allocated(Pawtab%kij))  then
     863           41 :    LIBPAW_DEALLOCATE(Pawtab%kij)
     864              :  end if
     865         2155 :  if (allocated(Pawtab%nabla_ij))  then
     866            6 :    LIBPAW_DEALLOCATE(Pawtab%nabla_ij)
     867              :  end if
     868         2155 :  if (allocated(Pawtab%nabla_im_ij))  then
     869            0 :    LIBPAW_DEALLOCATE(Pawtab%nabla_im_ij)
     870              :  end if
     871         2155 :  if (allocated(Pawtab%nablaphi))  then
     872           17 :    LIBPAW_DEALLOCATE(Pawtab%nablaphi)
     873              :  end if
     874         2155 :  if (allocated(Pawtab%orbitals)) then
     875          721 :    LIBPAW_DEALLOCATE(Pawtab%orbitals)
     876              :  end if
     877         2155 :  if (allocated(Pawtab%phi))  then
     878          739 :    LIBPAW_DEALLOCATE(Pawtab%phi)
     879              :  end if
     880         2155 :  if (allocated(Pawtab%phiphj))  then
     881          721 :    LIBPAW_DEALLOCATE(Pawtab%phiphj)
     882              :  end if
     883         2155 :  if (allocated(Pawtab%phiphjint))  then
     884           98 :    LIBPAW_DEALLOCATE(Pawtab%phiphjint)
     885              :  end if
     886         2155 :  if (allocated(Pawtab%ph0phiint))  then
     887           98 :    LIBPAW_DEALLOCATE(Pawtab%ph0phiint)
     888              :  end if
     889         2155 :  if (allocated(Pawtab%proj)) then
     890           40 :    LIBPAW_DEALLOCATE(Pawtab%proj)
     891              :  end if
     892         2155 :  if (allocated(Pawtab%proj2)) then
     893            0 :    LIBPAW_DEALLOCATE(Pawtab%proj2)
     894              :  end if
     895         2155 :  if (allocated(Pawtab%qgrid_shp))  then
     896            0 :    LIBPAW_DEALLOCATE(Pawtab%qgrid_shp)
     897              :  end if
     898         2155 :  if (allocated(Pawtab%qijl))  then
     899          721 :    LIBPAW_DEALLOCATE(Pawtab%qijl)
     900              :  end if
     901         2155 :  if (allocated(Pawtab%rad_for_spline))  then
     902            3 :    LIBPAW_DEALLOCATE(Pawtab%rad_for_spline)
     903              :  end if
     904         2155 :  if (allocated(Pawtab%rhoij0))  then
     905          721 :    LIBPAW_DEALLOCATE(Pawtab%rhoij0)
     906              :  end if
     907         2155 :  if (allocated(Pawtab%shape_alpha))  then
     908          137 :    LIBPAW_DEALLOCATE(Pawtab%shape_alpha)
     909              :  end if
     910         2155 :  if (allocated(Pawtab%shape_q))  then
     911          137 :    LIBPAW_DEALLOCATE(Pawtab%shape_q)
     912              :  end if
     913         2155 :  if (allocated(Pawtab%shapefunc))  then
     914          721 :    LIBPAW_DEALLOCATE(Pawtab%shapefunc)
     915              :  end if
     916         2155 :  if (allocated(Pawtab%shapefncg))  then
     917            0 :    LIBPAW_DEALLOCATE(Pawtab%shapefncg)
     918              :  end if
     919         2155 :  if (allocated(Pawtab%sij))  then
     920          721 :    LIBPAW_DEALLOCATE(Pawtab%sij)
     921              :  end if
     922         2155 :  if (allocated(Pawtab%tcoredens))  then
     923          721 :    LIBPAW_DEALLOCATE(Pawtab%tcoredens)
     924              :  end if
     925         2155 :  if (allocated(Pawtab%tcoretau))  then
     926           17 :    LIBPAW_DEALLOCATE(Pawtab%tcoretau)
     927              :  end if
     928         2155 :  if (allocated(Pawtab%tcorespl))  then
     929          721 :    LIBPAW_DEALLOCATE(Pawtab%tcorespl)
     930              :  end if
     931         2155 :  if (allocated(Pawtab%tcoretauspl))  then
     932          215 :    LIBPAW_DEALLOCATE(Pawtab%tcoretauspl)
     933              :  end if
     934         2155 :  if (allocated(Pawtab%tnablaphi))  then
     935           17 :    LIBPAW_DEALLOCATE(Pawtab%tnablaphi)
     936              :  end if
     937         2155 :  if (allocated(Pawtab%tphi))  then
     938          721 :    LIBPAW_DEALLOCATE(Pawtab%tphi)
     939              :  end if
     940         2155 :  if (allocated(Pawtab%tphitphj))  then
     941          721 :    LIBPAW_DEALLOCATE(Pawtab%tphitphj)
     942              :  end if
     943         2155 :  if (allocated(Pawtab%tproj)) then
     944            3 :    LIBPAW_DEALLOCATE(Pawtab%tproj)
     945              :  end if
     946         2155 :  if (allocated(Pawtab%tvalespl))  then
     947          522 :    LIBPAW_DEALLOCATE(Pawtab%tvalespl)
     948              :  end if
     949         2155 :  if (allocated(Pawtab%vee))  then
     950           97 :    LIBPAW_DEALLOCATE(Pawtab%vee)
     951              :  end if
     952         2155 :  if (allocated(Pawtab%Vex))  then
     953            1 :    LIBPAW_DEALLOCATE(Pawtab%Vex)
     954              :  end if
     955         2155 :  if (allocated(Pawtab%vhtnzc))  then
     956          721 :    LIBPAW_DEALLOCATE(Pawtab%vhtnzc)
     957              :  end if
     958         2155 :  if (allocated(Pawtab%VHnZC))  then
     959          721 :    LIBPAW_DEALLOCATE(Pawtab%VHnZC)
     960              :  end if
     961         2155 :  if (allocated(Pawtab%vminushalf))  then
     962            2 :    LIBPAW_DEALLOCATE(Pawtab%vminushalf)
     963              :  end if
     964         2155 :  if (allocated(Pawtab%zioneff))  then
     965           98 :    LIBPAW_DEALLOCATE(Pawtab%zioneff)
     966              :  end if
     967              : 
     968         2155 :  call wvlpaw_free(Pawtab%wvl)
     969              : 
     970              :  ! === Reset all flags and sizes ===
     971              : 
     972              : !CAUTION: do not reset these flags
     973              : !They are set from input data and must be kept
     974              : !Pawtab%has_kij=0
     975              : !Pawtab%has_tproj=0
     976              : !Pawtab%has_coretau=0
     977              : !Pawtab%has_tvale=0
     978              : !Pawtab%has_vhtnzc=0
     979              : !Pawtab%has_vhnzc=0
     980              : !Pawtab%has_vminushalf=0
     981              : !Pawtab%has_nabla=0
     982              : !Pawtab%has_nablaphi=0
     983              : !Pawtab%has_shapefncg=0
     984              : !Pawtab%has_wvl=0
     985              : 
     986         2155 :  Pawtab%usetcore=0
     987         2155 :  Pawtab%usexcnhat=0
     988         2155 :  Pawtab%useexexch=0
     989         2155 :  Pawtab%usepawu=0
     990         2155 :  Pawtab%usepotzero=0
     991         2155 :  Pawtab%usespnorb=0
     992         2155 :  Pawtab%mqgrid=0
     993         2155 :  Pawtab%mqgrid_shp=0
     994              : 
     995         2155 :  Pawtab%basis_size=0
     996         2155 :  Pawtab%ij_proj=0
     997         2155 :  Pawtab%ij_size=0
     998         2155 :  Pawtab%lcut_size=0
     999         2155 :  Pawtab%l_size=0
    1000         2155 :  Pawtab%lexexch=-1
    1001         2155 :  Pawtab%lmn_size=0
    1002         2155 :  Pawtab%lmn2_size=0
    1003         2155 :  Pawtab%lmnmix_sz=0
    1004         2155 :  Pawtab%lpawu=-1
    1005         2155 :  Pawtab%nproju=0
    1006         2155 :  Pawtab%option_interaction_pawu=0
    1007         2155 :  Pawtab%mesh_size=0
    1008         2155 :  Pawtab%partialwave_mesh_size=0
    1009         2155 :  Pawtab%core_mesh_size=0
    1010         2155 :  Pawtab%coretau_mesh_size=0
    1011         2155 :  Pawtab%vminus_mesh_size=0
    1012         2155 :  Pawtab%tnvale_mesh_size=0
    1013         2155 :  Pawtab%shape_type=-10
    1014              : 
    1015         2155 : end subroutine pawtab_free_0D
    1016              : !!***
    1017              : 
    1018              : !----------------------------------------------------------------------
    1019              : 
    1020              : !!****f* m_pawtab/pawtab_free_1D
    1021              : !! NAME
    1022              : !!  pawtab_free_1D
    1023              : !!
    1024              : !! FUNCTION
    1025              : !!  Destroy (deallocate) all pointers in an array of pawtab data structures
    1026              : !!
    1027              : !! SOURCE
    1028              : 
    1029         5808 : subroutine pawtab_free_1D(Pawtab)
    1030              : 
    1031              : !Arguments ------------------------------------
    1032              :  type(pawtab_type),intent(inout) :: Pawtab(:)
    1033              : 
    1034              : !Local variables-------------------------------
    1035              :  integer :: ii,nn
    1036              : 
    1037              : ! *************************************************************************
    1038              : 
    1039              :  !@pawtab_type
    1040              : 
    1041         5808 :  nn=size(Pawtab)
    1042         5808 :  if (nn==0) return
    1043              : 
    1044         2684 :  do ii=1,nn
    1045         2684 :    call pawtab_free_0D(Pawtab(ii))
    1046              :  end do
    1047              : 
    1048              : end subroutine pawtab_free_1D
    1049              : !!***
    1050              : 
    1051              : !----------------------------------------------------------------------
    1052              : 
    1053              : !!****f* m_pawtab/pawtab_set_flags_0D
    1054              : !! NAME
    1055              : !!  pawtab_set_flags_0D
    1056              : !!
    1057              : !! FUNCTION
    1058              : !!  Set flags controlling optional arrays in a pawtab datastructure
    1059              : !!
    1060              : !! SOURCE
    1061              : 
    1062            0 : subroutine pawtab_set_flags_0D(Pawtab,has_coretau,has_fock,has_kij,has_tproj,has_tvale,has_vhnzc,&
    1063              : &                              has_vhtnzc,has_nabla,has_nablaphi,has_shapefncg,has_vminushalf,has_wvl,&
    1064              : &                              add_core_energy)
    1065              : 
    1066              : !Arguments ------------------------------------
    1067              :  integer,intent(in),optional :: has_coretau,add_core_energy,has_fock,has_kij,has_tproj,has_tvale
    1068              :  integer,intent(in),optional :: has_vhnzc,has_vhtnzc,has_vminushalf
    1069              :  integer,intent(in),optional :: has_nabla,has_nablaphi,has_shapefncg,has_wvl
    1070              :  type(pawtab_type),intent(inout) :: Pawtab
    1071              : 
    1072              : !Local variables-------------------------------
    1073              : 
    1074              : ! *************************************************************************
    1075              : 
    1076              :  !@pawtab_type
    1077              : 
    1078            0 :  Pawtab%has_fock      =0
    1079            0 :  Pawtab%has_kij       =0
    1080            0 :  Pawtab%has_tproj     =0
    1081            0 :  Pawtab%has_tvale     =0
    1082            0 :  Pawtab%has_coretau   =0
    1083            0 :  Pawtab%has_vhnzc     =0
    1084            0 :  Pawtab%has_vhtnzc    =0
    1085            0 :  Pawtab%has_nabla     =0
    1086            0 :  Pawtab%has_nablaphi  =0
    1087            0 :  Pawtab%has_shapefncg =0
    1088            0 :  Pawtab%has_vminushalf=0
    1089            0 :  Pawtab%has_wvl       =0
    1090            0 :  Pawtab%add_core_energy=0
    1091            0 :  if (present(has_fock))      Pawtab%has_fock=has_fock
    1092            0 :  if (present(has_kij))       Pawtab%has_kij=has_kij
    1093            0 :  if (present(has_tproj))     Pawtab%has_tproj=has_tproj
    1094            0 :  if (present(has_tvale))     Pawtab%has_tvale=has_tvale
    1095            0 :  if (present(has_coretau))   Pawtab%has_coretau=has_coretau
    1096            0 :  if (present(has_vhnzc))     Pawtab%has_vhnzc=has_vhnzc
    1097            0 :  if (present(has_vhtnzc))    Pawtab%has_vhtnzc=has_vhtnzc
    1098            0 :  if (present(has_nabla))     Pawtab%has_nabla=has_nabla
    1099            0 :  if (present(has_nablaphi))  Pawtab%has_nablaphi=has_nablaphi
    1100            0 :  if (present(has_shapefncg) )Pawtab%has_shapefncg=has_shapefncg
    1101            0 :  if (present(has_vminushalf))Pawtab%has_vminushalf=has_vminushalf
    1102            0 :  if (present(has_wvl))       Pawtab%has_wvl=has_wvl
    1103            0 :  if (present(add_core_energy)) Pawtab%add_core_energy=add_core_energy
    1104              : 
    1105            0 : end subroutine pawtab_set_flags_0D
    1106              : !!***
    1107              : 
    1108              : !----------------------------------------------------------------------
    1109              : 
    1110              : !!****f* m_pawtab/pawtab_set_flags_1D
    1111              : !! NAME
    1112              : !!  pawtab_set_flags_1D
    1113              : !!
    1114              : !! FUNCTION
    1115              : !!  Set flags controlling optional arrays in an array of pawtab datastructures
    1116              : !! if (present(has_tvale))    Pawtab%has_tvale=has_tvale
    1117              : 
    1118              : !! SOURCE
    1119              : 
    1120          523 : subroutine pawtab_set_flags_1D(Pawtab,has_coretau,has_fock,has_kij,has_tproj,has_tvale,has_vhnzc,&
    1121              : &                              has_vhtnzc,has_nabla,has_nablaphi,has_shapefncg,has_vminushalf,has_wvl,&
    1122              : &                              add_core_energy)
    1123              : 
    1124              : !Arguments ------------------------------------
    1125              :  integer,intent(in),optional :: has_coretau,add_core_energy,has_fock,has_kij,has_tproj,has_tvale,has_vhnzc,has_vhtnzc
    1126              :  integer,intent(in),optional :: has_nabla,has_nablaphi,has_shapefncg,has_vminushalf,has_wvl
    1127              :  type(pawtab_type),intent(inout) :: Pawtab(:)
    1128              : 
    1129              : !Local variables-------------------------------
    1130              :  integer :: ii,nn
    1131              : 
    1132              : ! *************************************************************************
    1133              : 
    1134              :  !@pawtab_type
    1135              : 
    1136          523 :  nn=size(Pawtab)
    1137          523 :  if (nn==0) return
    1138              : 
    1139         1266 :  do ii=1,nn
    1140          743 :    Pawtab(ii)%has_fock      =0
    1141          743 :    Pawtab(ii)%has_kij       =0
    1142          743 :    Pawtab(ii)%has_tproj     =0
    1143          743 :    Pawtab(ii)%has_tvale     =0
    1144          743 :    Pawtab(ii)%has_coretau   =0
    1145          743 :    Pawtab(ii)%has_vhnzc     =0
    1146          743 :    Pawtab(ii)%has_vhtnzc    =0
    1147          743 :    Pawtab(ii)%has_nabla     =0
    1148          743 :    Pawtab(ii)%has_nablaphi  =0
    1149          743 :    Pawtab(ii)%has_shapefncg =0
    1150          743 :    Pawtab(ii)%has_vminushalf=0
    1151          743 :    Pawtab(ii)%has_wvl       =0
    1152          743 :    Pawtab(ii)%add_core_energy=0
    1153          743 :    if (present(has_fock))      Pawtab(ii)%has_fock=has_fock
    1154          743 :    if (present(has_kij))       Pawtab(ii)%has_kij=has_kij
    1155          743 :    if (present(has_tproj))     Pawtab(ii)%has_tproj=has_tproj
    1156          743 :    if (present(has_tvale))     Pawtab(ii)%has_tvale=has_tvale
    1157          743 :    if (present(has_coretau))   Pawtab(ii)%has_coretau=has_coretau
    1158          743 :    if (present(has_vhnzc))     Pawtab(ii)%has_vhnzc=has_vhnzc
    1159          743 :    if (present(has_vhtnzc))    Pawtab(ii)%has_vhtnzc=has_vhtnzc
    1160          743 :    if (present(has_nabla))     Pawtab(ii)%has_nabla=has_nabla
    1161          743 :    if (present(has_nablaphi))  Pawtab(ii)%has_nablaphi=has_nablaphi
    1162          743 :    if (present(has_shapefncg)) Pawtab(ii)%has_shapefncg=has_shapefncg
    1163          743 :    if (present(has_vminushalf))Pawtab(ii)%has_vminushalf=has_vminushalf
    1164          743 :    if (present(has_wvl))       Pawtab(ii)%has_wvl=has_wvl
    1165         1266 :    if (present(add_core_energy)) Pawtab(ii)%add_core_energy=add_core_energy
    1166              :  end do
    1167              : 
    1168              : end subroutine pawtab_set_flags_1D
    1169              : !!***
    1170              : 
    1171              : !----------------------------------------------------------------------
    1172              : 
    1173              : !!****f* m_pawtab/pawtab_print
    1174              : !! NAME
    1175              : !! pawtab_print
    1176              : !!
    1177              : !! FUNCTION
    1178              : !!  Print out the content of a pawtab datastructure
    1179              : !!
    1180              : !! INPUTS
    1181              : !!  Pawtab<pawtab_type> Only for PAW, TABulated data initialized at start
    1182              : !!
    1183              : !! OUTPUT
    1184              : !!  Only writing
    1185              : !!
    1186              : !! SOURCE
    1187              : 
    1188           26 : subroutine pawtab_print(Pawtab,header,unit,prtvol,mode_paral)
    1189              : 
    1190              : !Arguments ------------------------------------
    1191              : !scalars
    1192              :  integer,optional,intent(in) :: unit,prtvol
    1193              :  character(len=4),optional,intent(in) :: mode_paral
    1194              :  character(len=*),optional,intent(in) :: header
    1195              : !arrays
    1196              :  type(Pawtab_type) :: Pawtab(:)
    1197              : 
    1198              : !Local variables-------------------------------
    1199              : !scalars
    1200              :  integer :: ityp,ntypat,my_unt,my_prtvol
    1201              :  character(len=4) :: my_mode
    1202              :  character(len=500) :: msg
    1203              : 
    1204              : ! *************************************************************************
    1205              : 
    1206           13 :  my_unt   =ab_out ; if (PRESENT(unit      )) my_unt   =unit
    1207           13 :  my_prtvol=0      ; if (PRESENT(prtvol    )) my_prtvol=prtvol
    1208           13 :  my_mode  ='COLL' ; if (PRESENT(mode_paral)) my_mode  =mode_paral
    1209              : 
    1210              :  write(msg,'(6a)')&
    1211           13 : &  ' ==================================== ',ch10,&
    1212           13 : &  ' ==== Info on PAW TABulated data ==== ',ch10,&
    1213           26 : &  ' ==================================== ',ch10
    1214           13 :  if (PRESENT(header)) msg=' ==== '//TRIM(ADJUSTL(header))//' ==== '
    1215           13 :  call wrtout(my_unt,msg,my_mode)
    1216              : 
    1217           13 :  ntypat=SIZE(Pawtab(:))
    1218              : 
    1219           34 :  do ityp=1,ntypat
    1220              : 
    1221              :   ! Print out integer values (dimensions)
    1222           21 :   write(msg,'(a)')'                                 '
    1223           21 :   call wrtout(my_unt,msg,my_mode)
    1224           21 :   write(msg,'(a)')'  ****************************** '
    1225           21 :   call wrtout(my_unt,msg,my_mode)
    1226           21 :   write(msg,'(a,i4,a)')'  **** Atom type ',ityp,' ****   '
    1227           21 :   call wrtout(my_unt,msg,my_mode)
    1228           21 :   write(msg,'(a)')'  ****************************** '
    1229           21 :   call wrtout(my_unt,msg,my_mode)
    1230           21 :   write(msg,'(a,i4)')'  Number of (n,l) elements ....................... ',Pawtab(ityp)%basis_size
    1231           21 :   call wrtout(my_unt,msg,my_mode)
    1232           21 :   write(msg,'(a,i4)')'  Number of (l,m,n) elements ..................... ',Pawtab(ityp)%lmn_size
    1233           21 :   call wrtout(my_unt,msg,my_mode)
    1234           21 :   write(msg,'(a,i4)')'  Number of (i,j) elements (packed form) ......... ',Pawtab(ityp)%ij_size
    1235           21 :   call wrtout(my_unt,msg,my_mode)
    1236           21 :   write(msg,'(a,i4)')'  Max L+1 leading to non-zero Gaunt .............. ',Pawtab(ityp)%l_size
    1237           21 :   call wrtout(my_unt,msg,my_mode)
    1238           21 :   write(msg,'(a,i4)')'  Max L+1 leading to non-zero Gaunt (pawlcutd) ... ',Pawtab(ityp)%lcut_size
    1239           21 :   call wrtout(my_unt,msg,my_mode)
    1240           21 :   write(msg,'(a,i4)')'  lmn2_size ...................................... ',Pawtab(ityp)%lmn2_size
    1241           21 :   call wrtout(my_unt,msg,my_mode)
    1242           21 :   write(msg,'(a,i4)')'  lmnmix_sz ...................................... ',Pawtab(ityp)%lmnmix_sz
    1243           21 :   call wrtout(my_unt,msg,my_mode)
    1244           21 :   write(msg,'(a,i4)')'  Size of radial mesh ............................ ',Pawtab(ityp)%mesh_size
    1245           21 :   call wrtout(my_unt,msg,my_mode)
    1246           21 :   write(msg,'(a,i4)')'  Size of radial mesh for partial waves .......... ',Pawtab(ityp)%partialwave_mesh_size
    1247           21 :   call wrtout(my_unt,msg,my_mode)
    1248           21 :   write(msg,'(a,i4)')'  Size of radial mesh for [pseudo] core density .. ',Pawtab(ityp)%core_mesh_size
    1249           21 :   call wrtout(my_unt,msg,my_mode)
    1250           21 :   write(msg,'(a,i4)')'  Size of radial mesh for [pseudo] kincore density ',Pawtab(ityp)%coretau_mesh_size
    1251           21 :   call wrtout(my_unt,msg,my_mode)
    1252           21 :   write(msg,'(a,i4)')'  Size of radial mesh for pseudo valence density . ',Pawtab(ityp)%tnvale_mesh_size
    1253           21 :   call wrtout(my_unt,msg,my_mode)
    1254           21 :   write(msg,'(a,i4)')'  No of Q-points for tcorespl/tvalespl/tcoretauspl ',Pawtab(ityp)%mqgrid
    1255           21 :   call wrtout(my_unt,msg,my_mode)
    1256           21 :   write(msg,'(a,i4)')'  No of Q-points for the radial shape functions .. ',Pawtab(ityp)%mqgrid_shp
    1257           21 :   call wrtout(my_unt,msg,my_mode)
    1258           21 :   write(msg,'(a,i4)')'  Radial shape function type ..................... ',Pawtab(ityp)%shape_type
    1259           21 :   call wrtout(my_unt,msg,my_mode)
    1260           21 :   write(msg,'(a,i4)')'  shape_lambda ................................... ',Pawtab(ityp)%shape_lambda
    1261           21 :   call wrtout(my_unt,msg,my_mode)
    1262           21 :   write(msg,'(a,i4)')'  Use pseudized core density ..................... ',Pawtab(ityp)%usetcore
    1263           21 :   call wrtout(my_unt,msg,my_mode)
    1264           21 :   write(msg,'(a,i4)')'  Option for the use of hat density in XC terms .. ',Pawtab(ityp)%usexcnhat
    1265           21 :   call wrtout(my_unt,msg,my_mode)
    1266           21 :   write(msg,'(a,i4)')'  Use DFT+U ...................................... ',Pawtab(ityp)%usepawu
    1267           21 :   call wrtout(my_unt,msg,my_mode)
    1268           21 :   if (Pawtab(ityp)%usepawu/=0) then
    1269            0 :     write(msg,'(a,i4)')'  L on which U is applied ........................ ',Pawtab(ityp)%lpawu
    1270            0 :     call wrtout(my_unt,msg,my_mode)
    1271              :   end if
    1272           21 :   write(msg,'(a,i4)')'  Use Local Exact exchange ....................... ',Pawtab(ityp)%useexexch
    1273           21 :   call wrtout(my_unt,msg,my_mode)
    1274           21 :   if (Pawtab(ityp)%useexexch/=0) then
    1275            0 :     write(msg,'(a,i4)')'  L on which local exact-exchange is applied ..... ',Pawtab(ityp)%lexexch
    1276            0 :     call wrtout(my_unt,msg,my_mode)
    1277              :   end if
    1278           21 :   if (Pawtab(ityp)%usepawu/=0.or.Pawtab(ityp)%useexexch/=0) then
    1279            0 :     write(msg,'(a,i4)')'  Number of (i,j) elements for PAW+U or EXX ...... ',Pawtab(ityp)%ij_proj
    1280            0 :     call wrtout(my_unt,msg,my_mode)
    1281            0 :     write(msg,'(a,i4)')'  Number of projectors on which U or EXX acts .... ',Pawtab(ityp)%nproju
    1282            0 :     call wrtout(my_unt,msg,my_mode)
    1283            0 :     write(msg,'(a,i4)')'  Option interaction for PAW+U (double-counting) . ',Pawtab(ityp)%option_interaction_pawu
    1284            0 :     call wrtout(my_unt,msg,my_mode)
    1285              :   end if
    1286           21 :   write(msg,'(a,i4)')'  Use potential zero ............................. ',Pawtab(ityp)%usepotzero
    1287           21 :   call wrtout(my_unt,msg,my_mode)
    1288           21 :   write(msg,'(a,i4)')'  Use spin-orbit coupling ........................ ',Pawtab(ityp)%usespnorb
    1289           21 :   call wrtout(my_unt,msg,my_mode)
    1290              : 
    1291              :   ! "Has" flags
    1292           21 :   write(msg,'(a,i4)')'  Has Fock  ...................................... ',Pawtab(ityp)%has_fock
    1293           21 :   call wrtout(my_unt,msg,my_mode)
    1294           21 :   write(msg,'(a,i4)')'  Has kij   ...................................... ',Pawtab(ityp)%has_kij
    1295           21 :   call wrtout(my_unt,msg,my_mode)
    1296           21 :   write(msg,'(a,i4)')'  Has tproj ...................................... ',Pawtab(ityp)%has_tproj
    1297           21 :   call wrtout(my_unt,msg,my_mode)
    1298           21 :   write(msg,'(a,i4)')'  Has tvale ...................................... ',Pawtab(ityp)%has_tvale
    1299           21 :   call wrtout(my_unt,msg,my_mode)
    1300           21 :   write(msg,'(a,i4)')'  Has coretau .................................... ',Pawtab(ityp)%has_coretau
    1301           21 :   call wrtout(my_unt,msg,my_mode)
    1302           21 :   write(msg,'(a,i4)')'  Has vhtnzc ..................................... ',Pawtab(ityp)%has_vhtnzc
    1303           21 :   call wrtout(my_unt,msg,my_mode)
    1304           21 :   write(msg,'(a,i4)')'  Has vhnzc ...................................... ',Pawtab(ityp)%has_vhnzc
    1305           21 :   call wrtout(my_unt,msg,my_mode)
    1306           21 :   write(msg,'(a,i4)')'  Has vminushalf ................................. ',Pawtab(ityp)%has_vminushalf
    1307           21 :   call wrtout(my_unt,msg,my_mode)
    1308           21 :   write(msg,'(a,i4)')'  Has nabla ...................................... ',Pawtab(ityp)%has_nabla
    1309           21 :   call wrtout(my_unt,msg,my_mode)
    1310           21 :   write(msg,'(a,i4)')'  Has nablaphi ................................... ',Pawtab(ityp)%has_nablaphi
    1311           21 :   call wrtout(my_unt,msg,my_mode)
    1312           21 :   write(msg,'(a,i4)')'  Has shapefuncg ................................. ',Pawtab(ityp)%has_shapefncg
    1313           21 :   call wrtout(my_unt,msg,my_mode)
    1314           21 :   write(msg,'(a,i4)')'  Has wvl ........................................ ',Pawtab(ityp)%has_wvl
    1315           21 :   call wrtout(my_unt,msg,my_mode)
    1316           21 :   write(msg,'(a,i4)')'  Add core energy ................................ ',Pawtab(ityp)%add_core_energy
    1317           21 :   call wrtout(my_unt,msg,my_mode)
    1318              :   !
    1319              :   ! Real scalars
    1320           21 :   write(msg,'(a,es16.8)')'  beta ........................................',Pawtab(ityp)%beta
    1321           21 :   call wrtout(my_unt,msg,my_mode)
    1322           21 :   write(msg,'(a,es16.8)')'  1/q d(tNcore(q))/dq for q=0 .................',Pawtab(ityp)%dncdq0
    1323           21 :   call wrtout(my_unt,msg,my_mode)
    1324           21 :   write(msg,'(a,es16.8)')'  d^2(tNcore(q))/dq^2 for q=0 .................',Pawtab(ityp)%d2ncdq0
    1325           21 :   call wrtout(my_unt,msg,my_mode)
    1326           21 :   write(msg,'(a,es16.8)')'  1/q d(tNvale(q))/dq for q=0 .................',Pawtab(ityp)%dnvdq0
    1327           21 :   call wrtout(my_unt,msg,my_mode)
    1328           21 :   if (Pawtab(ityp)%has_coretau/=0) then
    1329            0 :     write(msg,'(a,es16.8)')'  1/q d(tTAUcore(q))/dq for q=0 ...............',Pawtab(ityp)%dtaucdq0
    1330            0 :     call wrtout(my_unt,msg,my_mode)
    1331              :   end if
    1332           21 :   if (Pawtab(ityp)%has_fock/=0) then
    1333            0 :     write(msg,'(a,es16.8)')'  Core-core Fock energy  ......................',Pawtab(ityp)%ex_cc
    1334            0 :     call wrtout(my_unt,msg,my_mode)
    1335              :   end if
    1336           21 :   write(msg,'(a,es16.8)')'  XC energy for the core density ..............',Pawtab(ityp)%exccore
    1337           21 :   call wrtout(my_unt,msg,my_mode)
    1338           21 :   write(msg,'(a,es16.8)')'  Kinetic energy for the core density .........',Pawtab(ityp)%ekincore
    1339           21 :   call wrtout(my_unt,msg,my_mode)
    1340           21 :   if(abs(Pawtab(ityp)%sxccore)>tiny(zero)) then
    1341            0 :     write(msg,'(a,es16.8)')'  XC entropy for the core density .............',Pawtab(ityp)%sxccore
    1342            0 :     call wrtout(my_unt,msg,my_mode)
    1343              :   end if
    1344           21 :   write(msg,'(a,es16.8)')'  EH(n_Zc) ....................................',Pawtab(ityp)%ehnzc
    1345           21 :   call wrtout(my_unt,msg,my_mode)
    1346           21 :   write(msg,'(a,es16.8)')'  Lamb shielding due to core density ..........',Pawtab(ityp)%lamb_shielding
    1347           21 :   call wrtout(my_unt,msg,my_mode)
    1348           21 :   write(msg,'(a,es16.8)')'  Radius of the PAW sphere ....................',Pawtab(ityp)%rpaw
    1349           21 :   call wrtout(my_unt,msg,my_mode)
    1350           21 :   write(msg,'(a,es16.8)')'  Compensation charge radius (if >rshp,g(r)=0) ',Pawtab(ityp)%rshp !(if r>rshp, g(r)=zero)
    1351           21 :   call wrtout(my_unt,msg,my_mode)
    1352           21 :   if (Pawtab(ityp)%shape_type==2) then
    1353           17 :     write(msg,'(a,es16.8)')'  Sigma parameter in gaussian shape function ..',Pawtab(ityp)%shape_sigma !(shape_type=2)
    1354           17 :     call wrtout(my_unt,msg,my_mode)
    1355              :   end if
    1356           21 :   if (Pawtab(ityp)%usepawu/=0) then
    1357            0 :     write(msg,'(a,es16.8)')'  Value of the U parameter [eV] ...............',Pawtab(ityp)%upawu*Ha_eV
    1358            0 :     call wrtout(my_unt,msg,my_mode)
    1359            0 :     write(msg,'(a,es16.8)')'  Value of the J parameter [eV] ...............',Pawtab(ityp)%jpawu*Ha_eV
    1360            0 :     call wrtout(my_unt,msg,my_mode)
    1361              :   end if
    1362           21 :   if (Pawtab(ityp)%useexexch/=0) then
    1363            0 :     write(msg,'(a,es16.8)')'  Mixing of exact exchange (PBE0) .............',Pawtab(ityp)%exchmix
    1364            0 :     call wrtout(my_unt,msg,my_mode)
    1365              :   end if
    1366           34 :   if (associated(Pawtab(ityp)%wvl)) then
    1367            0 :     write(msg,'(a,es16.8)')'  WARNING: This Pawtab structure contains WVL data.'
    1368            0 :     call wrtout(my_unt,msg,my_mode)
    1369              :   end if
    1370              : 
    1371              :  end do ! ityp
    1372              : 
    1373              :  ! The other (huge) arrays are not reported..
    1374              : 
    1375           13 : end subroutine pawtab_print
    1376              : !!***
    1377              : 
    1378              : !----------------------------------------------------------------------
    1379              : 
    1380              : !!****f* m_pawtap/pawtab_get_lsize
    1381              : !! NAME
    1382              : !!  pawtab_get_lsize
    1383              : !!
    1384              : !! FUNCTION
    1385              : !!  From an array of pawtab datastructures, get, for each atom, the value
    1386              : !!  of "l_size" parameter.
    1387              : !!  l_size is the maximum value of l accessible by a product of 2 partial waves;
    1388              : !!  it may be cut by dtset%pawlcutd parameter
    1389              : !!
    1390              : !! INPUTS
    1391              : !!   [mpi_atmtab(:)]=--optional-- indexes of the atoms treated by current proc
    1392              : !!   natom= number of atoms (may be a local or absolute number of atoms)
    1393              : !!   typat(:)= list of atom types
    1394              : !!
    1395              : !! OUTPUT
    1396              : !!   l_size_atm(natom)=output array of l_size values (for each atom)
    1397              : !!
    1398              : !! NOTES
    1399              : !!  This function returns an allocatable integer array which may be allocated
    1400              : !!  on the fly.
    1401              : !!
    1402              : !! SOURCE
    1403              : 
    1404         1531 : subroutine pawtab_get_lsize(Pawtab,l_size_atm,natom,typat, &
    1405         1531 : &                           mpi_atmtab) ! Optional argument
    1406              : 
    1407              : !Arguments ------------------------------------
    1408              : !scalars
    1409              :  integer,intent(in) :: natom
    1410              : !arrays
    1411              :  integer,intent(in) :: typat(:)
    1412              :  integer,optional,intent(in) :: mpi_atmtab(:)
    1413              :  integer,allocatable,intent(inout) :: l_size_atm(:)
    1414              :  type(pawtab_type),intent(in) :: pawtab(:)
    1415              : 
    1416              : !Local variables-------------------------------
    1417              :  integer :: ia,ityp,natom_typat
    1418              :  character(len=100) :: msg
    1419              : 
    1420              : ! *************************************************************************
    1421              : 
    1422              :  !@pawtab_type
    1423              : 
    1424         5778 :  natom_typat=count(typat>0)
    1425         5778 :  if (size(pawtab)<maxval(typat)) then
    1426            0 :    msg='error on pawtab size!'
    1427            0 :    LIBPAW_BUG(msg)
    1428              :  end if
    1429              : 
    1430         1531 :  if (.not.allocated(l_size_atm)) then
    1431         4593 :    LIBPAW_ALLOCATE(l_size_atm,(natom))
    1432            0 :  else if (size(l_size_atm)/=natom) then
    1433            0 :    LIBPAW_DEALLOCATE(l_size_atm)
    1434            0 :    LIBPAW_ALLOCATE(l_size_atm,(natom))
    1435              :  end if
    1436              : 
    1437         1531 :  if (natom==0) return
    1438              : 
    1439         1527 :  if (natom==natom_typat) then
    1440              : 
    1441              : !First case: sequential mode
    1442         3960 :    do ia=1,natom
    1443         2879 :      ityp=typat(ia)
    1444         3960 :      l_size_atm(ia)=pawtab(ityp)%lcut_size
    1445              :    end do
    1446              : 
    1447              :  else
    1448              : 
    1449              : !2nd case: parallel mode
    1450          446 :    if (.not.present(mpi_atmtab)) then
    1451            0 :      msg='optional args error!'
    1452            0 :      LIBPAW_BUG(msg)
    1453              :    end if
    1454         1001 :    do ia=1,natom
    1455          555 :      ityp=typat(mpi_atmtab(ia))
    1456         1001 :      l_size_atm(ia)=pawtab(ityp)%lcut_size
    1457              :    end do
    1458              : 
    1459              :  end if
    1460              : 
    1461              : end subroutine pawtab_get_lsize
    1462              : !!***
    1463              : 
    1464              : !----------------------------------------------------------------------
    1465              : 
    1466              : !!****f* m_pawtab/pawtab_bcast
    1467              : !! NAME
    1468              : !! pawtab_bcast
    1469              : !!
    1470              : !! FUNCTION
    1471              : !! Communicate pawtab data to all processors
    1472              : !!
    1473              : !! INPUTS
    1474              : !! comm_mpi= communicator used to broadcast data
    1475              : !! [only_from_file]= (optional, default=FALSE)
    1476              : !!    If true, only data obtained at the level of the reading
    1477              : !!    of the PAW dataset file are broadcasted
    1478              : !!
    1479              : !! SIDE EFFECTS
    1480              : !!  pawtab=<type pawtab_type>=a pawtab datastructure
    1481              : !!
    1482              : !! SOURCE
    1483              : 
    1484          300 : subroutine pawtab_bcast(pawtab,comm_mpi,only_from_file)
    1485              : 
    1486              : !Arguments ------------------------------------
    1487              : !scalars
    1488              :  integer,intent(in) :: comm_mpi
    1489              :  logical,optional,intent(in) :: only_from_file
    1490              :  type(pawtab_type),intent(inout) :: pawtab
    1491              : 
    1492              : !Local variables-------------------------------
    1493              : !scalars
    1494              :  integer :: ierr,ii,me,nn_dpr,nn_dpr_arr,nn_int,nn_int_arr
    1495              :  integer :: siz_indklmn,siz_indlmn,siz_klmntomn,siz_kmix,siz_lnproju,siz_orbitals
    1496              :  integer :: siz_coredens,siz_coretau,siz_dij0,siz_dltij,siz_dshpfunc,siz_eijkl,siz_eijkl_sr
    1497              :  integer :: siz_euijkl,siz_euij_fll,siz_fk,siz_gammaij,siz_gnorm,siz_fock,siz_kij
    1498              :  integer :: siz_nabla_ij,siz_nabla_im_ij,siz_nablaphi,siz_phi,siz_phiphj,siz_phiphjint
    1499              :  integer :: siz_ph0phiint,siz_proj,siz_proj2,siz_qgrid_shp,siz_qijl,siz_rad_for_spline,siz_rhoij0
    1500              :  integer :: siz_shape_alpha,siz_shape_q,siz_shapefunc,siz_shapefncg,siz_sij,siz_tcoredens
    1501              :  integer :: siz_tcoretau,siz_tcorespl,siz_tcoretauspl,siz_tnablaphi,siz_tphi,siz_tphitphj
    1502              :  integer :: siz_tproj,siz_tvalespl,siz_vee,siz_vex,siz_vhtnzc,siz_vhnzc,siz_vminushalf
    1503              :  integer :: siz_zioneff,siz_wvlpaw,siz_wvl_pngau,siz_wvl_parg,siz_wvl_pfac
    1504              :  integer :: siz_wvl_rholoc_rad,siz_wvl_rholoc_d,sz1,sz2
    1505              :  logical :: full_broadcast
    1506              :  character (len=500) :: msg,msg0
    1507              : !arrays
    1508              :  integer :: nn(4)
    1509          300 :  integer,allocatable :: list_int(:)
    1510          300 :  real(dp),allocatable :: list_dpr(:)
    1511              : 
    1512              : !*************************************************************************
    1513              : 
    1514          300 :  me=xmpi_comm_rank(comm_mpi)
    1515          300 :  full_broadcast=.true.;if (present(only_from_file)) full_broadcast=(.not.only_from_file)
    1516              : 
    1517          300 :  nn_int=0 ; nn_int_arr=0 ; nn_dpr=0 ; nn_dpr_arr=0
    1518              : 
    1519              : !=========================================================================
    1520              : !Compute the amount of data to communicate
    1521              : !=========================================================================
    1522              : 
    1523          300 :  if (me==0) then
    1524           78 :    msg=''
    1525              : 
    1526              : !Integers (read from psp file)
    1527              : !-------------------------------------------------------------------------
    1528              : !  basis_size,has_coretau,has_fock,has_kij,has_shapefncg,has_nabla,has_nablaphi,has_tproj
    1529              : !  has_tvale,has_vhtnzc,has_vhnzc,has_vminushalf,has_wvl,ij_size,l_size,lmn_size,lmn2_size
    1530              : !  mesh_size,partialwave_mesh_size,core_mesh_size,coretau_mesh_size,vminus_mesh_size
    1531              : !  tnvale_mesh_size,mqgrid,shape_lambda,shape_type,usetcore,usexcnhat
    1532           78 :    nn_int=nn_int+28
    1533              : 
    1534              : !Integers (depending on the parameters of the calculation)
    1535              : !-------------------------------------------------------------------------
    1536              : !  ij_proj,lcut_size,lexexch,lmnmix_sz,lpawu,mqgrid_shp,nproju,useexexch,usepawu,usepotzero,
    1537              : !  option_interaction_pawu,usespnorb,add_core_energy
    1538           78 :    if (full_broadcast) nn_int=nn_int+13
    1539              : 
    1540              : !Reals (read from psp file)
    1541              : !-------------------------------------------------------------------------
    1542              : !  beta,dncdq0,d2ncdq0,dnvdq0,dtaucdq0,eps,ex_cc,exccore,ekincore,sxccore,ehnzc,
    1543              : !  lamb_shielding,lambda,rpaw,rshp,rcore,rcoretau,shape_sigma
    1544              :    nn_dpr=nn_dpr+18
    1545              : 
    1546              : !Reals (depending on the parameters of the calculation)
    1547              : !-------------------------------------------------------------------------
    1548              : !  exchmix,f4of2_sla,f6of2_sla,jpawu,upawu
    1549            8 :    if (full_broadcast) nn_dpr=nn_dpr+5
    1550              : 
    1551              : !Integers arrays (read from psp file)
    1552              : !-------------------------------------------------------------------------
    1553           78 :    siz_indlmn=0 ; siz_orbitals=0
    1554           78 :    nn_int=nn_int+2
    1555           78 :    if (allocated(pawtab%indlmn)) then
    1556          210 :      siz_indlmn=size(pawtab%indlmn)                  !(6,lmn_size)
    1557           70 :      if (siz_indlmn/=6*pawtab%lmn_size) msg=trim(msg)//' indlmn'
    1558              :      nn_int_arr=nn_int_arr+siz_indlmn
    1559              :    end if
    1560           78 :    if (allocated(pawtab%orbitals)) then
    1561           70 :      siz_orbitals=size(pawtab%orbitals)              !(basis_size)
    1562           70 :      if (siz_orbitals/=pawtab%basis_size) msg=trim(msg)//' orbitals'
    1563           70 :      nn_int_arr=nn_int_arr+siz_orbitals
    1564              :    end if
    1565              : 
    1566              : !Integers arrays (depending on the parameters of the calculation)
    1567              : !-------------------------------------------------------------------------
    1568           78 :    siz_indklmn=0 ; siz_klmntomn=0 ; siz_kmix=0 ; siz_lnproju=0
    1569           78 :    if (full_broadcast) then
    1570            8 :      nn_int=nn_int+4
    1571            8 :      if (allocated(pawtab%indklmn)) then
    1572            0 :        siz_indklmn=size(pawtab%indklmn)             !(6,lmn2_size)
    1573            0 :        if (siz_indklmn/=8*pawtab%lmn2_size) msg=trim(msg)//' indklmn'
    1574            0 :        nn_int_arr=nn_int_arr+siz_indklmn
    1575              :      end if
    1576            8 :      if (allocated(pawtab%klmntomn)) then
    1577            0 :        siz_klmntomn=size(pawtab%klmntomn)           !(4,lmn2_size)
    1578            0 :        if (siz_klmntomn/=4*pawtab%lmn2_size) msg=trim(msg)//' klmntomn'
    1579            0 :        nn_int_arr=nn_int_arr+siz_klmntomn
    1580              :      end if
    1581            8 :      if (allocated(pawtab%kmix)) then
    1582            0 :        siz_kmix=size(pawtab%kmix)                   !(lmnmix_sz)
    1583            0 :        if (siz_kmix/=6*pawtab%lmnmix_sz) msg=trim(msg)//' kmix'
    1584            0 :        nn_int_arr=nn_int_arr+siz_kmix
    1585              :      end if
    1586            8 :      if (allocated(pawtab%lnproju)) then
    1587            0 :        siz_lnproju=size(pawtab%lnproju)             !(nproju)
    1588            0 :        if (siz_lnproju/=pawtab%nproju) msg=trim(msg)//' lnproju'
    1589            0 :        nn_int_arr=nn_int_arr+siz_lnproju
    1590              :      end if
    1591              :    end if ! full_broadcast
    1592              : 
    1593              : !Reals arrays (read from psp file)
    1594              : !-------------------------------------------------------------------------
    1595           78 :    siz_coredens=0 ; siz_coretau=0    ; siz_dij0=0     ; siz_kij=0        ; siz_fock=0
    1596           78 :    siz_phi=0      ; siz_rhoij0=0   ; siz_shape_alpha=0
    1597           78 :    siz_shape_q=0  ; siz_shapefunc=0  ; siz_tcoredens=0; siz_tcoretau=0
    1598           78 :    siz_tcorespl=0 ; siz_tcoretauspl=0; siz_tphi=0       ; siz_tproj=0
    1599           78 :    siz_tvalespl=0 ; siz_vhtnzc=0     ; siz_vhnzc=0    ; siz_vminushalf=0
    1600           78 :    nn_int=nn_int+20
    1601              : 
    1602           78 :    if (allocated(pawtab%coredens)) then
    1603           70 :      siz_coredens=size(pawtab%coredens)             !(core_mesh_size)
    1604           70 :      if (siz_coredens/=pawtab%core_mesh_size) &
    1605            0 : &      msg=trim(msg)//' coredens'
    1606           70 :      nn_dpr=nn_dpr+siz_coredens
    1607              :    end if
    1608           78 :    if (allocated(pawtab%coretau)) then
    1609            2 :      siz_coretau=size(pawtab%coretau)             !(coretau_mesh_size)
    1610            2 :      if (siz_coretau/=pawtab%coretau_mesh_size) &
    1611            0 : &      msg=trim(msg)//' coretau'
    1612            2 :      nn_dpr=nn_dpr+siz_coretau
    1613              :    end if
    1614           78 :    if (allocated(pawtab%dij0)) then
    1615           78 :      siz_dij0=size(pawtab%dij0)                     !(lmn2_size)
    1616           78 :      if (siz_dij0/=pawtab%lmn2_size) msg=trim(msg)//' dij0'
    1617           78 :      nn_dpr=nn_dpr+siz_dij0
    1618              :    end if
    1619           78 :    if (allocated(pawtab%ex_cvij)) then
    1620           29 :      siz_fock=size(pawtab%ex_cvij)                  !(lmn2_size)
    1621           29 :      if (siz_fock/=pawtab%lmn2_size) msg=trim(msg)//' fock'
    1622           29 :      nn_dpr=nn_dpr+siz_fock
    1623              :    end if
    1624           78 :    if (allocated(pawtab%kij)) then
    1625            0 :      siz_kij=size(pawtab%kij)                       !(lmn2_size)
    1626            0 :      if (siz_kij/=pawtab%lmn2_size) msg=trim(msg)//' kij'
    1627            0 :      nn_dpr=nn_dpr+siz_kij
    1628              :    end if
    1629           78 :    if (allocated(pawtab%phi)) then
    1630          210 :      siz_phi=size(pawtab%phi)                       !(partialwave_mesh_size, basis_size)
    1631           70 :      if (siz_phi/=pawtab%partialwave_mesh_size*pawtab%basis_size) msg=trim(msg)//' phi'
    1632           70 :      nn_dpr=nn_dpr+siz_phi
    1633              :    end if
    1634           78 :    if (allocated(pawtab%rhoij0)) then
    1635           70 :      siz_rhoij0=size(pawtab%rhoij0)                 !(lmn2_size)
    1636           70 :      if (siz_rhoij0/=pawtab%lmn2_size) msg=trim(msg)//' rhoij0'
    1637           70 :      nn_dpr=nn_dpr+siz_rhoij0
    1638              :    end if
    1639           78 :    if (allocated(pawtab%shape_alpha)) then
    1640           21 :      siz_shape_alpha=size(pawtab%shape_alpha)       !(2,l_size)
    1641            7 :      if (siz_shape_alpha/=pawtab%l_size*2) msg=trim(msg)//' shape_alpha'
    1642            7 :      nn_dpr=nn_dpr+siz_shape_alpha
    1643              :    end if
    1644           78 :    if (allocated(pawtab%shape_q)) then
    1645           21 :      siz_shape_q=size(pawtab%shape_q)               !(2,l_size)
    1646            7 :      if (siz_shape_q/=pawtab%l_size*2) msg=trim(msg)//' shape_q'
    1647            7 :      nn_dpr=nn_dpr+siz_shape_q
    1648              :    end if
    1649           78 :    if (allocated(pawtab%shapefunc)) then
    1650            0 :      siz_shapefunc=size(pawtab%shapefunc)           !(mesh_size,l_size)
    1651            0 :      if (siz_shapefunc/=pawtab%mesh_size*pawtab%l_size) msg=trim(msg)//' shapefunc'
    1652            0 :      nn_dpr=nn_dpr+siz_shapefunc
    1653              :    end if
    1654           78 :    if (allocated(pawtab%tcoredens)) then
    1655          210 :      siz_tcoredens=size(pawtab%tcoredens)           !(core_mesh_size,1 or 6)
    1656           70 :      if (siz_tcoredens/=pawtab%core_mesh_size.and.siz_tcoredens/=6*pawtab%core_mesh_size) &
    1657            0 : &      msg=trim(msg)//' tcoredens'
    1658           70 :      nn_dpr=nn_dpr+siz_tcoredens
    1659              :    end if
    1660           78 :    if (allocated(pawtab%tcoretau)) then
    1661            2 :      siz_tcoretau=size(pawtab%tcoretau)             !(coretau_mesh_size,1)
    1662            2 :      if (siz_tcoretau/=pawtab%coretau_mesh_size) &
    1663            0 : &      msg=trim(msg)//' tcoretau'
    1664            2 :      nn_dpr=nn_dpr+siz_tcoretau
    1665              :    end if
    1666           78 :    if (allocated(pawtab%tcorespl)) then
    1667          210 :      siz_tcorespl=size(pawtab%tcorespl)             !(mqgrid,2)
    1668           70 :      if (siz_tcorespl/=pawtab%mqgrid*2) msg=trim(msg)//' tcorespl'
    1669           70 :      nn_dpr=nn_dpr+siz_tcorespl
    1670              :    end if
    1671           78 :    if (allocated(pawtab%tcoretauspl)) then
    1672            6 :      siz_tcoretauspl=size(pawtab%tcoretauspl)       !(mqgrid,2)
    1673            2 :      if (siz_tcoretauspl/=pawtab%mqgrid*2.and.siz_tcoretauspl/=0) msg=trim(msg)//' tcoretauspl'
    1674            2 :      nn_dpr=nn_dpr+siz_tcoretauspl
    1675              :    end if
    1676           78 :    if (allocated(pawtab%tphi)) then
    1677          210 :      siz_tphi=size(pawtab%tphi)                     !(partialwave_mesh_size, basis_size)
    1678           70 :      if (siz_tphi/=pawtab%partialwave_mesh_size*pawtab%basis_size) msg=trim(msg)//' tphi'
    1679           70 :      nn_dpr=nn_dpr+siz_tphi
    1680              :    end if
    1681           78 :    if (allocated(pawtab%tproj)) then
    1682            0 :      siz_tproj=size(pawtab%tproj)                   !(???,basis_size)
    1683            0 :     if (mod(siz_tproj,pawtab%basis_size)/=0) msg=trim(msg)//' tproj'
    1684            0 :      nn_dpr=nn_dpr+siz_tproj
    1685              :    end if
    1686           78 :    if (allocated(pawtab%tvalespl)) then
    1687          135 :      siz_tvalespl=size(pawtab%tvalespl)             !(mqgrid or mesh_size or tnvale_mesh_size,2)
    1688           45 :      if (siz_tvalespl/=2*pawtab%mqgrid.and.siz_tvalespl/=2*pawtab%mesh_size.and. &
    1689            0 : &        siz_tvalespl/=2*pawtab%tnvale_mesh_size) msg=trim(msg)//' tvalespl'
    1690           45 :      nn_dpr=nn_dpr+siz_tvalespl
    1691              :    end if
    1692           78 :    if (allocated(pawtab%vhtnzc)) then
    1693           70 :      siz_vhtnzc=size(pawtab%vhtnzc)                 !(mesh_size)
    1694           70 :      if (siz_vhtnzc<pawtab%mesh_size) msg=trim(msg)//' vhtnzc'
    1695           70 :      nn_dpr=nn_dpr+siz_vhtnzc
    1696              :    end if
    1697           78 :    if (allocated(pawtab%vhnzc)) then
    1698           70 :      siz_vhnzc=size(pawtab%vhnzc)                   !(mesh_size)
    1699           70 :      if (siz_vhnzc/=pawtab%mesh_size) msg=trim(msg)//' vhnzc'
    1700           70 :      nn_dpr=nn_dpr+siz_vhnzc
    1701              :    end if
    1702           78 :    if (allocated(pawtab%vminushalf)) then
    1703            0 :      siz_vminushalf=size(pawtab%vminushalf)         !(mesh_size)
    1704            0 :      if (siz_vminushalf/=pawtab%vminus_mesh_size) msg=trim(msg)//' vvminushalf'
    1705            0 :      nn_dpr=nn_dpr+siz_vminushalf
    1706              :    end if
    1707              : 
    1708              : !Reals arrays (depending on the parameters of the calculation)
    1709              : !-------------------------------------------------------------------------
    1710           78 :    siz_dltij=0    ; siz_dshpfunc=0
    1711           78 :    siz_eijkl=0    ; siz_eijkl_sr=0 ; siz_euijkl=0    ; siz_euij_fll=0
    1712           78 :    siz_fk=0       ; siz_gammaij=0  ; siz_gnorm=0
    1713           78 :    siz_nabla_ij=0 ; siz_nabla_im_ij=0
    1714           78 :    siz_nablaphi=0 ; siz_phiphj=0   ; siz_phiphjint=0 ; siz_ph0phiint=0
    1715           78 :    siz_proj=0 ; siz_proj2=0 ;
    1716           78 :    siz_qgrid_shp=0; siz_qijl=0     ; siz_rad_for_spline=0
    1717           78 :    siz_shapefncg=0; siz_sij=0      ; siz_tnablaphi=0 ; siz_tphitphj=0
    1718           78 :    siz_vee=0      ; siz_vex=0      ; siz_zioneff=0
    1719           78 :    if (full_broadcast) then
    1720            8 :      nn_int=nn_int+27
    1721            8 :      if (allocated(pawtab%dltij)) then
    1722            0 :        siz_dltij=size(pawtab%dltij)                   !(lmn2_size)
    1723            0 :        if (siz_dltij/=pawtab%lmn2_size) msg=trim(msg)//' dltij'
    1724            0 :        nn_dpr=nn_dpr+siz_dltij
    1725              :      end if
    1726            8 :      if (allocated(pawtab%dshpfunc)) then
    1727            0 :        siz_dshpfunc=size(pawtab%dshpfunc)             !(mesh_size,l_size,4)
    1728            0 :        if (siz_dshpfunc/=pawtab%mesh_size*pawtab%l_size*4) msg=trim(msg)//' dshpfunc'
    1729            0 :        nn_dpr=nn_dpr+siz_dshpfunc
    1730              :      end if
    1731            8 :      if (allocated(pawtab%eijkl)) then
    1732            0 :        siz_eijkl=size(pawtab%eijkl)                   !(lmn2_size,lmn2_size)
    1733            0 :        if (siz_eijkl/=pawtab%lmn2_size*pawtab%lmn2_size) msg=trim(msg)//' eijkl'
    1734            0 :        nn_dpr=nn_dpr+siz_eijkl
    1735              :      end if
    1736            8 :      if (allocated(pawtab%eijkl_sr)) then
    1737            0 :        siz_eijkl_sr=size(pawtab%eijkl_sr)             !(lmn2_size,lmn2_size)
    1738            0 :        if (siz_eijkl_sr/=pawtab%lmn2_size*pawtab%lmn2_size) msg=trim(msg)//' eijkl_sr'
    1739            0 :        nn_dpr=nn_dpr+siz_eijkl_sr
    1740              :      end if
    1741            8 :      if (allocated(pawtab%euijkl)) then
    1742            0 :        siz_euijkl=size(pawtab%euijkl)                 !(3,lmn_size,lmn_size,lmn_size,lmn_size)
    1743            0 :        if (siz_euijkl/=3*pawtab%lmn_size*pawtab%lmn_size*pawtab%lmn_size*pawtab%lmn_size) msg=trim(msg)//' euijkl'
    1744            0 :        nn_dpr=nn_dpr+siz_euijkl
    1745              :      end if
    1746            8 :      if (allocated(pawtab%euij_fll)) then
    1747            0 :        siz_euij_fll=size(pawtab%euij_fll)             !(2,2,lmn_size,lmn_size,lmn_size,lmn_size)
    1748            0 :        if (siz_euij_fll/=4*pawtab%lmn_size*pawtab%lmn_size*pawtab%lmn_size*pawtab%lmn_size) msg=trim(msg)//' euij_fll'
    1749            0 :        nn_dpr=nn_dpr+siz_euij_fll
    1750              :      end if
    1751            8 :      if (allocated(pawtab%fk)) then
    1752            0 :        siz_fk=size(pawtab%fk)                         !(6,4)
    1753            0 :        if (siz_fk/=24) msg=trim(msg)//' fk'
    1754            0 :        nn_dpr=nn_dpr+siz_fk
    1755              :      end if
    1756            8 :      if (allocated(pawtab%gammaij)) then
    1757            0 :        siz_gammaij=size(pawtab%gammaij)               !(l_size)
    1758            0 :        if (siz_gammaij/=pawtab%l_size) msg=trim(msg)//' gammaij'
    1759            0 :        nn_dpr=nn_dpr+siz_gammaij
    1760              :      end if
    1761            8 :      if (allocated(pawtab%gnorm)) then
    1762            0 :        siz_gnorm=size(pawtab%gnorm)                   !(l_size)
    1763            0 :        if (siz_gnorm/=pawtab%l_size) msg=trim(msg)//' gnorm'
    1764            0 :        nn_dpr=nn_dpr+siz_gnorm
    1765              :      end if
    1766            8 :      if (allocated(pawtab%nabla_ij)) then
    1767            0 :        siz_nabla_ij=size(pawtab%nabla_ij)             !(3,lmn_size,lmn_size)
    1768            0 :        if (siz_nabla_ij/=pawtab%lmn_size) msg=trim(msg)//' nabla_ij'
    1769            0 :        nn_dpr=nn_dpr+siz_nabla_ij
    1770              :      end if
    1771            8 :      if (allocated(pawtab%nabla_im_ij)) then
    1772            0 :        siz_nabla_im_ij=size(pawtab%nabla_im_ij)       !(3,lmn_size,lmn_size)
    1773            0 :        if (siz_nabla_im_ij/=pawtab%lmn_size) msg=trim(msg)//' nabla_im_ij'
    1774            0 :        nn_dpr=nn_dpr+siz_nabla_im_ij
    1775              :      end if
    1776            8 :      if (allocated(pawtab%nablaphi)) then
    1777            0 :        siz_phi=size(pawtab%nablaphi)                  !(partialwave_mesh_size, basis_size)
    1778            0 :        if (siz_nablaphi/=pawtab%partialwave_mesh_size*pawtab%basis_size) msg=trim(msg)//' nablaphi'
    1779              :        nn_dpr=nn_dpr+siz_nablaphi
    1780              :      end if
    1781            8 :      if (allocated(pawtab%phiphj)) then
    1782            0 :        siz_phiphj=size(pawtab%phiphj)                 !(mesh_size,ij_size)
    1783            0 :        if (siz_phiphj/=pawtab%mesh_size*pawtab%ij_size) msg=trim(msg)//' phiphj'
    1784            0 :        nn_dpr=nn_dpr+siz_phiphj
    1785              :      end if
    1786            8 :      if (allocated(pawtab%phiphjint)) then
    1787            0 :        siz_phiphjint=size(pawtab%phiphjint)           !(ij_proj)
    1788            0 :        if (siz_phiphjint/=pawtab%ij_proj) msg=trim(msg)//' phiphjint'
    1789            0 :        nn_dpr=nn_dpr+siz_phiphjint
    1790              :      end if
    1791            8 :      if (allocated(pawtab%ph0phiint)) then
    1792            0 :        siz_ph0phiint=size(pawtab%ph0phiint)           !(ij_proj)
    1793            0 :        if (siz_ph0phiint/=pawtab%ij_proj) msg=trim(msg)//' ph0phiint'
    1794            0 :        nn_dpr=nn_dpr+siz_ph0phiint
    1795              :      end if
    1796            8 :      if (allocated(pawtab%proj)) then
    1797            0 :        siz_proj=size(pawtab%proj)
    1798            0 :        nn_dpr=nn_dpr+siz_proj
    1799              :      end if
    1800            8 :      if (allocated(pawtab%proj2)) then
    1801            0 :        siz_proj2=size(pawtab%proj2)
    1802            0 :        nn_dpr=nn_dpr+siz_proj2
    1803              :      end if
    1804            8 :      if (allocated(pawtab%qgrid_shp)) then
    1805            0 :        siz_qgrid_shp=size(pawtab%qgrid_shp)           !(mqgrid_shp)
    1806            0 :        if (siz_qgrid_shp/=pawtab%mqgrid_shp) msg=trim(msg)//' qgrid_shp'
    1807            0 :        nn_dpr=nn_dpr+siz_qgrid_shp
    1808              :      end if
    1809            8 :      if (allocated(pawtab%qijl)) then
    1810            0 :        siz_qijl=size(pawtab%qijl)                     !(l_size**2,lmn2_size)
    1811            0 :        if (siz_qijl/=pawtab%l_size**2*pawtab%lmn2_size) msg=trim(msg)//' qijl'
    1812            0 :        nn_dpr=nn_dpr+siz_qijl
    1813              :      end if
    1814            8 :      if (allocated(pawtab%rad_for_spline)) then
    1815            0 :        siz_rad_for_spline=size(pawtab%rad_for_spline) !(mesh_size)
    1816            0 :        if (siz_rad_for_spline/=pawtab%mesh_size) msg=trim(msg)//' rad_for_spline'
    1817            0 :        nn_dpr=nn_dpr+siz_rad_for_spline
    1818              :      end if
    1819            8 :      if (allocated(pawtab%shapefncg)) then
    1820            0 :        siz_shapefncg=size(pawtab%shapefncg)           !(mqgrid_shp,2,l_size)
    1821            0 :        if (siz_shapefncg/=2*pawtab%mqgrid_shp*pawtab%l_size) msg=trim(msg)//' shapefncg'
    1822            0 :        nn_dpr=nn_dpr+siz_shapefncg
    1823              :      end if
    1824            8 :      if (allocated(pawtab%sij)) then
    1825            0 :        siz_sij=size(pawtab%sij)                       !(lmn2_size)
    1826            0 :        if (siz_sij/=pawtab%lmn2_size) msg=trim(msg)//' sij'
    1827            0 :        nn_dpr=nn_dpr+siz_sij
    1828              :      end if
    1829            8 :      if (allocated(pawtab%tnablaphi)) then
    1830            0 :        siz_tnablaphi=size(pawtab%tnablaphi)           !(partialwave_mesh_size, basis_size)
    1831            0 :        if (siz_tnablaphi/=pawtab%partialwave_mesh_size*pawtab%basis_size) msg=trim(msg)//' tnablaphi'
    1832            0 :        nn_dpr=nn_dpr+siz_tnablaphi
    1833              :      end if
    1834            8 :      if (allocated(pawtab%tphitphj)) then
    1835            0 :        siz_tphitphj=size(pawtab%tphitphj)             !(mesh_size,ij_size)
    1836            0 :        if (siz_tphitphj/=pawtab%mesh_size*pawtab%ij_size) msg=trim(msg)//' tphitphj'
    1837            0 :        nn_dpr=nn_dpr+siz_tphitphj
    1838              :      end if
    1839            8 :      if (allocated(pawtab%vee)) then
    1840            0 :        siz_vee=size(pawtab%vee)                       !(2*lpawu+1,2*lpawu+1,2*lpawu+1,2*lpawu+1)
    1841            0 :        if (siz_vee/=(2*pawtab%lpawu+1)**4) msg=trim(msg)//' vee'
    1842            0 :        nn_dpr=nn_dpr+siz_vee
    1843              :      end if
    1844            8 :      if (allocated(pawtab%vex)) then
    1845            0 :        siz_vex=size(pawtab%vex)                       !(2*lexexch+1,2*lexexch+1,2*lexexch+1,2*lexexch+1,4)
    1846            0 :        if (siz_vex/=4*(2*pawtab%lpawu+1)**4) msg=trim(msg)//' vex'
    1847            0 :        nn_dpr=nn_dpr+siz_vex
    1848              :      end if
    1849            8 :      if (allocated(pawtab%zioneff)) then
    1850            0 :        siz_zioneff=size(pawtab%zioneff)               !(ij_proj)
    1851            0 :        if (siz_zioneff/=pawtab%ij_proj) msg=trim(msg)//' zioneff'
    1852            0 :        nn_dpr=nn_dpr+siz_zioneff
    1853              :      end if
    1854              :    end if ! full_broadcast
    1855              : 
    1856              : !Datastructures (read from psp file)
    1857              : !-------------------------------------------------------------------------
    1858           78 :    siz_wvl_pngau=0 ; siz_wvl_parg=0 ; siz_wvl_pfac=0
    1859           78 :    siz_wvl_rholoc_rad=0 ; siz_wvl_rholoc_d=0
    1860           78 :    siz_wvlpaw=0
    1861           78 :    nn_int=nn_int+1
    1862           78 :    if (associated(pawtab%wvl)) then
    1863            0 :      siz_wvlpaw=1
    1864              :      nn_int=nn_int+3
    1865              : !    wvl%npspcode_init_guess,wvl%ptotgau
    1866            0 :      nn_int=nn_int+2
    1867            0 :      if (allocated(pawtab%wvl%pngau)) then
    1868            0 :        siz_wvl_pngau=size(pawtab%wvl%pngau)         !(basis_size)
    1869            0 :        if (siz_wvl_pngau/=pawtab%basis_size) msg=trim(msg)//' wvl_pngau'
    1870            0 :        nn_int_arr=nn_int_arr+siz_wvl_pngau
    1871              :      end if
    1872            0 :      if (allocated(pawtab%wvl%parg)) then
    1873            0 :        siz_wvl_parg=size(pawtab%wvl%parg)          !(2,ptotgau)
    1874            0 :        if (siz_wvl_parg/=2*pawtab%wvl%ptotgau) msg=trim(msg)//' wvl_parg'
    1875              :        nn_dpr_arr=nn_dpr_arr+siz_wvl_parg
    1876              :      end if
    1877            0 :      if (allocated(pawtab%wvl%pfac)) then
    1878            0 :        siz_wvl_pfac=size(pawtab%wvl%pfac )         !(2,ptotgau)
    1879            0 :        if (siz_wvl_pfac/=2*pawtab%wvl%ptotgau) msg=trim(msg)//' wvl_pfac'
    1880            0 :        nn_dpr_arr=nn_dpr_arr+siz_wvl_pfac
    1881              :      end if
    1882              : !    wvl%rholoc%msz
    1883            0 :      nn_int=nn_int+3
    1884            0 :      if (pawtab%wvl%rholoc%msz>0) then
    1885            0 :        if (allocated(pawtab%wvl%rholoc%rad)) then
    1886            0 :          siz_wvl_rholoc_rad=size(pawtab%wvl%rholoc%rad) !(msz)
    1887            0 :          if (siz_wvl_rholoc_rad/=pawtab%wvl%rholoc%msz) msg=trim(msg)//' wvl_rholoc_rad'
    1888            0 :          nn_dpr_arr=nn_dpr_arr+siz_wvl_rholoc_rad
    1889              :        end if
    1890            0 :        if (allocated(pawtab%wvl%rholoc%d)) then
    1891            0 :          siz_wvl_rholoc_d=size(pawtab%wvl%rholoc%d)     !(msz,4)
    1892            0 :          if (siz_wvl_rholoc_d/=4*pawtab%wvl%rholoc%msz) msg=trim(msg)//' wvl_rholoc_d'
    1893            0 :          nn_dpr_arr=nn_dpr_arr+siz_wvl_rholoc_d
    1894              :        end if
    1895              :      end if
    1896              :    end if
    1897              : 
    1898              : !Datastructures (depending on the parameters of the calculation)
    1899              : !-------------------------------------------------------------------------
    1900              : !  Nothing
    1901              : 
    1902              : !  Are the sizes OK ?
    1903           78 :    if (trim(msg)/='') then
    1904              :      write(msg0,'(3a)') &
    1905            0 : &     'There is a problem with the size of the following array(s):',ch10,trim(msg)
    1906            0 :      LIBPAW_BUG(msg0)
    1907              :    end if
    1908              : 
    1909              :  end if ! me=0
    1910              : 
    1911              : !Broadcast the sizes of buffers
    1912              : !=========================================================================
    1913              : 
    1914              :  if (me==0) then
    1915           78 :    nn(1)=nn_int ; nn(2)=nn_int_arr
    1916           78 :    nn(3)=nn_dpr ; nn(4)=nn_dpr_arr
    1917              :  end if
    1918          300 :  call xmpi_bcast(nn,0,comm_mpi,ierr)
    1919          300 :  if (me/=0) then
    1920          222 :    nn_int=nn(1) ; nn_int_arr=nn(2)
    1921          222 :    nn_dpr=nn(3) ; nn_dpr_arr=nn(4)
    1922              :  end if
    1923              : 
    1924              : !Broadcast all the integer: sizes, integer scalars, integer arrays
    1925              : !=========================================================================
    1926              : 
    1927          900 :  LIBPAW_ALLOCATE(list_int,(nn_int+nn_int_arr))
    1928              : 
    1929              : !Fill the buffer of the sender
    1930              : !-------------------------------------------------------------------------
    1931          300 :  if (me==0) then
    1932           78 :    ii=1
    1933              : 
    1934              : !First the data read from a psp file
    1935              : !...................................
    1936              : 
    1937              : !Sizes of arrays (read from psp file)
    1938           78 :    list_int(ii)=siz_indlmn  ;ii=ii+1
    1939           78 :    list_int(ii)=siz_orbitals  ;ii=ii+1
    1940           78 :    list_int(ii)=siz_coredens  ;ii=ii+1
    1941           78 :    list_int(ii)=siz_coretau  ;ii=ii+1
    1942           78 :    list_int(ii)=siz_dij0  ;ii=ii+1
    1943           78 :    list_int(ii)=siz_kij  ;ii=ii+1
    1944           78 :    list_int(ii)=siz_fock  ;ii=ii+1
    1945           78 :    list_int(ii)=siz_phi  ;ii=ii+1
    1946           78 :    list_int(ii)=siz_rhoij0  ;ii=ii+1
    1947           78 :    list_int(ii)=siz_shape_alpha  ;ii=ii+1
    1948           78 :    list_int(ii)=siz_shape_q  ;ii=ii+1
    1949           78 :    list_int(ii)=siz_shapefunc  ;ii=ii+1
    1950           78 :    list_int(ii)=siz_tcoredens  ;ii=ii+1
    1951           78 :    list_int(ii)=siz_tcoretau  ;ii=ii+1
    1952           78 :    list_int(ii)=siz_tcorespl  ;ii=ii+1
    1953           78 :    list_int(ii)=siz_tcoretauspl  ;ii=ii+1
    1954           78 :    list_int(ii)=siz_tphi  ;ii=ii+1
    1955           78 :    list_int(ii)=siz_tproj  ;ii=ii+1
    1956           78 :    list_int(ii)=siz_tvalespl  ;ii=ii+1
    1957           78 :    list_int(ii)=siz_vhtnzc  ;ii=ii+1
    1958           78 :    list_int(ii)=siz_vhnzc  ;ii=ii+1
    1959           78 :    list_int(ii)=siz_vminushalf  ;ii=ii+1
    1960           78 :    list_int(ii)=siz_wvlpaw  ;ii=ii+1
    1961              : !Integers (read from psp file)
    1962           78 :    list_int(ii)=pawtab%basis_size  ;ii=ii+1
    1963           78 :    list_int(ii)=pawtab%has_fock  ;ii=ii+1
    1964           78 :    list_int(ii)=pawtab%has_kij  ;ii=ii+1
    1965           78 :    list_int(ii)=pawtab%has_shapefncg  ;ii=ii+1
    1966           78 :    list_int(ii)=pawtab%has_nabla  ;ii=ii+1
    1967           78 :    list_int(ii)=pawtab%has_nablaphi ; ii=ii+1
    1968           78 :    list_int(ii)=pawtab%has_tproj  ;ii=ii+1
    1969           78 :    list_int(ii)=pawtab%has_tvale  ;ii=ii+1
    1970           78 :    list_int(ii)=pawtab%has_coretau  ;ii=ii+1
    1971           78 :    list_int(ii)=pawtab%has_vhtnzc  ;ii=ii+1
    1972           78 :    list_int(ii)=pawtab%has_vhnzc  ;ii=ii+1
    1973           78 :    list_int(ii)=pawtab%has_vminushalf  ;ii=ii+1
    1974           78 :    list_int(ii)=pawtab%has_wvl  ;ii=ii+1
    1975           78 :    list_int(ii)=pawtab%ij_size  ;ii=ii+1
    1976           78 :    list_int(ii)=pawtab%l_size  ;ii=ii+1
    1977           78 :    list_int(ii)=pawtab%lmn_size  ;ii=ii+1
    1978           78 :    list_int(ii)=pawtab%lmn2_size  ;ii=ii+1
    1979           78 :    list_int(ii)=pawtab%mesh_size  ;ii=ii+1
    1980           78 :    list_int(ii)=pawtab%partialwave_mesh_size  ;ii=ii+1
    1981           78 :    list_int(ii)=pawtab%core_mesh_size  ;ii=ii+1
    1982           78 :    list_int(ii)=pawtab%coretau_mesh_size  ;ii=ii+1
    1983           78 :    list_int(ii)=pawtab%vminus_mesh_size  ;ii=ii+1
    1984           78 :    list_int(ii)=pawtab%tnvale_mesh_size  ;ii=ii+1
    1985           78 :    list_int(ii)=pawtab%mqgrid  ;ii=ii+1
    1986           78 :    list_int(ii)=pawtab%shape_lambda  ;ii=ii+1
    1987           78 :    list_int(ii)=pawtab%shape_type  ;ii=ii+1
    1988           78 :    list_int(ii)=pawtab%usetcore  ;ii=ii+1
    1989           78 :    list_int(ii)=pawtab%usexcnhat  ;ii=ii+1
    1990              : !Integer arrays (read from psp file)
    1991           78 :    if (siz_indlmn>0) then
    1992          140 :      list_int(ii:ii+siz_indlmn-1)=reshape(pawtab%indlmn,(/siz_indlmn/))
    1993           70 :      ii=ii+siz_indlmn
    1994              :    end if
    1995           78 :    if (siz_orbitals>0) then
    1996          390 :      list_int(ii:ii+siz_orbitals-1)=pawtab%orbitals(1:siz_orbitals)
    1997              :      ii=ii+siz_orbitals
    1998              :    end if
    1999              : !Integers in datastructures (read from psp file)
    2000           78 :    if (siz_wvlpaw==1) then
    2001            0 :      list_int(ii)=siz_wvl_pngau  ;ii=ii+1
    2002            0 :      list_int(ii)=siz_wvl_parg  ;ii=ii+1
    2003            0 :      list_int(ii)=siz_wvl_pfac  ;ii=ii+1
    2004            0 :      list_int(ii)=pawtab%wvl%npspcode_init_guess  ;ii=ii+1
    2005            0 :      list_int(ii)=pawtab%wvl%ptotgau  ;ii=ii+1
    2006            0 :      if (siz_wvl_pngau>0) then
    2007            0 :        list_int(ii:ii+siz_wvl_pngau-1)=pawtab%wvl%pngau(1:siz_wvl_pngau)
    2008              :        ii=ii+siz_wvl_pngau
    2009              :      end if
    2010            0 :      list_int(ii)=siz_wvl_rholoc_rad  ;ii=ii+1
    2011            0 :      list_int(ii)=siz_wvl_rholoc_d  ;ii=ii+1
    2012            0 :      list_int(ii)=pawtab%wvl%rholoc%msz  ;ii=ii+1
    2013              :    end if
    2014              : 
    2015              : !Then the data initialized later
    2016              : !...................................
    2017           78 :    if (full_broadcast) then
    2018              : 
    2019              : !Sizes of arrays
    2020            8 :      list_int(ii)=siz_indklmn  ;ii=ii+1
    2021            8 :      list_int(ii)=siz_klmntomn  ;ii=ii+1
    2022            8 :      list_int(ii)=siz_kmix  ;ii=ii+1
    2023            8 :      list_int(ii)=siz_lnproju  ;ii=ii+1
    2024            8 :      list_int(ii)=siz_dltij  ;ii=ii+1
    2025            8 :      list_int(ii)=siz_dshpfunc  ;ii=ii+1
    2026            8 :      list_int(ii)=siz_eijkl  ;ii=ii+1
    2027            8 :      list_int(ii)=siz_eijkl_sr  ;ii=ii+1
    2028            8 :      list_int(ii)=siz_euijkl  ;ii=ii+1
    2029            8 :      list_int(ii)=siz_euij_fll  ;ii=ii+1
    2030            8 :      list_int(ii)=siz_fk  ;ii=ii+1
    2031            8 :      list_int(ii)=siz_gammaij ;ii=ii+1
    2032            8 :      list_int(ii)=siz_gnorm  ;ii=ii+1
    2033            8 :      list_int(ii)=siz_nabla_ij  ;ii=ii+1
    2034            8 :      list_int(ii)=siz_nabla_im_ij  ;ii=ii+1
    2035            8 :      list_int(ii)=siz_nablaphi; ii=ii+1
    2036            8 :      list_int(ii)=siz_phiphj  ;ii=ii+1
    2037            8 :      list_int(ii)=siz_phiphjint  ;ii=ii+1
    2038            8 :      list_int(ii)=siz_ph0phiint  ;ii=ii+1
    2039            8 :      list_int(ii)=siz_proj  ;ii=ii+1
    2040            8 :      list_int(ii)=siz_proj2  ;ii=ii+1
    2041            8 :      list_int(ii)=siz_qgrid_shp  ;ii=ii+1
    2042            8 :      list_int(ii)=siz_qijl  ;ii=ii+1
    2043            8 :      list_int(ii)=siz_rad_for_spline  ;ii=ii+1
    2044            8 :      list_int(ii)=siz_shapefncg  ;ii=ii+1
    2045            8 :      list_int(ii)=siz_sij  ;ii=ii+1
    2046            8 :      list_int(ii)=siz_tnablaphi; ii=ii+1
    2047            8 :      list_int(ii)=siz_tphitphj  ;ii=ii+1
    2048            8 :      list_int(ii)=siz_vee  ;ii=ii+1
    2049            8 :      list_int(ii)=siz_vex  ;ii=ii+1
    2050            8 :      list_int(ii)=siz_zioneff  ;ii=ii+1
    2051              : !Integers
    2052            8 :      list_int(ii)=pawtab%ij_proj  ;ii=ii+1
    2053            8 :      list_int(ii)=pawtab%lcut_size  ;ii=ii+1
    2054            8 :      list_int(ii)=pawtab%lexexch  ;ii=ii+1
    2055            8 :      list_int(ii)=pawtab%lmnmix_sz  ;ii=ii+1
    2056            8 :      list_int(ii)=pawtab%lpawu  ;ii=ii+1
    2057            8 :      list_int(ii)=pawtab%mqgrid_shp  ;ii=ii+1
    2058            8 :      list_int(ii)=pawtab%nproju  ;ii=ii+1
    2059            8 :      list_int(ii)=pawtab%option_interaction_pawu ;ii=ii+1
    2060            8 :      list_int(ii)=pawtab%useexexch  ;ii=ii+1
    2061            8 :      list_int(ii)=pawtab%usepawu  ;ii=ii+1
    2062            8 :      list_int(ii)=pawtab%usepotzero ;ii=ii+1
    2063            8 :      list_int(ii)=pawtab%usespnorb ;ii=ii+1
    2064            8 :      list_int(ii)=pawtab%add_core_energy  ;ii=ii+1
    2065              : !Integer arrays
    2066            8 :      if (siz_indklmn>0) then
    2067            0 :        list_int(ii:ii+siz_indklmn-1)=reshape(pawtab%indklmn,(/siz_indklmn/))
    2068            0 :        ii=ii+siz_indklmn
    2069              :      end if
    2070            8 :      if (siz_klmntomn>0) then
    2071            0 :        list_int(ii:ii+siz_klmntomn-1)=reshape(pawtab%klmntomn,(/siz_klmntomn/))
    2072            0 :        ii=ii+siz_klmntomn
    2073              :      end if
    2074            8 :      if (siz_kmix>0) then
    2075            0 :        list_int(ii:ii+siz_kmix-1)=pawtab%kmix(1:siz_kmix)
    2076              :        ii=ii+siz_kmix
    2077              :      end if
    2078            8 :      if (siz_lnproju>0) then
    2079            0 :        list_int(ii:ii+siz_lnproju-1)=pawtab%lnproju(1:siz_lnproju)
    2080              :        ii=ii+siz_lnproju
    2081              :      end if
    2082              :    end if ! full_broadcast
    2083           78 :    ii=ii-1
    2084              : 
    2085           78 :    if (ii/=nn_int+nn_int_arr) then
    2086            0 :      msg='the number of loaded integers is not correct!'
    2087            0 :      LIBPAW_BUG(msg)
    2088              :    end if
    2089              : 
    2090              :  end if ! me=0
    2091              : 
    2092              : !Perfom the communication
    2093              : !-------------------------------------------------------------------------
    2094              : 
    2095          300 :  call xmpi_bcast(list_int,0,comm_mpi,ierr)
    2096              : 
    2097              : !Fill the receiver from the buffer
    2098              : !-------------------------------------------------------------------------
    2099          300 :  if (me/=0) then
    2100          222 :    ii=1
    2101              : 
    2102              : !First the data read from a psp file
    2103              : !...................................
    2104              : 
    2105              : !Sizes of arrays (read from psp file)
    2106          222 :    siz_indlmn=list_int(ii)  ;ii=ii+1
    2107          222 :    siz_orbitals=list_int(ii)  ;ii=ii+1
    2108          222 :    siz_coredens=list_int(ii)  ;ii=ii+1
    2109          222 :    siz_coretau=list_int(ii)  ;ii=ii+1
    2110          222 :    siz_dij0=list_int(ii)  ;ii=ii+1
    2111          222 :    siz_kij=list_int(ii)  ;ii=ii+1
    2112          222 :    siz_fock=list_int(ii)  ;ii=ii+1
    2113          222 :    siz_phi=list_int(ii)  ;ii=ii+1
    2114          222 :    siz_rhoij0=list_int(ii)  ;ii=ii+1
    2115          222 :    siz_shape_alpha=list_int(ii)  ;ii=ii+1
    2116          222 :    siz_shape_q=list_int(ii)  ;ii=ii+1
    2117          222 :    siz_shapefunc=list_int(ii)  ;ii=ii+1
    2118          222 :    siz_tcoredens=list_int(ii)  ;ii=ii+1
    2119          222 :    siz_tcoretau=list_int(ii)  ;ii=ii+1
    2120          222 :    siz_tcorespl=list_int(ii)  ;ii=ii+1
    2121          222 :    siz_tcoretauspl=list_int(ii)  ;ii=ii+1
    2122          222 :    siz_tphi=list_int(ii)  ;ii=ii+1
    2123          222 :    siz_tproj=list_int(ii)  ;ii=ii+1
    2124          222 :    siz_tvalespl=list_int(ii)  ;ii=ii+1
    2125          222 :    siz_vhtnzc=list_int(ii)  ;ii=ii+1
    2126          222 :    siz_vhnzc=list_int(ii)  ;ii=ii+1
    2127          222 :    siz_vminushalf=list_int(ii)  ;ii=ii+1
    2128          222 :    siz_wvlpaw=list_int(ii)  ;ii=ii+1
    2129              : !Integers (read from psp file)
    2130          222 :    pawtab%basis_size=list_int(ii)  ;ii=ii+1
    2131          222 :    pawtab%has_fock=list_int(ii)  ;ii=ii+1
    2132          222 :    pawtab%has_kij=list_int(ii)  ;ii=ii+1
    2133          222 :    pawtab%has_shapefncg=list_int(ii)  ;ii=ii+1
    2134          222 :    pawtab%has_nabla=list_int(ii)  ;ii=ii+1
    2135          222 :    pawtab%has_nablaphi=list_int(ii) ; ii=ii+1
    2136          222 :    pawtab%has_tproj=list_int(ii)  ;ii=ii+1
    2137          222 :    pawtab%has_tvale=list_int(ii)  ;ii=ii+1
    2138          222 :    pawtab%has_coretau=list_int(ii)  ;ii=ii+1
    2139          222 :    pawtab%has_vhtnzc=list_int(ii)  ;ii=ii+1
    2140          222 :    pawtab%has_vhnzc=list_int(ii)  ;ii=ii+1
    2141          222 :    pawtab%has_vminushalf=list_int(ii)  ;ii=ii+1
    2142          222 :    pawtab%has_wvl=list_int(ii)  ;ii=ii+1
    2143          222 :    pawtab%ij_size=list_int(ii)  ;ii=ii+1
    2144          222 :    pawtab%l_size=list_int(ii)  ;ii=ii+1
    2145          222 :    pawtab%lmn_size=list_int(ii)  ;ii=ii+1
    2146          222 :    pawtab%lmn2_size=list_int(ii)  ;ii=ii+1
    2147          222 :    pawtab%mesh_size=list_int(ii)  ;ii=ii+1
    2148          222 :    pawtab%partialwave_mesh_size=list_int(ii)  ;ii=ii+1
    2149          222 :    pawtab%core_mesh_size=list_int(ii)  ;ii=ii+1
    2150          222 :    pawtab%coretau_mesh_size=list_int(ii)  ;ii=ii+1
    2151          222 :    pawtab%vminus_mesh_size=list_int(ii)  ;ii=ii+1
    2152          222 :    pawtab%tnvale_mesh_size=list_int(ii)  ;ii=ii+1
    2153          222 :    pawtab%mqgrid=list_int(ii)  ;ii=ii+1
    2154          222 :    pawtab%shape_lambda=list_int(ii)  ;ii=ii+1
    2155          222 :    pawtab%shape_type=list_int(ii)  ;ii=ii+1
    2156          222 :    pawtab%usetcore=list_int(ii)  ;ii=ii+1
    2157          222 :    pawtab%usexcnhat=list_int(ii)  ;ii=ii+1
    2158              : !Integer arrays (read from psp file)
    2159          222 :    if (allocated(pawtab%indlmn)) then
    2160           21 :      LIBPAW_DEALLOCATE(pawtab%indlmn)
    2161              :    end if
    2162          222 :    if (siz_indlmn>0) then
    2163          618 :      LIBPAW_ALLOCATE(pawtab%indlmn,(6,pawtab%lmn_size))
    2164        16518 :      pawtab%indlmn=reshape(list_int(ii:ii+siz_indlmn-1),(/6,pawtab%lmn_size/))
    2165          206 :      ii=ii+siz_indlmn
    2166              :    end if
    2167          222 :    if (allocated(pawtab%orbitals)) then
    2168           21 :      LIBPAW_DEALLOCATE(pawtab%orbitals)
    2169              :    end if
    2170          222 :    if (siz_orbitals>0) then
    2171          618 :      LIBPAW_ALLOCATE(pawtab%orbitals,(pawtab%basis_size))
    2172         1356 :      pawtab%orbitals=list_int(ii:ii+pawtab%basis_size-1)
    2173          206 :      ii=ii+siz_orbitals
    2174              :    end if
    2175              : !Integers in datastructures (read from psp file)
    2176          222 :    if (siz_wvlpaw==1) then
    2177            0 :      call wvlpaw_allocate(pawtab%wvl)
    2178            0 :      siz_wvl_pngau=list_int(ii)  ;ii=ii+1
    2179            0 :      siz_wvl_parg=list_int(ii)  ;ii=ii+1
    2180            0 :      siz_wvl_pfac=list_int(ii)  ;ii=ii+1
    2181            0 :      pawtab%wvl%npspcode_init_guess=list_int(ii)  ;ii=ii+1
    2182            0 :      pawtab%wvl%ptotgau=list_int(ii)  ;ii=ii+1
    2183            0 :      if (allocated(pawtab%wvl%pngau)) then
    2184            0 :        LIBPAW_DEALLOCATE(pawtab%wvl%pngau)
    2185              :      end if
    2186            0 :      if (siz_wvl_pngau>0) then
    2187            0 :        LIBPAW_ALLOCATE(pawtab%wvl%pngau,(pawtab%basis_size))
    2188            0 :        pawtab%wvl%pngau=list_int(ii:ii+pawtab%basis_size-1)
    2189            0 :        ii=ii+siz_wvl_pngau
    2190              :      end if
    2191            0 :      siz_wvl_rholoc_rad=list_int(ii)  ;ii=ii+1
    2192            0 :      siz_wvl_rholoc_d=list_int(ii)  ;ii=ii+1
    2193            0 :      pawtab%wvl%rholoc%msz=list_int(ii)  ;ii=ii+1
    2194              :    end if
    2195              : 
    2196              : !Then the data initialized later
    2197              : !...................................
    2198          222 :    if (full_broadcast) then
    2199              : 
    2200              : !Sizes of arrays
    2201           16 :      siz_indklmn=list_int(ii)  ;ii=ii+1
    2202           16 :      siz_klmntomn=list_int(ii)  ;ii=ii+1
    2203           16 :      siz_kmix=list_int(ii)  ;ii=ii+1
    2204           16 :      siz_lnproju=list_int(ii)  ;ii=ii+1
    2205           16 :      siz_dltij=list_int(ii)  ;ii=ii+1
    2206           16 :      siz_dshpfunc=list_int(ii)  ;ii=ii+1
    2207           16 :      siz_eijkl=list_int(ii)  ;ii=ii+1
    2208           16 :      siz_eijkl_sr=list_int(ii)  ;ii=ii+1
    2209           16 :      siz_euijkl=list_int(ii)  ;ii=ii+1
    2210           16 :      siz_euij_fll=list_int(ii)  ;ii=ii+1
    2211           16 :      siz_fk=list_int(ii)  ;ii=ii+1
    2212           16 :      siz_gammaij=list_int(ii)  ;ii=ii+1
    2213           16 :      siz_gnorm=list_int(ii)  ;ii=ii+1
    2214           16 :      siz_nabla_ij=list_int(ii)  ;ii=ii+1
    2215           16 :      siz_nabla_im_ij=list_int(ii)  ;ii=ii+1
    2216           16 :      siz_nablaphi=list_int(ii)  ;ii=ii+1
    2217           16 :      siz_phiphj=list_int(ii)  ;ii=ii+1
    2218           16 :      siz_phiphjint=list_int(ii)  ;ii=ii+1
    2219           16 :      siz_ph0phiint=list_int(ii)  ;ii=ii+1
    2220           16 :      siz_proj=list_int(ii)  ;ii=ii+1
    2221           16 :      siz_proj2=list_int(ii)  ;ii=ii+1
    2222           16 :      siz_qgrid_shp=list_int(ii)  ;ii=ii+1
    2223           16 :      siz_qijl=list_int(ii)  ;ii=ii+1
    2224           16 :      siz_rad_for_spline=list_int(ii)  ;ii=ii+1
    2225           16 :      siz_shapefncg=list_int(ii)  ;ii=ii+1
    2226           16 :      siz_sij=list_int(ii)  ;ii=ii+1
    2227           16 :      siz_tnablaphi=list_int(ii)  ;ii=ii+1
    2228           16 :      siz_tphitphj=list_int(ii)  ;ii=ii+1
    2229           16 :      siz_vee=list_int(ii)  ;ii=ii+1
    2230           16 :      siz_vex=list_int(ii)  ;ii=ii+1
    2231           16 :      siz_zioneff=list_int(ii)  ;ii=ii+1
    2232              : !Integers
    2233           16 :      pawtab%ij_proj=list_int(ii)  ;ii=ii+1
    2234           16 :      pawtab%lcut_size=list_int(ii)  ;ii=ii+1
    2235           16 :      pawtab%lexexch=list_int(ii)  ;ii=ii+1
    2236           16 :      pawtab%lmnmix_sz=list_int(ii)  ;ii=ii+1
    2237           16 :      pawtab%lpawu=list_int(ii)  ;ii=ii+1
    2238           16 :      pawtab%mqgrid_shp=list_int(ii)  ;ii=ii+1
    2239           16 :      pawtab%nproju=list_int(ii)  ;ii=ii+1
    2240           16 :      pawtab%option_interaction_pawu=list_int(ii) ;ii=ii+1
    2241           16 :      pawtab%useexexch=list_int(ii)  ;ii=ii+1
    2242           16 :      pawtab%usepawu=list_int(ii)  ;ii=ii+1
    2243           16 :      pawtab%usepotzero=list_int(ii) ;ii=ii+1
    2244           16 :      pawtab%usespnorb=list_int(ii) ;ii=ii+1
    2245           16 :      pawtab%add_core_energy=list_int(ii) ;ii=ii+1
    2246              : !Integer arrays
    2247           16 :      if (allocated(pawtab%indklmn)) then
    2248            0 :        LIBPAW_DEALLOCATE(pawtab%indklmn)
    2249              :      end if
    2250           16 :      if (siz_indklmn>0) then
    2251            0 :        LIBPAW_ALLOCATE(pawtab%indklmn,(8,pawtab%lmn2_size))
    2252            0 :        pawtab%indklmn=reshape(list_int(ii:ii+siz_indklmn-1),(/8,pawtab%lmn2_size/))
    2253            0 :        ii=ii+siz_indklmn
    2254              :      end if
    2255           16 :      if (allocated(pawtab%klmntomn)) then
    2256            0 :        LIBPAW_DEALLOCATE(pawtab%klmntomn)
    2257              :      end if
    2258           16 :      if (siz_klmntomn>0) then
    2259            0 :        LIBPAW_ALLOCATE(pawtab%klmntomn,(4,pawtab%lmn2_size))
    2260            0 :        pawtab%klmntomn=reshape(list_int(ii:ii+siz_klmntomn-1),(/4,pawtab%lmn2_size/))
    2261            0 :        ii=ii+siz_klmntomn
    2262              :      end if
    2263           16 :      if (allocated(pawtab%kmix)) then
    2264            0 :        LIBPAW_DEALLOCATE(pawtab%kmix)
    2265              :      end if
    2266           16 :      if (siz_kmix>0) then
    2267            0 :        LIBPAW_ALLOCATE(pawtab%kmix,(pawtab%lmnmix_sz))
    2268            0 :        pawtab%kmix=list_int(ii:ii+pawtab%lmnmix_sz-1)
    2269            0 :        ii=ii+siz_kmix
    2270              :      end if
    2271           16 :      if (allocated(pawtab%lnproju)) then
    2272            0 :        LIBPAW_DEALLOCATE(pawtab%lnproju)
    2273              :      end if
    2274           16 :      if (siz_lnproju>0) then
    2275            0 :        LIBPAW_ALLOCATE(pawtab%lnproju,(pawtab%nproju))
    2276            0 :        pawtab%lnproju=list_int(ii:ii+pawtab%nproju-1)
    2277            0 :        ii=ii+siz_lnproju
    2278              :      end if
    2279              :    end if ! full_broadcast
    2280          222 :    ii=ii-1
    2281              : 
    2282          222 :    if (ii/=nn_int+nn_int_arr) then
    2283            0 :      msg='the number of broadcasted integers is not correct!'
    2284            0 :      LIBPAW_BUG(msg)
    2285              :    end if
    2286              : 
    2287              :  end if ! me/=0
    2288          300 :  LIBPAW_DEALLOCATE(list_int)
    2289              : 
    2290              : !Broadcast all the reals
    2291              : !=========================================================================
    2292              : 
    2293          900 :  LIBPAW_ALLOCATE(list_dpr,(nn_dpr+nn_dpr_arr))
    2294              : 
    2295              : !Fill the buffer of the sender
    2296              : !-------------------------------------------------------------------------
    2297          300 :  if (me==0) then
    2298           78 :    ii=1
    2299              : 
    2300              : !First the data read from a psp file
    2301              : !...................................
    2302              : 
    2303              : !Reals (read from psp file)
    2304           78 :    list_dpr(ii)=pawtab%beta    ;ii=ii+1
    2305           78 :    list_dpr(ii)=pawtab%dncdq0  ;ii=ii+1
    2306           78 :    list_dpr(ii)=pawtab%d2ncdq0  ;ii=ii+1
    2307           78 :    list_dpr(ii)=pawtab%dnvdq0  ;ii=ii+1
    2308           78 :    list_dpr(ii)=pawtab%dtaucdq0  ;ii=ii+1
    2309           78 :    list_dpr(ii)=pawtab%eps  ;ii=ii+1
    2310           78 :    list_dpr(ii)=pawtab%ex_cc   ;ii=ii+1
    2311           78 :    list_dpr(ii)=pawtab%exccore  ;ii=ii+1
    2312           78 :    list_dpr(ii)=pawtab%ekincore  ;ii=ii+1
    2313           78 :    list_dpr(ii)=pawtab%sxccore  ;ii=ii+1
    2314           78 :    list_dpr(ii)=pawtab%ehnzc  ;ii=ii+1
    2315           78 :    list_dpr(ii)=pawtab%lamb_shielding  ;ii=ii+1
    2316           78 :    list_dpr(ii)=pawtab%lambda  ;ii=ii+1
    2317           78 :    list_dpr(ii)=pawtab%rpaw  ;ii=ii+1
    2318           78 :    list_dpr(ii)=pawtab%rshp  ;ii=ii+1
    2319           78 :    list_dpr(ii)=pawtab%rcore  ;ii=ii+1
    2320           78 :    list_dpr(ii)=pawtab%rcoretau  ;ii=ii+1
    2321           78 :    list_dpr(ii)=pawtab%shape_sigma  ;ii=ii+1
    2322              : !Reals arrays (read from psp file)
    2323           78 :    if (siz_coredens>0) then
    2324        62994 :      list_dpr(ii:ii+siz_coredens-1)=pawtab%coredens(1:siz_coredens)
    2325           70 :      ii=ii+siz_coredens
    2326              :    end if
    2327           78 :    if (siz_coretau>0) then
    2328         2912 :      list_dpr(ii:ii+siz_coretau-1)=pawtab%coretau(1:siz_coretau)
    2329              :      ii=ii+siz_coretau
    2330              :    end if
    2331           78 :    if (siz_dij0>0) then
    2332         5730 :      list_dpr(ii:ii+siz_dij0-1)=pawtab%dij0(1:siz_dij0)
    2333              :      ii=ii+siz_dij0
    2334              :    end if
    2335           78 :    if (siz_fock>0) then
    2336         1883 :      list_dpr(ii:ii+siz_fock-1)=pawtab%ex_cvij(1:siz_fock)
    2337              :      ii=ii+siz_fock
    2338              :    end if
    2339           78 :    if (siz_kij>0) then
    2340            0 :      list_dpr(ii:ii+siz_kij-1)=pawtab%kij(1:siz_kij)
    2341              :      ii=ii+siz_kij
    2342              :    end if
    2343           78 :    if (siz_phi>0) then
    2344          140 :      list_dpr(ii:ii+siz_phi-1)=reshape(pawtab%phi,(/siz_phi/))
    2345           70 :      ii=ii+siz_phi
    2346              :    end if
    2347           78 :    if (siz_rhoij0>0) then
    2348         5434 :      list_dpr(ii:ii+siz_rhoij0-1)=pawtab%rhoij0(1:siz_rhoij0)
    2349              :      ii=ii+siz_rhoij0
    2350              :    end if
    2351           78 :    if (siz_shape_alpha>0) then
    2352           14 :      list_dpr(ii:ii+siz_shape_alpha-1)=reshape(pawtab%shape_alpha,(/siz_shape_alpha/))
    2353            7 :      ii=ii+siz_shape_alpha
    2354              :    end if
    2355           78 :    if (siz_shape_q>0) then
    2356           14 :      list_dpr(ii:ii+siz_shape_q-1)=reshape(pawtab%shape_q,(/siz_shape_q/))
    2357            7 :      ii=ii+siz_shape_q
    2358              :    end if
    2359           78 :    if (siz_shapefunc>0) then
    2360            0 :      list_dpr(ii:ii+siz_shapefunc-1)=reshape(pawtab%shapefunc,(/siz_shapefunc/))
    2361            0 :      ii=ii+siz_shapefunc
    2362              :    end if
    2363           78 :    if (siz_tcoredens>0) then
    2364          140 :      list_dpr(ii:ii+siz_tcoredens-1)=reshape(pawtab%tcoredens,(/siz_tcoredens/))
    2365           70 :      ii=ii+siz_tcoredens
    2366              :    end if
    2367           78 :    if (siz_tcoretau>0) then
    2368            4 :      list_dpr(ii:ii+siz_tcoretau-1)=reshape(pawtab%tcoretau,(/siz_tcoretau/))
    2369            2 :      ii=ii+siz_tcoretau
    2370              :    end if
    2371           78 :    if (siz_tcorespl>0) then
    2372          140 :      list_dpr(ii:ii+siz_tcorespl-1)=reshape(pawtab%tcorespl,(/siz_tcorespl/))
    2373           70 :      ii=ii+siz_tcorespl
    2374              :    end if
    2375           78 :    if (siz_tcoretauspl>0) then
    2376            4 :      list_dpr(ii:ii+siz_tcoretauspl-1)=reshape(pawtab%tcoretauspl,(/siz_tcoretauspl/))
    2377            2 :      ii=ii+siz_tcoretauspl
    2378              :    end if
    2379           78 :    if (siz_tphi>0) then
    2380          140 :      list_dpr(ii:ii+siz_tphi-1)=reshape(pawtab%tphi,(/siz_tphi/))
    2381           70 :      ii=ii+siz_tphi
    2382              :    end if
    2383           78 :    if (siz_tproj>0) then
    2384            0 :      list_dpr(ii:ii+siz_tproj-1)=reshape(pawtab%tproj,(/siz_tproj/))
    2385            0 :      ii=ii+siz_tproj
    2386              :    end if
    2387           78 :    if (siz_tvalespl>0) then
    2388           90 :      list_dpr(ii:ii+siz_tvalespl-1)=reshape(pawtab%tvalespl,(/siz_tvalespl/))
    2389           45 :      ii=ii+siz_tvalespl
    2390              :    end if
    2391           78 :    if (siz_vhtnzc>0) then
    2392        91146 :      list_dpr(ii:ii+siz_vhtnzc-1)=pawtab%vhtnzc(1:siz_vhtnzc)
    2393              :      ii=ii+siz_vhtnzc
    2394              :    end if
    2395           78 :    if (siz_vhnzc>0) then
    2396        62994 :      list_dpr(ii:ii+siz_vhnzc-1)=pawtab%vhnzc(1:siz_vhnzc)
    2397              :      ii=ii+siz_vhnzc
    2398              :    end if
    2399           78 :    if (siz_vminushalf>0) then
    2400            0 :      list_dpr(ii:ii+siz_vminushalf-1)=pawtab%vminushalf(1:siz_vminushalf)
    2401              :      ii=ii+siz_vminushalf
    2402              :    end if
    2403              : !Reals in datastructures (read from psp file)
    2404           78 :    if (siz_wvlpaw==1) then
    2405            0 :      if (siz_wvl_parg>0) then
    2406            0 :        list_dpr(ii:ii+siz_wvl_parg-1)=reshape(pawtab%wvl%parg,(/siz_wvl_parg/))
    2407            0 :        ii=ii+siz_wvl_parg
    2408              :      end if
    2409            0 :      if (siz_wvl_pfac>0) then
    2410            0 :        list_dpr(ii:ii+siz_wvl_pfac-1)=reshape(pawtab%wvl%pfac,(/siz_wvl_pfac/))
    2411            0 :        ii=ii+siz_wvl_pfac
    2412              :      end if
    2413            0 :      if (siz_wvl_rholoc_rad>0) then
    2414            0 :         list_dpr(ii:ii+siz_wvl_rholoc_rad-1)=pawtab%wvl%rholoc%rad(1:siz_wvl_rholoc_rad)
    2415              :         ii=ii+siz_wvl_rholoc_rad
    2416              :      end if
    2417            0 :      if (siz_wvl_rholoc_d>0) then
    2418            0 :         list_dpr(ii:ii+siz_wvl_rholoc_d-1)=reshape(pawtab%wvl%rholoc%d,(/siz_wvl_rholoc_d/))
    2419            0 :         ii=ii+siz_wvl_rholoc_d
    2420              :      end if
    2421              :    end if
    2422              : 
    2423              : !Then the data initialized later
    2424              : !...................................
    2425           78 :    if (full_broadcast) then
    2426              : 
    2427              : !Reals
    2428            8 :      list_dpr(ii)=pawtab%exchmix  ;ii=ii+1
    2429            8 :      list_dpr(ii)=pawtab%f4of2_sla  ;ii=ii+1
    2430            8 :      list_dpr(ii)=pawtab%f6of2_sla  ;ii=ii+1
    2431            8 :      list_dpr(ii)=pawtab%jpawu  ;ii=ii+1
    2432            8 :      list_dpr(ii)=pawtab%upawu  ;ii=ii+1
    2433              : !Reals arrays
    2434            8 :      if (siz_dltij>0) then
    2435            0 :        list_dpr(ii:ii+siz_dltij-1)=pawtab%dltij(1:siz_dltij)
    2436              :        ii=ii+siz_dltij
    2437              :      end if
    2438            8 :      if (siz_dshpfunc>0) then
    2439            0 :        list_dpr(ii:ii+siz_dshpfunc-1)=reshape(pawtab%dshpfunc,(/siz_dshpfunc/))
    2440            0 :        ii=ii+siz_dshpfunc
    2441              :      end if
    2442            8 :      if (siz_eijkl>0) then
    2443            0 :        list_dpr(ii:ii+siz_eijkl-1)=reshape(pawtab%eijkl,(/siz_eijkl/))
    2444            0 :        ii=ii+siz_eijkl
    2445              :      end if
    2446            8 :      if (siz_eijkl_sr>0) then
    2447            0 :        list_dpr(ii:ii+siz_eijkl_sr-1)=reshape(pawtab%eijkl_sr,(/siz_eijkl_sr/))
    2448            0 :        ii=ii+siz_eijkl_sr
    2449              :      end if
    2450            8 :      if (siz_euijkl>0) then
    2451            0 :        list_dpr(ii:ii+siz_euijkl-1)=reshape(pawtab%euijkl,(/siz_euijkl/))
    2452            0 :        ii=ii+siz_euijkl
    2453              :      end if
    2454            8 :      if (siz_euij_fll>0) then
    2455            0 :        list_dpr(ii:ii+siz_euij_fll-1)=reshape(pawtab%euij_fll,(/siz_euij_fll/))
    2456            0 :        ii=ii+siz_euij_fll
    2457              :      end if
    2458            8 :      if (siz_fk>0) then
    2459            0 :        list_dpr(ii:ii+siz_fk-1)=reshape(pawtab%fk,(/siz_fk/))
    2460            0 :        ii=ii+siz_fk
    2461              :      end if
    2462            8 :      if (siz_gammaij>0) then
    2463            0 :        list_dpr(ii:ii+siz_gammaij-1)=pawtab%gammaij(1:siz_gammaij)
    2464              :        ii=ii+siz_gammaij
    2465              :      end if
    2466            8 :      if (siz_gnorm>0) then
    2467            0 :        list_dpr(ii:ii+siz_gnorm-1)=pawtab%gnorm(1:siz_gnorm)
    2468              :        ii=ii+siz_gnorm
    2469              :      end if
    2470            8 :      if (siz_nabla_ij>0) then
    2471            0 :        list_dpr(ii:ii+siz_nabla_ij-1)=reshape(pawtab%nabla_ij,(/siz_nabla_ij/))
    2472            0 :        ii=ii+siz_nabla_ij
    2473              :      end if
    2474            8 :      if (siz_nabla_im_ij>0) then
    2475            0 :        list_dpr(ii:ii+siz_nabla_im_ij-1)=reshape(pawtab%nabla_im_ij,(/siz_nabla_im_ij/))
    2476            0 :        ii=ii+siz_nabla_im_ij
    2477              :      end if
    2478            8 :      if (siz_nablaphi>0) then
    2479            0 :        list_dpr(ii:ii+siz_nablaphi-1)=reshape(pawtab%nablaphi,(/siz_nablaphi/))
    2480            0 :        ii=ii+siz_nablaphi
    2481              :      end if
    2482            8 :      if (siz_phiphj>0) then
    2483            0 :        list_dpr(ii:ii+siz_phiphj-1)=reshape(pawtab%phiphj,(/siz_phiphj/))
    2484            0 :        ii=ii+siz_phiphj
    2485              :      end if
    2486            8 :      if (siz_phiphjint>0) then
    2487            0 :        list_dpr(ii:ii+siz_phiphjint-1)=pawtab%phiphjint(1:siz_phiphjint)
    2488              :        ii=ii+siz_phiphjint
    2489              :      end if
    2490            8 :      if (siz_ph0phiint>0) then
    2491            0 :        list_dpr(ii:ii+siz_ph0phiint-1)=pawtab%ph0phiint(1:siz_ph0phiint)
    2492              :        ii=ii+siz_ph0phiint
    2493              :      end if
    2494            8 :      if (siz_proj>0) then
    2495            0 :        list_dpr(ii:ii+siz_proj-1)=pawtab%proj(1:siz_proj)
    2496              :        ii=ii+siz_proj
    2497              :      end if
    2498            8 :      if (siz_proj2>0) then
    2499            0 :        list_dpr(ii:ii+siz_proj2-1)=pawtab%proj2(1:siz_proj2)
    2500              :        ii=ii+siz_proj2
    2501              :      end if
    2502            8 :      if (siz_qgrid_shp>0) then
    2503            0 :        list_dpr(ii:ii+siz_qgrid_shp-1)=pawtab%qgrid_shp(1:siz_qgrid_shp)
    2504              :        ii=ii+siz_qgrid_shp
    2505              :      end if
    2506            8 :      if (siz_qijl>0) then
    2507            0 :        list_dpr(ii:ii+siz_qijl-1)=reshape(pawtab%qijl,(/siz_qijl/))
    2508            0 :        ii=ii+siz_qijl
    2509              :      end if
    2510            8 :      if (siz_rad_for_spline>0) then
    2511            0 :        list_dpr(ii:ii+siz_rad_for_spline-1)=pawtab%rad_for_spline(1:siz_rad_for_spline)
    2512              :        ii=ii+siz_rad_for_spline
    2513              :      end if
    2514            8 :      if (siz_shapefncg>0) then
    2515            0 :        list_dpr(ii:ii+siz_shapefncg-1)=reshape(pawtab%shapefncg,(/siz_shapefncg/))
    2516            0 :        ii=ii+siz_shapefncg
    2517              :      end if
    2518            8 :      if (siz_sij>0) then
    2519            0 :        list_dpr(ii:ii+siz_sij-1)=pawtab%sij(1:siz_sij)
    2520              :        ii=ii+siz_sij
    2521              :      end if
    2522            8 :      if (siz_tnablaphi>0) then
    2523            0 :        list_dpr(ii:ii+siz_tnablaphi-1)=reshape(pawtab%tnablaphi,(/siz_tnablaphi/))
    2524            0 :        ii=ii+siz_tnablaphi
    2525              :      end if
    2526            8 :      if (siz_tphitphj>0) then
    2527            0 :        list_dpr(ii:ii+siz_tphitphj-1)=reshape(pawtab%tphitphj,(/siz_tphitphj/))
    2528            0 :        ii=ii+siz_tphitphj
    2529              :      end if
    2530            8 :      if (siz_vee>0) then
    2531            0 :        list_dpr(ii:ii+siz_vee-1)=reshape(pawtab%vee,(/siz_vee/))
    2532            0 :        ii=ii+siz_vee
    2533              :      end if
    2534            8 :      if (siz_vex>0) then
    2535            0 :        list_dpr(ii:ii+siz_vex-1)=reshape(pawtab%vex,(/siz_vex/))
    2536            0 :        ii=ii+siz_vex
    2537              :      end if
    2538            8 :      if (siz_zioneff>0) then
    2539            0 :        list_dpr(ii:ii+siz_zioneff-1)=pawtab%zioneff(1:siz_zioneff)
    2540              :        ii=ii+siz_zioneff
    2541              :      end if
    2542              : 
    2543              :    end if ! full_broadcast
    2544           78 :    ii=ii-1
    2545           78 :    if (ii/=nn_dpr+nn_dpr_arr) then
    2546            0 :      msg='the number of loaded reals is not correct!'
    2547            0 :      LIBPAW_BUG(msg)
    2548              :    end if
    2549              : 
    2550              :  end if ! me=0
    2551              : 
    2552              : !Perfom the communication
    2553              : !-------------------------------------------------------------------------
    2554              : 
    2555          300 :  call xmpi_bcast(list_dpr,0,comm_mpi,ierr)
    2556              : 
    2557              : !Fill the receiver from the buffer
    2558              : !-------------------------------------------------------------------------
    2559          300 :  if (me/=0) then
    2560          222 :    ii=1
    2561              : 
    2562              : !First the data read from a psp file
    2563              : !...................................
    2564              : 
    2565              : !Reals (read from psp file)
    2566          222 :    pawtab%beta=list_dpr(ii)    ;ii=ii+1
    2567          222 :    pawtab%dncdq0=list_dpr(ii)  ;ii=ii+1
    2568          222 :    pawtab%d2ncdq0=list_dpr(ii)  ;ii=ii+1
    2569          222 :    pawtab%dnvdq0=list_dpr(ii)  ;ii=ii+1
    2570          222 :    pawtab%dtaucdq0=list_dpr(ii)  ;ii=ii+1
    2571          222 :    pawtab%eps=list_dpr(ii)  ;ii=ii+1
    2572          222 :    pawtab%ex_cc=list_dpr(ii)  ;ii=ii+1
    2573          222 :    pawtab%exccore=list_dpr(ii)  ;ii=ii+1
    2574          222 :    pawtab%ekincore=list_dpr(ii)  ;ii=ii+1
    2575          222 :    pawtab%sxccore=list_dpr(ii)  ;ii=ii+1
    2576          222 :    pawtab%ehnzc=list_dpr(ii)  ;ii=ii+1
    2577          222 :    pawtab%lamb_shielding=list_dpr(ii)  ;ii=ii+1
    2578          222 :    pawtab%lambda=list_dpr(ii)  ;ii=ii+1
    2579          222 :    pawtab%rpaw=list_dpr(ii)  ;ii=ii+1
    2580          222 :    pawtab%rshp=list_dpr(ii)  ;ii=ii+1
    2581          222 :    pawtab%rcore=list_dpr(ii)  ;ii=ii+1
    2582          222 :    pawtab%rcoretau=list_dpr(ii)  ;ii=ii+1
    2583          222 :    pawtab%shape_sigma=list_dpr(ii)  ;ii=ii+1
    2584              : !Reals arrays (read from psp file)
    2585          222 :    if (allocated(pawtab%coredens)) then
    2586           21 :      LIBPAW_DEALLOCATE(pawtab%coredens)
    2587              :    end if
    2588          222 :    if (siz_coredens>0) then
    2589          618 :      LIBPAW_ALLOCATE(pawtab%coredens,(pawtab%core_mesh_size))
    2590       190536 :      pawtab%coredens=list_dpr(ii:ii+pawtab%core_mesh_size-1)
    2591          206 :      ii=ii+siz_coredens
    2592              :    end if
    2593          222 :    if (allocated(pawtab%coretau)) then
    2594            3 :      LIBPAW_DEALLOCATE(pawtab%coretau)
    2595              :    end if
    2596          222 :    if (siz_coretau>0) then
    2597           18 :      LIBPAW_ALLOCATE(pawtab%coretau,(pawtab%coretau_mesh_size))
    2598         8742 :      pawtab%coretau=list_dpr(ii:ii+pawtab%coretau_mesh_size-1)
    2599            6 :      ii=ii+siz_coretau
    2600              :    end if
    2601          222 :    if (allocated(pawtab%dij0)) then
    2602           21 :      LIBPAW_DEALLOCATE(pawtab%dij0)
    2603              :    end if
    2604          222 :    if (siz_dij0>0) then
    2605          666 :      LIBPAW_ALLOCATE(pawtab%dij0,(pawtab%lmn2_size))
    2606        16968 :      pawtab%dij0=list_dpr(ii:ii+pawtab%lmn2_size-1)
    2607          222 :      ii=ii+siz_dij0
    2608              :    end if
    2609          222 :    if (allocated(pawtab%ex_cvij)) then
    2610            3 :      LIBPAW_DEALLOCATE(pawtab%ex_cvij)
    2611              :    end if
    2612          222 :    if (siz_fock>0) then
    2613          273 :      LIBPAW_ALLOCATE(pawtab%ex_cvij,(pawtab%lmn2_size))
    2614         5888 :      pawtab%ex_cvij=list_dpr(ii:ii+pawtab%lmn2_size-1)
    2615           91 :      ii=ii+siz_fock
    2616              :    end if
    2617          222 :    if (allocated(pawtab%kij)) then
    2618            0 :      LIBPAW_DEALLOCATE(pawtab%kij)
    2619              :    end if
    2620          222 :    if (siz_kij>0) then
    2621            0 :      LIBPAW_ALLOCATE(pawtab%kij,(pawtab%lmn2_size))
    2622            0 :      pawtab%kij=list_dpr(ii:ii+pawtab%lmn2_size-1)
    2623            0 :      ii=ii+siz_kij
    2624              :    end if
    2625          222 :    if (allocated(pawtab%phi)) then
    2626           21 :      LIBPAW_DEALLOCATE(pawtab%phi)
    2627              :    end if
    2628          222 :    if (siz_phi>0) then
    2629          824 :      LIBPAW_ALLOCATE(pawtab%phi,(pawtab%partialwave_mesh_size,pawtab%basis_size))
    2630      1104836 :      pawtab%phi=reshape(list_dpr(ii:ii+siz_phi-1),(/pawtab%partialwave_mesh_size,pawtab%basis_size/))
    2631          206 :      ii=ii+siz_phi
    2632              :    end if
    2633          222 :    if (allocated(pawtab%rhoij0)) then
    2634           21 :      LIBPAW_DEALLOCATE(pawtab%rhoij0)
    2635              :    end if
    2636          222 :    if (siz_rhoij0>0) then
    2637          618 :      LIBPAW_ALLOCATE(pawtab%rhoij0,(pawtab%lmn2_size))
    2638        16360 :      pawtab%rhoij0=list_dpr(ii:ii+pawtab%lmn2_size-1)
    2639          206 :      ii=ii+siz_rhoij0
    2640              :    end if
    2641          222 :    if (allocated(pawtab%shape_alpha)) then
    2642            0 :      LIBPAW_DEALLOCATE(pawtab%shape_alpha)
    2643              :    end if
    2644          222 :    if (siz_shape_alpha>0) then
    2645           63 :      LIBPAW_ALLOCATE(pawtab%shape_alpha,(2,pawtab%l_size))
    2646          363 :      pawtab%shape_alpha=reshape(list_dpr(ii:ii+siz_shape_alpha-1),(/2,pawtab%l_size/))
    2647           21 :      ii=ii+siz_shape_alpha
    2648              :    end if
    2649          222 :    if (allocated(pawtab%shape_q)) then
    2650            0 :      LIBPAW_DEALLOCATE(pawtab%shape_q)
    2651              :    end if
    2652          222 :    if (siz_shape_q>0) then
    2653           63 :      LIBPAW_ALLOCATE(pawtab%shape_q,(2,pawtab%l_size))
    2654          363 :      pawtab%shape_q=reshape(list_dpr(ii:ii+siz_shape_q-1),(/2,pawtab%l_size/))
    2655           21 :      ii=ii+siz_shape_q
    2656              :    end if
    2657          222 :    if (allocated(pawtab%shapefunc)) then
    2658           21 :      LIBPAW_DEALLOCATE(pawtab%shapefunc)
    2659              :    end if
    2660          222 :    if (siz_shapefunc>0) then
    2661            0 :      LIBPAW_ALLOCATE(pawtab%shapefunc,(pawtab%mesh_size,pawtab%l_size))
    2662            0 :      pawtab%shapefunc=reshape(list_dpr(ii:ii+siz_shapefunc-1),(/pawtab%mesh_size,pawtab%l_size/))
    2663            0 :      ii=ii+siz_shapefunc
    2664              :    end if
    2665          222 :    if (allocated(pawtab%tcoredens)) then
    2666           21 :      LIBPAW_DEALLOCATE(pawtab%tcoredens)
    2667              :    end if
    2668          222 :    if (siz_tcoredens>0) then
    2669          206 :      sz2=siz_tcoredens/pawtab%core_mesh_size
    2670          824 :      LIBPAW_ALLOCATE(pawtab%tcoredens,(pawtab%core_mesh_size,sz2))
    2671       191154 :      pawtab%tcoredens=reshape(list_dpr(ii:ii+siz_tcoredens-1),(/pawtab%core_mesh_size,sz2/))
    2672          206 :      ii=ii+siz_tcoredens
    2673              :    end if
    2674          222 :    if (allocated(pawtab%tcoretau)) then
    2675            3 :      LIBPAW_DEALLOCATE(pawtab%tcoretau)
    2676              :    end if
    2677          222 :    if (siz_tcoretau>0) then
    2678           18 :      LIBPAW_ALLOCATE(pawtab%tcoretau,(pawtab%coretau_mesh_size))
    2679         8742 :      pawtab%tcoretau=list_dpr(ii:ii+siz_tcoretau-1)
    2680              :      ii=ii+siz_tcoretau
    2681              :    end if
    2682          222 :    if (allocated(pawtab%tcorespl)) then
    2683           21 :      LIBPAW_DEALLOCATE(pawtab%tcorespl)
    2684              :    end if
    2685          222 :    if (siz_tcorespl>0) then
    2686          618 :      LIBPAW_ALLOCATE(pawtab%tcorespl,(pawtab%mqgrid,2))
    2687      1249642 :      pawtab%tcorespl=reshape(list_dpr(ii:ii+siz_tcorespl-1),(/pawtab%mqgrid,2/))
    2688          206 :      ii=ii+siz_tcorespl
    2689              :    end if
    2690          222 :    if (allocated(pawtab%tcoretauspl)) then
    2691           21 :      LIBPAW_DEALLOCATE(pawtab%tcoretauspl)
    2692              :    end if
    2693          222 :    if (siz_tcoretauspl>0) then
    2694           18 :      LIBPAW_ALLOCATE(pawtab%tcoretauspl,(pawtab%mqgrid,2))
    2695        36048 :      pawtab%tcoretauspl=reshape(list_dpr(ii:ii+siz_tcoretauspl-1),(/pawtab%mqgrid,2/))
    2696            6 :      ii=ii+siz_tcoretauspl
    2697              :    else
    2698          432 :      LIBPAW_ALLOCATE(pawtab%tcoretauspl,(pawtab%mqgrid,0))
    2699              :    end if
    2700          222 :    if (allocated(pawtab%tphi)) then
    2701           21 :      LIBPAW_DEALLOCATE(pawtab%tphi)
    2702              :    end if
    2703          222 :    if (siz_tphi>0) then
    2704          824 :      LIBPAW_ALLOCATE(pawtab%tphi,(pawtab%partialwave_mesh_size,pawtab%basis_size))
    2705      1104836 :      pawtab%tphi=reshape(list_dpr(ii:ii+siz_tphi-1),(/pawtab%partialwave_mesh_size,pawtab%basis_size/))
    2706          206 :      ii=ii+siz_tphi
    2707              :    end if
    2708          222 :    if (allocated(pawtab%tproj)) then
    2709            0 :      LIBPAW_DEALLOCATE(pawtab%tproj)
    2710              :    end if
    2711          222 :    if (siz_tproj>0) then
    2712            0 :      sz1=siz_tproj/pawtab%basis_size
    2713            0 :      LIBPAW_ALLOCATE(pawtab%tproj,(sz1,pawtab%basis_size))
    2714            0 :      pawtab%tproj=reshape(list_dpr(ii:ii+siz_tproj-1),(/sz1,pawtab%basis_size/))
    2715            0 :      ii=ii+siz_tproj
    2716              :    end if
    2717          222 :    if (allocated(pawtab%tvalespl)) then
    2718            3 :      LIBPAW_DEALLOCATE(pawtab%tvalespl)
    2719              :    end if
    2720          222 :    if (siz_tvalespl>0) then
    2721          131 :      sz1=siz_tvalespl/2
    2722          393 :      LIBPAW_ALLOCATE(pawtab%tvalespl,(sz1,2))
    2723       799042 :      pawtab%tvalespl=reshape(list_dpr(ii:ii+siz_tvalespl-1),(/sz1,2/))
    2724          131 :      ii=ii+siz_tvalespl
    2725              :    end if
    2726          222 :    if (allocated(pawtab%vhtnzc)) then
    2727           21 :      LIBPAW_DEALLOCATE(pawtab%vhtnzc)
    2728              :    end if
    2729          222 :    if (siz_vhtnzc>0) then
    2730          618 :      LIBPAW_ALLOCATE(pawtab%vhtnzc,(siz_vhtnzc))
    2731       277056 :      pawtab%vhtnzc=list_dpr(ii:ii+siz_vhtnzc-1)
    2732              :      ii=ii+siz_vhtnzc
    2733              :    end if
    2734          222 :    if (allocated(pawtab%vhnzc)) then
    2735           21 :      LIBPAW_DEALLOCATE(pawtab%vhnzc)
    2736              :    end if
    2737          222 :    if (siz_vhnzc>0) then
    2738          618 :      LIBPAW_ALLOCATE(pawtab%vhnzc,(pawtab%mesh_size))
    2739       190536 :      pawtab%vhnzc=list_dpr(ii:ii+pawtab%mesh_size-1)
    2740          206 :      ii=ii+siz_vhnzc
    2741              :    end if
    2742          222 :    if (allocated(pawtab%vminushalf)) then
    2743            0 :      LIBPAW_DEALLOCATE(pawtab%vminushalf)
    2744              :    end if
    2745          222 :    if (siz_vminushalf>0) then
    2746            0 :      LIBPAW_ALLOCATE(pawtab%vminushalf,(pawtab%mesh_size))
    2747            0 :      pawtab%vminushalf=list_dpr(ii:ii+pawtab%mesh_size-1)
    2748            0 :      ii=ii+siz_vminushalf
    2749              :    end if
    2750              : !Reals in datastructures (read from psp file)
    2751          222 :    if (siz_wvlpaw==1) then
    2752            0 :      if (allocated(pawtab%wvl%parg)) then
    2753            0 :        LIBPAW_DEALLOCATE(pawtab%wvl%parg)
    2754              :      end if
    2755            0 :      if (siz_wvl_parg>0) then
    2756            0 :        LIBPAW_ALLOCATE(pawtab%wvl%parg,(2,pawtab%wvl%ptotgau))
    2757            0 :        pawtab%wvl%parg=reshape(list_dpr(ii:ii+siz_wvl_parg-1),(/2,pawtab%wvl%ptotgau/))
    2758            0 :        ii=ii+siz_wvl_parg
    2759              :      end if
    2760            0 :      if (allocated(pawtab%wvl%pfac)) then
    2761            0 :        LIBPAW_DEALLOCATE(pawtab%wvl%pfac)
    2762              :      end if
    2763            0 :      if (siz_wvl_pfac>0) then
    2764            0 :        LIBPAW_ALLOCATE(pawtab%wvl%pfac,(2,pawtab%wvl%ptotgau))
    2765            0 :        pawtab%wvl%pfac=reshape(list_dpr(ii:ii+siz_wvl_pfac-1),(/2,pawtab%wvl%ptotgau/))
    2766            0 :        ii=ii+siz_wvl_pfac
    2767              :      end if
    2768            0 :      if (allocated(pawtab%wvl%rholoc%rad)) then
    2769            0 :         LIBPAW_DEALLOCATE(pawtab%wvl%rholoc%rad)
    2770              :      end if
    2771            0 :      if (siz_wvl_rholoc_rad>0) then
    2772            0 :         sz1=pawtab%wvl%rholoc%msz
    2773            0 :         LIBPAW_ALLOCATE(pawtab%wvl%rholoc%rad,(sz1))
    2774            0 :         pawtab%wvl%rholoc%rad=list_dpr(ii:ii+sz1-1)
    2775            0 :         ii=ii+siz_wvl_rholoc_rad
    2776              :      end if
    2777            0 :      if (allocated(pawtab%wvl%rholoc%d)) then
    2778            0 :         LIBPAW_DEALLOCATE(pawtab%wvl%rholoc%d)
    2779              :      end if
    2780            0 :      if (siz_wvl_rholoc_d>0) then
    2781            0 :         sz1=pawtab%wvl%rholoc%msz
    2782            0 :         LIBPAW_ALLOCATE(pawtab%wvl%rholoc%d,(sz1,4))
    2783            0 :         pawtab%wvl%rholoc%d=reshape(list_dpr(ii:ii+siz_wvl_rholoc_d-1),(/sz1,4/))
    2784            0 :         ii=ii+siz_wvl_rholoc_d
    2785              :      end if
    2786              :    end if
    2787              : 
    2788              : !Then the data initialized later
    2789              : !...................................
    2790          222 :    if (full_broadcast) then
    2791              : 
    2792              : !Reals
    2793           16 :      pawtab%exchmix=list_dpr(ii)  ;ii=ii+1
    2794           16 :      pawtab%f4of2_sla=list_dpr(ii)  ;ii=ii+1
    2795           16 :      pawtab%f6of2_sla=list_dpr(ii)  ;ii=ii+1
    2796           16 :      pawtab%jpawu=list_dpr(ii)  ;ii=ii+1
    2797           16 :      pawtab%upawu=list_dpr(ii)  ;ii=ii+1
    2798              : !Reals arrays
    2799           16 :      if (allocated(pawtab%dltij)) then
    2800            0 :        LIBPAW_DEALLOCATE(pawtab%dltij)
    2801              :      end if
    2802           16 :      if (siz_dltij>0) then
    2803            0 :        LIBPAW_ALLOCATE(pawtab%dltij,(pawtab%lmn2_size))
    2804            0 :        pawtab%dltij=list_dpr(ii:ii+pawtab%lmn2_size-1)
    2805            0 :        ii=ii+siz_dltij
    2806              :      end if
    2807           16 :      if (allocated(pawtab%dshpfunc)) then
    2808            0 :        LIBPAW_DEALLOCATE(pawtab%dshpfunc)
    2809              :      end if
    2810           16 :      if (siz_dshpfunc>0) then
    2811            0 :        LIBPAW_ALLOCATE(pawtab%dshpfunc,(pawtab%mesh_size,pawtab%l_size,4))
    2812            0 :        pawtab%dshpfunc=reshape(list_dpr(ii:ii+siz_dshpfunc-1),(/pawtab%mesh_size,pawtab%l_size,4/))
    2813            0 :        ii=ii+siz_dshpfunc
    2814              :      end if
    2815           16 :      if (allocated(pawtab%eijkl)) then
    2816            0 :        LIBPAW_DEALLOCATE(pawtab%eijkl)
    2817              :      end if
    2818           16 :      if (siz_eijkl>0) then
    2819            0 :        LIBPAW_ALLOCATE(pawtab%eijkl,(pawtab%lmn2_size,pawtab%lmn2_size))
    2820            0 :        pawtab%eijkl=reshape(list_dpr(ii:ii+siz_eijkl-1),(/pawtab%lmn2_size,pawtab%lmn2_size/))
    2821            0 :        ii=ii+siz_eijkl
    2822              :      end if
    2823           16 :      if (allocated(pawtab%eijkl_sr)) then
    2824            0 :        LIBPAW_DEALLOCATE(pawtab%eijkl_sr)
    2825              :      end if
    2826           16 :      if (siz_eijkl_sr>0) then
    2827            0 :        LIBPAW_ALLOCATE(pawtab%eijkl_sr,(pawtab%lmn2_size,pawtab%lmn2_size))
    2828            0 :        pawtab%eijkl_sr=reshape(list_dpr(ii:ii+siz_eijkl_sr-1),(/pawtab%lmn2_size,pawtab%lmn2_size/))
    2829            0 :        ii=ii+siz_eijkl_sr
    2830              :      end if
    2831           16 :      if (allocated(pawtab%euijkl)) then
    2832            0 :        LIBPAW_DEALLOCATE(pawtab%euijkl)
    2833              :      end if
    2834           16 :      if (siz_euijkl>0) then
    2835            0 :        LIBPAW_ALLOCATE(pawtab%euijkl,(3,pawtab%lmn_size,pawtab%lmn_size,pawtab%lmn_size,pawtab%lmn_size))
    2836            0 :        pawtab%euijkl=reshape(list_dpr(ii:ii+siz_euijkl-1),(/3,pawtab%lmn_size,pawtab%lmn_size,pawtab%lmn_size,pawtab%lmn_size/))
    2837            0 :        ii=ii+siz_euijkl
    2838              :      end if
    2839           16 :      if (allocated(pawtab%euij_fll)) then
    2840            0 :        LIBPAW_DEALLOCATE(pawtab%euij_fll)
    2841              :      end if
    2842           16 :      if (siz_euij_fll>0) then
    2843            0 :        LIBPAW_ALLOCATE(pawtab%euij_fll,(pawtab%lmn2_size))
    2844            0 :        pawtab%euij_fll=reshape(list_dpr(ii:ii+siz_euij_fll-1),(/pawtab%lmn2_size/))
    2845            0 :        ii=ii+siz_euij_fll
    2846              :      end if
    2847           16 :      if (allocated(pawtab%fk)) then
    2848            0 :        LIBPAW_DEALLOCATE(pawtab%fk)
    2849              :      end if
    2850           16 :      if (siz_fk>0) then
    2851            0 :        LIBPAW_ALLOCATE(pawtab%fk,(6,4))
    2852            0 :        pawtab%fk=reshape(list_dpr(ii:ii+siz_fk-1),(/6,4/))
    2853            0 :        ii=ii+siz_fk
    2854              :      end if
    2855           16 :      if (allocated(pawtab%gammaij)) then
    2856            0 :        LIBPAW_DEALLOCATE(pawtab%gammaij)
    2857              :      end if
    2858           16 :      if (siz_gammaij>0) then
    2859            0 :        LIBPAW_ALLOCATE(pawtab%gammaij,(pawtab%l_size))
    2860            0 :        pawtab%gammaij=list_dpr(ii:ii+pawtab%l_size-1)
    2861            0 :        ii=ii+siz_gammaij
    2862              :      end if
    2863           16 :      if (allocated(pawtab%gnorm)) then
    2864            0 :        LIBPAW_DEALLOCATE(pawtab%gnorm)
    2865              :      end if
    2866           16 :      if (siz_gnorm>0) then
    2867            0 :        LIBPAW_ALLOCATE(pawtab%gnorm,(pawtab%l_size))
    2868            0 :        pawtab%gnorm=list_dpr(ii:ii+pawtab%l_size-1)
    2869            0 :        ii=ii+siz_gnorm
    2870              :      end if
    2871           16 :      if (allocated(pawtab%nabla_ij)) then
    2872            0 :        LIBPAW_DEALLOCATE(pawtab%nabla_ij)
    2873              :      end if
    2874           16 :      if (siz_nabla_ij>0) then
    2875            0 :        LIBPAW_ALLOCATE(pawtab%nabla_ij,(3,pawtab%lmn_size,pawtab%lmn_size))
    2876            0 :        pawtab%nabla_ij=reshape(list_dpr(ii:ii+siz_nabla_ij-1),(/3,pawtab%lmn_size,pawtab%lmn_size/))
    2877            0 :        ii=ii+siz_nabla_ij
    2878              :      end if
    2879           16 :      if (allocated(pawtab%nabla_im_ij)) then
    2880            0 :        LIBPAW_DEALLOCATE(pawtab%nabla_im_ij)
    2881              :      end if
    2882           16 :      if (siz_nabla_im_ij>0) then
    2883            0 :        LIBPAW_ALLOCATE(pawtab%nabla_im_ij,(3,pawtab%lmn_size,pawtab%lmn_size))
    2884            0 :        pawtab%nabla_im_ij=reshape(list_dpr(ii:ii+siz_nabla_im_ij-1),(/3,pawtab%lmn_size,pawtab%lmn_size/))
    2885            0 :        ii=ii+siz_nabla_im_ij
    2886              :      end if
    2887           16 :      if (allocated(pawtab%nablaphi)) then
    2888            0 :        LIBPAW_DEALLOCATE(pawtab%nablaphi)
    2889              :      end if
    2890           16 :      if (siz_nablaphi>0) then
    2891            0 :        LIBPAW_ALLOCATE(pawtab%nablaphi,(pawtab%partialwave_mesh_size,pawtab%basis_size))
    2892            0 :        pawtab%nablaphi=reshape(list_dpr(ii:ii+siz_nablaphi-1),(/pawtab%partialwave_mesh_size,pawtab%basis_size/))
    2893            0 :        ii=ii+siz_nablaphi
    2894              :      end if
    2895           16 :      if (allocated(pawtab%phiphj)) then
    2896            0 :        LIBPAW_DEALLOCATE(pawtab%phiphj)
    2897              :      end if
    2898           16 :      if (siz_phiphj>0) then
    2899            0 :        LIBPAW_ALLOCATE(pawtab%phiphj,(pawtab%mesh_size,pawtab%ij_size))
    2900            0 :        pawtab%phiphj=reshape(list_dpr(ii:ii+siz_phiphj-1),(/pawtab%mesh_size,pawtab%ij_size/))
    2901            0 :        ii=ii+siz_phiphj
    2902              :      end if
    2903           16 :      if (allocated(pawtab%phiphjint)) then
    2904            0 :        LIBPAW_DEALLOCATE(pawtab%phiphjint)
    2905              :      end if
    2906           16 :      if (siz_phiphjint>0) then
    2907            0 :        LIBPAW_ALLOCATE(pawtab%phiphjint,(pawtab%ij_proj))
    2908            0 :        pawtab%phiphjint=list_dpr(ii:ii+pawtab%ij_proj-1)
    2909            0 :        ii=ii+siz_phiphjint
    2910              :      end if
    2911           16 :      if (allocated(pawtab%ph0phiint)) then
    2912            0 :        LIBPAW_DEALLOCATE(pawtab%ph0phiint)
    2913              :      end if
    2914           16 :      if (siz_ph0phiint>0) then
    2915            0 :        LIBPAW_ALLOCATE(pawtab%ph0phiint,(pawtab%ij_proj))
    2916            0 :        pawtab%ph0phiint=list_dpr(ii:ii+pawtab%ij_proj-1)
    2917            0 :        ii=ii+siz_ph0phiint
    2918              :      end if
    2919           16 :      if (allocated(pawtab%proj)) then
    2920            0 :        LIBPAW_DEALLOCATE(pawtab%proj)
    2921              :      end if
    2922           16 :      if (siz_proj>0) then
    2923            0 :        LIBPAW_ALLOCATE(pawtab%proj,(siz_proj))
    2924            0 :        pawtab%proj=list_dpr(ii:ii+siz_proj-1)
    2925              :        ii=ii+siz_proj
    2926              :      end if
    2927           16 :      if (allocated(pawtab%proj2)) then
    2928            0 :        LIBPAW_DEALLOCATE(pawtab%proj2)
    2929              :      end if
    2930           16 :      if (siz_proj2>0) then
    2931            0 :        LIBPAW_ALLOCATE(pawtab%proj2,(siz_proj2))
    2932            0 :        pawtab%proj2=list_dpr(ii:ii+siz_proj2-1)
    2933              :        ii=ii+siz_proj2
    2934              :      end if
    2935           16 :      if (allocated(pawtab%qgrid_shp)) then
    2936            0 :        LIBPAW_DEALLOCATE(pawtab%qgrid_shp)
    2937              :      end if
    2938           16 :      if (siz_qgrid_shp>0) then
    2939            0 :        LIBPAW_ALLOCATE(pawtab%qgrid_shp,(pawtab%mqgrid_shp))
    2940            0 :        pawtab%qgrid_shp=list_dpr(ii:ii+pawtab%mqgrid_shp-1)
    2941            0 :        ii=ii+siz_qgrid_shp
    2942              :      end if
    2943           16 :      if (allocated(pawtab%qijl)) then
    2944            0 :        LIBPAW_DEALLOCATE(pawtab%qijl)
    2945              :      end if
    2946           16 :      if (siz_qijl>0) then
    2947            0 :        LIBPAW_ALLOCATE(pawtab%qijl,(pawtab%l_size**2,pawtab%lmn2_size))
    2948            0 :        pawtab%qijl=reshape(list_dpr(ii:ii+siz_qijl-1),(/pawtab%l_size**2,pawtab%lmn2_size/))
    2949            0 :        ii=ii+siz_qijl
    2950              :      end if
    2951           16 :      if (allocated(pawtab%rad_for_spline)) then
    2952            0 :        LIBPAW_DEALLOCATE(pawtab%rad_for_spline)
    2953              :      end if
    2954           16 :      if (siz_rad_for_spline>0) then
    2955            0 :        LIBPAW_ALLOCATE(pawtab%rad_for_spline,(pawtab%mesh_size))
    2956            0 :        pawtab%rad_for_spline=list_dpr(ii:ii+pawtab%mesh_size-1)
    2957            0 :        ii=ii+siz_rad_for_spline
    2958              :      end if
    2959           16 :      if (allocated(pawtab%shapefncg)) then
    2960            0 :        LIBPAW_DEALLOCATE(pawtab%shapefncg)
    2961              :      end if
    2962           16 :      if (siz_shapefncg>0) then
    2963            0 :        LIBPAW_ALLOCATE(pawtab%shapefncg,(pawtab%mqgrid_shp,2,pawtab%l_size))
    2964            0 :        pawtab%shapefncg=reshape(list_dpr(ii:ii+siz_shapefncg-1),(/pawtab%mqgrid_shp,2,pawtab%l_size/))
    2965            0 :        ii=ii+siz_shapefncg
    2966              :      end if
    2967           16 :      if (allocated(pawtab%sij)) then
    2968            0 :        LIBPAW_DEALLOCATE(pawtab%sij)
    2969              :      end if
    2970           16 :      if (siz_sij>0) then
    2971            0 :        LIBPAW_ALLOCATE(pawtab%sij,(pawtab%lmn2_size))
    2972            0 :        pawtab%sij=list_dpr(ii:ii+pawtab%lmn2_size-1)
    2973            0 :        ii=ii+siz_sij
    2974              :      end if
    2975           16 :     if (allocated(pawtab%tnablaphi)) then
    2976            0 :        LIBPAW_DEALLOCATE(pawtab%tnablaphi)
    2977              :      end if
    2978           16 :      if (siz_tnablaphi>0) then
    2979            0 :        LIBPAW_ALLOCATE(pawtab%tnablaphi,(pawtab%partialwave_mesh_size,pawtab%basis_size))
    2980            0 :        pawtab%tphi=reshape(list_dpr(ii:ii+siz_tnablaphi-1),(/pawtab%partialwave_mesh_size,pawtab%basis_size/))
    2981            0 :        ii=ii+siz_tnablaphi
    2982              :      end if
    2983           16 :      if (allocated(pawtab%tphitphj)) then
    2984            0 :        LIBPAW_DEALLOCATE(pawtab%tphitphj)
    2985              :      end if
    2986           16 :      if (siz_tphitphj>0) then
    2987            0 :        LIBPAW_ALLOCATE(pawtab%tphitphj,(pawtab%mesh_size,pawtab%ij_size))
    2988            0 :        pawtab%tphitphj=reshape(list_dpr(ii:ii+siz_tphitphj-1),(/pawtab%mesh_size,pawtab%ij_size/))
    2989            0 :        ii=ii+siz_tphitphj
    2990              :      end if
    2991           16 :      if (allocated(pawtab%vee)) then
    2992            0 :        LIBPAW_DEALLOCATE(pawtab%vee)
    2993              :      end if
    2994           16 :      if (siz_vee>0) then
    2995            0 :        sz1=2*pawtab%lpawu+1
    2996            0 :        LIBPAW_ALLOCATE(pawtab%vee,(sz1,sz1,sz1,sz1))
    2997            0 :        pawtab%vee=reshape(list_dpr(ii:ii+siz_vee-1),(/sz1,sz1,sz1,sz1/))
    2998            0 :        ii=ii+siz_vee
    2999              :      end if
    3000           16 :      if (allocated(pawtab%vex)) then
    3001            0 :        LIBPAW_DEALLOCATE(pawtab%vex)
    3002              :      end if
    3003           16 :      if (siz_vex>0) then
    3004            0 :        sz1=2*pawtab%lexexch+1
    3005            0 :        LIBPAW_ALLOCATE(pawtab%vex,(sz1,sz1,sz1,sz1,4))
    3006            0 :        pawtab%vex=reshape(list_dpr(ii:ii+siz_vex-1),(/sz1,sz1,sz1,sz1,4/))
    3007            0 :        ii=ii+siz_vex
    3008              :      end if
    3009           16 :      if (allocated(pawtab%zioneff)) then
    3010            0 :        LIBPAW_DEALLOCATE(pawtab%zioneff)
    3011              :      end if
    3012           16 :      if (siz_zioneff>0) then
    3013            0 :        LIBPAW_ALLOCATE(pawtab%zioneff,(pawtab%ij_proj))
    3014            0 :        pawtab%zioneff=list_dpr(ii:ii+pawtab%ij_proj-1)
    3015            0 :        ii=ii+siz_zioneff
    3016              :      end if
    3017              : 
    3018              :    end if ! full_broadcast
    3019          222 :    ii=ii-1
    3020              : 
    3021          222 :    if (ii/=nn_dpr+nn_dpr_arr) then
    3022            0 :      msg='the number of broadcasted reals is not correct!'
    3023            0 :      LIBPAW_BUG(msg)
    3024              :    end if
    3025              : 
    3026              :  end if ! me/=0
    3027          300 :  LIBPAW_DEALLOCATE(list_dpr)
    3028              : 
    3029          300 : end subroutine pawtab_bcast
    3030              : !!***
    3031              : 
    3032              : !----------------------------------------------------------------------
    3033              : 
    3034              : !!****f* m_pawtab/wvlpaw_allocate
    3035              : !! NAME
    3036              : !!  wvlpaw_allocate
    3037              : !!
    3038              : !! FUNCTION
    3039              : !!  Allocate (if necessary) and nullify content of a wvlpaw pointer
    3040              : !!
    3041              : !! SIDE EFFECTS
    3042              : !!  wvlpaw<type(wvlpaw_type)>=datastructure to be allocated.
    3043              : !!
    3044              : !! SOURCE
    3045              : 
    3046            0 : subroutine wvlpaw_allocate(wvlpaw)
    3047              : 
    3048              : !Arguments ------------------------------------
    3049              :  type(wvlpaw_type),pointer :: wvlpaw
    3050              : 
    3051              : ! *************************************************************************
    3052              : 
    3053              :  !@wvlpaw_type
    3054              : 
    3055            0 :  if (.not.associated(wvlpaw)) then
    3056            0 :    LIBPAW_DATATYPE_ALLOCATE(wvlpaw,)
    3057            0 :    call wvlpaw_nullify(wvlpaw)
    3058              :  end if
    3059              : 
    3060            0 :  wvlpaw%npspcode_init_guess=10
    3061              : 
    3062            0 : end subroutine wvlpaw_allocate
    3063              : !!***
    3064              : 
    3065              : !----------------------------------------------------------------------
    3066              : 
    3067              : !!****f* m_pawtab/wvlpaw_free
    3068              : !! NAME
    3069              : !!  wvlpaw_free
    3070              : !!
    3071              : !! FUNCTION
    3072              : !!  Deallocate arrays and nullify flags in a wvlpaw structure
    3073              : !!
    3074              : !! SIDE EFFECTS
    3075              : !!  wvlpaw<type(wvlpaw_type)>=datastructure to be destroyed.
    3076              : !!  All allocated arrays are deallocated.
    3077              : !!
    3078              : !! SOURCE
    3079              : 
    3080         2461 : subroutine wvlpaw_free(wvlpaw)
    3081              : 
    3082              : !Arguments ------------------------------------
    3083              :  type(wvlpaw_type),pointer :: wvlpaw
    3084              : 
    3085              : ! *************************************************************************
    3086              : 
    3087              :  !@wvlpaw_type
    3088              : 
    3089         2461 :  if (.not.associated(wvlpaw)) return
    3090              : 
    3091            0 :  if(allocated(wvlpaw%pngau)) then
    3092            0 :    LIBPAW_DEALLOCATE(wvlpaw%pngau)
    3093              :  end if
    3094            0 :  if(allocated(wvlpaw%parg)) then
    3095            0 :    LIBPAW_DEALLOCATE(wvlpaw%parg)
    3096              :  end if
    3097            0 :  if(allocated(wvlpaw%pfac)) then
    3098            0 :    LIBPAW_DEALLOCATE(wvlpaw%pfac)
    3099              :  end if
    3100              : 
    3101            0 :  wvlpaw%npspcode_init_guess=0
    3102            0 :  wvlpaw%ptotgau=0
    3103              : 
    3104            0 :  call wvlpaw_rholoc_free(wvlpaw%rholoc)
    3105              : 
    3106            0 :  LIBPAW_DATATYPE_DEALLOCATE(wvlpaw)
    3107              : 
    3108              : end subroutine wvlpaw_free
    3109              : !!***
    3110              : 
    3111              : !----------------------------------------------------------------------
    3112              : 
    3113              : !!****f* m_pawtab/wvlpaw_nullify
    3114              : !! NAME
    3115              : !!  wvlpaw_nullify
    3116              : !!
    3117              : !! FUNCTION
    3118              : !!  Nullify flags in a wvlpaw structure
    3119              : !!
    3120              : !! SIDE EFFECTS
    3121              : !!  wvlpaw=datastructure to be nullified
    3122              : !!
    3123              : !! SOURCE
    3124              : 
    3125            0 : subroutine wvlpaw_nullify(wvlpaw)
    3126              : 
    3127              : !Arguments ------------------------------------
    3128              :  type(wvlpaw_type),pointer :: wvlpaw
    3129              : 
    3130              : ! *************************************************************************
    3131              : 
    3132              :  !@wvlpaw_type
    3133            0 :  if (.not.associated(wvlpaw)) return
    3134              : 
    3135            0 :  wvlpaw%npspcode_init_guess=0
    3136            0 :  wvlpaw%ptotgau=0
    3137              : 
    3138            0 :  call wvlpaw_rholoc_nullify(wvlpaw%rholoc)
    3139              : 
    3140              : end subroutine wvlpaw_nullify
    3141              : !!***
    3142              : 
    3143              : !----------------------------------------------------------------------
    3144              : 
    3145              : !!****f* m_pawtab/wvlpaw_rholoc_free
    3146              : !! NAME
    3147              : !!  wvlpaw_rholoc_free
    3148              : !!
    3149              : !! FUNCTION
    3150              : !!  Deallocate arrays and nullify flags in a wvlpaw%rholoc structure
    3151              : !!
    3152              : !! SIDE EFFECTS
    3153              : !!  wvlpaw_rholoc<type(wvlpaw_rholoc_type)>=datastructure to be destroyed.
    3154              : !!  All allocated arrays are deallocated.
    3155              : !!
    3156              : !! SOURCE
    3157              : 
    3158            0 : subroutine wvlpaw_rholoc_free(wvlpaw_rholoc)
    3159              : 
    3160              : !Arguments ------------------------------------
    3161              :  type(wvlpaw_rholoc_type),intent(inout) :: wvlpaw_rholoc
    3162              : 
    3163              : ! *************************************************************************
    3164              : 
    3165              :  !@wvlpaw_rholoc_type
    3166              : 
    3167            0 :  if(allocated(wvlpaw_rholoc%d)) then
    3168            0 :    LIBPAW_DEALLOCATE(wvlpaw_rholoc%d)
    3169              :  end if
    3170            0 :  if(allocated(wvlpaw_rholoc%rad)) then
    3171            0 :    LIBPAW_DEALLOCATE(wvlpaw_rholoc%rad)
    3172              :  end if
    3173              : 
    3174            0 :  wvlpaw_rholoc%msz=0
    3175              : 
    3176            0 : end subroutine wvlpaw_rholoc_free
    3177              : !!***
    3178              : 
    3179              : !----------------------------------------------------------------------
    3180              : 
    3181              : !!****f* m_pawtab/wvlpaw_rholoc_nullify
    3182              : !! NAME
    3183              : !!  wvlpaw_rholoc_nullify
    3184              : !!
    3185              : !! FUNCTION
    3186              : !!  Nullify flags in a wvlpaw%rholoc structure
    3187              : !!
    3188              : !! SIDE EFFECTS
    3189              : !!  wvlpaw_rholoc<type(wvlpaw_rholoc_type)>=datastructure to be nullified.
    3190              : !!
    3191              : !! SOURCE
    3192              : 
    3193            0 : subroutine wvlpaw_rholoc_nullify(wvlpaw_rholoc)
    3194              : 
    3195              : !Arguments ------------------------------------
    3196              :  type(wvlpaw_rholoc_type),intent(inout) :: wvlpaw_rholoc
    3197              : 
    3198              : ! *************************************************************************
    3199              : 
    3200              :  !@wvlpaw_rholoc_type
    3201              : 
    3202            0 :  wvlpaw_rholoc%msz=0
    3203              : 
    3204            0 : end subroutine wvlpaw_rholoc_nullify
    3205              : !!***
    3206              : 
    3207              : !----------------------------------------------------------------------
    3208              : 
    3209            0 : END MODULE m_pawtab
    3210              : !!***
        

Generated by: LCOV version 2.3-1