LCOV - code coverage report
Current view: top level - src/57_iovars - m_invars2.F90 (source / functions) Coverage Total Hit
Test: coverage.info Lines: 87.6 % 2901 2540
Test Date: 2026-09-20 18:56:22 Functions: 100.0 % 2 2

            Line data    Source code
       1              : !!****m* ABINIT/m_invars2
       2              : !! NAME
       3              : !!  m_invars2
       4              : !!
       5              : !! FUNCTION
       6              : !!
       7              : !!
       8              : !! COPYRIGHT
       9              : !!  Copyright (C) 1999-2026 ABINIT group (XG)
      10              : !!  This file is distributed under the terms of the
      11              : !!  GNU General Public License, see ~abinit/COPYING
      12              : !!  or http://www.gnu.org/copyleft/gpl.txt .
      13              : !!
      14              : !! SOURCE
      15              : 
      16              : #if defined HAVE_CONFIG_H
      17              : #include "config.h"
      18              : #endif
      19              : 
      20              : #include "abi_common.h"
      21              : 
      22              : module m_invars2
      23              : 
      24              :  use defs_basis
      25              :  use m_abicore
      26              :  use m_errors
      27              :  use m_xmpi
      28              :  use m_nctk
      29              :  use m_sort
      30              :  use m_dtset
      31              :  use libxc_functionals
      32              :  use netcdf
      33              : 
      34              :  use defs_datatypes, only : pspheader_type
      35              :  use m_time,      only : timab
      36              :  use m_fstrings,  only : sjoin, itoa, ltoa, tolower, toupper
      37              :  use m_matrix,    only : matr3inv
      38              :  use m_parser,    only : intagm, intagm_img
      39              :  use m_geometry,  only : mkrdim, metric
      40              :  use m_gsphere,   only : setshells
      41              :  use m_xcdata,    only : get_auxc_ixc, get_xclevel
      42              :  use m_inkpts,    only : inkpts
      43              :  use m_ingeo,     only : invacuum
      44              :  use m_ipi,       only : ipi_check_initial_consistency
      45              :  use m_crystal,   only : crystal_t
      46              :  use m_bz_mesh,   only : kmesh_t
      47              :  use m_drivexc,   only : has_kxc
      48              :  use m_mep,       only : MEP_SOLVER_STEEPEST,NEB_ALGO_CINEB
      49              : 
      50              :  implicit none
      51              : 
      52              :  private
      53              : !!***
      54              : 
      55              :  public :: invars2m
      56              :  public :: invars2
      57              : !!***
      58              : 
      59              : contains
      60              : !!***
      61              : 
      62              : !!****f* ABINIT/invars2m
      63              : !! NAME
      64              : !! invars2m
      65              : !!
      66              : !! FUNCTION
      67              : !! Initialisation phase - main input routine.
      68              : !! Big loop on the datasets :
      69              : !! - for each of the datasets, write one line about the crystallographic data
      70              : !! - call invars2, that read the eventual single dataset input values;
      71              : !! - compute mgfft,mpw,nfft,... for this data set;
      72              : !! - compute quantities for the susceptibility computation
      73              : !! - compute the memory needs for this data set.
      74              : !!
      75              : !! INPUTS
      76              : !!  bravais_(11,0:ndtset_alloc)=characteristics of Bravais lattice
      77              : !!  iout=unit number of output file
      78              : !!  lenstr=actual length of string
      79              : !!  mband_upper_(0:ndtset_alloc)=list of mband_upper values
      80              : !!  msym=default maximal number of symmetries
      81              : !!  ndtset= number of datasets to be read; if 0, no multi-dataset mode
      82              : !!  ndtset_alloc=number of datasets, corrected for allocation of at least
      83              : !!      one data set.
      84              : !!  npsp=number of pseudopotentials
      85              : !!  pspheads(npsp)=<type pspheader_type>all the important information from the
      86              : !!   pseudopotential file header, as well as the psp file name
      87              : !!  string*(*)=character string containing all the input data.
      88              : !!   Initialized previously in instrng.
      89              : !! comm=MPI communicator
      90              : !!
      91              : !! OUTPUT
      92              : !!  dtsets(0:ndtset_alloc)=<type datafiles_type>contains all input variables,
      93              : !!   some of which are initialized here, while other were already
      94              : !!   initialized previously.
      95              : !!
      96              : !! NOTES
      97              : !! The outputs of this routine are the values of input variables,
      98              : !! their default value is stored at the index 0 of the last dimension
      99              : !! of their multi-dataset representation.
     100              : !!
     101              : !! SOURCE
     102              : 
     103         1428 : subroutine invars2m(dtsets,iout,lenstr,mband_upper_,msym,ndtset,ndtset_alloc,npsp,pspheads,string, comm)
     104              : 
     105              : !Arguments ------------------------------------
     106              : !scalars
     107              :  integer,intent(in) :: iout,lenstr,msym,ndtset,ndtset_alloc,npsp, comm
     108              :  character(len=*),intent(in) :: string
     109              : !arrays
     110              :  integer,intent(in) :: mband_upper_(0:ndtset_alloc)
     111              :  type(dataset_type),intent(inout) :: dtsets(0:ndtset_alloc)
     112              :  type(pspheader_type),intent(in) :: pspheads(npsp)
     113              : 
     114              : !Local variables -------------------------------
     115              : !scalars
     116              :  integer :: idtset,jdtset,mband_upper,nsheps,nshsigx,nshwfn,usepaw
     117              :  !integer,parameter :: master = 0
     118              :  real(dp) :: ucvol
     119              : !arrays
     120              :  integer :: bravais(11)
     121              :  real(dp) :: gmet(3,3),gprimd(3,3),rmet(3,3),rprimd(3,3)
     122         1428 :  real(dp),allocatable :: zionpsp(:)
     123              : !*************************************************************************
     124              : 
     125         8387 :  do idtset=1,ndtset_alloc
     126         6959 :    jdtset=dtsets(idtset)%jdtset ; if(ndtset==0)jdtset=0
     127        83508 :    bravais(:)=dtsets(idtset)%bravais(:)
     128         6959 :    mband_upper  =mband_upper_(idtset)
     129         6959 :    usepaw=dtsets(idtset)%usepaw
     130              :    ! Allocate arrays
     131        20877 :    ABI_MALLOC(zionpsp,(npsp))
     132        15565 :    zionpsp(:)=pspheads(1:npsp)%zionpsp
     133              : 
     134         6959 :    call mkrdim(dtsets(idtset)%acell_orig(1:3,1),dtsets(idtset)%rprim_orig(1:3,1:3,1),rprimd)
     135         6959 :    call metric(gmet,gprimd,-1,rmet,rprimd,ucvol)
     136              : 
     137              :    ! Here, nearly all the remaining input variables are initialized
     138         6959 :    call invars2(bravais,dtsets(idtset),iout,jdtset,lenstr,mband_upper,msym,npsp,string,usepaw,zionpsp,ucvol,comm)
     139              : 
     140         6959 :    ABI_FREE(zionpsp)
     141              : 
     142         8387 :    if (ANY(dtsets(idtset)%optdriver == [RUNL_SCREENING,RUNL_SIGMA,RUNL_BSE])) then
     143              :     ! For GW or BSE calculations, we only use (npwwfn|ecutwfn) G-vectors read from the KSS file,
     144              :     ! therefore the FFT box for the density should be defined according to ecut=ecutwfn.
     145              : 
     146          378 :      nshwfn=0
     147              :      call setshells(dtsets(idtset)%ecutwfn,dtsets(idtset)%npwwfn,nshwfn,&
     148          378 :        dtsets(idtset)%nsym,gmet,gprimd,dtsets(idtset)%symrel,'wfn',ucvol)
     149              : 
     150              :      ! MG: Hack to avoid portability problems under gfortran:
     151              :      ! getng and getmpw are indeed quite sensitive if ecut is small
     152              :      ! and, in the GW tests, mpw and ngfft might depend on the compiler used.
     153              :      ! the problem shows up if we use npwwfn instead of ecutwfn, a good reason for removing npwwfn!
     154          378 :      dtsets(idtset)%ecutwfn=dtsets(idtset)%ecutwfn-tol14
     155              :      ! MG: This is a kind of a hack, but the problem is ecutwfn that is too much redundant!
     156          378 :      dtsets(idtset)%ecut=dtsets(idtset)%ecutwfn
     157              : 
     158              :      ! Close the shell for (W|chi0)
     159          378 :      nsheps=0
     160              :      call setshells(dtsets(idtset)%ecuteps,dtsets(idtset)%npweps,nsheps,&
     161          378 :       dtsets(idtset)%nsym,gmet,gprimd,dtsets(idtset)%symrel,'eps',ucvol)
     162              : 
     163              :      ! Close the shell for the exchange term.
     164          378 :      nshsigx=0
     165              :      call setshells(dtsets(idtset)%ecutsigx,dtsets(idtset)%npwsigx,nshsigx,&
     166          378 :       dtsets(idtset)%nsym,gmet,gprimd,dtsets(idtset)%symrel,'sigx',ucvol)
     167              :    end if ! (SIGMA|SCREENING|SCGW|BSE|RDFTM)
     168              : 
     169              :  end do
     170              : 
     171         1428 : end subroutine invars2m
     172              : !!***
     173              : 
     174              : !!****f* ABINIT/invars2
     175              : !! NAME
     176              : !! invars2
     177              : !!
     178              : !! FUNCTION
     179              : !! Initialize variables for the ABINIT code, for one particular dataset, characterized by jdtset.
     180              : !! Note: some parameters have already been read in invars0 and invars1,
     181              : !! and were used to dimension the arrays needed here.
     182              : !!
     183              : !! INPUTS
     184              : !! bravais(11): bravais(1)=iholohedry
     185              : !!              bravais(2)=center
     186              : !!              bravais(3:11)=coordinates of rprim in the axes
     187              : !!               of the conventional bravais lattice (*2 if center/=0)
     188              : !! iout=unit number for echoed output
     189              : !! jdtset=number of the dataset looked for
     190              : !! lenstr=actual length of the string
     191              : !! mband=maximum number of bands for any k-point
     192              : !! msym=default maximal number of symmetries
     193              : !! npsp=number of pseudopotentials
     194              : !! string*(*)=character string containing all the input data.
     195              : !!  Initialized previously in instrng.
     196              : !! usepaw= 0 for non paw calculation; =1 for paw calculation
     197              : !! zionpsp(npsp)=valence charge of each type of atom (coming from the psp files)
     198              : !! ucvol: Unit cell volume
     199              : !! comm=MPI communicator
     200              : !!
     201              : !! OUTPUT
     202              : !!  (see side effects)
     203              : !!
     204              : !! SIDE EFFECTS
     205              : !! Input/Output:
     206              : !!  dtset=<type datafiles_type>contains all input variables,
     207              : !!   some of which are initialized here, while other were already
     208              : !! All rest of arguments given alphabetically from acell (length scales)
     209              : !! to wtk (k-point weights), used to control running of the main routine.
     210              : !! See abinit_help for definitions of these variables.
     211              : !! These values become defined by being read from string,
     212              : !! that contains all information from the input file,
     213              : !! in a compressed, standardized, format
     214              : !! At the input, they already contain a default value.
     215              : !!
     216              : !! SOURCE
     217              : 
     218         6959 : subroutine invars2(bravais,dtset,iout,jdtset,lenstr,mband,msym,npsp,string,usepaw,zionpsp,ucvol,comm)
     219              : 
     220              : !Arguments ------------------------------------
     221              : !scalars
     222              :  integer,intent(in) :: iout,jdtset,lenstr,mband,msym,npsp,usepaw, comm
     223              :  character(len=*),intent(in) :: string
     224              :  type(dataset_type),intent(inout) :: dtset
     225              :  real(dp),intent(in) :: ucvol
     226              : !arrays
     227              :  integer,intent(in) :: bravais(11)
     228              :  real(dp),intent(in) :: zionpsp(npsp)
     229              : 
     230              : !Local variables-------------------------------
     231              : !scalars
     232              :  integer,parameter :: master = 0
     233              :  integer :: bantot,berryopt,dmatsize,ndim,getocc,narr,nprocs
     234              :  integer :: iat,iatom,iband,ii,iimage,ikpt,intimage,ionmov,isppol,ixc_here
     235              :  integer :: densfor_pred,ipsp,iscf,isiz,itypat,jj,kptopt,lpawu,marr,natom,natomcor,nband1,nberry
     236              :  integer :: niatcon,nimage,nkpt,nkpthf,npspalch,nqpt,nsp,nspinor,nsppol,nsym,ntypalch,ntypat,ntyppure
     237              :  integer :: occopt,occopt_tmp,response,sumnbl,tfband,tnband,tread,tread_alt,tread_dft,tread_fock,tread_key,tread_extrael
     238              :  integer :: tread_brange, tread_erange, tread_kfilter, tread_qgbt, tread_cart
     239              :  integer :: itol, itol_gen, ds_input, ifreq, ncerr, ierr, image, tread_dipdip, my_rank
     240              :  integer :: itol_wfr, itol_gen_wfr
     241              :  logical :: xc_is_mgga,xc_is_pot_only,xc_need_kden,xc_has_kxc
     242              :  real(dp) :: areaxy,cellcharge_min,fband,kptrlen,nelectjell,sum_spinat
     243              :  real(dp) :: rhoavg,zelect,zval
     244              :  real(dp) :: toldfe_, tolrff_, toldff_, tolwfr_, tolvrs_, toldmag_
     245              :  real(dp) :: tolmxde_, tolmxf_
     246              :  character(len=500) :: msg
     247              :  character(len=fnlen) :: key_value
     248       361868 :  type(crystal_t) :: cryst
     249       180934 :  type(kmesh_t) :: kmesh, qmesh
     250              : !arrays
     251              :  integer :: vacuum(3)
     252         6959 :  integer,allocatable :: iatcon(:),natcon(:), intarr(:)
     253              :  real(dp) :: tsec(2),rprimd(3,3) ! qgbt(3),
     254         6959 :  real(dp),allocatable :: dmatpawu_tmp(:), dprarr(:)
     255        20877 :  type(libxc_functional_type) :: xcfunc(2)
     256              : ! *************************************************************************
     257              : 
     258         6959 :  call timab(191,1,tsec)
     259              : 
     260         6959 :  nprocs = xmpi_comm_size(comm); my_rank = xmpi_comm_rank(comm)
     261              : 
     262              :  ! Compute the maximum size of arrays intarr and dprarr
     263         6959 :  natom=dtset%natom
     264         6959 :  nimage=dtset%nimage
     265         6959 :  nkpt=dtset%nkpt
     266         6959 :  nkpthf=dtset%nkpthf
     267         6959 :  npspalch=dtset%npspalch
     268         6959 :  nspinor=dtset%nspinor
     269         6959 :  nsppol=dtset%nsppol
     270         6959 :  ntypat=dtset%ntypat
     271         6959 :  ntypalch=dtset%ntypalch
     272         6959 :  ntyppure=dtset%ntyppure
     273              : 
     274         6959 :  dmatsize=0 ! dmatpu not available for usepawu<0
     275         6959 :  if (dtset%usepawu>0.and.dtset%usedmatpu/=0) then
     276           64 :    do iatom=1,natom
     277           49 :      lpawu=dtset%lpawu(dtset%typat(iatom))
     278           64 :      if (lpawu/=-1) dmatsize=dmatsize+nsppol*nspinor*(2*lpawu+1)**2
     279              :    end do
     280              :  end if
     281              : 
     282              :  marr=max(3*natom,&
     283              :    nkpt*nsppol*mband,&
     284              :    2*dtset%nkptgw*nsppol,&
     285              :    dmatsize,&
     286              :    3*nkpt,&
     287              :    npsp,&
     288              :    ntypat,&
     289              :    9*msym,&
     290              :    60,100,&
     291              :    3*dtset%nconeq*natom,&
     292              :    nimage,&
     293              :    3*dtset%nqptdm,&
     294              :    3*dtset%natsph_extra,&
     295              :    dtset%natvshift*nsppol*natom,&
     296         6959 :    3*dtset%nzchempot*ntypat)
     297              : 
     298        20877 :  ABI_MALLOC(intarr,(marr))
     299        20877 :  ABI_MALLOC(dprarr,(marr))
     300              : 
     301              :  !----------------------------------------------------------------------------
     302              : 
     303              :  !****   Read parameters which set remaining array dimensions ****
     304              : 
     305              :  !Note: some parameters have already been read in invars0 and invars1
     306              :  !Also, some checking is needed here.
     307              : 
     308              :  !Read ngfft(1), ngfft(2), and ngfft(3), then ngfft(7)=fftalg and ngfft(8)=fftcache.
     309              :  !Read ngfftdg(1:3)
     310              : 
     311         6959 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'ngfft',tread,'INT')
     312         8315 :  if(tread==1) dtset%ngfft(1:3)=intarr(1:3)
     313              : 
     314         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fftalg',tread,'INT')
     315         6959 :  if(tread==1) then
     316          261 :    dtset%ngfft(7)=intarr(1)
     317          261 :    if (usepaw==1) dtset%ngfftdg(7)=intarr(1)
     318              :  end if
     319              : 
     320         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fftcache',tread,'INT')
     321              : 
     322         6959 :  if(tread==1) then
     323            2 :    dtset%ngfft(8)=intarr(1)
     324            2 :    if (usepaw==1) dtset%ngfftdg(8)=intarr(1)
     325              :  end if
     326              : 
     327         6959 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'ngfftdg',tread,'INT')
     328         7577 :  if(tread==1) dtset%ngfftdg(1:3)=intarr(1:3)
     329              : 
     330         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'mqgrid',tread,'INT')
     331         6959 :  if(tread==1) dtset%mqgrid=intarr(1)
     332              : 
     333         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'mqgriddg',tread,'INT')
     334         6959 :  if(tread==1) dtset%mqgriddg=intarr(1)
     335              : 
     336              :  ! Make special arrangements to check nband: may be a scalar
     337              :  ! (for occopt=0, 1 or 3, 4, 5, 6, 7, 8) or may be an array (for occopt=2)
     338              : 
     339         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'occopt',tread,'INT')
     340         6959 :  if(tread==1) dtset%occopt=intarr(1)
     341         6959 :  occopt=dtset%occopt
     342              : 
     343              :  ! check for variables related to genetic algorithm. ga_n_rules has been already read
     344              : 
     345         6959 :  if (dtset%imgmov==4) then
     346            1 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ga_algor',tread,'INT')
     347            1 :    if(tread==1) dtset%ga_algor=intarr(1)
     348              : 
     349            1 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ga_fitness',tread,'INT')
     350            1 :    if(tread==1) dtset%ga_fitness=intarr(1)
     351              : 
     352            1 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ga_opt_percent',tread,'ENE')
     353            1 :    if(tread==1) dtset%ga_opt_percent=dprarr(1)
     354              : 
     355            1 :    call intagm(dprarr,intarr,jdtset,marr,dtset%ga_n_rules,string(1:lenstr),'ga_rules',tread,'INT')
     356            1 :    if(tread==1)then
     357            5 :      dtset%ga_rules(1:dtset%ga_n_rules)=intarr(1:dtset%ga_n_rules)
     358            5 :      do ii=1,dtset%ga_n_rules
     359            5 :        if(dtset%ga_rules(ii)<0)then
     360              :          write(msg, '(3a)' )&
     361            0 :          'All values for Genetic rules must be greater than 0.',ch10,&
     362            0 :          'Action: check the values of ga_rules.'
     363            0 :          ABI_ERROR(msg)
     364              :        end if
     365              :      end do
     366              :    end if
     367              :  end if
     368              : 
     369         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwaclowrank',tread,'INT')
     370         6959 :  if(tread==1) dtset%gwaclowrank=intarr(1)
     371              : 
     372         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwcalctyp',tread,'INT')
     373         6959 :  if(tread==1) dtset%gwcalctyp=intarr(1)
     374              : 
     375         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwcomp',tread,'INT')
     376         6959 :  if(tread==1) dtset%gwcomp=intarr(1)
     377              : 
     378         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwencomp',tread,'ENE')
     379         6959 :  if(tread==1) dtset%gwencomp=dprarr(1)
     380              : 
     381         6959 :  if (usepaw==1) then
     382         1181 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gw_sigxcore',tread,'INT')
     383         1181 :    if(tread==1) dtset%gw_sigxcore=intarr(1)
     384              :  end if
     385              : 
     386         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwmem',tread,'INT')
     387         6959 :  if(tread==1) dtset%gwmem=intarr(1)
     388              : 
     389         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwr_nstep',tread,'INT')
     390         6959 :  if(tread==1) dtset%gwr_nstep=intarr(1)
     391              : 
     392         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwr_fit',tread,'INT')
     393         6959 :  if(tread==1) dtset%gwr_fit=intarr(1)
     394              : 
     395         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwr_tolqpe',tread,'ENE')
     396         6959 :  if(tread==1) dtset%gwr_tolqpe=dprarr(1)
     397              : 
     398         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_stern_kmax',tread,'INT')
     399         6959 :  if(tread==1) dtset%gwls_stern_kmax=intarr(1)
     400              : 
     401         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_npt_gauss_quad',tread,'INT')
     402         6959 :  if(tread==1) dtset%gwls_npt_gauss_quad=intarr(1)
     403              : 
     404         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_diel_model',tread,'INT')
     405         6959 :  if(tread==1) dtset%gwls_diel_model=intarr(1)
     406              : 
     407         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_model_parameter',tread,'ENE')
     408         6959 :  if(tread==1) dtset%gwls_model_parameter=dprarr(1)
     409              : 
     410         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_recycle',tread,'INT')
     411         6959 :  if(tread==1) dtset%gwls_recycle=intarr(1)
     412              : 
     413         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_print_debug',tread,'INT')
     414         6959 :  if(tread==1) dtset%gwls_print_debug=intarr(1)
     415              : 
     416         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_nseeds',tread,'INT')
     417         6959 :  if(tread==1) dtset%gwls_nseeds=intarr(1)
     418              : 
     419         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_kmax_complement',tread,'INT')
     420         6959 :  if(tread==1) dtset%gwls_kmax_complement=intarr(1)
     421              : 
     422         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_kmax_poles',tread,'INT')
     423         6959 :  if(tread==1) dtset%gwls_kmax_poles=intarr(1)
     424              : 
     425         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_kmax_analytic',tread,'INT')
     426         6959 :  if(tread==1) dtset%gwls_kmax_analytic=intarr(1)
     427              : 
     428         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_kmax_numeric',tread,'INT')
     429         6959 :  if(tread==1) dtset%gwls_kmax_numeric=intarr(1)
     430              : 
     431         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_exchange',tread,'INT')
     432         6959 :  if(tread==1) dtset%gwls_exchange=intarr(1)
     433              : 
     434         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_correlation',tread,'INT')
     435         6959 :  if(tread==1) dtset%gwls_correlation=intarr(1)
     436              : 
     437         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_band_index',tread,'INT')
     438         6959 :  if(tread==1) dtset%gwls_band_index=intarr(1)
     439              : 
     440         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gw1rdm',tread,'INT')
     441         6959 :  if(tread==1) dtset%gw1rdm=intarr(1)
     442              : 
     443         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'x1rdm',tread,'INT')
     444         6959 :  if(tread==1) dtset%x1rdm=intarr(1)
     445              : 
     446         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtchkprdm',tread,'INT')
     447         6959 :  if(tread==1) dtset%prtchkprdm=intarr(1)
     448              : 
     449         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdchkprdm',tread,'INT')
     450         6959 :  if(tread==1) dtset%irdchkprdm=intarr(1)
     451              : 
     452         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_first_seed',tread,'INT')
     453         6959 :  if(tread==1) then
     454            6 :    dtset%gwls_first_seed=intarr(1)
     455              :  else
     456         6953 :    dtset%gwls_first_seed=dtset%gwls_band_index
     457              :  end if
     458              : 
     459         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'extfpmd_nbcut',tread,'INT')
     460         6959 :  if(tread==1) dtset%extfpmd_nbcut=intarr(1)
     461              : 
     462         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'extfpmd_nbdbuf',tread,'INT')
     463         6959 :  if(tread==1) dtset%extfpmd_nbdbuf=intarr(1)
     464              : 
     465         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'extfpmd_nband',tread,'INT')
     466         6959 :  if(tread==1) dtset%extfpmd_nband=intarr(1)
     467              : 
     468         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'extfpmd_pawsph',tread,'INT')
     469         6959 :  if(tread==1) dtset%extfpmd_pawsph=intarr(1)
     470              : 
     471         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'extfpmd_prterr',tread,'INT')
     472         6959 :  if(tread==1) dtset%extfpmd_prterr=intarr(1)
     473              : 
     474         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rhoqpmix',tread,'DPR')
     475         6959 :  if(tread==1) dtset%rhoqpmix=dprarr(1)
     476              : 
     477         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rifcsph',tread,'DPR')
     478         6959 :  if(tread==1) dtset%rifcsph=dprarr(1)
     479              : 
     480         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nfreqim',tread,'INT')
     481         6959 :  if(tread==1) dtset%nfreqim=intarr(1)
     482         6959 :  if (dtset%cd_customnimfrqs/=0) then
     483              :    write(msg, '(3a)' )&
     484            1 :    'cd_customnimfrqs not equal to zero and not equal to nfreqim',ch10,&
     485            2 :    'setting nfreqim = cd_customnimfrqs'
     486            1 :    ABI_WARNING(msg)
     487            1 :    dtset%nfreqim = dtset%cd_customnimfrqs
     488              :  end if
     489              : 
     490         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nfreqim_conv',tread,'INT')
     491         6959 :  if(tread==1) dtset%nfreqim_conv=intarr(1)
     492              : 
     493         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'freqim_alpha',tread,'DPR')
     494         6959 :  if(tread==1) dtset%freqim_alpha=dprarr(1)
     495              : 
     496         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'freqremin',tread,'ENE')
     497         6959 :  if(tread==1) dtset%freqremin=dprarr(1)
     498              : 
     499         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'freqremax',tread,'ENE')
     500         6959 :  if(tread==1) dtset%freqremax=dprarr(1)
     501              : 
     502         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nfreqre',tread,'INT')
     503         6959 :  if(tread==1) dtset%nfreqre=intarr(1)
     504              : 
     505         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nfreqsp',tread,'INT')
     506         6959 :  if(tread==1) dtset%nfreqsp=intarr(1)
     507              : 
     508         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'freqspmax',tread,'ENE')
     509         6959 :  if(tread==1) dtset%freqspmax=dprarr(1)
     510              : 
     511         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'freqspmin',tread,'ENE')
     512         6959 :  if(tread==1) then
     513              :    ! If found, set it
     514            1 :    dtset%freqspmin=dprarr(1)
     515              :  else
     516              :    ! Else give it the value -freqspmax
     517         6958 :    dtset%freqspmin=-dtset%freqspmax
     518              :  end if
     519              : 
     520         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gw_frqim_inzgrid',tread,'INT')
     521         6959 :  if(tread==1) dtset%gw_frqim_inzgrid=intarr(1)
     522              : 
     523         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gw_frqre_inzgrid',tread,'INT')
     524         6959 :  if(tread==1) dtset%gw_frqre_inzgrid=intarr(1)
     525              : 
     526         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gw_frqre_tangrid',tread,'INT')
     527         6959 :  if(tread==1) dtset%gw_frqre_tangrid=intarr(1)
     528              : 
     529         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gw_invalid_freq',tread,'INT')
     530         6959 :  if(tread==1) dtset%gw_invalid_freq=intarr(1)
     531              : 
     532         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gw_icutcoul',tread,'INT')
     533         6959 :  if(tread==1) dtset%gw_icutcoul=intarr(1)
     534              : 
     535         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gw_qprange',tread,'INT')
     536         6959 :  if(tread==1) dtset%gw_qprange=intarr(1)
     537              : 
     538         6959 :  if(dtset%cd_customnimfrqs/=0) then
     539            1 :    call intagm(dprarr,intarr,jdtset,marr,dtset%cd_customnimfrqs,string(1:lenstr),'cd_imfrqs',tread,'ENE')
     540            1 :    if(tread==1) then
     541            5 :      dtset%cd_imfrqs(1:dtset%cd_customnimfrqs)=dprarr(1:dtset%cd_customnimfrqs)
     542            4 :      do ifreq=1,dtset%cd_customnimfrqs-1
     543            4 :        if (dtset%cd_imfrqs(ifreq+1)<dtset%cd_imfrqs(ifreq)) then
     544              :          write(msg, '(3a)' )&
     545            0 :          'The frequencies specified in cd_imfrqs must be strictly increasing',ch10,&
     546            0 :          'Action: Correct this in your input file'
     547            0 :          ABI_ERROR(msg)
     548              :        end if
     549              :      end do
     550              :    end if
     551              :  end if
     552              : 
     553         6959 :  if(dtset%gw_customnfreqsp/=0) then
     554            8 :    call intagm(dprarr,intarr,jdtset,marr,dtset%gw_customnfreqsp,string(1:lenstr),'gw_freqsp',tread,'ENE')
     555            8 :    if(tread==1) then
     556           23 :      dtset%gw_freqsp(1:dtset%gw_customnfreqsp)=dprarr(1:dtset%gw_customnfreqsp)
     557           15 :      do ifreq=1,dtset%gw_customnfreqsp-1
     558           15 :        if (dtset%gw_freqsp(ifreq+1)<dtset%gw_freqsp(ifreq)) then
     559              :          write(msg, '(3a)' )&
     560            0 :          'The frequencies specified in gw_freqsp must be strictly increasing',ch10,&
     561            0 :          'Action: Correct this in your input file'
     562            0 :          ABI_ERROR(msg)
     563              :        end if
     564              :      end do
     565              :    end if
     566              :  end if
     567              : 
     568         6959 :  if(dtset%gwls_n_proj_freq/=0) then
     569            0 :    call intagm(dprarr,intarr,jdtset,marr,dtset%gwls_n_proj_freq,string(1:lenstr),'gwls_list_proj_freq',tread,'ENE')
     570            0 :    if(tread==1) then
     571            0 :      dtset%gwls_list_proj_freq(1:dtset%gwls_n_proj_freq)=dprarr(1:dtset%gwls_n_proj_freq)
     572              :    end if
     573              :  end if
     574              : 
     575         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'cd_full_grid',tread,'INT')
     576         6959 :  if(tread==1) dtset%cd_full_grid=intarr(1)
     577              : 
     578         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'cd_frqim_method',tread,'INT')
     579         6959 :  if(tread==1) dtset%cd_frqim_method=intarr(1)
     580              : 
     581         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'cd_halfway_freq',tread,'ENE')
     582         6959 :  if(tread==1) dtset%cd_halfway_freq=dprarr(1)
     583              : 
     584         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'cd_max_freq',tread,'ENE')
     585         6959 :  if(tread==1) dtset%cd_max_freq=dprarr(1)
     586              : 
     587         6959 :  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'cd_subset_freq',tread,'INT')
     588         6959 :  if(tread==1) dtset%cd_subset_freq(1:2)=intarr(1:2)
     589              : 
     590         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwrpacorr',tread,'INT')
     591         6959 :  if(tread==1) dtset%gwrpacorr=intarr(1)
     592              : 
     593         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwgmcorr',tread,'INT')
     594         6959 :  if(tread==1) dtset%gwgmcorr=intarr(1)
     595              : 
     596         6959 :  narr = size(dtset%gwr_np_kgts)
     597         6959 :  call intagm(dprarr, intarr, jdtset, marr, narr, string(1:lenstr), 'gwr_np_kgts', tread, 'INT')
     598         6959 :  if (tread == 1) dtset%gwr_np_kgts = intarr(1:narr)
     599              : 
     600         6959 :  narr = size(dtset%gwr_ucsc_batch)
     601         6959 :  call intagm(dprarr, intarr, jdtset, marr, narr, string(1:lenstr), 'gwr_ucsc_batch', tread, 'INT')
     602         6959 :  if (tread == 1) dtset%gwr_ucsc_batch = intarr(1:narr)
     603              : 
     604         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'gwr_ntau', tread,'INT')
     605         6959 :  if (tread == 1) dtset%gwr_ntau = intarr(1)
     606              : 
     607         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'gwr_chi_algo', tread,'INT')
     608         6959 :  if (tread == 1) dtset%gwr_chi_algo = intarr(1)
     609         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'gwr_sigma_algo', tread,'INT')
     610         6959 :  if (tread == 1) dtset%gwr_sigma_algo = intarr(1)
     611         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'gwr_rpa_ncut', tread,'INT')
     612         6959 :  if (tread == 1) dtset%gwr_rpa_ncut = intarr(1)
     613              : 
     614         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'gwr_boxcutmin', tread, 'DPR')
     615         6959 :  if (tread == 1) dtset%gwr_boxcutmin = dprarr(1)
     616              : 
     617         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'gwr_max_hwtene', tread, 'ENE')
     618         6959 :  if (tread == 1) dtset%gwr_max_hwtene = dprarr(1)
     619              : 
     620         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'gwr_regterm', tread, 'DPR')
     621         6959 :  if (tread == 1) dtset%gwr_regterm = dprarr(1)
     622              : 
     623         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), "gwr_task", tread, 'KEY', key_value=key_value)
     624         6959 :  if (tread == 1) dtset%gwr_task = toupper(trim(key_value))
     625              : 
     626              :  ! RESPFN integer input variables (needed here to get the value of response)
     627              :  ! Warning: rfddk,rfelfd,rfmagn,rfphon,rfstrs,rfsrs_ref,rf2_dkdk and rf2_dkde are also read in invars1
     628              : 
     629              : !call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rfasr',tread,'INT')
     630              : !if(tread==1) dtset%rfasr=intarr(1)
     631              : 
     632         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'asr',tread,'INT')
     633         6959 :  if(tread==1) dtset%asr=intarr(1)
     634              : 
     635         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'chneut',tread,'INT')
     636         6959 :  if(tread==1) dtset%chneut=intarr(1)
     637              : 
     638              : 
     639         6959 :  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'rfatpol',tread,'INT')
     640         7571 :  if(tread==1) dtset%rfatpol(1:2)=intarr(1:2)
     641         6959 :  if(dtset%rfatpol(1)==-1)then
     642         6653 :    dtset%rfatpol(1)=1
     643              :  endif
     644         6959 :  if(dtset%rfatpol(2)==-1)then
     645         6653 :    dtset%rfatpol(2)=dtset%natom
     646              :  endif
     647              : 
     648         6959 :  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'mpatpol',tread,'INT')
     649         6973 :  if(tread==1) dtset%mpatpol(1:2)=intarr(1:2)
     650         6959 :  if(dtset%mpatpol(1)==-1)then
     651         6952 :    dtset%mpatpol(1)=1
     652              :  endif
     653         6959 :  if(dtset%mpatpol(2)==-1)then
     654         6952 :    dtset%mpatpol(2)=dtset%natom
     655              :  endif
     656              : 
     657         6959 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'rfdir',tread,'INT')
     658         8495 :  if(tread==1) dtset%rfdir(1:3)=intarr(1:3)
     659              : 
     660         6959 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'mpdir',tread,'INT')
     661         6980 :  if(tread==1) dtset%mpdir(1:3)=intarr(1:3)
     662              : 
     663         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rfddk',tread,'INT')
     664         6959 :  if(tread==1) dtset%rfddk=intarr(1)
     665              : 
     666         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rfelfd',tread,'INT')
     667         6959 :  if(tread==1) dtset%rfelfd=intarr(1)
     668              : 
     669         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rfmagn',tread,'INT')
     670         6959 :  if(tread==1) dtset%rfmagn=intarr(1)
     671              : 
     672         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rfmeth',tread,'INT')
     673         6959 :  if(tread==1) dtset%rfmeth=intarr(1)
     674              : 
     675         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rfphon',tread,'INT')
     676         6959 :  if(tread==1) dtset%rfphon=intarr(1)
     677              : 
     678         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rfstrs',tread,'INT')
     679         6959 :  if(tread==1) dtset%rfstrs=intarr(1)
     680              : 
     681         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rfstrs_ref',tread,'INT')
     682         6959 :  if(tread==1) dtset%rfstrs_ref=intarr(1)
     683              : 
     684         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rf2_dkdk',tread,'INT')
     685         6959 :  if(tread==1) dtset%rf2_dkdk=intarr(1)
     686              : 
     687         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rf2_dkde',tread,'INT')
     688         6959 :  if(tread==1) dtset%rf2_dkde=intarr(1)
     689              : 
     690         6959 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'rf2_pert1_dir',tread,'INT')
     691         6974 :  if(tread==1) dtset%rf2_pert1_dir(1:3)=intarr(1:3)
     692              : 
     693         6959 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'rf2_pert2_dir',tread,'INT')
     694         6974 :  if(tread==1) dtset%rf2_pert2_dir(1:3)=intarr(1:3)
     695              : 
     696              :  ! Set value of response to 1 and also set rfdir to 1 1 1 if we are doing
     697              :  ! response calculation but rfdir was left at default 0 0 0 value.
     698              :  ! For rf2_dkdk and rf2_dkde, we do the same for rf2_pert1_dir and rf2_pert2_dir
     699         6959 :  response=0
     700              :  if(dtset%rfddk/=0 .or. dtset%rf2_dkdk/=0 .or. dtset%rf2_dkde/=0 .or. dtset%rfelfd/=0 .or. &
     701         6959 :    dtset%rfphon/=0 .or. dtset%rfstrs/=0 ) then
     702          709 :    response=1
     703          709 :    if( (dtset%rfdir(1) == 0) .and. (dtset%rfdir(2) == 0) .and. (dtset%rfdir(3) == 0) ) dtset%rfdir(1:3) = 1
     704          709 :    if (dtset%rf2_dkdk/=0 .or. dtset%rf2_dkde/=0) then
     705          100 :      if (sum(abs(dtset%rf2_pert1_dir)) == 0) dtset%rf2_pert1_dir(:) = 1
     706          100 :      if (sum(abs(dtset%rf2_pert2_dir)) == 0) dtset%rf2_pert2_dir(:) = 1
     707              :    end if
     708              :  end if
     709              : 
     710         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rmm_diis',tread,'INT')
     711         6959 :  if(tread==1) dtset%rmm_diis=intarr(1)
     712         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rmm_diis_savemem',tread,'INT')
     713         6959 :  if(tread==1) dtset%rmm_diis_savemem=intarr(1)
     714              : 
     715         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nonlinear_info',tread,'INT')
     716         6959 :  if(tread==1) dtset%nonlinear_info=intarr(1)
     717              : 
     718         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nonlop_ylm_count',tread,'INT')
     719         6959 :  if(tread==1) dtset%nonlop_ylm_count=intarr(1)
     720              : 
     721              : !Need always to be read, in order to change the default value.
     722         6959 :  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'d3e_pert1_atpol',tread,'INT')
     723         6995 :  if(tread==1) dtset%d3e_pert1_atpol(1:2)=intarr(1:2)
     724         6959 :  if(dtset%d3e_pert1_atpol(1)==-1)then
     725         6941 :    dtset%d3e_pert1_atpol(1)=1
     726              :  endif
     727         6959 :  if(dtset%d3e_pert1_atpol(2)==-1)then
     728         6941 :    dtset%d3e_pert1_atpol(2)=dtset%natom
     729              :  endif
     730              : 
     731         6959 :  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'d3e_pert2_atpol',tread,'INT')
     732         6981 :  if(tread==1) dtset%d3e_pert2_atpol(1:2)=intarr(1:2)
     733         6959 :  if(dtset%d3e_pert2_atpol(1)==-1)then
     734         6948 :    dtset%d3e_pert2_atpol(1)=1
     735              :  endif
     736         6959 :  if(dtset%d3e_pert2_atpol(2)==-1)then
     737         6948 :    dtset%d3e_pert2_atpol(2)=dtset%natom
     738              :  endif
     739              : 
     740         6959 :  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'d3e_pert3_atpol',tread,'INT')
     741         6973 :  if(tread==1) dtset%d3e_pert3_atpol(1:2)=intarr(1:2)
     742         6959 :  if(dtset%d3e_pert3_atpol(1)==-1)then
     743         6952 :    dtset%d3e_pert3_atpol(1)=1
     744              :  endif
     745         6959 :  if(dtset%d3e_pert3_atpol(2)==-1)then
     746         6952 :    dtset%d3e_pert3_atpol(2)=dtset%natom
     747              :  endif
     748              : 
     749              : 
     750         6959 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'d3e_pert1_dir',tread,'INT')
     751         7070 :  if(tread==1) dtset%d3e_pert1_dir(1:3)=intarr(1:3)
     752              : 
     753         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'d3e_pert1_elfd',tread,'INT')
     754         6959 :  if(tread==1) dtset%d3e_pert1_elfd=intarr(1)
     755              : 
     756         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'d3e_pert1_phon',tread,'INT')
     757         6959 :  if(tread==1) dtset%d3e_pert1_phon=intarr(1)
     758              : 
     759         6959 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'d3e_pert2_dir',tread,'INT')
     760         7070 :  if(tread==1) dtset%d3e_pert2_dir(1:3)=intarr(1:3)
     761              : 
     762         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'d3e_pert2_elfd',tread,'INT')
     763         6959 :  if(tread==1) dtset%d3e_pert2_elfd=intarr(1)
     764              : 
     765         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'d3e_pert2_phon',tread,'INT')
     766         6959 :  if(tread==1) dtset%d3e_pert2_phon=intarr(1)
     767              : 
     768         6959 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'d3e_pert3_dir',tread,'INT')
     769         7055 :  if(tread==1) dtset%d3e_pert3_dir(1:3)=intarr(1:3)
     770              : 
     771         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'d3e_pert3_elfd',tread,'INT')
     772         6959 :  if(tread==1) dtset%d3e_pert3_elfd=intarr(1)
     773              : 
     774         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'d3e_pert3_phon',tread,'INT')
     775         6959 :  if(tread==1) dtset%d3e_pert3_phon=intarr(1)
     776              : 
     777         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'usepead',tread,'INT')
     778         6959 :  if(tread==1) dtset%usepead=intarr(1)
     779              : 
     780         6959 :  response=0
     781              :  if(dtset%rfddk/=0 .or. dtset%rfphon/=0 .or. dtset%rfelfd/=0 .or. &
     782              :     dtset%rfstrs/=0 .or. dtset%rf2_dkdk/=0 .or. dtset%rf2_dkde/=0 .or. &
     783              :     dtset%d3e_pert1_elfd/=0 .or. dtset%d3e_pert1_phon/=0 .or. &
     784              :     dtset%d3e_pert2_elfd/=0 .or. dtset%d3e_pert2_phon/=0 .or. &
     785         6959 :     dtset%d3e_pert3_elfd/=0 .or. dtset%d3e_pert3_phon/=0 ) response=1
     786              : 
     787         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prepanl',tread,'INT')
     788         6959 :  if(tread==1) dtset%prepanl=intarr(1)
     789              : 
     790         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prepgkk',tread,'INT')
     791         6959 :  if(tread==1) dtset%prepgkk=intarr(1)
     792              : 
     793         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'use_nonscf_gkk',tread,'INT')
     794         6959 :  if(tread==1) dtset%use_nonscf_gkk=intarr(1)
     795              : 
     796         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'use_yaml',tread,'INT')
     797         6959 :  if(tread==1) dtset%use_yaml=intarr(1)
     798              : 
     799         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'use_oldchi',tread,'INT')
     800         6959 :  if(tread==1) dtset%use_oldchi=intarr(1)
     801              : 
     802         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'brav',tread,'INT')
     803         6959 :  if(tread==1) dtset%brav=intarr(1)
     804              : 
     805         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'boxcutmin',tread,'DPR')
     806         6959 :  if(tread==1) dtset%boxcutmin=dprarr(1)
     807              : 
     808              : !Initialize cellcharge, that might differ for each image
     809         6959 :  cellcharge_min=huge(one)
     810        14178 :  do iimage=1,dtset%nimage
     811         7219 :    if (dtset%nimage /= 1) call wrtout(std_out, sjoin(' invars2: cellcharge, treat image number: ',itoa(iimage)))
     812              : 
     813              : !  Read cellcharge for each image, but use it only to initialize cellcharge_min
     814              : !  The old name 'charge' is still tolerated. Will be removed in due time.
     815         7219 :    dprarr(1)=dtset%cellcharge(iimage)
     816         7219 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'cellcharge',tread,'DPR')
     817         7219 :    if(tread==1)then
     818           34 :      dtset%cellcharge(iimage)=dprarr(1)
     819              :    else
     820         7185 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'charge',tread,'DPR')
     821         7185 :      if(tread==1) dtset%cellcharge(iimage)=dprarr(1)
     822              :    endif
     823              : !  Possibly overwrite cellcharge from the first image with a specific value for the current image
     824         7219 :    call intagm_img(dprarr,iimage,jdtset,lenstr,dtset%nimage,1,string,'cellcharge',tread_alt,'DPR')
     825         7219 :    if(tread_alt==1)then
     826          191 :      dtset%cellcharge(iimage)=dprarr(1)
     827              :    else
     828         7028 :      call intagm_img(dprarr,iimage,jdtset,lenstr,dtset%nimage,1,string,'charge',tread_alt,'DPR')
     829         7028 :      if(tread_alt==1) dtset%cellcharge(iimage)=dprarr(1)
     830              :    endif
     831              : 
     832        14178 :    if(dtset%cellcharge(iimage) < cellcharge_min)cellcharge_min=dtset%cellcharge(iimage)
     833              :  end do
     834              : 
     835         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'invovl_blksliced',tread,'INT')
     836         6959 :  if(tread==1)dtset%invovl_blksliced=intarr(1)
     837              : 
     838         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dosdeltae',tread,'ENE')
     839         6959 :  if(tread==1) dtset%dosdeltae=dprarr(1)
     840              : 
     841         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dtion',tread,'DPR')
     842         6959 :  if(tread==1) dtset%dtion=dprarr(1)
     843              : 
     844         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dtele',tread,'TIM')
     845         6959 :  if(tread==1) dtset%dtele=dprarr(1)
     846              : 
     847         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ecut',tread,'ENE')
     848         6959 :  if(tread==1) dtset%ecut=dprarr(1)
     849              : 
     850              :  ! With planewaves, ecut must use positive ecut
     851              :  ! Must perform the check here instead of chkinp else the code sigfaults in mpi_setup before calling chkinp
     852         6959 :  if(dtset%usewvl==0)then
     853         6959 :    if (dtset%ecut < tol2) then
     854              :      write(msg, '(3a)' )&
     855            0 :        'The input keyword "ecut" is compulsory !',ch10,&
     856            0 :        'Action: add a value for "ecut" in the input file.'
     857            0 :      ABI_ERROR(msg)
     858              :    end if
     859              :  end if
     860              : 
     861              : 
     862         6959 :  call intagm(dprarr,intarr,jdtset,marr,size(dtset%einterp),string(1:lenstr),'einterp',tread,'DPR')
     863         6975 :  if(tread==1) dtset%einterp=dprarr(1:size(dtset%einterp))
     864              : 
     865         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'elph2_imagden',tread,'ENE')
     866         6959 :  if(tread==1) dtset%elph2_imagden=dprarr(1)
     867              : 
     868         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'esmear',tread,'ENE')
     869         6959 :  if(tread==1) dtset%esmear=dprarr(1)
     870              : 
     871         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fermie_nest',tread,'ENE')
     872         6959 :  if(tread==1) dtset%fermie_nest=dprarr(1)
     873              : 
     874         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dfpt_sciss',tread,'ENE')
     875         6959 :  if(tread==1) dtset%dfpt_sciss=dprarr(1)
     876              : 
     877         6959 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'tmesh',tread,'DPR')
     878         7193 :  if(tread==1) dtset%tmesh=dprarr(1:3)
     879        27836 :  ABI_CHECK(all(dtset%tmesh >= zero), sjoin("Invalid tmesh containing T < 0:", ltoa(dtset%tmesh)))
     880              : 
     881         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tsmear',tread,'ENE')
     882         6959 :  if(tread==1) dtset%tsmear=dprarr(1)
     883              : 
     884         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vis',tread,'DPR')
     885         6959 :  if(tread==1) dtset%vis=dprarr(1)
     886              : 
     887         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vloc_rcut',tread,'LEN')
     888         6959 :  if(tread==1) dtset%vloc_rcut=dprarr(1)
     889              : 
     890         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ecutsm',tread,'ENE')
     891         6959 :  if(tread==1) dtset%ecutsm=dprarr(1)
     892              :  
     893         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ggtrcut',tread,'DPR')
     894         6959 :  if(tread==1) dtset%ggtrcut=dprarr(1)
     895              : 
     896         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'exchmix',tread,'DPR')
     897         6959 :  if(tread==1) dtset%exchmix=dprarr(1)
     898              : 
     899         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dilatmx',tread,'DPR')
     900         6959 :  if(tread==1) dtset%dilatmx=dprarr(1)
     901              : 
     902         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fxcartfactor',tread,'DPR')
     903         6959 :  if(tread==1) dtset%fxcartfactor=dprarr(1)
     904              : 
     905         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'strfact',tread,'DPR')
     906         6959 :  if(tread==1) dtset%strfact=dprarr(1)
     907              : 
     908         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'effmass_free',tread,'DPR')
     909         6959 :  if(tread==1) dtset%effmass_free=dprarr(1)
     910              : 
     911         6959 :  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'mdtemp',tread,'DPR')
     912         7037 :  if(tread==1) dtset%mdtemp(1:2)=dprarr(1:2)
     913              : 
     914         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rfomega',tread,'ENE')
     915         6959 :  if(tread==1) dtset%rfomega=dprarr(1)
     916              : 
     917         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rfeta',tread,'ENE')
     918         6959 :  if(tread==1) dtset%rfeta=dprarr(1)
     919              : 
     920         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'magpen',tread,'ENE')
     921         6959 :  if(tread==1) dtset%magpen=dprarr(1)
     922              : 
     923         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prt1mag',tread,'INT')
     924         6959 :  if(tread==1) dtset%prt1mag=intarr(1)
     925              : 
     926              : !LONG WAVE integer input variables
     927         6959 :  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'d3e_pert1_magat',tread,'INT')
     928         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rf1magat',tread_alt,'INT')
     929         6968 :  if(tread==1.or.tread_alt==1) dtset%d3e_pert1_magat(1:2)=intarr(1:2)
     930         6959 :  if (tread_alt==1) tread_key=1
     931         6959 :  if(dtset%d3e_pert1_magat(1)==-1)then
     932         6956 :    dtset%d3e_pert1_magat(1)=1
     933              :  endif
     934         6959 :  if(dtset%d3e_pert1_magat(2)==-1)then
     935         6956 :    dtset%d3e_pert1_magat(2)=dtset%natom
     936              :  endif
     937              : 
     938         6959 :  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'d3e_pert2_magat',tread,'INT')
     939         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rf2magat',tread_alt,'INT')
     940         6968 :  if(tread==1.or.tread_alt==1) dtset%d3e_pert2_magat(1:2)=intarr(1:2)
     941         6959 :  if (tread_alt==1) tread_key=1
     942         6959 :  if(dtset%d3e_pert2_magat(1)==-1)then
     943         6956 :    dtset%d3e_pert2_magat(1)=1
     944              :  endif
     945         6959 :  if(dtset%d3e_pert2_magat(2)==-1)then
     946         6956 :    dtset%d3e_pert2_magat(2)=dtset%natom
     947              :  endif
     948              : 
     949              :  ! SCF-Preconditioning input variables
     950         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'precon_in_memory',tread,'INT')
     951         6959 :  if(tread==1) dtset%precon_in_memory=intarr(1)
     952              : 
     953         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'precon_ls_maxite',tread,'INT')
     954         6959 :  if(tread==1) dtset%precon_ls_maxite=intarr(1)
     955              : 
     956         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'precon_ls_rtol',tread,'DPR')
     957         6959 :  if(tread==1) dtset%precon_ls_rtol=dprarr(1)
     958              : 
     959         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'precon_tsmear',tread,'ENE')
     960         6959 :  if(tread==1) dtset%precon_tsmear=dprarr(1)
     961              : 
     962         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'precon_verbose',tread,'INT')
     963         6959 :  if(tread==1) dtset%precon_verbose=intarr(1)
     964              : 
     965         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prepalw',tread,'INT')
     966         6959 :  if(tread==1) dtset%prepalw=intarr(1)
     967              : 
     968         6959 :  if(dtset%optdriver==RUNL_LONGWAVE) then
     969           17 :    tread_key=0
     970              : 
     971           17 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'timdisp',tread,'INT')
     972           17 :    if(tread==1) dtset%timdisp=intarr(1)
     973              : 
     974           17 :    call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'d3e_pert1_dir',tread,'INT')
     975           37 :    if(tread==1.or.tread_alt==1) dtset%d3e_pert1_dir(1:3)=intarr(1:3)
     976           17 :    if (tread_alt==1) tread_key=1
     977              : 
     978           17 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'d3e_pert1_elfd',tread,'INT')
     979           17 :    if(tread==1.or.tread_alt==1) dtset%d3e_pert1_elfd=intarr(1)
     980           17 :    if (tread_alt==1) tread_key=1
     981              : 
     982           17 :    call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'d3e_pert1_magdir',tread,'INT')
     983           37 :    if(tread==1.or.tread_alt==1) dtset%d3e_pert1_magdir(1:3)=intarr(1:3)
     984           17 :    if (tread_alt==1) tread_key=1
     985              : 
     986           17 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'d3e_pert1_magn',tread,'INT')
     987           17 :    if(tread==1.or.tread_alt==1) dtset%d3e_pert1_magn=intarr(1)
     988           17 :    if (tread_alt==1) tread_key=1
     989              : 
     990           17 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'d3e_pert1_phon',tread,'INT')
     991           17 :    if(tread==1.or.tread_alt==1) dtset%d3e_pert1_phon=intarr(1)
     992           17 :    if (tread_alt==1) tread_key=1
     993              : 
     994           17 :    call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'d3e_pert2_dir',tread,'INT')
     995           37 :    if(tread==1.or.tread_alt==1) dtset%d3e_pert2_dir(1:3)=intarr(1:3)
     996           17 :    if (tread_alt==1) tread_key=1
     997              : 
     998           17 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'d3e_pert2_elfd',tread,'INT')
     999           17 :    if(tread==1.or.tread_alt==1) dtset%d3e_pert2_elfd=intarr(1)
    1000           17 :    if (tread_alt==1) tread_key=1
    1001              : 
    1002           17 :    call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'d3e_pert2_magdir',tread,'INT')
    1003           37 :    if(tread==1.or.tread_alt==1) dtset%d3e_pert2_magdir(1:3)=intarr(1:3)
    1004           17 :    if (tread_alt==1) tread_key=1
    1005              : 
    1006           17 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'d3e_pert2_magn',tread,'INT')
    1007           17 :    if(tread==1.or.tread_alt==1) dtset%d3e_pert2_magn=intarr(1)
    1008           17 :    if (tread_alt==1) tread_key=1
    1009              : 
    1010           17 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'d3e_pert2_phon',tread,'INT')
    1011           17 :    if(tread==1.or.tread_alt==1) dtset%d3e_pert2_phon=intarr(1)
    1012           17 :    if (tread_alt==1) tread_key=1
    1013              : 
    1014           17 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'d3e_pert2_strs',tread,'INT')
    1015           17 :    if(tread==1.or.tread_alt==1) dtset%d3e_pert2_strs=intarr(1)
    1016           17 :    if (tread_alt==1) tread_key=1
    1017              : 
    1018           17 :    call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'d3e_pert3_atpol',tread,'INT')
    1019           17 :    if(tread==1.or.tread_alt==1) dtset%d3e_pert3_atpol(1:2)=intarr(1:2)
    1020           17 :    if (tread_alt==1) tread_key=1
    1021              : 
    1022           17 :    call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'d3e_pert3_dir',tread,'INT')
    1023           17 :    if(tread==1.or.tread_alt==1) dtset%d3e_pert3_dir(1:3)=intarr(1:3)
    1024           17 :    if (tread_alt==1) tread_key=1
    1025              : 
    1026           17 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'d3e_pert3_elfd',tread,'INT')
    1027           17 :    if(tread==1.or.tread_alt==1) dtset%d3e_pert3_elfd=intarr(1)
    1028           17 :    if (tread_alt==1) tread_key=1
    1029              : 
    1030           17 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'d3e_pert3_phon',tread,'INT')
    1031           17 :    if(tread==1.or.tread_alt==1) dtset%d3e_pert3_phon=intarr(1)
    1032           17 :    if (tread_alt==1) tread_key=1
    1033              : 
    1034           17 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lw_flexo',tread,'INT')
    1035           17 :    if(tread==1) dtset%lw_flexo=intarr(1)
    1036              : 
    1037           17 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lw_qdrpl',tread,'INT')
    1038           17 :    if(tread==1) dtset%lw_qdrpl=intarr(1)
    1039              : 
    1040           17 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lw_natopt',tread,'INT')
    1041           17 :    if(tread==1) dtset%lw_natopt=intarr(1)
    1042              : 
    1043           17 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ffnl_lw',tread,'INT')
    1044           17 :    if(tread==1) dtset%ffnl_lw=intarr(1)
    1045              :  end if
    1046              : 
    1047              :  ! Recursion input variables
    1048         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tfkinfunc',tread,'INT')
    1049         6959 :  if(tread==1) dtset%tfkinfunc=intarr(1)
    1050              : 
    1051         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'recgratio',tread,'INT')
    1052         6959 :  if(tread==1) dtset%recgratio=intarr(1)
    1053              : 
    1054         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'recefermi',tread,'ENE')
    1055         6959 :  if(tread==1) dtset%recefermi=dprarr(1)
    1056              : 
    1057         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'recnpath',tread,'INT')
    1058         6959 :  if(tread==1) dtset%recnpath=intarr(1)
    1059              : 
    1060         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'recnrec',tread,'INT')
    1061         6959 :  if(tread==1) dtset%recnrec=intarr(1)
    1062              : 
    1063         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'recrcut',tread,'LEN')
    1064         6959 :  if(tread==1) dtset%recrcut=dprarr(1)
    1065              : 
    1066         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'recptrott',tread,'INT')
    1067         6959 :  if(tread==1) dtset%recptrott=intarr(1)
    1068              : 
    1069         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rectesteg',tread,'INT')
    1070         6959 :  if(tread==1) dtset%rectesteg=intarr(1)
    1071              : 
    1072         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rectolden',tread,'DPR')
    1073         6959 :  if(tread==1) dtset%rectolden=dprarr(1)
    1074              : 
    1075              :  ! Constant NPT Molecular Dynamics Input variables
    1076         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'noseinert',tread,'DPR')
    1077         6959 :  if(tread==1) dtset%noseinert=dprarr(1)
    1078              : 
    1079         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bmass',tread,'DPR')
    1080         6959 :  if(tread==1) dtset%bmass=dprarr(1)
    1081              : 
    1082         6959 :  call intagm(dprarr,intarr,jdtset,marr,dtset%nnos,string(1:lenstr),'qmass',tread,'DPR')
    1083         6989 :  if(tread==1) dtset%qmass(:)=dprarr(1:dtset%nnos)
    1084              : 
    1085         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tphysel',tread,'ENE')
    1086         6959 :  if(tread==1) dtset%tphysel=dprarr(1)
    1087              : 
    1088         6959 :  call intagm(dprarr,intarr,jdtset,marr,6,string(1:lenstr),'strtarget',tread,'DPR')
    1089         7013 :  if(tread==1) dtset%strtarget(1:6)=dprarr(1:6)
    1090              : 
    1091         6959 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'vcutgeo',tread,'DPR')
    1092         7010 :  if(tread==1) dtset%vcutgeo(1:3)=dprarr(1:3)
    1093              : 
    1094         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'friction',tread,'DPR')
    1095         6959 :  if(tread==1) dtset%friction=dprarr(1)
    1096              : 
    1097         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'frictionbar',tread,'DPR')
    1098         6959 :  if(tread==1) dtset%frictionbar=dprarr(1)
    1099              : 
    1100         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'mdwall',tread,'LEN')
    1101         6959 :  if(tread==1) dtset%mdwall=dprarr(1)
    1102              : 
    1103              :  ! Path-Integral Molecular Dynamics Input variables
    1104         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'adpimd',tread,'INT')
    1105         6959 :  if(tread==1) dtset%adpimd=intarr(1)
    1106              : 
    1107         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'adpimd_gamma',tread,'DPR')
    1108         6959 :  if(tread==1) dtset%adpimd_gamma=dprarr(1)
    1109              : 
    1110         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pimd_constraint',tread,'INT')
    1111         6959 :  if(tread==1) dtset%pimd_constraint=intarr(1)
    1112              : 
    1113         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pitransform',tread,'INT')
    1114         6959 :  if(tread==1) dtset%pitransform=intarr(1)
    1115              : 
    1116              :  ! Default for pimass is amu
    1117        15545 :  dtset%pimass(1:ntypat)=dtset%amu_orig(1:ntypat,1)
    1118              :  ! NOTE: initialisation with the first image only. TO BE MODIFIED ....
    1119         6959 :  call intagm(dprarr,intarr,jdtset,marr,ntypat,string(1:lenstr),'pimass',tread,'DPR')
    1120         6965 :  if(tread==1) dtset%pimass(1:ntypat)=dprarr(1:ntypat)
    1121              : 
    1122         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spinmagntarget',tread,'DPR')
    1123         6959 :  if(tread==1) dtset%spinmagntarget=dprarr(1)
    1124              : 
    1125         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eshift',tread,'ENE')
    1126         6959 :  if(tread==1) dtset%eshift=dprarr(1)
    1127              : 
    1128         6959 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'boxcenter',tread,'DPR')
    1129         7064 :  if(tread==1) dtset%boxcenter(1:3)=dprarr(1:3)
    1130              : 
    1131         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ecuteps',tread,'ENE')
    1132         6959 :  if(tread==1) dtset%ecuteps=dprarr(1)
    1133              : 
    1134         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ecutsigx',tread,'ENE')
    1135         6959 :  if (any(dtset%optdriver == [RUNL_GWR])) dtset%ecutsigx = dtset%ecut
    1136         6959 :  if (tread==1) dtset%ecutsigx=dprarr(1)
    1137              :  !ABI_CHECK(dtset%ecutsigx <= four * dtset%ecut, "ecutwfn cannot be greater that 4*ecut")
    1138              : 
    1139         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ecutwfn',tread,'ENE')
    1140         6959 :  if (any(dtset%optdriver == [RUNL_SCREENING, RUNL_SIGMA, RUNL_GWR])) dtset%ecutwfn=dtset%ecut
    1141         6959 :  if (tread==1) dtset%ecutwfn = dprarr(1)
    1142              :  !ABI_CHECK(dtset%ecutwfn <= dtset%ecut, "ecutwfn cannot be greater that ecut")
    1143              : 
    1144         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'omegasimax',tread,'ENE')
    1145         6959 :  if(tread==1) dtset%omegasimax=dprarr(1)
    1146              : 
    1147         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'omegasrdmax',tread,'ENE')
    1148         6959 :  if(tread==1) dtset%omegasrdmax=dprarr(1)
    1149              : 
    1150         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'mbpt_sciss',tread,'ENE')
    1151         6959 :  if(tread==1) dtset%mbpt_sciss=dprarr(1)
    1152              : 
    1153         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spbroad',tread,'ENE')
    1154         6959 :  if(tread==1) dtset%spbroad=dprarr(1)
    1155              : 
    1156         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'stmbias',tread,'ENE')
    1157         6959 :  if(tread==1) dtset%stmbias=dprarr(1)
    1158              : 
    1159         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'awtr',tread,'INT')
    1160         6959 :  if(tread==1) dtset%awtr=intarr(1)
    1161              : 
    1162         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'inclvkb',tread,'INT')
    1163         6959 :  if(tread==1) dtset%inclvkb=intarr(1)
    1164              : 
    1165         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nomegasf',tread,'INT')
    1166         6959 :  if(tread==1) dtset%nomegasf=intarr(1)
    1167              : 
    1168         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spmeth',tread,'INT')
    1169         6959 :  if(tread==1) dtset%spmeth=intarr(1)
    1170              : 
    1171         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'symchi',tread,'INT')
    1172         6959 :  if(tread==1) dtset%symchi=intarr(1)
    1173              : 
    1174         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getefmas',tread,'INT')
    1175         6959 :  if(tread==1) dtset%getefmas=intarr(1)
    1176              : 
    1177         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getscr',tread,'INT')
    1178         6959 :  if(tread==1) dtset%getscr=intarr(1)
    1179              : 
    1180         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getscr_filepath',tread,'KEY', key_value=key_value)
    1181         6959 :  if(tread==1) dtset%getscr_filepath = key_value
    1182              : 
    1183         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwgamma',tread,'INT')
    1184         6959 :  if(tread==1) dtset%gwgamma=intarr(1)
    1185              : 
    1186         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwpt_wmode',tread,'INT')
    1187         6959 :  if(tread==1) dtset%gwpt_wmode=intarr(1)
    1188              : 
    1189         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwpt_g2mode',tread,'INT')
    1190         6959 :  if(tread==1) dtset%gwpt_g2mode=intarr(1)
    1191              : 
    1192         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdefmas',tread,'INT')
    1193         6959 :  if(tread==1) dtset%irdefmas=intarr(1)
    1194              : 
    1195         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdsuscep',tread,'INT')
    1196         6959 :  if(tread==1) dtset%irdsuscep=intarr(1)
    1197              : 
    1198         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdscr',tread,'INT')
    1199         6959 :  if(tread==1) dtset%irdscr=intarr(1)
    1200              : 
    1201         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nomegasi',tread,'INT')
    1202         6959 :  if(tread==1) dtset%nomegasi=intarr(1)
    1203              : 
    1204         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ppmodel',tread,'INT')
    1205         6959 :  if(tread==1) dtset%ppmodel=intarr(1)
    1206              : 
    1207         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'symsigma',tread,'INT')
    1208         6959 :  if(tread==1) dtset%symsigma=intarr(1)
    1209              : 
    1210         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'symsigma_de',tread,'ENE')
    1211         6959 :  if(tread==1) dtset%symsigma_de=dprarr(1)
    1212              : 
    1213         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fftgw',tread,'INT')
    1214         6959 :  if(tread==1) dtset%fftgw=intarr(1)
    1215              : 
    1216         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fft_count',tread,'INT')
    1217         6959 :  if(tread==1) dtset%fft_count=intarr(1)
    1218              : 
    1219         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getsuscep',tread,'INT')
    1220         6959 :  if(tread==1) dtset%getsuscep=intarr(1)
    1221              : 
    1222         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getqps',tread,'INT')
    1223         6959 :  if(tread==1) dtset%getqps=intarr(1)
    1224              : 
    1225         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwpara',tread,'INT')
    1226         6959 :  if(tread==1) dtset%gwpara=intarr(1)
    1227              : 
    1228         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdqps',tread,'INT')
    1229         6959 :  if(tread==1) dtset%irdqps=intarr(1)
    1230              : 
    1231         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ppmfrq',tread,'ENE')
    1232         6959 :  if(tread==1) dtset%ppmfrq=dprarr(1)
    1233              : 
    1234         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rcut',tread,'LEN')
    1235         6959 :  if(tread==1) dtset%rcut=dprarr(1)
    1236              : 
    1237         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fock_rcut',tread,'LEN')
    1238         6959 :  if(tread==1) dtset%fock_rcut=dprarr(1)
    1239              : 
    1240         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gw_rcut',tread,'LEN')
    1241         6959 :  if(tread==1) dtset%gw_rcut=dprarr(1)
    1242              : 
    1243         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'zcut',tread,'ENE')
    1244         6959 :  if(tread==1) dtset%zcut = dprarr(1)
    1245              : 
    1246              :  ! q-points for long wave-length limit.
    1247         6959 :  if (dtset%gw_nqlwl > 0) then
    1248            1 :    call intagm(dprarr,intarr,jdtset,marr,3*dtset%gw_nqlwl,string(1:lenstr),'gw_qlwl',tread,'DPR')
    1249            7 :    if(tread==1) dtset%gw_qlwl(1:3,1:dtset%gw_nqlwl) = reshape(dprarr(1:3*dtset%gw_nqlwl), [3, dtset%gw_nqlwl])
    1250              :  end if
    1251              : 
    1252              :  !@bethe_salpeter
    1253         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bs_nstates',tread,'INT')
    1254         6959 :  if(tread==1) dtset%bs_nstates=intarr(1)
    1255              : 
    1256         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bs_algorithm',tread,'INT')
    1257         6959 :  if(tread==1) dtset%bs_algorithm=intarr(1)
    1258              : 
    1259         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bs_haydock_niter',tread,'INT')
    1260         6959 :  if(tread==1) dtset%bs_haydock_niter=intarr(1)
    1261              : 
    1262         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bs_hayd_term',tread,'INT')
    1263         6959 :  if(tread==1) dtset%bs_hayd_term=intarr(1)
    1264              : 
    1265         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bs_exchange_term',tread,'INT')
    1266         6959 :  if(tread==1) dtset%bs_exchange_term=intarr(1)
    1267              : 
    1268         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bs_calctype',tread,'INT')
    1269         6959 :  if(tread==1) dtset%bs_calctype=intarr(1)
    1270              : 
    1271         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bs_coulomb_term',tread,'INT')
    1272         6959 :  if(tread==1) dtset%bs_coulomb_term=intarr(1)
    1273              : 
    1274         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bs_coupling',tread,'INT')
    1275         6959 :  if(tread==1) dtset%bs_coupling=intarr(1)
    1276              : 
    1277         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdbseig',tread,'INT')
    1278         6959 :  if(tread==1) dtset%irdbseig=intarr(1)
    1279              : 
    1280              :  !call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdbsr',tread,'INT')
    1281              :  !if(tread==1) dtset%irdbsr=intarr(1)
    1282              : 
    1283              :  !call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdbsc',tread,'INT')
    1284              :  !if(tread==1) dtset%irdbsc=intarr(1)
    1285              : 
    1286         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getbseig',tread,'INT')
    1287         6959 :  if(tread==1) dtset%getbseig=intarr(1)
    1288              : 
    1289         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getbsreso',tread,'INT')
    1290         6959 :  if(tread==1) dtset%getbsreso=intarr(1)
    1291              : 
    1292         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getbscoup',tread,'INT')
    1293         6959 :  if(tread==1) dtset%getbscoup=intarr(1)
    1294              : 
    1295         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gethaydock',tread,'INT')
    1296         6959 :  if(tread==1) dtset%gethaydock=intarr(1)
    1297              : 
    1298         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bs_interp_method',tread,'INT')
    1299         6959 :  if(tread==1) dtset%bs_interp_method=intarr(1)
    1300              : 
    1301         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bs_interp_mode',tread,'INT')
    1302         6959 :  if(tread==1) dtset%bs_interp_mode=intarr(1)
    1303              : 
    1304         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bs_interp_prep',tread,'INT')
    1305         6959 :  if(tread==1) dtset%bs_interp_prep=intarr(1)
    1306              : 
    1307         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bs_interp_m3_width',tread,'DPR')
    1308         6959 :  if(tread==1) dtset%bs_interp_m3_width=dprarr(1)
    1309              : 
    1310         6959 :  call intagm(dprarr,intarr,jdtset,marr,dtset%nsppol,string(1:lenstr),'bs_loband',tread,'INT')
    1311         7018 :  if(tread==1) dtset%bs_loband=intarr(1:dtset%nsppol)
    1312              : 
    1313         6959 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'bs_interp_kmult',tread,'INT')
    1314         6977 :  if(tread==1) dtset%bs_interp_kmult(1:3) = intarr(1:3)
    1315              : 
    1316         6959 :  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'bs_eh_cutoff',tread,'ENE')
    1317         6959 :  if(tread==1) dtset%bs_eh_cutoff(1:2)=dprarr(1:2)
    1318              : 
    1319         6959 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'bs_freq_mesh',tread,'ENE')
    1320         7040 :  if(tread==1) dtset%bs_freq_mesh(1:3)=dprarr(1:3)
    1321              : 
    1322         6959 :  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'bs_haydock_tol',tread,'DPR')
    1323         6997 :  if(tread==1) dtset%bs_haydock_tol=dprarr(1:2)
    1324              : 
    1325         6959 :  ntypalch=dtset%ntypalch
    1326         6959 :  npspalch=dtset%npspalch
    1327              : 
    1328              :  ! Compute ziontypat. When the pseudo-atom is pure, simple copy
    1329         6959 :  if(ntyppure>0)then
    1330        15515 :    do itypat=1,ntyppure
    1331        15515 :      dtset%ziontypat(itypat)=zionpsp(itypat)
    1332              :    end do
    1333              :  end if
    1334              : 
    1335              :  ! When the pseudo-atom is alchemical, must make mixing
    1336         6959 :  if(ntypalch>0)then
    1337           40 :    do itypat=ntyppure+1,ntypat
    1338           20 :      dtset%ziontypat(itypat)=zero
    1339           80 :      do ipsp=ntyppure+1,npsp
    1340              :        dtset%ziontypat(itypat)=dtset%ziontypat(itypat) &
    1341           60 :         + dtset%mixalch_orig(ipsp-ntyppure,itypat-ntyppure,1)*zionpsp(ipsp)
    1342              :      end do
    1343              :    end do
    1344              :  end if
    1345              : 
    1346         6959 :  dtset%nh_qFD=zero
    1347         6959 :  dtset%ne_qFD=zero
    1348         6959 :  dtset%ivalence=0
    1349              : 
    1350         6959 :  if (occopt==0 .or. occopt==1 .or. (occopt>=3 .and. occopt<=9) ) then
    1351         6745 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nband',tnband,'INT')
    1352         6745 :    if(tnband==1) then
    1353         4561 :      nband1=intarr(1)
    1354              :    else
    1355              :      ! Default value in the metallic case, or in the insulating case
    1356         2184 :      fband=0.5_dp
    1357         2184 :      if(occopt==1)fband=0.125_dp
    1358         2184 :      if((occopt/=1).and.(dtset%accuracy==5.or.dtset%accuracy==6)) fband =0.75_dp
    1359         2184 :      if (dtset%usewvl == 1) fband = zero
    1360         2184 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fband',tfband,'DPR')
    1361         2184 :      if(tfband==1)then
    1362            3 :        fband=dprarr(1)
    1363            3 :        write(msg, '(a,es16.8,a)' )' invars2: read the value of fband=',fband,' from input file.'
    1364              :      else
    1365         2181 :        write(msg, '(a,es16.8)' )' invars2: take the default value of fband=',fband
    1366              :      end if
    1367         2184 :      dtset%fband=fband
    1368         2184 :      call wrtout(std_out,msg,'COLL')
    1369              :      ! First compute the total valence charge
    1370         2184 :      zval=zero
    1371         2184 :      sum_spinat=zero
    1372        29232 :      do iatom=1,natom
    1373        27048 :        zval=zval+dtset%ziontypat(dtset%typat(iatom))
    1374        29232 :        sum_spinat=sum_spinat+dtset%spinat(3,iatom)
    1375              :      end do
    1376         2184 :      zelect=zval-cellcharge_min
    1377              :      ! Then select the minimum number of bands, and add the required number.
    1378              :      ! Note that this number might be smaller than the one computed
    1379              :      ! by a slightly different formula in invars1 (difference in fband).
    1380              :      nband1=dtset%nspinor * ((ceiling(zelect-tol10)+1)/2 + ceiling( fband*natom - tol10 )) &
    1381         2184 : &     + (nsppol-1)*(ceiling(half*(sum_spinat -tol10)))
    1382              :    end if
    1383              : 
    1384              :    ! Set nband to same input number for each k point and spin
    1385              :    ! where nband1 is the eventual input, computed value, or default
    1386       123631 :    do ikpt=1,nkpt*nsppol
    1387       123631 :      dtset%nband(ikpt)=nband1
    1388              :    end do
    1389              : 
    1390         6745 :    if (occopt==9)then
    1391              :       !Read the valence band index
    1392            1 :       call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ivalence',tread,'INT')
    1393            1 :       if (tread==1) dtset%ivalence=intarr(1)
    1394            1 :       call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nqfd',tread,'DPR')
    1395            1 :       if (tread==1)then
    1396            1 :         dtset%nqfd=dprarr(1)
    1397            1 :         dtset%ne_qFD=dprarr(1)
    1398            1 :         dtset%nh_qFD=dprarr(1)
    1399              :         ! Here we assume that number of excited electrons  = number of excited holes.
    1400              :         ! Potentially can be relaxed in the future if consistent changes with the
    1401              :         ! cellcharge tag are made.
    1402              :       end if
    1403              :    end if
    1404              : 
    1405          214 :  else if (occopt==2) then
    1406              :    ! Give nband explicitly for each k point and spin
    1407          214 :    call intagm(dprarr,intarr,jdtset,nkpt*nsppol,nkpt*nsppol,string(1:lenstr),'nband',tnband,'INT')
    1408          728 :    if(tnband==1) dtset%nband(1:nkpt*nsppol)=intarr(1:nkpt*nsppol)
    1409              : 
    1410              :  else
    1411            0 :    write(msg, '(a,i0,3a)' )'occopt=',occopt,' not allowed.',ch10,'Action: correct your input file.'
    1412            0 :    ABI_ERROR(msg)
    1413              :  end if
    1414              : 
    1415              :  !----------------------------------------------------------------------------
    1416              :  ! Read other parameters
    1417              :  ! ALL CHECKING SHOULD BE DONE IN m_chkinp.F90
    1418              : 
    1419         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'builtintest',tread,'INT')
    1420         6959 :  if(tread==1) dtset%builtintest=intarr(1)
    1421              : 
    1422              :  ! Here we set the values of the different chk* flags depending on the value of expert_user.
    1423         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'expert_user',tread,'INT')
    1424         6959 :  if(tread==1) dtset%expert_user=intarr(1)
    1425              : 
    1426         6959 :  if (dtset%expert_user > 0) then
    1427              :    ! Set all flags to zero although we still allow users to activate particular tests via explicit values.
    1428           25 :    dtset%chkdilatmx=0
    1429           25 :    dtset%chkparal=0
    1430           25 :    dtset%chkprim=0
    1431           25 :    dtset%chksymbreak=0
    1432           25 :    dtset%chksymtnons=0
    1433              :  end if
    1434              : 
    1435         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'chkdilatmx',tread,'INT')
    1436         6959 :  if(tread==1) dtset%chkdilatmx=intarr(1)
    1437              : 
    1438         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'chkparal',tread,'INT')
    1439         6959 :  if(tread==1) dtset%chkparal=intarr(1)
    1440              : 
    1441         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'chkprim',tread,'INT')
    1442         6959 :  if(tread==1) dtset%chkprim=intarr(1)
    1443              : 
    1444         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'chksymbreak',tread,'INT')
    1445         6959 :  if(tread==1) dtset%chksymbreak=intarr(1)
    1446              : 
    1447         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'chksymtnons',tread,'INT')
    1448         6959 :  if(tread==1) dtset%chksymtnons=intarr(1)
    1449              : 
    1450         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fockoptmix',tread,'INT')
    1451         6959 :  if(tread==1) dtset%fockoptmix=intarr(1)
    1452              : 
    1453         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getocc',tread,'INT')
    1454         6959 :  if(tread==1) dtset%getocc=intarr(1)
    1455         6959 :  getocc=dtset%getocc
    1456              : 
    1457         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getwfk',tread,'INT')
    1458         6959 :  if(tread==1) dtset%getwfk=intarr(1)
    1459         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getwfk_filepath',tread,'KEY', key_value=key_value)
    1460         6959 :  if(tread==1) dtset%getwfk_filepath = key_value
    1461              : 
    1462         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getwfkfine',tread,'INT')
    1463         6959 :  if(tread==1) dtset%getwfkfine=intarr(1)
    1464         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getwfkfine_filepath',tread,'KEY', key_value=key_value)
    1465         6959 :  if(tread==1) dtset%getwfkfine_filepath = key_value
    1466              : 
    1467         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getxcart',tread,'INT')
    1468         6959 :  if(tread==1) dtset%getxcart=intarr(1)
    1469              : 
    1470         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getxred',tread,'INT')
    1471         6959 :  if(tread==1) dtset%getxred=intarr(1)
    1472              : 
    1473         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getabiwan',tread,'INT')
    1474         6959 :  if(tread==1) dtset%getabiwan=intarr(1)
    1475              : 
    1476         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getctqmcdata',tread,'INT')
    1477         6959 :  if(tread==1) dtset%getctqmcdata=intarr(1)
    1478              : 
    1479         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getgwan',tread,'INT')
    1480         6959 :  if(tread==1) dtset%getgwan=intarr(1)
    1481              : 
    1482         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getddb',tread,'INT')
    1483         6959 :  if(tread==1) dtset%getddb=intarr(1)
    1484              : 
    1485         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getdvdb',tread,'INT')
    1486         6959 :  if(tread==1) dtset%getdvdb=intarr(1)
    1487              : 
    1488         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getdrhodb',tread,'INT')
    1489         6959 :  if(tread==1) dtset%getdrhodb=intarr(1)
    1490              : 
    1491         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getden',tread,'INT')
    1492         6959 :  if(tread==1) dtset%getden=intarr(1)
    1493              : 
    1494         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getden_filepath',tread,'KEY', key_value=key_value)
    1495         6959 :  if(tread==1) dtset%getden_filepath = key_value
    1496              : 
    1497         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getpawden',tread,'INT')
    1498         6959 :  if(tread==1) dtset%getpawden=intarr(1)
    1499              : 
    1500         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getabiwan_filepath',tread,'KEY', key_value=key_value)
    1501         6959 :  if(tread==1) dtset%getabiwan_filepath = key_value
    1502              : 
    1503         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getgwan_filepath',tread,'KEY', key_value=key_value)
    1504         6959 :  if(tread==1) dtset%getgwan_filepath = key_value
    1505              : 
    1506         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getddb_filepath',tread,'KEY', key_value=key_value)
    1507         6959 :  if(tread==1) dtset%getddb_filepath = key_value
    1508              : 
    1509         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getdvdb_filepath',tread,'KEY', key_value=key_value)
    1510         6959 :  if(tread==1) dtset%getdvdb_filepath = key_value
    1511              : 
    1512         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getdrhodb_filepath',tread,'KEY', key_value=key_value)
    1513         6959 :  if(tread==1) dtset%getdrhodb_filepath = key_value
    1514              : 
    1515         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getpot_filepath',tread,'KEY', key_value=key_value)
    1516         6959 :  if(tread==1) dtset%getpot_filepath = key_value
    1517              : 
    1518         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getsigeph_filepath',tread,'KEY', key_value=key_value)
    1519         6959 :  if(tread==1) dtset%getsigeph_filepath = key_value
    1520              : 
    1521         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getgstore_filepath',tread,'KEY', key_value=key_value)
    1522         6959 :  if(tread==1) dtset%getgstore_filepath = key_value
    1523              : 
    1524         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getqpdata_filepath',tread,'KEY', key_value=key_value)
    1525         6959 :  if(tread==1) dtset%getqpdata_filepath = key_value
    1526              : 
    1527         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getcell',tread,'INT')
    1528         6959 :  if(tread==1) dtset%getcell=intarr(1)
    1529              : 
    1530         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getgam_eig2nkq',tread,'INT')
    1531         6959 :  if(tread==1) dtset%getgam_eig2nkq=intarr(1)
    1532              : 
    1533         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getwfmq',tread,'INT')
    1534         6959 :  if(tread==1) dtset%getwfmq=intarr(1)
    1535              : 
    1536         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getwfmq_filepath',tread,'KEY', key_value=key_value)
    1537         6959 :  if(tread==1) dtset%getwfmq_filepath = key_value
    1538              : 
    1539         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getself',tread,'INT')
    1540         6959 :  if(tread==1) dtset%getself=intarr(1)
    1541              : 
    1542         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getvpq',tread,'INT')
    1543         6959 :  if(tread==1) dtset%getvpq=intarr(1)
    1544              : 
    1545         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getvpq_filepath',tread,'KEY', key_value=key_value)
    1546         6959 :  if(tread==1) dtset%getvpq_filepath = key_value
    1547              : 
    1548         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getwfq',tread,'INT')
    1549         6959 :  if(tread==1) dtset%getwfq=intarr(1)
    1550              : 
    1551         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getwfq_filepath',tread,'KEY', key_value=key_value)
    1552         6959 :  if(tread==1) dtset%getwfq_filepath = key_value
    1553              : 
    1554         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'get1wf',tread,'INT')
    1555         6959 :  if(tread==1) dtset%get1wf=intarr(1)
    1556              :  ! TODO
    1557              :  !call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'get1wf_filepath',tread,'KEY', key_value=key_value)
    1558              :  !if(tread==1) dtset%get1wf_filepath = key_value
    1559              : 
    1560         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getddk',tread,'INT')
    1561         6959 :  if(tread==1) dtset%getddk=intarr(1)
    1562              : 
    1563         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getdelfd',tread,'INT')
    1564         6959 :  if(tread==1) dtset%getdelfd=intarr(1)
    1565              : 
    1566         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getdkdk',tread,'INT')
    1567         6959 :  if(tread==1) dtset%getdkdk=intarr(1)
    1568              : 
    1569         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getdkde',tread,'INT')
    1570         6959 :  if(tread==1) dtset%getdkde=intarr(1)
    1571              : 
    1572         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getvel',tread,'INT')
    1573         6959 :  if(tread==1) dtset%getvel=intarr(1)
    1574              : 
    1575         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'get1den',tread,'INT')
    1576         6959 :  if(tread==1) dtset%get1den=intarr(1)
    1577              : 
    1578         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'iomode',tread,'INT')
    1579         6959 :  if(tread==1) dtset%iomode=intarr(1)
    1580              : 
    1581         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'enunit',tread,'INT')
    1582         6959 :  if(tread==1) dtset%enunit=intarr(1)
    1583              : 
    1584              :  ! eph variables
    1585         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dipdip',tread_dipdip,'INT')
    1586         6959 :  if(tread_dipdip==1) dtset%dipdip=intarr(1)
    1587              : 
    1588         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'symdynmat',tread,'INT')
    1589         6959 :  if(tread==1) dtset%symdynmat=intarr(1)
    1590              : 
    1591         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'symv1scf',tread,'INT')
    1592         6959 :  if(tread==1) dtset%symv1scf = intarr(1)
    1593              : 
    1594         6959 :  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'scr_wrange',tread,'INT')
    1595         6967 :  if(tread==1) dtset%scr_wrange = intarr(1:2)
    1596              : 
    1597         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_prtscratew',tread,'INT')
    1598         6959 :  if(tread==1) dtset%eph_prtscratew = intarr(1)
    1599              : 
    1600         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_task',tread,'INT')
    1601         6959 :  if(tread==1) dtset%eph_task=intarr(1)
    1602              : 
    1603         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_restart',tread,'INT')
    1604         6959 :  if(tread==1) then
    1605           12 :    dtset%eph_restart = intarr(1)
    1606              :  else
    1607         6947 :    if (any(dtset%eph_task == [13, -13])) then
    1608              :      ! In VARPEQ, restart must be activated explicitly.
    1609           11 :      dtset%eph_restart = 0
    1610              :    end if
    1611              :  end if
    1612              : 
    1613         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_mustar',tread,'DPR')
    1614         6959 :  if(tread==1) dtset%eph_mustar=dprarr(1)
    1615              : 
    1616         6959 :  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'eph_tols_idelta',tread,'DPR')
    1617         6963 :  if (tread == 1) dtset%eph_tols_idelta = dprarr(1:2)
    1618              : 
    1619         6959 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'eph_fix_wavevec',tread,'DPR')
    1620         6965 :  if (tread == 1) dtset%eph_fix_wavevec = dprarr(1:3)
    1621              : 
    1622         6959 :  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'eph_phrange',tread,'INT')
    1623         6961 :  if (tread == 1) dtset%eph_phrange = intarr(1:2)
    1624              : 
    1625         6959 :  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'eph_phrange_w',tread,'ENE')
    1626         6961 :  if (tread == 1) dtset%eph_phrange_w = dprarr(1:2)
    1627              : 
    1628        41751 :  if (any(abs(dtset%eph_phrange) /= 0) .and. any(abs(dtset%eph_phrange_w) > tol16)) then
    1629            0 :    ABI_ERROR("eph_phrange and eph_phrange_w are mutually exclusive")
    1630              :  end if
    1631              : 
    1632         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_intmeth',tread,'INT')
    1633         6959 :  if (tread == 1) then
    1634           27 :    dtset%eph_intmeth = intarr(1)
    1635              :  else
    1636              :    ! eph_intmeth depends on eph_task.
    1637              :    !if (abs(dtset%eph_task) == 4) dtset%eph_intmeth = 1
    1638         6932 :    if (dtset%eph_task == +4) dtset%eph_intmeth = 1
    1639         6932 :    if (dtset%eph_task == -4 .and. dtset%symsigma == 0) dtset%eph_intmeth = 1
    1640              :  end if
    1641              : 
    1642              :  ! Allow use to dope the system or to shift artificially the Fermi level
    1643         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_extrael',tread_extrael,'DPR')
    1644         6959 :  if (tread_extrael == 1) dtset%eph_extrael = dprarr(1)
    1645              : 
    1646         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'eph_doping', tread, 'DPR')
    1647         6959 :  if (tread == 1) then
    1648           13 :    ABI_CHECK(tread_extrael == 0, "eph_extrael and eph_doping are mutually exclusive!")
    1649              :    ! Units of eph_doping is e_charge / cm^3
    1650           13 :    dtset%eph_extrael = - dprarr(1) * ucvol * (Bohr_meter * 100) ** 3
    1651              :  end if
    1652              : 
    1653         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_ahc_type',tread,'INT')
    1654         6959 :  if(tread==1) dtset%eph_ahc_type=intarr(1)
    1655              : 
    1656         6959 :  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'eph_path_brange',tread,'INT')
    1657         6963 :  if(tread==1) dtset%eph_path_brange=intarr(1:2)
    1658              : 
    1659         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_fermie',tread,'ENE')
    1660         6959 :  if(tread==1) dtset%eph_fermie=dprarr(1)
    1661              : 
    1662         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_frohlichm',tread,'INT')
    1663         6959 :  if(tread==1) dtset%eph_frohlichm=intarr(1)
    1664              : 
    1665         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_frohl_ntheta',tread,'INT')
    1666         6959 :  if(tread==1) dtset%eph_frohl_ntheta=intarr(1)
    1667              : 
    1668         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_fsmear',tread,'ENE')
    1669         6959 :  if(tread==1) dtset%eph_fsmear=dprarr(1)
    1670              : 
    1671         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_fsewin',tread,'ENE')
    1672         6959 :  if(tread==1) dtset%eph_fsewin=dprarr(1)
    1673              : 
    1674         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_ecutosc',tread,'ENE')
    1675         6959 :  if(tread==1) dtset%eph_ecutosc=dprarr(1)
    1676              : 
    1677         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_phwinfact',tread,'DPR')
    1678         6959 :  if(tread==1) dtset%eph_phwinfact = dprarr(1)
    1679              : 
    1680         6959 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'eph_ngkpt_fine',tread,'INT')
    1681         6959 :  if(tread==1) dtset%eph_ngkpt_fine=intarr(1:3)
    1682              : 
    1683         6959 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'eph_ngqpt_fine',tread,'INT')
    1684         7112 :  if(tread==1) dtset%eph_ngqpt_fine=intarr(1:3)
    1685              : 
    1686         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_nshiftk_fine',tread,'INT')
    1687         6959 :  if(tread==1) dtset%eph_nshiftk_fine=intarr(1)
    1688         6959 :  if (dtset%eph_nshiftk_fine < 1 .or. dtset%eph_nshiftk_fine > MAX_NSHIFTK) then
    1689              :    write(msg, '(a,i0,2a,i0,3a)') &
    1690            0 :      'The only allowed values of eph_nshiftk_fine are between 1 and ', MAX_NSHIFTK, ch10, &
    1691            0 :      'while it is found to be ', dtset%eph_nshiftk_fine, '.', ch10, &
    1692            0 :      'Action: change the value of eph_nshiftk_fine in your input file.'
    1693            0 :    ABI_ERROR(msg)
    1694              :  end if
    1695              : 
    1696         6959 :  ABI_CHECK(3 * dtset%eph_nshiftk_fine <= marr, "3 * eph_nshiftk_fine > marr")
    1697         6959 :  call intagm(dprarr,intarr,jdtset,marr,3*dtset%eph_nshiftk_fine,string(1:lenstr),'eph_shiftk_fine',tread,'DPR')
    1698         6959 :  ABI_SFREE(dtset%eph_shiftk_fine)
    1699        48713 :  ABI_CALLOC(dtset%eph_shiftk_fine, (3, dtset%eph_nshiftk_fine))
    1700         6959 :  if(tread==1) dtset%eph_shiftk_fine = reshape(dprarr(1:3*dtset%eph_nshiftk_fine), [3, dtset%eph_nshiftk_fine])
    1701              : 
    1702         6959 :  narr = size(dtset%eph_np_pqbks)
    1703         6959 :  call intagm(dprarr,intarr,jdtset,marr,narr,string(1:lenstr),'eph_np_pqbks',tread,'INT')
    1704         6959 :  if (tread==1) dtset%eph_np_pqbks = intarr(1:narr)
    1705              : 
    1706         6959 :  narr = size(dtset%gwpt_np_wpqbks)
    1707         6959 :  call intagm(dprarr,intarr,jdtset,marr,narr,string(1:lenstr),'gwpt_np_wpqbks',tread,'INT')
    1708         6959 :  if (tread==1) dtset%gwpt_np_wpqbks = intarr(1:narr)
    1709              : 
    1710         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_stern',tread,'INT')
    1711         6959 :  if(tread==1) dtset%eph_stern = intarr(1)
    1712              : 
    1713         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_use_ftinterp',tread,'INT')
    1714         6959 :  if(tread==1) dtset%eph_use_ftinterp = intarr(1)
    1715              : 
    1716         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_transport',tread,'INT')
    1717         6959 :  if(tread==1) dtset%eph_transport=intarr(1)
    1718              : 
    1719         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ph_wstep',tread,'ENE')
    1720         6959 :  if(tread==1) dtset%ph_wstep=dprarr(1)
    1721              : 
    1722         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ph_intmeth',tread,'INT')
    1723         6959 :  if(tread==1) dtset%ph_intmeth=intarr(1)
    1724              : 
    1725         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ph_smear',tread,'ENE')
    1726         6959 :  if(tread==1) dtset%ph_smear=dprarr(1)
    1727              : 
    1728         6959 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'ddb_ngqpt',tread,'INT')
    1729         7292 :  if(tread==1) dtset%ddb_ngqpt=intarr(1:3)
    1730              : 
    1731         6959 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'ddb_shiftq',tread,'DPR')
    1732         6965 :  if(tread==1) dtset%ddb_shiftq=dprarr(1:3)
    1733              : 
    1734         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dvdb_qdamp',tread,'DPR')
    1735         6959 :  if(tread==1) dtset%dvdb_qdamp = dprarr(1)
    1736              : 
    1737         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dvdb_rspace_cell',tread, 'INT')
    1738         6959 :  if(tread==1) dtset%dvdb_rspace_cell = intarr(1)
    1739              : 
    1740         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dvdb_add_lr',tread,'INT')
    1741         6959 :  if(tread==1) dtset%dvdb_add_lr = intarr(1)
    1742              : 
    1743         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ph_ndivsm',tread,'INT')
    1744         6959 :  if(tread==1) dtset%ph_ndivsm=intarr(1)
    1745              : 
    1746         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ph_nqpath',tread,'INT')
    1747         6959 :  if(tread==1) dtset%ph_nqpath=intarr(1)
    1748              : 
    1749         6959 :  if (dtset%ph_nqpath > 0) then
    1750              :    ! Read qpath for phonons
    1751          117 :    ABI_MALLOC(dtset%ph_qpath, (3, dtset%ph_nqpath))
    1752           39 :    ABI_CHECK(3 * dtset%ph_nqpath <= marr, "3 * dtset%ph_nqpath > marr!")
    1753           39 :    call intagm(dprarr,intarr,jdtset,marr,3*dtset%ph_nqpath,string(1:lenstr),'ph_qpath',tread,'DPR')
    1754           39 :    if (tread == 0) then
    1755            0 :      ABI_ERROR("When ph_nqpath > 0, ph_qpath should be specified")
    1756              :    end if
    1757          684 :    dtset%ph_qpath = reshape(dprarr(1:3*dtset%ph_nqpath), [3, dtset%ph_nqpath])
    1758              :  end if
    1759              : 
    1760         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ph_nqshift',tread,'INT')
    1761         6959 :  if(tread==1) dtset%ph_nqshift=intarr(1)
    1762              : 
    1763         6959 :  if (dtset%ph_nqshift > 0) then
    1764              :    ! Read ph_qshift for phonons, default is [0,0,0]
    1765        48713 :    ABI_CALLOC(dtset%ph_qshift, (3, dtset%ph_nqshift))
    1766         6959 :    if (tread == 1) then
    1767           22 :      ABI_CHECK(3 * dtset%ph_nqshift <= marr, "3 * dtset%ph_nqshift > marr!")
    1768           22 :      call intagm(dprarr,intarr,jdtset,marr,3*dtset%ph_nqshift,string(1:lenstr),'ph_qshift',tread,'DPR')
    1769           22 :      if (tread == 0) then
    1770            0 :        ABI_ERROR("When ph_nqshift > 0, ph_qshift should be specified")
    1771              :      end if
    1772          176 :      dtset%ph_qshift = reshape(dprarr(1:3*dtset%ph_nqshift), [3, dtset%ph_nqshift])
    1773              :    end if
    1774              :  end if
    1775              : 
    1776         6959 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'ph_ngqpt',tread,'INT')
    1777         7028 :  if(tread==1) dtset%ph_ngqpt=intarr(1:3)
    1778              : !end e-ph variables
    1779              : 
    1780         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'exchn2n3d',tread,'INT')
    1781         6959 :  if(tread==1) dtset%exchn2n3d=intarr(1)
    1782              : 
    1783         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'extrapwf',tread,'INT')
    1784         6959 :  if(tread==1) dtset%extrapwf=intarr(1)
    1785              : 
    1786         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ibte_abs_tol',tread,'DPR')
    1787         6959 :  if(tread==1) dtset%ibte_abs_tol=dprarr(1)
    1788              : 
    1789         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ibte_alpha_mix',tread,'DPR')
    1790         6959 :  if(tread==1) dtset%ibte_alpha_mix=dprarr(1)
    1791              : 
    1792         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ibte_niter',tread,'INT')
    1793         6959 :  if(tread==1) dtset%ibte_niter=intarr(1)
    1794              : 
    1795         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ibte_prep',tread,'INT')
    1796              :  ! ibte_prep is only available when we compute the imaginary part.
    1797         6959 :  if(tread==1 .and. dtset%eph_task == -4) dtset%ibte_prep=intarr(1)
    1798              : 
    1799         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'iboxcut',tread,'INT')
    1800         6959 :  if(tread==1) dtset%iboxcut=intarr(1)
    1801              : 
    1802         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'icutcoul',tread,'INT')
    1803         6959 :  if(tread==1) dtset%icutcoul=intarr(1)
    1804              : 
    1805         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fock_icutcoul',tread,'INT')
    1806         6959 :  if(tread==1) dtset%fock_icutcoul=intarr(1)
    1807              : 
    1808         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'imgwfstor',tread,'INT')
    1809         6959 :  if(tread==1) dtset%imgwfstor=intarr(1)
    1810              : 
    1811         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'mdf_epsinf',tread,'DPR')
    1812         6959 :  if(tread==1) dtset%mdf_epsinf=dprarr(1)
    1813              : 
    1814         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'mem_test',tread,'INT')
    1815         6959 :  if(tread==1) dtset%mem_test=intarr(1)
    1816              : 
    1817         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'mixprec',tread,'INT')
    1818         6959 :  if (tread==1) dtset%mixprec = intarr(1)
    1819              : 
    1820         6959 :  if (dtset%imgmov==0.or.dtset%imgmov==2.or.dtset%imgmov==5) then
    1821         6944 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'mep_mxstep',tread,'LEN')
    1822         6944 :    if(tread==1) then
    1823            4 :      dtset%mep_mxstep=dprarr(1)
    1824         6940 :    else if(dtset%imgmov==5) then
    1825            1 :      dtset%mep_mxstep=0.4_dp
    1826              :    end if
    1827              :  end if
    1828         6959 :  if (dtset%imgmov==2.or.dtset%imgmov==5) then
    1829           28 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'mep_solver',tread,'INT')
    1830           28 :    if(tread==1) then
    1831            5 :      dtset%mep_solver=intarr(1)
    1832           23 :    else if(dtset%imgmov==2) then
    1833           23 :      dtset%mep_solver=MEP_SOLVER_STEEPEST
    1834            0 :    else if(dtset%imgmov==5) then
    1835            0 :      dtset%mep_solver=MEP_SOLVER_STEEPEST
    1836              :    end if
    1837           28 :    if (dtset%imgmov==2) then
    1838           24 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'string_algo',tread,'INT')
    1839           24 :      if(tread==1) dtset%string_algo=intarr(1)
    1840              :    end if
    1841           28 :    if (dtset%imgmov==5) then
    1842            4 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'neb_algo',tread,'INT')
    1843            4 :      if(tread==1) dtset%neb_algo=intarr(1)
    1844            4 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'neb_cell_algo',tread,'INT')
    1845            4 :      if(tread==1) dtset%neb_cell_algo=intarr(1)
    1846            4 :      call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'neb_spring',tread,'DPR')
    1847            4 :      if(tread==1) then
    1848            3 :        dtset%neb_spring(1:2)=dprarr(1:2)
    1849            3 :      else if (dtset%neb_algo==NEB_ALGO_CINEB) then
    1850            0 :        dtset%neb_spring(1:2)=(/0.02_dp,0.15_dp/)
    1851              :      end if
    1852            4 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'cineb_start',tread,'INT')
    1853            4 :      if(tread==1) dtset%cineb_start=intarr(1)
    1854              :    end if
    1855              :  end if
    1856              : 
    1857         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'istatimg',tread,'INT')
    1858         6959 :  if(tread==1) dtset%istatimg=intarr(1)
    1859              : 
    1860         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'quadquad',tread,'INT')
    1861         6959 :  if(tread==1) dtset%quadquad=intarr(1)
    1862              : 
    1863              :  ! variables for random positions in unit cell
    1864         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'random_atpos',tread,'INT')
    1865         6959 :  if(tread==1) dtset%random_atpos=intarr(1)
    1866              : 
    1867              : ! parsing GEOmetryOPTimization keys to internal variable ionmov
    1868         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'geoopt',tread,'KEY',key_value=key_value)
    1869         6959 :  if(tread==1) dtset%geoopt = tolower(key_value)
    1870         6959 :  if (dtset%geoopt.ne.'none') then
    1871           53 :    if(INDEX(dtset%geoopt,'viscous').gt.0) then
    1872            0 :      dtset%ionmov=1
    1873           53 :    elseif(INDEX(dtset%geoopt,'bfgs').gt.0) then
    1874           53 :      dtset%ionmov=2
    1875            0 :    elseif(INDEX(dtset%geoopt,'lbfgs').gt.0) then
    1876            0 :      dtset%ionmov=22
    1877            0 :    elseif(INDEX(dtset%geoopt,'mdmin').gt.0) then
    1878            0 :      dtset%ionmov=5
    1879            0 :    elseif(INDEX(dtset%geoopt,'quenched').gt.0) then
    1880            0 :      dtset%ionmov=7
    1881            0 :    elseif(INDEX(dtset%geoopt,'fire').gt.0) then
    1882            0 :      dtset%ionmov=15
    1883              :    end if
    1884              :  end if
    1885              : 
    1886              : ! parsing MOLecularDYNamics keys to internal variable ionmov
    1887         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'moldyn',tread,'KEY',key_value=key_value)
    1888         6959 :  if(tread==1) dtset%moldyn = tolower(key_value)
    1889         6959 :  if(dtset%moldyn.ne.'none') then
    1890            4 :    if(INDEX(dtset%moldyn,'nve_verlet').gt.0) then
    1891            0 :      dtset%ionmov=6
    1892            4 :    elseif(INDEX(dtset%moldyn,'nve_velverlet').gt.0) then
    1893            0 :      dtset%ionmov=24
    1894            4 :    elseif(INDEX(dtset%moldyn,'nvt_isokin').gt.0) then
    1895            2 :      dtset%ionmov=12
    1896            2 :    elseif(INDEX(dtset%moldyn,'nvt_langevin').gt.0) then
    1897            1 :      dtset%ionmov=16
    1898            1 :    elseif(INDEX(dtset%moldyn,'npt_langevin').gt.0) then
    1899            1 :      dtset%ionmov=16
    1900            0 :    elseif(INDEX(dtset%moldyn,'nst_langevin').gt.0) then
    1901            0 :      dtset%ionmov=16
    1902            0 :    elseif(INDEX(dtset%moldyn,'nvt_nose').gt.0) then
    1903            0 :      dtset%ionmov=13
    1904            0 :    elseif(INDEX(dtset%moldyn,'npt_martyna').gt.0) then
    1905            0 :      dtset%ionmov=13
    1906            0 :    elseif(INDEX(dtset%moldyn,'nst_martyna').gt.0) then
    1907            0 :      dtset%ionmov=13
    1908              :    end if
    1909              :  end if
    1910              : 
    1911         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ionmov',tread,'INT')
    1912         6959 :  if(tread==1) dtset%ionmov=intarr(1)
    1913              : 
    1914         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'paral_slice',tread,'INT')
    1915         6959 :  if(tread==1) dtset%paral_slice=intarr(1)
    1916              : 
    1917         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'intxc',tread,'INT')
    1918         6959 :  if(tread==1) dtset%intxc=intarr(1)
    1919              : 
    1920         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'densfor_pred',tread,'INT')
    1921         6959 :  if(tread==1) then
    1922           67 :    dtset%densfor_pred=intarr(1)
    1923              :  else
    1924         6892 :    if (dtset%paral_kgb==1) dtset%densfor_pred=6
    1925              :  end if
    1926              : 
    1927         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'hmcsst',tread,'INT')
    1928         6959 :  if(tread==1) dtset%hmcsst=intarr(1)
    1929              : 
    1930         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'hmctt',tread,'INT')
    1931         6959 :  if(tread==1) dtset%hmctt=intarr(1)
    1932              : 
    1933              :  ! For the moment LOTF does not use different from 2
    1934         6959 :  if(dtset%ionmov==23) then
    1935              : #ifdef HAVE_LOTF
    1936              :    if(dtset%densfor_pred/=2)then
    1937              :      densfor_pred=2
    1938              :      dtset%densfor_pred=densfor_pred
    1939              :      write(msg, '(4a)' )&
    1940              :        'When ionmov==23, densfor_pred must be 2.',ch10,&
    1941              :        'Set densfor_pred to 2.',ch10
    1942              :      ABI_COMMENT(msg)
    1943              :    end if
    1944              : #else
    1945            0 :    dtset%ionmov=12
    1946              :    write(msg, '(4a)' )&
    1947            0 :      'LOTF is disabled, ionmov can not be 23.',ch10,&
    1948            0 :      'Set ionmov to 12.',ch10
    1949            0 :    ABI_COMMENT(msg)
    1950              : #endif
    1951              :  end if
    1952              : 
    1953         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'iprcel',tread,'INT')
    1954         6959 :  if(tread==1) dtset%iprcel=intarr(1)
    1955              : 
    1956         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'iprcfc',tread,'INT')
    1957         6959 :  if(tread==1) dtset%iprcfc=intarr(1)
    1958              : 
    1959         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irandom',tread,'INT')
    1960         6959 :  if(tread==1) dtset%irandom=intarr(1)
    1961              : 
    1962         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdddb',tread,'INT')
    1963         6959 :  if(tread==1) dtset%irdddb=intarr(1)
    1964              : 
    1965         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdden',tread,'INT')
    1966         6959 :  if(tread==1) dtset%irdden=intarr(1)
    1967              : 
    1968         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irddvdb',tread,'INT')
    1969         6959 :  if(tread==1) dtset%irddvdb = intarr(1)
    1970              : 
    1971         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irddrhodb',tread,'INT')
    1972         6959 :  if(tread==1) dtset%irddrhodb = intarr(1)
    1973              : 
    1974         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdpawden',tread,'INT')
    1975         6959 :  if(tread==1) dtset%irdpawden=intarr(1)
    1976              : 
    1977         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdhaydock',tread,'INT')
    1978         6959 :  if(tread==1) dtset%irdhaydock=intarr(1)
    1979              : 
    1980         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdvdw',tread,'INT')
    1981         6959 :  if(tread==1) dtset%irdvdw=intarr(1)
    1982              : 
    1983         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdwfk',tread,'INT')
    1984         6959 :  if(tread==1) dtset%irdwfk=intarr(1)
    1985              : 
    1986         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdwfkfine',tread,'INT')
    1987         6959 :  if(tread==1) dtset%irdwfkfine=intarr(1)
    1988              : 
    1989         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'isecur',tread,'INT')
    1990         6959 :  if(tread==1) dtset%isecur=intarr(1)
    1991              : 
    1992              :  ! Reading ixc must be immediately followed by reading xcname
    1993         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ixc',tread,'INT')
    1994         6959 :  if(tread==1) dtset%ixc=intarr(1)
    1995              : 
    1996         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),"xcname",tread_key,'KEY',key_value=key_value)
    1997         6959 :  if(tread_key==1)then
    1998            1 :    if(tread==1)then
    1999              :      write(msg, '(5a)' )&
    2000            0 :       'ixc and xcname cannot be specified simultaneously',ch10,&
    2001            0 :       'for the same dataset.',ch10,'Action: check the input file.'
    2002            0 :      ABI_ERROR(msg)
    2003              :    else
    2004              :      !Note that xcname is a 'key' variable : its value is stored in keyw at output of intagm
    2005            1 :      if(trim(key_value) == 'PW92') then
    2006            1 :         dtset%ixc=7
    2007              :      else
    2008            0 :        ABI_ERROR(sjoin("Don't know how to convert xcname", key_value, "to ixc"))
    2009              :      end if
    2010              :      tread=1
    2011              :    end if
    2012              :  end if
    2013         6959 :  ixc_here=dtset%ixc
    2014              : 
    2015         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ixcrot',tread,'INT')
    2016         6959 :  if(tread==1) dtset%ixcrot=intarr(1)
    2017              : 
    2018              :  ! Read the ixc for an advanced functional
    2019              :  ! If present, and relevant (only specific values for gcalctyp),
    2020              :  ! the other internal variable will be adjusted to this other functional)
    2021         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ixc_sigma',tread,'INT')
    2022         6959 :  if(tread==1)then
    2023           79 :    dtset%ixc_sigma=intarr(1)
    2024           79 :    if (dtset%optdriver==RUNL_SIGMA.and.mod(dtset%gwcalctyp,10)==5) ixc_here=dtset%ixc_sigma
    2025              :  end if
    2026              : 
    2027              :  ! Initialize here data related to exchange-correlation functional
    2028         6959 :  if (ixc_here<0) then
    2029         1175 :    call libxc_functionals_init(ixc_here,dtset%nspden,xc_functionals=xcfunc,xc_tb09_c=dtset%xc_tb09_c)
    2030              :  end if
    2031         6959 :  call get_xclevel(ixc_here, dtset%xclevel, usefock=dtset%usefock)
    2032         6959 :  xc_has_kxc=has_kxc(ixc_here,xc_funcs=xcfunc)
    2033              :  ! Meta-GGA
    2034         6959 :  if (ixc_here<0) then
    2035         1175 :    xc_is_mgga=libxc_functionals_ismgga(xc_functionals=xcfunc)
    2036         1175 :    xc_is_pot_only=libxc_functionals_is_potential_only(xc_functionals=xcfunc)
    2037         1175 :    xc_need_kden=libxc_functionals_needs_tau(xc_functionals=xcfunc)
    2038              :  else
    2039         5784 :    xc_is_mgga=(ixc_here>=31.and.ixc_here<=35)
    2040         5784 :    xc_is_pot_only=.false.
    2041         5784 :    xc_need_kden=(ixc_here==31.or.ixc_here==34.or.ixc_here==35)
    2042              :  end if
    2043              :  ! Hybrids
    2044         6959 :  if (dtset%usefock==1) then
    2045          146 :    if(ixc_here==40.or.ixc_here==41.or.ixc_here==42) then
    2046           82 :      dtset%hyb_mixing_sr=zero
    2047           82 :      dtset%hyb_range_dft=zero ; dtset%hyb_range_fock=zero
    2048           82 :      if(ixc_here==40)dtset%hyb_mixing=one
    2049           82 :      if(ixc_here==41)dtset%hyb_mixing=quarter
    2050           82 :      if(ixc_here==42)dtset%hyb_mixing=third
    2051           64 :    else if(ixc_here==-427)then
    2052              :      ! Special case of HSE03
    2053            8 :      dtset%hyb_mixing=zero  ; dtset%hyb_mixing_sr=quarter
    2054            8 :      dtset%hyb_range_dft=0.15_dp*two**third  ; dtset%hyb_range_fock=0.15_dp*sqrt(half)
    2055           56 :    else if (ixc_here<0) then
    2056              :      call libxc_functionals_get_hybridparams(hyb_mixing=dtset%hyb_mixing,hyb_mixing_sr=dtset%hyb_mixing_sr,&
    2057           56 :        hyb_range=dtset%hyb_range_dft,xc_functionals=xcfunc)
    2058           56 :      dtset%hyb_range_fock=dtset%hyb_range_dft
    2059              :    end if
    2060              :  end if
    2061              :  ! Hybrids: auxiliary functional
    2062         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'auxc_scal',tread,'DPR')
    2063         6959 :  if(tread==1) dtset%auxc_scal=dprarr(1)
    2064         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'auxc_ixc',tread,'INT')
    2065         6959 :  if(tread==1) dtset%auxc_ixc=intarr(1)
    2066              :  ! If the default value had been given, possibly switch on
    2067              :  ! the auxc_ixc corresponding to ixc, if the latter is an hybrid
    2068         6959 :  if (dtset%auxc_ixc==0) then
    2069            0 :    call get_auxc_ixc(dtset%auxc_ixc,ixc_here)
    2070              :  end if
    2071         6959 :  if (ixc_here<0) then
    2072         1175 :    call libxc_functionals_end(xc_functionals=xcfunc)
    2073              :  end if
    2074              : 
    2075              :  ! Now take care of the parameters for hybrid functionals
    2076         6959 :  if(dtset%usefock==1)then
    2077              : 
    2078              :    ! Warning: the user-defined parameters for hybrids are by convention stored as negative numbers
    2079              :    ! This trick will allow to echo them, and only them.
    2080          146 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'hyb_mixing',tread,'DPR')
    2081          146 :    if(tread==1)then
    2082           16 :      if(dprarr(1)<-tol14)then
    2083              :        write(msg, '(a,es16.8,2a)' )&
    2084            0 :        'A negative value for hyb_mixing is not allowed, while at input hyb_mixing=',dprarr(1),ch10,&
    2085            0 :        'Action: modify hyb_mixing in the input file.'
    2086            0 :        ABI_ERROR(msg)
    2087              :      end if
    2088           16 :      dtset%hyb_mixing=-dprarr(1) ! Note the minus sign
    2089              :    end if
    2090              : 
    2091          146 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'hyb_mixing_sr',tread,'DPR')
    2092          146 :    if(tread==1)then
    2093            3 :      if(dprarr(1)<-tol14)then
    2094              :        write(msg, '(a,es16.8,2a)' )&
    2095            0 :        'A negative value for hyb_mixing_sr is not allowed, while at input hyb_mixing_sr=',dprarr(1),ch10,&
    2096            0 :        'Action: modify hyb_mixing_sr in the input file.'
    2097            0 :        ABI_ERROR(msg)
    2098              :      end if
    2099            3 :      dtset%hyb_mixing_sr=-dprarr(1) ! Note the minus sign
    2100              :    end if
    2101              : 
    2102          146 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'hyb_range_dft',tread_dft,'DPR')
    2103          146 :    if(tread_dft==1)then
    2104            6 :      if(dprarr(1)<-tol14)then
    2105              :        write(msg, '(a,es16.8,2a)' )&
    2106            0 :        'A negative value for hyb_range_dft is not allowed, while at input hyb_range_dft=',dprarr(1),ch10,&
    2107            0 :        'Action: modify hyb_range_dft in the input file.'
    2108            0 :        ABI_ERROR(msg)
    2109              :      end if
    2110            6 :      dtset%hyb_range_dft=-dprarr(1) ! Note the minus sign
    2111              :    end if
    2112              : 
    2113          146 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'hyb_range_fock',tread_fock,'DPR')
    2114          146 :    if(tread_fock==1)then
    2115           12 :      if(dprarr(1)<-tol14)then
    2116              :        write(msg, '(a,es16.8,2a)' )&
    2117            0 :        'A negative value for hyb_range_fock is not allowed, while at input hyb_range_fock=',dprarr(1),ch10,&
    2118            0 :        'Action: modify hyb_range_fock in the input file.'
    2119            0 :        ABI_ERROR(msg)
    2120              :      end if
    2121           12 :      dtset%hyb_range_fock=-dprarr(1) ! Note the minus sign
    2122              :    end if
    2123              : 
    2124          146 :    if(tread_fock==1 .and. tread_dft==0)dtset%hyb_range_dft=dtset%hyb_range_fock
    2125          146 :    if(tread_fock==0 .and. tread_dft==1)dtset%hyb_range_fock=dtset%hyb_range_dft
    2126              : 
    2127              :  end if
    2128              : 
    2129              : !Note iscf has to be read after ixc, usewvl, optdriver, optforces, densfor_pred
    2130         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'iscf',tread,'INT')
    2131         6959 :  if(tread==1) then
    2132          825 :    dtset%iscf=intarr(1)
    2133          825 :    if (dtset%usewvl==1) then
    2134              :      !wvl_bigdft_comp should be 1 for iscf=0, 0 for iscf>0, except if it is set by the user
    2135            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'wvl_bigdft_comp',tread,'INT')
    2136            0 :      if (tread==0.and.dtset%iscf==0) dtset%wvl_bigdft_comp=1
    2137            0 :      if (tread==0.and.dtset%iscf >0) dtset%wvl_bigdft_comp=0
    2138              :    end if
    2139         6134 :  else if (dtset%optdriver==RUNL_GWLS) then
    2140              :    !For GWLS, iscf=-2 is mandatory
    2141            8 :    dtset%iscf=-2
    2142         6126 :  else if (dtset%optdriver==RUNL_RESPFN.and.dtset%iscf>=10) then
    2143              :    !Only potential mixing available for response function
    2144           68 :    dtset%iscf=dtset%iscf-10
    2145         6058 :  else if (dtset%optdriver==RUNL_GSTATE.and.dtset%iscf>=10.and.xc_is_pot_only) then
    2146              :    !For the TB09 xc functional, the potential mixing seems to be better
    2147            3 :    dtset%iscf=dtset%iscf-10
    2148            3 :    msg='Automatically switching to potential mixing (iscf<10); seems to be better for BJ/TB09 XC...'
    2149            3 :    ABI_COMMENT(msg)
    2150              :  else if (dtset%optdriver==RUNL_GSTATE.and.dtset%iscf>=10.and. &
    2151         6055 : &         dtset%densfor_pred/=0.and.abs(dtset%densfor_pred)/=5) then
    2152              :    !In case of density mixing (iscf>=10) and correction of forces (densfor_pred/=0 and 5)
    2153              :    !  we need Kxc. If it is not available, we switch to potential mixing (iscf<10)
    2154          941 :    if (.not.xc_has_kxc) then
    2155            7 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'optforces',tread,'INT')
    2156            7 :      if (dtset%optforces/=0.or.intarr(1)/=0) then
    2157            7 :        dtset%iscf=dtset%iscf-10
    2158            7 :        ABI_COMMENT('Automatically switching to potential mixing (iscf<10), because XC functional doe snot provide Kxc!')
    2159              :      end if
    2160              :    end if
    2161              :  end if
    2162              : 
    2163         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_acutmin',tread,'DPR')
    2164         6959 :  if(tread==1) dtset%vdw_df_acutmin=dprarr(1)
    2165         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_aratio',tread,'DPR')
    2166         6959 :  if(tread==1) dtset%vdw_df_aratio=dprarr(1)
    2167         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_damax',tread,'DPR')
    2168         6959 :  if(tread==1) dtset%vdw_df_damax=dprarr(1)
    2169         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_damin',tread,'DPR')
    2170         6959 :  if(tread==1) dtset%vdw_df_damin=dprarr(1)
    2171         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_dcut',tread,'DPR')
    2172         6959 :  if(tread==1) dtset%vdw_df_dcut=dprarr(1)
    2173         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_dratio',tread,'DPR')
    2174         6959 :  if(tread==1) dtset%vdw_df_dratio=dprarr(1)
    2175         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_dsoft',tread,'DPR')
    2176         6959 :  if(tread==1) dtset%vdw_df_dsoft=dprarr(1)
    2177         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_gcut',tread,'DPR')
    2178         6959 :  if(tread==1) dtset%vdw_df_gcut=dprarr(1)
    2179         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_ndpts',tread,'INT')
    2180         6959 :  if(tread==1) dtset%vdw_df_ndpts=intarr(1)
    2181         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_ngpts',tread,'INT')
    2182         6959 :  if(tread==1) dtset%vdw_df_ngpts=intarr(1)
    2183         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_nqpts',tread,'INT')
    2184         6959 :  if(tread==1) dtset%vdw_df_nqpts=intarr(1)
    2185         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_nrpts',tread,'INT')
    2186         6959 :  if(tread==1) dtset%vdw_df_nrpts=intarr(1)
    2187         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_nsmooth',tread,'INT')
    2188         6959 :  if(tread==1) dtset%vdw_df_nsmooth=intarr(1)
    2189         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_phisoft',tread,'DPR')
    2190         6959 :  if(tread==1) dtset%vdw_df_phisoft=dprarr(1)
    2191         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_qcut',tread,'DPR')
    2192         6959 :  if(tread==1) dtset%vdw_df_qcut=dprarr(1)
    2193         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_qratio',tread,'DPR')
    2194         6959 :  if(tread==1) dtset%vdw_df_qratio=dprarr(1)
    2195         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_rcut',tread,'DPR')
    2196         6959 :  if(tread==1) dtset%vdw_df_rcut=dprarr(1)
    2197         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_rsoft',tread,'DPR')
    2198         6959 :  if(tread==1) dtset%vdw_df_rsoft=dprarr(1)
    2199         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_tolerance',tread,'DPR')
    2200         6959 :  if(tread==1) dtset%vdw_df_tolerance=dprarr(1)
    2201         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_threshold',tread,'DPR',ds_input)
    2202         6959 :  if(tread==1) dtset%vdw_df_threshold=dprarr(1)
    2203         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_tweaks',tread,'INT')
    2204         6959 :  if(tread==1) dtset%vdw_df_tweaks=intarr(1)
    2205         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_zab',tread,'DPR')
    2206         6959 :  if(tread==1) dtset%vdw_df_zab=dprarr(1)
    2207         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_xc',tread,'INT')
    2208         6959 :  if(tread==1) dtset%vdw_xc=intarr(1)
    2209              : 
    2210         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'posdoppler',tread,'INT')
    2211         6959 :  if(tread==1) dtset%posdoppler=intarr(1)
    2212              : 
    2213         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'positron',tread,'INT')
    2214         6959 :  if(tread==1) dtset%positron=intarr(1)
    2215              : 
    2216         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ixcpositron',tread,'INT')
    2217         6959 :  if(tread==1) dtset%ixcpositron=intarr(1)
    2218              : 
    2219         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'posnstep',tread,'INT')
    2220         6959 :  if(tread==1) dtset%posnstep=intarr(1)
    2221              : 
    2222         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'posocc',tread,'DPR')
    2223         6959 :  if(tread==1) dtset%posocc=dprarr(1)
    2224              : 
    2225         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'frzfermi',tread,'INT')
    2226         6959 :  if(tread==1) dtset%frzfermi=intarr(1)
    2227              : 
    2228         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nqpt',tread,'INT')
    2229         6959 :  if(tread==1) dtset%nqpt=intarr(1)
    2230              : 
    2231         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'efmas',tread,'INT')
    2232         6959 :  if(tread==1) dtset%efmas=intarr(1)
    2233              : 
    2234         6959 :  if(dtset%efmas>0) then
    2235           17 :    call intagm(dprarr,intarr,jdtset,marr,2*nkpt,string(1:lenstr),'efmas_bands',tread,'INT')
    2236           17 :    if(tread==1) then
    2237          123 :      dtset%efmas_bands(1:2,1:nkpt)=reshape(intarr(1:2*nkpt), [2,nkpt])
    2238              :    else
    2239            0 :      dtset%efmas_bands(1,:)=1
    2240            0 :      dtset%efmas_bands(2,:)=dtset%nband(:)
    2241              :    end if
    2242              :  end if
    2243              : 
    2244         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'efmas_deg',tread,'INT')
    2245         6959 :  if(tread==1) dtset%efmas_deg=intarr(1)
    2246              : 
    2247         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'efmas_deg_tol',tread,'ENE')
    2248         6959 :  if(tread==1) dtset%efmas_deg_tol=dprarr(1)
    2249              : 
    2250         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'efmas_dim',tread,'INT')
    2251         6959 :  if(tread==1) dtset%efmas_dim=intarr(1)
    2252              : 
    2253         6959 :  if(dtset%efmas_calc_dirs/=0 .and. dtset%efmas_n_dirs>0) then
    2254           14 :    ndim=2+MERGE(1,0,ABS(dtset%efmas_calc_dirs)<3)
    2255           14 :    call intagm(dprarr,intarr,jdtset,marr,ndim*dtset%efmas_n_dirs,string(1:lenstr),'efmas_dirs',tread,'DPR')
    2256           14 :    if(tread==1) then
    2257          276 :      dtset%efmas_dirs(1:ndim,1:dtset%efmas_n_dirs)=reshape(dprarr(1:ndim*dtset%efmas_n_dirs),(/ndim,dtset%efmas_n_dirs/))
    2258              :    end if
    2259              :  end if
    2260              : 
    2261         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'efmas_ntheta',tread,'INT')
    2262         6959 :  if(tread==1) dtset%efmas_ntheta=intarr(1)
    2263              : 
    2264         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ieig2rf',tread,'INT')
    2265         6959 :  if(tread==1) dtset%ieig2rf=intarr(1)
    2266              : 
    2267         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'smdelta',tread,'INT')
    2268         6959 :  if(tread==1) dtset%smdelta=intarr(1)
    2269              : 
    2270         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bdeigrf',tread,'INT')
    2271         6959 :  if(tread==1) dtset%bdeigrf=intarr(1)
    2272              : 
    2273         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'restartxf',tread,'INT')
    2274         6959 :  if(tread==1) dtset%restartxf=intarr(1)
    2275              : 
    2276         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'optcell',tread,'INT')
    2277         6959 :  if(tread==1) dtset%optcell=intarr(1)
    2278              : 
    2279         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdwfmq',tread,'INT')
    2280         6959 :  if(tread==1) dtset%irdwfmq=intarr(1)
    2281              : 
    2282         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdwfq',tread,'INT')
    2283         6959 :  if(tread==1) dtset%irdwfq=intarr(1)
    2284              : 
    2285         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ird1den',tread,'INT')
    2286         6959 :  if(tread==1) dtset%ird1den=intarr(1)
    2287              : 
    2288         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ird1wf',tread,'INT')
    2289         6959 :  if(tread==1) dtset%ird1wf=intarr(1)
    2290              : 
    2291         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdddk',tread,'INT')
    2292         6959 :  if(tread==1) dtset%irdddk=intarr(1)
    2293              : 
    2294         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irddelfd',tread,'INT')
    2295         6959 :  if(tread==1) dtset%irddelfd=intarr(1)
    2296              : 
    2297         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irddkdk',tread,'INT')
    2298         6959 :  if(tread==1) dtset%irddkdk=intarr(1)
    2299              : 
    2300         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irddkde',tread,'INT')
    2301         6959 :  if(tread==1) dtset%irddkde=intarr(1)
    2302              : 
    2303         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'kptopt',tread,'INT')
    2304         6959 :  if(tread==1) dtset%kptopt=intarr(1)
    2305              : 
    2306         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'chkexit',tread,'INT')
    2307         6959 :  if(tread==1) dtset%chkexit=intarr(1)
    2308              : 
    2309         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nbdblock',tread,'INT')
    2310         6959 :  if(tread==1) dtset%nbdblock=intarr(1)
    2311              : 
    2312         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nbdbuf',tread,'INT')
    2313         6959 :  if(tread==1)then
    2314         1216 :    dtset%nbdbuf=intarr(1)
    2315              :    ! A negative value is interpreted as percentage of nband, except -101. Anyhow, nbdbuf must be strictly bigger than -102
    2316         1216 :    ABI_CHECK(dtset%nbdbuf > -102, "nbdbuf should be > -102")
    2317         1216 :    if (dtset%nbdbuf < 0) then
    2318           20 :      if (dtset%nbdbuf/=-101) then
    2319           98 :        dtset%nbdbuf = max(nint(abs(dtset%nbdbuf) / 100.0_dp * maxval(dtset%nband)), 1)
    2320              :      else
    2321           15 :        ABI_CHECK(response==0,'nbdbuf=-101 is not implemented for DFPT')
    2322              :      end if
    2323              :    end if
    2324              :  else
    2325         5743 :    if(response/=1 .and. dtset%iscf<0) then
    2326          249 :      dtset%nbdbuf=2*dtset%nspinor
    2327              :      write(msg, "(5a)") &
    2328          249 :         "nbdbuf is not specified in input, using `nbdbuf = 2*nspinor` that may be too small!", ch10, &
    2329          249 :         "As a consequence, the NSCF cycle may have problems to converge the last bands within nstep iterations.", ch10, &
    2330          498 :         "To avoid this problem specify nbdbuf in the input file and adjust nband accordingly."
    2331          249 :      ABI_WARNING(msg)
    2332              :    end if
    2333         5743 :    if(response==1 .and. 3<=occopt .and. occopt<=8 )dtset%nbdbuf=2*dtset%nspinor
    2334              :  end if
    2335              : 
    2336         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'localrdwf',tread,'INT')
    2337         6959 :  if(tread==1) dtset%localrdwf=intarr(1)
    2338              : 
    2339         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'magconon',tread,'INT')
    2340         6959 :  if(tread==1) dtset%magconon=intarr(1)
    2341              : 
    2342         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'magcon_lambda',tread,'DPR')
    2343         6959 :  if(tread==1) dtset%magcon_lambda=dprarr(1)
    2344              : 
    2345         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ratopt',tread,'INT')
    2346         6959 :  if(tread==1) dtset%ratopt=intarr(1)
    2347              : 
    2348         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ratsm',tread,'DPR')
    2349         6959 :  if(tread==1) dtset%ratsm=dprarr(1)
    2350              : 
    2351         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'optforces',tread,'INT')
    2352         6959 :  if(tread==1) then
    2353          334 :    dtset%optforces=intarr(1)
    2354         6625 :  else if (xc_is_pot_only) then
    2355           12 :    dtset%optforces=0
    2356              :    write(msg, '(7a)' ) &
    2357           12 : &      'When the selected XC functional is a potential-only functional (Becke-Johnson or Tran-Blaha),',ch10,&
    2358           12 : &        'calculations cannot be self-consistent with respect to the total energy.',ch10,&
    2359           12 : &        'For that reason, neither forces nor stresses can be computed.',ch10,&
    2360           24 : &        'optforces and optstress are automatically set to 0.'
    2361           12 :    ABI_COMMENT(msg)
    2362              :  end if
    2363              : 
    2364         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'optstress',tread,'INT')
    2365         6959 :  if(tread==1) then
    2366          281 :    dtset%optstress=intarr(1)
    2367         6678 :  else if (xc_is_pot_only) then
    2368           12 :    dtset%optstress=0
    2369              :  end if
    2370              :  ! ABINIT cannot calculate stress when fock_icutcoul is not zero (not implemented)
    2371         6959 :  if (dtset%optstress==1.and.dtset%fock_icutcoul/=0) then
    2372              :    write(msg, '(3a)' ) &
    2373            1 :         'Stress can only be calculated (as of today) when fock_icutcoul=0',ch10,&
    2374            2 :         'If you really want the stress, change fock_icutcoul.'
    2375            1 :    if(tread==1) then
    2376            0 :      ABI_ERROR(msg)
    2377              :    else
    2378            1 :      ABI_COMMENT(msg)
    2379            1 :      dtset%optstress=0
    2380              :    endif
    2381              :  end if
    2382              : 
    2383         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'optnlxccc',tread,'INT')
    2384         6959 :  if(tread==1) dtset%optnlxccc=intarr(1)
    2385              : 
    2386         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nberry',tread,'INT')
    2387         6959 :  if(tread==1) dtset%nberry=intarr(1)
    2388              : 
    2389              :  !call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nb_protected',tread,'INT')
    2390              :  !if(tread==1) dtset%nb_protected=intarr(1)
    2391              : 
    2392              :  !call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nb_per_slice',tread,'INT')
    2393              :  !if(tread==1) dtset%nb_per_slice=intarr(1)
    2394              : 
    2395         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nc_xccc_gspace',tread,'INT')
    2396         6959 :  if(tread==1) dtset%nc_xccc_gspace=intarr(1)
    2397              : 
    2398         6959 :  call intagm(dprarr,intarr,jdtset,marr,2*nsppol,string(1:lenstr),'bdberry',tread,'INT')
    2399         6959 :  if(tread==1) then
    2400            0 :    dtset%bdberry(1)=intarr(1); dtset%bdberry(2)=intarr(2)
    2401            0 :    if(nsppol==2)then
    2402            0 :      dtset%bdberry(3)=intarr(3); dtset%bdberry(4)=intarr(4)
    2403              :    end if
    2404              :  end if
    2405              : 
    2406         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'berrystep',tread,'INT')
    2407         6959 :  if(tread==1) dtset%berrystep=intarr(1)
    2408              : 
    2409         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'delayperm',tread,'INT')
    2410         6959 :  if(tread==1) dtset%delayperm=intarr(1)
    2411              : 
    2412         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'signperm',tread,'INT')
    2413         6959 :  if(tread==1) dtset%signperm=intarr(1)
    2414              : 
    2415         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nbandkss',tread,'INT')
    2416         6959 :  if(tread==1) dtset%nbandkss=intarr(1)
    2417              : !This overloading of usepawu should be replaced by something cleaner ...
    2418              : ! if ( dtset%usedmft > 0  .and. (dtset%nbandkss==0.or.dtset%iscf<0)) then
    2419              : !   if (dtset%usepawu==4.or.dtset%usepawu==14)  dtset%usepawu=14
    2420              : !   if (dtset%usepawu/=4.and.dtset%usepawu/=14) dtset%usepawu=10
    2421              : ! end if
    2422              : 
    2423         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'npwkss',tread,'INT')
    2424         6959 :  if(tread==1) dtset%npwkss=intarr(1)
    2425              : 
    2426         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'kssform',tread,'INT')
    2427         6959 :  if(tread==1) dtset%kssform=intarr(1)
    2428              : 
    2429         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'td_mexcit',tread,'INT')
    2430         6959 :  if(tread==1) dtset%td_mexcit=intarr(1)
    2431              : 
    2432         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'td_exp_order',tread,'INT')
    2433         6959 :  if(tread==1) dtset%td_exp_order=intarr(1)
    2434              : 
    2435         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'td_scnmax',tread,'INT')
    2436         6959 :  if(tread==1) dtset%td_scnmax=intarr(1)
    2437              : 
    2438         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'td_prtstr',tread,'INT')
    2439         6959 :  if(tread==1) dtset%td_prtstr=intarr(1)
    2440              : 
    2441         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'td_restart',tread,'INT')
    2442         6959 :  if(tread==1) dtset%td_restart=intarr(1)
    2443              : 
    2444         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'td_propagator',tread,'INT')
    2445         6959 :  if(tread==1) dtset%td_propagator=intarr(1)
    2446              : 
    2447         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'td_scthr',tread,'DPR')
    2448         6959 :  if(tread==1) dtset%td_scthr=dprarr(1)
    2449              : 
    2450         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'td_ef_type',tread,'INT')
    2451         6959 :  if(tread==1) dtset%td_ef_type=intarr(1)
    2452              : 
    2453         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'td_ef_induced_vecpot',tread,'INT')
    2454         6959 :  if(tread==1) dtset%td_ef_induced_vecpot=intarr(1)
    2455              : 
    2456         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'td_ef_tzero',tread,'TIM')
    2457         6959 :  if(tread==1) dtset%td_ef_tzero=dprarr(1)
    2458              : 
    2459         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'td_ef_tau',tread,'TIM')
    2460         6959 :  if(tread==1) dtset%td_ef_tau=dprarr(1)
    2461              : 
    2462         6959 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'td_ef_pol',tread,'DPR')
    2463         6959 :  if(tread==1) dtset%td_ef_pol(1:3)=dprarr(1:3)
    2464              : 
    2465         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'td_ef_lambda',tread,'LEN')
    2466         6959 :  if(tread==1) dtset%td_ef_lambda=dprarr(1)
    2467              : 
    2468         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'td_ef_ezero',tread,'DPR')
    2469         6959 :  if(tread==1) dtset%td_ef_ezero=dprarr(1)
    2470              : 
    2471         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'npvel',tread,'INT')
    2472         6959 :  if(tread==1) dtset%npvel=intarr(1)
    2473              : 
    2474         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'npulayit',tread,'INT')
    2475         6959 :  if(tread==1) dtset%npulayit=intarr(1)
    2476              : 
    2477         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'diismemory',tread,'INT')
    2478         6959 :  if(tread==1) dtset%diismemory=intarr(1)
    2479              : 
    2480         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dipquad',tread,'INT')
    2481         6959 :  if(tread==1) dtset%dipquad=intarr(1)
    2482              : 
    2483         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'goprecon',tread,'INT')
    2484         6959 :  if(tread==1) dtset%goprecon=intarr(1)
    2485              : 
    2486         6959 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'goprecprm',tread,'DPR')
    2487         6980 :  if(tread==1) dtset%goprecprm(1:3)=dprarr(1:3)
    2488              : 
    2489         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'gstore_with_vk', tread, 'INT')
    2490         6959 :  if (tread == 1) dtset%gstore_with_vk = intarr(1)
    2491              : 
    2492         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'gstore_iv1p_comm', tread, 'INT')
    2493         6959 :  if (tread == 1) dtset%gstore_iv1p_comm = intarr(1)
    2494              : 
    2495         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'gstore_use_lgk', tread, 'INT')
    2496         6959 :  if (tread == 1) dtset%gstore_use_lgk = intarr(1)
    2497              : 
    2498         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'gstore_use_lgq', tread, 'INT')
    2499         6959 :  if (tread == 1) dtset%gstore_use_lgq = intarr(1)
    2500              : 
    2501         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'gstore_sym', tread, 'INT')
    2502         6959 :  if (tread == 1) dtset%gstore_sym = intarr(1)
    2503              : 
    2504         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'gstore_kzone', tread, 'KEY', key_value=key_value)
    2505         6959 :  if (tread == 1) dtset%gstore_kzone = tolower(key_value)
    2506              : 
    2507         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'gstore_qzone', tread, 'KEY', key_value=key_value)
    2508         6959 :  if (tread == 1) dtset%gstore_qzone = tolower(key_value)
    2509              : 
    2510         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'gstore_kfilter', tread_kfilter, 'KEY', key_value=key_value)
    2511         6959 :  if (tread_kfilter == 1) dtset%gstore_kfilter = tolower(key_value)
    2512              : 
    2513         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'gstore_gname', tread, 'KEY', key_value=key_value)
    2514         6959 :  if (tread == 1) dtset%gstore_gname = tolower(key_value)
    2515              : 
    2516         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'gstore_convert', tread, 'KEY', key_value=key_value)
    2517         6959 :  if (tread == 1) dtset%gstore_convert = tolower(key_value)
    2518              : 
    2519         6959 :  narr = 2 * nsppol
    2520         6959 :  call intagm(dprarr, intarr, jdtset, marr, narr, string(1:lenstr), 'gstore_brange', tread_brange, 'INT')
    2521         6959 :  if (tread_brange == 1) then
    2522           12 :    if (nsppol == 1) dtset%gstore_brange(:, 1) = intarr(1:narr)
    2523            4 :    if (nsppol == 2) dtset%gstore_brange = reshape(intarr(1:narr), [2, nsppol])
    2524              :  end if
    2525              : 
    2526         6959 :  narr = 2 * nsppol
    2527         6959 :  call intagm(dprarr, intarr, jdtset, marr, narr, string(1:lenstr), 'gstore_erange', tread_erange, 'ENE')
    2528         6959 :  if (tread_erange == 1) then
    2529            3 :    if (nsppol == 1) dtset%gstore_erange(:, 1) = dprarr(1:narr)
    2530            1 :    if (nsppol == 2) dtset%gstore_erange = reshape(dprarr(1:narr), [2, nsppol])
    2531              :  end if
    2532              : 
    2533         6959 :  if (tread_erange == 1 .and. tread_brange == 1) then
    2534            0 :    ABI_ERROR("gstore_erange and gstore_brange are mutually exclusive!")
    2535              :  end if
    2536         6959 :  if (tread_erange == 1 .and. tread_kfilter == 1) then
    2537            0 :    ABI_ERROR("gstore_erange and gstore_kfilter are mutually exclusive!")
    2538              :  end if
    2539              : 
    2540         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'vpq_aseed', tread, 'KEY', key_value=key_value)
    2541         6959 :  if (tread == 1) dtset%vpq_aseed = tolower(trim(key_value))
    2542              : 
    2543         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'vpq_mode', tread, 'KEY', key_value=key_value)
    2544         6959 :  if (tread == 1) dtset%vpq_mode = tolower(trim(key_value))
    2545              : 
    2546         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'vpq_pkind', tread, 'KEY', key_value=key_value)
    2547         6959 :  if (tread == 1) dtset%vpq_pkind = tolower(trim(key_value))
    2548              : 
    2549         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'vpq_atloc', tread, 'INT')
    2550         6959 :  if (tread == 1) dtset%vpq_atloc = intarr(1)
    2551              : 
    2552         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'vpq_avg_g', tread, 'INT')
    2553         6959 :  if (tread == 1) dtset%vpq_avg_g = intarr(1)
    2554              : 
    2555         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'vpq_translate', tread, 'INT')
    2556         6959 :  if (tread == 1) dtset%vpq_translate = intarr(1)
    2557              : 
    2558         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'vpq_interp', tread, 'INT')
    2559         6959 :  if (tread == 1) dtset%vpq_interp = intarr(1)
    2560              : 
    2561         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'vpq_nstates', tread, 'INT')
    2562         6959 :  if (tread == 1) dtset%vpq_nstates = intarr(1)
    2563              : 
    2564         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'vpq_hop_nstep', tread, 'INT')
    2565         6959 :  if (tread == 1) dtset%vpq_hop_nstep = intarr(1)
    2566              : 
    2567         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'vpq_hop_from_ip', tread, 'INT')
    2568         6959 :  if (tread == 1) dtset%vpq_hop_from_ip = intarr(1)
    2569              : 
    2570         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'vpq_hop_to_ip', tread, 'INT')
    2571         6959 :  if (tread == 1) dtset%vpq_hop_to_ip = intarr(1)
    2572              : 
    2573         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'vpq_nstep', tread, 'INT')
    2574         6959 :  if (tread == 1) dtset%vpq_nstep = intarr(1)
    2575              : 
    2576         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'vpq_nstep_ort', tread, 'INT')
    2577         6959 :  if (tread == 1) dtset%vpq_nstep_ort = intarr(1)
    2578              : 
    2579         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'vpq_select', tread, 'INT')
    2580         6959 :  if (tread == 1) dtset%vpq_select = intarr(1)
    2581              : 
    2582         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'vpq_mesh_fact', tread, 'INT')
    2583         6959 :  if (tread == 1) dtset%vpq_mesh_fact = intarr(1)
    2584              : 
    2585         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'vpq_hop_tolgrs', tread, 'DPR')
    2586         6959 :  if(tread==1) dtset%vpq_hop_tolgrs = dprarr(1)
    2587              : 
    2588         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'vpq_hop_ts', tread, 'DPR')
    2589         6959 :  if(tread==1) dtset%vpq_hop_ts = dprarr(1)
    2590              : 
    2591         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'vpq_mix_fact', tread, 'DPR')
    2592         6959 :  if(tread==1) dtset%vpq_mix_fact = dprarr(1)
    2593              : 
    2594         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'vpq_tolgrs', tread, 'DPR')
    2595         6959 :  if(tread==1) dtset%vpq_tolgrs = dprarr(1)
    2596              : 
    2597         6959 :  call intagm(dprarr, intarr, jdtset, marr, 3, string(1:lenstr), 'vpq_trvec', tread, 'INT')
    2598         6962 :  if (tread == 1) dtset%vpq_trvec = intarr(1:3)
    2599              : 
    2600         6959 :  call intagm(dprarr, intarr, jdtset, marr, 3, string(1:lenstr), 'vpq_hop_from_site', tread, 'INT')
    2601         6962 :  if (tread == 1) dtset%vpq_hop_from_site = intarr(1:3)
    2602              : 
    2603         6959 :  call intagm(dprarr, intarr, jdtset, marr, 3, string(1:lenstr), 'vpq_hop_to_site', tread, 'INT')
    2604         6962 :  if (tread == 1) dtset%vpq_hop_to_site = intarr(1:3)
    2605              : 
    2606         6959 :  call intagm(dprarr, intarr, jdtset, marr, 3, string(1:lenstr), 'vpq_hop_vec', tread, 'INT')
    2607         6962 :  if (tread == 1) dtset%vpq_hop_vec = intarr(1:3)
    2608              : 
    2609         6959 :  call intagm(dprarr, intarr, jdtset, marr, 2, string(1:lenstr), 'vpq_gpr_energy', tread, 'DPR')
    2610         6975 :  if (tread == 1) dtset%vpq_gpr_energy = dprarr(1:2)
    2611              : 
    2612         6959 :  call intagm(dprarr, intarr, jdtset, marr, 3, string(1:lenstr), 'vpq_gpr_length', tread, 'DPR')
    2613         6959 :  if (tread == 1) dtset%vpq_gpr_length = dprarr(1:3)
    2614              : 
    2615         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vpq_hop_from_filepath',tread,'KEY', key_value=key_value)
    2616         6959 :  if(tread==1) dtset%vpq_hop_from_filepath = key_value
    2617              : 
    2618         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vpq_hop_to_filepath',tread,'KEY', key_value=key_value)
    2619         6959 :  if(tread==1) dtset%vpq_hop_to_filepath = key_value
    2620              : 
    2621         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'vpq_efilter', tread, 'ENE')
    2622         6959 :  if(tread==1) dtset%vpq_efilter = dprarr(1)
    2623              : 
    2624         6959 :  call intagm(dprarr,intarr,jdtset,marr,ntypat,string(1:lenstr),'lambsig',tread,'DPR')
    2625         7000 :  if(tread==1) dtset%lambsig(1:ntypat)=dprarr(1:ntypat)
    2626              : 
    2627         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nwfshist',tread,'INT')
    2628         6959 :  if(tread==1) dtset%nwfshist=intarr(1)
    2629              : 
    2630         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'nscforder', tread, 'INT')
    2631         6959 :  if (tread == 1) dtset%nscforder = intarr(1)
    2632              : 
    2633         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nomegasrd',tread,'INT')
    2634         6959 :  if(tread==1) dtset%nomegasrd=intarr(1)
    2635              : 
    2636         6959 :  call intagm(dprarr,intarr,jdtset,marr,ntypat,string(1:lenstr),'corecs',tread,'DPR')
    2637         6959 :  if(tread==1)then
    2638            0 :    dtset%corecs(1:ntypat)=dprarr(1:ntypat)
    2639              :  end if
    2640              : 
    2641         6959 :  call intagm(dprarr,intarr,jdtset,marr,ntypat,string(1:lenstr),'ptcharge',tread,'DPR')
    2642         6959 :  if(tread==1)then
    2643            3 :    dtset%ptcharge(1:ntypat)=dprarr(1:ntypat)
    2644              :  end if
    2645              : 
    2646         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pulayhiststore',tread,'INT')
    2647         6959 :  if(tread==1) dtset%pulayhiststore=intarr(1)
    2648              : 
    2649         6959 :  call intagm(dprarr,intarr,jdtset,marr,ntypat,string(1:lenstr),'quadmom',tread,'DPR')
    2650         6959 :  if(tread==1)then
    2651           26 :    dtset%quadmom(1:ntypat)=dprarr(1:ntypat)
    2652              :  end if
    2653              : 
    2654         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'paw_add_core',tread,'INT')
    2655         6959 :  if(tread==1) dtset%paw_add_core=intarr(1)
    2656         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawcpxocc',tread,'INT')
    2657         6959 :  if(tread==1) then
    2658           40 :    dtset%pawcpxocc=intarr(1)
    2659         6919 :  else if(dtset%nspinor==2.and.(dtset%usepawu/=0.or.(dtset%usedmft>0.and.dtset%usedmft/=10))) then
    2660           28 :    dtset%pawcpxocc=2
    2661         6891 :  else if (dtset%pawspnorb>0.and.(dtset%kptopt<=0.or.dtset%kptopt>=3)) then
    2662           89 :    if (dtset%optdriver/=RUNL_GSTATE.or.dtset%ionmov<6.or.dtset%iscf<10) dtset%pawcpxocc=2
    2663       224690 :  else if (ANY(ABS(dtset%nucdipmom)>tol8)) then
    2664            2 :    dtset%pawcpxocc=2
    2665              :  end if
    2666              : 
    2667         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawcross',tread,'INT')
    2668         6959 :  if(tread==1) dtset%pawcross=intarr(1)
    2669              : 
    2670         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawecutdg',tread,'ENE')
    2671         6959 :  if(tread==1) then
    2672         1254 :    dtset%pawecutdg=dprarr(1)
    2673         5705 :  else if (dtset%accuracy==1.or.dtset%accuracy==2) then
    2674            0 :    dtset%pawecutdg=dtset%ecut
    2675         5705 :  else if (dtset%accuracy==3.) then
    2676            0 :    dtset%pawecutdg=1.2_dp*dtset%ecut
    2677         5705 :  else if (dtset%accuracy==4) then
    2678            0 :    dtset%pawecutdg=1.5_dp*dtset%ecut
    2679         5705 :  else if (dtset%accuracy==5.or.dtset%accuracy==6) then
    2680            2 :    dtset%pawecutdg=two*dtset%ecut
    2681              : ! NOT YET ACTIVATED
    2682              : ! else if (dtset%accuracy==0.and.usepaw==1.and.dtset%usewvl==0) then
    2683              : !  dtset%pawecutdg=1.5_dp*dtset%ecut
    2684              :  end if
    2685         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawlcutd',tread,'INT')
    2686         6959 :  if(tread==1) dtset%pawlcutd=intarr(1)
    2687              : 
    2688         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawlmix',tread,'INT')
    2689         6959 :  if(tread==1) dtset%pawlmix=intarr(1)
    2690              : 
    2691         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawmixdg',tread,'INT')
    2692         6959 :  if(tread==1) then
    2693           51 :    dtset%pawmixdg=intarr(1)
    2694         6908 :  else if (dtset%npfft>1.and.usepaw==1) then
    2695            0 :    dtset%pawmixdg=1
    2696         6908 :  else if (dtset%usewvl==1.and.usepaw==1) then
    2697            0 :    dtset%pawmixdg=1
    2698              :  end if
    2699              : 
    2700         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawnhatxc',tread,'INT')
    2701         6959 :  if(tread==1) dtset%pawnhatxc=intarr(1)
    2702              : 
    2703         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawntheta',tread,'INT')
    2704         6959 :  if(tread==1) dtset%pawntheta=intarr(1)
    2705              : 
    2706         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawnphi',tread,'INT')
    2707         6959 :  if(tread==1) dtset%pawnphi=intarr(1)
    2708              : 
    2709         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawnzlm',tread,'INT')
    2710         6959 :  if(tread==1) dtset%pawnzlm=intarr(1)
    2711              : 
    2712         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawoptmix',tread,'INT')
    2713         6959 :  if(tread==1) then
    2714           27 :    dtset%pawoptmix=intarr(1)
    2715              :  else
    2716         6932 :    if (usepaw==1.and.dtset%iscf<10.and.(dtset%positron==1.or.dtset%positron<0)) dtset%pawoptmix=1
    2717              :  end if
    2718              : 
    2719         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawoptosc',tread,'INT')
    2720         6959 :  if(tread==1) dtset%pawoptosc=intarr(1)
    2721              : 
    2722         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawovlp',tread,'DPR')
    2723         6959 :  if(tread==1) dtset%pawovlp=dprarr(1)
    2724              : 
    2725         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawprtdos',tread,'INT')
    2726         6959 :  if(tread==1) dtset%pawprtdos=intarr(1)
    2727              : 
    2728         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawprtvol',tread,'INT')
    2729         6959 :  if(tread==1) dtset%pawprtvol=intarr(1)
    2730              : 
    2731         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawprtwf',tread,'INT')
    2732         6959 :  if(tread==1) dtset%pawprtwf=intarr(1)
    2733              : 
    2734         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawprt_k',tread,'INT')
    2735         6959 :  if(tread==1) dtset%pawprt_k=intarr(1)
    2736              : 
    2737         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawprt_b',tread,'INT')
    2738         6959 :  if(tread==1) dtset%pawprt_b=intarr(1)
    2739              : 
    2740         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawstgylm',tread,'INT')
    2741         6959 :  if(tread==1) dtset%pawstgylm=intarr(1)
    2742              : 
    2743         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawsushat',tread,'INT')
    2744         6959 :  if(tread==1) dtset%pawsushat=intarr(1)
    2745              : 
    2746         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawusecp',tread,'INT')
    2747         6959 :  if(tread==1) dtset%pawusecp=intarr(1)
    2748              : 
    2749         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawxcdev',tread,'INT')
    2750         6959 :  if(tread==1) then
    2751           58 :    dtset%pawxcdev=intarr(1)
    2752         6901 :  else if (usepaw==1.and.xc_is_mgga) then
    2753           36 :    dtset%pawxcdev=0
    2754              :  end if
    2755              : 
    2756         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spnorbscl',tread,'DPR')
    2757         6959 :  if(tread==1) dtset%spnorbscl=dprarr(1)
    2758              : 
    2759         6959 :  if (dtset%usedmft>0.and.dtset%usedmft/=10) then
    2760           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_solv',tread,'INT')
    2761           43 :    if(tread==1) dtset%dmft_solv=intarr(1)
    2762           43 :    if (dtset%dmft_solv==6.or.dtset%dmft_solv==7) then ! change some default values for TRIQS
    2763            0 :      dtset%dmft_dc=0
    2764            0 :      dtset%dmft_iter=-1
    2765            0 :      if (dtset%dmft_solv==6) dtset%dmft_triqs_pauli_prob = 1.0_dp
    2766              :    end if
    2767           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_dc',tread,'INT')
    2768           43 :    if(tread==1) dtset%dmft_dc=intarr(1)
    2769              : ! XG20220322 - Should not impose dmft_dc on the flight. Should check in m_chkinp, and possibly stop.
    2770              : !  if (dtset%usepawu==14.and.dtset%dmft_dc/=5.and.dtset%dmft_dc/=6) then
    2771              : !    write(msg, '(a,a,a)' )&
    2772              : !     'usepawu == 4 and usedmft == 1, dmft_dc should be equal to 5 or 6 ',ch10,&
    2773              : !     'imposing dmft_dc = 5'
    2774              : !    ABI_WARNING(msg)
    2775              : !    dtset%dmft_dc=5
    2776              : !  end if
    2777           43 :    if (dtset%dmft_dc == 7) then
    2778            0 :      call intagm(dprarr,intarr,jdtset,marr,natom,string(1:lenstr),'dmft_nominal',tread,'INT')
    2779            0 :      if(tread==1) dtset%dmft_nominal(:)=intarr(1:natom)
    2780              :    end if
    2781           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_fermi_step',tread,'ENE')
    2782           43 :    if(tread==1) dtset%dmft_fermi_step=dprarr(1)
    2783           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_hybri_limit',tread,'INT')
    2784           43 :    if(tread==1) dtset%dmft_hybri_limit=intarr(1)
    2785           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_iter',tread,'INT')
    2786           43 :    if(tread==1) dtset%dmft_iter=intarr(1)
    2787           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_kspectralfunc',tread,'INT')
    2788           43 :    if(tread==1) dtset%dmft_kspectralfunc=intarr(1)
    2789           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_magnfield',tread,'INT')
    2790           43 :    if(tread==1) dtset%dmft_magnfield=intarr(1)
    2791           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_magnfield_b',tread,'DPR')
    2792           43 :    if(tread==1) dtset%dmft_magnfield_b=dprarr(1)
    2793           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_mxsf',tread,'DPR')
    2794           43 :    if(tread==1) dtset%dmft_mxsf=dprarr(1)
    2795           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_nwli',tread,'INT')
    2796           43 :    if(tread==1) dtset%dmft_nwli=intarr(1)
    2797           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_nwlo',tread,'INT')
    2798           43 :    if(tread==1) dtset%dmft_nwlo=intarr(1)
    2799           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_occnd_imag',tread,'INT')
    2800           43 :    if(tread==1) dtset%dmft_occnd_imag=intarr(1)
    2801           43 :    call intagm(dprarr,intarr,jdtset,marr,ntypat,string(1:lenstr),'dmft_orbital',tread,'INT')
    2802           43 :    if(tread==1) dtset%dmft_orbital(:)=intarr(1:ntypat)
    2803           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),"dmft_orbital_filepath",tread,'KEY',key_value=key_value)
    2804           43 :    if (tread==1) dtset%dmft_orbital_filepath=key_value
    2805           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_prt_maxent',tread,'INT')
    2806           43 :    if(tread==1) dtset%dmft_prt_maxent=intarr(1)
    2807           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_prtself',tread,'INT')
    2808           43 :    if(tread==1) dtset%dmft_prtself=intarr(1)
    2809           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_prtwan',tread,'INT')
    2810           43 :    if(tread==1) dtset%dmft_prtwan=intarr(1)
    2811           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_read_occnd',tread,'INT')
    2812           43 :    if(tread==1) dtset%dmft_read_occnd=intarr(1)
    2813           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_rslf',tread,'INT')
    2814           43 :    if(tread==1) dtset%dmft_rslf=intarr(1)
    2815           43 :    call intagm(dprarr,intarr,jdtset,marr,natom,string(1:lenstr),'dmft_shiftself',tread,'ENE')
    2816           43 :    if(tread==1) dtset%dmft_shiftself(:)=dprarr(1:natom)
    2817           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_t2g',tread,'INT')
    2818           43 :    if(tread==1) dtset%dmft_t2g=intarr(1)
    2819              : 
    2820           43 :    natomcor=0
    2821          139 :    do iatom=1,dtset%natom
    2822          139 :      if(dtset%lpawu(dtset%typat(iatom))>0) natomcor=natomcor+1
    2823              :    enddo
    2824           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_full_chipsi',tread,'INT')
    2825           43 :    if(tread==1) dtset%dmft_full_chipsi=intarr(1)
    2826              : 
    2827           43 :    if(natomcor>1.and.dtset%dmft_solv/=6.and.dtset%dmft_solv/=7) dtset%dmft_wanorthnorm=2
    2828           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_wanorthnorm',tread,'INT')
    2829           43 :    if(tread==1) dtset%dmft_wanorthnorm=intarr(1)
    2830           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_wanrad',tread,'LEN')
    2831           43 :    if(tread==1) dtset%dmft_wanrad=dprarr(1)
    2832           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_x2my2d',tread,'INT')
    2833           43 :    if(tread==1) dtset%dmft_x2my2d=intarr(1)
    2834           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_yukawa_epsilon',tread,'DPR')
    2835           43 :    if(tread==1) dtset%dmft_yukawa_epsilon=dprarr(1)
    2836           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_yukawa_lambda',tread,'DPR')
    2837           43 :    if(tread==1) dtset%dmft_yukawa_lambda=dprarr(1)
    2838           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_yukawa_param',tread,'INT')
    2839           43 :    if(tread==1) dtset%dmft_yukawa_param=intarr(1)
    2840           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_tolfreq',tread,'DPR')
    2841           43 :    if(tread==1) dtset%dmft_tolfreq=dprarr(1)
    2842           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_tollc',tread,'DPR')
    2843           43 :    if(tread==1) dtset%dmft_tollc=dprarr(1)
    2844           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_charge_prec',tread,'DPR')
    2845           43 :    if(tread==1) dtset%dmft_charge_prec=dprarr(1)
    2846           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftbandi',tread,'INT')
    2847           43 :    if(tread==1) dtset%dmftbandi=intarr(1)
    2848           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftbandf',tread,'INT')
    2849           43 :    if(tread==1) dtset%dmftbandf=intarr(1)
    2850              :    if(((dtset%dmftbandf-dtset%dmftbandi+1)<2*maxval(dtset%lpawu(:))+1.and.&
    2851          111 :     &  (dtset%dmft_t2g==0).and.(dtset%dmft_x2my2d==0)).or.&
    2852              :     &  ((dtset%dmftbandf-dtset%dmftbandi+1)<3.and.dtset%dmft_t2g==1)) then
    2853              :      write(msg, '(4a,i2,2a)' )&
    2854            0 :      '   dmftbandf-dmftbandi+1<2*max(lpawu(:))+1',ch10, &
    2855            0 :      '   Number of bands to construct Wannier functions is not', &
    2856            0 :      ' sufficient to build Wannier functions for l=',maxval(dtset%lpawu(:)),ch10, &
    2857            0 :      '   Action: select a correct number of KS bands with dmftbandi and dmftbandf.'
    2858            0 :      ABI_ERROR(msg)
    2859              :    end if
    2860              : 
    2861           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftcheck',tread,'INT')
    2862           43 :    if(tread==1) dtset%dmftcheck=intarr(1)
    2863           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_entropy',tread,'INT')
    2864           43 :    if(tread==1) dtset%dmft_entropy=intarr(1)
    2865           43 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_nlambda',tread,'INT')
    2866           43 :    if(tread==1) dtset%dmft_nlambda=intarr(1)
    2867              : 
    2868           43 :    if(dtset%dmft_solv>=5.and.dtset%dmft_solv/=6.and.dtset%dmft_solv/=7) then
    2869              : 
    2870           26 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftqmc_n',tread,'DPR')
    2871           26 :      if(tread==1) dtset%dmftqmc_n=dprarr(1)
    2872           26 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftqmc_l',tread,'INT')
    2873           26 :      if(tread==1) dtset%dmftqmc_l=intarr(1)
    2874           26 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftqmc_seed',tread,'INT')
    2875           26 :      if(tread==1) dtset%dmftqmc_seed=intarr(1)
    2876           26 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftqmc_therm',tread,'INT')
    2877           26 :      if(tread==1) dtset%dmftqmc_therm=intarr(1)
    2878           26 :      if(dtset%dmft_solv>=5.and.dtset%dmft_solv<=10) then
    2879           26 :        call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftctqmc_check',tread,'INT')
    2880           26 :        if(tread==1) dtset%dmftctqmc_check  =intarr(1)
    2881           26 :        call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftctqmc_correl',tread,'INT')
    2882           26 :        if(tread==1) dtset%dmftctqmc_correl =intarr(1)
    2883           26 :        call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftctqmc_gmove',tread,'INT')
    2884           26 :        if(tread==1) dtset%dmftctqmc_gmove  =intarr(1)
    2885           26 :        call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftctqmc_grnns',tread,'INT')
    2886           26 :        if(tread==1) dtset%dmftctqmc_grnns  =intarr(1)
    2887           26 :        call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftctqmc_localprop',tread,'INT')
    2888           26 :        if(tread==1) dtset%dmftctqmc_localprop  =intarr(1)
    2889           26 :        call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftctqmc_meas',tread,'INT')
    2890           26 :        if(tread==1) dtset%dmftctqmc_meas   =intarr(1)
    2891           26 :        call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftctqmc_mrka',tread,'INT')
    2892           26 :        if(tread==1) dtset%dmftctqmc_mrka   =intarr(1)
    2893           26 :        call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftctqmc_mov',tread,'INT')
    2894           26 :        if(tread==1) dtset%dmftctqmc_mov    =intarr(1)
    2895           26 :        call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftctqmc_chains',tread,'INT')
    2896           26 :        if(tread==1) dtset%dmftctqmc_chains=intarr(1)
    2897           26 :        call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftctqmc_order',tread,'INT')
    2898           26 :        if(tread==1) dtset%dmftctqmc_order  =intarr(1)
    2899           26 :        call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftctqmc_basis',tread,'INT')
    2900           26 :        if(tread==1) dtset%dmftctqmc_basis  =intarr(1)
    2901              :      end if
    2902           17 :    elseif(dtset%dmft_solv>=6.and.dtset%dmft_solv<=7) then
    2903            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_off_diag',tread,'INT')
    2904            0 :      if(tread==1) dtset%dmft_triqs_off_diag=intarr(1)
    2905            0 :      if (dtset%dmft_triqs_off_diag==1) then
    2906            0 :        dtset%dmft_triqs_measure_density_matrix = 0
    2907            0 :        dtset%dmft_triqs_time_invariance = 0
    2908            0 :        dtset%dmft_triqs_move_double = 1
    2909              :      end if
    2910              : 
    2911            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_basis',tread,'INT')
    2912            0 :      if(tread==1) dtset%dmft_triqs_basis=intarr(1)
    2913            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_chiloc',tread,'INT')           
    2914            0 :      if(tread==1) dtset%dmft_triqs_chiloc  =intarr(1)                                                    
    2915            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_chiloc_ins',tread,'INT')       
    2916            0 :      if(tread==1) dtset%dmft_triqs_chiloc_ins =intarr(1)    
    2917            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_compute_integral',tread,'INT')
    2918            0 :      if(tread==1) dtset%dmft_triqs_compute_integral=intarr(1)
    2919            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_det_init_size',tread,'INT')
    2920            0 :      if(tread==1) dtset%dmft_triqs_det_init_size=intarr(1)
    2921            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_det_n_operations_before_check',tread,'INT')
    2922            0 :      if(tread==1) dtset%dmft_triqs_det_n_operations_before_check=intarr(1)
    2923            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_det_precision_error',tread,'DPR')
    2924            0 :      if(tread==1) dtset%dmft_triqs_det_precision_error=dprarr(1)
    2925            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_det_precision_warning',tread,'DPR')
    2926            0 :      if(tread==1) dtset%dmft_triqs_det_precision_warning=dprarr(1)
    2927            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_det_singular_threshold',tread,'DPR')
    2928            0 :      if(tread==1) dtset%dmft_triqs_det_singular_threshold=dprarr(1)
    2929            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_dlr_epsilon',tread,'DPR')
    2930            0 :      if(tread==1) dtset%dmft_triqs_dlr_epsilon=dprarr(1)
    2931            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_dlr_wmax',tread,'ENE')
    2932            0 :      if(tread==1) dtset%dmft_triqs_dlr_wmax=dprarr(1)
    2933            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_entropy',tread,'INT')
    2934            0 :      if(tread==1) dtset%dmft_triqs_entropy=intarr(1)
    2935            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_gaussorder',tread,'INT')
    2936            0 :      if(tread==1) dtset%dmft_triqs_gaussorder=intarr(1)
    2937            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_imag_threshold',tread,'DPR')
    2938            0 :      if(tread==1) dtset%dmft_triqs_imag_threshold=dprarr(1)
    2939            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_length_cycle',tread,'INT')
    2940            0 :      if(tread==1) dtset%dmft_triqs_length_cycle=intarr(1)
    2941            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_loc_n_min',tread,'INT')
    2942            0 :      if(tread==1) dtset%dmft_triqs_loc_n_min=intarr(1)
    2943            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_loc_n_max',tread,'INT')
    2944            0 :      if(tread==1) dtset%dmft_triqs_loc_n_max=intarr(1)
    2945            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_measure_density_matrix',tread,'INT')
    2946            0 :      if(tread==1) dtset%dmft_triqs_measure_density_matrix=intarr(1)
    2947            0 :      if(dtset%dmft_triqs_measure_density_matrix==0) then
    2948            0 :        dtset%dmft_triqs_time_invariance=0
    2949            0 :        dtset%dmft_triqs_use_norm_as_weight=0
    2950              :      end if
    2951            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_measure_g_l',tread,'INT')
    2952            0 :      if(tread==1) dtset%dmft_triqs_measure_g_l=intarr(1)
    2953            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_move_double',tread,'INT')
    2954            0 :      if(tread==1) dtset%dmft_triqs_move_double=intarr(1)
    2955            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_move_shift',tread,'INT')
    2956            0 :      if(tread==1) dtset%dmft_triqs_move_shift=intarr(1)
    2957            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_n_cycles',tread,'INT')
    2958            0 :      if(tread==1) dtset%dmft_triqs_n_cycles=intarr(1)
    2959            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_n_iw',tread,'INT')
    2960            0 :      if(tread==1) dtset%dmft_triqs_n_iw=intarr(1)
    2961            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_n_l',tread,'INT')
    2962            0 :      if(tread==1) dtset%dmft_triqs_n_l=intarr(1)
    2963            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_n_tau',tread,'INT')
    2964            0 :      if(tread==1) dtset%dmft_triqs_n_tau=intarr(1)
    2965            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_n_warmup_cycles_init',tread,'INT')
    2966            0 :      if(tread==1) dtset%dmft_triqs_n_warmup_cycles_init=intarr(1)
    2967            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_n_warmup_cycles_restart',tread,'INT')
    2968            0 :      if(tread==1) dtset%dmft_triqs_n_warmup_cycles_restart=intarr(1)
    2969            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_nsubdivisions',tread,'INT')
    2970            0 :      if(tread==1) dtset%dmft_triqs_nsubdivisions=intarr(1)
    2971            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_pauli_prob',tread,'DPR')
    2972            0 :      if(tread==1) dtset%dmft_triqs_pauli_prob=dprarr(1)
    2973            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_prt_entropy',tread,'INT')
    2974            0 :      if(tread==1) dtset%dmft_triqs_prt_entropy=intarr(1)
    2975            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_random_seed_a',tread,'INT')
    2976            0 :      if(tread==1) dtset%dmft_triqs_random_seed_a=intarr(1)
    2977            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_random_seed_b',tread,'INT')
    2978            0 :      if(tread==1) dtset%dmft_triqs_random_seed_b=intarr(1)
    2979            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_read_ctqmcdata',tread,'INT')
    2980            0 :      if(tread==1) dtset%dmft_triqs_read_ctqmcdata=intarr(1)
    2981            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_shift_mu',tread,'ENE')
    2982            0 :      if(tread==1) dtset%dmft_triqs_shift_mu=dprarr(1)
    2983            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_time_invariance',tread,'INT')
    2984            0 :      if(tread==1) dtset%dmft_triqs_time_invariance=intarr(1)
    2985            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_tol_block',tread,'DPR')
    2986            0 :      if(tread==1) dtset%dmft_triqs_tol_block=dprarr(1)
    2987            0 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_triqs_use_norm_as_weight',tread,'INT')
    2988            0 :      if(tread==1) dtset%dmft_triqs_use_norm_as_weight=intarr(1)
    2989              :    end if
    2990         6916 :  elseif (dtset%usedmft==10) then
    2991            0 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftbandi',tread,'INT')
    2992            0 :    if(tread==1) dtset%dmftbandi=intarr(1)
    2993            0 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftbandf',tread,'INT')
    2994            0 :    if(tread==1) dtset%dmftbandf=intarr(1)
    2995              :  end if
    2996              : 
    2997         6959 :  if (dtset%usepawu/=0.or.(dtset%usedmft>0.and.dtset%usedmft/=10)) then
    2998          153 :    call intagm(dprarr,intarr,jdtset,marr,ntypat,string(1:lenstr),'f4of2_sla',tread,'ENE')
    2999          155 :    if(tread==1) dtset%f4of2_sla(1:ntypat)=dprarr(1:ntypat)
    3000          153 :    call intagm(dprarr,intarr,jdtset,marr,ntypat,string(1:lenstr),'f6of2_sla',tread,'ENE')
    3001          155 :    if(tread==1) dtset%f6of2_sla(1:ntypat)=dprarr(1:ntypat)
    3002              :  end if
    3003         6959 :  if (dtset%usepawu>0.or.(dtset%usedmft>0.and.dtset%usedmft/=10)) then
    3004          142 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmatpuopt',tread,'INT')
    3005          142 :    if(tread==1) dtset%dmatpuopt=intarr(1)
    3006          142 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmatudiag',tread,'INT')
    3007          142 :    if(tread==1) dtset%dmatudiag=intarr(1)
    3008              :  end if
    3009              : 
    3010         6959 :  if (dtset%macro_uj>0) then
    3011          160 :    dtset%pawujat=minval(pack((/ (ii,ii=1,dtset%natom) /) ,dtset%lpawu(dtset%typat(:))>0))
    3012           10 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawujat',tread,'INT')
    3013           10 :    if(tread==1) dtset%pawujat=intarr(1)
    3014              : 
    3015           10 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawujrad',tread,'LEN')
    3016           10 :    if(tread==1) dtset%pawujrad=dprarr(1)
    3017              : 
    3018           10 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawujv',tread,'ENE')
    3019           10 :    if(tread==1) dtset%pawujv=dprarr(1)
    3020              :  end if
    3021              : 
    3022         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawfatbnd',tread,'INT')
    3023         6959 :  if(tread==1) dtset%pawfatbnd=intarr(1)
    3024              : 
    3025         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bxctmindg',tread,'DPR')
    3026         6959 :  if(tread==1) then
    3027            1 :    dtset%bxctmindg=dprarr(1)
    3028         6958 :  else if(usepaw==1.and.dtset%accuracy==0)then
    3029         1171 :    dtset%bxctmindg=dtset%boxcutmin
    3030              :  end if
    3031              : 
    3032         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'usexcnhat',tread,'INT')
    3033         6959 :  if(tread==1) dtset%usexcnhat_orig=intarr(1)
    3034              : 
    3035              :  ! gemm_nonlop (must read it before useylm)
    3036         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'use_gemm_nonlop',tread,'INT')
    3037         6959 :  if(tread==1) dtset%use_gemm_nonlop=intarr(1)
    3038              : 
    3039         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'chebfi_oracle',tread,'INT')
    3040         6959 :  if(tread==1) dtset%chebfi_oracle=intarr(1)
    3041              : 
    3042         6959 :  if (dtset%chebfi_oracle==2) then
    3043           24 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'oracle_factor',tread,'DPR')
    3044           24 :    if(tread==1) dtset%oracle_factor = dprarr(1)
    3045              :  end if
    3046              : 
    3047         6959 :  if (dtset%chebfi_oracle>0.and.dtset%nbdbuf==-101) then
    3048           14 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'oracle_min_occ',tread,'DPR')
    3049           14 :    if(tread==1) dtset%oracle_min_occ = dprarr(1)
    3050              :  end if
    3051              : 
    3052         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'cprj_in_memory',tread,'INT')
    3053         6959 :  if(tread==1) then
    3054          319 :    dtset%cprj_in_memory=intarr(1)
    3055         6640 :  else if (dtset%wfoptalg==111.and.dtset%gpu_option==ABI_GPU_DISABLED) then
    3056            1 :     dtset%cprj_in_memory=1 ! cprj_in_memory set to 1 by default if chebfi2 and CPU
    3057              :  end if
    3058         6959 :  if (dtset%cprj_in_memory/=0.and.dtset%optdriver/=RUNL_GSTATE) then
    3059            0 :    dtset%cprj_in_memory=0
    3060              :    write(msg,'(a)') 'cprj_in_memory/=0 is implemented only for ground state (optdriver=0).&
    3061            0 :      & cprj_in_memory is set to 0 for this dataset.'
    3062            0 :    ABI_WARNING(msg)
    3063              :  end if
    3064              : 
    3065         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'cprj_update_lvl',tread,'INT')
    3066         6959 :  if(tread==1) dtset%cprj_update_lvl=intarr(1)
    3067              : 
    3068         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'xg_nonlop_option',tread,'INT')
    3069         6959 :  if(tread==1) dtset%xg_nonlop_option=intarr(1)
    3070              : 
    3071         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'useylm',tread,'INT')
    3072         6959 :  if(tread==1) dtset%useylm=intarr(1)
    3073              : 
    3074              :  ! Here we set useylm automatically to 1
    3075         6959 :  if (dtset%use_gemm_nonlop == 1) dtset%useylm = 1
    3076         6959 :  if (usepaw==1) dtset%useylm=1
    3077         6959 :  if (usepaw==1 .and. dtset%usewvl==1) dtset%useylm=0
    3078         6959 :  if (dtset%efmas==1 .or. dtset%rf2_dkdk/=0 .or. dtset%rf2_dkde/=0) dtset%useylm=1
    3079         6959 :  if (dtset%gpu_option /= ABI_GPU_DISABLED .and. dtset%optdriver /= RUNL_GWR) dtset%useylm=1
    3080         6959 :  if(dtset%tfkinfunc==2 .and. dtset%usewvl==0 ) then
    3081            6 :    dtset%useylm=1
    3082            6 :    dtset%userec=1
    3083              :  end if
    3084         6959 :  if (dtset%cprj_in_memory/=0) dtset%useylm=1
    3085              : 
    3086         6959 :  ionmov=dtset%ionmov ; densfor_pred=dtset%densfor_pred ; iscf=dtset%iscf ; nqpt=dtset%nqpt
    3087         6959 :  kptopt=dtset%kptopt; nberry=dtset%nberry ; berryopt=dtset%berryopt
    3088              : 
    3089              :  ! Dielectric real(dp) input variables
    3090              :  ! Reading of diemix/diemixmag must be inserted after iprcel
    3091         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'diecut',tread,'ENE')
    3092         6959 :  if(tread==1) dtset%diecut=dprarr(1)
    3093              :  ! Special treatment if iscf==-1
    3094         6959 :  if(iscf==-1) dtset%diecut=four*dtset%ecut
    3095         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dielng',tread,'LEN')
    3096         6959 :  if(tread==1) dtset%dielng=dprarr(1)
    3097         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'diemac',tread,'DPR')
    3098         6959 :  if(tread==1) dtset%diemac=dprarr(1)
    3099              : 
    3100         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'diemix',tread,'DPR')
    3101         6959 :  if(tread==1) then
    3102          916 :    dtset%diemix=dprarr(1)
    3103              :  else
    3104         6043 :    if (mod(dtset%iprcel,100)>19) dtset%diemix=one
    3105              :  end if
    3106              : 
    3107         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'diemixmag',tread,'DPR')
    3108         6959 :  if(tread==1) then
    3109           20 :    dtset%diemixmag=dprarr(1)
    3110              :  else
    3111         6939 :    if (dtset%iscf<10.or.dtset%nspden==1.or.dtset%iprcel==0.or.(dtset%iprcel>70.and.dtset%iprcel<80)) then
    3112         6937 :      dtset%diemixmag=dtset%diemix
    3113              :    else
    3114            2 :      dtset%diemixmag=-dtset%diemix
    3115              :    end if
    3116              :  end if
    3117              : 
    3118         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'diegap',tread,'ENE')
    3119         6959 :  if(tread==1) dtset%diegap=dprarr(1)
    3120              : 
    3121         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dielam',tread,'DPR')
    3122         6959 :  if(tread==1) dtset%dielam=dprarr(1)
    3123              : 
    3124         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'maxestep',tread,'DPR')
    3125         6959 :  if(tread==1) dtset%maxestep=dprarr(1)
    3126              : 
    3127         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'td_maxene',tread,'DPR')
    3128         6959 :  if(tread==1) dtset%td_maxene=dprarr(1)
    3129              : 
    3130         6959 :  if((iscf==5.or.iscf==6) .and. ionmov==4 .and. densfor_pred/=3 )then
    3131            1 :    densfor_pred=3
    3132            1 :    dtset%densfor_pred=densfor_pred
    3133              :    write(msg, '(3a)' )&
    3134            1 :    'When ionmov is [4, 5, 6], densfor_pred must be 3.',ch10,&
    3135            2 :    'Set densfor_pred to 3.'
    3136            1 :    ABI_COMMENT(msg)
    3137              :  end if
    3138              : 
    3139         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'mffmem',tread,'INT')
    3140         6959 :  if(tread==1) dtset%mffmem=intarr(1)
    3141              : 
    3142              :  ! Set default values of 0 for occupation numbers and k pt wts
    3143         6959 :  bantot = 0
    3144              :  ! nkpt and nband must be defined to execute following loop
    3145         6959 :  if ( tnband == 1 ) then
    3146       115327 :    do ikpt=1,nkpt*nsppol
    3147       982795 :      do ii=1,dtset%nband(ikpt)
    3148       867468 :        bantot=bantot+1
    3149      1850342 :        dtset%occ_orig(bantot,:)=zero
    3150              :      end do
    3151              :    end do
    3152              :  end if
    3153              : 
    3154         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nloc_alg',tread,'INT')
    3155         6959 :  if(tread==1) dtset%nloalg(1)=intarr(1)
    3156              : 
    3157         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nloc_mem',tread,'INT')
    3158         6959 :  if(tread==1) then
    3159            4 :    dtset%nloalg(2)=1 ; if(intarr(1)<0)dtset%nloalg(2)=-1
    3160            4 :    dtset%nloalg(3)=abs(intarr(1))-1
    3161              :  end if
    3162              : 
    3163              :  ! LOOP variables
    3164              : 
    3165         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'mdeg_filter',tread_alt,'INT')
    3166         6959 :  if(tread_alt==1) dtset%mdeg_filter=intarr(1)
    3167         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nline',tread,'INT')
    3168         6959 :  if (tread==1) dtset%nline=intarr(1)
    3169         6959 :  if (tread_alt/=1.and.tread==1) dtset%mdeg_filter = dtset%nline
    3170         6959 :  if (mod(dtset%wfoptalg,10) == 1) then
    3171              : !  For Chebyshev filtering algo, nline is the degree of the Chebyshev polynomial (but is obsolete)
    3172          199 :    if (tread_alt==1.and.tread/=1) dtset%nline = dtset%mdeg_filter
    3173              :  end if
    3174              : 
    3175         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nslice',tread,'INT')
    3176         6959 :  if(tread==1) dtset%nslice=intarr(1)
    3177              : 
    3178         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nblock_lobpcg',tread,'INT')
    3179         6959 :  if(tread==1) dtset%nblock_lobpcg=intarr(1)
    3180              : 
    3181         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nnsclo',tread,'INT')
    3182         6959 :  if(tread==1) dtset%nnsclo=intarr(1)
    3183              : 
    3184         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nnsclohf',tread,'INT')
    3185         6959 :  if(tread==1) dtset%nnsclohf=intarr(1)
    3186              : 
    3187         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nstep',tread,'INT')
    3188         6959 :  if(tread==1) dtset%nstep=intarr(1)
    3189              : 
    3190         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nstep_mixed',tread,'INT')
    3191         6959 :  if(tread==1) dtset%nstep_mixed=intarr(1)
    3192              : 
    3193         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ntime',tread,'INT')
    3194         6959 :  if(tread==1) dtset%ntime=intarr(1)
    3195              : 
    3196         6959 :  if (tread == 0) then
    3197              :    ! if ntime is not given but ionmov > 0 and imgmv is != 0, use a reasonable number of iterations!
    3198         6449 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ionmov',tread,'INT')
    3199         6449 :    if (tread == 1 .and. intarr(1) /= 0 .and. dtset%imgmov == 0) then
    3200            0 :      dtset%ntime = 1000
    3201            0 :      ABI_COMMENT("Found ionmov /= 0 without ntime in the input. ntime has been set automatically to 1000")
    3202              :    end if
    3203              :  end if
    3204              : 
    3205         6959 :  if (ionmov == 28) then
    3206              :    ! i-pi driver mode: check whether initial geometry from server agrees with input file")
    3207              :    !dtset%ntime = 10000
    3208            0 :    image = 1
    3209            0 :    call ipi_check_initial_consistency(natom, dtset%rprimd_orig(:,:,image), dtset%xred_orig(:,:,image), ierr)
    3210            0 :    ABI_CHECK(ierr == 0, "Initial structure sent by i-pi server does not match the one read from file! See messages above")
    3211              :  end if
    3212              : 
    3213         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nctime',tread,'INT')
    3214         6959 :  if(tread==1) dtset%nctime=intarr(1)
    3215              : 
    3216         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nucefg',tread,'INT')
    3217         6959 :  if(tread==1) dtset%nucefg=intarr(1)
    3218              : 
    3219         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nucfc',tread,'INT')
    3220         6959 :  if(tread==1) dtset%nucfc=intarr(1)
    3221              : 
    3222         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'orbmag',tread,'INT')
    3223         6959 :  if(tread==1) dtset%orbmag=intarr(1)
    3224              : 
    3225         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prt_lorbmag',tread,'INT')
    3226         6959 :  if(tread==1) dtset%prt_lorbmag=intarr(1)
    3227              : 
    3228         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ortalg',tread,'INT')
    3229         6959 :  if(tread==1) then
    3230           17 :    dtset%ortalg=intarr(1)
    3231         6942 :  else if (dtset%wfoptalg>=10 .and. dtset%ortalg>0) then
    3232          181 :    dtset%ortalg=-dtset%ortalg
    3233              :  end if
    3234              : 
    3235              :  ! Print variables
    3236         6959 :  call intagm(dprarr,intarr,jdtset,marr,natom,string(1:lenstr),'prtatlist',tread,'INT')
    3237         6959 :  if(tread==1) then
    3238          102 :    dtset%prtatlist=intarr(1:natom)
    3239            3 :    call sort_int(natom,dtset%prtatlist,intarr)
    3240              :  end if
    3241              : 
    3242         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtbbb',tread,'INT')
    3243         6959 :  if(tread==1) dtset%prtbbb=intarr(1)
    3244              : 
    3245         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtbltztrp',tread,'INT')
    3246         6959 :  if(tread==1) dtset%prtbltztrp=intarr(1)
    3247              : 
    3248         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtcif',tread,'INT')
    3249         6959 :  if(tread==1) dtset%prtcif=intarr(1)
    3250              : 
    3251         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtcurrent',tread,'INT')
    3252         6959 :  if(tread==1) dtset%prtcurrent=intarr(1)
    3253              : 
    3254         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtden',tread,'INT')
    3255         6959 :  if(tread==1) dtset%prtden=intarr(1)
    3256              : 
    3257         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtdipole',tread,'INT')
    3258         6959 :  if(tread==1) dtset%prtdipole=intarr(1)
    3259              : 
    3260         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtevk',tread,'INT')
    3261         6959 :  if(tread==1) dtset%prtevk=intarr(1)
    3262              : 
    3263         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtdos',tread,'INT')
    3264         6959 :  if(tread==1) dtset%prtdos=intarr(1)
    3265              : 
    3266         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtdosm',tread,'INT')
    3267         6959 :  if(tread==1) dtset%prtdosm=intarr(1)
    3268              : 
    3269         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtebands',tread,'INT')
    3270         6959 :  if(tread==1) dtset%prtebands=intarr(1)
    3271              : 
    3272         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtefmas',tread,'INT')
    3273         6959 :  if(tread==1) dtset%prtefmas=intarr(1)
    3274              : 
    3275         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prteig',tread,'INT')
    3276         6959 :  if(tread==1) dtset%prteig=intarr(1)
    3277              : 
    3278         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtelf',tread,'INT')
    3279         6959 :  if(tread==1) dtset%prtelf=intarr(1)
    3280              : 
    3281         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prteliash',tread,'INT')
    3282         6959 :  if(tread==1) dtset%prteliash=intarr(1)
    3283              : 
    3284         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtfull1wf',tread,'INT')
    3285         6959 :  if(tread==1) dtset%prtfull1wf=intarr(1)
    3286              : 
    3287         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtfsurf',tread,'INT')
    3288         6959 :  if(tread==1) dtset%prtfsurf=intarr(1)
    3289              : 
    3290         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtgsr',tread,'INT')
    3291         6959 :  if(tread==1) dtset%prtgsr=intarr(1)
    3292              : 
    3293         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtgden',tread,'INT')
    3294         6959 :  if(tread==1) dtset%prtgden=intarr(1)
    3295              : 
    3296         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtgeo',tread,'INT')
    3297         6959 :  if(tread==1) dtset%prtgeo=intarr(1)
    3298              : 
    3299         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtgkk',tread,'INT')
    3300         6959 :  if(tread==1) dtset%prtgkk=intarr(1)
    3301              : 
    3302              :  ! Read usekden and set prtkden to 1 by default.
    3303         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'usekden',tread,'INT')
    3304         6959 :  if(tread==1) then
    3305           44 :    dtset%usekden=intarr(1)
    3306              :  else
    3307        13798 :    dtset%usekden=merge(1,0,xc_need_kden)
    3308              :  end if
    3309         6959 :  if (dtset%usekden == 1 .and. dtset%nimage == 1) dtset%prtkden = 1
    3310              : 
    3311              : ! Some variables need usekden before being red
    3312         6959 : if (dtset%usekden==1) then
    3313           76 :    dtset%getkden=dtset%getden
    3314           76 :    dtset%irdkden=dtset%irdden
    3315           76 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getkden',tread,'INT')
    3316           76 :    if(tread==1) dtset%getkden=intarr(1)
    3317           76 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdkden',tread,'INT')
    3318           76 :    if(tread==1) dtset%irdkden=intarr(1)
    3319              :  end if
    3320              : 
    3321         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtkden',tread,'INT')
    3322         6959 :  if(tread==1) dtset%prtkden=intarr(1)
    3323              : 
    3324         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtlden',tread,'INT')
    3325         6959 :  if(tread==1) dtset%prtlden=intarr(1)
    3326              : 
    3327         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtnabla',tread,'INT')
    3328         6959 :  if(tread==1) dtset%prtnabla=intarr(1)
    3329              : 
    3330         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtnest',tread,'INT')
    3331         6959 :  if(tread==1) dtset%prtnest=intarr(1)
    3332              : 
    3333         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtocc',tread,'INT')
    3334         6959 :  if(tread==1) dtset%prtocc=intarr(1)
    3335              : 
    3336         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtphbands',tread,'INT')
    3337         6959 :  if(tread==1) dtset%prtphbands=intarr(1)
    3338              : 
    3339         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtphdos',tread,'INT')
    3340         6959 :  if(tread==1) dtset%prtphdos=intarr(1)
    3341              : 
    3342         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtphsurf',tread,'INT')
    3343         6959 :  if(tread==1) dtset%prtphsurf=intarr(1)
    3344              : 
    3345         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtposcar',tread,'INT')
    3346         6959 :  if(tread==1) dtset%prtposcar=intarr(1)
    3347              : 
    3348         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtprocar',tread,'INT')
    3349         6959 :  if(tread==1) dtset%prtprocar=intarr(1)
    3350              : 
    3351         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtpot',tread,'INT')
    3352         6959 :  if (dtset%optdriver == RUNL_RESPFN) dtset%prtpot = 1
    3353         6959 :  if(tread==1) dtset%prtpot=intarr(1)
    3354              : 
    3355         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtpsps',tread,'INT')
    3356         6959 :  if(tread==1) dtset%prtpsps=intarr(1)
    3357              : 
    3358         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtspcur',tread,'INT')
    3359         6959 :  if(tread==1) dtset%prtspcur=intarr(1)
    3360              : 
    3361         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtsuscep',tread,'INT')
    3362         6959 :  if(tread==1) dtset%prtsuscep=intarr(1)
    3363              : 
    3364         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtstm',tread,'INT')
    3365         6959 :  if(tread==1) dtset%prtstm=intarr(1)
    3366              : 
    3367         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prt1dm',tread,'INT')
    3368         6959 :  if(tread==1) dtset%prt1dm=intarr(1)
    3369              : 
    3370         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtvclmb',tread,'INT')
    3371         6959 :  if(tread==1) dtset%prtvclmb=intarr(1)
    3372              : 
    3373         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtvdw',tread,'INT')
    3374         6959 :  if(tread==1) dtset%prtvdw=intarr(1)
    3375              : 
    3376         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtvha',tread,'INT')
    3377         6959 :  if(tread==1) dtset%prtvha=intarr(1)
    3378              : 
    3379         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtvhxc',tread,'INT')
    3380         6959 :  if(tread==1) dtset%prtvhxc=intarr(1)
    3381              : 
    3382         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtkbff',tread,'INT')
    3383         6959 :  if(tread==1) dtset%prtkbff=intarr(1)
    3384              : 
    3385         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtvol',tread,'INT')
    3386         6959 :  if(tread==1) dtset%prtvol=intarr(1)
    3387              : 
    3388         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtvolimg',tread,'INT')
    3389         6959 :  if(tread==1) dtset%prtvolimg=intarr(1)
    3390              : 
    3391         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtvpsp',tread,'INT')
    3392         6959 :  if(tread==1) dtset%prtvpsp=intarr(1)
    3393              : 
    3394         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtvxc',tread,'INT')
    3395         6959 :  if(tread==1) dtset%prtvxc=intarr(1)
    3396              : 
    3397         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtwant',tread,'INT')
    3398         6959 :  if(tread==1) dtset%prtwant=intarr(1)
    3399              : 
    3400         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtwf',tread,'INT')
    3401         6959 :  if(tread==1) then
    3402         1102 :    dtset%prtwf=intarr(1)
    3403         5857 :  else if (dtset%tfkinfunc==2)then
    3404            6 :    dtset%prtwf=0
    3405              :  endif
    3406              : 
    3407         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtwf_full',tread,'INT')
    3408         6959 :  if (tread==1) dtset%prtwf_full=intarr(1)
    3409              : 
    3410         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtxml',tread,'INT')
    3411         6959 :  if(tread==1) dtset%prtxml=intarr(1)
    3412              : 
    3413         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ratsph_extra',tread,'DPR')
    3414         6959 :  if(tread==1) dtset%ratsph_extra=dprarr(1)
    3415              : 
    3416         6959 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'qprtrb',tread,'INT')
    3417         6983 :  if(tread==1) dtset%qprtrb(:)=intarr(1:3)
    3418              : 
    3419         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'strprecon',tread,'DPR')
    3420         6959 :  if(tread==1) dtset%strprecon=dprarr(1)
    3421              : 
    3422         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tim1rev',tread,'INT')
    3423         6959 :  if (tread==1) dtset%tim1rev=intarr(1)
    3424              : 
    3425         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'xc_denpos',tread,'DPR')
    3426         6959 :  if(tread==1) dtset%xc_denpos=dprarr(1)
    3427              : 
    3428         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'xc_taupos',tread,'DPR')
    3429         6959 :  if(tread==1) then
    3430            1 :    dtset%xc_taupos=dprarr(1)
    3431              :  else
    3432         6958 :    dtset%xc_taupos=dtset%xc_denpos
    3433              :  end if
    3434              : 
    3435         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'xc_tb09_c',tread,'DPR')
    3436         6959 :  if(tread==1) dtset%xc_tb09_c=dprarr(1)
    3437              : 
    3438         6959 :  call intagm(dprarr,intarr,jdtset,marr,3*dtset%natsph_extra,string(1:lenstr),'xredsph_extra',tread,'DPR')
    3439         7010 :  if(tread==1) dtset%xredsph_extra=reshape(dprarr(1:3*dtset%natsph_extra), (/3,dtset%natsph_extra/))
    3440              : 
    3441         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'wfinit',tread,'INT')
    3442         6959 :  if(tread==1) dtset%wfinit=intarr(1)
    3443              : 
    3444         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'wfmix',tread,'DPR')
    3445         6959 :  if(tread==1) dtset%wfmix=dprarr(1)
    3446              : 
    3447              :  ! WVL - Wavelets related values
    3448         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'wvl_hgrid',tread,'DPR')
    3449         6959 :  if(tread==1) dtset%wvl_hgrid=dprarr(1)
    3450              : 
    3451         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'wvl_crmult',tread,'DPR')
    3452         6959 :  if(tread==1) dtset%wvl_crmult=dprarr(1)
    3453              : 
    3454         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'wvl_frmult',tread,'DPR')
    3455         6959 :  if(tread==1) dtset%wvl_frmult=dprarr(1)
    3456              : 
    3457         6959 :  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'wvl_ngauss',tread,'INT')
    3458         6959 :  if(tread==1) dtset%wvl_ngauss(1:2)=intarr(1:2)
    3459              : 
    3460         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'wvl_nprccg',tread,'INT')
    3461         6959 :  if(tread==1) dtset%wvl_nprccg=intarr(1)
    3462              : 
    3463         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tl_nprccg',tread,'INT')
    3464         6959 :  if(tread==1) dtset%tl_nprccg=intarr(1)
    3465              : 
    3466         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tl_radius',tread,'DPR')
    3467         6959 :  if(tread==1) dtset%tl_radius=dprarr(1)
    3468              : 
    3469         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_fix_korq',tread,'KEY', key_value=key_value)
    3470         6959 :  if(tread==1) dtset%eph_fix_korq = key_value(1:1)
    3471              : 
    3472         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'cwfs_wouth',tread,'INT')
    3473         6959 :  if(tread==1) dtset%cwfs_wouth = intarr(1)
    3474              : 
    3475              :  ! RCPAW variables
    3476         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'use_rcpaw',tread,'INT')
    3477         6959 :  if(tread==1) dtset%use_rcpaw = intarr(1)
    3478              : 
    3479         6959 :  if(dtset%use_rcpaw==1) then
    3480            3 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rcpaw_frocc',tread,'INT')
    3481            3 :    if(tread==1) dtset%rcpaw_frocc = intarr(1)
    3482              : 
    3483            3 :    call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'rcpaw_updatepaw',tread,'INT')
    3484            3 :    if(tread==1) dtset%rcpaw_updatepaw(1:2) = intarr(1:2)
    3485              : 
    3486            3 :    dtset%rcpaw_updatetnc=dtset%nstep
    3487            3 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rcpaw_updatetnc',tread,'INT')
    3488            3 :    if(tread==1) dtset%rcpaw_updatetnc = intarr(1)
    3489              : 
    3490            3 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rcpaw_tolnc',tread,'DPR')
    3491            3 :    if(tread==1) dtset%rcpaw_tolnc = dprarr(1)
    3492              : 
    3493            3 :    call intagm(dprarr,intarr,jdtset,marr,ntypat,string(1:lenstr),'rcpaw_rctypat',tread,'INT')
    3494            3 :    if(tread==1) dtset%rcpaw_rctypat(1:ntypat) = intarr(1:ntypat)
    3495              : 
    3496            3 :    call intagm(dprarr,intarr,jdtset,marr,ntypat,string(1:lenstr),'rcpaw_sc',tread,'DPR')
    3497            3 :    if(tread==1) dtset%rcpaw_sc(1:ntypat) = dprarr(1:ntypat)
    3498              : 
    3499            3 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rcpaw_elin',tread,'INT')
    3500            3 :    if(tread==1) dtset%rcpaw_elin = intarr(1)
    3501              : 
    3502            3 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rcpaw_prtpaw',tread,'INT')
    3503            3 :    if(tread==1) dtset%rcpaw_prtpaw = intarr(1)
    3504              : 
    3505            3 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rcpaw_tpaw',tread,'INT')
    3506            3 :    if(tread==1) dtset%rcpaw_tpaw = intarr(1)
    3507              : 
    3508            3 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rcpaw_vhtnzc',tread,'INT')
    3509            3 :    if(tread==1) dtset%rcpaw_vhtnzc = intarr(1)
    3510              :  endif
    3511              : 
    3512              : ! Print variables
    3513         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'write_files',tread,'KEY', key_value=key_value)
    3514         6959 :  if(tread==1) dtset%write_files = key_value
    3515         6959 :  if(dtset%write_files=='default') then
    3516              :   !!!EMPTY ON PURPOSE
    3517           67 :  else if(dtset%write_files=='all') then
    3518            0 :    dtset%ncout      = 1 !Already the default but good to keep track
    3519            0 :    dtset%prtddb     = 1
    3520            0 :    dtset%prtden     = 1
    3521              :    !dtset%prtdos     = 1
    3522            0 :    dtset%prtebands  = 1 !DEFAULT in all set to xgr
    3523            0 :    dtset%prteig     = 1
    3524            0 :    dtset%prtelf     = 1 ! TO BE CHECKED FOR CONSISTENCY
    3525            0 :    dtset%prtevk     = 1
    3526              : #ifndef HAVE_NETCDF_MPI
    3527              :    if (dtset%paral_rf==1) dtset%prtevk = 0
    3528              : #endif
    3529              :    !dtset%prtfsurf   = 1  ! TO BE CHECKED FOR CONSISTENCY
    3530              :    !dtset%prtgden    = 1  ! TO BE CHECKED FOR CONSISTENCY
    3531            0 :    dtset%prtgeo     = 1
    3532            0 :    dtset%prtgkk     = 1
    3533            0 :    dtset%prtgsr     = 1
    3534            0 :    dtset%prthist    = 1
    3535            0 :    dtset%prtkbff    = 1
    3536              :    !dtset%prtkden    = 1  ! TO BE CHECKED FOR CONSISTENCY
    3537            0 :    dtset%prtlden    = 1  ! TO BE CHECKED FOR CONSISTENCY
    3538            0 :    dtset%prtpot     = 1
    3539              :    !dtset%prtpsps    = 1  ! TO BE CHECKED FOR CONSISTENCY
    3540              :    !dtset%prtstm     = 1  ! TO BE CHECKED FOR CONSISTENCY
    3541            0 :    dtset%prtsuscep  = 1  ! TO BE CHECKED FOR CONSISTENCY
    3542            0 :    dtset%prtvclmb   = 2  ! NC default
    3543            0 :    dtset%prtvha     = 1
    3544            0 :    dtset%prtvhxc    = 1
    3545              :    dtset%prtvhxc    = 1
    3546            0 :    dtset%prtvpsp    = 1  ! TO BE CHECKED FOR CONSISTENCY
    3547            0 :    dtset%prtvxc     = 1
    3548              :    !dtset%prtwant    = 1   ! TO BE CHECKED FOR CONSISTENCY
    3549            0 :    dtset%prtwf      = 1
    3550            0 :    dtset%prtxml     = 1
    3551           67 :  else if(dtset%write_files=='none') then
    3552           29 :    dtset%ncout      = 0
    3553           29 :    dtset%prtddb     = 0
    3554           29 :    dtset%prtden     = 0
    3555           29 :    dtset%prtdos     = 0
    3556           29 :    dtset%prtebands  = 0
    3557           29 :    dtset%prteig     = 0
    3558           29 :    dtset%prtelf     = 0
    3559           29 :    dtset%prtevk     = 0
    3560           29 :    dtset%prtfsurf   = 0
    3561           29 :    dtset%prtgden    = 0
    3562           29 :    dtset%prtgeo     = 0
    3563           29 :    dtset%prtgkk     = 0
    3564           29 :    dtset%prtgsr     = 0
    3565           29 :    dtset%prthist    = 0
    3566           29 :    dtset%prtkbff    = 0
    3567           29 :    dtset%prtkden    = 0
    3568           29 :    dtset%prtlden    = 0
    3569           29 :    dtset%prtpot     = 0
    3570           29 :    dtset%prtpsps    = 0
    3571           29 :    dtset%prtstm     = 0
    3572           29 :    dtset%prtsuscep  = 0
    3573           29 :    dtset%prtvclmb   = 0
    3574           29 :    dtset%prtvha     = 0
    3575           29 :    dtset%prtvhxc    = 0
    3576              :    dtset%prtvhxc    = 0
    3577           29 :    dtset%prtvpsp    = 0
    3578           29 :    dtset%prtvxc     = 0
    3579           29 :    dtset%prtwant    = 0
    3580           29 :    dtset%prtwf      = 0
    3581           29 :    dtset%prtxml     = 0
    3582              :  !!!PLEASE ADD IN ALPHABETICAL ORDER THE FUTURE OPTIONS BELOW!!!
    3583              :  else if (dtset%write_files.ne.'none' .or. dtset%write_files.ne.'all' .or. dtset%write_files.ne.'default' ) then
    3584           38 :    if (INDEX(dtset%write_files,'ddb') .gt. 0) then
    3585            1 :       dtset%prtddb = 1
    3586              :    else
    3587           37 :       dtset%prtddb = 0
    3588              :    end if
    3589           38 :    if (INDEX(dtset%write_files,'den_1') .gt. 0) then
    3590            1 :       dtset%prtden = 1
    3591           37 :    else if (INDEX(dtset%write_files,'den_2') .gt. 0) then
    3592            0 :       dtset%prtden = 2
    3593           37 :    else if (INDEX(dtset%write_files,'den_3') .gt. 0) then
    3594            0 :       dtset%prtden = 3
    3595           37 :    else if (INDEX(dtset%write_files,'den_4') .gt. 0) then
    3596            0 :       dtset%prtden = 4
    3597           37 :    else if (INDEX(dtset%write_files,'den_5') .gt. 0) then
    3598            0 :       dtset%prtden = 5
    3599           37 :    else if (INDEX(dtset%write_files,'den_6') .gt. 0) then
    3600            0 :       dtset%prtden = 6
    3601           37 :    else if (INDEX(dtset%write_files,'den_7') .gt. 0) then
    3602            0 :       dtset%prtden = 7
    3603              :    else
    3604           37 :       dtset%prtden = 0
    3605              :    end if
    3606           38 :    if ( (INDEX(dtset%write_files,'dos_1') .gt. 0) .AND. (dtset%occopt .ge. 3 .AND. dtset%occopt .le. 7 ) )then
    3607            1 :       dtset%prtdos = 1
    3608           37 :    else if ( (INDEX(dtset%write_files,'dos_1') .gt. 0) .AND. (dtset%iscf .eq. -3 ) )then
    3609            0 :       dtset%prtdos = 1
    3610           37 :    else if ( INDEX(dtset%write_files,'dos_2') .gt. 0 )then
    3611            1 :       dtset%prtdos = 2
    3612           36 :    else if ( INDEX(dtset%write_files,'dos_3') .gt. 0 )then
    3613            2 :       dtset%prtdos = 3
    3614           34 :    else if ( INDEX(dtset%write_files,'dos_4') .gt. 0 )then
    3615            1 :       dtset%prtdos = 4
    3616           33 :    else if ( (INDEX(dtset%write_files,'dos_5') .gt. 0 ) .AND. (dtset%nspinor .eq. 2 ) )then
    3617            0 :       dtset%prtdos = 5
    3618              :    else
    3619           33 :       dtset%prtdos = 0
    3620              :    end if
    3621           38 :    if ( (INDEX(dtset%write_files,'dosm_1') .gt. 0) .AND. (dtset%prtdos .eq. 3 ) )then
    3622            1 :       dtset%prtdosm = 1
    3623            1 :       dtset%prtdos  = 3
    3624              :    else
    3625           37 :       dtset%prtdosm = 0
    3626              :    end if
    3627           38 :    if (INDEX(dtset%write_files,'ebands_1') .gt. 0) then
    3628            1 :       dtset%prtebands = 1
    3629           37 :    else if (INDEX(dtset%write_files,'ebands_2') .gt. 0) then
    3630            1 :       dtset%prtebands = 2
    3631              :    else
    3632           36 :       dtset%prtebands = 0
    3633              :    end if
    3634           38 :    if (INDEX(dtset%write_files,'eig') .gt. 0) then
    3635            2 :       dtset%prteig = 1
    3636              :    else
    3637           36 :       dtset%prteig = 0
    3638              :    end if
    3639           38 :    if (INDEX(dtset%write_files,'elf') .gt. 0) then
    3640            1 :       dtset%prtelf = 1
    3641              :    else
    3642           37 :       dtset%prtelf = 0
    3643              :    end if
    3644           38 :    if (INDEX(dtset%write_files,'evk') .gt. 0) then
    3645            0 :       dtset%prtevk = 1
    3646              :    end if
    3647           38 :    if (INDEX(dtset%write_files,'fsurf') .gt. 0) then
    3648            0 :       dtset%prtfsurf = 1
    3649              :    else
    3650           38 :       dtset%prtfsurf = 0
    3651              :    end if
    3652           38 :    if (INDEX(dtset%write_files,'gden') .gt. 0) then
    3653            1 :       dtset%prtgden = 1
    3654              :    else
    3655           37 :       dtset%prtgden = 0
    3656              :    end if
    3657           38 :    if (INDEX(dtset%write_files,'geo_1') .gt. 0) then
    3658            0 :       dtset%prtgeo = 1
    3659           38 :    else if (INDEX(dtset%write_files,'geo_2') .gt. 0) then
    3660            0 :       dtset%prtgeo = 2
    3661           38 :    else if (INDEX(dtset%write_files,'geo_3') .gt. 0) then
    3662            0 :       dtset%prtgeo = 3
    3663           38 :    else if (INDEX(dtset%write_files,'geo') .gt. 0) then
    3664            1 :       dtset%prtgeo = 1
    3665              :    else
    3666           37 :       dtset%prtgeo = 0
    3667              :    end if
    3668           38 :    if (INDEX(dtset%write_files,'gkk') .gt. 0) then
    3669            0 :       dtset%prtgkk = 1
    3670              :    else
    3671           38 :       dtset%prtgkk = 0
    3672              :    end if
    3673           38 :    if (INDEX(dtset%write_files,'gsr') .gt. 0) then
    3674            7 :       dtset%prtgsr = 1
    3675              :    else
    3676           31 :       dtset%prtgsr = 0
    3677              :    end if
    3678           38 :    if (INDEX(dtset%write_files,'hist') .gt. 0) then
    3679            0 :       dtset%prthist = 1
    3680              :    else
    3681           38 :       dtset%prthist = 0
    3682              :    end if
    3683           38 :    if ( (INDEX(dtset%write_files,'kbff') .gt. 0) .AND. (dtset%iomode .eq. 3) )then
    3684            0 :       dtset%prtkbff = 1
    3685              :    else
    3686           38 :       dtset%prtkbff = 0
    3687              :    end if
    3688           38 :    if (INDEX(dtset%write_files,'kden') .gt. 0) then
    3689            0 :       dtset%prtkden = 1
    3690              :    else
    3691           38 :       dtset%prtkden = 0
    3692              :    end if
    3693           38 :    if (INDEX(dtset%write_files,'lden') .gt. 0) then
    3694            0 :       dtset%prtlden = 1
    3695              :    else
    3696           38 :       dtset%prtlden = 0
    3697              :    end if
    3698           38 :    if (INDEX(dtset%write_files,'ncout') .gt. 0) then
    3699            0 :       dtset%ncout = 1
    3700              :    else
    3701           38 :       dtset%ncout = 0
    3702              :    end if
    3703           38 :    if (INDEX(dtset%write_files,'pot') .gt. 0) then
    3704            1 :       dtset%prtpot = 1
    3705              :    else
    3706           37 :       dtset%prtpot = 0
    3707              :    end if
    3708           38 :    if (INDEX(dtset%write_files,'psps_1') .gt. 0) then
    3709            0 :       dtset%prtpsps = 1
    3710           38 :    else if (INDEX(dtset%write_files,'psps_-1') .gt. 0) then
    3711            0 :       dtset%prtpsps = -1
    3712              :    else
    3713           38 :       dtset%prtpsps = 0
    3714              :    end if
    3715           38 :    if (INDEX(dtset%write_files,'stm') .gt. 0) then
    3716            0 :       dtset%prtstm = 1
    3717              :    else
    3718           38 :       dtset%prtstm = 0
    3719              :    end if
    3720           38 :    if (INDEX(dtset%write_files,'suscep') .gt. 0) then
    3721            0 :       dtset%prtsuscep = 1
    3722              :    else
    3723           38 :       dtset%prtsuscep = 0
    3724              :    end if
    3725           38 :    if (INDEX(dtset%write_files,'vclmb_1') .gt. 0) then
    3726            1 :       dtset%prtvclmb = 1
    3727           37 :    else if (INDEX(dtset%write_files,'vclmb_2') .gt. 0) then
    3728            1 :       dtset%prtvclmb = 2
    3729              :    else
    3730           36 :       dtset%prtvha = 0
    3731              :    end if
    3732           38 :    if (INDEX(dtset%write_files,'vha') .gt. 0) then
    3733            3 :       dtset%prtvha = 1
    3734              :    else
    3735           35 :       dtset%prtvha = 0
    3736              :    end if
    3737           38 :    if (INDEX(dtset%write_files,'vhxc') .gt. 0) then
    3738            1 :       dtset%prtvhxc = 1
    3739              :    else
    3740           37 :       dtset%prtvhxc = 0
    3741              :    end if
    3742           38 :    if (INDEX(dtset%write_files,'vpsp') .gt. 0) then
    3743            0 :       dtset%prtvpsp = 1
    3744              :    else
    3745           38 :       dtset%prtvpsp = 0
    3746              :    end if
    3747           38 :    if (INDEX(dtset%write_files,'vxc') .gt. 0) then
    3748            1 :       dtset%prtvxc = 1
    3749              :    else
    3750           37 :       dtset%prtvxc = 0
    3751              :    end if
    3752           38 :    if (INDEX(dtset%write_files,'want_1') .gt. 0) then
    3753            0 :       dtset%prtwant = 1
    3754           38 :    else if (INDEX(dtset%write_files,'want_2') .gt. 0) then
    3755            0 :       dtset%prtwant = 2
    3756           38 :    else if (INDEX(dtset%write_files,'want_3') .gt. 0) then
    3757            0 :       dtset%prtwant = 3
    3758              :    else
    3759           38 :       dtset%prtwant = 0
    3760              :    end if
    3761           38 :    if (INDEX(dtset%write_files,'wf_1') .gt. 0) then
    3762            6 :       dtset%prtwf = 1
    3763            6 :       if (INDEX(dtset%write_files,'wf_full_1') .gt. 0) then
    3764            0 :          dtset%prtwf_full = 1
    3765              :       end if
    3766           32 :    else if (INDEX(dtset%write_files,'wf_2') .gt. 0) then
    3767            0 :       dtset%prtwf = 2
    3768           32 :    else if (INDEX(dtset%write_files,'wf_3') .gt. 0) then
    3769            0 :       dtset%prtwf = 3
    3770           32 :    else if (INDEX(dtset%write_files,'wf_-1') .gt. 0) then
    3771            0 :       dtset%prtwf = -1
    3772              :    else
    3773           32 :       dtset%prtwf = 0
    3774              :    end if
    3775           38 :    if (INDEX(dtset%write_files,'xml') .gt. 0) then
    3776            0 :       dtset%prtxml = 1
    3777              :    else
    3778           38 :       dtset%prtxml = 0
    3779              :    end if
    3780              :  end if
    3781              : 
    3782              :  ! Wannier90 interface related variables
    3783         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'w90iniprj',tread,'INT')
    3784         6959 :  if(tread==1) then
    3785           15 :    dtset%w90iniprj=intarr(1)
    3786              : !  These checks should be moved to m_chkinp.F90
    3787           15 :    if ( usepaw == 0 .and. ( dtset%w90iniprj /= 2  .and. dtset%w90iniprj/=0 .and. dtset%w90iniprj /= 1 )) then
    3788              :      write(msg, '(a,i0,2a)' )&
    3789            0 :       'w90iniprj should be set to 0, 1 or 2, however, it was ',dtset%w90iniprj,ch10,&
    3790            0 :       'Action: check the values of w90iniprj.'
    3791            0 :      ABI_ERROR(msg)
    3792              :    end if
    3793              : !  These checks should be moved to m_chkinp.F90
    3794              :    if ( usepaw == 1 .and. ( dtset%w90iniprj < 2 .or. dtset%w90iniprj>6 ) &
    3795           15 :       .and. ( dtset%w90iniprj /= 1 .and. dtset%w90iniprj/=0 )) then
    3796              :      write(msg, '(a,i0,2a)' )&
    3797            0 :       'In the PAW case, the only valid values for w90iniprj are 0, 1, 2, 5 and 6 however, it was ',dtset%w90iniprj,ch10,&
    3798            0 :       'Action: check the values of w90iniprj.'
    3799            0 :      ABI_ERROR(msg)
    3800              :    end if
    3801              :  end if
    3802              : 
    3803              :  ! w90prtunk
    3804         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'w90prtunk',tread,'INT')
    3805         6959 :  if(tread==1) then
    3806           10 :    dtset%w90prtunk=intarr(1)
    3807              : !  if ( dtset%w90prtunk < 0 ) then
    3808              : !    write(msg, '(4a)' )&
    3809              : !     'w90prtunk should be greater or equal to zero, however, it was ',dtset%w90prtunk,ch10,&
    3810              : !     'Action: check the values of w90prtunk.'
    3811              : !    ABI_ERROR(msg)
    3812              : !  end if
    3813              :  end if
    3814              : 
    3815              :  ! Wannier90 - GW quasiparticle interface
    3816         6959 :  if(dtset%prtwant==3) then
    3817            1 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getqps',tread,'INT')
    3818            1 :    if(tread==1) dtset%getqps=intarr(1)
    3819            1 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdqps',tread,'INT')
    3820            1 :    if(tread==1) dtset%irdqps=intarr(1)
    3821              :  end if
    3822              : 
    3823              :   !van der Waals with DFT-D approach
    3824         6959 :  if(dtset%vdw_xc==5.or.dtset%vdw_xc==6.or.dtset%vdw_xc==7) then
    3825            8 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_tol',tread,'DPR')
    3826            8 :    if(tread==1) dtset%vdw_tol=dprarr(1)
    3827            8 :    if (dtset%vdw_xc==6.or.dtset%vdw_xc==7) then
    3828            7 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_tol_3bt',tread,'DPR')
    3829            7 :      if(tread==1) dtset%vdw_tol_3bt=dprarr(1)
    3830              :    end if
    3831              :  end if
    3832              : 
    3833              :  ! van der Waals with Wannier functions (Silvestrelli's approach versions 1,2 and 3)
    3834         6959 :  if(dtset%vdw_xc==10.or.dtset%vdw_xc==11.or.dtset%vdw_xc==12.or.dtset%vdw_xc==14) then
    3835            4 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_nfrag',tread,'INT')
    3836            4 :    if(tread==1) dtset%vdw_nfrag=intarr(1)
    3837              : 
    3838            4 :    call intagm(dprarr,intarr,jdtset,marr,dtset%natom,string(1:lenstr),'vdw_typfrag',tread,'INT')
    3839            4 :    if(tread==1)then
    3840            8 :      dtset%vdw_typfrag(1:dtset%natom)=intarr(1:dtset%natom)
    3841              : !    These checks should be moved to m_chkinp.F90
    3842            8 :      do ii=1,dtset%natom
    3843            8 :        if(dtset%vdw_typfrag(ii)<0)then
    3844              :          write(msg, '(a,a,a,i0,a,i0,a,a)' )&
    3845            0 :           'All the components of vdw_typfrag must be greater than 0.',ch10,&
    3846            0 :           'The component',ii,' is equal to ',dtset%vdw_typfrag(ii),ch10,&
    3847            0 :           'Action: check the values of vdw_typfrag.'
    3848            0 :          ABI_ERROR(msg)
    3849              :        end if
    3850              :      end do
    3851              :    end if
    3852              :  end if
    3853         6959 :  if(dtset%vdw_xc==10.or.dtset%vdw_xc==11.or.dtset%vdw_xc==12.or.dtset%vdw_xc==14) then
    3854            4 :    call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'vdw_supercell',tread,'INT')
    3855            4 :    if(tread==1)then
    3856           12 :      dtset%vdw_supercell(1:3)=intarr(1:3)
    3857              : !    These checks should be moved to m_chkinp.F90
    3858            3 :      if (dtset%vdw_supercell(1)<zero.and.dtset%vdw_supercell(2)<zero) then
    3859              :        write(msg, '(7a)' )&
    3860            0 :         ' only one component of vdw_supercell could be < 0, however, it was ',ch10,&
    3861            0 :         dtset%vdw_supercell(1),dtset%vdw_supercell(2),dtset%vdw_supercell(3),ch10,&
    3862            0 :         'Action: check the components of vdw_supercell.'
    3863            0 :        ABI_ERROR(msg)
    3864              :      end if
    3865            3 :      if (dtset%vdw_supercell(2)<zero.and.dtset%vdw_supercell(3)<zero) then
    3866              :        write(msg, '(7a)' )&
    3867            0 :         'only one component of vdw_supercell could be < 0, however, it was ',ch10,&
    3868            0 :         dtset%vdw_supercell(1),dtset%vdw_supercell(2),dtset%vdw_supercell(3),ch10,&
    3869            0 :         'Action: check the components of vdw_supercell.'
    3870            0 :        ABI_ERROR(msg)
    3871              :      end if
    3872            3 :      if (dtset%vdw_supercell(1)<zero.and.dtset%vdw_supercell(3)<zero) then
    3873              :        write(msg, '(7a)' )&
    3874            0 :         'only one component of vdw_supercell could be < 0, however, it was ',ch10,&
    3875            0 :         dtset%vdw_supercell(1),dtset%vdw_supercell(2),dtset%vdw_supercell(3),ch10,&
    3876            0 :         'Action: check the components of vdw_supercell.'
    3877            0 :        ABI_ERROR(msg)
    3878              :      end if
    3879              :    end if
    3880              : 
    3881              :  end if !vdw_xc==10 or vdw_xc==11 or vdw_xc==12 or vdw_xc==14
    3882              : 
    3883         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ucrpa',tread,'INT')
    3884         6959 :  if(tread==1) dtset%ucrpa=intarr(1)
    3885              : 
    3886         6959 :  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'ucrpa_bands',tread_key,'INT')
    3887         6959 :  if(tread_key==1) then
    3888            0 :    if(dtset%nsym/=1) then
    3889              :      write(msg,"(a,i0,3a)")&
    3890            0 :       'Value of nsym different from 1 when ucrpa_bands is used is under test ',dtset%nsym,&
    3891            0 :       ' (because symmetry is not yet used)',ch10,&
    3892            0 :       'Action: check your calculation  with nsym=1'
    3893            0 :      ABI_WARNING(msg)
    3894              :    end if
    3895            0 :    dtset%ucrpa_bands(1:2)=intarr(1:2)
    3896              :  end if
    3897              : 
    3898         6959 :  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'ucrpa_window',tread,'ENE')
    3899         6959 :  if(tread==1) then
    3900            0 :    if(dtset%nsym/=1) then
    3901              :      write(msg,*)&
    3902            0 :       'Value of nsym different from 1 when ucrpa_windows is used is under test ',dtset%nsym,&
    3903            0 :       ' (because symmetry is not yet used)',ch10,&
    3904            0 :       'Action: check your calculation  with nsym=1'
    3905            0 :      ABI_WARNING(msg)
    3906              :    end if
    3907            0 :    dtset%ucrpa_window(1:2)=dprarr(1:2)
    3908              :  end if
    3909              : 
    3910         6959 :  if(tread==1.and.tread_key==1) then
    3911              :    write(msg, '(a,a,a,a,a)' )&
    3912            0 :     'ucrpa_bands and ucrpa_window cannot be specified simultaneously',ch10,&
    3913            0 :     'for the same dataset.',ch10,&
    3914            0 :     'Action: check the input file.'
    3915            0 :    ABI_ERROR(msg)
    3916              :  end if
    3917              : 
    3918              :  ! Tolerance variables
    3919         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tolimg',tread,'ENE')
    3920         6959 :  if(tread==1) dtset%tolimg=dprarr(1)
    3921              : 
    3922              :  ! find which tolerance is used for the ionic relaxations
    3923         6959 :  tolmxde_=dtset%tolmxde
    3924         6959 :  tolmxf_=dtset%tolmxf
    3925         6959 :  itol=0
    3926         6959 :  itol_gen=0
    3927              : 
    3928         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tolmxde',tread,'ENE',ds_input)
    3929         6959 :  if(tread==1) then
    3930            1 :    if (ds_input == 0) then
    3931            1 :      tolmxde_=dprarr(1)
    3932            1 :      if(abs(dprarr(1))>tiny(0._dp))itol_gen=itol_gen+1
    3933              :    else
    3934            0 :      dtset%tolmxde=dprarr(1)
    3935            0 :      if(abs(dprarr(1))>tiny(0._dp))itol=itol+1
    3936              :    end if
    3937              :  end if
    3938              : 
    3939         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tolmxf',tread,'DPR',ds_input)
    3940         6959 :  if(tread==1) then
    3941          280 :    if (ds_input == 0) then
    3942          178 :      tolmxf_=dprarr(1)
    3943          178 :      if(abs(dprarr(1))>tiny(0._dp))itol_gen=itol_gen+1
    3944              :    else
    3945          102 :      dtset%tolmxf=dprarr(1)
    3946          102 :      if(abs(dprarr(1))>tiny(0._dp))itol=itol+1
    3947              :    end if
    3948              :  else
    3949         6679 :    itol_gen=itol_gen+1
    3950              :  end if
    3951              : 
    3952              :  ! check for definitions of tolmxf and tolmxde for the present dataset
    3953         6959 :  if (itol > 1 .or. itol_gen > 1) then
    3954              :    write(msg, '(5a)' )&
    3955            0 :     'Only one of the tolmxf/tolmxde variables may be defined at once.',ch10,&
    3956            0 :     'Action: check values of tolmxf, tolmxde. If you want to use ',ch10,&
    3957            0 :     'tolmxde, you should explicitly put tolmxf to 0.0.'
    3958            0 :    ABI_ERROR(msg)
    3959              :  end if
    3960              : 
    3961              :  ! if no value is given for jdtset, use defaults
    3962         6959 :  if (itol == 0 .and. itol_gen == 1) then
    3963         6857 :    dtset%tolmxde=tolmxde_
    3964         6857 :    dtset%tolmxf=tolmxf_
    3965              :  end if
    3966              : 
    3967         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tolcum',tread,'DPR',ds_input)
    3968         6959 :  if(tread==1) dtset%tolcum=dprarr(1)
    3969              : 
    3970         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'focktoldfe',tread,'DPR')
    3971         6959 :  if(tread==1) dtset%focktoldfe=dprarr(1)
    3972              : 
    3973         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tolrde',tread,'DPR')
    3974         6959 :  if(tread==1) dtset%tolrde=dprarr(1)
    3975              : 
    3976              :  ! find which tolXXX are defined generically and for this jdtset
    3977         6959 :  tolwfr_=zero
    3978         6959 :  toldfe_=zero
    3979         6959 :  toldff_=zero
    3980         6959 :  toldmag_=zero
    3981         6959 :  tolrff_=zero
    3982         6959 :  tolvrs_=zero
    3983         6959 :  itol=0
    3984         6959 :  itol_gen=0
    3985         6959 :  itol_wfr=0
    3986         6959 :  itol_gen_wfr=0
    3987         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tolwfr',tread,'DPR',ds_input)
    3988         6959 :  if(tread==1) then
    3989         2104 :    if (ds_input == 0) then
    3990         1308 :      tolwfr_=dprarr(1)
    3991         1308 :      if(abs(dprarr(1))>tiny(0._dp)) then
    3992         1308 :        itol_gen_wfr=itol_gen_wfr+1
    3993              :        ! Set tolwfr_diago to tolwfr by default.
    3994              :        ! Will be overwritten below if tolwfr_diago is specified by the user
    3995         1308 :        dtset%tolwfr_diago=dprarr(1)
    3996              :      end if
    3997              :    else
    3998          796 :      dtset%tolwfr=dprarr(1)
    3999          796 :      if(abs(dprarr(1))>tiny(0._dp)) then
    4000          788 :        itol_wfr=itol_wfr+1
    4001              :        ! Set tolwfr_diago to tolwfr by default.
    4002              :        ! Will be overwritten below if tolwfr_diago is specified by the user
    4003          788 :        dtset%tolwfr_diago=dprarr(1)
    4004              :      end if
    4005              :    end if
    4006              :  end if
    4007              : 
    4008         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'toldff',tread,'DPR',ds_input)
    4009         6959 :  if(tread==1) then
    4010          404 :    if (ds_input == 0) then
    4011          305 :      toldff_=dprarr(1)
    4012          305 :      if(abs(dprarr(1))>tiny(0._dp))itol_gen=itol_gen+1
    4013              :    else
    4014           99 :      dtset%toldff=dprarr(1)
    4015           99 :      if(abs(dprarr(1))>tiny(0._dp))itol=itol+1
    4016              :    end if
    4017          404 :    dtset%optforces=1
    4018              :  end if
    4019              : 
    4020         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'toldmag',tread,'DPR',ds_input)
    4021         6959 :  if(tread==1) then
    4022            2 :    if (ds_input == 0) then
    4023            0 :      toldmag_=dprarr(1)
    4024            0 :      if(abs(dprarr(1))>tiny(0._dp))itol_gen=itol_gen+1
    4025              :    else
    4026            2 :      dtset%toldmag=dprarr(1)
    4027            2 :      if(abs(dprarr(1))>tiny(0._dp))itol=itol+1
    4028              :    end if
    4029              :  end if
    4030              : 
    4031         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tolrff',tread,'DPR',ds_input)
    4032         6959 :  if(tread==1) then
    4033           41 :    if (ds_input == 0) then
    4034           38 :      tolrff_=dprarr(1)
    4035           38 :      if(abs(dprarr(1))>tiny(0._dp))itol_gen=itol_gen+1
    4036              :    else
    4037            3 :      dtset%tolrff=dprarr(1)
    4038            3 :      if(abs(dprarr(1))>tiny(0._dp))itol=itol+1
    4039              :    end if
    4040           41 :    dtset%optforces=1
    4041              :  end if
    4042              : 
    4043         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'toldfe',tread,'ENE',ds_input)
    4044         6959 :  if(tread==1) then
    4045         2605 :    if (ds_input == 0) then
    4046         2254 :      toldfe_=dprarr(1)
    4047         2254 :      if(abs(dprarr(1))>tiny(0._dp))itol_gen=itol_gen+1
    4048              :    else
    4049          351 :      dtset%toldfe=dprarr(1)
    4050          351 :      if(abs(dprarr(1))>tiny(0._dp))itol=itol+1
    4051              :      ! A negative value is interpreted as energy per atom.
    4052          351 :      if (dtset%toldfe < zero) dtset%toldfe = abs(dtset%toldfe) * dtset%natom
    4053              :    end if
    4054              :  end if
    4055              : 
    4056              :  if((dtset%accuracy>0).and.(itol>0.or.itol_gen>0)) tolvrs_=zero
    4057              : 
    4058         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tolvrs',tread,'DPR',ds_input)
    4059         6959 :  if(tread==1) then
    4060         1661 :    if (ds_input == 0) then
    4061         1303 :      tolvrs_=dprarr(1)
    4062         1303 :      if(abs(dprarr(1))>tiny(0._dp))itol_gen=itol_gen+1
    4063              :    else
    4064          358 :      dtset%tolvrs=dprarr(1)
    4065          358 :      if(abs(dprarr(1))>tiny(0._dp))itol=itol+1
    4066              :    end if
    4067              :  end if
    4068              : 
    4069              :  !write(ab_out,*)"GGGGG", itol_gen,itol
    4070              :  ! check for multiple definitions of tolXXX for the present dataset
    4071         6959 :  if (itol > 1 .or. itol_gen > 1) then
    4072              :    write(msg, '(3a)' )&
    4073            0 :    'Only one of the tolXXX variables may be defined at once.',ch10,&
    4074            0 :    'Action: check values of tolvrs, toldfe, tolrff, toldmag and toldff.'
    4075            0 :    ABI_ERROR(msg)
    4076              :  end if
    4077              : 
    4078              : ! Now we take into account that tolwfr can be coupled with an other tolerance,
    4079              : ! ONLY if both tolerances are given for this dataset, or both generic values are defined
    4080              : !if tol/=tolwfr is set without tolwfr, tolwfr should be 0
    4081         6959 :  if (itol == 1 .and. itol_wfr == 0) then
    4082          804 :    dtset%tolwfr=zero
    4083          804 :    dtset%tolwfr_diago=zero
    4084              :  end if
    4085              : !if tolwfr is set without tol/=tolwfr, tol/=tolwfr should be 0
    4086         6959 :  if (itol == 0 .and. itol_wfr == 1) then
    4087          779 :    dtset%toldfe=zero
    4088          779 :    dtset%toldff=zero
    4089          779 :    dtset%toldmag=zero
    4090          779 :    dtset%tolrff=zero
    4091          779 :    dtset%tolvrs=zero
    4092              :  end if
    4093              : 
    4094              : ! up to here:
    4095              : ! -- dtset%tolXXX is set if given for this dataset (itol or itol_wfr>0)
    4096              : ! -- tolXXX_ is non-zero if a generic value is defined (itol_gen or itol_wfr_gen>0)
    4097              : !if no value is given for jdtset, use defaults:
    4098         6959 :  if (itol == 0 .and. itol_wfr == 0) then
    4099         5367 :    if (itol_gen == 1) then
    4100         3774 :      dtset%toldfe=toldfe_
    4101         3774 :      dtset%toldff=toldff_
    4102         3774 :      dtset%toldmag=toldmag_
    4103         3774 :      dtset%tolrff=tolrff_
    4104         3774 :      dtset%tolvrs=tolvrs_
    4105              :    end if
    4106         5367 :    if (itol_gen_wfr == 1) then
    4107         1299 :      dtset%tolwfr=tolwfr_
    4108              :    end if
    4109              :  end if
    4110              : 
    4111         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tolwfr_diago',tread,'DPR')
    4112         6959 :  if(tread==1) dtset%tolwfr_diago = dprarr(1)
    4113              : 
    4114              :  ! Tolerance variable for TFW initialization step
    4115         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tfw_toldfe',tread,'ENE',ds_input)
    4116         6959 :  if(tread==1) then
    4117            1 :    dtset%tfw_toldfe=dprarr(1)
    4118         6958 :  else if (dtset%tfkinfunc>10.and.dtset%toldfe>tiny(0._dp)) then
    4119            0 :    dtset%tfw_toldfe=dtset%toldfe
    4120              :  end if
    4121              : 
    4122              :  ! Tolerance variables for electrons-positron tc-dft
    4123         6959 :  toldfe_=zero;toldff_=zero
    4124         6959 :  itol=0;itol_gen=0
    4125         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'postoldff',tread,'DPR',ds_input)
    4126         6959 :  if(tread==1) then
    4127            1 :    if (ds_input == 0) then
    4128            0 :      toldff_=dprarr(1)
    4129            0 :      if(abs(dprarr(1))>tiny(0._dp))itol_gen=itol_gen+1
    4130              :    else
    4131            1 :      dtset%postoldff=dprarr(1)
    4132            1 :      if(abs(dprarr(1))>tiny(0._dp))itol=itol+1
    4133              :    end if
    4134            1 :    dtset%postoldfe=zero
    4135              :  end if
    4136              : 
    4137         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'postoldfe',tread,'ENE',ds_input)
    4138         6959 :  if(tread==1) then
    4139            9 :    if (ds_input == 0) then
    4140            9 :      toldfe_=dprarr(1)
    4141            9 :      if(abs(dprarr(1))>tiny(0._dp))itol_gen=itol_gen+1
    4142              :    else
    4143            0 :      dtset%postoldfe=dprarr(1)
    4144            0 :      if(abs(dprarr(1))>tiny(0._dp))itol=itol+1
    4145              :    end if
    4146              :  end if
    4147         6959 :  if (itol > 1.or.itol_gen >1) then
    4148              :    write(msg, '(3a)' )&
    4149            0 :    'Only one of the postolXXX variables may be defined at once.',ch10,&
    4150            0 :    'Action: check values of postoldfe and postoldff.'
    4151            0 :    ABI_ERROR(msg)
    4152              :  end if
    4153         6959 :  if (itol==0.and.itol_gen==1) then
    4154            8 :    dtset%postoldfe=toldfe_
    4155            8 :    dtset%postoldff=toldff_
    4156              :  end if
    4157              : 
    4158         6959 :  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'vprtrb',tread,'ENE')
    4159         6975 :  if(tread==1) dtset%vprtrb(:)=dprarr(1:2)
    4160              : 
    4161              : !TODO: should this test be just on natsph without caring about the others? natsph might be used for other purposes
    4162         6959 :  if((dtset%pawfatbnd>0.or.dtset%prtdos==3) .and. dtset%natsph>0)then
    4163           42 :    call intagm(dprarr,intarr,jdtset,marr,dtset%natsph,string(1:lenstr),'iatsph',tread,'INT')
    4164           70 :    if(tread==1) dtset%iatsph(1:dtset%natsph)=intarr(1:dtset%natsph)
    4165              :  end if
    4166              : 
    4167         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtdensph',tread,'INT')
    4168         6959 :  if(tread==1) then
    4169           17 :    dtset%prtdensph=intarr(1)
    4170         6942 :  else if (dtset%nsppol==1.and.dtset%nspden==2) then
    4171           34 :    dtset%prtdensph=1
    4172              :  end if
    4173              : 
    4174              :  ! Initialize atvshift
    4175         6959 :  if(dtset%natvshift>0)then
    4176           15 :    call intagm(dprarr,intarr,jdtset,marr,dtset%natvshift*nsppol*dtset%natom,string(1:lenstr),'atvshift',tread,'ENE')
    4177           15 :    if(tread==1) dtset%atvshift(1:dtset%natvshift,1:nsppol,1:dtset%natom)=&
    4178          111 : &   reshape(dprarr(1:dtset%natvshift*nsppol*dtset%natom),(/dtset%natvshift,nsppol,dtset%natom/))
    4179              :  end if
    4180              : 
    4181              :  ! Initialize wtatcon
    4182         6959 :  if(dtset%nconeq>0)then
    4183              : 
    4184              :    ! Read and check natcon
    4185           15 :    ABI_MALLOC(natcon,(dtset%nconeq))
    4186            5 :    call intagm(dprarr,intarr,jdtset,marr,dtset%nconeq,string(1:lenstr),'natcon',tread,'INT')
    4187            5 :    if(tread==1)then
    4188           10 :      natcon(:)=intarr(1:dtset%nconeq)
    4189              :    else
    4190              :      write(msg, '(3a)' )&
    4191            0 :       'When nconeq is positive, natcon MUST be defined.',ch10,&
    4192            0 :       'Action: check the values of nconeq and natcon.'
    4193            0 :      ABI_ERROR(msg)
    4194              :    end if
    4195           10 :    do ii=1,dtset%nconeq
    4196           10 :      if(natcon(ii)<0)then
    4197              :        write(msg, '(3a,i0,a,i0,2a)' )&
    4198            0 :         'All the components of natcon must be greater than 0.',ch10,&
    4199            0 :         'The component',ii,' is equal to ',natcon(ii),ch10,&
    4200            0 :         'Action: check the values of natcon.'
    4201            0 :        ABI_ERROR(msg)
    4202              :      end if
    4203              :    end do
    4204           10 :    niatcon=sum(natcon(:))
    4205              : 
    4206              :    ! Read and check iatcon
    4207           15 :    ABI_MALLOC(iatcon,(niatcon))
    4208            5 :    call intagm(dprarr,intarr,jdtset,marr,niatcon,string(1:lenstr),'iatcon',tread,'INT')
    4209            5 :    if(tread==1)then
    4210           14 :      iatcon(:)=intarr(1:niatcon)
    4211              :    else
    4212              :      write(msg, '(3a)' )&
    4213            0 :      'When nconeq is positive, natcon MUST be defined.',ch10,&
    4214            0 :      'Action: check the values of nconeq and natcon.'
    4215            0 :      ABI_ERROR(msg)
    4216              :    end if
    4217           14 :    do ii=1,niatcon
    4218           14 :      if(iatcon(ii)<0)then
    4219              :        write(msg, '(a,a,a,i4,a,i4,a,a)' )&
    4220            0 :         'All the components of iatcon must be greater than 0.',ch10,&
    4221            0 :         'The component',ii,' is equal to ',iatcon(ii),ch10,&
    4222            0 :         'Action: check the values of iatcon.'
    4223            0 :        ABI_ERROR(msg)
    4224              :      end if
    4225              :    end do
    4226              : 
    4227              :    ! Read wtatcon, and unfold it.
    4228            5 :    call intagm(dprarr,intarr,jdtset,marr,3*niatcon,string(1:lenstr),'wtatcon',tread,'DPR')
    4229            5 :    if(tread/=1)then
    4230              :      write(msg, '(3a)' )&
    4231            0 :      'When nconeq is positive, wtatcon MUST be defined.',ch10,&
    4232            0 :      'Action: check the values of nconeq and wtatcon.'
    4233            0 :      ABI_ERROR(msg)
    4234              :    end if
    4235            5 :    iat=0
    4236           10 :    do ii=1,dtset%nconeq
    4237           14 :      do jj=1,natcon(ii)
    4238           41 :        dtset%wtatcon(1:3,iatcon(jj+iat),ii)=dprarr(1+3*(jj+iat-1):3+3*(jj+iat-1))
    4239              :      end do
    4240           10 :      iat=iat+natcon(ii)
    4241              :    end do
    4242              : 
    4243            5 :    ABI_FREE(iatcon)
    4244            5 :    ABI_FREE(natcon)
    4245              :  end if
    4246              : 
    4247              :   ! Initialize chempot
    4248         6959 :  if(dtset%nzchempot>0)then
    4249            7 :    call intagm(dprarr,intarr,jdtset,marr,3*dtset%nzchempot*ntypat,string(1:lenstr),'chempot',tread,'DPR')
    4250            7 :    if(tread==1) dtset%chempot(1:3,1:dtset%nzchempot,1:ntypat)=&
    4251          154 : &   reshape(dprarr(1:3*dtset%nzchempot*ntypat),(/3,dtset%nzchempot,ntypat/))
    4252              :  end if
    4253              : 
    4254              :  ! Initialize the list of k points, as well as wtk and istwfk
    4255         6959 :  intimage=1 ; if(nimage>2)intimage=(1+nimage)/2
    4256         6959 :  call invacuum(jdtset,lenstr,natom,dtset%rprimd_orig(1:3,1:3,intimage),string,vacuum,dtset%xred_orig(1:3,1:natom,intimage))
    4257              : 
    4258              :  ! reset rfdir to 1 1 1 in case it was left at the default of 0 0 0 for berryopt -1
    4259              :  if( (dtset%berryopt == -1) .AND. &
    4260              : & (dtset%rfdir(1) == 0) .AND. &
    4261         6959 : & (dtset%rfdir(2) == 0) .AND. &
    4262            0 : & (dtset%rfdir(3) == 0) ) dtset%rfdir(1:3) = 1
    4263              : 
    4264              : !In case of a Berryphase calculation put response = 1
    4265              : !in order to set istwfk = 1 at all k-points
    4266         6959 :  if ( dtset%berryopt/=0 ) then
    4267           83 :    response = 1
    4268              :  end if
    4269              : 
    4270              : !In case of longwave calculation put response = 1
    4271              : !in order to set istwfk = 1 at all k-points
    4272         6959 :  if ( dtset%optdriver==RUNL_LONGWAVE ) then
    4273           17 :    response = 1
    4274              :  end if
    4275              : 
    4276         6959 :  nsym=dtset%nsym
    4277         6959 :  ii=0;if (mod(dtset%wfoptalg,10)==4) ii=2
    4278              : #ifdef HAVE_DFTI
    4279         6959 :  if (dtset%wfoptalg==114.or.dtset%wfoptalg==111) ii=0 ! allow any istwfk for LOBPCG or Chebfi with xg_tools
    4280              : #else
    4281              :  if (dtset%wfoptalg==114.or.dtset%wfoptalg==111) ii=2 ! allow only istwfk=1 or 2 for LOBPCG or Chebfi with xg_tools
    4282              : #endif
    4283         6959 :  if(dtset%ngfft(7)==314)ii=1
    4284         6959 :  if(dtset%usefock==1.and.dtset%optdriver/=RUNL_SIGMA.and.mod(dtset%wfoptalg,10)/=5.and.nkpt>1) ii=1
    4285              :  !Enforce istwfk = 1 for all k-points in RT-TDDFT calculations
    4286         6959 :  if(dtset%optdriver==RUNL_RTTDDFT) ii=1
    4287              : 
    4288              :  call inkpts(bravais,dtset%chksymbreak,dtset%fockdownsampling,iout,iscf,dtset%istwfk(1:nkpt),jdtset,&
    4289              :    dtset%kpt(:,1:nkpt),dtset%kptns_hf(:,1:nkpthf),kptopt,dtset%kptnrm,&
    4290              :    dtset%kptrlatt_orig,dtset%kptrlatt,kptrlen,lenstr,nsym, dtset%getkerange_filepath, &
    4291              :    nkpt,nkpthf,nqpt,dtset%ngkpt,dtset%nshiftk,dtset%nshiftk_orig,dtset%shiftk_orig,nsym,&
    4292              :    occopt,dtset%qptn,response,dtset%rprimd_orig(1:3,1:3,intimage),dtset%shiftk,string,&
    4293         6959 :    dtset%symafm(1:nsym),dtset%symrel(:,:,1:nsym),vacuum,dtset%wtk(1:nkpt), comm, impose_istwf_1=ii)
    4294              : 
    4295         6959 :  dtset%kptrlen=kptrlen
    4296              : 
    4297       460183 :  dtset%kptns(:,1:nkpt)=dtset%kpt(:,1:nkpt)/dtset%kptnrm
    4298         6959 :  if(nqpt>=1 .and. dtset%optdriver/=RUNL_RESPFN.and.dtset%optdriver/=RUNL_LONGWAVE)then
    4299         4223 :    dtset%kptns(1,1:nkpt)=dtset%kptns(1,1:nkpt)+dtset%qptn(1)
    4300         4223 :    dtset%kptns(2,1:nkpt)=dtset%kptns(2,1:nkpt)+dtset%qptn(2)
    4301         4223 :    dtset%kptns(3,1:nkpt)=dtset%kptns(3,1:nkpt)+dtset%qptn(3)
    4302              :  end if
    4303              : 
    4304         6959 :  if(nkpthf/=0)then
    4305      3007314 :    dtset%kptns_hf(:,1:nkpthf)=dtset%kptns_hf(:,1:nkpthf)/dtset%kptnrm
    4306              :  end if
    4307              : 
    4308              :  ! Read variables defining the k-path
    4309              :  ! If kptopt < 0  --> Band structure and kptbounds size is given by abs(kptopt)
    4310              :  ! If kptopt >= 0 --> We may have a k-path specified by nkpath and kptbounds (used by post-processing tools)
    4311              :  ! TODO: ndivk?
    4312              : 
    4313         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ndivsm',tread,'INT')
    4314         6959 :  if (tread == 1) dtset%ndivsm = intarr(1)
    4315              : 
    4316         6959 :  if (dtset%kptopt < 0) then
    4317          142 :    dtset%nkpath = abs(dtset%kptopt)
    4318              :  else
    4319         6817 :    dtset%nkpath = 0
    4320         6817 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nkpath',tread,'INT')
    4321         6817 :    if (tread==1) dtset%nkpath = intarr(1)
    4322              :  end if
    4323              : 
    4324         6959 :  if (dtset%nkpath /= 0) then
    4325          145 :    call intagm(dprarr,intarr,jdtset,marr,3*dtset%nkpath,string(1:lenstr),'kptbounds',tread,'DPR')
    4326              : 
    4327          145 :    if (tread == 1) then
    4328          435 :      ABI_MALLOC(dtset%kptbounds, (3, dtset%nkpath))
    4329         2200 :      dtset%kptbounds = reshape(dprarr(1:3*dtset%nkpath), [3, dtset%nkpath])
    4330              :    else
    4331            0 :      ABI_ERROR("When nkpath /= 0 or kptopt < 0, kptbounds must be defined in the input file.")
    4332              :    end if
    4333              :  else
    4334         6814 :    ABI_MALLOC(dtset%kptbounds, (0,0))
    4335              :  end if
    4336              : 
    4337              :  ! if prtkpt==-2, write the k-points in netcdf format and exit here so that AbiPy can read the data.
    4338         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtkpt',tread,'INT')
    4339         6959 :  if (tread == 1 .and. intarr(1) == -2) then
    4340            0 :    if (my_rank == 0) then
    4341            0 :      ncerr= nctk_write_ibz("kpts.nc", dtset%kptns(:,1:nkpt), dtset%wtk(1:nkpt))
    4342            0 :      NCF_CHECK(ncerr)
    4343              :    end if
    4344            0 :    call xmpi_barrier(comm)
    4345            0 :    ABI_ERROR_NODUMP("kpts.nc file written. Aborting now")
    4346              :  end if
    4347              : 
    4348         6959 :  if (dtset%nkptgw>0) then
    4349              :    ! Read bdgw.
    4350          292 :    call intagm(dprarr,intarr,jdtset,marr,2*dtset%nkptgw*dtset%nsppol,string(1:lenstr),'bdgw',tread,'INT')
    4351          292 :    if (tread==1) then
    4352              :      dtset%bdgw(1:2,1:dtset%nkptgw,1:dtset%nsppol) =  &
    4353         4411 :        reshape(intarr(1:2*dtset%nkptgw*dtset%nsppol),[2,dtset%nkptgw,dtset%nsppol])
    4354              :    end if
    4355              : 
    4356              :    ! Test bdgw values.
    4357          292 :    if (any(dtset%optdriver == [RUNL_SIGMA, RUNL_EPH])) then
    4358         1977 :      if (any(dtset%bdgw(1:2,1:dtset%nkptgw,1:dtset%nsppol) <= 0)) then
    4359            0 :        ABI_ERROR("bdgw entries cannot be <= 0. Check input file")
    4360              :      end if
    4361          927 :      if (any(dtset%bdgw(1,1:dtset%nkptgw,1:dtset%nsppol) > dtset%bdgw(2,1:dtset%nkptgw,1:dtset%nsppol))) then
    4362            0 :        ABI_ERROR("First band index in bdgw cannot be greater than the second index")
    4363              :      end if
    4364              :    end if
    4365              : 
    4366          292 :    call intagm(dprarr,intarr,jdtset,marr,3*dtset%nkptgw,string(1:lenstr),'kptgw',tread,'DPR')
    4367         4772 :    if(tread==1) dtset%kptgw(1:3,1:dtset%nkptgw) = reshape(dprarr(1:3*dtset%nkptgw), [3, dtset%nkptgw])
    4368              :  end if
    4369              : 
    4370         6959 :  if (dtset%nqptdm > 0) then
    4371            3 :    call intagm(dprarr,intarr,jdtset,marr,3*dtset%nqptdm,string(1:lenstr),'qptdm',tread,'DPR')
    4372           33 :    if(tread==1) dtset%qptdm(1:3,1:dtset%nqptdm)=reshape(dprarr(1:3*dtset%nqptdm), [3, dtset%nqptdm])
    4373              :  end if
    4374              : 
    4375         6959 :  if(dtset%npvel>0) then
    4376            2 :    call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'pvelmax',tread,'DPR')
    4377            8 :    if(tread==1) dtset%pvelmax(1:3)=dprarr(1:3)
    4378              :  end if
    4379              : 
    4380         6959 :  if(dtset%imgmov==6)then
    4381            6 :    call intagm(dprarr,intarr,jdtset,marr,dtset%nimage,string(1:lenstr),'mixesimgf',tread,'DPR')
    4382           18 :    if(tread==1)dtset%mixesimgf(1:dtset%nimage)=dprarr(1:dtset%nimage)
    4383              :  endif
    4384              : 
    4385              :  ! Read remaining input variables depending on images : occ_orig, upawu, jpawu.
    4386              :  ! MT oct 15: these lines are inspired from invars1 but are not really understood
    4387         6959 :  intimage=2 ; if(dtset%nimage==1)intimage=1
    4388        14223 :  do ii=1,dtset%nimage+1
    4389        14178 :    iimage=ii
    4390        14178 :    if(dtset%nimage==1 .and. ii==2)exit
    4391         7269 :    if(dtset%nimage==2 .and. ii==3)exit
    4392         7264 :    if(dtset%nimage> 2 .and. ii==intimage)cycle ! Will do the intermediate reference image at the last reading
    4393         7219 :    if(dtset%nimage>=2 .and. ii==dtset%nimage+1)iimage=intimage
    4394              : 
    4395              :    ! Only read occ if (iscf >0 or iscf=-1 or iscf=-3) and (occopt==0 or occopt==2)
    4396         7219 :    if  (iscf>=0.or.iscf==-1.or.iscf==-3)  then
    4397         6725 :      if (occopt==2 .and. getocc==0) then
    4398              :        ! Read occ(nband(kpt)*nkpt*nsppol) explicitly
    4399          200 :        call wrtout(std_out,' invars2: reading occ(nband*nkpt*nsppol) explicitly','COLL')
    4400          200 :        call intagm(dprarr,intarr,jdtset,marr,bantot,string(1:lenstr),'occ',tread,'DPR')
    4401         1837 :        if(tread==1) dtset%occ_orig(1:bantot,iimage)=dprarr(1:bantot)
    4402          200 :        call intagm_img(dprarr(1:bantot),iimage,jdtset,lenstr,dtset%nimage,bantot,string,'occ',tread_alt,'DPR')
    4403          200 :        if(tread_alt==1) dtset%occ_orig(1:bantot,iimage)=dprarr(1:bantot)
    4404         6525 :      else if(occopt==0) then
    4405          256 :        nband1=dtset%nband(1)
    4406              :        ! Read usual occupancy--same for all k points but might differ for spins
    4407          256 :        call intagm(dprarr,intarr,jdtset,marr,nband1*nsppol,string(1:lenstr),'occ',tread,'DPR')
    4408         2630 :        if(tread==1) dtset%occ_orig(1:nband1*nsppol,iimage)=dprarr(1:nband1*nsppol)
    4409          256 :        call intagm_img(dprarr(1:nband1*nsppol),iimage,jdtset,lenstr,dtset%nimage,nband1*nsppol,string,'occ',tread_alt,'DPR')
    4410          608 :        if(tread_alt==1) dtset%occ_orig(1:nband1*nsppol,iimage)=dprarr(1:nband1*nsppol)
    4411              :        ! Fill in full occ array using input values for each k and spin
    4412              :        ! (make a separate copy for each k point and spin)
    4413          256 :        if(nkpt>1)then
    4414          218 :          do isppol=nsppol,1,-1
    4415          674 :            do ikpt=1,nkpt
    4416              :              dtset%occ_orig(1+(ikpt-1)*nband1+nkpt*nband1*(isppol-1):ikpt*nband1+nkpt*nband1*(isppol-1),iimage)=&
    4417        13484 : &             dtset%occ_orig(1+nband1*(isppol-1):nband1*isppol,iimage)
    4418              :            end do
    4419              :          end do
    4420              :        endif
    4421              :      end if
    4422              :    end if
    4423              : 
    4424        14178 :    if (dtset%usepawu/=0.or.(dtset%usedmft>0.and.dtset%usedmft/=10)) then
    4425              : 
    4426          386 :      dprarr(1:ntypat)=dtset%upawu(1:ntypat,iimage)
    4427          153 :      call intagm(dprarr,intarr,jdtset,marr,ntypat,string(1:lenstr),'upawu',tread,'ENE')
    4428          368 :      if(tread==1) dtset%upawu(1:ntypat,iimage)=dprarr(1:ntypat)
    4429          153 :      call intagm_img(dprarr(1:ntypat),iimage,jdtset,lenstr,dtset%nimage,ntypat,string,'upawu',tread_alt,'ENE')
    4430          153 :      if(tread_alt==1) dtset%upawu(1:ntypat,iimage)=dprarr(1:ntypat)
    4431              : 
    4432          386 :      dprarr(1:ntypat)=dtset%jpawu(1:ntypat,iimage)
    4433          153 :      call intagm(dprarr,intarr,jdtset,marr,ntypat,string(1:lenstr),'jpawu',tread,'ENE')
    4434          350 :      if(tread==1) dtset%jpawu(1:ntypat,iimage)=dprarr(1:ntypat)
    4435          153 :      call intagm_img(dprarr(1:ntypat),iimage,jdtset,lenstr,dtset%nimage,ntypat,string,'jpawu',tread_alt,'ENE')
    4436          153 :      if(tread_alt==1) dtset%jpawu(1:ntypat,iimage)=dprarr(1:ntypat)
    4437              : 
    4438          153 :      if (dtset%usedmatpu/=0.and.dmatsize>0) then
    4439           15 :        nsp=nsppol*nspinor
    4440           15 :        call intagm(dprarr,intarr,jdtset,marr,dmatsize,string(1:lenstr),'dmatpawu',tread,'DPR')
    4441           15 :        if(tread==1) then
    4442           15 :          iat=1;jj=1
    4443           64 :          do iatom=1,natom
    4444           49 :            lpawu=dtset%lpawu(dtset%typat(iatom))
    4445           64 :            if (lpawu/=-1) then
    4446           26 :              isiz=nsp*(2*lpawu+1)**2
    4447              :              dtset%dmatpawu(1:2*lpawu+1,1:2*lpawu+1,1:nsp,iat,iimage)= &
    4448         1448 : &             reshape(dprarr(jj:jj+isiz),(/2*lpawu+1,2*lpawu+1,nsp/))
    4449           26 :              iat=iat+1;jj=jj+isiz
    4450              :            end if
    4451              :          end do
    4452              :        end if
    4453              : 
    4454           45 :        ABI_MALLOC(dmatpawu_tmp,(dmatsize))
    4455           15 :        iat=1;jj=1
    4456           64 :        do iatom=1,natom
    4457           49 :          lpawu=dtset%lpawu(dtset%typat(iatom))
    4458           64 :          if (lpawu/=-1) then
    4459           26 :            isiz=nsp*(2*lpawu+1)**2
    4460              :            dmatpawu_tmp(jj:jj+isiz-1)= &
    4461           52 : &           reshape(dtset%dmatpawu(1:2*lpawu+1,1:2*lpawu+1,1:nsp,iat,iimage),(/isiz/))
    4462           26 :            iat=iat+1;jj=jj+isiz
    4463              :          end if
    4464              :        end do
    4465           15 :        call intagm_img(dmatpawu_tmp,iimage,jdtset,lenstr,dtset%nimage,dmatsize, string,'dmatpawu',tread_alt,'DPR')
    4466           15 :        if(tread_alt==1) then
    4467            0 :          iat=1;jj=1
    4468            0 :          do iatom=1,natom
    4469            0 :            lpawu=dtset%lpawu(dtset%typat(iatom))
    4470            0 :            if (lpawu/=-1) then
    4471            0 :              isiz=nsp*(2*lpawu+1)**2
    4472              :              dtset%dmatpawu(1:2*lpawu+1,1:2*lpawu+1,1:nsp,iat,iimage)= &
    4473            0 : &             reshape(dmatpawu_tmp(jj:jj+isiz-1),(/2*lpawu+1,2*lpawu+1,nsp/))
    4474            0 :              iat=iat+1;jj=jj+isiz
    4475              :            end if
    4476              :          end do
    4477              :        end if
    4478           15 :        ABI_FREE(dmatpawu_tmp)
    4479              : 
    4480           15 :        if (tread/=1.and.tread_alt/=1) then
    4481              :          write(msg, '(3a)' )&
    4482            0 :          'When LDA/GGA+U is activated and usedmatpu/=0, dmatpawu MUST be defined.',ch10,&
    4483            0 :          'Action: add dmatpawu keyword in input file.'
    4484            0 :          ABI_ERROR(msg)
    4485              :        end if
    4486              :      end if
    4487              : 
    4488              :    end if
    4489              : 
    4490              :  end do
    4491              : 
    4492         6959 :  nelectjell=zero
    4493         6959 :  if(dtset%jellslab/=0)then
    4494            6 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'slabwsrad',tread,'LEN')
    4495            6 :    if(tread==1) dtset%slabwsrad=dprarr(1)
    4496              : 
    4497              :    ! Update number of electrons taking into account jellium
    4498              :    ! Suppose that the cell has z axis perpendicular to x and y axes.
    4499              :    ! This will be checked later
    4500            6 :    areaxy=abs(dtset%rprimd_orig(1,1,1)*dtset%rprimd_orig(2,2,1)-dtset%rprimd_orig(1,2,1)*dtset%rprimd_orig(2,1,1))
    4501            6 :    rhoavg=three/(four_pi*dtset%slabwsrad**3)
    4502            6 :    nelectjell=areaxy*(dtset%slabzend-dtset%slabzbeg)*rhoavg
    4503              :  end if
    4504              : 
    4505              :  ! Initialize occ if occopt==1 or 3 ... 8,
    4506              :  ! while if getocc/=0, make a fake initialization
    4507              :  ! If iscf>0, check the charge of the system, and compute nelect.
    4508         6959 :  occopt_tmp=occopt
    4509         6959 :  if(getocc/=0)occopt_tmp=1
    4510         6959 :  call dtset%initocc_chkneu(nelectjell,occopt_tmp)
    4511              : 
    4512              :  ! Now that the occupation numbers have been initialized, can meaningfully define nbandhf.
    4513         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nbandhf',tread,'INT')
    4514         6959 :  if(tread==1) then
    4515           13 :    dtset%nbandhf=intarr(1)
    4516              :  else
    4517              :    ! If the occupation numbers might change, must keep the maximum number of bands
    4518         6946 :    if(occopt>=3 .and. occopt<=9)then
    4519        50269 :      dtset%nbandhf=maxval(dtset%nband(1:nkpt*nsppol))
    4520         4414 :    else if(occopt==0 .or. occopt==1 .or. occopt==2) then
    4521              :      ! Eliminate all the bands that are never occupied
    4522         4414 :      nband1=0 ; bantot=0
    4523         9209 :      do isppol=1,dtset%nsppol
    4524        78816 :        do ikpt=1,dtset%nkpt
    4525       608570 :          do iband=1,dtset%nband(ikpt+(isppol-1)*dtset%nkpt)
    4526       534168 :            bantot=bantot+1
    4527      1676842 :            if(maxval(abs(dtset%occ_orig(bantot,:)))>tol8)then
    4528       534168 :              if(iband>nband1)nband1=iband
    4529              :            end if
    4530              :          end do
    4531              :        end do
    4532              :      end do
    4533         4414 :      dtset%nbandhf=nband1
    4534              :    else
    4535            0 :      write(msg, '(a,i0,3a)' )'occopt=',occopt,' not allowed.',ch10,'Action: correct your input file.'
    4536            0 :      ABI_ERROR(msg)
    4537              :    end if
    4538              :  end if
    4539              : 
    4540              :  ! Initialize Berry phase vectors
    4541              :  ! Should check that nberry is smaller than 20
    4542         6959 :  if(berryopt>0 .and. nberry>0)then
    4543           26 :    call intagm(dprarr,intarr,jdtset,marr,3*nberry,string(1:lenstr),'kberry',tread,'INT')
    4544           26 :    if(tread==1) dtset%kberry(1:3,1:nberry)=reshape(intarr(1:3*nberry), [3,nberry])
    4545              :  end if
    4546              : 
    4547         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ddamp',tread,'DPR')
    4548         6959 :  if (tread==1) dtset%ddamp = dprarr(1)
    4549              : 
    4550         6959 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'polcen',tread,'DPR')
    4551         6959 :  if (tread==1) dtset%polcen(1:3) = dprarr(1:3)
    4552              : 
    4553         6959 :  call intagm(dprarr,intarr,jdtset,marr,ntypat,string(1:lenstr),'densty',tread,'DPR')
    4554         7047 :  if(tread==1) dtset%densty(1:ntypat,1)=dprarr(1:ntypat)
    4555              : 
    4556         6959 :  call intagm(dprarr,intarr,jdtset,marr,npsp,string(1:lenstr),'so_psp',tread,'INT')
    4557         7156 :  if (tread==1.and.dtset%usepaw==0) dtset%so_psp(1:npsp) = intarr(1:npsp)
    4558              : 
    4559              :  ! LOTF variables
    4560              : #if defined HAVE_LOTF
    4561              :  if(dtset%ionmov==23) then
    4562              :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lotf_classic',tread,'INT')
    4563              :    if(tread==1) dtset%lotf_classic=intarr(1)
    4564              :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lotf_nitex',tread,'INT')
    4565              :    if(tread==1) dtset%lotf_nitex=intarr(1)
    4566              :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lotf_nneigx',tread,'INT')
    4567              :    if(tread==1) dtset%lotf_nneigx=intarr(1)
    4568              :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lotf_version',tread,'INT')
    4569              :    if(tread==1) dtset%lotf_version=intarr(1)
    4570              :  end if
    4571              : #endif
    4572              : 
    4573              : !Read input variables related to Projected Local Orbitals Wannier functions (plowan)
    4574         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'plowan_bandi',tread,'INT')
    4575         6959 :  if(tread==1) dtset%plowan_bandi=intarr(1)
    4576         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'plowan_bandf',tread,'INT')
    4577         6959 :  if(tread==1) dtset%plowan_bandf=intarr(1)
    4578         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'plowan_realspace',tread,'INT')
    4579         6959 :  if(tread==1) dtset%plowan_realspace=intarr(1)
    4580         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'plowan_natom',tread,'INT')
    4581         6959 :  if(tread==1) dtset%plowan_natom=intarr(1)
    4582         6959 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'plowan_nt',tread,'INT')
    4583         6959 :  if(tread==1) dtset%plowan_nt=intarr(1)
    4584              : 
    4585              : ! if (dtset%plowan_compute>0) then
    4586         6959 :    call intagm(dprarr,intarr,jdtset,marr,3*dtset%plowan_nt,string(1:lenstr),'plowan_it',tread,'INT')
    4587         6959 :    if(tread==1) dtset%plowan_it(1:3*dtset%plowan_nt)=intarr(1:3*dtset%plowan_nt)
    4588              : 
    4589         6959 :    call intagm(dprarr,intarr,jdtset,marr,dtset%plowan_natom,string(1:lenstr),'plowan_iatom',tread,'INT')
    4590         6959 :    if(tread==1) dtset%plowan_iatom(1:dtset%plowan_natom)=intarr(1:dtset%plowan_natom)
    4591              : 
    4592         6959 :    call intagm(dprarr,intarr,jdtset,marr,dtset%plowan_natom,string(1:lenstr),'plowan_nbl',tread,'INT')
    4593         6959 :    if(tread==1) dtset%plowan_nbl(1:dtset%plowan_natom)=intarr(1:dtset%plowan_natom)
    4594        61731 :    sumnbl=sum(dtset%plowan_nbl(:))
    4595              : 
    4596         6959 :    call intagm(dprarr,intarr,jdtset,marr,sumnbl,string(1:lenstr),'plowan_lcalc',tread,'INT')
    4597         6959 :    if(tread==1) dtset%plowan_lcalc(1:sumnbl)=intarr(1:sumnbl)
    4598              : 
    4599         6959 :    call intagm(dprarr,intarr,jdtset,marr,sumnbl,string(1:lenstr),'plowan_projcalc',tread,'INT')
    4600         6959 :    if(tread==1) dtset%plowan_projcalc(1:sumnbl)=intarr(1:sumnbl)
    4601              : ! end if
    4602              : 
    4603              : 
    4604         6959 :    if ((dtset%ucrpa > 0 .and. dtset%plowan_compute >=0 )) then
    4605              :    !   dtset%plowan_natom=1
    4606              :    !   dtset%plowan_nbl(:)=1
    4607            0 :      dtset%plowan_nt=1
    4608            0 :      dtset%plowan_it(:)=0
    4609            0 :      dtset%plowan_realspace=1
    4610              :    !   call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_t2g',tread,'INT')
    4611              :    !   if(tread==1) dtset%dmft_t2g=intarr(1)
    4612              :    !   do iatom=1,dtset%natom
    4613              :    !     lpawu=dtset%lpawu(dtset%typat(iatom))
    4614              :    !     if (lpawu/=-1) then
    4615              :    !       dtset%plowan_lcalc(:)=lpawu
    4616              :    !       dtset%plowan_iatom(:)=iatom
    4617              :    !       dtset%plowan_projcalc(:)=-2
    4618              :    !     end if
    4619              :    !   end do
    4620              :    !   dtset%plowan_bandi=dtset%dmftbandi
    4621              :    !   dtset%plowan_bandf=dtset%dmftbandf
    4622              :    !   if (dtset%nbandkss /= 0 .and. dtset%usedmft/=0) then
    4623              :    !     dtset%plowan_compute=1
    4624              :    !     dtset%usedmft=0
    4625              :    !   else if (dtset%optdriver==3) then
    4626              :    !     dtset%plowan_compute=10
    4627              :    !   else if(dtset%optdriver==4) then
    4628              :    !     dtset%plowan_compute=10
    4629              :    !   end if
    4630              :    end if
    4631              : 
    4632              :  ! band range for self-energy sum
    4633         6959 :  call intagm(dprarr, intarr, jdtset, marr, 2, string(1:lenstr), 'sigma_bsum_range', tread, 'INT')
    4634         6959 :  if (tread == 1) then
    4635            6 :     dtset%sigma_bsum_range = intarr(1:2)
    4636            6 :     ABI_CHECK(all(dtset%sigma_bsum_range > 0), "sigma_bsum_range cannot be negative")
    4637            2 :     ABI_CHECK(dtset%sigma_bsum_range(2) >= dtset%sigma_bsum_range(1), "sigma_bsum_range(2) must be >= (1)")
    4638              :  end if
    4639              : 
    4640              :  ! band range for self-energy corrections.
    4641         6959 :  call intagm(dprarr, intarr, jdtset, marr, 2, string(1:lenstr), 'sigma_erange', tread, 'ENE')
    4642         6959 :  if (tread == 1) then
    4643           57 :    dtset%sigma_erange = dprarr(1:2)
    4644              :    !if (all(dtset%sigma_erange < zero) .and. .not. tread_dipdip == 1) dtset%dipdip = 0
    4645              :  end if
    4646              : 
    4647              :  ! IBZ k-points for transport calculation in terms of transport_ngkpt
    4648         6959 :  call intagm(dprarr, intarr, jdtset, marr, 3, string(1:lenstr), 'transport_ngkpt', tread, 'INT')
    4649         6962 :  if (tread == 1) dtset%transport_ngkpt = intarr(1:3)
    4650              : 
    4651              :  ! IBZ k-points for electron self-energy given in terms of sigma_ngkpt
    4652         6959 :  call intagm(dprarr, intarr, jdtset, marr, 3, string(1:lenstr), 'sigma_ngkpt', tread, 'INT')
    4653              : 
    4654         6959 :  if (tread == 1) then
    4655              :    ! sigma_ngkpt mode --> initialize shifts, provide default if not given in input
    4656              :    ! Consistency check: nkptgw must be zero, sigma_erange should not be given.
    4657            8 :    ABI_CHECK(dtset%nkptgw == 0, "nkptgw and sigma_ngkpt are mutually exclusive.")
    4658              : 
    4659           32 :    dtset%sigma_ngkpt = intarr(1:3)
    4660            8 :    call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'sigma_nshiftk', tread, 'INT')
    4661            8 :    if (tread == 1) dtset%sigma_nshiftk = intarr(1)
    4662            8 :    if (dtset%sigma_nshiftk < 1 .or. dtset%sigma_nshiftk > MAX_NSHIFTK ) then
    4663              :      write(msg, '(a,i0,2a,i0,3a)' ) &
    4664            0 :      'The only allowed values of nshiftk are between 1 and ',MAX_NSHIFTK,ch10,&
    4665            0 :      'while it is found to be ',dtset%sigma_nshiftk,'.',ch10,&
    4666            0 :      'Action: change the value of sigma_nshiftk in your input file, or change kptopt.'
    4667            0 :      ABI_ERROR(msg)
    4668              :    end if
    4669              : 
    4670            8 :    call intagm(dprarr, intarr, jdtset, marr, 3*dtset%sigma_nshiftk, string(1:lenstr), 'sigma_shiftk', tread, 'DPR')
    4671              :    ! Yes, I know that multidatasets will likely crash if sigma_nshiftk changes...
    4672           56 :    ABI_CALLOC(dtset%sigma_shiftk, (3, dtset%sigma_nshiftk))
    4673            8 :    if (tread == 1) then
    4674           14 :      dtset%shiftk(:,1:dtset%sigma_nshiftk) = reshape(dprarr(1:3*dtset%sigma_nshiftk), [3,dtset%sigma_nshiftk])
    4675              :    end if
    4676              :  end if
    4677              : 
    4678         6959 :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), "wfk_task", tread, 'KEY', key_value=key_value)
    4679         6959 :  if (tread==1) dtset%wfk_task = str2wfktask(tolower(key_value))
    4680         6959 :  if (dtset%optdriver == RUNL_WFK .and. dtset%wfk_task == WFK_TASK_NONE) then
    4681            0 :     ABI_ERROR(sjoin("A valid wfk_task must be specified when optdriver= ", itoa(dtset%optdriver), ", Received:", key_value))
    4682              :  end if
    4683              : 
    4684         6959 :  if (dtset%use_gbt /= 0) then
    4685            8 :    call intagm(dprarr, intarr, jdtset, marr, 3, string(1:lenstr), 'qgbt', tread_qgbt, 'DPR')
    4686           32 :    if (tread_qgbt == 1) dtset%qgbt(1:3) = dprarr(1:3)
    4687            8 :    call intagm(dprarr, intarr, jdtset, marr, 3, string(1:lenstr), 'qgbt_cart', tread_cart, 'DPR')
    4688            8 :    if (tread_qgbt ==1 .and. tread_cart == 1) then
    4689            0 :      ABI_ERROR("Both 'qgbt' and 'qgbt_cart' are defined, choose to define only one of these.")
    4690            8 :    else if (tread_cart == 1) then
    4691            0 :      dtset%qgbt_cart = dprarr(1:3)
    4692            0 :      call mkrdim(dtset%acell_orig(1:3,1),dtset%rprim_orig(1:3,1:3,1),rprimd)
    4693            0 :      dtset%qgbt(1:3) = MATMUL(TRANSPOSE(rprimd)/two_pi, dtset%qgbt_cart)
    4694              :    end if
    4695              :  end if
    4696              : 
    4697         6959 :  ABI_FREE(intarr)
    4698         6959 :  ABI_FREE(dprarr)
    4699              : 
    4700         6959 :  if (dtset%nqptdm == -1) then
    4701            0 :    cryst = dtset%get_crystal(1)
    4702              :    !call cryst%print(mode_paral='COLL')
    4703            0 :    call Kmesh%init(Cryst, dtset%nkpt, dtset%kptns, Dtset%kptopt, wrap_1zone=.FALSE.)
    4704              : 
    4705              :    ! Some required information are not filled up inside kmesh_init
    4706              :    ! So doing it here, even though it is not clean
    4707            0 :    Kmesh%kptrlatt(:,:) = Dtset%kptrlatt(:,:)
    4708            0 :    Kmesh%nshift = Dtset%nshiftk
    4709            0 :    ABI_MALLOC(Kmesh%shift, (3, Kmesh%nshift))
    4710            0 :    Kmesh%shift(:,:) = Dtset%shiftk(:,1:Dtset%nshiftk)
    4711              :    !call Kmesh%print("K-mesh for the wavefunctions",ab_out, dtset%prtvol)
    4712            0 :    call Qmesh%find_qmesh(Cryst, Kmesh)
    4713            0 :    if (my_rank == master) then
    4714            0 :      NCF_CHECK(nctk_write_ibz("qptdms.nc", qmesh%ibz, qmesh%wt))
    4715              :    end if
    4716            0 :    call xmpi_barrier(comm)
    4717            0 :    ABI_ERROR_NODUMP("Aborting now")
    4718              :  end if
    4719              : 
    4720         6959 :  call timab(191,2,tsec)
    4721              : 
    4722         6959 : end subroutine invars2
    4723              : !!***
    4724              : 
    4725              : end module m_invars2
    4726              : !!***
        

Generated by: LCOV version 2.3-1