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 % 2902 2541
Test Date: 2026-11-10 12:08:57 Functions: 100.0 % 2 2
Branches: 73.8 % 3814 2814

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

Generated by: LCOV version 2.3-1