LCOV - code coverage report
Current view: top level - src/57_iovars - m_chkinp.F90 (source / functions) Coverage Total Hit
Test: coverage.info Lines: 58.3 % 2679 1561
Test Date: 2026-11-08 00:10:28 Functions: 100.0 % 1 1
Branches: 65.7 % 3014 1979

             Branch data     Line data    Source code
       1                 :             : !!****m* ABINIT/m_chkinp
       2                 :             : !! NAME
       3                 :             : !!  m_chkinp
       4                 :             : !!
       5                 :             : !! FUNCTION
       6                 :             : !! Check consistency of Abinit input data against itself.
       7                 :             : !!
       8                 :             : !! COPYRIGHT
       9                 :             : !!  Copyright (C) 1998-2026 ABINIT group (DCA, XG, GMR, MKV, DRH, MVer, MG)
      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_chkinp
      23                 :             : 
      24                 :             :  use defs_basis
      25                 :             :  use m_gwdefs
      26                 :             :  use m_abicore
      27                 :             :  use m_errors
      28                 :             :  use m_xmpi
      29                 :             :  use m_xomp
      30                 :             :  use libxc_functionals
      31                 :             :  use m_dtset
      32                 :             : 
      33                 :             :  use defs_datatypes,   only : pspheader_type
      34                 :             :  use defs_abitypes,    only : MPI_type
      35                 :             :  use m_numeric_tools,  only : iseven, isdiagmat, wrap2_zero_one
      36                 :             :  use m_symtk,          only : sg_multable, chkorthsy, symmetrize_xred
      37                 :             :  use m_fstrings,       only : string_in, sjoin, itoa
      38                 :             :  use m_geometry,       only : metric
      39                 :             :  use m_fftcore,        only : fftalg_has_mpi
      40                 :             :  use m_exit,           only : get_timelimit
      41                 :             :  use m_parser,         only : chkdpr, chkint, chkint_eq, chkint_ge, chkint_le, chkint_ne
      42                 :             :  use m_pawpsp,         only : pawpsp_check_corefile
      43                 :             :  use m_mep
      44                 :             : 
      45                 :             :  implicit none
      46                 :             : 
      47                 :             :  private
      48                 :             : !!***
      49                 :             : 
      50                 :             :  public :: chkinp
      51                 :             : !!***
      52                 :             : 
      53                 :             : contains
      54                 :             : !!***
      55                 :             : 
      56                 :             : !!****f* ABINIT/chkinp
      57                 :             : !! NAME
      58                 :             : !! chkinp
      59                 :             : !!
      60                 :             : !! FUNCTION
      61                 :             : !! Check consistency of input data against itself.
      62                 :             : !! Please: use the alphabetic order
      63                 :             : !! Please: use the routines chkint_eq, chkint_ne, chkint_ge, chkint_le, and chkdpr
      64                 :             : !!
      65                 :             : !! INPUTS
      66                 :             : !!  dtsets(0:ndtset_alloc)=<type datafiles_type>contains all input variables
      67                 :             : !!  iout=unit number for output file
      68                 :             : !!  mpi_enregs(0:ndtset_alloc)=information about MPI parallelization
      69                 :             : !!  ndtset=number of datasets
      70                 :             : !!  ndtset_alloc=number of datasets, corrected for allocation of at least one data set.
      71                 :             : !!  npsp=number of pseudopotentials
      72                 :             : !!  pspheads(npsp)=<type pspheader_type>all the important information from the
      73                 :             : !!   pseudopotential file header, as well as the psp file name
      74                 :             : !!  comm: MPI communicator (MPI_COMM_WORLD)
      75                 :             : !!
      76                 :             : !! OUTPUT
      77                 :             : !!
      78                 :             : !! SOURCE
      79                 :             : 
      80                 :        1433 : subroutine chkinp(dtsets, iout, mpi_enregs, ndtset, ndtset_alloc, npsp, pspheads, comm)
      81                 :             : 
      82                 :             : !Arguments ------------------------------------
      83                 :             : !scalars
      84                 :             :  integer,intent(in) :: iout,ndtset,ndtset_alloc,npsp, comm
      85                 :             :  type(MPI_type),intent(in) :: mpi_enregs(0:ndtset_alloc)
      86                 :             : !arrays
      87                 :             :  type(dataset_type),intent(in) :: dtsets(0:ndtset_alloc)
      88                 :             :  type(pspheader_type),intent(in) :: pspheads(npsp)
      89                 :             : 
      90                 :             : !Local variables-------------------------------
      91                 :             : !scalars
      92                 :             :  integer :: bantot,fixed_mismatch,ia,iatom,ib,iband,idtset,ierr,iexit,ii,iimage,ikpt,intimage,ierrgrp!,ilang
      93                 :             :  integer :: ipsp,isppol,isym,itypat,iz,jdtset,jj,kk,lpawu,maxiatsph,maxidyn,minplowan_iatom,maxplowan_iatom
      94                 :             :  integer :: mband,miniatsph,minidyn,mod10,mpierr,all_nprocs
      95                 :             :  integer :: mu,natom,nfft,nfftdg,nkpt,nloc_mem,nlpawu
      96                 :             :  integer :: nproc,nthreads,nspden,nspinor,nsppol,optdriver,mismatch_fft_tnons,response !,so_psp
      97                 :             :  integer :: fftalg,fftalga,usepaw,usewvl
      98                 :             :  integer :: ttoldfe,ttoldff,ttolrff,ttolvrs,ttolwfr,ttoldmag
      99                 :             :  logical :: test,twvl,allowed,berryflag
     100                 :             :  logical :: wvlbigdft=.false.
     101                 :             :  logical :: xc_is_lda,xc_is_gga,xc_is_mgga,xc_is_hybrid,xc_is_pot_only,xc_need_kden
     102                 :             :  real(dp) :: dotval,dz,norm_spinat,norm_spinaxis,sumalch,summix,sumocc,ucvol,wvl_hgrid,zatom,zval
     103                 :             :  character(len=1000) :: msg
     104   [ +  +  +  +  :      183424 :  type(dataset_type) :: dt
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
             +  +  +  +  
                      + ]
     105                 :             :  character(len=fnlen) :: corewf_str
     106                 :             :  logical :: corewf_exist
     107                 :             : !arrays
     108                 :             :  integer :: cond_values(4)!,nprojmax(0:3)
     109                 :             :  integer :: gpu_devices(12)=(/-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2/)
     110                 :        1433 :  integer,allocatable :: ierr_dtset(:)
     111                 :             :  real(dp) :: gmet(3,3),gprimd(3,3),rmet(3,3),rprimd(3,3)
     112                 :        1433 :  real(dp),allocatable :: frac(:,:),tnons_new(:,:),xred(:,:), my_xred(:,:), xshift(:,:)
     113                 :             :  character(len=32) :: cond_string(4)
     114                 :             :  character(len=32) :: input_name
     115         [ +  + ]:        4299 :  type(libxc_functional_type) :: xcfunc(2)
     116                 :             : ! *************************************************************************
     117                 :             : 
     118                 :             :  DBG_ENTER("COLL")
     119                 :             : 
     120                 :        1433 :  all_nprocs = xmpi_comm_size(comm)
     121                 :             : 
     122                 :             : !Some initialisations
     123         [ +  + ]:        7165 :  cond_string(1:4)='#####'
     124                 :        1433 :  cond_values(1:4)=(/0,0,0,0/)
     125   [ -  +  +  -  :        4299 :  ABI_MALLOC(ierr_dtset,(ndtset_alloc))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     126         [ +  + ]:        8416 :  ierr_dtset=0
     127                 :             : 
     128                 :             : !Do loop on idtset (allocate statements are present)
     129         [ +  + ]:        8416 :  do idtset=1,ndtset_alloc
     130         [ -  + ]:        6983 :    if(mpi_enregs(idtset)%me<0) cycle
     131                 :        6983 :    jdtset=dtsets(idtset)%jdtset
     132         [ +  + ]:        6983 :    if(ndtset==0)jdtset=0
     133                 :        6983 :    ierr=0
     134                 :             : 
     135         [ +  + ]:        6983 :    if(jdtset/=0)then
     136                 :        6584 :      write(msg, '(a,a,a,i4,a)' ) ch10,' chkinp: Checking input parameters for consistency,',' jdtset=',jdtset,'.'
     137                 :             :    else
     138                 :         399 :      write(msg, '(a,a)' ) ch10,' chkinp: Checking input parameters for consistency.'
     139                 :             :    end if
     140                 :        6983 :    call wrtout(iout,msg)
     141                 :        6983 :    call wrtout(std_out,msg)
     142                 :             : 
     143                 :             :    ! Will test directly on the dataset "dt"
     144   [ -  +  -  +  :        6983 :    dt = dtsets(idtset)%copy()
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  + ]
     145                 :             : 
     146                 :             :    ! count nominal valence electrons according to ziontypat
     147                 :        6983 :    zval=zero
     148         [ +  + ]:       44983 :    do iatom=1,dt%natom
     149                 :       44983 :      zval=zval+dt%ziontypat(dt%typat(iatom))
     150                 :             :    end do
     151                 :             : 
     152                 :             :    ! Copy or initialize locally a few input dataset values
     153                 :        6983 :    fftalg   =dt%ngfft(7)
     154                 :        6983 :    fftalga  =fftalg/100!; fftalgc=mod(fftalg,10)
     155                 :             :    nthreads = xomp_get_num_threads(.true.)
     156                 :        6983 :    natom    =dt%natom
     157                 :        6983 :    nkpt     =dt%nkpt
     158                 :        6983 :    nspden   =dt%nspden
     159                 :        6983 :    nspinor  =dt%nspinor
     160                 :        6983 :    nsppol   =dt%nsppol
     161                 :        6983 :    optdriver=dt%optdriver
     162                 :        6983 :    usepaw   =dt%usepaw
     163                 :        6983 :    usewvl   =dt%usewvl
     164         [ +  + ]:        6983 :    intimage=1 ; if(dtsets(idtset)%nimage>2)intimage=2
     165   [ +  +  +  + ]:       90779 :    rprimd(:,:)=dtsets(idtset)%rprimd_orig(:,:,intimage)    ! For the purpose of checking symmetries
     166                 :        6983 :    response=0
     167                 :             :    if(dt%rfelfd/=0.or.dt%rfphon/=0.or.dt%rfstrs/=0.or.dt%rfddk/=0 &
     168                 :             : &   .or.dt%rf2_dkdk/=0.or.dt%rf2_dkde/=0.or.dt%rfmagn/=0.or.dt%d3e_pert1_elfd/=0 &
     169                 :             : &   .or.dt%d3e_pert2_elfd/=0.or.dt%d3e_pert3_elfd/=0.or.dt%d3e_pert1_phon/=0 &
     170   [ +  +  +  +  :        6983 : &   .or.dt%d3e_pert2_phon/=0.or.dt%d3e_pert3_phon/=0) response=1
          +  +  +  +  +  
          +  +  +  +  +  
          +  -  +  -  +  
             +  +  -  -  
                      + ]
     171                 :        6983 :    call metric(gmet,gprimd,-1,rmet,rprimd,ucvol)
     172                 :        6983 :    nproc=mpi_enregs(idtset)%nproc
     173                 :             : 
     174                 :             :    !  Some properties of the XC functional
     175         [ +  + ]:        6983 :    if (dt%ixc>=0) then
     176                 :        5802 :      xc_is_lda=((dt%ixc>=1.and.dt%ixc<=10).or.dt%ixc==50)
     177                 :        5802 :      xc_is_gga=((dt%ixc>=11.and.dt%ixc<=16).or.(dt%ixc>=23.and.dt%ixc<=39))
     178                 :        5802 :      xc_is_mgga=(dt%ixc>=31.and.dt%ixc<=35)
     179                 :        5802 :      xc_is_pot_only=.false.
     180                 :        5802 :      xc_is_hybrid=(dt%ixc==40.or.dt%ixc==41.or.dt%ixc==42)
     181   [ +  +  -  + ]:        5802 :      xc_need_kden=(dt%ixc==31.or.dt%ixc==34.or.dt%ixc==35)
     182                 :             :    else
     183                 :        1181 :      call libxc_functionals_init(dt%ixc,nspden,xc_functionals=xcfunc,xc_tb09_c=dt%xc_tb09_c)
     184                 :        1181 :      xc_is_lda=libxc_functionals_islda(xc_functionals=xcfunc)
     185                 :        1181 :      xc_is_gga=libxc_functionals_isgga(xc_functionals=xcfunc)
     186                 :        1181 :      xc_is_mgga=libxc_functionals_ismgga(xc_functionals=xcfunc)
     187                 :        1181 :      xc_is_pot_only=libxc_functionals_is_potential_only(xc_functionals=xcfunc)
     188                 :        1181 :      xc_is_hybrid=libxc_functionals_is_hybrid(xc_functionals=xcfunc)
     189                 :        1181 :      xc_need_kden=libxc_functionals_needs_tau(xc_functionals=xcfunc)
     190                 :        1181 :      call libxc_functionals_end(xc_functionals=xcfunc)
     191                 :             :    end if
     192                 :             : 
     193                 :             : !  =====================================================================================================
     194                 :             : !  Check the values of variables, using alphabetical order
     195                 :             : !  PLEASE: use the routines chkint_eq, chkint_ne, chkint_ge, chkint_le, chkdpr
     196                 :             : 
     197                 :             :    ! iomode Must be one of 0, 1, 3
     198                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'iomode',dt%iomode,3, [IO_MODE_FORTRAN,IO_MODE_MPI,IO_MODE_ETSF],iout)
     199                 :             :    !  However, if mpi_io is not enabled, must be one of 0, 3.
     200                 :             :    if(xmpi_mpiio==0)then
     201                 :             :      cond_string(1)='enable_mpi_io' ;  cond_values(1)=0
     202                 :             :      ! Make sure that iomode is 0 or 3
     203                 :             :      call chkint_eq(1,1,cond_string,cond_values,ierr,'iomode',dt%iomode,2,[IO_MODE_FORTRAN,IO_MODE_ETSF],iout)
     204                 :             :    end if
     205   [ -  +  -  - ]:        6983 :    if (dt%iomode == IO_MODE_NETCDF .and. dt%npspinor == 2) then
     206                 :           0 :      ABI_ERROR_NOSTOP("npspinor == 2 not compatible with netcdf", ierr)
     207                 :             :    end if
     208                 :             : 
     209                 :             :    ! accuracy
     210                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'accuracy',dt%accuracy,7,(/0,1,2,3,4,5,6/),iout)
     211                 :             : 
     212                 :             :    ! adpimd
     213                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'accuracy',dt%adpimd,2,(/0,1/),iout)
     214                 :             : 
     215                 :             :    ! amu Check that atomic masses are > 0 if ionmov = 1
     216         [ +  + ]:       14226 :    do iimage=1,dt%nimage
     217         [ +  + ]:       14226 :      if (dt%ionmov==1) then
     218         [ +  + ]:          14 :        do itypat=1,dt%ntypat
     219                 :           8 :          cond_string(1)='ionmov' ; cond_values(1)=dt%ionmov
     220                 :           8 :          write(input_name,'(a4,i2,a1,i2,a1)')'amu(',itypat,',',iimage,')'
     221                 :          14 :          call chkdpr(1,1,cond_string,cond_values,ierr,input_name,dt%amu_orig(itypat,iimage),1,tol8,iout)
     222                 :             :        end do
     223                 :             :      end if
     224                 :             :    end do
     225                 :             : 
     226                 :             :    ! autoparal
     227                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'autoparal',dt%autoparal,5,(/0,1,2,3,4/),iout)
     228   [ +  +  +  +  :        6983 :    if(dt%chkparal/=0.and.(dt%autoparal/=0.and.dt%optdriver/=RUNL_GSTATE)) then
                   -  + ]
     229                 :           0 :        cond_string(1)='optdriver' ; cond_values(1)=dt%optdriver
     230                 :           0 :        cond_string(2)='chkparal' ; cond_values(2)=dt%chkparal
     231                 :           0 :        call chkint_eq(2,2,cond_string,cond_values,ierr,'autoparal',dt%autoparal,1,(/0/),iout)
     232                 :             :    end if
     233         [ -  + ]:        6983 :    if (dt%gpu_option/=ABI_GPU_DISABLED) then ! At present (v10.8.1), autoparal is not available with GPU
     234                 :           0 :      cond_string(1)='gpu_option' ; cond_values(1)=dt%gpu_option
     235                 :           0 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'autoparal',dt%autoparal,1,(/0/),iout)
     236         [ #  # ]:           0 :      if(dt%autoparal/=0) then
     237                 :             :        write(msg,'(3a)')&
     238                 :           0 :         "autoparal is not supported with GPU enabled.",ch10,&
     239                 :           0 :         "Action: remove 'autoparal' from input and set 'np_spkpt' and 'npband' accordingly."
     240                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
     241                 :             :      end if
     242                 :             :    end if
     243                 :             : 
     244                 :             : 
     245                 :             :    ! auxc_scal
     246                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'auxc_scal',dt%auxc_scal,1,0.0_dp,iout)
     247                 :             : 
     248                 :             :    ! bdberry
     249                 :             :    if(dt%berryopt>0.and.dt%nberry>0.and.&
     250                 :             :       dt%berryopt/= 4.and.dt%berryopt/= 6.and.dt%berryopt/= 7.and.&
     251   [ +  +  +  - ]:        6983 :       dt%berryopt/=14.and.dt%berryopt/=16.and.dt%berryopt/=17) then
     252         [ #  # ]:           0 :      do ii=1,2*nsppol
     253                 :           0 :        cond_string(1)='berryopt' ; cond_values(1)=dt%berryopt
     254                 :           0 :        cond_string(2)='nberry'   ; cond_values(2)=dt%nberry
     255                 :           0 :        write(input_name,'(a4,i1,a1)')'bdberry(',ii,')'
     256                 :           0 :        call chkint_ge(2,2,cond_string,cond_values,ierr,input_name,dt%bdberry(ii),1,iout)
     257                 :             :      end do
     258                 :             :      ! bdberry(2) must be greater than bdberry(1)
     259                 :           0 :      cond_string(1)='berryopt' ; cond_values(1)=dt%berryopt
     260                 :           0 :      cond_string(2)='nberry'   ; cond_values(2)=dt%nberry
     261                 :           0 :      cond_string(3)='bdberry(1)'   ; cond_values(3)=dt%bdberry(1)
     262                 :           0 :      call chkint_ge(3,3,cond_string,cond_values,ierr,'bdberry(2)',dt%bdberry(2),dt%bdberry(1),iout)
     263         [ #  # ]:           0 :      if(nsppol==2)then
     264                 :             :        ! bdberry(4) must be greater than bdberry(3)
     265                 :           0 :        cond_string(1)='berryopt' ; cond_values(1)=dt%berryopt
     266                 :           0 :        cond_string(2)='nberry'   ; cond_values(2)=dt%nberry
     267                 :           0 :        cond_string(3)='bdberry(3)'   ; cond_values(3)=dt%bdberry(3)
     268                 :           0 :        call chkint_ge(3,3,cond_string,cond_values,ierr,'bdberry(4)',dt%bdberry(4),dt%bdberry(3),iout)
     269                 :             :      end if
     270                 :             :      ! Make sure all nband(nkpt) are >= bdberry
     271         [ #  # ]:           0 :      do isppol=1,nsppol
     272         [ #  # ]:           0 :        do ikpt=1,nkpt
     273         [ #  # ]:           0 :          if (dt%nband(ikpt+(isppol-1)*nkpt)<=dt%bdberry(2*isppol)) then
     274                 :           0 :            cond_string(1)='ikpt'   ; cond_values(1)=ikpt
     275                 :           0 :            cond_string(2)='isppol' ; cond_values(2)=isppol
     276                 :           0 :            cond_string(3)='nband'  ; cond_values(3)=dt%nband(ikpt+(isppol-1)*nkpt)
     277                 :             :            call chkint_le(0,3,cond_string,cond_values,ierr,&
     278                 :           0 :              'bdberry',dt%bdberry(2*isppol),dt%nband(ikpt+(isppol-1)*nkpt),iout)
     279         [ #  # ]:           0 :            if(ierr==1)exit
     280                 :             :          end if
     281                 :             :        end do
     282                 :             :      end do
     283                 :             :    end if
     284                 :             : 
     285                 :             :    !  berryopt must be between -3 to +4, 6,7,14,16,17
     286                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'berryopt',dt%berryopt,13,(/-3,-2,-1,0,1,2,3,4,6,7,14,16,17/),iout)
     287                 :             :    ! berryopt must be positive when mkmem==0
     288         [ -  + ]:        6983 :    if(dt%mkmem==0)then
     289                 :           0 :      cond_string(1)='mkmem' ; cond_values(1)=dt%mkmem
     290                 :           0 :      call chkint_ge(1,1,cond_string,cond_values,ierr,'berryopt',dt%berryopt,0,iout)
     291                 :             :    end if
     292                 :             :    !  berryopt must be positive when occopt/=1
     293         [ +  + ]:        6983 :    if(dt%occopt/=1)then
     294                 :        2997 :      cond_string(1)='occopt' ; cond_values(1)=dt%occopt
     295                 :        2997 :      call chkint_ge(1,1,cond_string,cond_values,ierr,'berryopt',dt%berryopt,0,iout)
     296                 :             :    end if
     297                 :             :    !  berryopt cannot be 4,6,7,14,16,17 when toldfe, tolvrs, toldff and tolrff are zero (or negative)
     298   [ +  +  +  +  :       48725 :    if (any(dt%berryopt== [4,6,7,14,16,17] ) ) then
                   +  + ]
     299                 :          26 :      cond_string(1)='berryopt' ; cond_values(1)=dt%berryopt
     300                 :             :      call chkdpr(1,1,cond_string,cond_values,ierr,'max(toldfe,toldff,tolrff,tolvrs,toldmag)',&
     301                 :          26 :        max(dt%toldfe,dt%toldff,dt%tolrff,dt%tolvrs,dt%toldmag),1,tol16*tol16,iout)
     302                 :             :    endif
     303                 :             :    ! Non-zero berryopt and usepaw==1 cannot be done unless response==0
     304   [ +  +  +  + ]:        6983 :    if (usepaw==1.and.dt%berryopt/=0) then
     305                 :          30 :      cond_string(1)='usepaw' ; cond_values(1)=usepaw
     306                 :          30 :      cond_string(2)='berryopt' ; cond_values(2)=dt%berryopt
     307                 :          30 :      call chkint_eq(1,2,cond_string,cond_values,ierr,'response',response,1,(/0/),iout)
     308                 :             :    end if
     309                 :             : !  Non-zero berryopt and usepaw==1 and kptopt/=3 cannot be done unless symmorphi=0
     310                 :             : !  (that is, nonsymmorphic symmetries do not work yet
     311                 :             : !  Update MT 2017-05-31: nonsymmorphic symmetries seem also to be an issue for NCPP
     312   [ +  +  +  +  :        6983 :    if (usepaw==1.and.dt%berryopt/=0.and.dt%kptopt/=3) then
                   +  + ]
     313                 :             :   !if (clldt%berryopt/=0.and.dt%kptopt/=3) then
     314                 :          26 :      cond_string(1)='usepaw'; cond_values(1)=usepaw
     315                 :          26 :      cond_string(2)='berryopt'; cond_values(2)=dt%berryopt
     316                 :          26 :      cond_string(3)='kptopt'; cond_values(3)=dt%kptopt
     317                 :          26 :      call chkint_eq(1,3,cond_string,cond_values,ierr,'symmorphi',dt%symmorphi,1,(/0/),iout)
     318                 :             :    end if
     319                 :             : !  Restrictions for berryopt=4,6,7,14,16,17
     320                 :        6983 :    if (usepaw==1.and.&
     321                 :             :       (dt%berryopt== 4.or.dt%berryopt== 6.or.dt%berryopt== 7.or.&
     322                 :             :        dt%berryopt==14.or.dt%berryopt==16.or.dt%berryopt==17)) then
     323                 :             : !     if (nsppol==2.and.nproc>1) then
     324                 :             : !       write(msg,'(3a)') &
     325                 :             : !&       'For berryopt = 4,6,7,14,16,17 and nsppol=2, nproc must = 1 ',ch10,&
     326                 :             : !&       'Action: change number of processes'
     327                 :             : !       ABI_ERROR_NOSTOP(msg, ierr)
     328                 :             : !     end if
     329                 :             :    end if
     330                 :             : !  berryopt.GE.4 and usepaw==1 and kpt // requires nproc to be a divisor of nkpt
     331   [ +  +  +  +  :        6983 :    if (usepaw==1 .and. dt%berryopt.GE.4 .and. nproc>1 .and. mod(dt%nkpt,nproc)/=0) then
             +  +  -  + ]
     332                 :             :      write(msg, '(3a)' )&
     333                 :           0 :       'For berryopt >= 4 with PAW in parallel, nproc must be a divisor of nkpt ',ch10,&
     334                 :           0 :       'Action: change number of processes or kpts such that nproc divides nkpt evenly'
     335                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
     336                 :             :    end if
     337                 :             : 
     338                 :             :    ! Finite electric/displacement field checks
     339         [ +  + ]:        6983 :    if (dt%berryopt==4) then
     340                 :             :      if (maxval(abs(dt%dfield(1:3)))>tiny(0.0_dp).or.&
     341                 :             :          maxval(abs(dt%red_dfield(1:3)))>tiny(0.0_dp).or.&
     342   [ -  +  +  -  :         442 :          maxval(abs(dt%red_efield(1:3)))>tiny(0.0_dp).or.&
          +  +  -  +  +  
          -  +  +  -  +  
          +  -  +  +  -  
          +  +  -  +  +  
          +  -  +  -  +  
                -  -  + ]
     343                 :             :          maxval(abs(dt%red_efieldbar(1:3)))>tiny(0.0_dp)) then
     344                 :             :        write(msg,'(5a)' ) &
     345                 :           0 :         'When berryopt==4, only efield is needed, other input field',ch10,&
     346                 :           0 :         '(dfield,red_dfield,red_efield,red_efieldbar) should be zero.',ch10,&
     347                 :           0 :         'Action: delete unneeded field in input file.'
     348                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
     349                 :             :      end if
     350                 :             :    end if
     351         [ -  + ]:        6983 :    if (dt%berryopt==14) then
     352                 :             :      if (maxval(abs(dt%dfield(1:3)))>tiny(0.0_dp).or.&
     353                 :             :          maxval(abs(dt%red_dfield(1:3)))>tiny(0.0_dp).or.&
     354   [ #  #  #  #  :           0 :          maxval(abs(dt%red_efield(1:3)))>tiny(0.0_dp).or.&
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                #  #  # ]
     355                 :             :          maxval(abs(dt%efield(1:3)))>tiny(0.0_dp)) then
     356                 :             :        write(msg,'(5a)') &
     357                 :           0 :         'When berryopt==14, only red_efieldbar is needed, other input field',ch10,&
     358                 :           0 :         '(dfield,red_dfield,efield,red_efield) should be zero.',ch10,&
     359                 :           0 :         'Action: delete unneeded field in input file.'
     360                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
     361                 :             :      end if
     362                 :             :    end if
     363         [ -  + ]:        6983 :    if (dt%berryopt==6) then
     364                 :             :      if (maxval(abs(dt%red_dfield(1:3)))>tiny(0.0_dp).or.&
     365   [ #  #  #  #  :           0 :          maxval(abs(dt%red_efield(1:3)))>tiny(0.0_dp).or.&
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
             #  #  #  #  
                      # ]
     366                 :             :          maxval(abs(dt%red_efieldbar(1:3)))>tiny(0.0_dp)) then
     367                 :             :        write(msg,'(5a)') &
     368                 :           0 :          'When berryopt==6, only dfield and efield are needed, other input field',ch10,&
     369                 :           0 :          '(red_dfield,red_efield,red_efieldbar) should be zero.',ch10,&
     370                 :           0 :          'Action: delete unneeded field in input file.'
     371                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
     372                 :             :      end if
     373                 :             :    end if
     374         [ -  + ]:        6983 :    if (dt%berryopt==16) then
     375                 :             :      if (maxval(abs(dt%dfield(1:3)))>tiny(0.0_dp).or.&
     376   [ #  #  #  #  :           0 :          maxval(abs(dt%efield(1:3)))>tiny(0.0_dp).or.&
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
             #  #  #  #  
                      # ]
     377                 :             :          maxval(abs(dt%red_efieldbar(1:3)))>tiny(0.0_dp)) then
     378                 :             :        write(msg,'(5a)')  &
     379                 :           0 :          'When berryopt==16, only red_dfield and red_efield are needed, other input field',ch10,&
     380                 :           0 :          '(dfield,efield,red_efieldbar) should be zero.',ch10,&
     381                 :           0 :          'Action: delete unneeded field in input file.'
     382                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
     383                 :             :      end if
     384                 :             :    end if
     385         [ -  + ]:        6983 :    if (dt%berryopt==17) then
     386                 :             :      if (maxval(abs(dt%dfield(1:3)))>tiny(0.0_dp).or.&
     387   [ #  #  #  #  :           0 :          maxval(abs(dt%efield(1:3)))>tiny(0.0_dp).or.&
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
             #  #  #  #  
                      # ]
     388                 :             :          maxval(abs(dt%red_efield(1:3)))>tiny(0.0_dp)) then
     389                 :             :        write(msg,'(5a)') &
     390                 :           0 :         'When berryopt==17, only red_dfield and red_efieldbar are needed, other input field',ch10,&
     391                 :           0 :         '(dfield,efield,red_efield) should be zero.',ch10,&
     392                 :           0 :         'Action: delete unneeded field in input file.'
     393                 :           0 :         ABI_ERROR_NOSTOP(msg, ierr)
     394                 :             :      end if
     395                 :             :      if ((dt%jfielddir(1)/=1.and.dt%jfielddir(1)/=2).or.&
     396   [ #  #  #  #  :           0 :          (dt%jfielddir(2)/=1.and.dt%jfielddir(2)/=2).or.&
                   #  # ]
     397                 :             :          (dt%jfielddir(3)/=1 .and.dt%jfielddir(3)/=2)) then
     398                 :             :        write(msg,'(5a)') &
     399                 :           0 :         'When berryopt==17, jfielddir can only be 1 or 2 to controls whether reduced electric field',ch10,&
     400                 :           0 :         '(jfielddir=1) or reduced electric displacement field (jfielddir=2) is chosen to be fixed', ch10,&
     401                 :           0 :         'Action: change jfielddir to be 1 or 2 in input file.'
     402                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
     403                 :             :      end if
     404                 :             :    end if
     405                 :             : 
     406                 :             : !  berrystep
     407                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'berrystep',dt%berrystep,1,iout)
     408         [ +  + ]:        6983 :    if(nproc>1)then
     409                 :        1234 :      cond_string(1)='nproc'; cond_values(1)=mpi_enregs(idtset)%nproc
     410                 :        1234 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'berrystep',dt%berrystep,1,(/1/),iout)
     411                 :             :    end if
     412                 :             : 
     413                 :             : !  boxcutmin
     414                 :             : !  if(response==1)then
     415                 :             : !    cond_string(1)='response' ; cond_values(1)=response
     416                 :             : !    call chkdpr(1,1,cond_string,cond_values,ierr,'boxcutmin',dt%boxcutmin,1,two,iout)
     417                 :             : !  end if
     418                 :             : 
     419                 :             :    ! builtintest
     420                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'builtintest',dt%builtintest,8,(/0,1,2,3,4,5,6,7/),iout)
     421                 :             : 
     422                 :             :    ! cellcharge
     423                 :             :    ! The value of cellcharge cannot change between images, except when imgmov=6 and (occopt=0 or occopt=2)
     424   [ +  +  -  + ]:        6983 :    if(dt%imgmov/=6 .or. (dt%occopt/=0 .and. dt%occopt/=2))then
     425         [ +  + ]:       14208 :      do iimage=1,dt%nimage
     426         [ -  + ]:       14214 :        if(abs(dt%cellcharge(iimage)-dt%cellcharge(1))>tol8)then
     427                 :           0 :          write(msg, '(2a,i4,a,i4,2a,es12.4,a,i4,es12.4)' )ch10,&
     428                 :           0 :          ' chkinp : imgmov=',dt%imgmov,', occopt=',dt%occopt,ch10,&
     429                 :           0 :          ' chkinp : cellcharge(1)=',dt%cellcharge(1),', while for image=',iimage,', cellcharge=',dt%cellcharge(iimage)
     430                 :           0 :          call wrtout(iout,msg)
     431                 :           0 :          call wrtout(std_out,  msg)
     432                 :             :          write(msg, '(a,i4,2a,i4,2a,f8.2,4a)' )&
     433                 :           0 :           ' This is not allowed: cellcharge is allowed to vary only when imgmov=6 and occopt=0 or 2.',ch10,&
     434                 :           0 :           ' Action: check the content of the input variables cellcharge, imgmov anf occopt.'
     435                 :           0 :          ABI_ERROR_NOSTOP(msg, ierr)
     436                 :             :        end if
     437                 :             :      end do
     438                 :             :    end if
     439                 :             : 
     440                 :             : !  chebfi_oracle: must be 0,1,2
     441                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'chebfi_oracle',dt%chebfi_oracle,3,(/0,1,2/),iout)
     442         [ -  + ]:        6983 :    if (dt%gpu_option/=ABI_GPU_DISABLED) then ! At present (v10.2.2), chebfi oracle is not available with GPU
     443                 :           0 :      cond_string(1)='gpu_option' ; cond_values(1)=dt%gpu_option
     444                 :           0 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'chebfi_oracle',dt%chebfi_oracle,1,(/0/),iout)
     445                 :             :    end if
     446                 :             : 
     447                 :             : !  oracle_factor: must be > 1e-30 and below 1
     448                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'oracle_factor',dt%oracle_factor,1,tol30,iout)
     449                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'oracle_factor',dt%oracle_factor,-1,0.99_dp,iout)
     450                 :             : 
     451                 :             : !  oracle_min_occ: must be > 1e-10 and below 1
     452                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'oracle_min_occ',dt%oracle_factor,1,tol10,iout)
     453                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'oracle_min_occ',dt%oracle_factor,-1,0.99_dp,iout)
     454                 :             : 
     455                 :             : !  chkdilatmx
     456                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'chkdilatmx',dt%chkdilatmx,2,(/0,1/),iout)
     457                 :             : 
     458                 :             : !  chkparal
     459                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'chkparal',dt%chkparal,2,(/0,1/),iout)
     460                 :             : 
     461                 :             : !  chksymbreak
     462                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'chksymbreak',dt%chksymbreak,2,(/0,1/),iout)
     463                 :             : 
     464                 :             : !  chksymtnons
     465                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'chksymtnons',dt%chksymtnons,4,(/0,1,2,3/),iout)
     466                 :             : 
     467         [ +  + ]:        6983 :    if(dt%chksymtnons>0)then
     468                 :             : !    Check the values of tnons
     469   [ -  +  +  -  :       19377 :      ABI_MALLOC(tnons_new,(3,dt%nsym))
          +  -  +  -  -  
                +  -  + ]
     470   [ -  +  +  -  :       19377 :      ABI_MALLOC(xred,(3,dt%natom))
          +  -  +  -  -  
                +  -  + ]
     471   [ +  +  +  + ]:      154123 :      xred(:,:)=dt%xred_orig(:,1:dt%natom,1)
     472                 :             :      ! Use the largest significant value of tolsym, namely, one.
     473                 :             :      call symmetrize_xred(dt%natom,dt%nsym,dt%symrel,dt%tnons,xred,&
     474                 :        6459 :        fixed_mismatch=fixed_mismatch,mismatch_fft_tnons=mismatch_fft_tnons,tnons_new=tnons_new,tolsym=one)
     475         [ -  + ]:        6459 :      ABI_FREE(tnons_new)
     476                 :             : 
     477         [ +  + ]:        6459 :      if(mismatch_fft_tnons/=0)then
     478         [ +  - ]:           2 :        if(fixed_mismatch==1)then
     479                 :           2 :          write(msg, '(2a)' ) ch10,' chkinp: COMMENT -'
     480                 :           2 :          call wrtout(std_out,msg)
     481                 :             :          write(msg, '(4a,3es20.10)' )  &
     482                 :           2 :           '   Found potentially symmetry-breaking value of tnons (see input variable chksymtnons). ', ch10,&
     483                 :           2 :           '   The following shift of all reduced symmetry-corrected atomic positions might possibly remove this problem:',ch10,&
     484         [ +  + ]:          10 :           xred(:,1)-dt%xred_orig(:,1,1)
     485                 :           2 :          call wrtout(std_out,msg)
     486                 :           2 :          call wrtout(iout,msg)
     487                 :           2 :          write(msg, '(4a)' ) ch10,&
     488                 :           2 :           '   For your convenience, you might cut+paste the shifted new atomic positions (for image 1 only):',ch10,&
     489                 :           4 :           '   xred'
     490                 :           2 :          call wrtout(std_out,msg)
     491                 :           2 :          call wrtout(iout,msg)
     492         [ +  + ]:          19 :          do iatom=1,dt%natom
     493                 :          17 :            write(msg,'(a,3es20.10)') '        ',xred(:,iatom)
     494                 :          17 :            call wrtout(std_out,msg)
     495                 :          19 :            call wrtout(iout,msg)
     496                 :             :          enddo
     497                 :           2 :          call wrtout(std_out,' ')
     498                 :             :        endif
     499                 :             : 
     500         [ -  + ]:           2 :        if(dt%chksymtnons==1 .or. dt%chksymtnons==3)then
     501                 :           0 :          write(msg, '(8a,i4,2a,9i3,2a,3es20.10,11a)' ) ch10,&
     502                 :           0 :           ' chkinp: ERROR -',ch10,&
     503                 :           0 :           '   Chksymtnons=1 or 3 . Found potentially symmetry-breaking value of tnons, ', ch10,&
     504                 :           0 :           '   which is neither a rational fraction in 1/8th nor in 1/12th (1/9th and 1/10th are tolerated also):', ch10,&
     505                 :           0 :           '   for the symmetry number ',mismatch_fft_tnons,ch10,&
     506                 :           0 :           '   symrel is ',dt%symrel(1:3,1:3,mismatch_fft_tnons),ch10,&
     507                 :           0 :           '   tnons is ',dt%tnons(1:3,mismatch_fft_tnons),ch10,&
     508                 :           0 :           '   So, your atomic positions are not aligned with the FFT grid.',ch10,&
     509                 :           0 :           '   Please, read the description of the input variable chksymtnons.',ch10,&
     510                 :           0 :           '   If you are planning cDFT, GW or BSE calculations, such tnons value is very problematic.',ch10,&
     511                 :           0 :           '   Otherwise, you might set chksymtnons=0.',&
     512                 :           0 :           '   But do not be surprised if ABINIT does not converge for cDFT, or crashes for GW or BSE.',ch10,&
     513                 :           0 :           '   Better solution: you might shift your atomic positions to better align the FFT grid and the symmetry axes.'
     514                 :           0 :          call wrtout(std_out,msg)
     515         [ #  # ]:           0 :          if(fixed_mismatch==1)then
     516                 :             :            write(msg, '(a)' )&
     517                 :           0 :            '   ABINIT has detected such a possible shift. See the suggestion given in the COMMENT above (or in output or log file).'
     518                 :           0 :            call wrtout(std_out,msg, do_flush=.True.)
     519                 :             :          endif
     520                 :           0 :          ierr=ierr+1 ! Previously a warning: for slab geometries arbitrary tnons can appear along the vacuum direction.
     521                 :             :                      ! But then simply set chksymtnons=0 ...
     522                 :             :        endif
     523                 :             :      endif
     524         [ -  + ]:        6459 :      ABI_FREE(xred)
     525                 :             :    end if
     526                 :             : 
     527                 :             : !  constraint_kind
     528         [ +  + ]:       15610 :    do itypat=1,dt%ntypat
     529                 :        8627 :      cond_string(1)='itypat';cond_values(1)=itypat
     530                 :             :      call chkint_eq(0,1,cond_string,cond_values,ierr,'constraint_kind',dt%constraint_kind(itypat),&
     531                 :        8627 :        10,(/0,1,2,3,4,10,11,12,13,14/),iout)
     532                 :             :      !Only potential self-consistency is currently allowed with constrained_dft
     533         [ +  + ]:        8627 :      if (dt%iscf>10) then
     534                 :        1542 :        cond_string(1)='itypat';cond_values(1)=itypat
     535                 :        1542 :        cond_string(2)='iscf';cond_values(2)=dt%iscf
     536                 :        1542 :        call chkint_eq(2,2,cond_string,cond_values,ierr,'constraint_kind',dt%constraint_kind(itypat),1,(/0/),iout)
     537                 :             :      endif
     538         [ +  + ]:        8627 :      if (dt%ionmov==4) then
     539                 :           6 :        cond_string(1)='itypat';cond_values(1)=itypat
     540                 :           6 :        cond_string(2)='ionmov';cond_values(2)=dt%ionmov
     541                 :           6 :        call chkint_eq(2,2,cond_string,cond_values,ierr,'constraint_kind',dt%constraint_kind(itypat),1,(/0/),iout)
     542                 :             :      endif
     543         [ +  + ]:        8627 :      if (dt%nspden==2) then
     544                 :        1921 :        cond_string(1)='itypat';cond_values(1)=itypat
     545                 :        1921 :        cond_string(2)='nspden';cond_values(2)=dt%nspden
     546                 :        1921 :        call chkint_eq(2,2,cond_string,cond_values,ierr,'constraint_kind',dt%constraint_kind(itypat),8,(/0,1,2,3,10,11,12,13/),iout)
     547                 :             :      endif
     548         [ +  + ]:       15610 :      if (dt%chksymtnons==1 .or. dt%chksymtnons==2) then
     549                 :        7945 :        cond_string(1)='itypat';cond_values(1)=itypat
     550                 :        7945 :        cond_string(2)='chksymtnons';cond_values(2)=dt%chksymtnons
     551                 :        7945 :        call chkint_eq(2,2,cond_string,cond_values,ierr,'constraint_kind',dt%constraint_kind(itypat),1,(/0/),iout)
     552                 :             :      endif
     553                 :             : 
     554                 :             :    enddo
     555                 :             : 
     556                 :             : !  cprj_in_memory
     557         [ +  + ]:        6983 :    if (dt%cprj_in_memory/=0) then
     558         [ -  + ]:         162 :      if (dt%optdriver/=RUNL_GSTATE) then
     559                 :           0 :        ABI_ERROR_NOSTOP('cprj_in_memory/=0 is implemented only for ground state (optdriver=0).',ierr)
     560                 :             :      else
     561         [ -  + ]:         162 :        if (dt%useylm /= 1) then
     562                 :           0 :          ABI_ERROR_NOSTOP('cprj_in_memory/=0 requires the input variable "useylm" to be 1',ierr)
     563                 :             :        end if
     564         [ -  + ]:         162 :        ABI_CHECK(dt%gpu_option==0,"cprj_in_memory/=0 is not implemented for GPUs. Change cprj_in_memory or gpu_option.")
     565                 :         162 :        write(msg,'(a)') "cprj_in_memory/=0 is not compatible with use_gemm_nonlop/=0. Change cprj_in_memory or use_gemm_nonlop."
     566         [ -  + ]:         162 :        ABI_CHECK(dt%use_gemm_nonlop==0,msg)
     567   [ +  +  +  -  :         162 :        test = dt%wfoptalg==10 .or. dt%wfoptalg==114 .or. dt%wfoptalg==111 .or. dt%wfoptalg==112
                   -  - ]
     568                 :         162 :        write(msg,'(a)') "With cprj_in_memory/=0, only wfoptalg==10,114,112 or 111 are implemented. Change cprj_in_memory or wfoptalg."
     569         [ -  + ]:         162 :        ABI_CHECK(test,msg)
     570         [ -  + ]:         162 :        ABI_CHECK(dt%rmm_diis==0, "With cprj_in_memory/=0, rmm_diis/=0 is not implemented. Change cprj_in_memory or rmm_diis.")
     571         [ -  + ]:         162 :        ABI_CHECK(dt%berryopt==0, "With cprj_in_memory/=0, berryopt/=0 is not implemented. Change cprj_in_memory or berryopt.")
     572         [ -  + ]:         162 :        ABI_CHECK(dt%usefock==0, "With cprj_in_memory/=0, usefock/=0 is not implemented. Change cprj_in_memory or usefock.")
     573   [ +  +  +  + ]:        1618 :        test = sum(abs(dt%nucdipmom))<tol16
     574         [ -  + ]:         162 :        ABI_CHECK(test,"With cprj_in_memory/=0, nuclear dipolar moments are not implemented. Change cprj_in_memory or nucdipmom.")
     575                 :             :        !
     576                 :         162 :        test=dt%cprj_in_memory==0.or.dt%cprj_in_memory==1.or.dt%cprj_in_memory==2
     577                 :         162 :        write(msg,'(a)') "cprj_in_memory must 0 (not used), 1 (LOBPCG or Chebfi) or 2 (Conjugate Gradient). Change cprj_in_memory."
     578         [ -  + ]:         162 :        ABI_CHECK(test,msg)
     579   [ +  +  +  - ]:         162 :        test = dt%usepaw==1.or.dt%nspinor==1
     580                 :         162 :        write(msg,'(a,a)') "With cprj_in_memory/=0, nspinor=2 is not available with Norm-Concerving pseudo-potentials.",&
     581                 :         324 :          " Use nspinor=1, or PAW pseudos, or set cprj_in_memory to 0."
     582         [ -  + ]:         162 :        ABI_CHECK(test,msg)
     583   [ +  -  -  + ]:         162 :        if (dt%cprj_in_memory==1.and.dt%wfoptalg==10) then
     584                 :           0 :          ABI_ERROR_NOSTOP('cprj_in_memory must be 2 for Conjugate Gradient (not 1).',ierr)
     585                 :             :        end if
     586   [ -  +  -  - ]:         162 :        if (dt%cprj_in_memory==2.and.(dt%wfoptalg==114.or.dt%wfoptalg==111)) then
     587                 :           0 :          dt%cprj_in_memory=1
     588                 :           0 :          ABI_ERROR_NOSTOP('cprj_in_memory must be 1 for LOBPCG or Chebfi (not 2).',ierr)
     589                 :             :        end if
     590   [ +  +  -  + ]:         162 :        if (dt%wfoptalg/=111.and.dt%xg_nonlop_option/=0) then
     591                 :           0 :          dt%xg_nonlop_option=0
     592                 :           0 :          ABI_ERROR_NOSTOP('xg_nonlop_option/=0 is useful only for Chebfi (wfoptalg=111).',ierr)
     593                 :             :        end if
     594                 :             :      end if
     595                 :             :    end if
     596                 :             : 
     597                 :             : !  spectrum slicing
     598   [ +  +  -  + ]:        6983 :    if (dt%wfoptalg/=112 .and. dt%paral_slice/=0) then
     599                 :           0 :        ABI_ERROR_NOSTOP("paral_slice is useful only for Spectrum Slicing (wfoptalg=112).", ierr)
     600                 :             :    end if
     601                 :             : 
     602                 :             : !  d3e_pert1_atpol
     603                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'d3e_pert1_atpol(1)',dt%d3e_pert1_atpol(1),1,iout)
     604                 :        6983 :    cond_string(1)='natom' ; cond_values(1)=natom
     605                 :        6983 :    call chkint_le(1,1,cond_string,cond_values,ierr,'d3e_pert1_atpol(2)',dt%d3e_pert1_atpol(2),natom,iout)
     606                 :             : 
     607                 :             : !  d3e_pert2_atpol
     608                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'d3e_pert2_atpol(1)',dt%d3e_pert2_atpol(1),1,iout)
     609                 :        6983 :    cond_string(1)='natom' ; cond_values(1)=natom
     610                 :        6983 :    call chkint_le(1,1,cond_string,cond_values,ierr,'d3e_pert2_atpol(2)',dt%d3e_pert2_atpol(2),natom,iout)
     611                 :             : 
     612                 :             : !  d3e_pert3_atpol
     613                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'d3e_pert3_atpol(1)',dt%d3e_pert3_atpol(1),1,iout)
     614                 :        6983 :    cond_string(1)='natom' ; cond_values(1)=natom
     615                 :        6983 :    call chkint_le(1,1,cond_string,cond_values,ierr,'d3e_pert3_atpol(2)',dt%d3e_pert3_atpol(2),natom,iout)
     616                 :             : 
     617                 :             : !  d3e_pert1_magat
     618                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'d3e_pert1_magat(1)',dt%d3e_pert1_magat(1),1,iout)
     619                 :        6983 :    cond_string(1)='natom' ; cond_values(1)=natom
     620                 :        6983 :    call chkint_le(1,1,cond_string,cond_values,ierr,'d3e_pert1_magat(2)',dt%d3e_pert1_magat(2),natom,iout)
     621                 :             : 
     622                 :             : !  d3e_pert2_magat
     623                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'d3e_pert2_magat(1)',dt%d3e_pert2_magat(1),1,iout)
     624                 :        6983 :    cond_string(1)='natom' ; cond_values(1)=natom
     625                 :        6983 :    call chkint_le(1,1,cond_string,cond_values,ierr,'d3e_pert2_magat(2)',dt%d3e_pert2_magat(2),natom,iout)
     626                 :             : 
     627                 :             : !  densfor_pred
     628         [ +  + ]:        6983 :    if(dt%iscf>0)then
     629                 :        6268 :      cond_string(1)='iscf';cond_values(1)=dt%iscf
     630                 :        6268 :      call chkint_le(0,1,cond_string,cond_values,ierr,'densfor_pred',dt%densfor_pred,6,iout)
     631                 :        6268 :      call chkint_ge(0,1,cond_string,cond_values,ierr,'densfor_pred',dt%densfor_pred,-6,iout)
     632   [ -  +  -  -  :        6268 :      if (dt%densfor_pred<0.and.mod(dt%iprcel,100)>=61.and.(dt%iprcel<71.or.dt%iprcel>79)) then
                   -  - ]
     633                 :           0 :        cond_string(1)='iscf';cond_values(1)=dt%iscf
     634                 :           0 :        cond_string(2)='iprcel';cond_values(2)=dt%iprcel
     635                 :           0 :        call chkint_ge(1,2,cond_string,cond_values,ierr,'densfor_pred',dt%densfor_pred,0,iout)
     636                 :             :      end if
     637                 :             :      ! densfor_pred<0 not valid for mGGA
     638                 :             :      ! Yet it is but contribution from Laplacian and/or kin. ene. density are not taken into account
     639                 :             :      !if(dt%densfor_pred<0.and.xc_is_mgga.and.dt%iscf>=10)then
     640                 :             :      !  msg='densfor_pred<0 (full correction for forces) is not allowed for density mixing and meta-GGA XC!'
     641                 :             :      !  ABI_ERROR_NOSTOP(msg, ierr)
     642                 :             :      !end if
     643                 :             :    end if
     644                 :             : 
     645                 :             : !  diecut
     646         [ +  + ]:        6983 :    if(dt%iscf==-1)then
     647                 :          22 :      cond_string(1)='iscf' ; cond_values(1)=dt%iscf
     648                 :          22 :      cond_string(2)='4*ecut==diecut' ; cond_values(2)=0
     649                 :             : !    Checks that presently diecut is 4*ecut
     650                 :          22 :      call chkdpr(1,2,cond_string,cond_values,ierr,'diecut',dt%diecut,0,4*dt%ecut,iout)
     651                 :             :    end if
     652                 :             : 
     653                 :             : !  diemac
     654                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'diemac',dt%diemac,1,0.01_dp,iout)
     655                 :             : 
     656                 :             : !  dilatmx
     657                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'dilatmx',dt%dilatmx,1,zero,iout)
     658         [ +  + ]:        6983 :    if(dt%chkdilatmx==1)then
     659                 :        6941 :      cond_string(1)='chkdilatmx' ; cond_values(1)=dt%chkdilatmx
     660                 :             : !    Checks that presently chkdilatmx is smaller than 1.15
     661                 :        6941 :      call chkdpr(1,1,cond_string,cond_values,ierr,'dilatmx',dt%dilatmx,-1,1.15_dp,iout)
     662                 :             :    end if
     663         [ +  + ]:        6983 :    if (dt%optdriver/=RUNL_GSTATE) then
     664                 :        1322 :      cond_string(1)='optdriver' ; cond_values(1)=dt%optdriver
     665                 :             :      ! Checks that presently dilatmx is 1 if optdriver is not GSTATE
     666                 :        1322 :      call chkdpr(1,1,cond_string,cond_values,ierr,'dilatmx',dt%dilatmx,0,1._dp,iout)
     667                 :             :    end if
     668                 :             :    ! Warn the user if dilatmx > 1 and optcell == 0.
     669   [ +  +  +  + ]:        6983 :    if (dt%dilatmx>one.and.dt%optcell==0) then
     670                 :             :      write(msg, "(a)") 'dilatmx > 1 and optcell=0, this is a waste of resources (computational time and memory). &
     671                 :          86 :      & You should set dilatmx to 1.'
     672                 :          86 :      ABI_WARNING(msg)
     673                 :             :    end if
     674                 :             : 
     675                 :             : !  dmatpuopt
     676         [ +  + ]:        6983 :    if (dt%usepawu>0) then
     677                 :         142 :      cond_string(1)='usepawu' ; cond_values(1)=dt%usepawu
     678                 :         142 :      call chkint_eq(0,1,cond_string,cond_values,ierr,'dmatpuopt',dt%dmatpuopt,10,(/1,2,3,4,5,6,7,8,9,10/),iout)
     679                 :             :    end if
     680                 :             : 
     681                 :             : !  dmatudiag
     682         [ +  + ]:        6983 :    if (dt%usepawu>0) then
     683                 :         142 :      cond_string(1)='usepawu' ; cond_values(1)=dt%usepawu
     684                 :         142 :      call chkint_eq(0,1,cond_string,cond_values,ierr,'dmatudiag',dt%dmatudiag,3,(/0,1,2/),iout)
     685                 :             :    end if
     686                 :             : 
     687                 :             : 
     688                 :             : !  dmftbandi, dmftbandf
     689         [ +  + ]:        6983 :    if (dt%usedmft>0.and.dt%usedmft/=10) then
     690                 :          43 :      cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     691                 :          43 :      call chkint_eq(0,1,cond_string,cond_values,ierr,'dmftcheck',dt%dmftcheck,4,(/-1,0,1,2/),iout)
     692         [ +  + ]:          43 :      if(dt%dmftcheck/=-1) then
     693                 :             : 
     694                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     695                 :          42 :        call chkint_eq(1,1,cond_string,cond_values,ierr,'occopt',dt%occopt,1,(/3/),iout)
     696                 :             : 
     697                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     698                 :          42 :        call chkint_ge(0,1,cond_string,cond_values,ierr,'dmftbandi',dt%dmftbandi,1,iout)
     699                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     700                 :          42 :        call chkint_ge(0,1,cond_string,cond_values,ierr,'dmftbandf',dt%dmftbandf,dt%dmftbandi,iout)
     701                 :             : 
     702                 :          42 :        cond_string(1)='mband' ; cond_values(1)=dt%mband
     703                 :          42 :        call chkint_le(0,1,cond_string,cond_values,ierr,'dmftbandi',dt%dmftbandi,dt%mband,iout)
     704                 :          42 :        cond_string(1)='mband' ; cond_values(1)=dt%mband
     705                 :          42 :        call chkint_le(0,1,cond_string,cond_values,ierr,'dmftbandf',dt%dmftbandf,dt%mband,iout)
     706                 :             : 
     707                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     708                 :          42 :        call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_entropy',dt%dmft_entropy,0,iout)
     709                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     710                 :          42 :        call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_iter',dt%dmft_iter,0,iout)
     711                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     712                 :          42 :        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_kspectralfunc',dt%dmft_kspectralfunc,2,(/0,1/),iout)
     713                 :             : 
     714         [ +  + ]:          42 :        if(dt%dmft_kspectralfunc==1) then
     715                 :           4 :          cond_string(1)='dmft_kspectralfunc' ; cond_values(1)=dt%dmft_kspectralfunc
     716                 :           4 :          call chkint_eq(0,1,cond_string,cond_values,ierr,'iscf',dt%iscf,2,(/-2,-3/),iout)
     717                 :             :        endif
     718                 :             : 
     719                 :          42 :        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_magnfield',dt%dmft_magnfield,3,(/0,1,2/),iout)
     720                 :             : 
     721         [ +  + ]:          42 :        if(dt%dmft_magnfield .gt. 0) then
     722                 :          13 :          cond_string(1)='dmft_magnfield' ; cond_values(1)=dt%dmft_magnfield
     723                 :          13 :          call chkdpr(0,1,cond_string,cond_values,ierr,'dmft_magnfield_b',dt%dmft_magnfield_b,1,0.0_dp,iout)
     724                 :             :        endif
     725                 :             : 
     726   [ +  -  +  - ]:          42 :        if(dt%ucrpa==0.and.dt%dmft_solv/=9.and.dt%dmft_solv/=6.and.dt%dmft_solv/=7) then
     727                 :          42 :          cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     728                 :          42 :          call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_nwlo',dt%dmft_nwlo,1,iout)
     729                 :          42 :          cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     730                 :          42 :          call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_nwli',dt%dmft_nwli,1,iout)
     731                 :             :        end if
     732                 :             : 
     733                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     734                 :          42 :        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_read_occnd',dt%dmft_read_occnd,3,(/0,1,2/),iout)
     735                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     736                 :          42 :        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_occnd_imag',dt%dmft_occnd_imag,2,(/0,1/),iout)
     737                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     738                 :          42 :        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_prt_maxent',dt%dmft_prt_maxent,2,(/0,1/),iout)
     739                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     740                 :          42 :        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_prtself',dt%dmft_prtself,2,(/0,1/),iout)
     741                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     742                 :          42 :        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_prtwan',dt%dmft_prtwan,2,(/0,1/),iout)
     743                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     744                 :          42 :        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_rslf',dt%dmft_rslf,3,(/-1,0,1/),iout)
     745                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     746                 :          42 :        call chkdpr(0,1,cond_string,cond_values,ierr,'dmft_fermi_step',dt%dmft_fermi_step,1,zero,iout)
     747                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     748                 :          42 :        call chkdpr(0,1,cond_string,cond_values,ierr,'dmft_mxsf',dt%dmft_mxsf,1,zero,iout)
     749                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     750                 :          42 :        call chkdpr(0,1,cond_string,cond_values,ierr,'dmft_mxsf',dt%dmft_mxsf,-1,one,iout)
     751                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     752                 :          42 :        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_solv',dt%dmft_solv,11,(/-2,-1,0,1,2,5,6,7,8,9,10/),iout)
     753                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     754                 :          42 :        call chkdpr(0,1,cond_string,cond_values,ierr,'dmft_tolfreq',dt%dmft_tolfreq,-1,0.01_dp,iout)
     755                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     756                 :          42 :        call chkdpr(0,1,cond_string,cond_values,ierr,'dmft_tollc',dt%dmft_tollc,-1,tol5,iout)
     757                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     758                 :          42 :        call chkdpr(0,1,cond_string,cond_values,ierr,'dmft_charge_prec',dt%dmft_charge_prec,-1,tol4,iout)
     759                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     760                 :          42 :        call chkdpr(0,1,cond_string,cond_values,ierr,'dmft_charge_prec',dt%dmft_charge_prec,1,tol20,iout)
     761                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     762                 :          42 :        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_dc',dt%dmft_dc,6,(/1,2,5,6,7,8/),iout)
     763                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     764                 :          42 :        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_full_chipsi',dt%dmft_full_chipsi,2,(/0,1/),iout)
     765                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     766                 :          42 :        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_wanorthnorm',dt%dmft_wanorthnorm,2,(/2,3/),iout)
     767   [ +  +  +  +  :          42 :        if(dt%getwfk==0.and.dt%irdwfk==0.and.dt%irdden==0.and.dt%getden==0.and.dt%ucrpa==0) then
          +  -  -  +  -  
                      - ]
     768                 :             :          write(msg,'(3a,i3,a,i3,a,i3,a,i3,a)' )&
     769                 :           0 :          'When usedmft==1, A WFK file or a DEN file has to be read. In the current calculation:',ch10, &
     770                 :           0 :          '  getwfk =',dt%getwfk, &
     771                 :           0 :          '  irdwfk =',dt%irdwfk, &
     772                 :           0 :          '  getden =',dt%getden, &
     773                 :           0 :          '  irdden =',dt%irdden, &
     774                 :           0 :          '  Action: use a restart density or WFK file'
     775         [ #  # ]:           0 :          if(dt%iscf>0) ABI_ERROR(msg)
     776                 :             :        end if
     777                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     778                 :          42 :        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_t2g',dt%dmft_t2g,2,(/0,1/),iout)
     779                 :          42 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     780                 :          42 :        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_x2my2d',dt%dmft_x2my2d,2,(/0,1/),iout)
     781   [ +  +  +  - ]:          42 :        if (dt%dmft_solv>=5.and.dt%ucrpa==0.and.dt%dmft_solv/=9.and.dt%dmft_solv/=6.and.dt%dmft_solv/=7) then
     782                 :          26 :          cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     783                 :          26 :          call chkint_ge(0,1,cond_string,cond_values,ierr,'dmftqmc_l',dt%dmftqmc_l,1,iout)
     784                 :          26 :          cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     785                 :          26 :          call chkdpr(0,1,cond_string,cond_values,ierr,'dmftqmc_n',dt%dmftqmc_n,1,one,iout)
     786                 :          26 :          cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     787                 :          26 :          call chkint_ge(0,1,cond_string,cond_values,ierr,'dmftqmc_seed',dt%dmftqmc_seed,0,iout)
     788                 :          26 :          cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     789                 :          26 :          call chkint_ge(0,1,cond_string,cond_values,ierr,'dmftqmc_therm',dt%dmftqmc_therm,1,iout)
     790                 :             :        end if
     791                 :          42 :        cond_string(1)='usepawu' ; cond_values(1)=dt%usepawu
     792         [ +  + ]:          42 :        if (dt%usepawu==14) then
     793                 :          17 :          call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_dc',dt%dmft_dc,4,(/5,6,7,8/),iout)
     794                 :             :        else
     795                 :          25 :          call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_dc',dt%dmft_dc,2,(/1,2/),iout)
     796                 :             :        endif
     797         [ -  + ]:          42 :        if (dt%dmft_dc==8) then
     798                 :           0 :          cond_string(1)='dmft_dc' ; cond_values(1)=dt%dmft_dc
     799                 :           0 :          call chkint_eq(0,1,cond_string,cond_values,ierr,'ixc',dt%ixc,4,(/7,-1012,11,-101130/),iout)
     800                 :           0 :          cond_string(1)='dmft_dc' ; cond_values(1)=dt%dmft_dc
     801                 :           0 :          call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_solv',dt%dmft_solv,10,(/-2,0,1,2,5,6,7,8,9,10/),iout)
     802                 :           0 :          cond_string(1)='dmft_dc' ; cond_values(1)=dt%dmft_dc
     803                 :           0 :          call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_t2g',dt%dmft_t2g,1,(/0/),iout)
     804                 :           0 :          cond_string(1)='dmft_dc' ; cond_values(1)=dt%dmft_dc
     805                 :           0 :          call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_x2my2d',dt%dmft_x2my2d,1,(/0/),iout)
     806                 :           0 :          cond_string(1)='dmft_dc' ; cond_values(1)=dt%dmft_dc
     807                 :           0 :          call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_yukawa_param',dt%dmft_yukawa_param,4,(/1,2,3,4/),iout)
     808         [ #  # ]:           0 :          if (dt%dmft_yukawa_param==4) then
     809                 :           0 :            cond_string(1)='dmft_yukawa_param' ; cond_values(1)=dt%dmft_yukawa_param
     810                 :           0 :            call chkdpr(0,1,cond_string,cond_values,ierr,'dmft_yukawa_lambda',dt%dmft_yukawa_lambda,1,zero,iout)
     811                 :           0 :            cond_string(1)='dmft_yukawa_param' ; cond_values(1)=dt%dmft_yukawa_param
     812                 :           0 :            call chkdpr(0,1,cond_string,cond_values,ierr,'dmft_yukawa_epsilon',dt%dmft_yukawa_epsilon,1,zero,iout)
     813                 :             :          end if
     814                 :             :        end if
     815                 :             : 
     816   [ -  +  -  - ]:          42 :        if (dt%dmft_solv .eq. 10 .and. dt%nspinor .eq. 1) then
     817                 :           0 :          write(msg,'(2a)') "dmft_solv == 10 is not implemented for nspinor == 1 "
     818                 :           0 :          ABI_ERROR(msg)
     819                 :             :        endif
     820                 :             : 
     821         [ -  + ]:          42 :        if (dt%dmft_solv .eq. 10) then
     822                 :           0 :           cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     823                 :           0 :           call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_hybri_limit',dt%dmft_hybri_limit,2,(/0,1/),iout)
     824                 :             :        endif
     825                 :             : 
     826         [ +  + ]:         108 :        do itypat=1,dt%ntypat
     827         [ +  + ]:          66 :          if (dt%lpawu(itypat)==-1) cycle
     828   [ -  +  -  - ]:          84 :          if (dt%dmft_orbital(itypat)<=0.and.dt%dmft_orbital_filepath==ABI_NOFILE) then
     829                 :           0 :            write(msg,'(2a)') "You need to provide a filename for the DMFT orbital", &
     830                 :           0 :                             & " with dmft_orbital_filepath"
     831                 :           0 :            ABI_ERROR(msg)
     832                 :             :          end if
     833                 :             :        end do
     834                 :             : 
     835                 :             :        !if (dt%dmft_prtwan==1) then
     836                 :             :        !  cond_string(1)='dmft_prtwan' ; cond_values(1)=dt%dmft_prtwan
     837                 :             :        !  call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_solv',dt%dmft_solv,2,(/6,7/),iout)
     838                 :             :        !end if
     839                 :             : 
     840   [ +  +  +  - ]:          42 :        if (dt%dmft_solv>=5.and.dt%dmft_solv/=6.and.dt%dmft_solv/=7) then
     841                 :          26 :          cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     842                 :             :          if (dt%dmft_solv == 6 .or. dt%dmft_solv == 7 ) then
     843                 :             :            call chkint_eq(0,1,cond_string,cond_values,ierr,'dmftctqmc_basis',dt%dmftctqmc_basis,5,(/0,1,2,3,4/),iout)
     844                 :             :            if (dt%dmftctqmc_basis == 4) then
     845                 :             :              cond_string(1)='dmftctqmc_basis' ; cond_values(1)=dt%dmftctqmc_basis
     846                 :             :              call chkint_eq(0,1,cond_string,cond_values,ierr,'nspinor',dt%nspinor,1,(/2/),iout)
     847                 :             :            end if
     848                 :             :          else
     849                 :          26 :            call chkint_eq(0,1,cond_string,cond_values,ierr,'dmftctqmc_basis',dt%dmftctqmc_basis,4,(/0,1,2,4/),iout)
     850         [ -  + ]:          26 :            if (dt%dmftctqmc_basis == 4) then
     851                 :           0 :               cond_string(1)='dmftctqmc_basis' ; cond_values(1)=dt%dmftctqmc_basis
     852                 :           0 :               call chkint_eq(0,1,cond_string,cond_values,ierr,'nspinor',dt%nspinor,1,(/2/),iout)
     853                 :             :             end if
     854                 :             :          end if
     855                 :          26 :          cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     856                 :          26 :          call chkint_eq(0,1,cond_string,cond_values,ierr,'dmftctqmc_check',dt%dmftctqmc_check,4,(/0,1,2,3/),iout)
     857                 :          26 :          cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     858                 :          26 :          call chkint_ge(0,1,cond_string,cond_values,ierr,'dmftctqmc_gmove',dt%dmftctqmc_gmove,0,iout)
     859                 :          26 :          cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     860                 :          26 :          call chkint_ge(0,1,cond_string,cond_values,ierr,'dmftctqmc_meas',dt%dmftctqmc_meas,1,iout)
     861                 :             : #if defined HAVE_TRIQS_v2_0 || defined HAVE_TRIQS_v1_4
     862                 :             :          if (dt%dmft_solv==9) then
     863                 :             :            call chkint_ge(0,1,cond_string,cond_values,ierr,'dmftqmc_l',dt%dmftqmc_l,2*dt%dmft_nwli+1,iout)
     864                 :             :            cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
     865                 :             :            call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_triqs_n_l',dt%dmft_triqs_n_l,1,iout)
     866                 :             :          end if
     867                 :             : #endif
     868                 :             : #if !defined HAVE_PYTHON_INVOCATION
     869         [ -  + ]:          26 :          if (dt%dmft_solv==9) then
     870                 :             :            write(msg,'(2a)')&
     871                 :           0 :             'ABINIT must have been compiled with the flag enable_python_invocation="yes" in order to allow', &
     872                 :           0 :             ' dmft_solv==9. You need to recompile ABINIT or change the value of dmft_solv.'
     873                 :           0 :            ABI_ERROR(msg)
     874                 :             :          end if
     875                 :             : #endif
     876                 :             :        end if
     877                 :             : 
     878         [ +  + ]:          42 :        if (dt%dmft_solv==5) then
     879                 :          26 :          cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     880                 :          26 :          call chkint_eq(0,1,cond_string,cond_values,ierr,'dmftctqmc_correl',dt%dmftctqmc_correl,2,(/0,1/),iout)
     881                 :          26 :          call chkint_eq(0,1,cond_string,cond_values,ierr,'dmftctqmc_grnns',dt%dmftctqmc_grnns,2,(/0,1/),iout)
     882                 :          26 :          call chkint_ge(0,1,cond_string,cond_values,ierr,'dmftctqmc_mrka',dt%dmftctqmc_mrka,0,iout)
     883                 :          26 :          call chkint_eq(0,1,cond_string,cond_values,ierr,'dmftctqmc_mov',dt%dmftctqmc_mov,2,(/0,1/),iout)
     884                 :          26 :          call chkint_ge(0,1,cond_string,cond_values,ierr,'dmftctqmc_order',dt%dmftctqmc_order,0,iout)
     885                 :          26 :          call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_nwlo',dt%dmft_nwlo,2*dt%dmftqmc_l,iout)
     886                 :             :        end if
     887                 :          42 :        cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     888                 :          42 :        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmftctqmc_localprop',dt%dmftctqmc_localprop,4,(/0,1,2,3/),iout)
     889         [ +  + ]:          42 :        if (dt%dmft_entropy>=1) then
     890                 :           3 :          cond_string(1)='dmft_entropy' ; cond_values(1)=dt%dmft_entropy
     891                 :           3 :          call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_nlambda',dt%dmft_nlambda,3,iout)
     892                 :           3 :          call chkint_le(0,1,cond_string,cond_values,ierr,'dmft_entropy',dt%dmft_entropy,dt%dmft_nlambda,iout)
     893                 :           3 :          call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_dc',dt%dmft_dc,1,(/1/),iout)
     894         [ -  + ]:           3 :          if (dt%dmft_solv /= 5) then
     895                 :             :            write(msg,'(3a,i3,a,i3,a,i3,a,i3,a)' )&
     896                 :           0 :            'When dmft_entropy>=1, the impurity solver has to be currently  dmft_solv=5:',ch10, &
     897                 :           0 :            'Action: change your dmft_solv input'
     898                 :           0 :            ABI_ERROR(msg)
     899                 :             :          end if
     900                 :             :        end if
     901         [ -  + ]:          42 :        if (dt%nspinor==2.and.dt%nspden==1) ABI_ERROR(' nspinor=2, nspden=1 and usedmft=1 is not implemented')
     902   [ +  +  -  + ]:         479 :        if (maxval(abs(dt%nband(1:dt%nkpt)-dt%nband(1)))>0) ABI_ERROR("Every kpt needs to have the same number of bands in DMFT")
     903         [ +  + ]:         134 :        do iatom=1,natom
     904                 :          92 :          lpawu = dt%lpawu(dt%typat(iatom))
     905         [ +  + ]:          92 :          if (lpawu==-1) cycle
     906   [ +  +  -  + ]:          48 :          if (dt%dmft_t2g==1.and.lpawu/=2) ABI_ERROR("lpawu/=2 and dmft_t2g=1 are not compatible")
     907   [ -  +  -  - ]:          48 :          if (dt%dmft_x2my2d==1.and.lpawu/=2) ABI_ERROR("lpawu/=2 and dmft_x2my2d=1 are not compatible")
     908   [ -  +  -  - ]:          48 :          if (dt%dmft_dc==7.and.dt%dmft_nominal(iatom)<1) ABI_ERROR("Please set a physical value for nominal occupancies with dmft_nominal")
     909   [ -  +  -  - ]:          90 :          if (lpawu==0.and.dt%dmft_triqs_basis==4) ABI_ERROR("lpawu must be >0 in order to use JmJ basis")
     910                 :             :        end do
     911                 :             :      end if
     912                 :             :    end if
     913                 :             : 
     914                 :             :    ! Use of Wannier90 and TRIQS. Could use a new variable name instead. w90dmft?
     915                 :             : #if !defined HAVE_WANNIER90
     916                 :             :    if(dt%usedmft==10) then
     917                 :             :     write(msg, '(5a)') &
     918                 :             :     ' usedmft == 10 is only relevant with Wannier90. This ABINIT was not',ch10,&
     919                 :             :     ' compiled with Wannier90.',ch10,&
     920                 :             :     ' Action: check compilation options to link Wannier90.'
     921                 :             :     ABI_ERROR(msg)
     922                 :             :    endif
     923                 :             : #else
     924         [ -  + ]:        6983 :    if(dt%usedmft==10) then
     925         [ #  # ]:           0 :     if(dt%prtwant /=2) then
     926                 :             :       write(msg, '(4a,i0,a)' )&
     927                 :           0 :        ' In DMFT with Wannier90 orbital, you have to use the Wannier90 interface,',ch10,&
     928                 :           0 :        ' which requires that you use the prtwant = 2 keyword. It was instead found to be ',ch10,&
     929                 :           0 :        dt%prtwant, '. Please look at the tutorial on Wannier90.'
     930                 :           0 :       ABI_ERROR(msg)
     931                 :             :     end if
     932         [ #  # ]:           0 :     if(dt%w90iniprj /=2) then
     933                 :             :       write(msg, '(5a,i0,2a)' )&
     934                 :           0 :        ' In DMFT with Wannier90 orbital, the only valid value for w90iniprj is 2,',ch10,&
     935                 :           0 :        ' meaning that the Wannier90 initial projection are defined in a .win file.',ch10,&
     936                 :           0 :        ' For this calculation, it was found to be ', dt%w90iniprj,ch10,&
     937                 :           0 :        ' Action: check the values of w90iniprj and the .win file.'
     938                 :           0 :       ABI_ERROR(msg)
     939                 :             :     end if
     940                 :             :    endif
     941                 :             : #endif
     942                 :             : 
     943                 :             : #if !defined HAVE_TRIQS_INTERNAL && !defined HAVE_TRIQS_v3_2
     944         [ -  + ]:        6983 :    if(dt%dmft_solv>=6.and.dt%dmft_solv<=7) then
     945                 :             :      write(msg,'(3a)') &
     946                 :           0 :       & ' dmft_solv=6, or 7 is only relevant if the TRIQS library v3.2>= is linked',ch10,&
     947                 :           0 :       & ' Action: check compilation options'
     948                 :           0 :      ABI_ERROR(msg)
     949                 :             :    end if
     950                 :             : #endif
     951                 :             : 
     952         [ -  + ]:        6983 :    if(dt%dmft_solv==6.or.dt%dmft_solv==7) then
     953                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     954                 :           0 :      call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_triqs_length_cycle',dt%dmft_triqs_length_cycle,1,iout)
     955                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     956                 :           0 :      call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_triqs_basis',dt%dmft_triqs_basis,5,(/0,1,2,3,4/),iout)
     957         [ #  # ]:           0 :      if (dt%dmft_triqs_basis == 4) then
     958                 :           0 :        cond_string(1)='dmft_triqs_basis' ; cond_values(1)=dt%dmft_triqs_basis
     959                 :           0 :        call chkint_eq(0,1,cond_string,cond_values,ierr,'nspinor',dt%nspinor,1,(/2/),iout)
     960                 :             :      end if
     961                 :           0 :      call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_triqs_chiloc',dt%dmft_triqs_chiloc,3,(/0,1,2/),iout)
     962         [ #  # ]:           0 :      if (dt%dmft_triqs_chiloc > 0) then
     963                 :           0 :        cond_string(1)='dmft_triqs_chiloc' ; cond_values(1)=dt%dmft_triqs_chiloc
     964                 :           0 :        call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_triqs_chiloc_ins',dt%dmft_triqs_chiloc_ins,1,iout)
     965                 :             :      end if
     966                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     967                 :           0 :      call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_triqs_n_warmup_cycles_init',dt%dmft_triqs_n_warmup_cycles_init,0,iout)
     968                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     969                 :           0 :      call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_triqs_n_cycles',dt%dmft_triqs_n_cycles,1,iout)
     970                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     971                 :           0 :      call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_triqs_n_tau',dt%dmft_triqs_n_tau,1,iout)
     972                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     973                 :           0 :      call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_triqs_n_iw',dt%dmft_triqs_n_iw,1,iout)
     974                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     975                 :           0 :      call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_triqs_compute_integral',dt%dmft_triqs_compute_integral,2,(/0,1/),iout)
     976                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     977                 :           0 :      call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_triqs_prt_entropy',dt%dmft_triqs_prt_entropy,2,(/0,1/),iout)
     978                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     979                 :           0 :      call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_triqs_det_init_size',dt%dmft_triqs_det_init_size,1,iout)
     980                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     981                 :           0 :      call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_triqs_det_n_operations_before_check',dt%dmft_triqs_det_n_operations_before_check,1,iout)
     982                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     983                 :           0 :      call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_triqs_entropy',dt%dmft_triqs_entropy,2,(/0,1/),iout)
     984                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     985                 :           0 :      call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_triqs_measure_g_l',dt%dmft_triqs_measure_g_l,2,(/0,1/),iout)
     986                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     987                 :           0 :      call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_triqs_loc_n_min',dt%dmft_triqs_loc_n_min,0,iout)
     988                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     989                 :           0 :      call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_triqs_loc_n_max',dt%dmft_triqs_loc_n_max,dt%dmft_triqs_loc_n_min,iout)
     990                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     991                 :           0 :      call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_triqs_measure_density_matrix',dt%dmft_triqs_measure_density_matrix,2,(/0,1/),iout)
     992                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     993                 :           0 :      call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_triqs_move_double',dt%dmft_triqs_move_double,2,(/0,1/),iout)
     994                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     995                 :           0 :      call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_triqs_move_shift',dt%dmft_triqs_move_shift,2,(/0,1/),iout)
     996                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     997                 :           0 :      call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_triqs_off_diag',dt%dmft_triqs_off_diag,2,(/0,1/),iout)
     998                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
     999                 :           0 :      call chkdpr(0,1,cond_string,cond_values,ierr,'dmft_triqs_pauli_prob',dt%dmft_triqs_pauli_prob,1,zero,iout)
    1000                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
    1001                 :           0 :      call chkdpr(0,1,cond_string,cond_values,ierr,'dmft_triqs_pauli_prob',dt%dmft_triqs_pauli_prob,-1,one,iout)
    1002                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
    1003                 :           0 :      call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_triqs_read_ctqmcdata',dt%dmft_triqs_read_ctqmcdata,2,(/0,1/),iout)
    1004                 :             : #if defined HAVE_TRIQS_INTERNAL
    1005                 :             :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
    1006                 :             :      call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_triqs_n_warmup_cycles_restart',dt%dmft_triqs_n_warmup_cycles_restart,0,iout)
    1007                 :             : #endif
    1008                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
    1009                 :           0 :      call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_triqs_time_invariance',dt%dmft_triqs_time_invariance,2,(/0,1/),iout)
    1010                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
    1011                 :           0 :      call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_triqs_use_norm_as_weight',dt%dmft_triqs_use_norm_as_weight,2,(/0,1/),iout)
    1012                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
    1013                 :           0 :      call chkdpr(0,1,cond_string,cond_values,ierr,'dmft_triqs_det_precision_error',dt%dmft_triqs_det_precision_error,1,zero,iout)
    1014                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
    1015                 :           0 :      call chkdpr(0,1,cond_string,cond_values,ierr,'dmft_triqs_det_precision_warning',dt%dmft_triqs_det_precision_warning,1,zero,iout)
    1016                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
    1017                 :           0 :      call chkdpr(0,1,cond_string,cond_values,ierr,'dmft_triqs_det_precision_error',dt%dmft_triqs_det_precision_error,1,dt%dmft_triqs_det_precision_warning,iout)
    1018                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
    1019                 :           0 :      call chkdpr(0,1,cond_string,cond_values,ierr,'dmft_triqs_imag_threshold',dt%dmft_triqs_imag_threshold,1,zero,iout)
    1020         [ #  # ]:           0 :      if (dt%dmft_triqs_time_invariance==1) then
    1021                 :           0 :        cond_string(1)='dmft_triqs_time_invariance' ; cond_values(1)=dt%dmft_triqs_time_invariance
    1022                 :           0 :        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_triqs_measure_density_matrix',dt%dmft_triqs_measure_density_matrix,1,(/1/),iout)
    1023                 :             :      end if
    1024         [ #  # ]:           0 :      if (dt%dmft_triqs_measure_density_matrix == 1) then
    1025                 :           0 :        cond_string(1)='dmft_triqs_measure_density' ; cond_values(1)=dt%dmft_triqs_measure_density_matrix
    1026                 :           0 :        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_triqs_use_norm_as_weight',dt%dmft_triqs_use_norm_as_weight,1,(/1/),iout)
    1027                 :             :      end if
    1028                 :           0 :      cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
    1029                 :           0 :      cond_string(2)='dmft_triqs_measure_g_l' ; cond_values(2)=dt%dmft_triqs_measure_g_l
    1030         [ #  # ]:           0 :      if (dt%dmft_triqs_measure_g_l==0) then
    1031                 :           0 :        call chkdpr(0,2,cond_string,cond_values,ierr,'dmft_triqs_dlr_wmax',dt%dmft_triqs_dlr_wmax,1,zero,iout)
    1032                 :           0 :        cond_string(1)='dmft_solv' ; cond_values(1)=dt%dmft_solv
    1033                 :           0 :        cond_string(2)='dmft_triqs_measure_g_l' ; cond_values(2)=dt%dmft_triqs_measure_g_l
    1034                 :           0 :        call chkdpr(0,2,cond_string,cond_values,ierr,'dmft_triqs_dlr_epsilon',dt%dmft_triqs_dlr_epsilon,1,zero,iout)
    1035                 :             :      else
    1036                 :           0 :        call chkint_ge(0,2,cond_string,cond_values,ierr,'dmft_triqs_n_l',dt%dmft_triqs_n_l,1,iout)
    1037                 :             :      end if
    1038         [ #  # ]:           0 :      if (dt%dmft_triqs_off_diag==1) then
    1039                 :           0 :        cond_string(1)='dmft_triqs_off_diag' ; cond_values(1)=dt%dmft_triqs_off_diag
    1040                 :           0 :        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_triqs_measure_density_matrix',dt%dmft_triqs_measure_density_matrix,1,(/0/),iout)
    1041                 :             :      end if
    1042   [ #  #  #  # ]:           0 :      if (dt%dmft_triqs_compute_integral==1.and.dt%dmft_triqs_entropy==1) then
    1043                 :           0 :        cond_string(1)='dmft_triqs_compute_integral' ; cond_values(1)=dt%dmft_triqs_compute_integral
    1044                 :           0 :        cond_string(2)='dmft_triqs_entropy' ; cond_values(2)=dt%dmft_triqs_entropy
    1045                 :           0 :        call chkint_eq(0,2,cond_string,cond_values,ierr,'dmft_triqs_measure_density_matrix',dt%dmft_triqs_measure_density_matrix,1,(/1/),iout)
    1046                 :           0 :        cond_string(1)='dmft_triqs_compute_integral' ; cond_values(1)=dt%dmft_triqs_compute_integral
    1047                 :           0 :        cond_string(2)='dmft_triqs_entropy' ; cond_values(2)=dt%dmft_triqs_entropy
    1048                 :           0 :        call chkint_ge(0,2,cond_string,cond_values,ierr,'dmft_triqs_gaussorder',dt%dmft_triqs_gaussorder,0,iout)
    1049                 :           0 :        cond_string(1)='dmft_triqs_compute_integral' ; cond_values(1)=dt%dmft_triqs_compute_integral
    1050                 :           0 :        cond_string(2)='dmft_triqs_entropy' ; cond_values(2)=dt%dmft_triqs_entropy
    1051                 :           0 :        call chkint_ge(0,2,cond_string,cond_values,ierr,'dmft_triqs_nsubdivisions',dt%dmft_triqs_nsubdivisions,1,iout)
    1052                 :             :      end if
    1053         [ #  # ]:           0 :      if (dt%dmft_t2g==1) then
    1054                 :           0 :        cond_string(1)='dmft_t2g' ; cond_values(1)=dt%dmft_t2g
    1055                 :           0 :        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_triqs_basis',dt%dmft_triqs_basis,1,(/0/),iout)
    1056                 :             :      end if
    1057         [ #  # ]:           0 :      if (dt%dmft_x2my2d==1) then
    1058                 :           0 :        cond_string(1)='dmft_x2my2d' ; cond_values(1)=dt%dmft_x2my2d
    1059                 :           0 :        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_triqs_basis',dt%dmft_triqs_basis,1,(/0/),iout)
    1060                 :             :      end if
    1061                 :             :    end if
    1062                 :             : 
    1063                 :             : !  dosdeltae
    1064                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'dosdeltae',dt%dosdeltae,1,0.0_dp,iout)
    1065                 :             : 
    1066                 :             : !  dynimage between 0 and 1
    1067         [ +  + ]:       14247 :    maxidyn=maxval(dt%dynimage(:))
    1068         [ +  + ]:       14247 :    minidyn=minval(dt%dynimage(:))
    1069                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'dynimage',minidyn,0,iout)
    1070                 :        6983 :    call chkint_le(0,0,cond_string,cond_values,ierr,'dynimage',maxidyn,1,iout)
    1071                 :             : 
    1072                 :             : !  ecut
    1073                 :             : !  With planewaves, one must use positive ecut
    1074         [ +  - ]:        6983 :    if(usewvl==0)then
    1075         [ -  + ]:        6983 :      if (dt%ecut < tol2) then
    1076                 :             :        write(msg, '(3a)' )&
    1077                 :           0 :         'The input keyword "ecut" is compulsory !',ch10,&
    1078                 :           0 :         'Action: add a value for "ecut" in the input file.'
    1079                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    1080                 :             :      else
    1081                 :        6983 :        cond_string(1)='usewvl' ; cond_values(1)=usewvl
    1082                 :        6983 :        call chkdpr(1,1,cond_string,cond_values,ierr,'ecut',dt%ecut,1,tol8,iout)
    1083                 :             :      end if
    1084                 :             :    end if
    1085                 :             : 
    1086                 :             : !  pawecutdg (placed here to stop before ngfftdg)
    1087         [ +  + ]:        6983 :    if (usepaw==1) then
    1088         [ +  - ]:        1205 :      if(usewvl==0) then
    1089                 :        1205 :        call chkdpr(1,0,cond_string,cond_values,ierr,'pawecutdg',dt%pawecutdg,1,tol8,iout)
    1090                 :        1205 :        cond_string(1)='pawecutdg>=ecut' ; cond_values(1)=0
    1091                 :        1205 :        call chkdpr(1,1,cond_string,cond_values,ierr,'pawecutdg',dt%pawecutdg,1,dt%ecut,iout)
    1092                 :             :      else
    1093         [ #  # ]:           0 :        if(dt%pawecutdg > tol8) then
    1094                 :           0 :          ABI_ERROR('In PAW+WVL do not use pawecutdg')
    1095                 :             :        end if
    1096                 :             :      end if
    1097                 :             :    end if
    1098                 :             : 
    1099                 :             : !  ecuteps
    1100         [ +  + ]:        6983 :    if (any(optdriver == [RUNL_SCREENING]) )then
    1101                 :         148 :      call chkdpr(0,0,cond_string,cond_values,ierr,'ecuteps',dt%ecuteps,1,0.0_dp,iout)
    1102         [ -  + ]:         148 :      if (dt%ecuteps <= 0) then
    1103                 :           0 :        ABI_ERROR_NOSTOP("ecuteps must be > 0 if optdriver == 3", ierr)
    1104                 :             :      end if
    1105         [ +  + ]:         148 :      if(dt%fftgw<20 .and. dt%fftgw/=0)then
    1106         [ -  + ]:          12 :        if(dt%ecutwfn<dt%ecuteps-tol8)then
    1107                 :             :          write(msg,'(a,es16.6,a,es16.6,a,6a)')&
    1108                 :           0 :           'The values of ecutwfn and ecuteps are ', dt%ecutwfn,' and ',dt%ecuteps,ch10,&
    1109                 :           0 :           'With fftgw lower than 20, one expect ecuteps to be smaller or equal to ecutwfn.',ch10,&
    1110                 :           0 :           'Indeed, one is wasting memory without gaining CPU time or accuracy.',ch10,&
    1111                 :           0 :           'Action: use another value of fftgw (e.g. 21), or adjust ecutwfn with ecuteps.'
    1112                 :           0 :          ABI_ERROR_NOSTOP(msg, ierr)
    1113                 :             :        end if
    1114                 :             :      end if
    1115         [ -  + ]:         148 :      if (any(dt%gw_icutcoul == [14, 15, 16])) then
    1116                 :           0 :        msg = "Monte-carlo integration method should not be used when computing the screening. Please change gw_icutcoul."
    1117                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    1118                 :             :      end if
    1119                 :             :    end if
    1120                 :             : 
    1121                 :             : !  ecutsigx
    1122                 :             : !  @MG FIXME reinstate this check, after having rewritten FFT treatment in GW
    1123                 :        6983 :    if( ANY( optdriver == [RUNL_SIGMA] ) .and..FALSE.)then
    1124                 :             :      call chkdpr(0,0,cond_string,cond_values,ierr,'ecutsigx',dt%ecutsigx,1,0.0_dp,iout)
    1125                 :             :      if(dt%fftgw<20)then
    1126                 :             :        if(dt%ecutwfn<dt%ecutsigx-tol8)then
    1127                 :             :          write(msg,'(a,es16.6,a,es16.6,a,6a)')&
    1128                 :             :           'The values of ecutwfn and ecutsigx are ', dt%ecutwfn,' and ',dt%ecutsigx,ch10,&
    1129                 :             :           'With fftgw lower than 20, one expect ecutsigx to be smaller or equal to ecutwfn.',ch10,&
    1130                 :             :           'Indeed, one is wasting memory without gaining CPU time or accuracy.',ch10,&
    1131                 :             :           'Action: use another value of fftgw (e.g. 21), or adjust ecutwfn with ecutsigx.'
    1132                 :             :          ABI_ERROR_NOSTOP(msg, ierr)
    1133                 :             :        end if
    1134                 :             :      end if
    1135                 :             :    end if
    1136                 :             : 
    1137         [ +  + ]:        6983 :    if (optdriver == RUNL_BSE) then
    1138                 :             :      ! Check for BSE calculations that are not implemented.
    1139         [ -  + ]:          29 :      if (dt%nspinor == 2) then
    1140                 :           0 :        ABI_ERROR_NOSTOP("BSE with nspinor 2 not implemented", ierr)
    1141                 :             :      end if
    1142                 :             :    end if
    1143                 :             : 
    1144                 :             : !  ecutsigx
    1145                 :             : 
    1146                 :             :    ! Check for GW calculations that are not implemented.
    1147         [ +  + ]:        6983 :    if (ANY(optdriver == [RUNL_SCREENING, RUNL_SIGMA])) then
    1148         [ +  + ]:         349 :      if (dt%nspinor == 2) then
    1149         [ -  + ]:           9 :        if (dt%usepaw == 1) then
    1150                 :           0 :          ABI_ERROR_NOSTOP("GW with PAW and nspinor 2 not implemented", ierr)
    1151                 :             :        end if
    1152                 :             :        !if (optdriver == RUNL_SCREENING .and. dt%symchi == 1) then
    1153                 :             :        !  ABI_ERROR_NOSTOP("Screening with symchi 1 and nspinor 2 not implemented", ierr)
    1154                 :             :        !end if
    1155                 :             :        !if (optdriver == RUNL_SIGMA .and. dt%symsigma == 1) then
    1156                 :             :        !  ABI_ERROR_NOSTOP("Self-energy with symsigma 1 and nspinor 2 not implemented", ierr)
    1157                 :             :        !end if
    1158         [ -  + ]:           7 :        if (optdriver == RUNL_SIGMA .and. &
    1159         [ +  + ]:           9 :            any(mod(dt%gwcalctyp, 10) == [SIG_QPGW_PPM, SIG_QPGW_CD])) then
    1160                 :           0 :          ABI_ERROR_NOSTOP("model GW with nspinor 2 are not implemented", ierr)
    1161                 :             :        end if
    1162                 :             :        !if (optdriver == RUNL_SIGMA .and. mod(dt%gwcalctyp, 100) >= 10) then
    1163                 :             :        !  ABI_ERROR_NOSTOP("Self-consistent GW with nspinor == 2 not implemented", ierr)
    1164                 :             :        !end if
    1165   [ +  +  +  +  :           9 :        if (optdriver == RUNL_SIGMA .and. dt%symsigma > 0 .and. dt%gwcalctyp >= 20) then
                   -  + ]
    1166                 :           0 :          ABI_ERROR_NOSTOP("gwcalctyp >= 0 requires symsigma == 0 in input. New default in Abinit9 is symsigma 1!", ierr)
    1167                 :             :        end if
    1168   [ +  +  +  +  :           9 :        if (optdriver == RUNL_SIGMA .and. dt%symsigma > 0 .and. dt%ucrpa > 0) then
                   -  + ]
    1169                 :           0 :          ABI_ERROR_NOSTOP("ucrpa requires symsigma == 0 in input. New default in Abinit9 is symsigma 1!", ierr)
    1170                 :             :        end if
    1171         [ -  + ]:           9 :        if (dt%gwcomp /= 0 .and. dt%gwcomp /= 1) then
    1172                 :           0 :          ABI_ERROR_NOSTOP("gwcomp 2 and -2 with nspinor 2 not implemented (gwcomp 1 is)", ierr)
    1173                 :             :        end if
    1174   [ +  +  +  -  :           9 :        if (optdriver == RUNL_SCREENING .and. dt%usepaw == 0 .and. dt%inclvkb /= 0) then
                   -  + ]
    1175                 :             :          ! The commutator [Vnl, r] for q --> 0 is coded for nspinor 1 only (add_vnlr_commutator in m_vkbr).
    1176                 :           0 :          ABI_ERROR_NOSTOP("inclvkb /= 0 with nspinor 2 not implemented. Action: set inclvkb 0", ierr)
    1177                 :             :        end if
    1178                 :             :      end if ! nspinor 2
    1179                 :             : 
    1180   [ +  +  +  +  :        2424 :      if (maxval(abs(dt%istwfk(1:nkpt))) > 1 .and. mod(dt%gwcalctyp, 100) >= 20) then
                   -  + ]
    1181                 :           0 :        write(msg, "(3a)")"Self-consistent GW with istwfk > 1 not supported.",ch10, &
    1182                 :           0 :        "Please regenerate your WFK file with istwfk *1"
    1183                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    1184                 :             :      end if
    1185                 :             : 
    1186                 :             :      ! Avoid wasting CPUs if nsppol==2.
    1187   [ +  +  +  -  :         349 :      if (dt%nsppol == 2 .and. .not. iseven(nproc) .and. nproc > 1) then
                   -  + ]
    1188                 :           0 :        write(msg,'(3a)') "Spin-polarized GW calculations should be run with an even number of processors ",ch10,&
    1189                 :           0 :         " for achieving an optimal distribution of memory and CPU load. Please change the number of processors."
    1190                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    1191                 :             :      end if
    1192                 :             :    end if
    1193                 :             : 
    1194                 :             : !  ecutsm
    1195                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'ecutsm',dt%ecutsm,1,0.0_dp,iout)
    1196                 :             : 
    1197                 :             : !  With non-zero optcell, one must use non-zero ecutsm
    1198                 :             :    !if(dt%optcell/=0 )then
    1199                 :             :    !  cond_string(1)='optcell' ; cond_values(1)=dt%optcell
    1200                 :             :    !  call chkdpr(1,1,cond_string,cond_values,ierr,'ecutsm',dt%ecutsm,1,tol8,iout)
    1201                 :             :    !end if
    1202                 :             : !  At present (v10.2.2), Chebyshev filtering algorithm (wfoptalg=1 or 111) cannot be used with ecutsm>0.
    1203                 :             : !  So we allow ecutsm=0 but with a warning.
    1204   [ +  +  +  +  :        6983 :    if(dt%optcell/=0 .and. dt%ecutsm < tol8 .and. dt%wfoptalg/=1 .and. dt%wfoptalg/=111) then
             +  -  +  + ]
    1205                 :           3 :      write(msg, "(2a)") 'For optcell > 0, it is highly recommended to set ecutsm > 0 to have better precision on stress',&
    1206                 :           6 :                       & ' (available only if wfoptalg is neither 1 nor 111).'
    1207                 :           3 :      ABI_WARNING(msg)
    1208                 :             :    end if
    1209                 :             : 
    1210                 :             :    !  ecutwfn <= ecut. This is also needed for the correct evaluation
    1211                 :             :    !  of the Kleynman-Bylander form factors as the spline in Psps% is done with ecut
    1212                 :             :    !  while we need |q+G| up to ecut. enlargement due to the q is already
    1213                 :             :    !  taken into account by enlarging the spline mesh by around 20%.
    1214         [ +  + ]:        6983 :    if ( ANY(optdriver == [RUNL_SCREENING, RUNL_SIGMA, RUNL_BSE]) ) then
    1215                 :         378 :      call chkdpr(0,0,cond_string,cond_values,ierr,'ecutwfn',dt%ecuteps,1,0.0_dp,iout)
    1216         [ -  + ]:         378 :      if(dt%ecut<dt%ecutwfn-tol8)then
    1217                 :             :        write(msg,'(a,es16.6,a,es16.6,a,6a)')&
    1218                 :           0 :         'The values of ecut and ecutwfn are ', dt%ecut,' and ',dt%ecutwfn,ch10,&
    1219                 :           0 :         'One expects ecutwfn to be smaller or equal to ecut.',ch10,&
    1220                 :           0 :         'Action: adjust ecutwfn with ecut.'
    1221                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    1222                 :             :      end if
    1223                 :             :    end if
    1224                 :             : 
    1225                 :             :    ! Check variables used to specify k-points in self-energy.
    1226   [ +  +  +  +  :       20820 :    if (dt%nkptgw /= 0 .and. (any(dt%sigma_erange > tol8 .or. dt%gw_qprange /= 0))) then
          +  +  +  +  -  
                      + ]
    1227                 :           0 :      ABI_ERROR_NOSTOP("nkptw cannot be used with sigma_erange or gw_qprange", ierr)
    1228                 :             :    end if
    1229   [ +  +  +  +  :       20926 :    if (any(dt%sigma_erange > tol8) .and. dt%gw_qprange /= 0) then
             +  +  -  + ]
    1230                 :           0 :      ABI_ERROR_NOSTOP("sigma_erange and gw_qprange are mutually exclusive", ierr)
    1231                 :             :    end if
    1232   [ +  +  +  +  :       41871 :    if (any(dt%sigma_erange < -tol8) .and. any(dt%sigma_erange > tol8)) then
          +  +  +  +  -  
                      + ]
    1233                 :           0 :      ABI_ERROR_NOSTOP("Found negative sigma_erange entry (metals) with another positive entry (semiconductors)!", ierr)
    1234                 :             :    end if
    1235                 :             : 
    1236                 :             : !  effmass_free
    1237   [ +  +  +  +  :        6983 :    if(abs(dt%effmass_free-one)>tol8.and.dt%ixc/=31.and.dt%ixc/=35.and.xc_is_mgga)then
             +  -  -  + ]
    1238                 :             :      write(msg, '(5a)' )&
    1239                 :           0 :       'A modified electronic effective mass is not usable with a meta-GGA XC functional!',ch10,&
    1240                 :           0 :       'Except with some fake metaGGAs (ixc=31 or ixc=35).',ch10,&
    1241                 :           0 :       'effmass should be included in kinetic energy density (tau).'
    1242                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    1243                 :             :    end if
    1244                 :             : 
    1245                 :             : !  efmas
    1246         [ +  + ]:        6983 :    if(optdriver==RUNL_RESPFN) then !.and.usepaw==1)then
    1247                 :         720 :      cond_string(1)='optdriver' ; cond_values(1)=RUNL_RESPFN
    1248                 :         720 :      cond_string(2)='usepaw'    ; cond_values(2)=dt%usepaw !usepaw
    1249                 :         720 :      cond_string(3)='ieig2rf'   ; cond_values(3)=dt%ieig2rf
    1250                 :         720 :      cond_string(4)='nsym'      ; cond_values(4)=dt%nsym
    1251                 :         720 :      call chkint_eq(1,4,cond_string,cond_values,ierr,'efmas',dt%efmas,2,(/0,1/),iout)
    1252         [ +  + ]:         720 :      if (dt%paral_rf==1) then
    1253                 :          26 :        cond_string(1)='paral_rf' ; cond_values(1)=dt%paral_rf
    1254                 :          26 :        call chkint_eq(1,1,cond_string,cond_values,ierr,'efmas',dt%efmas,1,(/0/),iout)
    1255                 :             :      end if
    1256                 :             :    end if
    1257                 :             : 
    1258         [ +  + ]:        6983 :    if (dt%efmas==1) then
    1259                 :             :      ! Consistency check for efmas calculations.
    1260                 :          17 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'efmas_calc_dirs',dt%efmas_calc_dirs,7,[-3,-2,-1,0,1,2,3],iout)
    1261                 :             : 
    1262                 :          17 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'efmas_deg',dt%efmas_deg,2,[0,1],iout)
    1263                 :             : 
    1264                 :          17 :      call chkdpr(0,0,cond_string,cond_values,ierr,'efmas_deg_tol',dt%efmas_deg_tol,1,0.0_dp,iout)
    1265                 :             : 
    1266                 :          17 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'efmas_dim',dt%efmas_dim,3,[1,2,3],iout)
    1267                 :             : 
    1268                 :          17 :      call chkint_ge(0,0,cond_string,cond_values,ierr,'efmas_n_dirs',dt%efmas_n_dirs,0,iout)
    1269                 :             : 
    1270                 :          17 :      call chkint_ge(0,0,cond_string,cond_values,ierr,'efmas_ntheta',dt%efmas_ntheta,1,iout)
    1271                 :             : 
    1272         [ -  + ]:          17 :      ABI_CHECK_NOSTOP(all_nprocs == 1, "efmas 1 is not compatible with MPI. Use 1 processor", ierr)
    1273                 :             :    end if
    1274                 :             : 
    1275                 :             : !  enable_mpi_io
    1276         [ +  + ]:        6983 :    if(dt%iomode==IO_MODE_MPI) then
    1277                 :          28 :      cond_string(1)='iomode' ; cond_values(1)=dt%iomode
    1278                 :          28 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'enable_mpi_io',xmpi_mpiio,1,(/1/),iout)
    1279                 :             :    end if
    1280                 :             : 
    1281                 :             :    ! ========
    1282                 :             :    ! eph code
    1283                 :             :    ! ========
    1284         [ +  + ]:        6983 :    if (optdriver == RUNL_EPH) then
    1285                 :         109 :      cond_string(1)='optdriver'; cond_values(1)=optdriver
    1286                 :             :      call chkint_eq(1,1,cond_string,cond_values,ierr,'eph_task',dt%eph_task, &
    1287                 :         109 :        28, [0, 1, 2, -2, 3, 4, -4, 5, -5, 6, 7, -7, 8, 9, 10, 11, -12, 13, -13, 14, 15, -15, 16, 17, 18, 19, 20, 24], iout)
    1288                 :             : 
    1289   [ +  +  +  -  :         436 :      if (any(dt%ddb_ngqpt <= 0)) then
                   -  + ]
    1290                 :           0 :        ABI_ERROR_NOSTOP("ddb_ngqpt must be specified when performing EPH calculations.", ierr)
    1291                 :             :      end if
    1292                 :             : 
    1293                 :             :      ! TODO: Activate this check and update the two EPH tests that started to failed
    1294                 :             :      ! We need "enough" valence states to compute the mu(T) in semiconductors
    1295                 :             :      if ((dt%nsppol == 1 .and. dt%nspinor == 1 .and. dt%nband(1) <= zval/two) .or. &
    1296   [ +  -  +  -  :         109 :          (dt%nsppol == 2 .and. dt%nband(1) <= zval) .or. &   ! Magnetic semiconductors are not easy to predict!
          +  +  -  +  -  
             -  -  +  -  
                      - ]
    1297                 :             :          (dt%nspinor == 2 .and. dt%nband(1) <= zval)) then
    1298                 :             :        !ABI_ERROR_NOSTOP("Please add enough conduction bands (including degenerate states) to compute the Fermi level.", ierr)
    1299                 :           3 :        ABI_WARNING("Please add enough conduction bands (including degenerate states) to compute the Fermi level.")
    1300                 :             :      end if
    1301                 :             : 
    1302   [ +  +  -  + ]:         109 :      if (dt%eph_task == 1 .and. dt%ph_nqpath <= 0) then
    1303                 :           0 :        ABI_ERROR("When eph_task == 1, the q-path for the linewidth must be specified via ph_nqpath and ph_qpath")
    1304                 :             :      end if
    1305   [ +  +  -  + ]:         109 :      if (dt%eph_task == 1 .and. dt%nshiftk <= 0) then
    1306                 :           0 :        ABI_ERROR_NOSTOP('phgamma does not work with multiple k-shifts', ierr)
    1307                 :             :      end if
    1308   [ +  +  -  + ]:         109 :      if (dt%eph_task == 1 .and. .not. isdiagmat(dt%kptrlatt)) then
    1309                 :           0 :        ABI_ERROR_NOSTOP("kptrlatt must be diagonal in phgamma.", ierr)
    1310                 :             :      end if
    1311                 :             :      if (dt%eph_task == 2 .and. dt%irdwfk == 0 .and. &
    1312   [ +  +  +  -  :         109 :           dt%getwfk == 0 .and. dt%getwfk_filepath == ABI_NOFILE) then
             -  +  -  - ]
    1313                 :           0 :        ABI_ERROR_NOSTOP('Neither getwfk, irdwfk, getwfk_filepath were given in order to compute the gkk', ierr)
    1314                 :             :      end if
    1315         [ +  + ]:         109 :      if (any(dt%eph_task == [-5])) then
    1316         [ -  + ]:           1 :        ABI_CHECK(dt%ph_nqpath > 0, "ph_nqpath must be specified when eph_task == -5")
    1317                 :             :      end if
    1318                 :             : 
    1319         [ +  + ]:         109 :      if (any(dt%eph_task == [18])) then
    1320         [ -  + ]:           2 :        if (dt%tolwfr == zero) then
    1321                 :           0 :          ABI_ERROR_NOSTOP("tolwfr must be specified when eph_stern /= 0", ierr)
    1322                 :             :        end if
    1323         [ +  + ]:           2 :        if (dt%eph_fix_korq == "k") then
    1324         [ -  + ]:           1 :          ABI_CHECK(dt%ph_nqpath > 0, "ph_nqpath must be specified when elh_fix_kord = 'k' with eph_task == -5")
    1325                 :             :        end if
    1326         [ +  + ]:           2 :        if (dt%eph_fix_korq == "q") then
    1327         [ -  + ]:           1 :          ABI_CHECK(dt%nkpath > 0, "nkpath and kptbounds must be specified when eph_fix_kord = 'q' with eph_task == -5")
    1328         [ -  + ]:           1 :          ABI_CHECK(allocated(dt%kptbounds), "kptbounds must be specified when eph_fix_kord = 'q' with eph_task == -5")
    1329                 :             :        end if
    1330                 :             :      end if
    1331                 :             : 
    1332         [ +  + ]:         109 :      if (dt%eph_task == 13) then
    1333                 :           9 :        msg = "electron, hole"
    1334         [ -  + ]:           9 :        if (.not. string_in(dt%vpq_pkind, msg)) then
    1335                 :           0 :          ABI_ERROR_NOSTOP(sjoin("Invalid vpq_pkind: `", dt%vpq_pkind, "`, must be among:", msg), ierr)
    1336                 :             :        end if
    1337                 :           9 :        msg = "polaron, hopping, debug_dw"
    1338         [ -  + ]:           9 :        if (.not. string_in(dt%vpq_mode, msg)) then
    1339                 :           0 :          ABI_ERROR_NOSTOP(sjoin("Invalid vpq_mode: `", dt%vpq_mode, "`, must be among:", msg), ierr)
    1340                 :             :        end if
    1341   [ -  +  -  -  :           9 :        if (dt%vpq_aseed == "localize" .and. (dt%vpq_atloc < 1 .or. dt%vpq_atloc > dt%natom)) then
                   -  - ]
    1342                 :           0 :          ABI_ERROR_NOSTOP(sjoin("vpq_atloc must be from 1 to natom if vpq_aseed = `", dt%vpq_aseed, "`"), ierr)
    1343                 :             :        end if
    1344                 :             :      end if
    1345                 :             :      !if (dt%eph_task == -4 .and. dt%occopt /= 3) then
    1346                 :             :      !  ABI_ERROR_NOSTOP("eph_task -4 requires occopt 3 in the input file (Fermi-Dirac with physical Temperature!", ierr)
    1347                 :             :      !end if
    1348   [ +  +  -  + ]:         109 :      if (dt%eph_fermie /= zero .and. nint(dt%tmesh(3)) /= 1) then
    1349                 :           0 :        ABI_ERROR_NOSTOP("eph_fermie does not support multiple temperatures in tmesh !", ierr)
    1350                 :             :      end if
    1351   [ +  +  -  + ]:         109 :      if (dt%eph_fermie /= zero .and. dt%eph_extrael /= zero) then
    1352                 :           0 :        ABI_ERROR_NOSTOP("eph_fermie and (eph_extrael|eph_doping) are mutually exclusive", ierr)
    1353                 :             :      end if
    1354                 :             : 
    1355                 :         109 :      cond_string(1)='optdriver' ; cond_values(1)=optdriver
    1356                 :         109 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'eph_frohlichm',dt%eph_frohlichm,2,[0,1],iout)
    1357                 :             : 
    1358         [ +  + ]:         109 :      if (dt%eph_stern /= 0) then
    1359                 :             :        ! Check requirements for Sternheimer.
    1360         [ -  + ]:          25 :        if (dt%tolwfr == zero) then
    1361                 :           0 :          ABI_ERROR_NOSTOP("tolwfr must be specified when eph_stern /= 0", ierr)
    1362                 :             :        end if
    1363         [ -  + ]:          25 :        if (dt%getpot_filepath == ABI_NOFILE) then
    1364                 :           0 :          ABI_ERROR_NOSTOP("getpot_filepath is required when eph_stern /= 0", ierr)
    1365                 :             :        end if
    1366   [ +  -  -  +  :          25 :        if (all(dt%sigma_bsum_range /= 0)) then
                   -  + ]
    1367                 :           0 :          ABI_ERROR_NOSTOP("sigma_bsum_range cannot be used when eph_stern /= 0", ierr)
    1368                 :             :        end if
    1369                 :             :      end if
    1370                 :             : 
    1371   [ +  +  +  +  :         418 :      if (dt%ibte_prep /= 0 .and. any(dt%sigma_ngkpt /= 0)) then
             +  +  -  + ]
    1372                 :           0 :        ABI_ERROR_NOSTOP("sigma_ngkpt cannot be used to downsample the k-mesh when ibte_prep is used.", ierr)
    1373                 :             :      end if
    1374                 :             : 
    1375                 :             :      ! Additional checks for GWPT
    1376         [ +  + ]:         109 :      if (dt%eph_task == 17) then
    1377                 :           3 :        call chkdpr(0,0,cond_string,cond_values,ierr,'ecuteps',dt%ecuteps,1,0.0_dp,iout)
    1378         [ -  + ]:           3 :        if (dt%ecuteps <= 0) then
    1379                 :           0 :          ABI_ERROR_NOSTOP("ecuteps must be specified if GWPT is activated", ierr)
    1380                 :             :        end if
    1381         [ -  + ]:           3 :        if (dt%ecutsigx <= 0) then
    1382                 :           0 :          ABI_ERROR_NOSTOP("ecutsigx must be specified if GWPT is activated", ierr)
    1383                 :             :        end if
    1384         [ -  + ]:           3 :        if (any(dt%ppmodel == [3, 4])) then
    1385                 :           0 :          ABI_ERROR_NOSTOP("GWPT does not support ppmodel 3 or 4", ierr)
    1386                 :             :        end if
    1387                 :             :      end if
    1388                 :             : 
    1389         [ +  + ]:         109 :      if (dt%eph_task == 18) then
    1390                 :             :        ! Compute e-ph matrix elements along q-path.
    1391         [ -  + ]:           2 :        if (dt%nbdbuf == 0) then
    1392                 :           0 :          msg = "nbdbuf > 0 is required for NSCF. Adjust nband and nbdbuf to converge only the bands of interests"
    1393                 :           0 :          ABI_ERROR_NOSTOP(msg, ierr)
    1394                 :             :        end if
    1395                 :             :      end if
    1396                 :             : 
    1397                 :             :    end if ! RUNL_EPH
    1398                 :             : 
    1399   [ +  +  +  -  :       41898 :    if (any(dt%eph_np_pqbks /= 0)) then
                   -  + ]
    1400                 :             :      ! Perform basic consistency check for MPI grid.
    1401                 :             :      ! (q-points and k-points will be computed at runtime so cannot perform checks at this level.
    1402   [ #  #  #  # ]:           0 :      if (product(dt%eph_np_pqbks) /= all_nprocs) then
    1403                 :             :        write(msg, "(a,i0,3a, 6(a,1x,i0))") &
    1404                 :           0 :          "Cannot create 5d Cartesian grid with nprocs: ", all_nprocs, ch10, &
    1405                 :           0 :          "Idle processes are not supported. The product of the `nproc_*` vars should be equal to nproc.", ch10, &
    1406                 :           0 :          "nprocs_pert (", dt%eph_np_pqbks(1), ") x nprocs_qpt (", dt%eph_np_pqbks(2), &
    1407                 :           0 :          ") x nprocs_bsum (", dt%eph_np_pqbks(3), ") x nprocs_kcalc (", dt%eph_np_pqbks(4), &
    1408                 :           0 :          ") x nprocs_spin (", dt%eph_np_pqbks(5), ") != ", all_nprocs
    1409                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    1410                 :             :      end if
    1411                 :             : 
    1412                 :             :      ! Check spin
    1413         [ #  # ]:           0 :      if (all(dt%eph_np_pqbks(5) /= [0, 1])) then
    1414         [ #  # ]:           0 :        if (dt%nspinor == 2) then
    1415                 :           0 :          ABI_ERROR_NOSTOP("Spin parallelism cannot be used when nspinor == 2", ierr)
    1416   [ #  #  #  # ]:           0 :        else if (dt%nspinor == 1 .and. dt%eph_np_pqbks(5) > dt%nsppol) then
    1417                 :           0 :          ABI_ERROR_NOSTOP("nproc for spin parallelism cannot be greater than nsppol", ierr)
    1418                 :             :        end if
    1419                 :             :      end if
    1420                 :             : 
    1421   [ #  #  #  # ]:           0 :     if (dt%eph_np_pqbks(1) /= 0 .and. dt%eph_np_pqbks(1) > 3 * dt%natom ) then
    1422                 :           0 :       ABI_ERROR_NOSTOP("nproc for pert parallelism cannot be greater than 3 * natom", ierr)
    1423                 :             :     end if
    1424                 :             : 
    1425         [ #  # ]:           0 :     if (mod(3 * dt%natom, dt%eph_np_pqbks(1)) /= 0) then
    1426                 :           0 :       ABI_ERROR_NOSTOP("nproc for pert parallelism must divide 3 * natom.", ierr)
    1427                 :             :     end if
    1428                 :             : 
    1429                 :             : #ifndef HAVE_NETCDF_MPI
    1430                 :             :     if (abs(dt%eph_task) == 4 .and. (dt%eph_np_pqbks(4) /= 1 .or. dt%eph_np_pqbks(5) /= 1)) then
    1431                 :             :       ABI_ERROR_NOSTOP("k-point and/or spin parallelism in EPH code requires Netcdf4 with MPI-IO support!", ierr)
    1432                 :             :     end if
    1433                 :             : #endif
    1434                 :             :    end if
    1435                 :             : 
    1436                 :             :    ! exchmix
    1437                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'exchmix',dt%exchmix,1,0.0_dp,iout)
    1438                 :             : 
    1439                 :             :    ! extrapwf
    1440                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'extrapwf',dt%extrapwf,3, [0,1,2], iout)
    1441   [ +  +  -  + ]:        6983 :    if (dt%extrapwf>0.and.dt%densfor_pred<5) then
    1442                 :             :      write(msg,'(3a)')&
    1443                 :           0 :      'extrapwf keyword (extrapolation of WF) is only compatible with',ch10,&
    1444                 :           0 :      'densfor_pred=5 or 6; please change densfor_pred value.'
    1445                 :           0 :      ABI_ERROR_NOSTOP(msg,ierr)
    1446                 :             :      ! MT oct 14: Should use chkint_eq but the msg is not clear enough
    1447                 :             :    end if
    1448                 :             : 
    1449                 :             :    ! expert_user
    1450                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'expert_user',dt%expert_user,4, [0,1,2,3],iout)
    1451                 :             : 
    1452                 :             :    ! fermie_nest
    1453                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'fermie_nest',dt%fermie_nest,1,0.0_dp,iout)
    1454                 :             : 
    1455                 :             :    !  ffnl_lw
    1456                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'ffnl_lw',dt%ffnl_lw,2,(/0,1/),iout)
    1457                 :             : 
    1458                 :             :    ! fftgw
    1459                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'fftgw',dt%fftgw,8, [00,01,10,11,20,21,30,31],iout)
    1460                 :             : 
    1461                 :             :    !  fockoptmix
    1462                 :             :    call chkint_eq(0,0,cond_string,cond_values,ierr,'fockoptmix',&
    1463                 :        6983 :      dt%fockoptmix,12,[0,1,11,201,211,301,401,501,601,701,801,901],iout)
    1464                 :             : 
    1465         [ +  + ]:        6983 :    if (dt%paral_kgb/=0) then
    1466                 :         628 :      cond_string(1)='paral_kgb' ; cond_values(1)=dt%paral_kgb
    1467                 :             :      ! Make sure that dt%fockoptmix is 0, 1 or 11 (wfmixalg==0)
    1468                 :         628 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'fockoptmix',dt%fockoptmix,3,(/0,1,11/),iout)
    1469                 :             :    end if
    1470                 :             : 
    1471                 :             :    ! fock_icutcoul ! FBruneval: I have forbidden values 1, 2, 4 since they are buggy
    1472                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'fock_icutcoul',dt%fock_icutcoul,3,[0,3,5],iout)
    1473                 :             : 
    1474                 :             :    ! frzfermi
    1475                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'frzfermi',dt%frzfermi,2,[0,1],iout)
    1476                 :             : 
    1477                 :             :    ! fxcartfactor
    1478                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'fxcartfactor',dt%fxcartfactor,1,zero,iout)
    1479                 :             : 
    1480                 :             :    ! ga_algor
    1481                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'ga_algor',dt%ga_algor,3,[1,2,3],iout)
    1482                 :             : 
    1483                 :             :    ! ga_fitness
    1484                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'ga_fitness',dt%ga_fitness,3,[1,2,3],iout)
    1485                 :             : 
    1486                 :             :    ! ga_opt_percent
    1487                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'ga_opt_percent',dt%ga_opt_percent,1,tol8,iout)
    1488                 :             : 
    1489                 :             :    ! getxred
    1490         [ +  + ]:        6983 :    if(dt%getxcart/=0)then
    1491                 :          30 :      cond_string(1)='getxcart' ; cond_values(1)=dt%getxcart
    1492                 :             :      ! Make sure that dt%getxred is 0. NB: this has already been checked elsewhere:
    1493                 :             :      !  that only one of xred xcart xrandom getxred getxcart are set
    1494                 :          30 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'getxred',dt%getxred,1,[0],iout)
    1495                 :             :    end if
    1496                 :             : 
    1497                 :             :    ! goprecon
    1498                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'goprecon',dt%goprecon,4,[0,1,2,3],iout)
    1499                 :             : 
    1500                 :             :    ! gpu_devices
    1501         [ -  + ]:        6983 :    if (dt%gpu_option/=ABI_GPU_DISABLED) then
    1502   [ #  #  #  #  :           0 :      if (all(gpu_devices(:)==-2)) then
                   #  # ]
    1503         [ #  # ]:           0 :        gpu_devices(:)=dt%gpu_devices(:)
    1504   [ #  #  #  #  :           0 :      else if (any(dt%gpu_devices(:)/=gpu_devices(:))) then
                   #  # ]
    1505                 :             :        write(msg,'(3a)')&
    1506                 :           0 :         'GPU device(s) selection cannot be different from one dataset to another!',ch10,&
    1507                 :           0 :         'Action: change gpu_devices in input file.'
    1508                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    1509                 :             :      end if
    1510                 :             :    end if
    1511                 :             : 
    1512                 :             : !  gpu_nfft_blocks
    1513                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'gpu_nfft_blocks',dt%gpu_nfft_blocks,0,iout)
    1514   [ +  -  -  + ]:        6983 :    if (dt%gpu_option/=ABI_GPU_OPENMP .and. dt%gpu_nfft_blocks/=0) then
    1515                 :           0 :      ABI_WARNING('gpu_nfft_blocks is ignored outside of OpenMP GPU (gpu_option 2)!')
    1516                 :             :    end if
    1517                 :             : 
    1518                 :             : !  gpu_kokkos_nthrd
    1519                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'gpu_kokkos_nthrd',dt%gpu_kokkos_nthrd,1,iout)
    1520                 :             : 
    1521                 :             : !  gpu_nl_distrib
    1522                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'gpu_nl_distrib',dt%gpu_nl_distrib,2,(/0,1/),iout)
    1523   [ +  -  -  + ]:        6983 :    if (dt%gpu_option/=ABI_GPU_OPENMP .and. dt%gpu_nl_distrib==1) then
    1524                 :           0 :      ABI_WARNING('gpu_nl_distrib is ignored outside of OpenMP GPU (gpu_option 2)!')
    1525                 :             :    end if
    1526                 :             : 
    1527                 :             : !  gpu_nl_splitsize
    1528                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'gpu_nl_splitsize',dt%gpu_nl_splitsize,0,iout)
    1529   [ +  -  -  + ]:        6983 :    if (dt%gpu_option/=ABI_GPU_OPENMP .and. dt%gpu_nl_splitsize/=0) then
    1530                 :           0 :      ABI_WARNING('gpu_nl_splitsize is ignored outside of OpenMP GPU (gpu_option 2)!')
    1531                 :             :    end if
    1532                 :             : 
    1533                 :             : !  gpu_option
    1534                 :             :    call chkint_eq(0,0,cond_string,cond_values,ierr,'gpu_option',dt%gpu_option,4, &
    1535                 :        6983 :    &        (/ABI_GPU_DISABLED,ABI_GPU_LEGACY,ABI_GPU_OPENMP,ABI_GPU_KOKKOS/),iout)
    1536         [ -  + ]:        6983 :    if (dt%gpu_option/=ABI_GPU_DISABLED) then
    1537                 :             : !     if (dt%nspinor==2) then
    1538                 :             : !       write(msg,'(3a)')&
    1539                 :             : !&       'Use of GPU is not allowed when nspinor==2 !',ch10,&
    1540                 :             : !&       'Action: impose gpu_option=0 in your input file.'
    1541                 :             : !       ABI_ERROR_NOSTOP(msg, ierr)
    1542                 :             : !     end if
    1543                 :             : !    if (dt%optdriver==RUNL_GSTATE.and.mod(dt%wfoptalg,10)/=4) then
    1544                 :             : !    write(msg,'(6a)') ch10,&
    1545                 :             : !    &       ' chkinp: ERROR -',ch10,&
    1546                 :             : !    &       '  When GPU is in use (gpu_option>0), wfoptalg must be 4 or 14 !',ch10,&
    1547                 :             : !    &       '  Action: change wfoptalg in your input file.'
    1548                 :             : !    call wrtout(std_out,msg)
    1549                 :             : !    ierr=ierr+1
    1550                 :             : !    end if
    1551   [ #  #  #  # ]:           0 :      if (dt%useylm == 0 .and. dt%optdriver /= RUNL_GWR) then
    1552                 :             :        write(msg,'(3a)')&
    1553                 :           0 :         'Use of GPU is not allowed when useylm==0 !',ch10,&
    1554                 :           0 :         'Action: impose useylm=1 in your input file.'
    1555                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    1556                 :             :      end if
    1557         [ #  # ]:           0 :      if (dt%tfkinfunc>0) then
    1558                 :             :        write(msg,'(5a)')&
    1559                 :           0 :        'gpu_option/=0 (use of GPU) is not allowed when tfkinfunc>0 !',ch10,&
    1560                 :           0 :        'Action: suppress gpu_option from your input file',ch10,&
    1561                 :           0 :        '        (GPU will be used but with another mechanism)'
    1562                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    1563                 :             :      end if
    1564   [ #  #  #  #  :           0 :      if (dt%ngfft(4)/=dt%ngfft(1).or.dt%ngfft(5)/=dt%ngfft(2).or.dt%ngfft(6)/=dt%ngfft(3)) then
                   #  # ]
    1565                 :             :        write(msg,'(3a)')&
    1566                 :           0 :        'When GPU is in use (gpu_option/=0), ngfft(4:6) must be equal to ngfft(1:3) !',ch10,&
    1567                 :           0 :        'Action: suppress ngfft in input file or change it.'
    1568                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    1569                 :             :      end if
    1570                 :             : #ifndef HAVE_GPU
    1571                 :           0 :      write(msg,'(6a)') ch10,&
    1572                 :           0 :      ' invars0: ERROR -',ch10,&
    1573                 :           0 :      '   Input variable gpu_option is on but abinit hasn''t been built with GPU mode enabled !',ch10,&
    1574                 :           0 :      '   Action: suppress the input variable gpu_option or re-compile ABINIT with GPU enabled.'
    1575                 :           0 :      call wrtout(std_out,msg)
    1576                 :           0 :      ierr=ierr+1
    1577                 :             : #endif
    1578                 :             : !#ifndef HAVE_GPU_CUDA_DP
    1579                 :             : !     write(msg,'(10a)') ch10,&
    1580                 :             : !&     ' invars0: ERROR -',ch10,&
    1581                 :             : !&     '   Input variable gpu_option is on but abinit hasn''t been built',ch10,&
    1582                 :             : !&     '   with GPU mode in DOUBLE PRECISION enabled !',ch10,&
    1583                 :             : !&     '   Action: suppress input variable gpu_option',ch10,&
    1584                 :             : !&     '   or re-compile ABINIT with double precision GPU enabled.'
    1585                 :             : !     call wrtout(std_out,msg)
    1586                 :             : !     ierr=ierr+1
    1587                 :             : !#endif
    1588                 :             :    end if
    1589                 :             : 
    1590                 :             : !  gpu_thread_limit
    1591                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'gpu_thread_limit',dt%gpu_thread_limit,0,iout)
    1592                 :             : 
    1593                 :             :    ! RT-TDDFT
    1594         [ +  + ]:        6983 :    if (dt%optdriver == RUNL_RTTDDFT) then
    1595                 :             :      ! getwfk / getwfk_filepath / irdwfk
    1596   [ +  +  +  -  :          50 :      if (dt%getwfk == 0 .and. dt%irdwfk == 0 .and. dt%getwfk_filepath==ABI_NOFILE .and. dt%td_restart==0) then
             +  +  -  + ]
    1597                 :             :        write(msg, '(3a)' ) &
    1598                 :           0 :         'Initial KS orbitals need to be read in WFK file for RT-TDDFT runs!',ch10,&
    1599                 :           0 :         'Action: set irdwfk or getwfk /= 0 or specify the WFK filename using getwfk_filepath.'
    1600                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    1601                 :             :      endif
    1602                 :             :      ! usewvl
    1603         [ -  + ]:          50 :      if (dt%usewvl /= 0) then
    1604                 :           0 :         ABI_ERROR_NOSTOP('RT-TDDFT and wavelets are not compatible, set usewvl to 0.', ierr)
    1605                 :             :      endif
    1606                 :             :      ! nimage
    1607         [ -  + ]:          50 :      if (dt%nimage > 1) then
    1608                 :           0 :         ABI_ERROR_NOSTOP('RT-TDDFT and multiple images are not compatible, set nimage to 1.', ierr)
    1609                 :             :      endif
    1610                 :             :      ! tfkinfunc
    1611         [ -  + ]:          50 :      if (dt%tfkinfunc == 2) then
    1612                 :           0 :         ABI_ERROR_NOSTOP('RT-TDDFT and Thomas-Fermi functionals are not compatible, set tfkinfunc to 0.', ierr)
    1613                 :             :      endif
    1614                 :             :      ! positron
    1615         [ -  + ]:          50 :      if (dt%positron /= 0) then
    1616                 :           0 :         ABI_ERROR_NOSTOP('RT-TDDFT and Positron are not compatible, set positron to 0.', ierr)
    1617                 :             :      endif
    1618                 :             :      ! usefock
    1619         [ -  + ]:          50 :      if (dt%usefock==1) then
    1620                 :           0 :         ABI_ERROR_NOSTOP('RT-TDDFT and Exact exchange are not compatible, set usefock to 0.', ierr)
    1621                 :             :      end if
    1622                 :             :      ! usedmft
    1623         [ -  + ]:          50 :      if (dt%usedmft /= 0) then
    1624                 :           0 :         ABI_ERROR_NOSTOP('RT-TDDFT and DMFT are not compatible, set usedmft to 0.', ierr)
    1625                 :             :      endif
    1626                 :             :      ! usepawu
    1627         [ -  + ]:          50 :      if (dt%usepawu /= 0) then
    1628                 :           0 :         ABI_ERROR_NOSTOP('RT-TDDFT with DFT+U has not been tested yet, set usepawu to 0.', ierr)
    1629                 :             :      endif
    1630                 :             :      ! usekden
    1631         [ -  + ]:          50 :      if (xc_is_mgga) then
    1632                 :           0 :         ABI_ERROR_NOSTOP('RT-TDDFT with mGGA has not been tested yet and is thus not available.', ierr)
    1633                 :             :      end if
    1634                 :             :      ! vdw_xc
    1635         [ -  + ]:          50 :      if (dt%vdw_xc /= 0) then
    1636                 :           0 :         ABI_ERROR_NOSTOP('RT-TDDFT with VDW corrected functionals has not been tested yet, set vdw_xc to 0.', ierr)
    1637                 :             :      endif
    1638                 :             :      ! ecutsm
    1639         [ -  + ]:          50 :      if (dt%ecutsm > 0.0) then
    1640                 :           0 :         ABI_ERROR_NOSTOP('RT-TDDFT is not compatible with ecutsm, set ecutsm to 0.', ierr)
    1641                 :             :      end if
    1642                 :             :      !TODO FB: Should probably be made possible later
    1643                 :             :      ! useextfpmd
    1644         [ -  + ]:          50 :      if (dt%useextfpmd /= 0) then
    1645                 :           0 :         write(msg,'(a)') 'RT-TDDFT and extFPMD has not been tested yet, set useextfpmd to 0.'
    1646                 :           0 :         ABI_ERROR_NOSTOP(msg, ierr)
    1647                 :             :      endif
    1648                 :             :      ! Magnetic case and spin-orbit
    1649                 :             :      ! nsspol, nspden, spinor
    1650   [ +  -  -  + ]:          50 :      if (dt%nsppol /= 1 .or. dt%nspden /= 1 .or. dt%nspinor /=1) then
    1651                 :             :         write(msg,'(a)') 'RT-TDDFT has not been tested yet for magnetic cases nor with spin-orbit coupling, &
    1652                 :           0 :         & set nsppol, nspden and nspinor to 1.'
    1653                 :           0 :         ABI_ERROR_NOSTOP(msg, ierr)
    1654                 :             :      endif
    1655                 :             :    endif
    1656                 :             : 
    1657                 :             :    ! gw_invalid_freq
    1658                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'gw_invalid_freq',dt%gw_invalid_freq,3,[0,1,2],iout)
    1659                 :             : 
    1660                 :             :    ! gw_icutcoul
    1661                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'gw_icutcoul',dt%gw_icutcoul,11,[0,1,2,3,4,5,6,7,14,15,16],iout)
    1662                 :             : 
    1663                 :             :    ! gw_sigxcore
    1664                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'gw_sigxcore',dt%gw_sigxcore,2,[0,1],iout)
    1665                 :             : 
    1666   [ +  +  +  +  :        6983 :    if (dt%gw_sigxcore==1.and.dt%usepaw==1.and.optdriver==RUNL_SIGMA) then !SF check if core wf file is present
                   +  + ]
    1667         [ +  + ]:           2 :      do ipsp=1,npsp
    1668                 :           1 :        call pawpsp_check_corefile(corewf_str,corewf_exist,pspheads(ipsp)%filpsp)
    1669         [ -  + ]:           2 :        if (.not. corewf_exist) then
    1670                 :           0 :          write(msg,'(7a)') 'gw_sigxcore=1, but the core wave function file corresponding to ', ch10,&
    1671         [ #  # ]:           0 :          trim(pspheads(ipsp)%filpsp), ch10,&
    1672                 :           0 :          'cannot be found.', ch10,&
    1673                 :           0 :          'Action: Provide a core wave function file for each atom type OR set gw_sigxcore=0'
    1674                 :           0 :          ABI_ERROR_NOSTOP(msg, ierr)
    1675                 :             :        endif
    1676                 :             :      enddo
    1677                 :             :    endif
    1678                 :             : 
    1679                 :             :    ! gwcomp
    1680                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'gwcomp',dt%gwcomp,4,[-2,0,1,2],iout)
    1681                 :             : 
    1682   [ -  +  -  - ]:        6983 :    if (dt%gwcomp == -2 .and. optdriver == RUNL_SIGMA) then
    1683                 :             :      ! Dynamic remainder: only GW with Godby-Needs or Hybertsen-Louie plasmon-pole models.
    1684                 :           0 :      mod10=MOD(dt%gwcalctyp,10)
    1685   [ #  #  #  # ]:           0 :      if (.not. ANY(mod10 == [SIG_GW_PPM, SIG_QPGW_PPM]) .or. ALL(dt%ppmodel /= [1,2])) then
    1686                 :           0 :        ABI_ERROR_NOSTOP('gwcomp -2 requires a plasmon-pole model for Sigma_c (gwcalctyp 0, 10, 20 or 8, 18, 28) with ppmodel 1 or 2', ierr)
    1687                 :             :      end if
    1688                 :             :    end if
    1689                 :             : 
    1690   [ -  +  -  - ]:        6983 :    if (abs(dt%gwcomp) == 2 .and. optdriver == RUNL_SCREENING) then
    1691                 :             :      ! The static (2) and dynamic (-2) remainders are for Sigma_c only: chi0 implements gwcomp 0 and 1.
    1692                 :           0 :      write(msg,'(a,i0,3a)')'gwcomp ',dt%gwcomp,' is not available in the screening calculation (only 0 or 1).',ch10,&
    1693                 :           0 :        'Action: use gwcomp 0 or 1 for the screening dataset (e.g. gwcomp2 2 for the sigma dataset only)'
    1694                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    1695                 :             :    end if
    1696                 :             : 
    1697         [ +  + ]:        6983 :    if (dt%gwcomp/=0) then
    1698   [ +  +  +  -  :          40 :      if (optdriver==RUNL_SCREENING .and. dt%gwcomp == 1 .and. (dt%awtr /=1 .or. dt%spmeth /=0)) then
             +  -  -  + ]
    1699                 :             :        write(msg,'(3a)' )&
    1700                 :           0 :         'When gwcomp == 1, the Adler-Wiser formula with time-reversal should be used',ch10,&
    1701                 :           0 :         'Action: set awtr to 1 or/and spmeth to 0'
    1702                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    1703                 :             :      end if
    1704                 :             : 
    1705                 :             :      ! Extrapolar trick with HF, SEX and COHSEX is meaningless for Sigma
    1706         [ +  + ]:          40 :      if(optdriver == RUNL_SIGMA) then
    1707                 :          19 :        mod10=MOD(dt%gwcalctyp,10)
    1708         [ -  + ]:          19 :        if ( ANY(mod10 == [SIG_HF, SIG_SEX, SIG_COHSEX]) ) then
    1709                 :             :          write(msg,'(3a)' )&
    1710                 :           0 :          'gwcomp/=0, is meaningless in the case of HF, SEX or COHSEX calculations. ',ch10,&
    1711                 :           0 :          'Action: set gwcomp to 0 or change gwcalctyp'
    1712                 :           0 :          ABI_ERROR_NOSTOP(msg, ierr)
    1713                 :             :        end if
    1714                 :             :      end if
    1715         [ -  + ]:          40 :      if (optdriver==RUNL_SIGMA .and. ALL( dt%ppmodel /= [0,1,2] )) then
    1716                 :             :        write(msg,'(a,i0,a)')&
    1717                 :           0 :          'The completeness trick cannot be used when ppmodel is ',dt%ppmodel,'. It should be set to 0, 1 or 2. '
    1718                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    1719                 :             :      end if
    1720                 :             :    end if
    1721                 :             : 
    1722                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'gwmem',dt%gwmem,4,[0,1,10,11],iout)
    1723                 :             : 
    1724                 :             :    ! gwpara
    1725                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'gwpara',dt%gwpara,3,[0,1,2],iout)
    1726                 :             : 
    1727                 :             :    ! gwrpacorr
    1728         [ +  + ]:        6983 :    if(dt%gwrpacorr>0) then
    1729                 :           5 :      mod10=MOD(dt%gwcalctyp,10)
    1730         [ -  + ]:           5 :      if (optdriver /= RUNL_SCREENING) then
    1731                 :             :        write(msg,'(3a)' )&
    1732                 :           0 :        'gwrpacorr>0 can only be used when calculating the screening',ch10,&
    1733                 :           0 :        'Action: set gwrpacorr to 0 or optdriver to 3'
    1734                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    1735                 :             :      end if
    1736         [ -  + ]:           5 :      if( mod10 /= SIG_GW_AC ) then
    1737                 :             :        write(msg,'(3a)' )&
    1738                 :           0 :        'gwrpacorr > 0 can only be used with purely imaginary frequencies',ch10,&
    1739                 :           0 :        'Action: set gwrpacorr to 0 or change gwcalctyp'
    1740                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    1741                 :             :      end if
    1742                 :             :    end if
    1743                 :             :    ! gwgmcorr
    1744   [ +  +  -  + ]:        6983 :    if(dt%gwgmcorr==1 .and. dt%gwrpacorr==0) then
    1745                 :             :      write(msg,'(3a)' )&
    1746                 :           0 :      'gwgmcorr=1 can only be used with gwrpacorr/=0',ch10,&
    1747                 :           0 :      'Action: set gwgmcorr to 0 or gwrpacorr > 0'
    1748                 :           0 :       ABI_ERROR_NOSTOP(msg, ierr)
    1749                 :             :    end if
    1750                 :             : 
    1751                 :             :    ! gwls_stern_kmax
    1752                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_stern_kmax',dt%gwls_stern_kmax,1,iout)
    1753                 :             : 
    1754                 :             :    ! gwls_npt_gauss_quad
    1755                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_npt_gauss_quad',dt%gwls_npt_gauss_quad,1,iout)
    1756                 :             : 
    1757                 :             :    ! gwls_diel_model
    1758                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_diel_model',dt%gwls_diel_model,1,iout)
    1759                 :        6983 :    call chkint_le(0,0,cond_string,cond_values,ierr,'gwls_diel_model',dt%gwls_diel_model,3,iout)
    1760                 :             : 
    1761                 :             :    ! gwls_model_parameter
    1762                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'gwls_model_parameter',dt%gwls_model_parameter,1,zero,iout)
    1763                 :             : 
    1764                 :             :    ! gwls_print_debug
    1765                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_print_debug',dt%gwls_print_debug,0,iout)
    1766                 :             : 
    1767                 :             :    ! gwls_nseeds
    1768                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_nseeds',dt%gwls_nseeds,1,iout)
    1769                 :             : 
    1770                 :             :    ! gwls_kmax_complement
    1771                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_kmax_complement',dt%gwls_kmax_complement,0,iout)
    1772                 :             : 
    1773                 :             :    ! gwls_kmax_poles
    1774                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_kmax_poles',dt%gwls_kmax_poles,0,iout)
    1775                 :             : 
    1776                 :             :    ! gwls_kmax_analytic
    1777                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_kmax_analytic',dt%gwls_kmax_analytic,0,iout)
    1778                 :             : 
    1779                 :             :    ! gwls_kmax_numeric
    1780                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_kmax_numeric',dt%gwls_kmax_numeric,0,iout)
    1781                 :             : 
    1782                 :             :    ! gwls_band_index
    1783                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_band_index',dt%gwls_band_index,1,iout)
    1784                 :             : 
    1785                 :             :    ! gwls_exchange
    1786                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_exchange',dt%gwls_exchange,0,iout)
    1787                 :             : 
    1788                 :             :    ! gwls_correlation
    1789                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_correlation',dt%gwls_correlation,0,iout)
    1790                 :             : 
    1791                 :             :    ! gwls_first_seed
    1792                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_first_seed',dt%gwls_first_seed,1,iout)
    1793                 :             : 
    1794                 :             :    ! gwls_recycle
    1795                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_recycle',dt%gwls_recycle,0,iout)
    1796                 :        6983 :    call chkint_le(0,0,cond_string,cond_values,ierr,'gwls_recycle',dt%gwls_recycle,2,iout)
    1797                 :             : 
    1798                 :             :    ! iatsph must between 1 and natom
    1799         [ +  + ]:       44955 :    maxiatsph=maxval(dt%iatsph(1:dt%natsph))
    1800         [ +  + ]:       44955 :    miniatsph=minval(dt%iatsph(1:dt%natsph))
    1801                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'iatsph',miniatsph,1,iout)
    1802                 :        6983 :    call chkint_le(0,0,cond_string,cond_values,ierr,'iatsph',maxiatsph,natom,iout)
    1803                 :             : 
    1804                 :             :    ! icoulomb
    1805                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'icoulomb',dt%icoulomb,3,[0,1,2],iout)
    1806         [ +  + ]:        6983 :    if (dt%nspden > 2) then
    1807                 :         174 :      cond_string(1)='nspden' ; cond_values(1)=nspden
    1808                 :         174 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'icoulomb',dt%icoulomb,1,[0],iout)
    1809                 :             :    end if
    1810                 :             : 
    1811                 :             :    ! icutcoul
    1812                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'icutcoul',dt%icutcoul,13,[0,1,2,3,4,5,6,7,14,15,16,22,55],iout)
    1813                 :             : 
    1814   [ +  +  -  + ]:        6983 :    if(optdriver/=RUNL_RESPFN.and.dt%icutcoul==55)then
    1815                 :             :      write(msg, '(3a)' ) &
    1816                 :           0 :      'The PCM short-circuit Coulomb cutoff is only available for linear-esponse calculations',ch10,&
    1817                 :           0 :      'Action: set icutcoul /= 55 .'
    1818                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    1819                 :             :    end if
    1820                 :             : 
    1821                 :             :    ! ieig2rf
    1822         [ +  + ]:        6983 :    if(optdriver==RUNL_RESPFN.and.usepaw==1)then
    1823                 :         116 :      cond_string(1)='optdriver' ; cond_values(1)=optdriver
    1824                 :         116 :      cond_string(2)='usepaw'    ; cond_values(2)=usepaw
    1825                 :         116 :      call chkint_eq(1,2,cond_string,cond_values,ierr,'ieig2rf',dt%ieig2rf,1,[0],iout)
    1826                 :             :    end if
    1827   [ +  +  +  + ]:        6983 :    if(optdriver==RUNL_RESPFN.and.dt%paral_rf==1)then
    1828                 :          26 :      cond_string(1)='paral_rf' ; cond_values(1)=dt%paral_rf
    1829                 :          26 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'ieig2rf',dt%ieig2rf,1,[0],iout)
    1830                 :             :    end if
    1831                 :             : 
    1832                 :             :    ! imgmov
    1833                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'imgmov',dt%imgmov,9,(/0,1,2,4,5,6,9,10,13/),iout)
    1834         [ +  + ]:        6983 :    if (dt%imgmov>0 .and. dt%imgmov/=6) then ! when imgmov>0, except imgmov==6, allow only ionmov=0 and optcell=0
    1835                 :          37 :      cond_string(1)='imgmov' ; cond_values(1)=dt%imgmov
    1836                 :          37 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'ionmov',dt%ionmov,1,(/0/),iout)
    1837                 :          37 :      cond_string(1)='imgmov' ; cond_values(1)=dt%imgmov
    1838                 :          37 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'optcell',dt%optcell,1,(/0/),iout)
    1839                 :             :    end if
    1840                 :             : 
    1841                 :             :    ! imgwfstor
    1842                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'imgwfstor',dt%imgwfstor,2,(/0,1/),iout)
    1843         [ +  + ]:        6983 :    if (dt%extrapwf/=0) then ! extrapwf/=0 not allowed presently with imgwfstor
    1844                 :           1 :      cond_string(1)='extrapwf' ; cond_values(1)=dt%extrapwf
    1845                 :           1 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'imgwfstor',dt%imgwfstor,1,(/0/),iout)
    1846                 :             :    endif
    1847         [ +  + ]:        6983 :    if (dt%ntimimage<=1) then ! imgwfstor activate only when there is more than one time step for images
    1848                 :        6940 :      cond_string(1)='ntimimage' ; cond_values(1)=dt%ntimimage
    1849                 :        6940 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'imgwfstor',dt%imgwfstor,1,(/0/),iout)
    1850                 :             :    endif
    1851                 :             : 
    1852                 :             : !  inclvkb
    1853                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'inclvkb',dt%inclvkb,2,(/0,2/),iout)
    1854                 :             : 
    1855                 :             : !  intxc
    1856                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'intxc',dt%intxc,2,(/0,1/),iout)
    1857         [ +  + ]:        6983 :    if(dt%iscf==-1)then
    1858                 :          22 :      cond_string(1)='iscf' ; cond_values(1)=dt%iscf
    1859                 :             :      ! Make sure that dt%intxc is 0
    1860                 :          22 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'intxc',dt%intxc,1,(/0/),iout)
    1861                 :             :    end if
    1862                 :             : !  TEMPORARY
    1863         [ +  + ]:        6983 :    if(optdriver==RUNL_RESPFN)then ! Make sure that dt%intxc is 0
    1864                 :         720 :      cond_string(1)='optdriver' ; cond_values(1)=optdriver
    1865                 :         720 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'intxc',dt%intxc,1,(/0/),iout)
    1866                 :             :    end if
    1867                 :             : 
    1868                 :             : !  invovl_algo
    1869                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'invovl_algo',dt%invovl_algo,2,(/0,1/),iout)
    1870                 :             : 
    1871                 :             : !  invovl_dyn_prec
    1872                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'invovl_dyn_prec',dt%invovl_dyn_prec,2,(/0,1/),iout)
    1873                 :             : 
    1874                 :             : !  invovl_precision: must be > 1e-30 and below 1
    1875                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'invovl_precision',dt%invovl_precision,1,tol30,iout)
    1876                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'invovl_precision',dt%invovl_precision,-1,0.99_dp,iout)
    1877                 :             : 
    1878                 :             : !  invovl_prec_ceil: must be >= invovl_precision and below 1 if dynamic precision is used
    1879         [ +  + ]:        6983 :    if (dt%invovl_dyn_prec==1) then
    1880                 :           6 :      cond_string(1)='invovl_dyn_prec' ; cond_values(1)=dt%invovl_dyn_prec
    1881                 :           6 :      call chkdpr(1,1,cond_string,cond_values,ierr,'invovl_prec_ceil',dt%invovl_prec_ceil,1,dt%invovl_precision,iout)
    1882                 :           6 :      call chkdpr(1,1,cond_string,cond_values,ierr,'invovl_prec_ceil',dt%invovl_prec_ceil,-1,0.99_dp,iout)
    1883                 :             :    end if
    1884                 :             : 
    1885                 :             : !  invovl_algo, invovl_dyn_prec: warn if set but unused
    1886   [ +  +  +  +  :        6983 :    if (usepaw==1 .and. dt%cprj_in_memory/=0 .and. &
             +  -  -  + ]
    1887                 :             : &      (dt%invovl_algo/=0 .or. dt%invovl_dyn_prec/=0)) then
    1888                 :           0 :      write(msg,'(a)') 'invovl_algo and invovl_dyn_prec have no effect with cprj_in_memory/=0 (inverse overlap not used).'
    1889                 :           0 :      ABI_WARNING(msg)
    1890                 :             :    end if
    1891   [ +  +  +  -  :        6983 :    if (dt%invovl_algo/=0 .and. (dt%wfoptalg==1 .or. dt%gpu_option==ABI_GPU_LEGACY .or. dt%gpu_option==ABI_GPU_KOKKOS)) then
             +  -  -  + ]
    1892                 :           0 :      write(msg,'(a)') 'invovl_algo/=0 is only implemented for wfoptalg=111/112 with gpu_option=0 or 2. It will be ignored.'
    1893                 :           0 :      ABI_WARNING(msg)
    1894                 :             :    end if
    1895                 :             : 
    1896                 :             :    ! ionmov
    1897                 :             :    call chkint_eq(0,0,cond_string,cond_values,ierr,'ionmov',&
    1898                 :        6983 :      dt%ionmov,25, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,20,21,22,23,24,25,26,28],iout)
    1899                 :             : 
    1900                 :             :    ! When optcell/=0, ionmov must be 2, 3, 13, 22 or 25, 28 (except if imgmov>0)
    1901         [ +  + ]:        6983 :    if(dt%optcell/=0)then
    1902         [ +  - ]:          97 :      if (dt%imgmov==0) then
    1903                 :          97 :        cond_string(1)='optcell' ; cond_values(1)=dt%optcell
    1904                 :          97 :        call chkint_eq(1,1,cond_string,cond_values,ierr,'ionmov',dt%ionmov,8,[2,3,13,15,16,22,25,28],iout)
    1905                 :             :      else
    1906                 :           0 :        cond_string(1)='optcell' ; cond_values(1)=dt%optcell
    1907                 :           0 :        call chkint_eq(1,1,cond_string,cond_values,ierr,'ionmov',dt%ionmov,1,(/0/),iout)
    1908                 :             :      end if
    1909                 :             :    end if
    1910         [ +  + ]:        6983 :    if (dt%ionmov == 13) then
    1911                 :           5 :      cond_string(1)='ionmov' ; cond_values(1)=dt%ionmov
    1912                 :             : !    Make sure that nnos is not null
    1913                 :           5 :      call chkint_ge(1,1,cond_string,cond_values,ierr,'nnos',dt%nnos,1,iout)
    1914                 :             :    end if
    1915                 :             : 
    1916                 :             : !  iprcel
    1917                 :        6983 :    call chkint(0,0,cond_string,cond_values,ierr,'iprcel',dt%iprcel,1,(/0/),1,21,iout)
    1918                 :             :    if(nsppol==2 .and. (dt%occopt>=3 .and. dt%occopt<=9).and.mod(dt%iprcel,10)>49 )then
    1919                 :             :      write(msg,'(5a)')&
    1920                 :             :      'For spin-polarized metallic systems (occopt>3),',ch10,&
    1921                 :             :      'only RPA dielectric matrix can be evaluated) !',ch10,&
    1922                 :             :      'Action: change iprcel value in input file (mod(iprcel,100)<50) !'
    1923                 :             :      ABI_ERROR_NOSTOP(msg, ierr)
    1924                 :             :    end if
    1925   [ +  +  -  + ]:        6983 :    if(dt%npspinor>1.and.dt%iprcel>0)then
    1926                 :             :      write(msg,'(5a)')&
    1927                 :           0 :      'When parallelization over spinorial components is activated (npspinor>1),',ch10,&
    1928                 :           0 :      'only model dielectric function is allowed (iprcel=0) !',ch10,&
    1929                 :           0 :      'Action: change iprcel value in input file !'
    1930                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    1931                 :             :    end if
    1932         [ +  + ]:        6983 :    if(dt%iprcel>=200 .and. dt%iprcel<300) then
    1933                 :             : 
    1934                 :           2 :      cond_string(1)='iprcel' ; cond_values(1)=dt%iprcel
    1935                 :             :      !Implemented models for chi0-based preconditioning are 200, 201, 202, [203, 210, 211, 212, 299]
    1936                 :           2 :      call chkint_eq(1, 1, cond_string, cond_values(1), ierr, 'iprcel', dt%iprcel, 8, [200, 201, 202, 203, 210, 211, 212, 299], iout)
    1937                 :             :      !chi0-based preconditioning (iprcel=2**) incompatible with fft-grid parallelization.
    1938                 :           2 :      call chkint_eq(1, 1, cond_string, cond_values, ierr, 'npfft', dt%npfft, 1, [1], iout)
    1939                 :             :      !chi0-based preconditioning (iprcel=2**) needs a smooth smearing.
    1940                 :           2 :      call chkint_eq(1, 1, cond_string, cond_values, ierr, 'occopt', dt%occopt, 5, [3, 4, 5, 6, 7], iout)
    1941                 :             :      !chi0-based preconditioning (iprcel=2**) only implemented on the fine grid (PAW).
    1942         [ -  + ]:           2 :      if (usepaw==1) then
    1943                 :           0 :        call chkint_eq(1, 1, cond_string, cond_values, ierr, 'pawmixdg', dt%pawmixdg, 1, [1], iout)
    1944                 :             :      end if
    1945                 :             :      !chi0-based preconditioning without RPA (iprcel=201/2/3) incompatible with non-collinear magnetism and non-LDA functionals.
    1946         [ +  + ]:           2 :      if (dt%iprcel>=201 .and. dt%iprcel<=203) then
    1947         [ +  - ]:           1 :        if (.not. xc_is_lda) then
    1948                 :           1 :          cond_string(2)='ixc' ; cond_values(2)=dt%ixc
    1949                 :           1 :          call chkint_ne(1, 2, cond_string, cond_values, ierr, 'nspden', dt%nspden, 1, [4], iout)
    1950                 :             :        end if
    1951                 :             :      end if
    1952                 :             :      !Hybrid preconditioning (iprcel=202/3)
    1953         [ +  + ]:           2 :      if (dt%iprcel>=202 .and. dt%iprcel<=203) then
    1954                 :             :        !Hybrid preconditioning (iprcel=202/3) not (yet) implemented with band parallelisation and non-collinear magnetism.
    1955         [ -  + ]:           1 :        if (dt%nspden>2) then
    1956                 :           0 :          cond_string(2)='nspden' ; cond_values(2)=dt%nspden
    1957                 :           0 :          call chkint_eq(1, 2, cond_string, cond_values, ierr, 'npband', dt%npband, 1, [1], iout)
    1958                 :             :        end if
    1959                 :             :        !Hybrid preconditioning (iprcel=202/3) needs nsppol=2 => nspden=2 and nspinor=2 => nspden=4
    1960         [ +  - ]:           1 :        if (dt%nsppol==2) then
    1961                 :           1 :          cond_string(2)='nsppol' ; cond_values(2)=dt%nsppol
    1962                 :           1 :          call chkint_eq(1, 2, cond_string, cond_values, ierr, 'nspden', dt%nspden, 1, [2], iout)
    1963                 :             :        end if
    1964         [ -  + ]:           1 :        if (dt%nspinor==2) then
    1965                 :           0 :          cond_string(2)='nspinor' ; cond_values(2)=dt%nspinor
    1966                 :           0 :          call chkint_eq(1, 2, cond_string, cond_values, ierr, 'nspden', dt%nspden, 1, [4], iout)
    1967                 :             :        end if
    1968                 :             :        !Hybrid preconditioning (iprcel=202/3) needs precon_in_memory=1 with band parallelization.
    1969         [ -  + ]:           1 :        if (dt%npband>1) then
    1970                 :           0 :         cond_string(2)='npband' ; cond_values(2)=dt%npband
    1971                 :           0 :         call chkint_eq(1, 2, cond_string, cond_values, ierr, 'precon_in_memory', dt%precon_in_memory, 1, [1], iout)
    1972                 :             :       end if
    1973                 :             :      end if
    1974                 :             : 
    1975                 :             :    end if
    1976                 :             : 
    1977                 :             :    ! irandom
    1978                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'irandom',dt%irandom,3, [1,2,3], iout)
    1979                 :             : 
    1980                 :             :    ! iscf
    1981         [ +  - ]:        6983 :    if (usewvl ==0) then
    1982                 :             :      call chkint_eq(0,0,cond_string,cond_values,ierr,&
    1983                 :        6983 :       'iscf',dt%iscf,18, [-3,-2,-1,1,2,3,4,5,6,7,11,12,13,14,15,16,17,22], iout)
    1984                 :             :    else
    1985                 :             : !    If usewvl: wvlbigdft indicates that the BigDFT workflow will be followed
    1986   [ #  #  #  # ]:           0 :      wvlbigdft=(dt%usewvl==1.and.dt%wvl_bigdft_comp==1)
    1987                 :           0 :      cond_string(1)='wvl_bigdft_comp' ; cond_values(1)=dt%wvl_bigdft_comp
    1988         [ #  # ]:           0 :      if(wvlbigdft) then
    1989                 :             :        call chkint_eq(1,1,cond_string,cond_values,ierr,&
    1990                 :           0 :         'iscf',dt%iscf,15,(/0,1,2,3,4,5,6,7,11,12,13,14,15,16,17/),iout)
    1991                 :             :      else
    1992                 :             :        call chkint_eq(1,1,cond_string,cond_values,ierr,&
    1993                 :           0 :         'iscf',dt%iscf,18,(/-3,-2,-1,1,2,3,4,5,6,7,11,12,13,14,15,16,17,22/),iout)
    1994                 :             :      end if
    1995                 :             : !    If wvl+metal, iscf cannot be 0
    1996         [ #  # ]:           0 :      if (dt%occopt>2) then
    1997                 :           0 :        cond_string(1)='occopt' ; cond_values(1)=dt%occopt
    1998                 :             :        call chkint_eq(1,1,cond_string,cond_values,ierr,&
    1999                 :           0 :         'iscf',dt%iscf,18,(/-3,-2,-1,1,2,3,4,5,6,7,11,12,13,14,15,16,17,22/),iout)
    2000                 :             :      end if
    2001                 :             :    end if
    2002                 :             : 
    2003                 :             :    ! If ionmov==4, iscf must be 2, 12, 5 or 6.
    2004         [ +  + ]:        6983 :    if(dt%ionmov==4)then
    2005                 :           6 :      cond_string(1)='ionmov' ; cond_values(1)=dt%ionmov
    2006                 :           6 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'iscf',dt%iscf,4,(/2,12,5,6/),iout)
    2007                 :             :    end if
    2008                 :             : !  If PAW, iscf cannot be -1, 11
    2009         [ +  + ]:        6983 :    if (usepaw==1 .and. usewvl==0) then
    2010                 :        1205 :      cond_string(1)='usepaw' ; cond_values(1)=usepaw
    2011                 :        1205 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'iscf',dt%iscf,11,(/-3,-2,2,3,4,7,12,13,14,17,22/),iout)
    2012                 :             :    end if
    2013                 :             : !  Mixing on density is only allowed for GS calculations or for drivers where it is not used.
    2014   [ +  +  +  +  :       59305 :    if(optdriver /= RUNL_GSTATE .and. all(optdriver /= [RUNL_SCREENING,RUNL_SIGMA,RUNL_BSE,RUNL_EPH, &
                   +  + ]
    2015                 :             :      RUNL_WFK,RUNL_NONLINEAR,RUNL_RTTDDFT, RUNL_GWR])) then
    2016                 :         745 :      cond_string(1)='optdriver' ; cond_values(1)=optdriver
    2017                 :         745 :      call chkint_le(1,1,cond_string,cond_values,ierr,'iscf',dt%iscf,9,iout)
    2018                 :             :    end if
    2019                 :             : !  When pawoptmix=1 and nspden=4, iscf must be >=10
    2020   [ +  +  -  + ]:        6983 :    if(dt%pawoptmix/=0.and.nspden==4)then
    2021                 :           0 :      cond_string(1)='nspden'    ; cond_values(1)=nspden
    2022                 :           0 :      cond_string(2)='pawoptmix' ; cond_values(2)=dt%pawoptmix
    2023                 :           0 :      call chkint_ge(2,2,cond_string,cond_values,ierr,'iscf',dt%iscf,10,iout)
    2024                 :             :    end if
    2025                 :             : 
    2026                 :             : !  istatimg
    2027                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'istatimg',dt%istatimg,2,(/0,1/),iout)
    2028         [ -  + ]:        6983 :    if (dt%string_algo==STRING_ALGO_SIMPLIFIED_ENERGY) then
    2029                 :           0 :      cond_string(1)='string_algo' ; cond_values(1)=dt%string_algo
    2030                 :           0 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'istatimg',dt%istatimg,1,(/1/),iout)
    2031                 :             :    end if
    2032                 :             : 
    2033                 :             : !  istwfk
    2034   [ +  +  +  +  :      120432 :    if(dt%usefock==1 .and. dt%optdriver/=RUNL_SIGMA .and. mod(dt%wfoptalg,10)/=5 .and. maxval(abs(dt%istwfk(1:nkpt)-1)) > 0 .and. nkpt > 1 ) then
          +  +  +  -  -  
                      + ]
    2035                 :             :      write(msg,'(3a)' )&
    2036                 :           0 :       'When usefock==1 and several k-points, unless sigma calculation, all the components of istwfk must be 1.',ch10,&
    2037                 :           0 :       'Action: set istwfk to 1 for all k-points'
    2038                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    2039                 :             :    end if
    2040                 :             : 
    2041   [ +  +  -  +  :      120432 :    if(dt%usewvl==1 .and. maxval( abs(dt%istwfk(1:nkpt)-1) ) >0)then
                   -  - ]
    2042                 :             :      write(msg,'(3a)' )&
    2043                 :           0 :       'When usewvl==1, all the components of istwfk must be 1.',ch10,&
    2044                 :           0 :       'Action: set istwfk to 1 for all k-points'
    2045                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    2046                 :             :    end if
    2047                 :             : 
    2048   [ +  +  +  +  :      120432 :    if(response==1 .and. maxval( abs(dt%istwfk(1:nkpt)-1) ) >0)then
                   -  + ]
    2049                 :             :      ! Force istwfk to be 1 for RF calculations
    2050                 :             :      ! Other choices cannot be realized yet, because of the ddk perturbation.
    2051                 :             :      write(msg,'(5a)' )&
    2052                 :           0 :      'When response==1, all the components of istwfk must be 1.',ch10,&
    2053                 :           0 :      'Not yet programmed for time-reversal symmetry.',ch10,&
    2054                 :           0 :      'Action: set istwfk to 1 for all k-points'
    2055                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    2056                 :             :    end if
    2057   [ +  +  +  +  :      120432 :    if(dt%nbandkss/=0 .and. dt%kssform/=3 .and. maxval( abs(dt%istwfk(1:nkpt)-1) ) >0)then
             +  +  -  + ]
    2058                 :             :      write(msg,'(5a)' )&
    2059                 :           0 :      'When nbandkss/=0 and kssform/=3 all the components of istwfk must be 1.',ch10,&
    2060                 :           0 :      'Not yet programmed for time-reversal symmetry.',ch10,&
    2061                 :           0 :      'Action: set istwfk to 1 for all k-points'
    2062                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    2063                 :             :    end if
    2064   [ +  +  +  +  :      172693 :    if(dt%berryopt/=0 .and. maxval(dt%istwfk(:))/=1)then
                   -  + ]
    2065                 :             :      write(msg,'(5a)' )&
    2066                 :           0 :      'When berryopt/=0, all the components of istwfk must be 1.',ch10,&
    2067                 :           0 :      'Not yet programmed for time-reversal symmetry.',ch10,&
    2068                 :           0 :      'Action: set istwfk to 1 for all k-points'
    2069                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    2070                 :             :    end if
    2071   [ +  +  -  +  :      120432 :    if ( dt%gpu_option/=0 .and. dt%gpu_option/=2 .and. maxval( abs(dt%istwfk(1:nkpt)-1) ) > 0 ) then
                   -  - ]
    2072                 :             :      write(msg,'(3a)' )&
    2073                 :           0 :       'When gpu_option is neither 0 nor 2, all the components of istwfk must be 1.',ch10,&
    2074                 :           0 :       'Action: set istwfk to 1 for all k-points or change gpu_option.'
    2075                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    2076                 :             :    end if
    2077                 :             : 
    2078   [ +  +  +  +  :      108545 :    if ( dt%npfft>1 .and. any( dt%istwfk(1:nkpt) > 2 ) ) then
             +  +  -  + ]
    2079                 :             :      write(msg,'(3a)' )&
    2080                 :           0 :       'When npfft>1, all the components of istwfk must be 1 or 2.',ch10,&
    2081                 :           0 :       'Action: set "npfft 1" or set "istwfk *1" in the input file. If only one k-point which is "0 0 0" then set "istwfk 2".'
    2082                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    2083                 :             :    end if
    2084                 :             : 
    2085                 :             : !  ixc
    2086                 :             :    call chkint(0,0,cond_string,cond_values,ierr,&
    2087                 :        6983 : &   'ixc',dt%ixc,36,(/0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,20,21,22,23,24,26,27,31,32,33,34,35,40,41,42,50,51,60/),-1,0,iout) ! One of the values, or negative
    2088         [ +  + ]:        6983 :    if(dt%iscf==-1)then
    2089                 :          22 :      cond_string(1)='iscf' ; cond_values(1)=dt%iscf
    2090                 :             : !    Make sure that ixc is 1, 7, 8, 20, 21 or 22  (native functionals only for TDDFT - LibXC functionals have not been tested !)
    2091                 :          22 :      call chkint(1,1,cond_string,cond_values,ierr,'ixc',dt%ixc,6,(/1,7,8,20,21,22/),0,0,iout)
    2092                 :             :    end if
    2093         [ +  + ]:        6983 :    if(response==1)then
    2094                 :         754 :      cond_string(1)='response' ; cond_values(1)=response
    2095                 :             : !    Make sure that ixc is between 0 and 9, or 11, 12, 14, 15, 23 or 24 or negative
    2096                 :             :      call chkint(1,1,cond_string,cond_values,ierr,&
    2097                 :         754 :       'ixc',dt%ixc,17,(/0,1,2,3,4,5,6,7,8,9,11,12,14,15,23,24,51/),-1,0,iout)
    2098                 :             :    end if
    2099         [ +  + ]:        6983 :    if(nspden/=1)then
    2100                 :        1963 :      cond_string(1)='nspden' ; cond_values(1)=nspden
    2101                 :             : !    Make sure that ixc is 0, 1 , the gga, or Fermi-Amaldi, or negative
    2102                 :             :      call chkint(1,1,cond_string,cond_values,ierr,&
    2103                 :        1963 :       'ixc',dt%ixc,25,(/0,1,7,8,9,11,12,13,14,15,16,17,20,23,24,26,27,31,32,33,34,35,40,41,42/),-1,0,iout)
    2104                 :             :    end if
    2105   [ +  +  +  + ]:        6983 :    if (dt%usepaw>0.and.(dt%ixc==-427.or.dt%ixc==-428)) then
    2106                 :           4 :      ABI_WARNING('Range-separated Hybrid Functionals have not been extensively tested in PAW!!!')
    2107                 :             :    end if
    2108   [ +  +  +  +  :        6983 :    allowed=((xc_is_lda.and.dt%ixc<0).or.dt%ixc==0.or.dt%ixc==3.or.dt%ixc==7.or.dt%ixc==8)
                   +  + ]
    2109                 :             :    if(.not.allowed)then
    2110                 :        5469 :      cond_string(1)='ixc' ; cond_values(1)=dt%ixc
    2111                 :        5469 :      call chkint_ne(1,1,cond_string,cond_values,ierr,'optdriver',dt%optdriver,1,(/RUNL_NONLINEAR/),iout)
    2112                 :             :    end if
    2113         [ +  + ]:        6983 :    if (xc_is_mgga) then
    2114                 :             : !    mGGA not allowed for different drivers
    2115                 :          59 :      cond_string(1)='ixc' ; cond_values(1)=dt%ixc
    2116                 :             :      call chkint_ne(1,1,cond_string,cond_values,ierr,'optdriver',dt%optdriver,5, &
    2117                 :          59 :        [RUNL_SCREENING,RUNL_SIGMA,RUNL_BSE,RUNL_NONLINEAR,RUNL_LONGWAVE, RUNL_GWR, RUNL_EPH], iout)
    2118                 :             :    end if
    2119                 :             : 
    2120                 :             : !  ixcpositron
    2121                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'ixcpositron',dt%ixcpositron,8,(/0,-1,1,11,2,3,31,4/),iout)
    2122                 :             : 
    2123                 :             : !  ixcrot
    2124                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'ixcrot',dt%ixcrot,3,(/1,2,3/),iout)
    2125         [ +  + ]:        6983 :    if(dt%rfmagn/=0)then
    2126         [ +  + ]:          12 :      if(dt%ixcrot/=3)then
    2127                 :           2 :        cond_string(1)='rfmagn' ; cond_values(1)=dt%rfmagn
    2128                 :           2 :        cond_string(2)='ixcrot' ; cond_values(2)=dt%ixcrot
    2129                 :           2 :        call chkdpr(1,2,cond_string,cond_values,ierr,'qptn(1)',dt%qptn(1),0,zero,iout)
    2130                 :           2 :        call chkdpr(1,2,cond_string,cond_values,ierr,'qptn(2)',dt%qptn(2),0,zero,iout)
    2131                 :           2 :        call chkdpr(1,2,cond_string,cond_values,ierr,'qptn(3)',dt%qptn(3),0,zero,iout)
    2132                 :             :      end if
    2133                 :             :    endif
    2134                 :             : 
    2135                 :             : !  tim1rev
    2136                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'tim1rev',dt%tim1rev,2,(/0,1/),iout)
    2137                 :             : 
    2138                 :             : !  kptnrm and kpt
    2139                 :             : !  Coordinates components must be between -1 and 1.
    2140         [ -  + ]:        6983 :    if(dt%kptnrm<1.0-1.0d-10)then
    2141                 :             :      write(msg, '(a,es22.14,a,a,a)' )&
    2142                 :           0 :       'The input variable kptnrm is',dt%kptnrm,' while it must be >=1.0_dp.',ch10,&
    2143                 :           0 :       'Action: change the input variable kptnrm.'
    2144                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    2145                 :             :    end if
    2146         [ +  + ]:      120432 :    do ikpt=1,nkpt
    2147         [ +  + ]:      460779 :      do mu=1,3
    2148         [ -  + ]:      453796 :        if ( abs(dt%kpt(mu,ikpt))> dt%kptnrm*1.0000001_dp ) then
    2149                 :             :          write(msg, '(a,i5,a,a,a,a,3es22.14,a,a,a,a)' )&
    2150                 :           0 :           'For k point number',ikpt,'  the reduced coordinates',ch10,&
    2151                 :           0 :           'generated by the input variables kpt and kptnrm are',ch10,&
    2152                 :           0 :           dt%kpt(1,ikpt)/dt%kptnrm,dt%kpt(2,ikpt)/dt%kptnrm,dt%kpt(3,ikpt)/dt%kptnrm,ch10,&
    2153                 :           0 :           'while they must be between -1.0_dp and 1.0_dp (included).',ch10,&
    2154                 :           0 :           'Action: check kpt and kptnrm in the input file.'
    2155                 :           0 :          ABI_ERROR_NOSTOP(msg, ierr)
    2156                 :             :        end if
    2157                 :             :      end do
    2158                 :             :    end do
    2159                 :             : 
    2160                 :             : !  jellslab
    2161                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'jellslab',dt%jellslab,2,(/0,1/),iout)
    2162                 :             : 
    2163         [ +  + ]:        6983 :    if (dt%jellslab==1) then
    2164         [ -  + ]:           6 :      if(dt%nimage>1)then
    2165                 :           0 :        cond_string(1)='nimage' ; cond_values(1)=dt%nimage
    2166                 :           0 :        call chkint_eq(1,1,cond_string,cond_values,ierr,'jellslab',dt%jellslab,1,(/0/),iout)
    2167                 :             :      end if
    2168                 :             : !    slabwsrad must be positive
    2169                 :           6 :      cond_string(1)='jellslab' ; cond_values(1)=dt%jellslab
    2170                 :           6 :      call chkdpr(1,1,cond_string,cond_values,ierr,'slabwsrad',dt%slabwsrad,1,zero,iout)
    2171                 :             : !    slabzbeg must be positive
    2172                 :           6 :      call chkdpr(1,1,cond_string,cond_values,ierr,'slabzbeg',dt%slabzbeg,1,zero,iout)
    2173                 :             : !    slabzend must be bigger than slabzbeg
    2174                 :           6 :      call chkdpr(1,1,cond_string,cond_values,ierr,'slabzend',dt%slabzend,1,dt%slabzbeg,iout)
    2175                 :             : !    rprimd(3,3) must be bigger than slabzend
    2176                 :           6 :      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd33',rprimd(3,3),1,dt%slabzend,iout)
    2177                 :             : !    Third real space primitive translation has to be orthogonal to the other ones,
    2178                 :             : !    actually, for convenience it is useful that rprimd is something like:
    2179                 :             : !    a  b  0
    2180                 :             : !    c  d  0
    2181                 :             : !    0  0  e
    2182         [ -  + ]:           6 :      if(abs(rprimd(1,3))+abs(rprimd(2,3))+abs(rprimd(3,1))+abs(rprimd(3,2))>tol12) then
    2183                 :             :        write(msg,'(3a)')&
    2184                 :           0 :         'Third real space vector is not orthogonal to the other ones,',ch10,&
    2185                 :           0 :         'this is needed to use jellium'
    2186                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    2187                 :             :      end if
    2188                 :             : 
    2189                 :             : !    Atoms have to be placed in the vacuum space
    2190         [ +  + ]:          12 :      do iatom=1,natom
    2191                 :           6 :        zatom=(dt%xred_orig(3,iatom,intimage)-anint(dt%xred_orig(3,iatom,intimage)-half+tol6))*rprimd(3,3)
    2192   [ +  +  -  + ]:           6 :        if(abs(zatom-dt%slabzbeg)<tol8 .or. abs(zatom-dt%slabzend)<tol8) then
    2193         [ -  + ]:           2 :          if(dt%znucl(dt%typat(iatom))>tol6) then
    2194                 :           0 :            write(msg,'(a,i0,a)')'atom number=',iatom,' lies precisely on the jellium edge !'
    2195                 :           0 :            ABI_WARNING(msg)
    2196                 :             :          end if
    2197                 :             :          cycle
    2198                 :             :        end if
    2199   [ -  +  -  - ]:          10 :        if(zatom>dt%slabzbeg .and. zatom<dt%slabzend) then
    2200                 :           0 :          write(msg,'(a,i0,a)')' atom number=',iatom,' is inside the jellium slab.'
    2201                 :           0 :          ABI_ERROR_NOSTOP(msg, ierr)
    2202                 :             :        end if
    2203                 :             :      end do
    2204                 :             :    end if
    2205                 :             : 
    2206                 :             : !  kptopt
    2207                 :        6983 :    call chkint_le(0,0,cond_string,cond_values,ierr,'kptopt',dt%kptopt,4,iout)
    2208                 :             :   ! If kptopt < 0, it is only valid when iscf = -2
    2209         [ +  + ]:        6983 :    if (dt%iscf/=-2) then
    2210                 :        6489 :       cond_string(1)='iscf' ; cond_values(1)=dt%iscf
    2211                 :        6489 :       call chkint_ge(1,1,cond_string,cond_values,ierr,'kptopt',dt%kptopt,0,iout)
    2212                 :             :    end if
    2213                 :             :   ! If hspinfield is applied, only kptopt = 0, 3, 4 are allowed
    2214   [ +  +  +  +  :       27914 :    if (any(abs(dt%hspinfield)>tol8)) then
                   +  + ]
    2215                 :          12 :       cond_string(1) = 'hspinfield(x)' ; cond_values(1) = dt%hspinfield(1)
    2216                 :          12 :       cond_string(2) = 'hspinfield(y)' ; cond_values(2) = dt%hspinfield(2)
    2217                 :          12 :       cond_string(3) = 'hspinfield(z)' ; cond_values(3) = dt%hspinfield(3)
    2218                 :          12 :       call chkint_eq(3,3,cond_string,cond_values,ierr,'kptopt',dt%kptopt,3,(/0,3,4/),iout)
    2219                 :             :    end if
    2220                 :             : 
    2221                 :             : !  kssform
    2222                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'kssform',dt%kssform,3,(/0,1,3/),iout)
    2223                 :             : 
    2224   [ +  -  +  + ]:        6983 :    if (dt%kssform/=0 .and. dt%nbandkss/=0) then ! Check for outkss limitations.
    2225                 :           6 :      call wrtout(std_out," Checking if input is consistent with KSS generation")
    2226                 :           6 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'paral_kgb',dt%paral_kgb,1,(/0/),iout)
    2227                 :           6 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'iomode',dt%iomode,2,(/IO_MODE_FORTRAN,IO_MODE_ETSF/),iout)
    2228                 :             :    end if
    2229                 :             : 
    2230                 :             : !  localrdwf
    2231                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'localrdwf',dt%localrdwf,2,(/0,1/),iout)
    2232         [ -  + ]:        6983 :    if(dt%mkmem==0)then
    2233                 :           0 :      cond_string(1)='mkmem' ; cond_values(1)=dt%mkmem
    2234                 :           0 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'localrdwf',dt%localrdwf,1,(/1/),iout)
    2235                 :             :    end if
    2236         [ -  + ]:        6983 :    if(dt%mkqmem==0)then
    2237                 :           0 :      cond_string(1)='mkqmem' ; cond_values(1)=dt%mkqmem
    2238                 :           0 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'localrdwf',dt%localrdwf,1,(/1/),iout)
    2239                 :             :    end if
    2240         [ -  + ]:        6983 :    if(dt%mk1mem==0)then
    2241                 :           0 :      cond_string(1)='mk1mem' ; cond_values(1)=dt%mk1mem
    2242                 :           0 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'localrdwf',dt%localrdwf,1,(/1/),iout)
    2243                 :             :    end if
    2244         [ +  + ]:        6983 :    if(dt%iomode==IO_MODE_MPI)then
    2245                 :          28 :      cond_string(1)='iomode' ; cond_values(1)=dt%iomode
    2246                 :          28 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'localrdwf',dt%localrdwf,1,(/1/),iout)
    2247                 :             :    end if
    2248                 :             : 
    2249                 :             : 
    2250                 :             : !  LOTF
    2251                 :             : #if defined HAVE_LOTF
    2252                 :             :    if (dt%ionmov==23) then
    2253                 :             :      write(msg, '(a,a)' ) ch10, '=== LOTF METHOD ================================================================'
    2254                 :             :      call wrtout(ab_out,msg)
    2255                 :             :      cond_string(1)='ionmov' ; cond_values(1)=dt%ionmov
    2256                 :             :      call chkint_eq(0,1,cond_string,cond_values,ierr,'lotf_classic',dt%lotf_classic,1,(/5/),iout)
    2257                 :             :      call chkint_ge(0,1,cond_string,cond_values,ierr,'lotf_nitex',dt%lotf_nitex,1,iout)
    2258                 :             :      call chkint_ge(0,1,cond_string,cond_values,ierr,'lotf_nneigx',dt%lotf_nneigx,2,iout)
    2259                 :             :      call chkint_eq(0,1,cond_string,cond_values,ierr,'lotf_version',dt%lotf_version,1,(/2/),iout)
    2260                 :             :    end if
    2261                 :             : #endif
    2262                 :             : 
    2263                 :             : ! lw_flexo
    2264                 :        6983 :   call chkint_eq(0,0,cond_string,cond_values,ierr,'lw_flexo',dt%lw_flexo,5,(/0,1,2,3,4/),iout)
    2265         [ +  + ]:        6983 :   if(dt%lw_flexo/=0)then
    2266                 :           3 :     cond_string(1)='lw_flexo' ; cond_values(1)=dt%lw_flexo
    2267                 :           3 :     call chkint_eq(1,1,cond_string,cond_values,ierr,'optdriver',dt%optdriver,1,(/RUNL_LONGWAVE/),iout)
    2268                 :             :   end if
    2269                 :             : 
    2270                 :             : ! lw_qdrpl
    2271                 :        6983 :   call chkint_eq(0,0,cond_string,cond_values,ierr,'lw_qdrpl',dt%lw_qdrpl,2,(/0,1/),iout)
    2272         [ +  + ]:        6983 :   if(dt%lw_qdrpl/=0)then
    2273                 :           7 :     cond_string(1)='lw_qdrpl' ; cond_values(1)=dt%lw_qdrpl
    2274                 :           7 :     call chkint_eq(1,1,cond_string,cond_values,ierr,'optdriver',dt%optdriver,1,(/RUNL_LONGWAVE/),iout)
    2275                 :             :   end if
    2276                 :             : 
    2277                 :             : ! lw_natopt
    2278                 :        6983 :   call chkint_eq(0,0,cond_string,cond_values,ierr,'lw_natopt',dt%lw_natopt,2,(/0,1/),iout)
    2279         [ +  + ]:        6983 :   if(dt%lw_natopt/=0)then
    2280                 :           1 :     cond_string(1)='lw_natopt' ; cond_values(1)=dt%lw_natopt
    2281                 :           1 :     call chkint_eq(1,1,cond_string,cond_values,ierr,'optdriver',dt%optdriver,1,(/RUNL_LONGWAVE/),iout)
    2282                 :             :   end if
    2283                 :             : 
    2284                 :             : !  magconon
    2285                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'magconon',dt%magconon,3,(/0,1,2/),iout)
    2286                 :             : !!  impose nspden 4 for the moment and spinors
    2287                 :             : !   if (dt%magconon == 1) then
    2288                 :             : !     if (dt%nspinor /= 2 .or. dt%nspden /= 4) then
    2289                 :             : !       write (msg, '(4a)') &
    2290                 :             : !&       ' magnetization direction constraint is only compatible with non-collinear calculations', ch10,&
    2291                 :             : !&       ' Action: set nspinor 2 and nspden 4 in the input file.'
    2292                 :             : !       ABI_ERROR_NOSTOP(msg,ierr)
    2293                 :             : !     end if
    2294                 :             : !   end if
    2295                 :             : 
    2296                 :             : !  magpen
    2297         [ +  + ]:        6983 :    if(dt%magpen/=zero)then
    2298                 :           7 :      cond_string(1)='magpen' ; cond_values(1)=dt%magpen
    2299                 :           7 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'nspden',dt%nspden,1,(/4/),iout)
    2300                 :             :    end if
    2301                 :             : 
    2302                 :             : !  macro_uj
    2303         [ +  + ]:        6983 :    if(dt%macro_uj/=0) then
    2304         [ -  + ]:          10 :      if (dt%ionmov/=0) then
    2305                 :             :        write(msg, '(3a,i2,2a,i2,3a)' )&
    2306                 :           0 :         'Determination of U can not be combined with ionic movements.',ch10,&
    2307                 :           0 :         'Here  ionmov= ',dt%ionmov,ch10,&
    2308                 :           0 :         'and macro_uj=',dt%macro_uj,'.',ch10,&
    2309                 :           0 :         'Action: change ionmov in input file.'
    2310                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    2311         [ -  + ]:          10 :      else if (dt%nstep<3) then
    2312                 :             :        write(msg, '(3a,i1,2a,i2,3a)' )&
    2313                 :           0 :         'Determination of U needs at least 3 scf steps:',ch10,&
    2314                 :           0 :         ' nstep = ',dt%nstep,ch10,&
    2315                 :           0 :         ' and macro_uj=',dt%macro_uj,'.',ch10,&
    2316                 :           0 :         'Action: increase nstep in input file.'
    2317                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    2318   [ +  +  +  +  :         130 :      else if ((dt%pawujv==0.0d0).or.(sum(abs(dt%atvshift(1:dt%natvshift,1:dt%nsppol,dt%pawujat)))<1.0d-9)) then
             +  -  -  + ]
    2319                 :             :        write(msg,'(5a)')&
    2320                 :           0 :        'pawujv and/or atvshift found to be 0.0d0.',ch10,&
    2321                 :           0 :        'When engaging the linear response procedure, the perturbation strength',ch10,&
    2322                 :           0 :        'must be non-zero. Action: change pawujv and/or atvshift to a non-zero value.'
    2323                 :           0 :        ABI_ERROR(msg)
    2324                 :             :      end if
    2325                 :             :    end if
    2326                 :             : 
    2327                 :             : !  mep_solver
    2328                 :             :    call chkint_eq(0,0,cond_string,cond_values,ierr,'mep_solver',dt%mep_solver,&
    2329         [ +  + ]:       41898 : &    5,(/MEP_SOLVER_STEEPEST,MEP_SOLVER_QUICKMIN,MEP_SOLVER_LBFGS,MEP_SOLVER_GBFGS,MEP_SOLVER_RK4/),iout)
    2330                 :             : !  String method
    2331         [ +  + ]:        6983 :    if(dt%imgmov==2) then
    2332                 :          24 :      cond_string(1)='imgmov'      ; cond_values(1)=dt%imgmov
    2333                 :             : !    Some restriction for the solver
    2334         [ -  + ]:          24 :      if(dt%string_algo==STRING_ALGO_ORIGINAL)then
    2335                 :           0 :        cond_string(2)='string_algo' ; cond_values(2)=dt%string_algo
    2336                 :             :        call chkint_eq(1,1,cond_string,cond_values,ierr,'mep_solver',dt%mep_solver,&
    2337         [ #  # ]:           0 : &        1,(/MEP_SOLVER_STEEPEST/),iout)
    2338                 :             :      end if
    2339   [ -  +  -  - ]:          24 :      if(dt%string_algo==STRING_ALGO_SIMPLIFIED_EQUAL.or.&
    2340                 :             : &       dt%string_algo==STRING_ALGO_SIMPLIFIED_ENERGY)then
    2341                 :          24 :        cond_string(2)='string_algo' ; cond_values(2)=dt%string_algo
    2342                 :             :        call chkint_eq(1,1,cond_string,cond_values,ierr,'mep_solver',dt%mep_solver,&
    2343         [ +  + ]:          72 : &        2,(/MEP_SOLVER_STEEPEST,MEP_SOLVER_RK4/),iout)
    2344                 :             :      end if
    2345                 :             :    end if
    2346                 :             : !  NEB
    2347         [ +  + ]:        6983 :    if(dt%imgmov==5)then
    2348                 :           4 :      cond_string(1)='imgmov' ; cond_values(1)=dt%imgmov
    2349                 :             : !    Some restriction for the solver
    2350                 :             :      call chkint_eq(0,0,cond_string,cond_values,ierr,'mep_solver',dt%mep_solver,&
    2351         [ +  + ]:          20 : &    4,(/MEP_SOLVER_STEEPEST,MEP_SOLVER_QUICKMIN,MEP_SOLVER_LBFGS,MEP_SOLVER_GBFGS/),iout)
    2352                 :             : !    Only steepest descent for variable-cell NEB
    2353   [ +  +  -  + ]:           4 :      if (dt%neb_cell_algo/=NEB_CELL_ALGO_NONE.and.dt%mep_solver/=MEP_SOLVER_STEEPEST) then
    2354                 :             :        write(msg, '(5a)' )&
    2355                 :           0 :         'When using NEB with variable cell, you can only use',ch10,&
    2356                 :           0 :         ' steepest-descent algorithm (i.e. mep_solver=steepest-descent)!',ch10,&
    2357                 :           0 :         'Action: change mep_solver to 0.'
    2358                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    2359                 :             :      end if
    2360                 :             : !    Static image energy is needed if spring constant is variable
    2361   [ -  +  -  - ]:           4 :      if (abs(dt%neb_spring(1)-dt%neb_spring(2))>=tol8.and.dt%istatimg==0) then
    2362                 :             :        write(msg, '(7a)' )&
    2363                 :           0 :         'When using variable NEB spring constants (which is the default for CI-NEB),',ch10,&
    2364                 :           0 :         'all the energies of the cell images are needed (including static images!).',ch10,&
    2365                 :           0 :         'You cannot use istatimg=0!',ch10,&
    2366                 :           0 :         'Action: put istatimg=1 in input file.'
    2367                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    2368                 :             :      end if
    2369                 :             : !    Static image energy is needed for CI-NEB or improved tangent
    2370   [ +  +  +  +  :           4 :      if ((dt%neb_algo==NEB_ALGO_IMPROVED_TAN.or.dt%neb_algo==NEB_ALGO_CINEB).and.dt%istatimg==0) then
                   -  + ]
    2371                 :             :        write(msg, '(7a)' )&
    2372                 :           0 :         'When using Improved-tangent-NEB or CI-NEB,',ch10,&
    2373                 :           0 :         'all the energies of the cell images are needed (including static images!).',ch10,&
    2374                 :           0 :         'You cannot use istatimg=0!',ch10,&
    2375                 :           0 :         'Action: put istatimg=1 in input file.'
    2376                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    2377                 :             :      end if
    2378                 :             :    end if
    2379                 :             : 
    2380                 :             : !  mffmem
    2381                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'mffmem',dt%mffmem,2,(/0,1/),iout)
    2382                 :             : 
    2383                 :             : !  mixalch_orig
    2384                 :             : !  For each type of atom, the sum of the psp components must be one.
    2385         [ +  + ]:       14226 :    do iimage=1,dt%nimage
    2386         [ +  + ]:       14226 :      if(dt%ntypalch>0)then
    2387         [ +  + ]:          52 :        do itypat=1,dt%ntypalch
    2388         [ +  + ]:          94 :          sumalch=sum(dt%mixalch_orig(:,itypat,iimage))
    2389         [ -  + ]:          52 :          if(abs(sumalch-one)>tol10)then
    2390         [ #  # ]:           0 :            if(dt%npspalch<=6)then
    2391                 :           0 :              write(msg, '(2a,6es12.4)' )ch10,' chkinp: mixalch(:,itypat,iimage)=',dt%mixalch_orig(:,itypat,iimage)
    2392                 :             :            end if
    2393                 :           0 :            call wrtout(iout,msg)
    2394                 :           0 :            call wrtout(std_out,  msg)
    2395                 :             :            write(msg, '(a,i4,2a,i4,2a,f8.2,4a)' )&
    2396                 :           0 :             'For the alchemical atom number',itypat,ch10,&
    2397                 :           0 :             'image number',iimage,ch10,&
    2398                 :           0 :             'the sum of the pseudopotential coefficients is',sumalch,ch10,&
    2399                 :           0 :             'while it should be one.',ch10,&
    2400                 :           0 :             'Action: check the content of the input variable mixalch.'
    2401                 :           0 :            ABI_ERROR_NOSTOP(msg, ierr)
    2402                 :             :          end if
    2403                 :             :        end do
    2404                 :             :      end if
    2405                 :             :    end do
    2406                 :             : 
    2407                 :             : !  mixesimgf
    2408                 :             : !  The sum of the mixing image factors must be one
    2409         [ +  + ]:        6983 :    if(dt%imgmov==6)then
    2410         [ +  + ]:          18 :      summix=sum(dt%mixesimgf(1:dt%nimage))
    2411         [ -  + ]:           6 :      if(abs(summix-one)>tol10)then
    2412                 :           0 :        write(msg, '(2a,20es12.4)' )ch10,' chkinp: mixesimgf(1:dt%nimage)=',dt%mixesimgf(1:dt%nimage)
    2413                 :           0 :        call wrtout(iout,msg)
    2414                 :           0 :        call wrtout(std_out,  msg)
    2415                 :             :        write(msg, '(a,es12.4,4a)' )&
    2416                 :           0 :         'The sum of the mixing image factors is',summix,ch10,&
    2417                 :           0 :         'while it should be one.',ch10,&
    2418                 :           0 :         'Action: check the content of the input variable mixesimgf.'
    2419                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    2420                 :             :      end if
    2421                 :             :    end if
    2422                 :             : 
    2423                 :             : !  mpatpol
    2424                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'mpatpol(1)',dt%mpatpol(1),1,iout)
    2425                 :        6983 :    cond_string(1)='natom' ; cond_values(1)=natom
    2426                 :        6983 :    call chkint_le(1,1,cond_string,cond_values,ierr,'mpatpol(2)',dt%mpatpol(2),natom,iout)
    2427                 :             : 
    2428                 :             : !  natom
    2429         [ +  + ]:        6983 :    if(dt%prtgeo>0)then
    2430                 :          53 :      cond_string(1)='prtgeo' ; cond_values(1)=dt%prtgeo
    2431                 :          53 :      call chkint_le(1,1,cond_string,cond_values,ierr,'natom',natom,9999,iout)
    2432                 :             :    end if
    2433                 :             : 
    2434                 :             : !  nband
    2435                 :             : !  Make sure all nband(nkpt) are > 0
    2436         [ +  + ]:       15718 :    do isppol=1,nsppol
    2437         [ +  + ]:      133261 :      do ikpt=1,nkpt
    2438         [ -  + ]:      126278 :        if (dt%nband(ikpt+(isppol-1)*nkpt)<=0) then
    2439                 :           0 :          cond_string(1)='ikpt' ; cond_values(1)=ikpt
    2440                 :           0 :          cond_string(2)='isppol' ; cond_values(2)=isppol
    2441                 :           0 :          call chkint_ge(0,2,cond_string,cond_values,ierr,'nband',dt%nband(ikpt+(isppol-1)*nkpt),1,iout)
    2442                 :             :        end if
    2443                 :             :      end do
    2444                 :             :    end do
    2445   [ +  +  +  + ]:        6983 :    if(nproc/=1.and.nsppol==2.and.usewvl==0)then
    2446         [ +  + ]:         752 :      do ikpt=1,nkpt
    2447         [ -  + ]:         752 :        if (dt%nband(ikpt)/=dt%nband(ikpt+nkpt)) then
    2448                 :             :          write(msg, '(5a,i4,a,2i5,a)' )&
    2449                 :           0 :           'the number of bands in the spin up case must be equal to',ch10,&
    2450                 :           0 :           'the number of bands in the spin down case.',ch10,&
    2451                 :           0 :           'This is not the case for the k point number:',ikpt,&
    2452                 :           0 :           'The number of bands spin up and down are:',dt%nband(ikpt),dt%nband(ikpt+nkpt),&
    2453                 :           0 :           'Action: change nband, or use the sequential version of ABINIT.'
    2454                 :           0 :          ABI_ERROR_NOSTOP(msg, ierr)
    2455                 :             :        end if
    2456                 :             :      end do
    2457                 :             :    end if
    2458                 :             : 
    2459                 :             : !  nbdbuf
    2460                 :             : !  At this stage, nbdbuf Must be greater or equal to 0, or take the special value -101.
    2461                 :             : !  Note that other negative values are permitted in input, but immediately
    2462                 :             : !  transformed to a fraction of the number of bands hence a positive number.
    2463                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'nbdbuf',dt%nbdbuf,-101,iout)
    2464         [ +  + ]:        6983 :    if(dt%nbdbuf/=-101)then
    2465                 :        6968 :      cond_string(1)='nbdbuf' ; cond_values(1)=dt%nbdbuf
    2466                 :        6968 :      call chkint_ge(1,1,cond_string,cond_values,ierr,'nbdbuf',dt%nbdbuf,0,iout)
    2467                 :             :    endif
    2468                 :             : 
    2469                 :             : 
    2470                 :             : !  nbandkss
    2471                 :             : !  Must be greater or equal to -1
    2472                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'nbandkss',dt%nbandkss,-1,iout)
    2473                 :             : !  When ionmov/=0
    2474   [ +  +  -  + ]:        6983 :    if(dt%ionmov/=0 .and. dt%nbandkss/=0)then
    2475                 :             :      write(msg,'(11a)')&
    2476                 :           0 :       'Ions (or cell) are allowed to move (ionmov/=0),',ch10,&
    2477                 :           0 :       'and a _KSS file is requested (nbandkss/=0).',ch10,&
    2478                 :           0 :       'A _KSS file will be created at each geometry-optimisation step.',ch10,&
    2479                 :           0 :       'Note that this is time consuming !',ch10,&
    2480                 :           0 :       'Action: use datasets (one for geometry optimisation,',ch10,&
    2481                 :           0 :       '        one for states output).'
    2482                 :           0 :      ABI_WARNING(msg)
    2483                 :             :    end if
    2484                 :             : 
    2485                 :             : !  nbdblock
    2486                 :             : !  Must be greater or equal to 1
    2487                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'nbdblock',dt%nbdblock,1,iout)
    2488                 :             : !  When wfoptalg==0, nbdblock must be 1
    2489         [ +  + ]:        6983 :    if(mod(dt%wfoptalg,10)==0)then
    2490                 :        6268 :      cond_string(1)='wfoptalg' ; cond_values(1)=dt%wfoptalg
    2491                 :        6268 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'nbdblock',dt%nbdblock,1,(/1/),iout)
    2492                 :             :    end if
    2493                 :             : !  When wfoptalg==2, nbdblock must be 1
    2494         [ -  + ]:        6983 :    if(dt%wfoptalg==2)then
    2495                 :           0 :      cond_string(1)='wfoptalg' ; cond_values(1)=dt%wfoptalg
    2496                 :           0 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'nbdblock',dt%nbdblock,1,(/1/),iout)
    2497                 :             :    end if
    2498                 :             : !  When wfoptalg==3, nbdblock must be 1, and iscf must be -2
    2499         [ +  + ]:        6983 :    if(dt%wfoptalg==3)then
    2500                 :           2 :      cond_string(1)='wfoptalg' ; cond_values(1)=dt%wfoptalg
    2501                 :           2 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'nbdblock',dt%nbdblock,1,(/1/),iout)
    2502                 :           2 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'iscf',dt%iscf,1,(/-2/),iout)
    2503                 :             :    end if
    2504                 :             : !  When wfoptalg==4, nbdblock must be a divisor of nband
    2505   [ +  +  +  + ]:        6983 :    if(mod(dt%wfoptalg,10)==4.and.dt%optdriver==RUNL_GSTATE)then
    2506         [ +  + ]:         996 :      do isppol=1,nsppol
    2507         [ +  + ]:        3582 :        do ikpt=1,nkpt
    2508         [ -  + ]:        3098 :          if(mod(dt%nband(ikpt+(isppol-1)*nkpt),dt%nbdblock)/=0) then
    2509                 :             :            write(msg, '(5a)' )&
    2510                 :           0 :             'For the moment, when wfoptalg=4,',ch10,&
    2511                 :           0 :             'nband must be a multiple of nbdblock.',ch10,&
    2512                 :           0 :             'Action: check the value of the input variable nbdblock.'
    2513                 :           0 :            ABI_ERROR_NOSTOP(msg, ierr)
    2514                 :             :          end if
    2515                 :             :        end do
    2516                 :             :      end do
    2517                 :             :    end if
    2518                 :             : 
    2519                 :             : !  nberry
    2520                 :             : !  must be between 0 and 20
    2521         [ +  + ]:        6983 :    if(dt%berryopt/=0)then
    2522                 :          83 :      call chkint_ge(0,0,cond_string,cond_values,ierr,'nberry',dt%nberry,0,iout)
    2523                 :          83 :      call chkint_le(0,0,cond_string,cond_values,ierr,'nberry',dt%nberry,20,iout)
    2524                 :             :      if(xmpi_paral==1)then
    2525                 :             : !      MPI Parallel case
    2526                 :             :        if (dt%nberry/=0.and.dt%berryopt>0.and.&
    2527                 :             :            dt%berryopt/= 4.and.dt%berryopt/= 5.and.dt%berryopt/= 6.and.dt%berryopt/= 7.and.&
    2528   [ +  -  +  + ]:          83 :            dt%berryopt/=14.and.dt%berryopt/=15.and.dt%berryopt/=16.and.dt%berryopt/=17) then
    2529                 :             :          write(msg,'(a,a,a,a,a,i4,a,a,a)')&
    2530                 :           0 :           'Berry phase calculation of polarisation with positive berryopt is not',ch10,&
    2531                 :           0 :           'allowed in the parallel version of ABINIT.',ch10,&
    2532                 :           0 :           'So, the value of nberry=',dt%nberry,' is not allowed,',ch10,&
    2533                 :           0 :           'Action: change berryopt to negative values or change nberry, or use the sequential version.'
    2534                 :           0 :          ABI_ERROR_NOSTOP(msg, ierr)
    2535                 :             :        end if
    2536                 :             :      end if
    2537                 :             :    end if
    2538                 :             : 
    2539   [ +  +  -  + ]:        6983 :    if (dt%optcell /=0 .and. dt%berryopt == 4)  then
    2540                 :           0 :      write(msg,'(a,a,a,a,a,a,a,a,a,a,a,a,a)') ch10,&
    2541                 :           0 :       ' chkinp : WARNING -',ch10,&
    2542                 :           0 :       '  Constant unreduced E calculation with relaxation of cell parameters is allowed.',ch10,&
    2543                 :           0 :       '  But we strongly recommend users to use reduced ebar calculation (berryopt=14)',ch10,&
    2544                 :           0 :       '  with the relaxation of cell parameters, for internal consistency purpose.',ch10, &
    2545                 :           0 :       '  For more information, please refer to "M. Stengel, N.A. Spaldin and D.Vanderbilt,', ch10, &
    2546                 :           0 :       '  Nat. Phys., 5, 304,(2009)" and its supplementary notes.', ch10 ! [[cite:Stengel2009]]
    2547                 :           0 :      call wrtout(ab_out,msg)
    2548                 :           0 :      call wrtout(std_out,msg)
    2549                 :             :    end if
    2550                 :             : 
    2551   [ +  +  -  + ]:        6983 :    if (dt%optcell /=0 .and. (dt%berryopt == 6 ))  then
    2552                 :           0 :      write(msg,'(12a)') ch10,&
    2553                 :           0 :       ' chkinp : WARNING -',ch10,&
    2554                 :           0 :       '  Constant unreduced D calculation with relaxation of cell parameters is allowed.',ch10,&
    2555                 :           0 :       '  But we strongly recommend users to use reduced d calculation (berryopt=16)',ch10,&
    2556                 :           0 :       '  with the relaxation of cell parameters, for internal consistency purpose.',ch10, &
    2557                 :           0 :       '  For more information, please refer to "M. Stengel, N.A. Spaldin and D.Vanderbilt,', ch10, &
    2558                 :           0 :       '  Nat. Phys., 5, 304,(2009)" and its supplementary notes.' ! [[cite:Stengel2009]]
    2559                 :           0 :      call wrtout(ab_out,msg)
    2560                 :           0 :      call wrtout(std_out,msg)
    2561                 :             :    end if
    2562                 :             : 
    2563                 :             : !  ndynimage
    2564                 :             : !  Must be greater or equal to 1
    2565                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'ndynimage',dt%ndynimage,1,iout)
    2566                 :             : 
    2567                 :             : !  neb_algo
    2568                 :             :    call chkint_eq(0,0,cond_string,cond_values,ierr,'neb_algo',dt%neb_algo,&
    2569         [ +  + ]:       27932 : &    3,(/NEB_ALGO_STANDARD,NEB_ALGO_IMPROVED_TAN,NEB_ALGO_CINEB/),iout)
    2570                 :             : 
    2571                 :             : !  neb_cell_algo
    2572                 :             :    call chkint_eq(0,0,cond_string,cond_values,ierr,'neb_cell_algo',dt%neb_cell_algo,&
    2573         [ +  + ]:       27932 : &    3,(/NEB_CELL_ALGO_NONE,NEB_CELL_ALGO_GSSNEB,NEB_CELL_ALGO_VCNEB/),iout)
    2574                 :             :    !Forbid fixed atoms for variable-cell NEB
    2575         [ +  + ]:        6983 :    if (dt%neb_cell_algo/=NEB_CELL_ALGO_NONE) then
    2576   [ +  +  +  +  :           9 :      if (any(dt%iatfix(:,:)==1)) then
             +  -  -  + ]
    2577                 :             :        write(msg,'(3a)') &
    2578                 :           0 : &        'Having fixed atoms is forbidden when performing variable-cell',ch10,&
    2579                 :           0 : &        'mimimum energy path searching (NEB) (imgmov=5)!'
    2580                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    2581                 :             :      end if
    2582                 :             :    end if
    2583                 :             : 
    2584                 :             : !  nfft and nfftdg
    2585                 :             : !  Must have nfft<=nfftdg
    2586         [ +  + ]:        6983 :    if (usepaw==1) then
    2587                 :        1205 :      nfft  =dt%ngfft(1)  *dt%ngfft(2)  *dt%ngfft(3)
    2588                 :        1205 :      nfftdg=dt%ngfftdg(1)*dt%ngfftdg(2)*dt%ngfftdg(3)
    2589                 :        1205 :      cond_string(1)='nfft' ; cond_values(1)=nfft
    2590                 :        1205 :      call chkint(1,1,cond_string,cond_values,ierr,'nfftdg',nfftdg,1,(/0/),1,nfft,iout) ! Must be 0 or nfft
    2591                 :             :    end if
    2592                 :             : 
    2593                 :             : !  diismemory
    2594                 :             : !  Must be greater or equal to 1
    2595                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'diismemory',dt%diismemory,1,iout)
    2596                 :             : 
    2597                 :             : !  nimage
    2598                 :             : !  Must be greater or equal to 1
    2599                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'nimage',dt%nimage,1,iout)
    2600         [ -  + ]:        6983 :    if (usewvl==1) then
    2601                 :           0 :      cond_string(1)='usewvl' ; cond_values(1)=usewvl
    2602                 :           0 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'nimage',dt%nimage,1,(/1/),iout)
    2603                 :             :    end if
    2604         [ +  + ]:        6983 :    if (optdriver/=RUNL_GSTATE) then
    2605                 :        1322 :      cond_string(1)='optdriver' ; cond_values(1)=optdriver
    2606                 :        1322 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'nimage',dt%nimage,1,(/1/),iout)
    2607                 :             :    end if
    2608         [ +  + ]:        6983 :    if (dt%tfkinfunc==2) then
    2609                 :           6 :      cond_string(1)='tfkinfunc' ; cond_values(1)=dt%tfkinfunc
    2610                 :           6 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'nimage',dt%nimage,1,(/1/),iout)
    2611                 :             :    end if
    2612         [ +  + ]:        6983 :    if (dt%prtxml==1) then
    2613                 :           1 :      cond_string(1)='prtxml' ; cond_values(1)=dt%prtxml
    2614                 :           1 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'nimage',dt%nimage,1,(/1/),iout)
    2615                 :             :    end if
    2616         [ +  + ]:        6983 :    if (dt%imgmov==9.or.dt%imgmov==13) then
    2617   [ +  +  -  + ]:           7 :      if (dt%pitransform==1.and.(mod(dt%nimage,2)/=0)) then
    2618                 :           0 :        write(msg,'(6a)')ch10,&
    2619                 :           0 :         'Path-Integral Molecular Dynamics (imgmov=9,13)',ch10,&
    2620                 :           0 :         'in normal mode transformation (pitransform=1).',ch10,&
    2621                 :           0 :         'requires nimage to be even!'
    2622                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    2623                 :             :      end if
    2624                 :             :    end if
    2625   [ -  +  -  - ]:        6983 :    if (dt%imgmov==10.and.dt%pitransform>0) then
    2626                 :           0 :      write(msg,'(4a)')ch10,&
    2627                 :           0 :       'Path-Integral Molecular Dynamics (imgmov=10) with QTB',ch10,&
    2628                 :           0 :       'requires primitive coordinates (pitransform=0).'
    2629                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    2630                 :             :    end if
    2631                 :             : 
    2632                 :             : !  nkpt
    2633                 :             : !  Must be greater or equal to 1
    2634                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'nkpt',nkpt,1,iout)
    2635                 :             : !  If prtdos>=2, nkpt must be greater or equal to 2
    2636         [ +  + ]:        6983 :    if(dt%prtdos>=2)then
    2637                 :          48 :      cond_string(1)='prtdos' ; cond_values(1)=dt%prtdos
    2638                 :          48 :      call chkint_ge(1,1,cond_string,cond_values,ierr,'nkpt',nkpt,2,iout)
    2639                 :             :    end if
    2640                 :             : !  Must be smaller than 50 if iscf=-2 (band structure)
    2641                 :             : !  while prteig=0 and prtvol<2, except if kptopt>0
    2642   [ +  +  +  +  :        6983 :    if(dt%iscf==-2 .and. dt%prteig==0 .and. dt%prtvol<2 .and. dt%kptopt<=0)then
             +  -  -  + ]
    2643                 :           0 :      cond_string(1)='iscf'   ; cond_values(1)=dt%iscf
    2644                 :           0 :      cond_string(2)='prteig' ; cond_values(2)=dt%prteig
    2645                 :           0 :      cond_string(3)='prtvol' ; cond_values(3)=dt%prtvol
    2646                 :           0 :      call chkint_le(1,3,cond_string,cond_values,ierr,'nkpt',nkpt,50,iout)
    2647                 :             :    end if
    2648                 :             : 
    2649                 :             : !  nline
    2650                 :             : !  Must be equal to mdeg_filter for filtering algorithms
    2651         [ +  + ]:        6983 :    if (mod(dt%wfoptalg,10) == 1) then
    2652         [ -  + ]:         216 :      if (dt%nline/=dt%mdeg_filter) then
    2653                 :             :        write(msg,'(5a)') &
    2654                 :           0 :         "If you use a subspace filtering algorithm to optimize wavefunctions,",ch10,&
    2655                 :           0 :         "the degree of the polynomial filter (i.e. mdeg_filter) must be equal to",ch10,&
    2656                 :           0 :         "the value of nline parameter (which is obsolete for filtering algorithms)!"
    2657                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    2658                 :             :      end if
    2659                 :             :    end if
    2660                 :             : 
    2661                 :             : !  nloalg(1)= nloc_alg
    2662         [ +  + ]:        6983 :    if(dt%useylm==0) then
    2663                 :             : !    Must be 2, 3, 4
    2664                 :        5642 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'nloc_alg',dt%nloalg(1),3,(/2,3,4/),iout)
    2665                 :             :    else
    2666                 :             : !    Must be between 2 and 10
    2667                 :        1341 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'nloc_alg',dt%nloalg(1),9,(/2,3,4,5,6,7,8,9,10/),iout)
    2668                 :             :    end if
    2669                 :             : 
    2670                 :             : !  nloc_mem= nloalg(2)*(nloalg(3)+1)
    2671                 :             : !  nloalg(2) must be -1 or 1 ; nloalg(3) is 0 or 1.
    2672                 :        6983 :    nloc_mem=dt%nloalg(2)*(dt%nloalg(3)+1)
    2673                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'nloc_mem',nloc_mem,4,(/-2,-1,1,2/),iout)
    2674                 :             : 
    2675                 :             : !  npband
    2676                 :             : !  Must be greater or equal to 1
    2677                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'npband',dt%npband,1,iout)
    2678                 :             : 
    2679                 :             : !  npfft
    2680                 :             : !  Must be greater or equal to 1
    2681                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'npfft',dt%npfft,1,iout)
    2682                 :             : 
    2683                 :             : !  If usepaw==1 and pawmixdg==0, npfft must be equal to 1
    2684   [ +  +  +  + ]:        6983 :    if(usepaw==1 .and. dt%pawmixdg==0)then
    2685                 :        1012 :      cond_string(1)='usepaw  ' ; cond_values(1)=usepaw
    2686                 :        1012 :      cond_string(2)='pawmixdg' ; cond_values(2)=dt%pawmixdg
    2687                 :        1012 :      call chkint_eq(1,2,cond_string,cond_values,ierr,'npfft',dt%npfft,1,(/1/),iout)
    2688                 :             :    end if
    2689                 :             : #ifdef HAVE_OPENMP
    2690                 :             :    if (dt%wfoptalg==114 .or. dt%wfoptalg==1 .or. dt%wfoptalg==111 .or. dt%wfoptalg==112) then
    2691                 :             :      if ( nthreads > 1 ) then
    2692                 :             :        if ( dt%npfft > 1 ) then
    2693                 :             :          write(msg,'(4a,i4,a,i4,a)') "Using LOBPCG algorithm (wfoptalg=114), the FFT parallelization is not ",&
    2694                 :             :           "compatible with multiple threads.",ch10,"Please set npfft to 1 (currently npfft=",dt%npfft,&
    2695                 :             :           ") or export OMP_NUM_THREADS=1 (currently: the number of threads is ",nthreads,")"
    2696                 :             :          ABI_ERROR_NOSTOP(msg, ierr)
    2697                 :             :        end if
    2698                 :             :        if ( dt%npspinor > 1 ) then
    2699                 :             :          write(msg,'(4a,i1,a,i4,a)') "Using LOBPCG algorithm (wfoptalg=114), the parallelization on spinorial components is not",&
    2700                 :             :           " compatible with multiple threads.",ch10,"Please set npspinor to 1 (currently npspinor=",dt%npspinor,&
    2701                 :             :           ") or export OMP_NUM_THREADS=1 (currently: the number of threads is ",nthreads,")"
    2702                 :             :          ABI_ERROR_NOSTOP(msg, ierr)
    2703                 :             :        end if
    2704                 :             :        if ( dt%bandpp>1.and.fftalga==FFT_SG ) then
    2705                 :             :          write(msg,'(4a,i1,a,i4,a)') "To use bandpp > 1 and nthreads > 1 is not possible with S. Goedecker FFT (fftalg=1XX).",ch10,&
    2706                 :             :           "Change nthreads, bandpp, or fftalg (for example fftalg=401)."
    2707                 :             :          ABI_ERROR_NOSTOP(msg, ierr)
    2708                 :             :        end if
    2709                 :             :      end if
    2710                 :             :    end if
    2711                 :             : #endif
    2712                 :             :    !Not yet implemented
    2713   [ +  +  -  + ]:        6983 :    if ((dt%wfoptalg==111 .or. dt%wfoptalg==112) .and. dt%npfft > 1) then
    2714                 :           0 :      write(msg,'(5a,i3,5a)') "The FFT parallelization (npfft>1) is not compatible ",&
    2715                 :           0 : &      "with Chebyshev filtering algorithm (wfoptalg=111)!",ch10,&
    2716                 :           0 : &      "Please use multithreading instead (export OMP_NUM_THREADS=...)",&
    2717                 :           0 : &      " and set npfft to 1 (currently npfft=",dt%npfft,&
    2718                 :             : #ifdef HAVE_OPENMP
    2719                 :             : &      ")."
    2720                 :             : #else
    2721                 :           0 : &      ").",ch10,"But for that, you need to recompile ABINIT for multithreading,",ch10,&
    2722                 :           0 : &      "setting --enable-openmp at configure stage."
    2723                 :             : #endif
    2724                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    2725                 :             :    end if
    2726                 :             : 
    2727                 :             : !  npimage
    2728                 :             : !  Must be greater or equal to 1
    2729                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'npimage',dt%npimage,1,iout)
    2730                 :             : !  At present, parallelism over images is not coded ...
    2731                 :             : !  call chkint_eq(0,0,cond_string,cond_values,ierr,'npimage',dt%npimage,1,(/1/),iout)
    2732                 :             : 
    2733                 :             : !  np_spkpt
    2734                 :             : !  Must be greater or equal to 1
    2735                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'np_spkpt',dt%np_spkpt,1,iout)
    2736                 :             : 
    2737                 :             : !  nppert
    2738                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'nppert',dt%nppert,1,iout)
    2739                 :             : 
    2740                 :             : !  nproc
    2741   [ +  +  +  +  :        6983 :    if (response==1.and.nsppol==2.and.nproc>1.and.modulo(nproc,2)>0) then
             +  +  -  + ]
    2742                 :             :      write(msg,'(3a)' ) &
    2743                 :           0 :       'For DFPT parallel calculations on spin-polarized systems (nsppol=2),',ch10,&
    2744                 :           0 :       'the number of processors must be even!'
    2745                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    2746                 :             :    end if
    2747                 :             : 
    2748                 :             : !  nproj
    2749                 :             : !  If there is more than one projector for some angular momentum channel of some pseudopotential
    2750                 :             : !   do ilang=0,3
    2751                 :             : !     nprojmax(ilang)=pspheads(1)%nproj(ilang)
    2752                 :             : !     if(npsp>=2)then
    2753                 :             : !       do ii=2,npsp
    2754                 :             : !         nprojmax(ilang)=max(pspheads(ii)%nproj(ilang),nprojmax(ilang))
    2755                 :             : !       end do
    2756                 :             : !     end if
    2757                 :             : !   end do
    2758                 :             : 
    2759                 :             : !  npspinor
    2760                 :             : !  Must be equal to 1 or 2
    2761                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'npspinor',dt%npspinor,2,(/1,2/),iout)
    2762                 :             : !  If nspinor==1, npspinor must be equal to 1
    2763         [ +  + ]:        6983 :    if(dt%nspinor==1 )then
    2764                 :        6634 :      cond_string(1)='nspinor' ; cond_values(1)=dt%nspinor
    2765                 :        6634 :      call chkint_eq(0,1,cond_string,cond_values,ierr,'npspinor',dt%npspinor,1,(/1/),iout)
    2766                 :             :    end if
    2767                 :             : !  When NC+SOC with useylm=1 (nonlop_ylm pathway), spinor parallelism (npspinor>1) is incompatible
    2768   [ +  +  +  +  :        6983 :    if (dt%nspinor==2 .and. dt%usepaw==0 .and. dt%useylm==1 .and. dt%npspinor>1) then
             +  +  -  + ]
    2769                 :           0 :      write(msg,'(3a)') 'NC+SOC with useylm=1 (nonlop_ylm pathway) does not support spinor parallelism.',ch10,&
    2770                 :           0 : &      'Action: set npspinor=1 (or use useylm=0, or use PAW pseudopotentials).'
    2771                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    2772                 :             :    end if
    2773                 :             : 
    2774                 :             : !  npvel (must be positive)
    2775                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'npvel',dt%npvel,0,iout)
    2776                 :             : 
    2777                 :             : !  npwkss
    2778                 :             : !  Must be greater or equal to -1
    2779                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'npwkss',dt%npwkss,-1,iout)
    2780                 :             : 
    2781                 :             : !  nqpt
    2782                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'nqpt',dt%nqpt,2,(/0,1/),iout)
    2783                 :             : 
    2784                 :             : !  nscforder
    2785                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'nscforder',dt%nscforder,10,(/8,14,16,20,24,30,40,50,60,100/),iout)
    2786                 :             : 
    2787                 :             : !  nshiftk
    2788                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'nshiftk',dt%nshiftk,8,(/1,2,3,4,5,6,7,8/),iout)
    2789                 :             : !  If chksymbreak=1, nshiftk must be equal to 1, 2, 4.
    2790         [ +  + ]:        6983 :    if(dt%chksymbreak==1 )then
    2791                 :        6742 :      cond_string(1)='chksymbreak' ; cond_values(1)=dt%chksymbreak
    2792                 :        6742 :      call chkint_eq(0,1,cond_string,cond_values,ierr,'nshiftk',dt%nshiftk,3,(/1,2,4/),iout)
    2793                 :             :    end if
    2794                 :             : 
    2795                 :             : !  nspden
    2796                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'nspden',nspden,3,(/1,2,4/),iout)
    2797                 :             : 
    2798         [ +  + ]:        6983 :    if(nsppol==2)then  !  When nsppol=2, nspden must be 2
    2799                 :        1752 :      cond_string(1)='nsppol' ; cond_values(1)=nsppol
    2800                 :        1752 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'nspden',nspden,1,(/2/),iout)
    2801                 :             :    end if
    2802   [ +  +  +  +  :        6983 :    if(nspden==2 .and. nsppol==1 .and. response==1)then
                   -  + ]
    2803                 :             :      write(msg,'(13a)')&
    2804                 :           0 :       'nspden==2 together with nsppol==1 is not allowed',ch10,&
    2805                 :           0 :       'for response function calculations.',ch10,&
    2806                 :           0 :       'For antiferromagnetic materials, use nspden==2 and nsppol=2.',ch10,&
    2807                 :           0 :       'In this case, Shubnikov symmetries will be used to decrease',ch10,&
    2808                 :           0 :       'the number of perturbations. In a future version, it will also be',ch10,&
    2809                 :           0 :       'used to decrease the number of spin components (to be coded).',ch10,&
    2810                 :           0 :       'Action: change nsppol to 1, or check nspden.'
    2811                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    2812                 :             :    end if
    2813   [ +  +  +  + ]:        6983 :    if(nspden==4.and.response==1)then
    2814                 :             :      write(msg,'(3a)')&
    2815                 :          24 :       'nspden==4 allowed in response formalism.',ch10,&
    2816                 :          48 :       'BUT Non collinear magnetism under development in perturbative treatment.'
    2817                 :          24 :      ABI_WARNING(msg)
    2818                 :             :    end if
    2819                 :             : !  TR symmetry not allowed for NC magnetism, in the present version
    2820                 :             : !  (to be investigated further)
    2821   [ +  +  -  + ]:        6983 :    if (nspden==4.and.(dt%kptopt==1.or.dt%kptopt==2)) then
    2822                 :           0 :      write(msg, '(8a)' ) ch10,&
    2823                 :           0 :       'When non-collinear magnetism is activated (nspden=4),',ch10,&
    2824                 :           0 :       'time-reversal symmetry cannot be used in the present',ch10,&
    2825                 :           0 :       'state of the code (to be checked and validated).',ch10,&
    2826                 :           0 :       'Action: choose kptopt different from 1 or 2.'
    2827                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    2828                 :             :    end if
    2829                 :             : !  When densfor_pred<0 or 3, nspden must be 1 or 2
    2830         [ +  + ]:        6983 :    if(dt%densfor_pred<0.or.dt%densfor_pred==3)then
    2831                 :           2 :      cond_string(1)='densfor_pred' ; cond_values(1)=dt%densfor_pred
    2832                 :           2 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'nspden',nspden,2,(/1,2/),iout)
    2833                 :             :    end if
    2834                 :             : !  When ionmov=4 and iscf>10, nspden must be 1 or 2
    2835   [ +  +  -  + ]:        6983 :    if(dt%ionmov==4.and.dt%iscf>10)then
    2836                 :           0 :      cond_string(1)='ionmov' ; cond_values(1)=dt%ionmov
    2837                 :           0 :      cond_string(2)='iscf' ; cond_values(2)=dt%iscf
    2838                 :           0 :      call chkint_eq(1,2,cond_string,cond_values,ierr,'nspden',nspden,2,(/1,2/),iout)
    2839                 :             :    end if
    2840                 :             : !  When iprcel>49, nspden must be 1 or 2
    2841         [ +  + ]:        6983 :    if(mod(dt%iprcel,100)>49)then
    2842                 :           5 :      cond_string(1)='iprcel' ; cond_values(1)=dt%iprcel
    2843                 :           5 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'nspden',nspden,2,(/1,2/),iout)
    2844                 :             :    end if
    2845   [ +  +  -  + ]:        6983 :    if(xc_is_mgga.and.nspden==4)then
    2846                 :             :      write(msg, '(3a)' )&
    2847                 :           0 :       'The meta-GGA XC kernel is not yet implemented for non-colinear magnetism case',ch10, &
    2848                 :           0 :       'Please use "nspden=1 or 2".'
    2849                 :           0 :      ABI_ERROR(msg)
    2850                 :             :    end if
    2851                 :             : !  When abs(usepawu) is not 0, 1, 4, 10 or 14, nspden must be 1 or 2
    2852                 :             :    if (abs(dt%usepawu)/=0 .and. abs(dt%usepawu)/=1 .and. abs(dt%usepawu)/=4 .and. &
    2853   [ +  +  +  +  :        6983 :        abs(dt%usepawu)/=10 .and. abs(dt%usepawu)/=14 )then
                   +  + ]
    2854                 :           6 :      cond_string(1)='usepawu' ; cond_values(1)=dt%usepawu
    2855                 :           6 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'nspden',nspden,2,(/1,2/),iout)
    2856                 :             :    end if
    2857                 :             : 
    2858                 :             : !  nspinor
    2859                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'nspinor',nspinor,2,(/1,2/),iout)
    2860         [ +  + ]:        6983 :    if(nspden==2)then !  When nspden=2, nspinor must be 1
    2861                 :        1789 :      cond_string(1)='nspden' ; cond_values(1)=nspden
    2862                 :        1789 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'nspinor',nspinor,1,(/1/),iout)
    2863                 :             :    end if
    2864                 :             : 
    2865         [ +  + ]:        6983 :    if(nspden==4)then  !  When nspden=4, nspinor must be 2
    2866                 :         174 :      cond_string(1)='nspden' ; cond_values(1)=nspden
    2867                 :         174 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'nspinor',nspinor,1,(/2/),iout)
    2868                 :             :    end if
    2869                 :             : !  When iscf=-1, nspinor must be 1
    2870         [ +  + ]:        6983 :    if(dt%iscf==-1)then
    2871                 :          22 :      cond_string(1)='iscf' ; cond_values(1)=dt%iscf
    2872                 :             : !    Make sure that nsppol is 1
    2873                 :          22 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'nspinor',nspinor,1,(/1/),iout)
    2874                 :             :    end if
    2875                 :             : !  spin-orbit is not implemented for the strain perturbation
    2876         [ +  + ]:        6983 :    if(dt%rfstrs/=0)then
    2877                 :          37 :      cond_string(1)='rfstrs' ; cond_values(1)=dt%rfstrs
    2878                 :          37 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'nspinor',nspinor,1,(/1/),iout)
    2879                 :             :    end if
    2880                 :             : !  When usepawu=2 or -2, nspinor must be 1
    2881         [ +  + ]:        6983 :    if(abs(dt%usepawu)==2)then
    2882                 :           6 :      cond_string(1)='usepawu' ; cond_values(1)=dt%usepawu
    2883                 :             : !    Make sure that nspinor is 1
    2884                 :           6 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'nspinor',nspinor,1,(/1/),iout)
    2885                 :             :    end if
    2886                 :             : 
    2887                 :             : !  nsppol
    2888                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'nsppol',nsppol,2,(/1,2/),iout)
    2889                 :             : 
    2890                 :             : !  nstep
    2891                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'nstep',dt%nstep,0,iout)
    2892         [ +  + ]:        6983 :    if(dt%nstep==0)then
    2893                 :             : !    nstep==0 computation of energy not yet implemented with Fock term, see m_energy.F90
    2894                 :          36 :      cond_string(1)='usefock' ; cond_values(1)=dt%usefock
    2895         [ +  - ]:          36 :      if(dt%usefock/=1) then
    2896                 :          36 :        call chkint_eq(1,1,cond_string,cond_values,ierr,'usefock',dt%usefock,1,(/0/),iout)
    2897                 :             :      else
    2898                 :             :        write(msg,'(a)')&
    2899                 :           0 :        'For usefock=1 and nstep=0, the Fock energy is not available and will not be computed.'
    2900                 :           0 :        ABI_WARNING(msg)
    2901                 :             :      endif
    2902                 :             :    endif
    2903                 :             : 
    2904                 :             : !  nsym
    2905                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'nsym',dt%nsym,1,iout)
    2906                 :             : !  check if nsym=1 in phonon calculation in finite electric field
    2907   [ +  +  +  + ]:        6983 :    if (response==1.and.&
    2908                 :             :       (dt%berryopt== 4.or.dt%berryopt== 6.or.dt%berryopt== 7.or.&
    2909                 :             :        dt%berryopt==14.or.dt%berryopt==16.or.dt%berryopt==17)) then
    2910                 :           1 :      cond_string(1)='response' ; cond_values(1)=response
    2911                 :           1 :      cond_string(2)='berryopt' ; cond_values(2)=dt%berryopt
    2912                 :           1 :      call chkint_eq(1,2,cond_string,cond_values,ierr,'nsym',dt%nsym,1,(/1/),iout)
    2913                 :             :    end if
    2914                 :             : 
    2915                 :             : !  ntime
    2916                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'ntime',dt%ntime,0,iout)
    2917                 :             : 
    2918                 :             : !  ntimimage
    2919                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'ntimimage',dt%ntimimage,1,iout)
    2920                 :             : 
    2921                 :             : !  ntypalch
    2922         [ +  + ]:        6983 :    if (usepaw==1) then
    2923                 :        1205 :      cond_string(1)='usepaw' ; cond_values(1)=dt%usepaw
    2924                 :        1205 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'ntypalch',dt%ntypalch,1,(/0/),iout)
    2925                 :             :    end if
    2926                 :             : 
    2927                 :             : !  nucdipmom
    2928                 :             : 
    2929   [ +  +  +  +  :      225603 :    if (any(abs(dt%nucdipmom)>tol8)) then
             +  +  +  + ]
    2930                 :             : 
    2931                 :             : !    !nucdipmom requires PAW
    2932                 :             :      !if(usepaw/=1)then
    2933                 :             :      !  write(msg, '(3a)' )&
    2934                 :             :      !   'Nuclear dipole moments (variable nucdipmom or atndlist) input as nonzero but PAW not activated => stop',ch10,&
    2935                 :             :      !   'Action: re-run with PAW '
    2936                 :             :      !  ABI_ERROR_NOSTOP(msg, ierr)
    2937                 :             :      !end if
    2938                 :             : 
    2939                 :             :      !  paral_atom not allowed at present
    2940                 :          48 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'paral_atom',dt%paral_atom,1,(/0/),iout)
    2941                 :             : 
    2942                 :             : !    nucdipmom with PAW requires complex rhoij
    2943   [ +  +  -  + ]:          48 :      if((usepaw.EQ.1).AND.(dt%pawcpxocc.NE.2))then
    2944                 :             :        write(msg, '(3a)' )&
    2945                 :           0 :        'Nuclear dipole moments (variable nucdipmom or atndlist) require complex rhoij => stop',ch10,&
    2946                 :           0 :        'Action: re-run with pawcpxocc = 2 '
    2947                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    2948                 :             :      end if
    2949                 :             : 
    2950                 :             : !    nucdipmom requires no force or stress calculation
    2951   [ +  -  -  + ]:          48 :      if(dt%optforces/=0 .OR. dt%optstress/=0)then
    2952                 :             :        write(msg, '(3a)' )&
    2953                 :           0 :        'Nuclear dipole moments (variable nucdipmom or atndlist) cannot be used with force or stress calculations => stop',ch10,&
    2954                 :           0 :        'Action: re-run with optforces = 0 and optstress = 0 '
    2955                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    2956                 :             :      end if
    2957                 :             : 
    2958                 :             : !    nucdipmom requires kptopt 0, 3, or 4 (no time reversal symmetry allowed)
    2959         [ -  + ]:          48 :      if( (dt%kptopt .EQ. 1) .OR. (dt%kptopt .EQ. 2) ) then
    2960                 :             :        write(msg, '(a,i4,a,a,a)' )&
    2961                 :           0 :        ' Nuclear dipole moments (variable nucdipmom or atndlist) break time reversal symmetry but kptopt = ',dt%kptopt,&
    2962                 :           0 :        ' => stop ',ch10,&
    2963                 :           0 :        'Action: re-run with kptopt of 0, 3 or 4'
    2964                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    2965                 :             :      end if
    2966                 :             : 
    2967                 :             :      !! nucdipmom is not currently compatible with spinat (this is necessary because both are used in symfind)
    2968                 :             :      !if( any(abs(dt%spinat) > tol8) ) then
    2969                 :             :      !  write(msg, '(3a)' )&
    2970                 :             :      !   ' Nuclear dipole moments (variable nucdipmom or atndlist) input as nonzero but spinat is also nonzero => stop',ch10,&
    2971                 :             :      !   'Action: re-run with spinat zero '
    2972                 :             :      !  ABI_ERROR_NOSTOP(msg, ierr)
    2973                 :             :      !end if
    2974                 :             : 
    2975                 :             :    end if
    2976                 :             : 
    2977                 :             : !  nzchempot
    2978                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'nzchempot',dt%nzchempot,0,iout)
    2979                 :             : !  Cannot be used with response functions at present
    2980         [ +  + ]:        6983 :    if (response==1) then
    2981                 :         754 :      cond_string(1)='response' ; cond_values(1)=response
    2982                 :         754 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'nzchempot',dt%nzchempot,1,(/0/),iout)
    2983                 :             :    end if
    2984         [ +  + ]:        6983 :    if(dt%nzchempot>0)then
    2985         [ +  + ]:          21 :      do itypat=1,dt%ntypat
    2986         [ +  + ]:          28 :        do iz=2,dt%nzchempot
    2987                 :          14 :          dz=dt%chempot(1,iz,itypat)-dt%chempot(1,iz-1,itypat)
    2988         [ -  + ]:          28 :          if(dz<-tol12)then
    2989                 :             :            write(msg, '(a,2i6,a,a,d17.10,a,a, a,d17.10,a,a, a,a,a)' )&
    2990                 :           0 :             ' For izchempot,itypat=',iz,itypat,ch10,&
    2991                 :           0 :             ' chempot(1,izchempot-1,itypat) = ',dt%chempot(1,iz-1,itypat),' and', ch10,&
    2992                 :           0 :             ' chempot(1,izchempot  ,itypat) = ',dt%chempot(1,iz  ,itypat),',',ch10,&
    2993                 :           0 :             ' while they should be ordered in increasing values =>stop',ch10,&
    2994                 :           0 :             'Action: correct chempot(1,*,itypat) in input file.'
    2995                 :           0 :            ABI_ERROR_NOSTOP(msg, ierr)
    2996                 :             :          end if
    2997                 :             :        end do
    2998                 :          14 :        dz=dt%chempot(1,dt%nzchempot,itypat)-dt%chempot(1,1,itypat)
    2999         [ -  + ]:          21 :        if(dz>one)then
    3000                 :             :          write(msg, '(a,2i6,a,a,d17.10,a,a, a,d17.10,a,a, a,a,a)' )&
    3001                 :           0 :           ' For nzchempot,itypat=',dt%nzchempot,itypat,ch10,&
    3002                 :           0 :           ' chempot(1,1,itypat) = ',dt%chempot(1,1,itypat),' and', ch10,&
    3003                 :           0 :           ' chempot(1,nzchempot  ,itypat) = ',dt%chempot(1,dt%nzchempot,itypat),'.',ch10,&
    3004                 :           0 :           ' However, the latter should, at most, be one more than the former =>stop',ch10,&
    3005                 :           0 :           'Action: correct chempot(1,nzchempot,itypat) in input file.'
    3006                 :           0 :          ABI_ERROR_NOSTOP(msg, ierr)
    3007                 :             :        end if
    3008                 :             :      end do
    3009                 :             :    end if
    3010                 :             : 
    3011                 :             : !  occ
    3012                 :             : !  Do following tests only for occopt==0 or 2, when occupation numbers are needed
    3013   [ +  +  +  +  :        6983 :    if ((dt%iscf>0.or.dt%iscf==-1.or.dt%iscf==-3) .and. (dt%occopt==0 .or. dt%occopt==2) ) then
                   +  + ]
    3014         [ +  + ]:         919 :      do iimage=1,dt%nimage
    3015                 :             : !      make sure occupation numbers (occ(n)) were defined:
    3016                 :         463 :        sumocc=zero
    3017                 :         463 :        bantot=0
    3018         [ +  + ]:        1163 :        do isppol=1,nsppol
    3019         [ +  + ]:        2286 :          do ikpt=1,nkpt
    3020         [ +  + ]:       11414 :            do iband=1,dt%nband(ikpt+(isppol-1)*nkpt)
    3021                 :        9591 :              bantot=bantot+1
    3022                 :        9591 :              sumocc=sumocc+dt%occ_orig(bantot,iimage)
    3023         [ -  + ]:       10714 :              if (dt%occ_orig(bantot,iimage)<-tol8) then
    3024                 :             :                write(msg, '(a,3i6,a,e20.10,a,a,a)' )&
    3025                 :           0 :                 'iband,ikpt,iimage=',iband,ikpt,iimage,' has negative occ=',dt%occ_orig(bantot,iimage),' =>stop',ch10,&
    3026                 :           0 :                 'Action: correct this occupation number in input file.'
    3027                 :           0 :                ABI_ERROR_NOSTOP(msg, ierr)
    3028                 :             :              end if
    3029                 :             :            end do
    3030                 :             :          end do
    3031                 :             :        end do
    3032         [ -  + ]:         919 :        if (sumocc<=1.0d-8) then
    3033                 :             :          write(msg, '(a,1p,e20.10,a,a,a)')&
    3034                 :           0 :           'Sum of occ=',sumocc, ' =>occ not defined => stop',ch10,&
    3035                 :           0 :           'Action: correct the array occ in input file.'
    3036                 :           0 :          ABI_ERROR_NOSTOP(msg, ierr)
    3037                 :             :        end if
    3038                 :             :      enddo
    3039                 :             :    end if
    3040                 :             : 
    3041                 :             : !  occopt
    3042                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'occopt',dt%occopt,10,(/0,1,2,3,4,5,6,7,8,9/),iout)
    3043                 :             : !  When prtdos==1 or 4, occopt must be between 3 and 8
    3044         [ +  + ]:        6983 :    if(dt%prtdos==1.or.dt%prtdos==4)then
    3045                 :           9 :      cond_string(1)='prtdos' ; cond_values(1)=dt%prtdos
    3046                 :             : !    Make sure that occopt is 3,4,5,6,7, or 8
    3047                 :           9 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'occopt',dt%occopt,7,(/3,4,5,6,7,8,9/),iout)
    3048                 :             :    end if
    3049                 :             : !  When nsppol==2 and spinmagntarget is the default value (-99.99d0), occopt cannot be 1.
    3050   [ +  +  +  +  :        6983 :    if(nsppol==2.and.dt%occopt==1.and.abs(dt%spinmagntarget+99.99d0)<tol8)then
                   +  + ]
    3051   [ +  -  -  + ]:           8 :      if(natom/=1 .or. abs(dt%znucl(dt%typat(1))-one)>tol8)then
    3052                 :             :        write(msg,'(a,i3,2a,i3,4a,f7.2,7a)' )&
    3053                 :           0 :         'This is a calculation with spin-up and spin-down wavefunctions,         ... nsppol=',nsppol,ch10,&
    3054                 :           0 :         'in which the occupation numbers are to be determined automatically.     ... occopt=',dt%occopt,ch10,&
    3055                 :           0 :         'However, in this case, the target total spin magnetization',ch10,&
    3056                 :           0 :         'must be specified, while the default value is observed.                 ... spinmagntarget=',dt%spinmagntarget,ch10,&
    3057                 :           0 :         'Action: if you are doing an antiferromagnetic calculation, please use nsppol=1 with nspden=2;',ch10,&
    3058                 :           0 :         'on the other hand, if you are doing a ferromagnetic calculation, either specify your own spinmagntarget,',ch10,&
    3059                 :           0 :         'or let the code determine the total spin-polarization, by using a metallic value for occopt (e.g. 7 or 4 ...).'
    3060                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    3061                 :             :      end if
    3062                 :             :    end if
    3063                 :             : 
    3064                 :             : !  optcell
    3065                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'optcell',dt%optcell,10,(/0,1,2,3,4,5,6,7,8,9/),iout)
    3066                 :             : !  With dt%berryopt=4, one must have optcell==0
    3067                 :             : !  if(dt%berryopt==4)then
    3068                 :             : !  cond_string(1)='berryopt' ; cond_values(1)=dt%berryopt
    3069                 :             : !  call chkint_eq(1,1,cond_string,cond_values,ierr,'optcell',dt%optcell,1,(/0/),iout)
    3070                 :             : !  end if
    3071                 :             : 
    3072                 :             : !  optdcmagpawu
    3073   [ +  +  +  + ]:        6983 :    if (dt%usepawu/=0.and.dt%nspden==4) then
    3074                 :          25 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'optdcmagpawu',dt%optdcmagpawu,3,(/1,2,3/),iout)
    3075                 :             :    end if
    3076                 :             : 
    3077                 :             : !  Check the value of optdriver
    3078                 :             :    call chkint_eq(0, 0, cond_string, cond_values, ierr, 'optdriver', optdriver, 12,&
    3079                 :             :                   [RUNL_GSTATE,RUNL_RESPFN,RUNL_SCREENING,RUNL_SIGMA,RUNL_NONLINEAR,RUNL_GWR, RUNL_BSE, &
    3080                 :        6983 :                    RUNL_GWLS, RUNL_WFK,RUNL_EPH,RUNL_LONGWAVE,RUNL_RTTDDFT], iout)
    3081                 :             : 
    3082   [ +  +  +  +  :        6983 :    if (response==1.and.all(dt%optdriver/=[RUNL_RESPFN,RUNL_NONLINEAR,RUNL_LONGWAVE])) then
                   -  + ]
    3083                 :             :      write(msg,'(a,i3,3a,13(a,i2),4a)' )&
    3084                 :           0 :      'The input variable optdriver=',dt%optdriver,ch10,&
    3085                 :           0 :      'This is in conflict with the values of the other input variables,',ch10,&
    3086                 :           0 :      'rfphon=',dt%rfphon,' rfddk=',dt%rfddk,' rf2_dkdk=',dt%rf2_dkdk,' rf2_dkde=',dt%rf2_dkde,&
    3087                 :           0 :      ' rfelfd=',dt%rfelfd,'  rfmagn=',dt%rfmagn,' rfstrs=',dt%rfstrs,&
    3088                 :           0 :      ' d3e_pert1_elfd=',dt%d3e_pert1_elfd,' d3e_pert2_elfd=',dt%d3e_pert2_elfd,' d3e_pert3_elfd=',dt%d3e_pert3_elfd,&
    3089                 :           0 :      ' d3e_pert1_phon=',dt%d3e_pert1_phon,' d3e_pert2_phon=',dt%d3e_pert2_phon,' d3e_pert3_phon=',dt%d3e_pert3_phon,ch10,&
    3090                 :           0 :      'Action: check the values of optdriver, rfphon, rfddk, rf2dkdk, rf2dkde, rfelfd, rfmagn, rfstrs,',ch10,&
    3091                 :           0 :      'd3e_pert1_elfd, d3e_pert2_elfd, d3e_pert3_elfd, d3e_pert1_phon, d3e_pert2_phon, and d3e_pert3_phon in your input file.'
    3092                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    3093                 :             :    end if
    3094   [ +  +  +  +  :       27932 :    if (response==1 .and. (sum(dt%qptn(:)**2)>tol12 .or. nspden==4) .and. &
          +  +  +  +  +  
             +  -  +  -  
                      - ]
    3095                 :             :        .not.(dt%kptopt==3 .or. dt%kptopt==0 .or. dt%nsym==1 .or. dt%iscf<0)) then
    3096                 :             :      write(msg,'(a,i3,2a,a,3f16.6,2a,2a,a)' )&
    3097                 :           0 :       'The input variable optdriver=',dt%optdriver,' which implies response functions.',ch10,&
    3098                 :           0 :       'Also qptn=',dt%qptn(:),' that is non-zero, or one has a calculation with non-collinear magnetism.',ch10,&
    3099                 :           0 :       'This requires kptopt 3 (or 0 for expert users) or nsym=1, or non-self-consistent calculation (iscf<0).',ch10,&
    3100                 :           0 :       'Set kptopt to 3 to let the code reduce the k with the correct small group of symmetries.'
    3101                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    3102                 :             :    end if
    3103   [ +  +  +  +  :       27932 :    if (response==1 .and. (sum(dt%qptn(:)**2)<tol12 .and. nspden/=4) .and. &
          +  +  +  +  +  
          +  +  +  -  +  
                   -  - ]
    3104                 :             :       .not.(dt%kptopt==3 .or. dt%kptopt==0 .or. dt%kptopt==2 .or. dt%nsym==1 .or. dt%iscf<0)) then
    3105                 :             :      write(msg,'(a,i3,2a,2a,2a,a)' )&
    3106                 :           0 :        'The input variable optdriver=',dt%optdriver,' which implies response functions.',ch10,&
    3107                 :           0 :        'Also qptn is null, and there is no non-collinear magnetism.',ch10,&
    3108                 :           0 :        'This requires kptopt 3 or 2 (or 0 for expert users) or nsym=1, or non-self-consistent calculation (iscf<0).',ch10,&
    3109                 :           0 :        'Set kptopt to 2 to let the code reduce the k with the correct small group of symmetries.'
    3110                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    3111                 :             :    end if
    3112         [ +  + ]:        6983 :    if(usepaw==1)then
    3113                 :             :      ! Is optdriver compatible with PAW?
    3114                 :        1205 :      cond_string(1)='usepaw' ; cond_values(1)=usepaw
    3115                 :             :      call chkint_eq(1,1,cond_string,cond_values,ierr,'optdriver',optdriver,9,&
    3116                 :        1205 :         [RUNL_GSTATE,RUNL_RESPFN,RUNL_SCREENING,RUNL_SIGMA,RUNL_BSE,RUNL_WFK,RUNL_NONLINEAR,RUNL_RTTDDFT,RUNL_GWR],iout)
    3117                 :             :    end if
    3118                 :             : 
    3119                 :             :    !  Linear and Non-linear response calculations
    3120                 :             :    ! Non-linear response not compatible with spinors
    3121         [ +  + ]:        6983 :    if(nspinor/=1)then
    3122                 :         349 :      cond_string(1)='nspinor' ; cond_values(1)=nspinor
    3123                 :         349 :      call chkint_ne(1,1,cond_string,cond_values,ierr,'optdriver',dt%optdriver,1,(/RUNL_NONLINEAR/),iout)
    3124                 :             :    end if
    3125                 :             :    ! Non-linear response only for insulators
    3126         [ +  + ]:        6983 :    if(dt%occopt/=1 .and. dt%occopt/=2)then
    3127                 :        2783 :      cond_string(1)='occopt' ; cond_values(1)=dt%occopt
    3128                 :        2783 :      call chkint_ne(1,1,cond_string,cond_values,ierr,'optdriver',dt%optdriver,2,(/RUNL_NONLINEAR,RUNL_LONGWAVE/),iout)
    3129                 :             :    end if
    3130                 :             :    ! Non-linear response not compatible with mkmem=0
    3131         [ -  + ]:        6983 :    if(dt%mkmem==0)then
    3132                 :           0 :      cond_string(1)='mkmem' ; cond_values(1)=dt%mkmem
    3133                 :           0 :      call chkint_ne(1,1,cond_string,cond_values,ierr,'optdriver',dt%optdriver,1,(/RUNL_NONLINEAR/),iout)
    3134                 :             :    end if
    3135                 :             :    ! Longwave needs all k-points
    3136         [ +  + ]:        6983 :    if(dt%kptopt==1 .or. dt%kptopt==4) then
    3137                 :        2313 :      cond_string(1)='kptopt' ; cond_values(1)=dt%kptopt
    3138                 :        2313 :      call chkint_ne(1,1,cond_string,cond_values,ierr,'optdriver',dt%optdriver,1,(/RUNL_LONGWAVE/),iout)
    3139                 :             :    end if
    3140                 :             : 
    3141                 :             :    ! dkdk and dkde non-linear response only for occopt=1 (insulators)
    3142         [ +  + ]:        6983 :    if (dt%rf2_dkdk==1 .or. dt%rf2_dkdk==2 .or. dt%rf2_dkdk==3) then
    3143                 :          18 :      cond_string(1)='rf2_dkdk' ; cond_values(1)=dt%rf2_dkdk
    3144                 :          18 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'occopt',dt%occopt,1,(/1/),iout)
    3145                 :             :    end if
    3146         [ +  + ]:        6983 :    if (dt%rf2_dkdk/=0) then
    3147                 :          18 :      cond_string(1)='rf2_dkdk' ; cond_values(1)=dt%rf2_dkdk
    3148                 :          18 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'useylm',dt%useylm,1,(/1/),iout)
    3149                 :             :    end if
    3150                 :             : 
    3151         [ +  + ]:        6983 :    if (dt%rf2_dkde==1) then
    3152                 :           7 :      cond_string(1)='rf2_dkde' ; cond_values(1)=dt%rf2_dkde
    3153                 :           7 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'occopt',dt%occopt,1,(/1/),iout)
    3154                 :             :    end if
    3155         [ +  + ]:        6983 :    if (dt%rf2_dkde/=0) then
    3156                 :           7 :      cond_string(1)='rf2_dkde' ; cond_values(1)=dt%rf2_dkde
    3157                 :           7 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'useylm',dt%useylm,1,(/1/),iout)
    3158                 :             :    end if
    3159                 :             : 
    3160                 :             :    ! PEAD non-linear response only for occopt=1 (insulators)
    3161   [ +  +  +  - ]:        6983 :    if(dt%usepead==0.and.dt%optdriver==RUNL_NONLINEAR)then
    3162                 :           7 :      cond_string(1)='usepead'   ; cond_values(1)=dt%usepead
    3163                 :           7 :      cond_string(2)='optdriver' ; cond_values(2)=dt%optdriver
    3164                 :           7 :      call chkint_eq(1,2,cond_string,cond_values,ierr,'occopt',dt%occopt,1,(/1/),iout)
    3165                 :             :    end if
    3166                 :             :    ! PAW non-linear response only with DFPT (PEAD not allowed)
    3167   [ +  +  +  + ]:        6983 :    if(usepaw==1.and.dt%optdriver==RUNL_NONLINEAR)then
    3168                 :           4 :      cond_string(1)='usepaw'    ; cond_values(1)=usepaw
    3169                 :           4 :      cond_string(2)='optdriver' ; cond_values(2)=dt%optdriver
    3170                 :           4 :      call chkint_eq(1,2,cond_string,cond_values,ierr,'usepead',dt%usepead,1,(/0/),iout)
    3171                 :           4 :      cond_string(1)='usepaw'    ; cond_values(1)=usepaw
    3172                 :           4 :      cond_string(2)='optdriver' ; cond_values(2)=dt%optdriver
    3173                 :           4 :      call chkint_eq(1,2,cond_string,cond_values,ierr,'pawxcdev',dt%pawxcdev,1,(/0/),iout)
    3174                 :             :    end if
    3175                 :             :    ! Non-linear response not compatible with autoparal
    3176         [ +  + ]:        6983 :    if(dt%optdriver==RUNL_NONLINEAR)then
    3177                 :          28 :      cond_string(1)='optdriver' ; cond_values(1)=dt%optdriver
    3178                 :          28 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'autoparal',dt%autoparal,1,(/0/),iout)
    3179                 :             :    end if
    3180                 :             :    ! !Linear Response function only for LDA/GGA
    3181                 :             :    ! allowed=((xc_is_lda.or.xc_is_gga.or.dt%ixc==0).and.dt%ixc/=50)
    3182                 :             :    ! if(.not.allowed)then
    3183                 :             :    !   cond_string(1)='ixc' ; cond_values(1)=dt%ixc
    3184                 :             :    !   call chkint_ne(1,1,cond_string,cond_values,ierr,'optdriver',dt%optdriver,1,(/RUNL_RESPFN/),iout)
    3185                 :             :    ! end if
    3186                 :             :    !PAW+Linear Response+GGA function restricted to pawxcdev=0
    3187                 :             :    !PAW+response_to_strain only allowed for LDA
    3188   [ +  +  +  + ]:        6983 :    if (dt%usepaw==1.and.dt%optdriver==RUNL_RESPFN) then
    3189   [ +  +  +  +  :         116 :      if( xc_is_gga.and. &
          +  -  +  +  +  
                -  -  + ]
    3190                 :             :         (dt%rfphon/=0.or.dt%rfelfd==1.or.dt%rfelfd==3.or.dt%rfstrs/=0.or.dt%rf2_dkde/=0) ) then
    3191         [ -  + ]:           6 :        if (dt%pawxcdev/=0)then
    3192                 :             :          write(msg,'(7a)' )&
    3193                 :           0 :          'You are performing a DFPT+PAW calculation using a GGA XC functional:',ch10,&
    3194                 :           0 :          '  This is restricted to pawxcdev = 0!',ch10,&
    3195                 :           0 :          '  Action: change pawxcdev value in your input file!',ch10,&
    3196                 :           0 :          '    and be careful to run the preparatory Ground-State calculations also with pawxcdev = 0!'
    3197                 :           0 :          ABI_ERROR_NOSTOP(msg, ierr)
    3198                 :             :        else
    3199                 :             :          write(msg,'(5a)' )&
    3200                 :           6 :          'You are performing a DFPT+PAW calculation using a GGA XC functional:',ch10,&
    3201                 :           6 :          '  - This is restricted to pawxcdev = 0!',ch10,&
    3202                 :          12 :          '  - Be careful to run the preparatory Ground-State calculations also with pawxcdev = 0!'
    3203                 :           6 :          ABI_WARNING(msg)
    3204                 :             :        end if
    3205         [ -  + ]:           6 :        if (dt%rfstrs/=0) then
    3206                 :             :          write(msg,'(3a)' )&
    3207                 :           0 :          'You are performing a DFPT+PAW calculation using a GGA XC functional:',ch10,&
    3208                 :           0 :          '  Response to strain perturbation is not yet available!'
    3209                 :           0 :          ABI_ERROR_NOSTOP(msg, ierr)
    3210                 :             :        end if
    3211                 :             :      end if
    3212                 :             :    end if
    3213                 :             :    !PAW+mGGA function restricted to pawxcdev=0
    3214   [ +  +  +  +  :        6983 :    if (dt%usepaw==1.and.xc_is_mgga.and.dt%pawxcdev/=0) then
                   -  + ]
    3215                 :             :      write(msg,'(5a)' ) &
    3216                 :           0 :      'You are performing a PAW calculation using a meta-GGA XC functional:',ch10,&
    3217                 :           0 :      '  This is restricted to pawxcdev = 0!',ch10,&
    3218                 :           0 :      '  Action: change pawxcdev value in your input file!'
    3219                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    3220                 :             :    end if
    3221                 :             :    !Non linear Response function only for LDA (restricted to ixc=3/7/8)
    3222   [ +  +  +  +  :        6983 :    allowed=((xc_is_lda.and.dt%ixc<0).or.dt%ixc==0.or.dt%ixc==3.or.dt%ixc==7.or.dt%ixc==8)
                   +  + ]
    3223                 :             :    if(.not.allowed)then
    3224                 :        5469 :      cond_string(1)='ixc' ; cond_values(1)=dt%ixc
    3225                 :        5469 :      call chkint_ne(1,1,cond_string,cond_values,ierr,'optdriver',dt%optdriver,1,(/RUNL_NONLINEAR/),iout)
    3226                 :             :    end if
    3227                 :             :    !Longwave not compatible with spinors
    3228   [ +  +  +  + ]:        6983 :    if(nspinor/=1.and.dt%timdisp==0)then
    3229                 :         343 :      cond_string(1)='nspinor' ; cond_values(1)=nspinor
    3230                 :         343 :      call chkint_ne(1,1,cond_string,cond_values,ierr,'optdriver',dt%optdriver,1,(/RUNL_LONGWAVE/),iout)
    3231                 :             :    end if
    3232                 :             :    !Longwave calculation only compatible with nonlinear core corrections for quadrupoles and NOA
    3233   [ +  +  +  +  :        6983 :    if(dt%optdriver==RUNL_LONGWAVE.and.dt%timdisp==0.and.dt%lw_flexo/=0)then
                   +  + ]
    3234         [ +  + ]:           6 :      do ipsp=1,npsp
    3235                 :             :        !  Check that xccc is zero
    3236         [ -  + ]:           6 :        if (pspheads(ipsp)%xccc/=0) then
    3237                 :             :          write(msg, '(5a,i0,3a)' )&
    3238                 :           0 :          'For a longwave calculation of flexoelectric properties it is not possible',ch10,&
    3239                 :           0 :          'to use norm-conserving pseudopotentials with a non-linear core correction.',ch10,&
    3240                 :           0 :          'However, for pseudopotential number ',ipsp,', there is such a core correction.',ch10,&
    3241                 :           0 :          'Action: change this pseudopotential file.'
    3242                 :           0 :          ABI_ERROR_NOSTOP(msg, ierr)
    3243                 :             :        end if
    3244                 :             :      end do
    3245                 :             :    end if
    3246                 :             :    ! Longwave calculation function only for useylm=1
    3247   [ +  +  +  +  :        6983 :    if(dt%optdriver==RUNL_LONGWAVE.and.dt%useylm/=1.and.(dt%lw_qdrpl/=0.or.dt%lw_flexo/=0))then
             +  -  -  + ]
    3248                 :             :     write(msg, '(3a,2a,2a)' )&
    3249                 :           0 :      'A longwave calculation can only be run with the input variable useylm/=1',ch10 ,&
    3250                 :           0 :      'for lw_natopt=1, while this seems not to be the case in your input,',ch10,&
    3251                 :           0 :      'where lw_qdrpl/= and/or lw_flexo/=0.',ch10,&
    3252                 :           0 :      'Action: change "useylm" value in your input file.'
    3253                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    3254                 :             :    end if
    3255                 :             :    ! Longwave calculation not compatible with PAW
    3256         [ +  + ]:        6983 :    if(dt%optdriver==RUNL_LONGWAVE)then
    3257                 :          17 :      cond_string(1)='optdriver' ; cond_values(1)=dt%optdriver
    3258                 :          17 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'usepaw',dt%usepaw,1,(/0/),iout)
    3259                 :             :    endif
    3260                 :             :    !Longwave calculation not compatible with spin-dependent calculations
    3261   [ +  +  +  +  :        6983 :    if((dt%nsppol/=1.or.dt%nspden/=1).and.dt%timdisp==0)then
                   +  + ]
    3262                 :        1957 :      cond_string(1)='nsppol' ; cond_values(1)=dt%nsppol
    3263                 :        1957 :      cond_string(2)='nspden' ; cond_values(2)=dt%nspden
    3264                 :        1957 :      call chkint_ne(1,2,cond_string,cond_values,ierr,'optdriver',dt%optdriver,1,(/RUNL_LONGWAVE/),iout)
    3265                 :             :    end if
    3266                 :             : 
    3267                 :             : !
    3268                 :             : 
    3269                 :             : !  optforces
    3270                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'optforces',dt%optforces,3,(/0,1,2/),iout)
    3271                 :             : !  When ionmov>0, optforces must be >0
    3272         [ +  + ]:        6983 :    if(dt%ionmov>0)then
    3273                 :         327 :      cond_string(1)='ionmov' ; cond_values(1)=dt%ionmov
    3274                 :         327 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'optforces',dt%optforces,2,(/1,2/),iout)
    3275                 :             :    end if
    3276                 :             : !  When imgmov>0, optforces must be >0
    3277         [ +  + ]:        6983 :    if(dt%imgmov>0)then
    3278                 :          43 :      cond_string(1)='imgmov' ; cond_values(1)=dt%imgmov
    3279                 :          43 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'optforces',dt%optforces,2,(/1,2/),iout)
    3280                 :             :    end if
    3281                 :             : !  When iscf=22, optforces must be 0 or 2
    3282         [ -  + ]:        6983 :    if(dt%iscf==22)then
    3283                 :           0 :      cond_string(1)='iscf' ; cond_values(1)=dt%iscf
    3284                 :           0 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'optforces',dt%optforces,2,(/0,2/),iout)
    3285                 :             :    end if
    3286                 :             : !  When usedmft=1, optforces must be 0
    3287         [ +  + ]:        6983 :    if(dt%usedmft==1.or.dt%usedmft==10)then
    3288                 :          43 :      cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
    3289                 :          43 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'optforces',dt%optforces,1,(/0/),iout)
    3290                 :             :    end if
    3291                 :             : 
    3292                 :             : !  optstress
    3293                 :             : !  Por mGGA, optstress not yet allowed (temporary, hopefully)
    3294                 :             : !   if(dt%optstress>0.and.xc_is_mgga)then
    3295                 :             : !     msg='Computation of stress tensor is not yet implemented for meta-GGA XC functionals!'
    3296                 :             : !     ABI_ERROR_NOSTOP(msg, ierr)
    3297                 :             : !   end if
    3298                 :             : !  When optcell>0, optstress must be >0
    3299         [ +  + ]:        6983 :    if(dt%optcell>0)then
    3300                 :          97 :      cond_string(1)='optcell' ; cond_values(1)=dt%optcell
    3301                 :          97 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'optstress',dt%optstress,1,(/1/),iout)
    3302                 :             :    end if
    3303                 :             : !  TB09 XC functional cannot provide forces/stresses
    3304   [ +  +  +  +  :        6983 :    if((dt%optforces/=0.or.dt%optstress/=0).and.xc_is_pot_only)then
                   -  + ]
    3305                 :             :      write(msg, '(7a)' ) &
    3306                 :           0 :       'When the selected XC functional is a potential-only functional (Becke-Johnson or Tran-Blaha),',ch10,&
    3307                 :           0 :       'calculations cannot be self-consistent with respect to the total energy.',ch10,&
    3308                 :           0 :       'For that reason, neither forces nor stresses can be computed.',ch10,&
    3309                 :           0 :       'You should set optforces and optstress to 0!'
    3310                 :           0 :      ABI_WARNING(msg)
    3311                 :             :   end if
    3312                 :             : 
    3313                 :             :   !  orbmag
    3314                 :             :   ! only values of -3..4 are allowed. 0 is the default.
    3315                 :        6983 :   call chkint_eq(0,0,cond_string,cond_values,ierr,'orbmag',dt%orbmag,8,(/-3,-2,-1,0,1,2,3,4/),iout)
    3316         [ +  + ]:        6983 :   if(dt%orbmag .NE. 0) then
    3317                 :          21 :     cond_string(1)='orbmag';cond_values(1)=dt%orbmag
    3318                 :             :   ! only kptopt 0, 3, 4 are allowed, because ddk cannot use spatial symmetries and
    3319                 :             :   ! time reversal symmetry is typically broken
    3320                 :          21 :     call chkint_eq(1,1,cond_string,cond_values,ierr,'kptopt',dt%kptopt,3,(/0,3,4/),iout)
    3321                 :             :   ! only kpt parallelism is allowed at present
    3322                 :          21 :     call chkint_eq(1,1,cond_string,cond_values,ierr,'paral_kgb',dt%paral_kgb,1,(/0/),iout)
    3323         [ +  + ]:          21 :     if (dt%usepaw.EQ.1) then
    3324                 :             :       !  if PAW, require usexcnhat 0
    3325                 :          20 :       call chkint_eq(1,1,cond_string,cond_values,ierr,'usexcnhat',dt%usexcnhat_orig,1,(/0/),iout)
    3326                 :             :       ! if PAW, require paral_atom 0
    3327                 :          20 :       call chkint_eq(1,1,cond_string,cond_values,ierr,'paral_atom',dt%paral_atom,1,(/0/),iout)
    3328                 :             :     end if
    3329                 :             :   end if
    3330         [ +  + ]:        6983 :   if(dt%orbmag .LT. 0) then
    3331                 :             :     ! berryopt -2 ddk is required
    3332                 :           1 :     call chkint_eq(1,1,cond_string,cond_values,ierr,'berryopt',dt%berryopt,1,(/-2/),iout)
    3333                 :             :   end if
    3334   [ +  +  -  +  :        6983 :   if((dt%orbmag.GT.0).AND.(dt%rfddk.NE.1).AND.(dt%rfelfd.LT.2)) then
                   -  - ]
    3335                 :             :     write(msg, '(3a)' )&
    3336                 :           0 :       'Positive values of orbmag require DFPT DDK wavefunctions',ch10,&
    3337                 :           0 :       'Action: rerun calculation using rfddk 1 or rfelfd 2.'
    3338                 :           0 :     ABI_ERROR_NOSTOP(msg, ierr)
    3339                 :             :   end if
    3340                 :             : 
    3341                 :             : !  paral_atom
    3342                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'paral_atom',dt%paral_atom,2,(/0,1/),iout)
    3343         [ +  + ]:        6983 :    if (dt%paral_atom/=0) then
    3344         [ -  + ]:         474 :      if (dt%optdriver/=RUNL_GSTATE.and.dt%optdriver/=RUNL_RESPFN) then
    3345                 :             :        write(msg, '(5a)' )&
    3346                 :           0 :         'Parallelisation over atoms is only compatible with',ch10,&
    3347                 :           0 :         'ground-state or response function calculations !',ch10,&
    3348                 :           0 :         'Action: change paral_atom in input file.'
    3349                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    3350                 :             :      end if
    3351         [ -  + ]:         474 :      if (dt%optdriver==RUNL_NONLINEAR) then
    3352                 :           0 :        cond_string(1)='optdriver' ; cond_values(1)=dt%optdriver
    3353                 :           0 :        call chkint_eq(1,1,cond_string,cond_values,ierr,'paral_atom',dt%paral_atom,1,(/0/),iout)
    3354                 :             :      end if
    3355         [ -  + ]:         474 :      if (dt%usedmft==1.or.dt%usedmft==10) then
    3356                 :           0 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
    3357                 :           0 :        call chkint_eq(1,1,cond_string,cond_values,ierr,'paral_atom',dt%paral_atom,1,(/0/),iout)
    3358                 :             :      end if
    3359   [ -  +  -  - ]:         474 :      if (dt%prtden>1.and.dt%paral_kgb==0) then
    3360                 :           0 :        cond_string(1)='paral_kgb' ; cond_values(1)=dt%paral_kgb
    3361                 :           0 :        cond_string(2)='prtden' ; cond_values(2)=dt%prtden
    3362                 :           0 :        call chkint_eq(1,2,cond_string,cond_values,ierr,'paral_atom',dt%paral_atom,1,(/0/),iout)
    3363                 :             :      end if
    3364                 :             :    end if
    3365                 :             : 
    3366                 :             : !  paral_kgb
    3367                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'paral_kgb',dt%paral_kgb,2,(/0,1/),iout)
    3368                 :             : !  Warning
    3369   [ +  +  +  + ]:        6983 :    if(dt%paral_kgb==1.and.dt%iomode/=IO_MODE_MPI) then
    3370                 :             :      write(msg,'(11a)' )&
    3371                 :         600 :       'When k-points/bands/FFT parallelism is activated',ch10,&
    3372                 :         600 :       '(paral_kgb=1), only MPI-IO input/output is allowed !',ch10,&
    3373                 :         600 :       'iomode/=1 in your input file',ch10,&
    3374                 :        1200 :       'You will not be able to perform input/output !'
    3375                 :         600 :      ABI_WARNING(msg)
    3376                 :             :    end if
    3377                 :             : 
    3378   [ +  +  -  + ]:        6983 :    if(dt%paral_kgb==1.and.dt%nstep==0) then
    3379                 :           0 :      ABI_ERROR_NOSTOP('When k-points/bands/FFT parallelism is activated, nstep=0 is not allowed!', ierr)
    3380                 :             :    end if
    3381   [ +  +  -  + ]:        6983 :    if(dt%paral_kgb==1.and.dt%usefock>0) then
    3382                 :           0 :      ABI_ERROR_NOSTOP('Hartree-Fock or Hybrid Functionals are not compatible with bands/FFT parallelism!', ierr)
    3383                 :             :    end if
    3384   [ +  +  +  +  :        6983 :    if(dt%chkparal/=0.and.(dt%paral_kgb/=0.and.(dt%optdriver/=RUNL_GSTATE .and. dt%optdriver/=RUNL_GWLS .and. &
             +  +  -  + ]
    3385                 :             :       dt%optdriver/=RUNL_RTTDDFT))) then
    3386                 :           0 :        cond_string(1)='optdriver' ; cond_values(1)=dt%optdriver
    3387                 :           0 :        cond_string(2)='chkparal' ; cond_values(2)=dt%chkparal
    3388                 :           0 :        call chkint_eq(2,2,cond_string,cond_values,ierr,'paral_kgb',dt%paral_kgb,1,(/0/),iout)
    3389                 :             :    end if
    3390                 :             : 
    3391                 :             : !  paral_rf
    3392   [ +  +  -  + ]:        6983 :    if (response==0 .and. dt%paral_rf/=0) then
    3393                 :             :      write(msg,'(a,i3,3a,13(a,i2),4a)' )&
    3394                 :           0 :      'The input variable optdriver=',dt%optdriver,ch10,&
    3395                 :           0 :      'This is in conflict with the values of the other input variables,',ch10,&
    3396                 :           0 :      'rfphon=',dt%rfphon,' rfddk=',dt%rfddk,' rf2_dkdk=',dt%rf2_dkdk,' rf2_dkde=',dt%rf2_dkde,&
    3397                 :           0 :      ' rfelfd=',dt%rfelfd,'  rfmagn=',dt%rfmagn,' rfstrs=',dt%rfstrs,&
    3398                 :           0 :      ' d3e_pert1_elfd=',dt%d3e_pert1_elfd,' d3e_pert2_elfd=',dt%d3e_pert2_elfd,' d3e_pert3_elfd=',dt%d3e_pert3_elfd,&
    3399                 :           0 :      ' d3e_pert1_phon=',dt%d3e_pert1_phon,' d3e_pert2_phon=',dt%d3e_pert2_phon,' d3e_pert3_phon=',dt%d3e_pert3_phon,ch10,&
    3400                 :           0 :      'Action: check the values of optdriver, rfphon, rfddk, rf2dkdk, rf2dkde, rfelfd, rfmagn, rfstrs,',ch10,&
    3401                 :           0 :      'd3e_pert1_elfd, d3e_pert2_elfd, d3e_pert3_elfd, d3e_pert1_phon, d3e_pert2_phon, and d3e_pert3_phon in your input file.'
    3402                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    3403                 :             :    end if
    3404                 :             : 
    3405                 :             : !  paw_add_core
    3406         [ +  + ]:        6983 :    if (usepaw==1) then
    3407                 :        1205 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'paw_add_core',dt%paw_add_core,2,(/0,1/),iout)
    3408   [ +  +  +  +  :        2159 :      if (dt%paw_add_core==1.and.any(pspheads(1:npsp)%pspcod/=17)) then
             +  +  -  + ]
    3409                 :             :        write(msg, '(5a)' )&
    3410                 :           0 :         'paw_add_core input variable can only be used PAW datasets in XML format.',ch10,&
    3411                 :           0 :         'However one of your PAW atomic dataset is not in PAW-XML format!',ch10,&
    3412                 :           0 :         'Action: change your pseudopotential file to a PAW-XML one '
    3413                 :           0 :        ABI_ERROR_NOSTOP(msg,ierr)
    3414                 :             :      end if
    3415                 :             :    endif
    3416                 :             : 
    3417                 :             : !  pawcpxocc
    3418         [ +  + ]:        6983 :    if (usepaw==1) then
    3419                 :        1205 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'pawcpxocc',dt%pawcpxocc,2,(/1,2/),iout)
    3420   [ +  +  +  +  :        1205 :      if (dt%usepawu/=0.and.nspinor==2.and.dt%pawcpxocc==1) then
                   -  + ]
    3421                 :             :        write(msg, '(5a)' )&
    3422                 :           0 :        'When non-collinear magnetism is activated ,',ch10,&
    3423                 :           0 :        'and DFT+U activated ',ch10,&
    3424                 :           0 :        'PAW occupancies must be complex !'
    3425                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    3426   [ +  +  +  +  :        1205 :      else if (dt%pawspnorb==1.and.(dt%kptopt==0.or.dt%kptopt>=3).and.dt%pawcpxocc==1) then
                   +  + ]
    3427   [ +  -  -  + ]:           1 :        if (optdriver==RUNL_GSTATE.and.dt%iscf<10) then
    3428                 :             :          write(msg, '(11a)' )&
    3429                 :           0 :          'When spin-orbit coupling is activated (pawspnorb=1),',ch10,&
    3430                 :           0 :          'and time-reversal symmetry is broken (kptopt/=1 and kptopt/=2)',ch10,&
    3431                 :           0 :          'PAW occupancies are complex !',ch10,&
    3432                 :           0 :          'Their imaginary part is used to evaluate total energy by direct',ch10,&
    3433                 :           0 :          'scheme, needed here because SCF potential mixing has been chosen (iscf<10).',ch10,&
    3434                 :           0 :          'Action: put pawcpxocc=2 in input file, or choose SCF density mixing (iscf>=10).'
    3435                 :           0 :          ABI_ERROR_NOSTOP(msg, ierr)
    3436   [ +  -  +  - ]:           1 :        else if (optdriver==RUNL_GSTATE.and.dt%iscf>=10) then
    3437                 :             :          write(msg, '(11a)' )&
    3438                 :           1 :          'When spin-orbit coupling is activated (pawspnorb=1),',ch10,&
    3439                 :           1 :          'and time-reversal symmetry is broken (kptopt/=1 and kptopt/=2)',ch10,&
    3440                 :           1 :          'PAW occupancies are complex !',ch10,&
    3441                 :           1 :          'By setting pawcpxocc=1 in input file, their imaginary part',ch10,&
    3442                 :           1 :          'is not computed. As a consequence, total energy computed',ch10,&
    3443                 :           2 :          'is not available. Put pawcpxocc=2 in input file if you want it.'
    3444                 :           1 :          ABI_WARNING(msg)
    3445                 :             :        else
    3446                 :             :          write(msg, '(11a)' )&
    3447                 :           0 :          'When spin-orbit coupling is activated (pawspnorb=1),',ch10,&
    3448                 :           0 :          'and time-reversal symmetry is broken (kptopt/=1 and kptopt/=2)',ch10,&
    3449                 :           0 :          'PAW occupancies are complex !',ch10,&
    3450                 :           0 :          'Action: put pawcpxocc=2 in input file to compute their imaginary part.'
    3451                 :           0 :          ABI_ERROR_NOSTOP(msg, ierr)
    3452                 :             :        end if
    3453                 :             :      end if
    3454   [ +  +  +  + ]:        1205 :      if (dt%pawspnorb==1.and.dt%kptopt==0) then
    3455                 :             :        write(msg, '(7a)' )&
    3456                 :          16 :        'When spin-orbit coupling is activated (pawspnorb=1),',ch10,&
    3457                 :          16 :        'time-reversal symmetry might be broken.',ch10,&
    3458                 :          16 :        'Using kptopt=0 might be risky: if (kx,ky,kz) is present in k-points list,',ch10,&
    3459                 :          32 :        '(-kx,-ky,-kz) (or equivalent) should also be present.'
    3460                 :          16 :        ABI_WARNING(msg)
    3461                 :             :      end if
    3462                 :             :    end if
    3463                 :             : 
    3464                 :             : !  pawcross
    3465         [ +  + ]:        6983 :    if (usepaw==1) then
    3466                 :        1205 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'pawcross',dt%pawcross,2,(/0,1/),iout)
    3467                 :             :    endif
    3468                 :             : 
    3469                 :             : !  pawfatbnd
    3470                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'pawfatbnd',dt%pawfatbnd,3,(/0,1,2/),iout)
    3471   [ +  +  -  + ]:        6983 :    if(usepaw/=1.and.dt%pawfatbnd>1) then
    3472                 :           0 :      ABI_ERROR_NOSTOP('pawfatbnd without PAW is not possible', ierr)
    3473                 :             :    end if
    3474   [ +  +  -  + ]:        6983 :    if(dt%prtdosm==1.and.dt%pawfatbnd>0)then
    3475                 :           0 :      ABI_ERROR_NOSTOP('pawfatbnd>0  and prtdosm=1 are not compatible', ierr)
    3476                 :             :    end if
    3477                 :             : !  for the moment pawfatbnd is not compatible with fft or band parallelization
    3478                 :             :    !if (dt%pawfatbnd > 0 .and. (dt%npfft > 1 .or. dt%npband > 1)) then
    3479                 :             :    !  msg = 'pawfatbnd and FFT or band parallelization are not compatible yet. Set pawfatbnd to 0  '
    3480                 :             :    !  ABI_ERROR_NOSTOP(msg,ierr)
    3481                 :             :    !end if
    3482                 :             : 
    3483                 :             : !  pawlcutd
    3484         [ +  + ]:        6983 :    if (usepaw==1) then
    3485                 :        1205 :      call chkint_ge(0,0,cond_string,cond_values,ierr,'pawlcutd',dt%pawlcutd,0,iout)
    3486                 :             :    endif
    3487                 :             : 
    3488                 :             : !  pawlmix
    3489         [ +  + ]:        6983 :    if (usepaw==1) then
    3490                 :        1205 :      call chkint_ge(0,0,cond_string,cond_values,ierr,'pawlmix',dt%pawlmix,0,iout)
    3491                 :             :    endif
    3492                 :             : 
    3493                 :             : !  pawmixdg
    3494         [ +  + ]:        6983 :    if (usepaw==1) then
    3495         [ -  + ]:        1205 :      if(dt%ionmov==4)then
    3496                 :           0 :        cond_string(1)='ionmov' ; cond_values(1)=dt%ionmov
    3497                 :           0 :        call chkint_eq(1,1,cond_string,cond_values,ierr,'pawmixdg',dt%pawmixdg,1,(/1/),iout)
    3498                 :             :      end if
    3499   [ +  -  -  + ]:        1205 :      if(dt%iscf==5.or.dt%iscf==6.or.dt%iscf==15.or.dt%iscf==16)then
    3500                 :           0 :        cond_string(1)='iscf' ; cond_values(1)=dt%iscf
    3501                 :           0 :        call chkint_eq(1,1,cond_string,cond_values,ierr,'pawmixdg',dt%pawmixdg,1,(/1/),iout)
    3502                 :             :      end if
    3503         [ -  + ]:        1205 :      if(usewvl==1)then
    3504                 :           0 :        cond_string(1)='usewvl' ; cond_values(1)=usewvl
    3505                 :           0 :        call chkint_eq(1,1,cond_string,cond_values,ierr,'pawmixdg',dt%pawmixdg,1,(/1/),iout)
    3506                 :             :      end if
    3507                 :             :    end if
    3508                 :             : 
    3509                 :             : !  pawnhatxc
    3510         [ +  + ]:        6983 :    if (usepaw==1) then
    3511                 :        1205 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'pawnhatxc',dt%pawnhatxc,2,(/0,1/),iout)
    3512                 :             :    endif
    3513                 :             : 
    3514                 :             : !  pawnzlm
    3515         [ +  + ]:        6983 :    if (usepaw==1) then
    3516                 :        1205 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'pawnzlm',dt%pawnzlm,2,(/0,1/),iout)
    3517                 :             :    endif
    3518                 :             : 
    3519                 :             : !  pawoptmix
    3520         [ +  + ]:        6983 :    if (usepaw==1) then
    3521                 :        1205 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'pawoptmix',dt%pawoptmix,2,(/0,1/),iout)
    3522                 :             :    endif
    3523                 :             : 
    3524                 :             : !  pawprtdos
    3525         [ +  + ]:        6983 :    if (usepaw==1) then
    3526                 :        1205 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'pawprtdos',dt%pawprtdos,3,(/0,1,2/),iout)
    3527                 :             :    endif
    3528                 :             : 
    3529                 :             : !  pawprtvol
    3530         [ +  + ]:        6983 :    if (usepaw==1) then
    3531                 :        1205 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'pawprtvol',dt%pawprtvol,7,(/-3,-2,-1,0,1,2,3/),iout)
    3532                 :             :    endif
    3533                 :             : 
    3534                 :             : !  pawspnorb
    3535         [ +  + ]:        6983 :    if (usepaw==1) then
    3536                 :        1205 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'pawspnorb',dt%pawspnorb,2,(/0,1/),iout)
    3537   [ +  +  -  + ]:        1205 :      if (dt%pawspnorb==1.and.(dt%kptopt==1.or.dt%kptopt==2)) then
    3538                 :             :        write(msg, '(7a)' )&
    3539                 :           0 :         'When spin-orbit coupling is activated (pawspnorb=1),',ch10,&
    3540                 :           0 :         'time-reversal symmetry is broken; k-points cannot',ch10,&
    3541                 :           0 :         'be generated using TR-symmetry.',ch10,&
    3542                 :           0 :         'Action: choose kptopt different from 1 or 2.'
    3543                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    3544                 :             :      end if
    3545                 :             :    end if
    3546                 :             : 
    3547                 :             : !  pawstgylm, pawsushat
    3548         [ +  + ]:        6983 :    if (usepaw==1) then
    3549                 :        1205 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'pawstgylm',dt%pawstgylm,2,(/0,1/),iout)
    3550                 :        1205 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'pawsushat',dt%pawstgylm,2,(/0,1/),iout)
    3551                 :             :    end if
    3552                 :             : 
    3553                 :             : !  pawusecp
    3554         [ +  + ]:        6983 :    if (usepaw==1) then
    3555                 :        1205 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'pawusecp',dt%pawusecp,2,(/0,1/),iout)
    3556                 :             : !      if (dt%mkmem/=0)then
    3557                 :             : !        cond_string(1)='mkmem' ; cond_values(1)=dt%mkmem
    3558                 :             : !        call chkint_eq(1,1,cond_string,cond_values,ierr,'pawusecp',dt%pawusecp,1,(/1/),iout)
    3559                 :             : !      end if
    3560                 :             : !      if (dt%mk1mem/=0)then
    3561                 :             : !        cond_string(1)='mk1mem' ; cond_values(1)=dt%mk1mem
    3562                 :             : !        call chkint_eq(1,1,cond_string,cond_values,ierr,'pawusecp',dt%pawusecp,1,(/1/),iout)
    3563                 :             : !      end if
    3564                 :             : !      if (dt%mkqmem/=0)then
    3565                 :             : !        cond_string(1)='mkqmem' ; cond_values(1)=dt%mkqmem
    3566                 :             : !        call chkint_eq(1,1,cond_string,cond_values,ierr,'pawusecp',dt%pawusecp,1,(/1/),iout)
    3567                 :             : !      end if
    3568                 :             :    end if
    3569                 :             : 
    3570                 :             : !  pawxcdev
    3571         [ +  + ]:        6983 :    if (usepaw==1) then
    3572                 :        1205 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'pawxcdev',dt%pawxcdev,3,(/0,1,2/),iout)
    3573                 :             :    endif
    3574                 :             : 
    3575                 :             : !  pimass
    3576                 :             : !  Check that masses are > 0 if imgmov = 9 or 13
    3577         [ +  + ]:        6983 :    if (dt%imgmov==9.or.dt%imgmov==13) then
    3578         [ +  + ]:          14 :      do itypat=1,dt%ntypat
    3579                 :           7 :        cond_string(1)='imgmov' ; cond_values(1)=dt%imgmov
    3580                 :           7 :        write(input_name,'(a4,i1,a1)')'pimass(',itypat,')'
    3581                 :          14 :        call chkdpr(1,1,cond_string,cond_values,ierr,input_name,dt%pimass(itypat),1,tol8,iout)
    3582                 :             :      end do
    3583                 :             :    end if
    3584                 :             : 
    3585                 :             : !  pimd_constraint
    3586                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'pimd_constraint',dt%pimd_constraint,2,(/0,1/),iout)
    3587   [ +  +  -  + ]:        6983 :    if(dt%pimd_constraint==1.and.dt%nconeq>1 )then
    3588                 :           0 :      cond_string(1)='pimd_constraint' ; cond_values(1)=dt%pimd_constraint
    3589                 :             : !    Make sure that nconeq=1
    3590                 :           0 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'nconeq',dt%nconeq,1,(/1/),iout)
    3591                 :             :    end if
    3592                 :             : 
    3593                 :             : !  pitransform
    3594                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'pitransform',dt%pitransform,3,(/0,1,2/),iout)
    3595                 :             : !  When imgmov is not one of 9 or 13, pitransform must be 0
    3596         [ +  + ]:        6983 :    if(dt%imgmov/=9 .and. dt%imgmov/=13 )then
    3597                 :        6976 :      cond_string(1)='imgmov' ; cond_values(1)=dt%imgmov
    3598                 :             : !    Make sure that pitransform=0
    3599                 :        6976 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'pitransform',dt%pitransform,1,(/0/),iout)
    3600                 :             :    end if
    3601         [ +  + ]:        6983 :    if(dt%pimd_constraint/=0 )then
    3602                 :           1 :      cond_string(1)='pimd_constraint' ; cond_values(1)=dt%pimd_constraint
    3603                 :             : !    Make sure that pitransform=0
    3604                 :           1 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'pitransform',dt%pitransform,1,(/0/),iout)
    3605                 :             :    end if
    3606                 :             : 
    3607                 :             : !  plowan_compute
    3608                 :        6983 :    cond_string(1)='usepaw' ; cond_values(1)=usepaw
    3609                 :        6983 :    call chkint_eq(1,1,cond_string,cond_values,ierr,'plowan_compute',dt%plowan_compute,4,(/0,1,2,10/),iout)
    3610         [ -  + ]:        6983 :    if(dt%plowan_compute>0) then
    3611                 :             : !    plowan_bandi/plowan_bandf
    3612                 :             :      !call chkint_ge(0,0,cond_string,cond_values,ierr,'plowan_bandi',dt%plowan_bandi,              1,iout)
    3613                 :             :      !call chkint_ge(0,0,cond_string,cond_values,ierr,'plowan_bandf',dt%plowan_bandf,dt%plowan_bandi,iout)
    3614                 :             : 
    3615                 :             :      !call chkint_le(0,0,cond_string,cond_values,ierr,'plowan_bandi',dt%plowan_bandi,dt%plowan_bandf,iout)
    3616                 :             :      !call chkint_le(0,0,cond_string,cond_values,ierr,'plowan_bandi',dt%plowan_bandf,dt%mband       ,iout)
    3617                 :             : 
    3618                 :           0 :      call chkint_ge(0,0,cond_string,cond_values,ierr,'plowan_natom',dt%plowan_natom,              0,iout)
    3619                 :             : 
    3620         [ #  # ]:           0 :      maxplowan_iatom=maxval(dt%plowan_iatom(1:dt%plowan_natom))
    3621         [ #  # ]:           0 :      minplowan_iatom=minval(dt%plowan_iatom(1:dt%plowan_natom))
    3622                 :           0 :      call chkint_ge(0,0,cond_string,cond_values,ierr,'plowan_iatom',minplowan_iatom,              1,iout)
    3623                 :           0 :      call chkint_le(0,0,cond_string,cond_values,ierr,'plowan_iatom',maxplowan_iatom,          natom,iout)
    3624                 :             : 
    3625                 :           0 :      kk=0
    3626         [ #  # ]:           0 :      do jj = 1, dt%plowan_natom
    3627         [ #  # ]:           0 :        do ii = 1, dt%plowan_nbl(jj)
    3628                 :           0 :          kk=kk+1
    3629                 :           0 :          cond_string(1)='usepaw' ; cond_values(1)=usepaw
    3630                 :           0 :          call chkint_eq(1,1,cond_string,cond_values,ierr,'plowan_lcalc',dt%plowan_lcalc(kk),4,(/0,1,2,3/),iout)
    3631                 :             :        end do
    3632                 :             :      end do
    3633                 :             : 
    3634                 :           0 :      call chkint_ge(0,0,cond_string,cond_values,ierr,'plowan_nt'   ,dt%plowan_nt,                 0,iout)
    3635                 :           0 :      cond_string(1)='usepaw' ; cond_values(1)=usepaw
    3636                 :           0 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'plowan_realspace',dt%plowan_realspace,3,(/0,1,2/),iout)
    3637                 :             :    end if
    3638                 :             : 
    3639                 :             : !  posdoppler
    3640                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'posdoppler',dt%posdoppler,2,(/0,1/),iout)
    3641                 :             : 
    3642                 :             : !  positron
    3643                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'positron',dt%positron,7,(/-20,-10,-2,-1,0,1,2/),iout)
    3644   [ +  +  -  + ]:        6983 :    if ((dt%positron==2.or.dt%positron<0).and.(dt%ixcpositron==3.or.dt%ixcpositron==31)) then
    3645   [ #  #  #  #  :           0 :      if ((dt%ixc<11.or.dt%ixc>17).and.dt%ixc/=23.and.dt%ixc/=26.and.dt%ixc/=27) then
                   #  # ]
    3646                 :             :        write(msg, '(7a)' )&
    3647                 :           0 :         'For the electronic ground-state calculation in presence of a positron,',ch10,&
    3648                 :           0 :         'when GGA is selected for electron-positron correlation (ixcpositron=3 or 31),',ch10,&
    3649                 :           0 :         'electron-electron XC must also be GGA !',ch10,&
    3650                 :           0 :         'Action: choose another psp file.'
    3651                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    3652                 :             :      end if
    3653                 :             :    end if
    3654   [ +  +  -  + ]:        6983 :    if (dt%positron/=0.and.xc_is_mgga) then
    3655                 :           0 :      msg='Electron-positron calculation is not compatible with meta-GGA XC functional!'
    3656                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    3657                 :             :    end if
    3658   [ +  +  -  + ]:        6983 :    if (dt%positron/=0.and.dt%ionmov==5) then
    3659                 :           0 :      cond_string(1)='ionmov' ; cond_values(1)=dt%ionmov
    3660                 :           0 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'positron',dt%positron,1,(/0/),iout)
    3661                 :             :    end if
    3662   [ +  +  -  + ]:        6983 :    if (dt%positron<0.and.usepaw==0) then
    3663                 :             :      write(msg, '(5a)' )&
    3664                 :           0 :       'You cannot use positron<0 (automatic two-component DFT)',ch10,&
    3665                 :           0 :       'with norm-conserving pseudopotentials !',ch10,&
    3666                 :           0 :       'Action: choose PAW.'
    3667                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    3668                 :             :    end if
    3669   [ +  +  -  +  :        6983 :    if ((dt%positron==1.or.dt%positron<0).and.dt%iscf<10.and.dt%tolvrs>tiny(one)) then
                   -  - ]
    3670                 :             :      write(msg, '(7a)' )&
    3671                 :           0 :       'You cannot perform a positronic ground-state calculation (positron=1 or <0)',ch10,&
    3672                 :           0 :       'using SCF potential mixing (iscf<10) and tolvrs !',ch10,&
    3673                 :           0 :       '(in that case, the potential is constant)',ch10,&
    3674                 :           0 :       'Action: change iscf or select another convergence criterion.'
    3675                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    3676                 :             :    end if
    3677                 :             : 
    3678                 :             : !  posocc
    3679                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'posocc',dt%posocc,-1,one,iout)
    3680                 :             : 
    3681                 :             : !  postoldfe, postoldff
    3682                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'postoldff',dt%postoldff,1,zero,iout)
    3683         [ +  + ]:        6983 :    if (dt%positron<0) then
    3684   [ +  -  +  +  :           8 :      if ( (abs(dt%postoldfe)> tiny(0.0_dp).and.abs(dt%postoldff)> tiny(0.0_dp)).or.&
                   -  + ]
    3685         [ +  + ]:           8 :           (abs(dt%postoldfe)<=tiny(0.0_dp).and.abs(dt%postoldff)<=tiny(0.0_dp))) then
    3686                 :             :        write(msg,'(5a)' )&
    3687                 :           0 :         'One and only one of the input tolerance criteria postoldfe or postoldff',ch10,&
    3688                 :           0 :         'must differ from zero !',ch10,&
    3689                 :           0 :         'Action: change postoldfe or postldff in input file.'
    3690                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    3691                 :             :      end if
    3692   [ +  +  -  + ]:           8 :      if (abs(dt%postoldff)>tiny(0.0_dp).and.dt%optforces/=1)then
    3693                 :             :        write(msg,'(3a)' )&
    3694                 :           0 :         'When postoldff is set to a non-zero value, optforces must be set to 1 !',ch10,&
    3695                 :           0 :         'Action: change your input file.'
    3696                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    3697                 :             :      end if
    3698                 :             :    end if
    3699                 :             : 
    3700                 :             : ! prepalw
    3701                 :        6983 :   call chkint_eq(0,0,cond_string,cond_values,ierr,'prepalw',dt%prepalw,5,(/0,1,2,3,4/),iout)
    3702                 :             : 
    3703                 :             : !  prepanl
    3704                 :             : !  Must have prtden=1 to prepare a nonlinear calculation
    3705   [ +  +  +  +  :        6983 :    if (dt%prepanl==1.and.(dt%rfelfd/=0.or.dt%rfphon/=0)) then
                   -  + ]
    3706                 :          24 :      cond_string(1)='rfelfd'  ; cond_values(1)=dt%rfelfd
    3707                 :          24 :      cond_string(2)='rfphon'  ; cond_values(2)=dt%rfphon
    3708                 :          24 :      cond_string(3)='prepanl' ; cond_values(3)=dt%prepanl
    3709                 :          24 :      call chkint_eq(1,3,cond_string,cond_values,ierr,'prtden',dt%prtden,1,(/1/),iout)
    3710                 :             :    end if
    3711                 :             : 
    3712                 :             : !  prtbbb
    3713                 :             : !  Not allowed for PAW
    3714   [ +  +  -  + ]:        6983 :    if(usepaw==1.and.dt%prtbbb==1)then
    3715                 :           0 :      cond_string(1)='usepaw' ; cond_values(1)=usepaw
    3716                 :           0 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtbbb',dt%prtbbb,1,(/0/),iout)
    3717                 :             :    end if
    3718                 :             : 
    3719                 :             : !  prtden
    3720         [ +  + ]:        6983 :    if (usepaw==1) then
    3721                 :        1205 :      call chkint_le(0,0,cond_string,cond_values,ierr,'prtden',dt%prtden,7,iout)
    3722                 :             :    else
    3723                 :        5778 :      call chkint_le(0,0,cond_string,cond_values,ierr,'prtden',dt%prtden,1,iout)
    3724                 :             :    end if
    3725                 :             : 
    3726                 :             : !  prtdensph
    3727         [ +  + ]:        6983 :    if (usepaw==1) then
    3728                 :        1205 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'prtdensph',dt%prtdensph,2,(/0,1/),iout)
    3729                 :             :    endif
    3730                 :             : 
    3731                 :             :    !  prt_lorbmag
    3732         [ +  + ]:        6983 :    if (usepaw==1) call chkint_eq(0,0,cond_string,cond_values,ierr,'prt_lorbmag',dt%prt_lorbmag,2,(/0,1/),iout)
    3733                 :             : 
    3734                 :             : !  prtdos
    3735                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'prtdos',dt%prtdos,6,(/0,1,2,3,4,5/),iout)
    3736                 :             : 
    3737                 :             : ! for the moment prtdos 3,4,5 are not compatible with fft or band parallelization
    3738   [ +  +  +  -  :        6983 :    if (dt%prtdos > 4 .and. (dt%npfft > 1 .or. dt%npband > 1)) then
                   -  + ]
    3739                 :           0 :      ABI_ERROR_NOSTOP('prtdos>4 and FFT or band parallelization are not compatible yet. Set prtdos <= 4', ierr)
    3740                 :             :    end if
    3741                 :             : 
    3742                 :             : ! prtdos 5 only makes sense for nspinor == 2. Otherwise reset to prtdos 2
    3743   [ +  +  -  + ]:        6983 :    if (dt%prtdos == 5 .and. dt%nspinor /= 2) then
    3744                 :           0 :      dt%prtdos = 2
    3745                 :           0 :      ABI_WARNING('prtdos==5 is only useful for nspinor 2. Has been reset to 2')
    3746                 :             :    end if
    3747   [ +  +  -  + ]:        6983 :    if (dt%prtdos == 5 .and. dt%npspinor /= 1) then
    3748                 :           0 :      ABI_ERROR_NOSTOP('prtdos==5 not available with npspinor==2', ierr)
    3749                 :             :    end if
    3750                 :             :    ! Consistency check for prtdos 5 with PAW
    3751   [ +  +  -  + ]:        6983 :    if (dt%prtdos == 5 .and. dt%usepaw == 1) then
    3752         [ #  # ]:           0 :      if (dt%pawprtdos == 2) then
    3753                 :           0 :        ABI_ERROR_NOSTOP('prtdos==5 is not compatible with pawprtdos 2', ierr)
    3754                 :             :      end if
    3755                 :           0 :      ABI_ERROR_NOSTOP('prtdos==5 is not available with PAW', ierr)
    3756                 :             :    end if
    3757                 :             : 
    3758                 :             : !  prtdosm
    3759                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'prtdosm',dt%prtdosm,3,(/0,1,2/),iout)
    3760   [ +  +  -  + ]:        6983 :    if(usepaw==1.and.dt%pawprtdos==1)then
    3761                 :           0 :      cond_string(1)='pawprtdos' ; cond_values(1)=dt%pawprtdos
    3762                 :           0 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtdosm',dt%prtdosm,1,(/0/),iout)
    3763                 :             :    end if
    3764   [ +  +  +  + ]:        6983 :    if(usepaw==1.and.dt%prtdosm>=1)then
    3765                 :           1 :      cond_string(1)='prtdosm' ; cond_values(1)=dt%prtdosm
    3766                 :           1 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtdos',dt%prtdos,1,(/3/),iout)
    3767                 :             :    end if
    3768   [ -  +  -  - ]:        6983 :    if(dt%prtdosm==2.and.dt%pawprtdos/=2)then
    3769                 :           0 :      ABI_ERROR(' pawprtdos/=2  and prtdosm=2 are not compatible')
    3770                 :             :    end if
    3771                 :             : 
    3772                 :             :    !  prtefmas
    3773                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'prtefmas',dt%prtefmas,2,(/0,1/),iout)
    3774                 :             :    !if(optdriver/=RUNL_RESPFN)then
    3775                 :             :    !  cond_string(1)='optdriver' ; cond_values(1)=optdriver
    3776                 :             :    !  call chkint_eq(0,1,cond_string,cond_values,ierr,'prtefmas',dt%prtefmas,1,(/0/),iout)
    3777                 :             :    !end if
    3778                 :             : 
    3779                 :             : !  prtelf
    3780                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'prtelf',dt%prtkden,0,iout)
    3781         [ +  + ]:        6983 :    if(optdriver/=RUNL_GSTATE)then
    3782                 :        1322 :      cond_string(1)='optdriver' ; cond_values(1)=optdriver
    3783                 :        1322 :      call chkint_eq(0,1,cond_string,cond_values,ierr,'prtelf',dt%prtelf,1,(/0/),iout)
    3784                 :             :    end if
    3785         [ +  + ]:        6983 :    if(usepaw/=0)then
    3786                 :        1205 :      cond_string(1)='usepaw' ; cond_values(1)=usepaw
    3787                 :        1205 :      call chkint_eq(0,1,cond_string,cond_values,ierr,'prtelf',dt%prtelf,1,(/0/),iout)
    3788                 :             :    end if
    3789                 :             : 
    3790                 :             : !  prtevk
    3791                 :             : !  Not compatible with parallelization over perturbations if netcdf doesn't have MPI
    3792                 :             :    if (dt%prtevk==1.and.dt%paral_rf==1) then
    3793                 :             : #ifndef HAVE_NETCDF_MPI
    3794                 :             :      write(msg,'(8a)')ch10,&
    3795                 :             :         'prtevk=1 (printing of EVK file) is not compatible with parallelization over',ch10, &
    3796                 :             :         '  perturbations when netCDF/HDF5 is not parallel (MPI)!',ch10,&
    3797                 :             :         'Action: suppress parallelization over perturbations (paral_rf)',ch10,&
    3798                 :             :         '        or link ABINIT with a MPI-compatible netCDF'
    3799                 :             :     ABI_ERROR_NOSTOP(msg, ierr)
    3800                 :             : #endif
    3801                 :             :    end if
    3802                 :             : 
    3803                 :             : !  prtfsurf only one shift allowed (gamma)
    3804         [ +  + ]:        6983 :    if (dt%prtfsurf == 1) then
    3805                 :             : 
    3806         [ -  + ]:           2 :      if (.not. isdiagmat(dt%kptrlatt)) then
    3807                 :           0 :        write(msg,'(4a)')ch10,&
    3808                 :           0 :          'prtfsurf does not work with non-diagonal kptrlatt ', ch10,&
    3809                 :           0 :          'Action: set nshift 1 and shiftk 0 0 0'
    3810                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    3811                 :             :      end if
    3812         [ -  + ]:           2 :      if (dt%nshiftk > 1) then
    3813                 :           0 :        ABI_ERROR_NOSTOP('prtfsurf does not work with multiple kpt shifts ', ierr)
    3814                 :             :      end if
    3815   [ +  +  +  +  :          10 :      if (sum(abs(dt%shiftk(:,1:dt%nshiftk))) > tol8) then
                   -  + ]
    3816                 :           0 :        write(msg,'(4a)')ch10,&
    3817                 :           0 :         'prtfsurf does not work with non-zero k-shifts ',ch10,&
    3818                 :           0 :         'Action: set nshift 1 and shiftk 0 0 0'
    3819                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    3820                 :             :      end if
    3821                 :             : 
    3822                 :             : !    Occcupations, Fermi level and k weights have to be calculated correctly.
    3823         [ -  + ]:           2 :      if (.not.(dt%iscf>1.or.dt%iscf==-3)) then
    3824                 :           0 :        write(msg,'(4a)')ch10,&
    3825                 :           0 :         'prtfsurf==1 requires either iscf>1 or iscf==-3 ',ch10,&
    3826                 :           0 :         'Action: change iscf in the input file. '
    3827                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    3828                 :             :      end if
    3829                 :             : 
    3830                 :             : !    Make sure all nband are equal (well it is always enforced for metals)
    3831   [ +  +  +  +  :         160 :      if (any(dt%nband(1:nkpt*nsppol) /= maxval(dt%nband(1:nkpt*nsppol)) )) then
             +  -  -  + ]
    3832                 :             :        write(msg,'(3a)')&
    3833                 :           0 :         'The number of bands has to be constant for the output of the Fermi surface.',ch10,&
    3834                 :           0 :         'Action: set all the nbands to the same value in your input file'
    3835                 :           0 :        ABI_ERROR_NOSTOP(msg,ierr)
    3836                 :             :      end if
    3837                 :             :    end if ! prtfsurf==1
    3838                 :             : 
    3839                 :             : !  prtgden
    3840                 :        6983 :    call chkint(0,0,cond_string,cond_values,ierr,'prtgden',dt%prtgden,1,(/0/),1,0,iout)
    3841         [ +  + ]:        6983 :    if(optdriver/=RUNL_GSTATE)then
    3842                 :        1322 :      cond_string(1)='optdriver' ; cond_values(1)=optdriver
    3843                 :        1322 :      call chkint(0,1,cond_string,cond_values,ierr,'prtgden',dt%prtgden,1,(/0/),0,0,iout)
    3844                 :             :    end if
    3845         [ +  + ]:        6983 :    if(usepaw/=0)then
    3846                 :        1205 :      cond_string(1)='usepaw' ; cond_values(1)=usepaw
    3847                 :        1205 :      call chkint(0,1,cond_string,cond_values,ierr,'prtgden',dt%prtgden,1,(/0/),0,0,iout)
    3848                 :             :    end if
    3849                 :             : 
    3850                 :             : !  prtkden
    3851                 :             :    ! call chkint_ge(0,0,cond_string,cond_values,ierr,'prtkden',dt%prtkden,0,iout)
    3852                 :             :    ! if(optdriver/=RUNL_GSTATE)then
    3853                 :             :    !   cond_string(1)='optdriver' ; cond_values(1)=optdriver
    3854                 :             :    !   call chkint_eq(0,1,cond_string,cond_values,ierr,'prtkden',dt%prtkden,1,(/0/),iout)
    3855                 :             :    !end if
    3856                 :             :    !if(usepaw/=0)then
    3857                 :             :    !  cond_string(1)='usepaw' ; cond_values(1)=usepaw
    3858                 :             :    !  call chkint_eq(0,1,cond_string,cond_values,ierr,'prtkden',dt%prtkden,1,(/0/),iout)
    3859                 :             :    !end if
    3860                 :             : 
    3861                 :             : !  prtlden
    3862                 :        6983 :    call chkint(0,0,cond_string,cond_values,ierr,'prtlden',dt%prtlden,1,(/0/),1,0,iout)
    3863         [ +  + ]:        6983 :    if(optdriver/=RUNL_GSTATE)then
    3864                 :        1322 :      cond_string(1)='optdriver' ; cond_values(1)=optdriver
    3865                 :        1322 :      call chkint(0,1,cond_string,cond_values,ierr,'prtlden',dt%prtlden,1,(/0/),0,0,iout)
    3866                 :             :    end if
    3867                 :             :    !if(usepaw/=0)then
    3868                 :             :    !  cond_string(1)='usepaw' ; cond_values(1)=usepaw
    3869                 :             :    !  call chkint(0,1,cond_string,cond_values,ierr,'prtlden',dt%prtlden,1,(/0/),0,0,iout)
    3870                 :             :    !end if
    3871                 :             : 
    3872                 :             : !  prt1mag
    3873                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'prt1mag',dt%prt1mag,3,(/0,1,2/),iout)
    3874                 :             : 
    3875                 :             : !  prtstm
    3876                 :        6983 :    call chkint_le(0,0,cond_string,cond_values,ierr,'prtstm',dt%prtstm,1,iout)
    3877                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'prtstm',dt%prtstm,-dt%mband,iout)
    3878         [ +  + ]:        6983 :    if(optdriver/=RUNL_GSTATE)then
    3879                 :        1322 :      cond_string(1)='optdriver' ; cond_values(1)=optdriver
    3880                 :        1322 :      call chkint_eq(0,1,cond_string,cond_values,ierr,'prtstm',dt%prtstm,1,(/0/),iout)
    3881                 :             :    end if
    3882         [ +  + ]:        6983 :    if(dt%occopt/=7)then
    3883                 :        5076 :      cond_string(1)='occopt' ; cond_values(1)=dt%occopt
    3884                 :        5076 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtstm',dt%prtstm,1,(/0/),iout)
    3885                 :             :    end if
    3886         [ +  + ]:        6983 :    if(dt%nstep/=1)then
    3887                 :        4824 :      cond_string(1)='nstep' ; cond_values(1)=dt%nstep
    3888                 :        4824 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtstm',dt%prtstm,1,(/0/),iout)
    3889                 :             :    end if
    3890         [ +  + ]:        6983 :    if(dt%ionmov/=0)then
    3891                 :         327 :      cond_string(1)='ionmov' ; cond_values(1)=dt%ionmov
    3892                 :         327 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtstm',dt%prtstm,1,(/0/),iout)
    3893                 :             :    end if
    3894                 :             : !  tolwfr must be 0 to make a problem (another tol variable is used). Here, check that it is very very small.
    3895         [ +  + ]:        6983 :    if(abs(dt%tolwfr)<tol16*tol16)then
    3896                 :        4880 :      cond_string(1)='prtstm' ; cond_values(1)=dt%prtstm
    3897                 :        4880 :      call chkdpr(1,1,cond_string,cond_values,ierr,'tolwfr',dt%tolwfr,1,tol16*tol16,iout)
    3898                 :             :    end if
    3899         [ +  + ]:        6983 :    if(dt%prtden/=0)then
    3900                 :        5960 :      cond_string(1)='prtden' ; cond_values(1)=dt%prtden
    3901                 :        5960 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtstm',dt%prtstm,1,(/0/),iout)
    3902                 :             :    end if
    3903                 :             : 
    3904                 :             : !  prtnabla
    3905         [ +  + ]:        6983 :    if(dt%prtnabla>0)then
    3906                 :          52 :      cond_string(1)='prtnabla' ; cond_values(1)=dt%prtnabla
    3907                 :          52 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtstm',dt%prtstm,1,(/0/),iout)
    3908   [ -  +  -  -  :          52 :      if(dt%npspinor>1.and.(dt%prtnabla==1.or.dt%prtnabla==2).and.dt%pawspnorb==1)then
                   -  - ]
    3909                 :           0 :        msg='Parallelization over spinorial components not allowed with prtnabla=(1 or 2) and SOC!'
    3910                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    3911                 :             :      end if
    3912                 :             :    end if
    3913                 :             : 
    3914         [ +  + ]:        6983 :    if(dt%prtvxc>0)then
    3915                 :          58 :      cond_string(1)='prtvxc' ; cond_values(1)=dt%prtvxc
    3916                 :          58 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtstm',dt%prtstm,1,(/0/),iout)
    3917                 :             :    end if
    3918         [ +  + ]:        6983 :    if(dt%prtvha>0)then
    3919                 :          61 :      cond_string(1)='prtvha' ; cond_values(1)=dt%prtvha
    3920                 :          61 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtstm',dt%prtstm,1,(/0/),iout)
    3921                 :             :    end if
    3922         [ +  + ]:        6983 :    if(dt%prtvhxc>0)then
    3923                 :          60 :      cond_string(1)='prtvhxc' ; cond_values(1)=dt%prtvhxc
    3924                 :          60 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtstm',dt%prtstm,1,(/0/),iout)
    3925                 :             :    end if
    3926                 :             : 
    3927                 :             : !  prtvclmb - needs prtvha as well
    3928         [ +  + ]:        6983 :    if(dt%prtvclmb > 0)then
    3929                 :          59 :      cond_string(1)='prtvclmb' ; cond_values(1)=dt%prtvclmb
    3930                 :          59 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtvha',dt%prtvha,1,(/1/),iout)
    3931                 :             :    end if
    3932                 :             : 
    3933                 :             : !  prtvolimg
    3934                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'prtvolimg',dt%prtvolimg,3,(/0,1,2/),iout)
    3935                 :             : 
    3936                 :             : !  prtwant
    3937         [ +  + ]:        6983 :    if (dt%prtwant/=0) then
    3938                 :          17 :      cond_string(1)='prtwant' ; cond_values(1)=dt%prtwant
    3939                 :             :      ! wannier function output is not available with paral_kgb algorithm
    3940                 :          17 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'paral_kgb',dt%paral_kgb,1,(/0/),iout)
    3941                 :             :      ! wannier function output is not available with PAW
    3942   [ +  +  -  + ]:          17 :      if (usepaw == 1 .and. dt%wfk_task == WFK_TASK_WANNIER) then
    3943                 :             :        write(msg, '(a,a,a)' )&
    3944                 :           0 :         ' prtwant does not function with PAW and wfk_task = wannier',ch10,&
    3945                 :           0 :         ' Action: use norm conserving pseudopotentials'
    3946                 :           0 :        ABI_ERROR(msg)
    3947                 :             :      end if
    3948                 :             :    end if
    3949                 :             : #if !defined HAVE_WANNIER90
    3950                 :             :    if(dt%prtwant==2) then
    3951                 :             :      write(msg, '(a,a,a)' )&
    3952                 :             :      ' prtwant==2 is only relevant if wannier90 library is linked',ch10,&
    3953                 :             :      ' Action: check compilation options'
    3954                 :             :      ABI_ERROR_NOSTOP(msg,ierr)
    3955                 :             :    end if
    3956                 :             : #endif
    3957                 :             : 
    3958                 :             : !  prtwf
    3959                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'prtwf',dt%prtwf,5,[-1,0,1,2,3],iout)
    3960                 :             : 
    3961   [ +  +  -  + ]:        6983 :    if (dt%prtkbff == 1 .and. dt%useylm /= 0) then
    3962                 :           0 :      ABI_ERROR_NOSTOP("prtkbff == 1 requires useylm == 0", ierr)
    3963                 :             :    end if
    3964                 :             : 
    3965                 :             : !  prtwf_full
    3966                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'prtwf_full',dt%prtwf_full,2,[0,1],iout)
    3967         [ +  + ]:        6983 :    if (dt%prtwf==0) then
    3968                 :        1004 :      cond_string(1)='prtwf' ; cond_values(1)=dt%prtwf
    3969                 :        1004 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtwf_full',dt%prtwf_full,1,(/0/),iout)
    3970                 :             :    end if
    3971                 :             : 
    3972                 :             : !  pulayhiststore
    3973                 :             :    call chkint_eq(0,0,cond_string,cond_values,ierr,'pulayhiststore', &
    3974                 :        6983 : &    dt%pulayhiststore,2,(/0,1/),iout)
    3975                 :             : 
    3976                 :             : !  random_atpos
    3977                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'random_atpos',dt%random_atpos,5,(/0,1,2,3,4/),iout)
    3978                 :             : 
    3979                 :             : !  ratopt
    3980                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'ratopt',dt%ratopt,2,(/1,2/),iout)
    3981                 :             : 
    3982                 :             : !  ratsph
    3983                 :             : !  If PAW and (prtdos==3 or dt%prtdensph==1), must be greater than PAW radius
    3984   [ +  +  +  +  :        6983 :    if(usepaw==1.and.(dt%prtdos==3.or.dt%prtdensph==1))then
                   -  + ]
    3985         [ +  + ]:        3023 :      do itypat=1,dt%ntypat
    3986         [ -  + ]:        8801 :        if (pspheads(itypat)%pawheader%rpaw>dt%ratsph(itypat)) then
    3987                 :             :          write(msg, '(7a,i2,a,f15.12,3a)' )&
    3988                 :           0 :          'Projected DOS/density is required in the framework of PAW !',ch10,&
    3989                 :           0 :          'The radius of spheres in which DOS/density has to be projected',ch10,&
    3990                 :           0 :          'must be greater or equal than the (max.) PAW radius !',ch10,&
    3991                 :           0 :          'Rpaw(atom_type ',itypat,')= ',pspheads(itypat)%pawheader%rpaw,' au',ch10,&
    3992                 :           0 :          'Action: modify value of ratsph in input file.'
    3993                 :           0 :          ABI_ERROR_NOSTOP(msg, ierr)
    3994                 :             :        end if
    3995                 :             :      end do
    3996                 :             :    end if
    3997                 :             : 
    3998                 :             : !  rcpaw_frocc
    3999                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'rcpaw_frocc',dt%rcpaw_frocc,2,(/0,1/),iout)
    4000                 :             : 
    4001                 :             : !  rcpaw_rctypat
    4002         [ +  + ]:       15610 :    do itypat=1,dt%ntypat
    4003                 :       15610 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'rcpaw_rctypat',dt%rcpaw_rctypat(itypat),2,(/0,1/),iout)
    4004                 :             :    enddo
    4005                 :             : 
    4006                 :             : !  recgratio
    4007         [ +  + ]:        6983 :    if (dt%tfkinfunc==2) then
    4008                 :           6 :      write(msg, '(a,a)' ) ch10,'=== RECURSION METHOD ==========================================================='
    4009                 :           6 :      call wrtout(ab_out,msg)
    4010                 :           6 :      cond_string(1)='tfkinfunc' ; cond_values(1)=dt%tfkinfunc
    4011                 :           6 :      call chkint_ge(0,1,cond_string,cond_values,ierr,'recgratio',dt%recgratio,1,iout)
    4012         [ +  + ]:           6 :      if(dt%recgratio>1) then
    4013                 :           1 :        write(msg, '(a,a)' )'=== Coarse Grid is used in recursion ==========================================='
    4014                 :           1 :        call wrtout(ab_out,msg)
    4015                 :           1 :        write(msg, '(a,i3,a,a,i3,a,i3,a,i3)' ) 'grid ratio =',dt%recgratio,&
    4016                 :           2 :         ch10,'fine grid =   ',dt%ngfft(1),' ',dt%ngfft(2),' ',dt%ngfft(3)
    4017                 :           1 :        call wrtout(ab_out,msg)
    4018                 :           1 :        write(msg, '(a,i2,a,i2,a,i2)' ) 'coarse grid = ',&
    4019                 :           2 :         dt%ngfft(1)/dt%recgratio,' ',dt%ngfft(2)/dt%recgratio,' ',dt%ngfft(3)/dt%recgratio
    4020                 :           1 :        call wrtout(ab_out,msg)
    4021                 :             :      else
    4022                 :           5 :        write(msg, '(a,i2,a,i2,a,i2)' ) 'fine grid =   ',dt%ngfft(1),' ',dt%ngfft(2),' ',dt%ngfft(3)
    4023                 :           5 :        call wrtout(ab_out,msg)
    4024                 :             :      end if
    4025                 :             :    end if
    4026                 :             : 
    4027                 :             : !  restartxf
    4028                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'restartxf',dt%restartxf,4,(/0,-1,-2,-3/),iout)
    4029                 :             : 
    4030                 :             : !  rfatpol
    4031                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'rfatpol(1)',dt%rfatpol(1),1,iout)
    4032                 :        6983 :    cond_string(1)='natom' ; cond_values(1)=natom
    4033                 :        6983 :    call chkint_le(1,1,cond_string,cond_values,ierr,'rfatpol(2)',dt%rfatpol(2),natom,iout)
    4034                 :             : 
    4035                 :             : !  rfmeth
    4036                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'rfmeth',dt%rfmeth,6,(/-3,-2,-1,1,2,3/),iout)
    4037                 :             : 
    4038                 :             : !  rfomega
    4039         [ +  + ]:        6983 :    if(dt%rfomega/=zero)then
    4040                 :           2 :      cond_string(1)='rfomega' ; cond_values(1)=dt%rfomega
    4041                 :           2 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'tim1rev',dt%tim1rev,1,(/0/),iout)
    4042                 :             :    end if
    4043                 :             : 
    4044                 :             : !  rfeta
    4045         [ -  + ]:        6983 :    if(dt%rfeta/=zero)then
    4046                 :           0 :      cond_string(1)='rfeta' ; cond_values(1)=dt%rfeta
    4047                 :           0 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'tim1rev',dt%tim1rev,1,(/0/),iout)
    4048                 :             :    end if
    4049                 :             : 
    4050                 :             : !  rprimd
    4051                 :             : !  With optcell beyond 4, one has constraints on rprimd.
    4052                 :        6983 :    cond_string(1)='optcell' ; cond_values(1)=dt%optcell
    4053         [ +  + ]:        6983 :    if( dt%optcell==7 )then
    4054                 :           1 :      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd(1,2)',rprimd(1,2),0,0.0_dp,iout)
    4055                 :           1 :      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd(1,3)',rprimd(1,3),0,0.0_dp,iout)
    4056                 :           1 :      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd(2,1)',rprimd(2,1),0,0.0_dp,iout)
    4057                 :           1 :      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd(3,1)',rprimd(3,1),0,0.0_dp,iout)
    4058         [ -  + ]:        6982 :    else if( dt%optcell==8 )then
    4059                 :           0 :      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd(2,1)',rprimd(2,1),0,0.0_dp,iout)
    4060                 :           0 :      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd(2,3)',rprimd(2,3),0,0.0_dp,iout)
    4061                 :           0 :      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd(1,2)',rprimd(1,2),0,0.0_dp,iout)
    4062                 :           0 :      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd(3,2)',rprimd(3,2),0,0.0_dp,iout)
    4063         [ +  + ]:        6982 :    else if( dt%optcell==9 )then
    4064                 :           1 :      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd(3,1)',rprimd(3,1),0,0.0_dp,iout)
    4065                 :           1 :      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd(3,2)',rprimd(3,2),0,0.0_dp,iout)
    4066                 :           1 :      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd(1,3)',rprimd(1,3),0,0.0_dp,iout)
    4067                 :           1 :      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd(2,3)',rprimd(2,3),0,0.0_dp,iout)
    4068                 :             :    end if
    4069                 :             : 
    4070         [ +  + ]:        6983 :    if (dt%rmm_diis /= 0) then
    4071                 :             :      ! Check for calculations that are not implemented with RMM-DIIS
    4072         [ -  + ]:          30 :      ABI_CHECK(dt%usefock == 0, "RMM-DIIS with Hartree-Fock or Hybrid Functionals is not implemented")
    4073         [ -  + ]:          30 :      ABI_CHECK(dt%wfoptalg /= 1, "RMM-DIIS with Chebyshev is not supported.")
    4074                 :             :      !ABI_CHECK(dt%gpu_option == ABI_GPU_DISABLED, "RMM-DIIS does not support GPUs.")
    4075   [ +  +  +  - ]:         210 :      berryflag = any(dt%berryopt == [4, 14, 6, 16, 7, 17])
    4076         [ -  + ]:          30 :      ABI_CHECK(.not. berryflag, "RMM-DIIS with Electric field is not supported.")
    4077                 :             :    end if
    4078                 :             : 
    4079                 :             : !  so_psp
    4080         [ +  + ]:        6983 :    if(usepaw==0)then
    4081         [ +  + ]:       12607 :      do ipsp=1,npsp
    4082                 :             :        ! Check that so_psp is between 0 and 3
    4083         [ -  + ]:        6829 :        if ( dt%so_psp(ipsp)<0 .or. dt%so_psp(ipsp)>3 ) then
    4084                 :             :          write(msg, '(a,i3,a,i3,a,a,a,a,a)' )&
    4085                 :           0 :          'so_psp(',ipsp,' ) was input as ',dt%so_psp(ipsp),' .',ch10,&
    4086                 :           0 :          'Input value must be 0, 1, 2, or 3.',ch10,&
    4087                 :           0 :          'Action: modify value of so_psp (old name: so_typat) in input file.'
    4088                 :           0 :          ABI_ERROR_NOSTOP(msg, ierr)
    4089                 :             :        end if
    4090                 :             :        ! If nspinor=1, the spin-orbit contribution cannot be taken into account
    4091   [ +  +  -  + ]:        6829 :        if ( nspinor==1 .and. (dt%so_psp(ipsp)==2 .or. dt%so_psp(ipsp)==3) ) then
    4092                 :             :          write(msg, '(a,i2,a,i3,a,a,a,a,a)' )&
    4093                 :           0 :          'so_psp(',ipsp,') was input as ',dt%so_psp(ipsp),', with nspinor=1 and usepaw=0.',ch10,&
    4094                 :           0 :          'When nspinor=1, so_psp cannot be required to be 2 or 3.',ch10,&
    4095                 :           0 :          'Action: modify value of so_psp (old name: so_typat) or nspinor in input file.'
    4096                 :           0 :          ABI_ERROR_NOSTOP(msg, ierr)
    4097                 :             :        end if
    4098                 :             :        ! If nspinor=2, the spin-orbit contribution should be present in the pseudopotentials,
    4099                 :             :        ! unless the user explicitly allows not to treat it.
    4100   [ +  +  +  +  :       12607 :        if ( nspinor==2 .and. dt%so_psp(ipsp)/=0 .and. pspheads(ipsp)%pspso==0 ) then
                   -  + ]
    4101                 :             :          write(msg, '(2(a,i0),9a)' )&
    4102                 :           0 :          'so_psp(',ipsp,') was input as ',dt%so_psp(ipsp),', with nspinor=2 and usepaw=0.',ch10,&
    4103                 :           0 :          'This requires a treatment of the spin-orbit interaction. However, it has been detected ',ch10,&
    4104                 :           0 :          'that the pseudopotential that you want to use does not specify the spin-orbit coupling.',ch10,&
    4105                 :           0 :          'Action: choose a pseudopotential that contains information about the spin-orbit interaction,',ch10,&
    4106                 :           0 :          'or deliberately switch off the spin-orbit interaction by setting so_psp=0 for that pseudopotential in the input file.'
    4107                 :           0 :          ABI_ERROR_NOSTOP(msg, ierr)
    4108                 :             :        end if
    4109                 :             :      end do ! ipsp
    4110                 :             :    end if ! usepaw==0
    4111                 :             : 
    4112                 :             : !  spinat
    4113                 :             : !  Not allowed with nspden=1 (PAW)
    4114                 :             :    !if(any(abs(dt%spinat)>tol8).and.nspden==1.and.usepaw==1) then
    4115                 :             :    !  write(msg, '(3a)' )&
    4116                 :             :    !   'A spinat/=0 is not allowed when magnetization is forced to zero (nspden=1)!',ch10,&
    4117                 :             :    !   'Action: re-run with spinat zero '
    4118                 :             :    !  ABI_ERROR_NOSTOP(msg, ierr)
    4119                 :             :    !end if
    4120                 :             : 
    4121                 :             : !  prevent the running if the spinat is not 0 0 0 when nspden=1 nsppol=1
    4122   [ +  +  +  +  :      138112 :   if(any(abs(dt%spinat)>tol8).and.nspden==1.and.nsppol==1) then
          +  +  +  +  -  
                +  -  - ]
    4123                 :             :     write(msg, '(3a)')&
    4124                 :           0 :       'A spinat/=0 is not allowed when nspden=1 and nsppol=1!',ch10,&
    4125                 :           0 :       'Action: re-run with spinat zero '
    4126                 :           0 :     ABI_ERROR_NOSTOP(msg,ierr)
    4127                 :             :   end if
    4128                 :             : 
    4129                 :             : !  spinaxis: only avaliable for SOC/cDFT/hspinfield
    4130         [ +  + ]:       27932 :   norm_spinaxis = sqrt(dot_product(dt%spinaxis, dt%spinaxis))
    4131         [ -  + ]:        6983 :   ABI_CHECK_NOSTOP(norm_spinaxis > tol8, 'Spinaxis must be a non-zero vector', ierr)
    4132         [ +  + ]:        6983 :   if (dt%nspden == 2) then
    4133         [ +  + ]:       20046 :     do iatom = 1, dt%natom
    4134                 :             :       ! use Cartesian spinat for consistency with spinaxis
    4135         [ +  + ]:       73028 :       norm_spinat = sqrt(dot_product(dt%spinat_cart(:,iatom),dt%spinat_cart(:,iatom)))
    4136         [ +  + ]:       18257 :       if (norm_spinat < tol8) cycle
    4137         [ +  + ]:       70604 :       dotval = dot_product(dt%spinat_cart(:,iatom), dt%spinaxis)
    4138         [ -  + ]:       19440 :       if (abs(abs(dotval) - norm_spinat*norm_spinaxis) > tol8*norm_spinat*norm_spinaxis) then
    4139                 :             :         write(msg, '(3a)')&
    4140                 :           0 :          'In collinear (nspden=2) calculation, spinat (Cartesian) must be parallel to spin quantization axis',ch10,&
    4141                 :           0 :          'Action: modify spinat(_cart) or spinaxis in your input file '
    4142                 :           0 :         ABI_ERROR_NOSTOP(msg,ierr)
    4143                 :             :       end if
    4144                 :             :     end do
    4145                 :             :   end if
    4146                 :             : 
    4147         [ +  + ]:        6983 :   if (dt%spinaxis(1)**2 + dt%spinaxis(2)**2 > tol8*tol8 ) then
    4148                 :             :     if(all(dt%so_psp(1:dt%ntypat)/=1) .and. &
    4149   [ +  -  -  +  :           6 :         all(abs(dt%hspinfield(:))<tol8) .and. &
          +  +  +  -  +  
          +  +  -  -  +  
                   -  - ]
    4150                 :             :         all(dt%constraint_kind(1:dt%ntypat)==0)) then
    4151                 :           0 :         ABI_WARNING("Spinaxis is defined but no SOC, hspinfield or cDFT is active. spinaxis will not affect the calculation.")
    4152                 :             :      end if
    4153                 :             :    end if
    4154                 :             : 
    4155                 :             : !  spinmagntarget
    4156   [ +  +  +  + ]:        6983 :    if(abs(dt%spinmagntarget+99.99d0)>tol8 .and. abs(dt%spinmagntarget)>tol8)then
    4157         [ -  + ]:          26 :      if(nsppol==1)then
    4158                 :             :        write(msg, '(a,f8.2,4a)' )&
    4159                 :           0 :        'spinmagntarget was input as ',dt%spinmagntarget,ch10,&
    4160                 :           0 :        'When nsppol=1, spinmagntarget is required to be 0.0d0 or the default value.',ch10,&
    4161                 :           0 :        'Action: modify value spinmagntarget or nsppol in input file.'
    4162                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    4163                 :             :      end if
    4164         [ -  + ]:          26 :      if(optdriver==RUNL_RESPFN)then
    4165                 :             :        write(msg, '(a,f8.2,8a)' )&
    4166                 :           0 :        'spinmagntarget was input as ',dt%spinmagntarget,ch10,&
    4167                 :           0 :        'For a response function run, spinmagntarget is required to be 0.0d0 or the default value.',ch10,&
    4168                 :           0 :        'A spin-polarized response function calculation for a ferromagnetic insulator needs occopt=0, 1 or 2',ch10,&
    4169                 :           0 :        'the default value of spinmagntarget, and explicit definition of occ. ',ch10,&
    4170                 :           0 :        'Action: modify spinmagntarget, occopt or nsppol in your input file.'
    4171                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    4172                 :             :      end if
    4173         [ -  + ]:          26 :      if(dt%prtdos==1)then
    4174                 :             :        write(msg, '(a,f8.2,8a)' )&
    4175                 :           0 :        'spinmagntarget was input as ',dt%spinmagntarget,ch10,&
    4176                 :           0 :        'When prtdos==1, spinmagntarget is required to be 0.0d0 or the default value.',ch10,&
    4177                 :           0 :        'A spin-polarized DOS calculation for a ferromagnetic insulator needs occopt=0, 1 or 2',ch10,&
    4178                 :           0 :        'the default value of spinmagntarget, and explicit definition of occ.',ch10,&
    4179                 :           0 :        'Action: modify spinmagntarget, occopt or nsppol in your input file.'
    4180                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    4181                 :             :      end if
    4182                 :             :    end if
    4183                 :             : !  If nsppol==2 and spinmagntarget==0.0 , suggest to use anti-ferromagnetic capability of ABINIT.
    4184   [ +  +  +  + ]:        6983 :    if(nsppol==2.and.abs(dt%spinmagntarget)<tol8)then
    4185                 :             :      write(msg,'(a,i3,2a,f7.2,6a)' )&
    4186                 :         123 :      ' This is a calculation with spin-up and spin-down wavefunctions,         ... nsppol=',nsppol,ch10,&
    4187                 :         123 :      ' in which the target spin-polarization is zero.                  ... spinmagntarget=',dt%spinmagntarget,ch10,&
    4188                 :         123 :      ' Tip ... It might be possible that the ground state is either non-spin-polarized, or antiferromagnetic.',ch10,&
    4189                 :         123 :      ' In the former case, it is advantageous to use nsppol=1 and nspden=1,',ch10,&
    4190                 :         246 :      ' while in the latter  case, it is advantageous to use nsppol=1 and nspden=2.'
    4191                 :         123 :      call wrtout(iout,msg)
    4192                 :             :    end if
    4193                 :             : 
    4194                 :             : !  stmbias
    4195                 :        6983 :    cond_string(1)='prtstm' ; cond_values(1)=dt%prtstm
    4196         [ +  + ]:        6983 :    if(dt%prtstm/=0)then
    4197                 :             : !    If non-zero prtstm, stmbias cannot be zero: test is positive or zero
    4198         [ +  + ]:           3 :      if(dt%stmbias>-tol10)then
    4199                 :             : !      Then, enforce positive
    4200                 :           2 :        call chkdpr(1,1,cond_string,cond_values,ierr,'stmbias',dt%stmbias,1,2*tol10,iout)
    4201                 :             :      end if
    4202                 :             :    else
    4203                 :        6980 :      call chkdpr(1,1,cond_string,cond_values,ierr,'stmbias',dt%stmbias,0,zero,iout)
    4204                 :             :    end if
    4205                 :             : 
    4206                 :             : !  string_algo
    4207                 :             :    call chkint_eq(0,0,cond_string,cond_values,ierr,'string_algo',dt%string_algo,&
    4208         [ +  + ]:       20949 :      2, [STRING_ALGO_SIMPLIFIED_EQUAL,STRING_ALGO_SIMPLIFIED_ENERGY],iout)
    4209                 :             : 
    4210                 :             : !  symafm
    4211   [ +  +  +  + ]:        6983 :    if(nsppol==1 .and. nspden==2)then
    4212                 :             : !    At least one of the symmetry operations must be antiferromagnetic
    4213   [ +  +  -  + ]:        1045 :      if(minval(dt%symafm(1:dt%nsym))/=-1)then
    4214                 :             :        write(msg, '(5a)' )&
    4215                 :           0 :        'When nsppol==1 and nspden==2, at least one of the symmetry operations',ch10,&
    4216                 :           0 :        'must be anti-ferromagnetic (symafm=-1), in order to deduce the spin-down density',ch10,&
    4217                 :           0 :        'from the spin-up density.'
    4218                 :           0 :        call wrtout(iout,msg)
    4219                 :           0 :        call wrtout(std_out,  msg)
    4220                 :             :        write(msg, '(7a)' ) &
    4221                 :           0 :        'However, it is observed that none of the symmetry operations is anti-ferromagnetic.',ch10,&
    4222                 :           0 :        'Action: Check the atomic positions, the input variables spinat, symrel, tnons, symafm.',ch10,&
    4223                 :           0 :        '        In case your system is not antiferromagnetic (it might be ferrimagnetic ...),',ch10,&
    4224                 :           0 :        '        you must use nsppol=2 with nspden=2 (the latter being the default when nsppol=2).'
    4225                 :           0 :        ABI_ERROR_NOSTOP(msg,ierr)
    4226                 :             :      end if
    4227                 :             :    end if
    4228                 :             : 
    4229                 :             : !  symrel and tnons
    4230                 :             : !  Check the point group closure
    4231                 :        6983 :    call sg_multable(dt%nsym,dt%symafm,dt%symrel,ierrgrp, tnons=dt%tnons, tnons_tol=tol5)
    4232         [ -  + ]:        6983 :    if (ierrgrp==1) ierr=ierr+1
    4233                 :             : 
    4234                 :             : !  Check the orthogonality of the symmetry operations
    4235                 :             : !  (lengths and absolute values of scalar products should be preserved)
    4236                 :        6983 :    iexit=0
    4237                 :             : 
    4238                 :        6983 :    call chkorthsy(gprimd,iexit,dt%nsym,rmet,rprimd,dt%symrel,tol8)
    4239                 :             : 
    4240                 :             : !  symchi
    4241         [ -  + ]:        6983 :    if (all(dt%symchi /= [0, 1])) then
    4242                 :           0 :      write(msg, '(a,i0,2a)' )'symchi was input as ',dt%symchi,ch10,'Input value must be 0, 1.'
    4243                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    4244                 :             :    end if
    4245                 :             : 
    4246                 :             : !  symsigma
    4247         [ -  + ]:        6983 :    if (all(dt%symsigma /= [0, 1, -1])) then
    4248                 :             :      write(msg, '(a,i0,4a)' )&
    4249                 :           0 :       'symsigma was input as ',dt%symsigma,ch10,&
    4250                 :           0 :       'Input value must be 0, 1, or -1.',ch10,&
    4251                 :           0 :       'Action: modify value of symsigma in input file.'
    4252                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    4253                 :             :    end if
    4254                 :             : 
    4255                 :             : !  MG now it is possible to perform a GW calculation with non-symmorphic operations if required by the user
    4256                 :             : !  tnons
    4257         [ +  + ]:        6983 :    if (dt%symmorphi==0) then
    4258         [ -  + ]:         101 :      if(dt%nbandkss/=0)then
    4259         [ #  # ]:           0 :        do isym=1,dt%nsym
    4260   [ #  #  #  # ]:           0 :          if(sum(dt%tnons(:,isym)**2)>tol6)then
    4261                 :             :            write(msg, '(3a,i3,a,3f8.4,3a)' )&
    4262                 :           0 :            'When nbandkss/=0, all the components of tnons must be zero.',ch10,&
    4263                 :           0 :            'However, for the symmetry operation number ',isym,', tnons =',dt%tnons(:,isym),'.',ch10,&
    4264                 :           0 :            'Action: use the symmetry finder (nsym=0) with symmorphi==0.'
    4265                 :           0 :            ABI_ERROR_NOSTOP(msg,ierr)
    4266                 :             :          end if
    4267                 :             :        end do
    4268                 :             :      end if
    4269         [ +  + ]:         101 :      if (ANY(optdriver == [RUNL_SCREENING, RUNL_SIGMA])) then
    4270         [ +  + ]:         331 :        do isym=1,dt%nsym
    4271   [ +  +  -  + ]:        1279 :          if (sum(dt%tnons(:,isym)**2)>tol6) then
    4272                 :             :            write(msg,'(3a,i3,a,3f8.4,3a)')&
    4273                 :           0 :            'When optdriver==RUNL_SCREENING or RUNL_SIGMA, all the components of tnons must be zero.',ch10,&
    4274                 :           0 :            'However, for the symmetry operation number ',isym,', tnons =',dt%tnons(:,isym),'.',ch10,&
    4275                 :           0 :            'Action: use the symmetry finder (nsym=0) with symmorphi==0.'
    4276                 :           0 :            ABI_ERROR_NOSTOP(msg, ierr)
    4277                 :             :          end if
    4278                 :             :        end do
    4279                 :             :      end if
    4280                 :             :    end if !of symmorphi
    4281                 :             : 
    4282                 :             : !  tfkinfunc
    4283                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'tfwkinfunc',dt%tfkinfunc,5,(/0,1,2,11,12/),iout)
    4284         [ +  + ]:        6983 :    if(dt%ionmov==4)then
    4285                 :           6 :      cond_string(1)='ionmov' ; cond_values(1)=dt%ionmov
    4286                 :           6 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'tkinfunc',dt%tfkinfunc,1,(/0/),iout)
    4287                 :             :    end if
    4288         [ +  + ]:        6983 :    if(dt%tfkinfunc==2)then
    4289                 :           6 :      cond_string(1)='tfkinfunc' ; cond_values(1)=dt%tfkinfunc
    4290                 :           6 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'useylm',dt%useylm,1,(/1/),iout)
    4291                 :           6 :      cond_string(1)='prtwf' ; cond_values(1)=dt%prtwf
    4292                 :           6 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtwf',dt%prtwf,1,(/0/),iout)
    4293                 :             :    end if
    4294                 :             : 
    4295                 :             : !  timdisp
    4296                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'timdisp',dt%timdisp,2,(/0,1/),iout)
    4297         [ +  + ]:        6983 :    if(dt%timdisp/=0)then
    4298                 :           6 :      cond_string(1)='timdisp' ; cond_values(1)=dt%timdisp
    4299                 :           6 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'optdriver',dt%optdriver,1,(/RUNL_LONGWAVE/),iout)
    4300                 :             :    end if
    4301                 :             : 
    4302                 :             : !  tolmxde
    4303                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'tolmxde',dt%tolmxde,1,zero,iout)
    4304                 :             : 
    4305                 :             : !  toldff
    4306                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'toldff',dt%toldff,1,zero,iout)
    4307                 :             : 
    4308                 :             : !  tolimg
    4309                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'tolimg',dt%tolimg,1,zero,iout)
    4310                 :             : 
    4311                 :             : !  tolrde
    4312                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'tolrde',dt%tolrde,1,zero,iout)
    4313                 :             : 
    4314                 :             : !  tolrff
    4315                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'tolrff',dt%tolrff,1,zero,iout)
    4316                 :             : 
    4317                 :             : !  tolwfr
    4318                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'tolwfr',dt%tolwfr,1,zero,iout)
    4319                 :             : 
    4320                 :             : !!  tolwfr
    4321                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'toldmag',dt%tolwfr,1,zero,iout)
    4322                 :             : 
    4323                 :             : !  tsmear
    4324                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'tsmear',dt%tsmear,1,zero,iout)
    4325                 :             : !  Check that tsmear is non-zero positive for metallic occupation functions
    4326         [ +  + ]:        6983 :    if(3<=dt%occopt .and. dt%occopt<=9)then
    4327                 :        2531 :      cond_string(1)='occopt' ; cond_values(1)=dt%occopt
    4328                 :        2531 :      call chkdpr(1,1,cond_string,cond_values,ierr,'tsmear',dt%tsmear,1,tol8,iout)
    4329                 :             :    end if
    4330                 :             : 
    4331                 :             : !  ucrpa
    4332                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'ucrpa',dt%ucrpa,5,(/0,1,2,3,4/),iout)
    4333         [ -  + ]:        6983 :    if (dt%ucrpa>=1) then
    4334                 :           0 :      cond_string(1)='ucrpa' ; cond_values(1)=dt%ucrpa
    4335                 :           0 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'nspinor',dt%nspinor,1,(/1/),iout)
    4336                 :             :    end if
    4337                 :             : 
    4338                 :             : !  usedmatpu
    4339   [ +  +  +  + ]:        6983 :    if (usepaw==1.and.dt%usepawu>0) then
    4340                 :         142 :      cond_string(1)='nstep' ; cond_values(1)=dt%nstep
    4341                 :         142 :      call chkint_le(1,1,cond_string,cond_values,ierr,'abs(usedmatpu)',abs(dt%usedmatpu),dt%nstep,iout)
    4342                 :             : !    lpawu must be constant or -1
    4343         [ +  + ]:         142 :      if (dt%usedmatpu/=0) then
    4344         [ +  + ]:          42 :        do itypat=1,dt%ntypat
    4345   [ +  +  +  +  :          93 :          if (dt%lpawu(itypat)/=-1.and.dt%lpawu(itypat)/=maxval(dt%lpawu(:))) then
                   -  + ]
    4346                 :             :            write(msg, '(3a)' )&
    4347                 :           0 :            'When usedmatpu/=0 (use of an initial density matrix for DFT+U),',ch10,&
    4348                 :           0 :            'lpawu must be equal for all types of atoms on which +U is applied !'
    4349                 :           0 :            ABI_ERROR_NOSTOP(msg,ierr)
    4350                 :             :          end if
    4351                 :             :        end do
    4352                 :             :      end if
    4353                 :             :    end if
    4354                 :             :    !usedmatpu not allowed with experimental usepawu<0
    4355   [ +  +  +  + ]:        6983 :    if (usepaw==1.and.dt%usepawu<0) then
    4356                 :          11 :      cond_string(1)='usepawu' ; cond_values(1)=dt%usepawu
    4357                 :          11 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'usedmatpu',dt%usedmatpu,1,(/0/),iout)
    4358                 :             :    end if
    4359                 :             :    !usedmatpu only allowed for GS
    4360   [ +  +  +  +  :        6983 :    if (usepaw==1.and.dt%usedmatpu/=0.and.dt%optdriver/=RUNL_GSTATE) then
                   -  + ]
    4361                 :           0 :      ABI_ERROR_NOSTOP('usedmatpu/=0 is only allowed for Ground-State calculations!', ierr)
    4362                 :             :    end if
    4363                 :             : 
    4364                 :             : !  usedmft
    4365         [ +  + ]:        6983 :    if (dt%usedmft>0) then
    4366                 :          43 :      cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
    4367                 :          43 :      call chkint_eq(0,1,cond_string,cond_values,ierr,'usedmft',dt%usedmft,3,(/0,1,10/),iout)
    4368         [ +  + ]:          43 :      if (dt%paral_kgb>0) then
    4369                 :           4 :        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
    4370                 :           4 :        call chkint_eq(1,1,cond_string,cond_values,ierr,'npspinor',dt%npspinor,1,(/1/),iout)
    4371                 :             :      end if
    4372                 :             : !    call chkint_eq(1,1,cond_string,cond_values,ierr,'paral_kgb',dt%paral_kgb,1,(/0/),iout)
    4373                 :             :    end if
    4374                 :             : 
    4375                 :             : !  useexexch and lexexch
    4376                 :             : !  Local exact-exchange and restrictions
    4377         [ +  + ]:        6983 :    if(dt%useexexch/=0)then
    4378                 :           1 :      cond_string(1)='useexexch' ; cond_values(1)=dt%useexexch
    4379                 :           1 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'useexexch',dt%useexexch,1,(/1/),iout)
    4380                 :           1 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'usepaw',usepaw,1,(/1/),iout)
    4381                 :           1 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'pawxcdev',dt%pawxcdev,2,(/1,2/),iout)
    4382                 :           1 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'ixc',dt%ixc,2,(/11,23/),iout)
    4383         [ +  + ]:           3 :      do itypat=1,dt%ntypat
    4384                 :           2 :        cond_string(1)='lexexch' ; cond_values(1)=dt%lexexch(itypat)
    4385                 :           3 :        call chkint_eq(1,1,cond_string,cond_values,ierr,'lexexch',dt%lexexch(itypat),5,(/-1,0,1,2,3/),iout)
    4386                 :             :      end do
    4387                 :             :    end if
    4388                 :             : 
    4389                 :             : !  usefock and restrictions
    4390                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'usefock',dt%usefock,2,(/0,1/),iout)
    4391                 :             : 
    4392         [ +  + ]:        6983 :    if (dt%use_gemm_nonlop == 1) then
    4393         [ -  + ]:          29 :      if (dt%useylm /= 1) then
    4394                 :           0 :        ABI_ERROR_NOSTOP('use_gemm_nonlop requires the input variable "useylm" to be 1',ierr)
    4395                 :             :      end if
    4396                 :             :    end if
    4397                 :             : 
    4398                 :             : !  usekden
    4399                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'usekden',dt%usekden,2,(/0,1/),iout)
    4400                 :             : !  The following test is only a way to practically prevent the usage of mGGA with nspden=4 (not allowed yet),
    4401                 :             : !  while allowing to have usekden=1 with nspden=4. Indeed, while mGGA is not allowed for the non-collinear case,
    4402                 :             : !  the computation of the kinetic energy density in the non-collinear spin case is working, and there are tests of this ...
    4403                 :             : !  What should be done: modify the definition of xclevel, to index differently GGAs and mGGAs, etc, and test on xclevel instead of usekden.
    4404   [ +  +  +  + ]:        6983 :    if(dt%nspden==4 .and. dt%prtkden==0)then
    4405                 :         166 :      cond_string(1)='nspden' ; cond_values(1)=dt%nspden
    4406                 :         166 :      cond_string(1)='prtkden' ; cond_values(2)=dt%prtkden
    4407                 :         166 :      call chkint_eq(1,2,cond_string,cond_values,ierr,'usekden',dt%usekden,1,(/0/),iout)
    4408                 :             :    endif
    4409         [ +  + ]:        6983 :    if(dt%usekden==0)then
    4410                 :        6907 :      cond_string(1)='usekden' ; cond_values(1)=dt%usekden
    4411                 :        6907 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtkden',dt%prtkden,1,(/0/),iout)
    4412   [ -  +  -  - ]:        6907 :      if(xc_need_kden.and.dt%usekden<1)then
    4413                 :             :        write(msg, '(3a)' )&
    4414                 :           0 :        'The functional is a MGGA using kinetic energy density, but the kinetic energy density',ch10, &
    4415                 :           0 :        'is not present. Please set "usekden 1" in the input file.'
    4416                 :           0 :        ABI_ERROR(msg)
    4417                 :             :      end if
    4418                 :             :    else if(dt%usekden/=0)then
    4419                 :          76 :      cond_string(1)='usekden' ; cond_values(1)=dt%usekden
    4420                 :          76 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'usewvl',usewvl,1,(/0/),iout)
    4421                 :             : !     call chkint_eq(1,1,cond_string,cond_values,ierr,'usepaw',usepaw,1,(/0/),iout)
    4422                 :          76 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'intxc',dt%intxc,1,(/0/),iout)
    4423         [ +  + ]:         160 :      do ipsp=1,npsp
    4424                 :             : !      Check that xccc is zero (NCPP metaGGAs cannot be used at present with non-linear core corrections)
    4425   [ +  +  +  + ]:         160 :        if (pspheads(ipsp)%xccc/=0.and.usepaw==0) then
    4426                 :             :          write(msg, '(5a,i0,3a)' )&
    4427                 :           5 :           'When usekden/=0, it is not possible to use norm-conserving pseudopotentials',ch10,&
    4428                 :           5 :           'with a non-linear core correction.',ch10,&
    4429                 :           5 :           'However, for pseudopotential number ',ipsp,', there is such a core correction.',ch10,&
    4430                 :          10 :           'Action: either set usekden=0 in input file, or change this pseudopotential file.'
    4431                 :             :          !ABI_ERROR_NOSTOP(msg, ierr)
    4432                 :           5 :          ABI_WARNING(msg)
    4433                 :             :        end if
    4434                 :             :      end do
    4435                 :             :    end if
    4436                 :             : 
    4437                 :             : !  usepawu and lpawu
    4438                 :             : !  PAW+U and restrictions
    4439                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'usepawu',dt%usepawu,11,(/-4,-3,-2,-1,0,1,2,3,4,10,14/),iout)
    4440         [ +  + ]:        6983 :    if(dt%usedmft==1)then
    4441                 :          43 :      cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
    4442                 :          43 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'usepawu',dt%usepawu,2,(/10,14/),iout)
    4443                 :             :    end if
    4444         [ +  + ]:        6983 :    if(dt%usedmft==0)then
    4445                 :        6940 :      cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
    4446                 :        6940 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'usepawu',dt%usepawu,9,(/-4,-3,-2,-1,0,1,2,3,4/),iout)
    4447                 :             :    end if
    4448         [ +  + ]:        6983 :    if(dt%usepawu/=0)then
    4449                 :         153 :      cond_string(1)='usepawu' ; cond_values(1)=dt%usepawu
    4450                 :         153 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'usepaw',dt%usepaw,1,(/1/),iout)
    4451         [ +  + ]:         386 :      do itypat=1,dt%ntypat
    4452                 :         233 :        cond_string(1)='lpawu' ; cond_values(1)=dt%lpawu(itypat)
    4453                 :         386 :        call chkint_eq(1,1,cond_string,cond_values,ierr,'lpawu',dt%lpawu(itypat),5,(/-1,0,1,2,3/),iout)
    4454                 :             :      end do
    4455         [ +  + ]:         153 :      if(dt%pawspnorb>0) then
    4456                 :          26 :        write(msg,'(3a)' ) 'DFT+U+SpinOrbit is still on test ',ch10,'(not yet in production)'
    4457                 :          26 :        ABI_WARNING(msg)
    4458                 :             :      end if
    4459                 :             :    end if
    4460                 :             : 
    4461                 :             : !  usepawu and response: q must be zero
    4462   [ +  +  -  + ]:        6983 :    if(dt%usepawu/=0.and.response==1) then
    4463                 :           0 :      cond_string(1)='usepawu' ; cond_values(1)=dt%usepawu
    4464         [ #  # ]:           0 :      call chkdpr(1,1,cond_string,cond_values,ierr,'norm(qpt)',sum(dt%qptn(:)**2),0,zero,iout)
    4465                 :             :    end if
    4466                 :             : 
    4467                 :             : !  useexexch AND usepawu
    4468                 :             : !  Restriction when use together
    4469   [ +  +  -  + ]:        6983 :    if(dt%useexexch/=0.and.dt%usepawu/=0)then
    4470         [ #  # ]:           0 :      do itypat=1,dt%ntypat
    4471   [ #  #  #  #  :           0 :        if (dt%lpawu(itypat)/=dt%lexexch(itypat).and.dt%lpawu(itypat)/=-1.and.dt%lexexch(itypat)/=-1) then
                   #  # ]
    4472                 :             :          write(msg, '(5a,i2,3a)' )&
    4473                 :           0 :           'When PAW+U (usepawu/=0) and local exact-exchange (useexexch/=0)',ch10,&
    4474                 :           0 :           'are selected together, they must apply on the same',ch10,&
    4475                 :           0 :           'angular momentum (lpawu/=lexexch forbidden, here for typat=',itypat,') !',ch10,&
    4476                 :           0 :           'Action: correct your input file.'
    4477                 :           0 :          ABI_ERROR_NOSTOP(msg,ierr)
    4478                 :             :        end if
    4479                 :             :      end do
    4480                 :             :    end if
    4481                 :             : 
    4482                 :             : !  usedmft/usepawu and lpawu
    4483                 :             : !  Restriction when use together
    4484   [ +  +  +  + ]:        6983 :    if((dt%usedmft>0.and.dt%usedmft/=10).or.dt%usepawu/=0)then
    4485                 :         153 :      nlpawu=0
    4486         [ +  + ]:         386 :      do itypat=1,dt%ntypat
    4487         [ +  + ]:         386 :        if (dt%lpawu(itypat)/=-1) then
    4488                 :         165 :          nlpawu=nlpawu+1
    4489                 :             :        end if
    4490                 :             :      end do
    4491         [ -  + ]:         153 :      if(nlpawu==0) then
    4492                 :             :        write(msg, '(6a)' )&
    4493                 :           0 :         'When DFT+U or DFT+DMFT is used',ch10,&
    4494                 :           0 :         'at least one value of lpawu should be different from -1',ch10,&
    4495                 :           0 :         'Action: correct your input file.'
    4496                 :           0 :        ABI_ERROR(msg)
    4497                 :             :      end if
    4498                 :             :    end if
    4499                 :             : 
    4500                 :             : !  usepotzero
    4501         [ +  + ]:        6983 :    if(dt%usepotzero/=0)then
    4502         [ -  + ]:           2 :      if(dt%iscf<10) then
    4503                 :             :        write(msg, '(3a)' )&
    4504                 :           0 :         'usepotzero can only be used with density mixing (not implemented yet)',ch10,&
    4505                 :           0 :         'Action: choose iscf > 10 '
    4506                 :           0 :        ABI_ERROR_NOSTOP(msg,ierr)
    4507                 :             :      end if
    4508                 :             :    end if
    4509                 :             : 
    4510                 :             : !  use_rcpaw
    4511                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'use_rcpaw',dt%use_rcpaw,2,(/0,1/),iout)
    4512         [ +  + ]:        6983 :    if(dt%use_rcpaw==1) then
    4513                 :             :      if((dt%npfft/=1).or.(dt%occopt<3).or.(dt%occopt>8).or.&
    4514                 :             :         (dt%stmbias/=zero).or.(dt%spinmagntarget/=-99.99_dp).or.&
    4515                 :             :         (dt%usewvl==1).or.(dt%positron/=0).or.(dt%icoulomb/=0).or.(dt%iscf<12).or.&
    4516   [ +  -  +  -  :           3 :         (dt%usepaw/=1).or.(dt%usepawu==1).or.(dt%usedmft==1)) then
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  -  
                      + ]
    4517                 :           0 :        ABI_ERROR('RCPAW: work in progress')
    4518                 :             :      endif
    4519   [ +  +  +  -  :           6 :      if (any(pspheads(1:npsp)%pspcod/=17)) then
                   -  + ]
    4520                 :             :        write(msg, '(5a)' )&
    4521                 :           0 :         'Relaxed-core PAW (use_rcpaw=1) can only be used PAW datasets in XML format.',ch10,&
    4522                 :           0 :         'However one of your PAW atomic dataset is not in PAW-XML format!',ch10,&
    4523                 :           0 :         'Action: change your pseudopotential file to a PAW-XML one '
    4524                 :           0 :        ABI_ERROR_NOSTOP(msg,ierr)
    4525                 :             :      end if
    4526                 :             :    endif
    4527                 :             : 
    4528                 :             : !  usexcnhat
    4529                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'usexcnhat',dt%usexcnhat_orig,3,(/-1,0,1/),iout)
    4530                 :             : 
    4531                 :             : !  useylm
    4532                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'useylm',dt%useylm,2,(/0,1/),iout)
    4533         [ +  + ]:        6983 :    if (usepaw==1) then
    4534                 :        1205 :      cond_string(1)='usepaw' ; cond_values(1)=usepaw
    4535                 :        1205 :      cond_string(2)='usewvl' ; cond_values(2)=usewvl
    4536         [ +  - ]:        1205 :      if(usewvl==0) then
    4537                 :        1205 :        call chkint_eq(1,1,cond_string,cond_values,ierr,'useylm',dt%useylm,1,(/1/),iout)
    4538                 :             :      else
    4539                 :           0 :        call chkint_eq(1,1,cond_string,cond_values,ierr,'useylm',dt%useylm,1,(/0/),iout)
    4540                 :             :      end if
    4541                 :             :    end if
    4542                 :             : 
    4543                 :             : !  use_slk
    4544         [ +  + ]:        6983 :    if (dt%paral_kgb==1) then
    4545                 :         628 :      call chkint_eq(0,0,cond_string,cond_values,ierr,'use_slk',dt%use_slk,2,(/0,1/),iout)
    4546                 :             :    end if
    4547                 :             : 
    4548                 :             : !  use_oldchi
    4549                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'use_oldchi',dt%use_oldchi,2,(/0,1/),iout)
    4550                 :             : 
    4551                 :             : !  vdw_xc
    4552                 :        6983 :    call chkint_eq(0,0,cond_string,cond_values,ierr,'vdw_xc',dt%vdw_xc,9,(/0,1,2,5,6,7,10,11,14/),iout)
    4553   [ +  +  -  +  :        6983 :    if (dt%usepaw==1.and.(.not.(dt%vdw_xc==0.or.dt%vdw_xc==5.or.dt%vdw_xc==6.or.dt%vdw_xc==7))) then
             -  -  -  - ]
    4554                 :           0 :      write(msg,'(a,i2,a)')'vdw_xc=',dt%vdw_xc,' is not yet available with Projector Augmented-Wave (PAW) formalism!'
    4555                 :           0 :      ABI_ERROR_NOSTOP(msg, ierr)
    4556                 :             :    end if
    4557                 :             : 
    4558                 :             : !  vdw DFT-D2
    4559         [ +  + ]:        6983 :    if (dt%vdw_xc==5.or.dt%vdw_xc==6.or.dt%vdw_xc==7) then
    4560                 :             : !    Only for GS or RF calculations
    4561         [ -  + ]:           8 :      if(optdriver/=RUNL_GSTATE.and.optdriver/=RUNL_RESPFN) then
    4562                 :           0 :        cond_string(1)='vdw_xc' ; cond_values(1)=dt%vdw_xc
    4563                 :           0 :        call chkint_ne(1,1,cond_string,cond_values,ierr,'optdriver',optdriver,2,(/RUNL_GSTATE,RUNL_RESPFN/),iout)
    4564                 :             :      end if
    4565                 :             : !    Restriction for DFT-D2
    4566         [ +  + ]:           8 :      if (dt%vdw_xc==5) then
    4567                 :             : !    Only with PBE, BP86 or BLYP GGA XC
    4568                 :             :        if(dt%ixc/=11.and.dt%ixc/=-101130.and.dt%ixc/=-130101.and. &
    4569                 :             :           dt%ixc/=18.and.dt%ixc/=-106131.and.dt%ixc/=-131106.and. &
    4570                 :             :           dt%ixc/=19.and.dt%ixc/=-106132.and.dt%ixc/=-132106.and. &
    4571   [ -  +  -  -  :           1 :           dt%ixc/=-202231.and.dt%ixc/=-231202) then
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
                      - ]
    4572                 :           0 :          write(msg,'(6a)') ch10,&
    4573                 :           0 :           'Van der Waals DFT-D2 correction (vdw_xc=5) only available for the following XC functionals:',ch10,&
    4574                 :           0 :           '    GGA-PBE, GGA-BLYP, GGA-BP86, mGGA-TPSS',ch10,&
    4575                 :           0 :           'Action: change your pseudopotential file.'
    4576                 :           0 :          call wrtout(std_out,msg)
    4577                 :           0 :          ierr=ierr+1
    4578                 :             :        end if
    4579                 :             : !       Only for the first 5 lines of the periodic table
    4580         [ +  + ]:           2 :        do itypat=1,dt%ntypat
    4581   [ +  -  -  + ]:           2 :          if (dt%znucl(itypat)<0.or.dt%znucl(itypat)>54) then
    4582                 :           0 :            write(msg,'(4a,f5.1,a)') ch10,&
    4583                 :           0 :            ' chkinp: ERROR -',ch10,&
    4584                 :           0 :            '  Van der Waals DFT-D2 correction (vdw_xc=5) not available for atom type Z=',dt%znucl(itypat),' !'
    4585                 :           0 :            call wrtout(std_out,msg)
    4586                 :           0 :            ierr=ierr+1
    4587                 :             :          end if
    4588                 :             :        end do
    4589                 :             :      end if
    4590                 :             : !    Restriction for DFT-D3/DFT-D3(BJ)
    4591         [ +  + ]:           8 :      if (dt%vdw_xc==6.or.dt%vdw_xc==7) then
    4592                 :             : !    Only with PBE, BP86  or BLYP GGA XC
    4593                 :             :        if(dt%ixc/=11.and.dt%ixc/=-101130.and.dt%ixc/=-130101.and. &
    4594                 :             :           dt%ixc/=18.and.dt%ixc/=-106131.and.dt%ixc/=-131106.and. &
    4595                 :             :           dt%ixc/=19.and.dt%ixc/=-106132.and.dt%ixc/=-132106.and. &
    4596                 :             :           dt%ixc/=-202231.and.dt%ixc/=-231202.and.&
    4597                 :             :           dt%ixc/=14.and.dt%ixc/=-102130.and.dt%ixc/=-130102.and. &
    4598         [ -  + ]:           7 :           dt%ixc/=-170.and.dt%ixc/=41.and.dt%ixc/=-406) then
    4599                 :             :          write(msg,'(a,i0,5a)') &
    4600                 :           0 :          'Van der Waals DFT-D correction (vdw_xc=',dt%vdw_xc,') only available for the following XC functionals:',ch10,&
    4601                 :           0 :          '    GGA-PBE, GGA-BLYP, GGA-BP86, mGGA-TPSS, GGA-RevPBE, PBE0',ch10,&
    4602                 :           0 :          'Action: change your pseudopotential file.'
    4603                 :           0 :          ABI_CHECK_NOSTOP(.False., msg, ierr)
    4604                 :             :        end if
    4605                 :             : !       Only up to chemical species 96
    4606         [ +  + ]:          16 :        do itypat=1,dt%ntypat
    4607   [ +  -  +  - ]:          16 :          if (dt%znucl(itypat)<0.or.dt%znucl(itypat)>96) then
    4608                 :             :            write(msg,'(a,i0,1a,f5.1,a)')&
    4609                 :           0 :             'Van der Waals DFT-D correction (vdw_xc=',dt%vdw_xc,') not available for atom type Z=',dt%znucl(itypat),' !'
    4610                 :           9 :            ABI_CHECK_NOSTOP(.False., msg, ierr)
    4611                 :             :          end if
    4612                 :             :        end do
    4613                 :             :      end if
    4614                 :             :    end if
    4615                 :             : 
    4616                 :             : !  wfoptalg
    4617                 :             : !  Must be greater or equal to 0
    4618                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'wfoptalg',dt%wfoptalg,0,iout)
    4619                 :             : !  wfoptalg==0,1,4,10,14,111,112 or 114 if PAW
    4620         [ +  + ]:        6983 :    if (usepaw==1) then
    4621                 :        1205 :      cond_string(1)='usepawu' ; cond_values(1)=dt%usepawu
    4622                 :        1205 :      call chkint_eq(0,1,cond_string,cond_values,ierr,'wfoptalg',dt%wfoptalg,8,(/0,1,4,10,14,111,112,114/),iout)
    4623                 :             :    end if
    4624                 :             : !  wfoptalg/=114 if PAW+Fock
    4625   [ +  +  +  + ]:        6983 :    if (usepaw==1 .and. dt%usefock==1) then
    4626                 :          15 :      cond_string(1)='usepawu' ; cond_values(1)=dt%usepawu
    4627                 :          15 :      cond_string(2)='usefock' ; cond_values(2)=dt%usefock
    4628                 :          15 :      call chkint_ne(1,2,cond_string,cond_values,ierr,'wfoptalg',dt%wfoptalg,1,(/114/),iout)
    4629                 :             :    end if
    4630                 :             : 
    4631                 :             :    ! Check if FFT library supports MPI-FFT.
    4632   [ +  +  -  + ]:        6983 :    if (dt%npfft > 1 .and..not. fftalg_has_mpi(fftalg)) then
    4633                 :           0 :      write(msg,"(a,i0,a)")"fftalg: ",fftalg," cannot be used in MPI-FFT mode (npfft > 1)"
    4634                 :           0 :      ABI_ERROR_NOSTOP(msg,ierr)
    4635                 :             :    end if
    4636                 :             : 
    4637                 :             :    ! Chebyshev and Spectrum Slicing
    4638   [ +  +  +  + ]:        6983 :    if(dt%wfoptalg == 1 .or. dt%wfoptalg == 111 .or. dt%wfoptalg == 112) then
    4639   [ +  +  -  + ]:         225 :      if(dt%nspinor > 1 .and. dt%wfoptalg == 1) then
    4640                 :           0 :        msg='Nspinor > 1 not yet compatible with wfoptalg 1. Use chebfi V2 instead (wfoptalg=111).'
    4641                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    4642                 :             :      end if
    4643         [ -  + ]:         225 :      if(dt%usefock > 0) then
    4644                 :           0 :        ABI_ERROR_NOSTOP('Fock not yet compatible with wfoptalg 1 (use Fock-level parallelism)', ierr)
    4645                 :             :      end if
    4646   [ +  +  +  +  :        1836 :      if(dt%wfoptalg==1.and.maxval(abs(dt%istwfk(1:nkpt))) > 2) then
                   -  + ]
    4647                 :           0 :        ABI_ERROR_NOSTOP('Istwfk > 2 not compatible with wfoptalg 1. Use chebfi V2 instead (wfoptalg=111).', ierr)
    4648                 :             :      end if
    4649         [ -  + ]:         225 :      if(dt%ecutsm > 0) then
    4650                 :           0 :        ABI_ERROR_NOSTOP('ecutsm > 0 not yet compatible with wfoptalg 1', ierr)
    4651                 :             :      end if
    4652                 :             :    end if
    4653                 :             : 
    4654                 :             : !  np_slk
    4655                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'np_slk',dt%np_slk,0,iout)
    4656   [ +  -  +  + ]:        6983 :    if (dt%np_slk>0 .and. dt%wfoptalg /= 114 ) then
    4657   [ +  +  -  + ]:        6520 :      if(dt%np_slk <= dt%npfft*dt%npband*dt%npspinor .and. MOD(dt%npfft*dt%npband*dt%npspinor, dt%np_slk) /= 0) then
    4658                 :           0 :        ABI_ERROR_NOSTOP('np_slk must divide npfft*npband*npspinor.',ierr)
    4659                 :             :      end if
    4660                 :             :    end if
    4661                 :             : !  slk_rankpp
    4662                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'slk_rankpp',dt%slk_rankpp,0,iout)
    4663                 :             : 
    4664                 :             : !  wtk
    4665                 :             : !  Check that no k point weight is < 0:
    4666         [ +  + ]:      120432 :    do ikpt=1,nkpt
    4667         [ -  + ]:      120432 :      if (dt%wtk(ikpt)< -tiny(0.0_dp) ) then
    4668                 :             :        write(msg, '(a,i5,a,1p,e12.4,a,a,a)' )&
    4669                 :           0 :         'At k point number',ikpt,'  wtk=',dt%wtk(ikpt),' <0.',ch10,&
    4670                 :           0 :         'Action: check wtk in input file. Each wtk must be >=0.'
    4671                 :           0 :        ABI_ERROR_NOSTOP(msg,ierr)
    4672                 :             :      end if
    4673                 :             :    end do
    4674                 :             : 
    4675                 :             : !  w90prtunk
    4676                 :        6983 :    call chkint_ge(0,0,cond_string,cond_values,ierr,'w90prtunk',dt%w90prtunk,0,iout)
    4677                 :             : 
    4678                 :             : !  xc_denpos
    4679                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'xc_denpos',dt%xc_denpos,1,tiny(one),iout)
    4680                 :             : 
    4681                 :             : !  xc_taupos
    4682                 :             : !  Allow for negative value of xc_taupos (to deactivate it)
    4683                 :             : !  call chkdpr(0,0,cond_string,cond_values,ierr,'xc_taupos',dt%xc_taupos,1,tiny(one),iout)
    4684                 :             : 
    4685                 :             : !  xc_tb09_c
    4686                 :        6983 :    call chkdpr(0,0,cond_string,cond_values,ierr,'xc_tb09_c',dt%xc_tb09_c,1,0.0_dp,iout)
    4687                 :             :    !if (dt%xc_tb09_c>99._dp.and.dt%iscf==22) then
    4688                 :             :    !  write(msg, '(a,i4,a,i4,a,a,a,a,a,a)' )&
    4689                 :             :    !&   'TB09 XC functional with variable c is not compatible with ODA mixing (iscf=22)!'
    4690                 :             :    !  ABI_ERROR_NOSTOP(msg,ierr)
    4691                 :             :    !end if
    4692                 :             : 
    4693                 :             : !  xred
    4694                 :             : !  Check that two atoms are not on top of each other
    4695         [ +  + ]:       14226 :    do iimage=1,dt%nimage
    4696         [ +  + ]:       14226 :      if(natom>1)then
    4697   [ -  +  +  -  :       17733 :        ABI_MALLOC(frac,(3,natom))
          +  -  -  +  -  
                      + ]
    4698         [ +  + ]:       43247 :        do ia=1,natom
    4699                 :             : !        Map reduced coordinate xred(mu,ia) into [0,1)
    4700                 :       37336 :          frac(1,ia)=dt%xred_orig(1,ia,iimage)-aint(dt%xred_orig(1,ia,iimage))+0.5_dp-sign(0.5_dp,dt%xred_orig(1,ia,iimage))
    4701                 :       37336 :          frac(2,ia)=dt%xred_orig(2,ia,iimage)-aint(dt%xred_orig(2,ia,iimage))+0.5_dp-sign(0.5_dp,dt%xred_orig(2,ia,iimage))
    4702                 :       43247 :          frac(3,ia)=dt%xred_orig(3,ia,iimage)-aint(dt%xred_orig(3,ia,iimage))+0.5_dp-sign(0.5_dp,dt%xred_orig(3,ia,iimage))
    4703                 :             :        end do
    4704         [ +  + ]:       37336 :        do ia=1,natom-1
    4705         [ +  + ]:      398357 :          do ib=ia+1,natom
    4706                 :             :            if (abs(frac(1,ia)-frac(1,ib))<1.0d-6 .and. &
    4707   [ +  +  +  +  :      361021 :                abs(frac(2,ia)-frac(2,ib))<1.0d-6 .and. &
                   -  + ]
    4708                 :       31425 :                abs(frac(3,ia)-frac(3,ib))<1.0d-6 ) then
    4709         [ #  # ]:           0 :              if(iimage>1)then
    4710                 :           0 :                write(msg,'(2a,i5)') ch10,' The following was observed for image=',iimage
    4711                 :           0 :                call wrtout(iout,msg)
    4712                 :           0 :                call wrtout(std_out,msg)
    4713                 :             :              end if
    4714                 :             :              write(msg, '(a,i0,a,i0,6a)') &
    4715                 :           0 :               'Atoms number',ia,' and',ib,' are located at the same point',' of the unit cell',ch10,&
    4716                 :           0 :               '(periodic images are taken into account).',ch10,&
    4717                 :           0 :               'Action: change the coordinate of one of these atoms in the input file.'
    4718                 :           0 :              ABI_ERROR_NOSTOP(msg,ierr)
    4719                 :             :            end if
    4720                 :             :          end do
    4721                 :             :        end do
    4722         [ -  + ]:        5911 :        ABI_FREE(frac)
    4723                 :             :      end if
    4724                 :             :    end do
    4725                 :             : 
    4726                 :             : !  znucl
    4727                 :             : !  Check that znucl and znuclpsp agree
    4728         [ +  + ]:       15630 :    do ipsp=1,npsp
    4729         [ -  + ]:       15630 :      if (abs(dt%znucl(ipsp)-pspheads(ipsp)%znuclpsp)> tol12 ) then
    4730                 :             :        write(msg, '(a,i0,a,es12.4,a,a,es12.4,2a)' )&
    4731                 :           0 :         'For pseudopotential ',ipsp,'  znucl from user input file= ',dt%znucl(ipsp),ch10,&
    4732                 :           0 :         'while znucl from pseudopotential file=',pspheads(ipsp)%znuclpsp,ch10,&
    4733                 :           0 :         'Action: check znucl in input file, or check psp file. They must agree.'
    4734                 :           0 :        ABI_ERROR_NOSTOP(msg,ierr)
    4735                 :             :      end if
    4736                 :             :    end do
    4737                 :             : 
    4738                 :             :   ! ZORA
    4739                 :             :   ! only values of -3,-2,-1,0,1,2,3 are allowed. 0 is the default.
    4740                 :        6983 :   call chkint_eq(0,0,cond_string,cond_values,ierr,'zora',dt%zora,7,(/-3,-2,-1,0,1,2,3/),iout)
    4741         [ +  + ]:        6983 :   if(dt%zora .NE. 0) then
    4742                 :          16 :      cond_string(1)='zora';cond_values(1)=dt%zora
    4743                 :             :   !  require PAW
    4744                 :          16 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'usepaw',dt%usepaw,1,(/1/),iout)
    4745                 :             :   end if
    4746         [ +  + ]:        6983 :   if(dt%zora .NE. 0 .and. dt%zora .NE. 1) then
    4747                 :          14 :      cond_string(1)='zora';cond_values(1)=dt%zora
    4748                 :             :      ! require nspinor 2
    4749                 :          14 :      call chkint_eq(1,1,cond_string,cond_values,ierr,'nspinor',dt%nspinor,1,(/2/),iout)
    4750                 :             :   end if
    4751                 :             : 
    4752                 :             : !  bandFFT
    4753   [ +  +  +  + ]:        6983 :    if(dt%paral_kgb==1.and.dt%optdriver==RUNL_GSTATE) then
    4754   [ +  +  -  + ]:         592 :      if (mod(dt%wfoptalg,10) /= 4 .and. mod(dt%wfoptalg,10) /= 2 .and. mod(dt%wfoptalg,10) /= 1) then
    4755                 :             :        write(msg,'(a,i0,a,a,a,a)')&
    4756                 :           0 : &       'The value of wfoptalg is found to be ',dt%wfoptalg,ch10,&
    4757                 :           0 : &       'This is not allowed in the case of band-FFT parallelization.',ch10,&
    4758                 :           0 : &       'Action: put wfoptalg = 4, 14 or 112, 114 in your input file'
    4759                 :           0 :        ABI_ERROR_NOSTOP(msg,ierr)
    4760                 :             :      end if
    4761                 :             : !    Make sure all nband are equal
    4762   [ +  +  +  +  :        7472 :      if (any(dt%nband(1:nkpt*nsppol) /= maxval(dt%nband(1:nkpt*nsppol)) )) then
             +  -  -  + ]
    4763                 :             :        write(msg,'(a,a,a)')&
    4764                 :           0 :        'The number of bands have to remain constant in the case of band-FFT parallelization.',ch10,&
    4765                 :           0 :        'Action: set all the nbands to the same value in your input file'
    4766                 :           0 :        ABI_ERROR_NOSTOP(msg,ierr)
    4767                 :             :      end if
    4768         [ -  + ]:         592 :      if (dt%mkmem == 0) then
    4769                 :             :        write(msg,'(a,i0,a,a,a,a)')&
    4770                 :           0 :         'The value of mkmem is found to be ',dt%mkmem,ch10,&
    4771                 :           0 :         'An out-of-core solution can''t be used in the case of band-FFT parallelization.',ch10,&
    4772                 :           0 :         'Action: put mkmem = nkpt in your input file'
    4773                 :           0 :        ABI_ERROR_NOSTOP(msg,ierr)
    4774                 :             :      end if
    4775                 :             :    end if
    4776                 :             : 
    4777                 :             : !  WVL - wavelets checks and limitations
    4778         [ -  + ]:        6983 :    if(dt%usewvl == 1) then
    4779         [ #  # ]:           0 :      if (dt%wvl_hgrid <= 0) then
    4780                 :             :        write(msg,'(a,i0,a,a,a,a)')&
    4781                 :           0 :         'The value of wvl_hgrid is found to be ',dt%wvl_hgrid,ch10,&
    4782                 :           0 :         'This value is mandatory and must be positive.',ch10,&
    4783                 :           0 :         'Action: put wvl_hgrid to a positive value in your input file'
    4784                 :           0 :        ABI_ERROR_NOSTOP(msg,ierr)
    4785                 :             :      end if
    4786   [ #  #  #  # ]:           0 :      if (dt%nsym /= 1 .and. dt%icoulomb == 1) then
    4787                 :             :        write(msg,'(a,i0,a,a,a,a)')&
    4788                 :           0 :         'The value of nsym is found to be ',dt%nsym,ch10,&
    4789                 :           0 :         'No symmetry operations are allowed for isolated systems.',ch10,&
    4790                 :           0 :         'Action: put nsym = 1 in your input file'
    4791                 :           0 :        ABI_ERROR_NOSTOP(msg,ierr)
    4792                 :             :      end if
    4793         [ #  # ]:           0 :      if (dt%optstress > 0) then
    4794                 :             :        write(msg,'(a,i0,a,a,a,a)')&
    4795                 :           0 :         'The value of optstress is found to be ', dt%optstress, ch10,&
    4796                 :           0 :         'There is no stress computation available with the wavelet code.',ch10,&
    4797                 :           0 :         'Action: put optstress = 0 in your input file'
    4798                 :           0 :        ABI_ERROR_NOSTOP(msg,ierr)
    4799                 :             :      end if
    4800         [ #  # ]:           0 :      if (usepaw == 1) then
    4801                 :           0 :        ABI_WARNING('WVL+PAW is under development')
    4802                 :             :      end if
    4803         [ #  # ]:           0 :      if (dt%nspden > 2) then
    4804                 :             :        write(msg,'(a,i0,a,a,a,a)')&
    4805                 :           0 :        'The value of nspden is found to be ', dt%nspden, ch10, &
    4806                 :           0 :        'The wavelet computation is not allowed with non-colinear spin.',ch10,&
    4807                 :           0 :        'Action: put nspden = 1 or 2 in your input file'
    4808                 :           0 :        ABI_ERROR_NOSTOP(msg,ierr)
    4809                 :             :      end if
    4810         [ #  # ]:           0 :      if (dt%nspden /= dt%nsppol) then
    4811                 :             :        write(msg,'(a,i0,2a,i0,2a)')&
    4812                 :           0 :         'The value of nspden is found to be ', dt%nspden, ch10, &
    4813                 :           0 :         'and the one of nsppol is found to be ', dt%nsppol, ch10, &
    4814                 :           0 :         'In wavelet computation, nspden and nsppol must be equal.'
    4815                 :           0 :        ABI_ERROR_NOSTOP(msg,ierr)
    4816                 :             :      end if
    4817                 :             :      ! We check the consistency of occupation, empty bands are not allowed.
    4818         [ #  # ]:           0 :      if (dt%nsppol == 2) then
    4819                 :           0 :        mband = dt%nelect
    4820                 :             :      else
    4821                 :           0 :        mband = dt%mband
    4822                 :             :      end if
    4823         [ #  # ]:           0 :      do iimage=1,dt%nimage
    4824         [ #  # ]:           0 :        do ii = 1, mband, 1
    4825   [ #  #  #  # ]:           0 :          if (dt%occ_orig(ii,iimage) < tol8 .and. dt%iscf == 0) then
    4826                 :             :            write(msg,'(a,f7.4,6a)')&
    4827                 :           0 :             'One value of occ is found to be ', dt%occ_orig(ii,iimage), ch10, &
    4828                 :           0 :             'The direct minimization is not allowed with empty bands.',ch10,&
    4829                 :           0 :             'Action: use occopt = 1 for automatic band filling or', ch10, &
    4830                 :           0 :             'change occ value in your input file'
    4831                 :           0 :            ABI_ERROR_NOSTOP(msg,ierr)
    4832                 :             :          end if
    4833                 :             :        end do
    4834                 :             :      enddo
    4835         [ #  # ]:           0 :      if (npsp /= dt%ntypat) then
    4836                 :           0 :        write(msg, '(a,a,a,a,I0,a,I0,a,a,a)' ) ch10,&
    4837                 :           0 :        'consistency checks failed,', ch10, &
    4838                 :           0 :        'dtset%npsp (', npsp, ') /= dtset%ntypat (', dt%ntypat, ').', ch10, &
    4839                 :           0 :        'No alchemy pseudo are allowed with wavelets.'
    4840                 :           0 :        ABI_ERROR_NOSTOP(msg,ierr)
    4841                 :             :      end if
    4842                 :             :    end if
    4843                 :             : 
    4844                 :             :    ! Test on tolerances (similar tests are performed in scprqt, so keep the two versions in synch)
    4845         [ +  + ]:        6983 :    if (any(optdriver == [RUNL_GSTATE, RUNL_RESPFN])) then
    4846                 :        6381 :      ttolwfr=0 ; ttoldff=0 ; ttoldfe=0 ; ttolvrs=0; ttolrff=0; ttoldmag=0
    4847         [ +  + ]:        6381 :      if(abs(dt%tolwfr)>tiny(zero))ttolwfr=1
    4848         [ +  + ]:        6381 :      if(abs(dt%toldff)>tiny(zero))ttoldff=1
    4849         [ +  + ]:        6381 :      if(abs(dt%tolrff)>tiny(zero))ttolrff=1
    4850         [ +  + ]:        6381 :      if(abs(dt%toldfe)>tiny(zero))ttoldfe=1
    4851         [ +  + ]:        6381 :      if(abs(dt%tolvrs)>tiny(zero))ttolvrs=1
    4852         [ +  + ]:        6381 :      if(abs(dt%toldmag)>tiny(zero))ttoldmag=1
    4853                 :             : 
    4854                 :             :      ! If non-scf calculations, tolwfr must be defined
    4855   [ +  +  +  -  :        6381 :      if(ttolwfr /= 1 .and. ((dt%iscf<0 .and. dt%iscf/=-3) .or. dt%rf2_dkdk/=0 .or. dt%rf2_dkde/=0))then
                   -  + ]
    4856                 :             :        write(msg,'(a,a,a,es14.6,a,a)')&
    4857                 :           0 :         'When iscf < 0 and /= -3, or when rf2_dkdk /= 0 or rf2_dkde /= 0, tolwfr must be strictly',ch10,&
    4858                 :           0 :         'positive as this is the only convergence criterion that can be used, while it is: ',dt%tolwfr,ch10,&
    4859                 :           0 :         'Action: use tolwfr in your input file and resubmit the job.'
    4860                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    4861                 :             :      end if
    4862                 :             :      !  toldff only allowed when prtfor==1
    4863                 :             :      !if((ttoldff == 1 .or. ttolrff == 1) .and. dt%prtfor==0 )then
    4864                 :             :      !  ABI_ERROR_NOSTOP('toldff only allowed when prtfor=1!', ierr)
    4865                 :             :      !end if
    4866                 :             : 
    4867                 :             :      ! If SCF calculations, one and only one of these can differ from zero
    4868   [ +  +  +  +  :        6381 :      if ( (dt%iscf>0 .or. dt%iscf==-3) .and. &
             -  +  -  + ]
    4869                 :             :        & ( (ttolwfr==1.and.ttoldff+ttoldfe+ttolvrs+ttolrff+ttoldmag>1) .or. (ttolwfr==0.and.ttoldff+ttoldfe+ttolvrs+ttolrff+ttoldmag/=1) ) ) then
    4870                 :             :        write(msg,'(6a,es14.6,a,es14.6,a,es14.6,a,a,es14.6,a,es14.6,a,i0,2a)' )&
    4871                 :           0 :         'For the SCF case, one and only one of the input tolerance criteria ',ch10,&
    4872                 :           0 :         'toldff, tolrff, toldfe, toldmag or tolvrs ','must differ from zero, while they are',ch10,&
    4873                 :           0 :         'toldff=',dt%toldff,', tolrff=',dt%tolrff,', toldfe=',dt%toldfe,ch10,&
    4874                 :           0 :         'toldmag=',dt%toldmag,'and tolvrs=',dt%tolvrs,' for idtset: ', idtset, ch10,&
    4875                 :           0 :         'Action: change your input file and resubmit the job.'
    4876                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    4877                 :             :      end if
    4878                 :             : 
    4879   [ +  +  -  + ]:        6381 :      if (ttolwfr==1.and.dt%tolwfr_diago>dt%tolwfr) then
    4880                 :             :        write(msg, '(2a,2(a,es14.6),a)' )&
    4881                 :           0 :         ' tolwfr_diago cannot be bigger than tolwfr !',ch10,&
    4882                 :           0 :         ' tolwfr=',dt%tolwfr,' and tolwfr_diago=',dt%tolwfr_diago,&
    4883                 :           0 :         ' Action: change the value of tolwfr or tolwfr_diago in the input file.'
    4884                 :           0 :        ABI_ERROR_NOSTOP(msg, ierr)
    4885                 :             :      end if
    4886                 :             : 
    4887                 :             :    end if
    4888                 :             : 
    4889         [ -  + ]:        6983 :    if (optdriver == RUNL_GWR) then
    4890                 :           0 :      msg = "G0W0, HDIAGO, HDIAGO_FULL, RPA_ENERGY, EGEW, EGW0, G0EW, G0V, CC4S, CC4S_FULL, CC4S_FROM_WFK, GAMMA_GW, CHI0"
    4891         [ #  # ]:           0 :      if (.not. string_in(dt%gwr_task, msg)) then
    4892                 :           0 :        ABI_ERROR_NOSTOP(sjoin("Invalid gwr_task:`", dt%gwr_task, "`, must be among:", msg), ierr)
    4893                 :             :      end if
    4894                 :             : #ifndef HAVE_LINALG_SCALAPACK
    4895                 :           0 :      ABI_ERROR("GWR code requires scalapack library")
    4896                 :             : #endif
    4897                 :             : 
    4898                 :             :      ! Avoid wasting CPUs if nsppol==2.
    4899                 :             :      !if (dt%nsppol == 2 .and. .not. iseven(nproc) .and. nproc > 1) then
    4900                 :             :      !  write(msg,'(3a)') "Spin-polarized GW calculations should be run with an even number of processors ",ch10,&
    4901                 :             :      !   " for achieving an optimal distribution of memory and CPU load. Please change the number of processors."
    4902                 :             :      !  ABI_ERROR_NOSTOP(msg, ierr)
    4903                 :             :      !end if
    4904   [ #  #  #  # ]:           0 :      if (dt%usepaw == 1 .and. .not. string_in(dt%gwr_task, "HDIAGO, HDIAGO_FULL, CC4S, CC4S_FULL, CC4S_FROM_WFK")) then
    4905                 :           0 :        ABI_ERROR_NOSTOP("GWR with PAW not yet implemented", ierr)
    4906                 :             :      end if
    4907                 :             :      !if (dt%nshiftk /= 1 .or. any(abs(dt%shiftk(:,1)) > tol6)) then
    4908                 :             :      !  ABI_ERROR_NOSTOP('GWR requires Gamma-centered k-meshes', ierr)
    4909                 :             :      !end if
    4910                 :             :      !if (dt%nspinor == 2 .and. .not. string_in(dt%gwr_task, "HDIAGO, HDIAGO_FULL")) then
    4911                 :             :      !  ABI_ERROR_NOSTOP('GWR does not support nspinor == 2', ierr)
    4912                 :             :      !end if
    4913                 :             :    end if
    4914                 :             : 
    4915                 :             :    ! ===========================================================
    4916                 :             :    ! Write COMMENTs if some combination of input vars look weird
    4917                 :             :    ! ===========================================================
    4918   [ +  +  +  +  :       37174 :    if (optdriver == RUNL_EPH .and. dt%dipdip /= 0 .and. any(dt%occopt == [3, 4, 5, 6, 7])) then
          +  +  +  -  +  
                      + ]
    4919                 :          31 :      ABI_COMMENT("dipdip can be set to 0 in case of metals whereas dipdip 1 should be used in polar materials.")
    4920                 :             :    end if
    4921                 :             : 
    4922                 :             :    ! Check features that are not compatible with the generalized Bloch theorem.
    4923         [ +  + ]:        6983 :    if (dt%use_gbt /= 0) then
    4924         [ -  + ]:           8 :      ABI_CHECK_NOSTOP(optdriver == RUNL_GSTATE, 'GBT can only be used in GS calculations', ierr)
    4925         [ -  + ]:           8 :      ABI_CHECK_NOSTOP(dt%usepaw == 0, 'GBT does not support PAW', ierr)
    4926         [ -  + ]:           8 :      ABI_CHECK_NOSTOP(dt%paral_kgb == 0, 'GBT does not support paral_kgb 1', ierr)
    4927         [ -  + ]:           8 :      ABI_CHECK_NOSTOP(dt%wfoptalg == 0, 'GBT is only coded for wfoptalg 0', ierr)
    4928         [ -  + ]:           8 :      ABI_CHECK_NOSTOP(dt%nsym == 1, 'GBT cannot exploit spatial symmetries, please use nsym 1', ierr)
    4929         [ -  + ]:           8 :      ABI_CHECK_NOSTOP(dt%kptopt == 4, 'GBT requires kptopt 4', ierr)
    4930         [ -  + ]:           8 :      ABI_CHECK_NOSTOP(dt%useylm == 0, 'GBT requires useylm 0', ierr)
    4931         [ -  + ]:           8 :      ABI_CHECK_NOSTOP(dt%gpu_option == ABI_GPU_DISABLED, 'GBT is not compatible with GPUs', ierr)
    4932         [ -  + ]:           8 :      ABI_CHECK_NOSTOP(dt%nspinor == 2, 'GBT requires nspinor 2', ierr)
    4933         [ -  + ]:           8 :      ABI_CHECK_NOSTOP(dt%nspden == 4, 'GBT requires nspden 4', ierr)
    4934   [ +  +  +  -  :          72 :      ABI_CHECK_NOSTOP(all(dt%istwfk(1:nkpt) == 1), 'GBT requires istwfk == 1', ierr)
                   -  + ]
    4935         [ -  + ]:           8 :      ABI_CHECK_NOSTOP(dt%usefock == 0, 'GBT with Fock is not coded', ierr)
    4936         [ -  + ]:           8 :      ABI_CHECK_NOSTOP(.not. xc_is_mgga, 'GBT with meta-GGA is not coded', ierr)
    4937                 :             : !     ABI_CHECK_NOSTOP(dt%ionmov == 0, 'GBT and atomic relaxation not tested', ierr)
    4938                 :             : !     ABI_CHECK_NOSTOP(dt%optcell == 0, 'GBT and cell relaxation not coded', ierr)
    4939   [ +  -  +  -  :           8 :      if (all(abs(dt%spinat(1:2, 1:dt%natom)) < tol8)) then
             -  +  -  + ]
    4940                 :           0 :        ABI_CHECK_NOSTOP(.False., 'at least one spinat(:,iat) should have non-zero x or y components', ierr)
    4941                 :             :      end if
    4942         [ +  + ]:           8 :      if(dt%use_gbt == 1) then
    4943   [ +  +  +  -  :          14 :        ABI_CHECK_NOSTOP(all(dt%so_psp(1:npsp) == 0), 'use_gbt = 1 requires so_psp == 0', ierr)
                   -  + ]
    4944                 :             :      end if
    4945                 :             : 
    4946                 :             :      ! in calcdenmagsph we wrap the atoms in the first unit cell assuming the magnetization is periodic
    4947                 :             :      ! but this is not the case when GBT is used. So make sure all atomic sites are in the first unit cell.
    4948   [ -  +  +  -  :          24 :      ABI_MALLOC(my_xred, (3, dt%natom))
          +  -  +  -  -  
                +  -  + ]
    4949   [ -  +  +  -  :          16 :      ABI_MALLOC(xshift, (3, dt%natom))
             -  +  -  + ]
    4950   [ +  +  +  + ]:          52 :      call wrap2_zero_one(dt%xred_orig(:,1:dt%natom,1), my_xred, xshift)
    4951                 :             : 
    4952   [ +  +  +  +  :          52 :      if (any(abs(dt%xred_orig(:,1:dt%natom,1) - my_xred) > tol6)) then
             +  -  -  + ]
    4953                 :           0 :        ABI_CHECK_NOSTOP(.False., "GBT requires fractional coordinates to be in the unit cell when computing mx, my!", ierr)
    4954                 :             :      end if
    4955                 :             : 
    4956         [ -  + ]:           8 :      ABI_FREE(my_xred)
    4957         [ -  + ]:           8 :      ABI_FREE(xshift)
    4958                 :             :    end if
    4959                 :             : 
    4960                 :             :    ! Consistency check for GSTORE input variables.
    4961   [ +  +  -  + ]:        6983 :    if (dt%gstore_kzone == "ibz" .and. dt%gstore_qzone == "ibz") then
    4962                 :           0 :      ABI_CHECK_NOSTOP(.False., "gstore_kzone and gstore_qzone cannot be both in the 'ibz' ", ierr)
    4963                 :             :    end if
    4964   [ +  +  -  + ]:        6983 :    if (dt%gstore_use_lgk /= 0 .and. dt%gstore_qzone /= "bz") then
    4965                 :           0 :      ABI_CHECK_NOSTOP(.False., "when gstore_use_lgk /= 0, gstore_qzone must be 'bz' ", ierr)
    4966                 :             :    end if
    4967   [ -  +  -  - ]:        6983 :    if (dt%gstore_use_lgq /= 0 .and. dt%gstore_kzone /= "bz") then
    4968                 :           0 :      ABI_CHECK_NOSTOP(.False., "when gstore_use_lgq /= 0, gstore_kzone must be 'bz' ", ierr)
    4969                 :             :    end if
    4970         [ -  + ]:        6983 :    if (dt%gstore_sym /= 0 .and. dt%gstore_sym /= 1 .and. dt%gstore_sym /= 2) then
    4971                 :           0 :      ABI_CHECK_NOSTOP(.False., "gstore_sym must be 0, 1, or 2 ", ierr)
    4972                 :             :    end if
    4973   [ +  -  -  -  :        6983 :    if (dt%gstore_sym /= 0 .and. .not. (dt%gstore_kzone == "bz" .and. dt%gstore_qzone == "bz")) then
                   -  - ]
    4974                 :        6983 :      ABI_CHECK_NOSTOP(.False., "gstore_sym /= 0 requires gstore_kzone == 'bz' and gstore_qzone == 'bz' ", ierr)
    4975                 :             :    end if
    4976                 :             :    !if (dt%gstore_sym == 2 .and. dt%gstore_use_lgk == 0) then
    4977                 :             :    !  ABI_CHECK_NOSTOP(.False., "gstore_sym == 2 requires gstore_use_lgk == 1 ", ierr)
    4978                 :             :    !end if
    4979   [ -  +  -  - ]:        6983 :    if (dt%gstore_sym /= 0 .and. nspinor == 2) then
    4980                 :           0 :      ABI_CHECK_NOSTOP(.False., "gstore_sym /= 0 is not compatible with nspinor 2 ", ierr)
    4981                 :             :    end if
    4982                 :             : 
    4983                 :             : !  If molecular dynamics or structural optimization is being done
    4984                 :             : !  (dt%ionmov>0), make sure not all atoms are fixed
    4985                 :             : !  if (dt%ionmov > 0) then
    4986                 :             : !  if (natfix == natom) then
    4987                 :             : !  write(msg, '(a,a,a,a,i4,a,i5,a,a,i5,a,a,a,a,a,a)' ) ch10,&
    4988                 :             : !  &   ' setup1: ERROR -',ch10,&
    4989                 :             : !  &   '  ionmov is ',dt%ionmov,' and number of fixed atoms is ',natfix,ch10,&
    4990                 :             : !  &   '  while number of atoms natom is ',natom,'.',ch10,&
    4991                 :             : !  &   '  Thus all atoms are fixed and option ionmov to move atoms',&
    4992                 :             : !  &           ' is inconsistent.',ch10,&
    4993                 :             : !  &   '  Action: change ionmov or natfix and iatfix in input file and resubmit.'
    4994                 :             : !  call wrtout(std_out,msg)
    4995                 :             : !  ierr = ierr + 1
    4996                 :             : !  end if
    4997                 :             : !  end if
    4998                 :             : 
    4999                 :             : !  Should check that the symmetry operations are consistent with iatfixx,
    5000                 :             : !  iatfixy and iatfixz (diagonal symmetry operations)
    5001                 :             : 
    5002                 :             : !  Should check values of fftalg
    5003                 :             : 
    5004                 :             : !  Must have nqpt=1 for rfphon=1
    5005                 :             : 
    5006                 :             :    ! Here ends the checking section **************************************
    5007                 :        6983 :    call dt%free()
    5008                 :        8416 :    ierr_dtset(idtset)=ierr
    5009                 :             :  end do ! idtset
    5010                 :             : 
    5011   [ +  +  -  + ]:        9849 :  if (maxval(dtsets(:)%usewvl) > 0) then
    5012                 :           0 :    write(msg,'(4a)') ch10,&
    5013                 :           0 :     ' Comparison between wvl_hgrid and ecut',ch10,&
    5014                 :           0 :     ' real-space mesh | eq. Ec around atoms | eq. Ec further from atoms'
    5015                 :           0 :    ABI_COMMENT(msg)
    5016                 :           0 :    wvl_hgrid = zero
    5017                 :           0 :    twvl = .false.
    5018         [ #  # ]:           0 :    do idtset=1,ndtset_alloc
    5019                 :             :      ! Give an indication to the equivalent ecut corresponding to given hgrid.
    5020   [ #  #  #  # ]:           0 :      if (dtsets(idtset)%usewvl == 1 .and. wvl_hgrid /= dtsets(idtset)%wvl_hgrid) then
    5021                 :             :        write(msg,'(F11.3,A,F16.1,A,F16.1,A)') &
    5022                 :           0 :         dtsets(idtset)%wvl_hgrid, " bohr  |", &
    5023                 :           0 :         two * pi * pi / (dtsets(idtset)%wvl_hgrid ** 2), " Ht  | ", &
    5024                 :           0 :         half * pi * pi / (dtsets(idtset)%wvl_hgrid ** 2), " Ht"
    5025                 :           0 :        call wrtout(std_out,msg)
    5026                 :           0 :        wvl_hgrid = dtsets(idtset)%wvl_hgrid
    5027                 :             :      end if
    5028   [ #  #  #  #  :           0 :      twvl = twvl .or. (dtsets(idtset)%usewvl == 1 .and. dtsets(idtset)%iomode /= IO_MODE_ETSF)
                   #  # ]
    5029                 :             :    end do
    5030         [ #  # ]:           0 :    if (twvl) then
    5031                 :             :      write(msg,'(5a)') &
    5032                 :           0 :       'Restart files from wavelets in non ETSF format does not follow', ch10, &
    5033                 :           0 :       'the ABINIT standards.', ch10, &
    5034                 :           0 :       'Set iomode to 3 to use ETSF restart files.'
    5035                 :           0 :      ABI_WARNING(msg)
    5036                 :             :    end if
    5037                 :             :  end if
    5038                 :             : 
    5039                 :             :  ! If there was a problem, then stop.
    5040                 :        1433 :  call xmpi_sum(ierr_dtset, comm, mpierr)
    5041         [ +  + ]:        8416 :  ierr=sum(ierr_dtset(1:ndtset_alloc)/mpi_enregs(1:ndtset_alloc)%nproc)
    5042                 :             : 
    5043         [ -  + ]:        1433 :  if (ierr==1) then
    5044                 :           0 :    write(msg,'(6a)')ch10,&
    5045                 :           0 :      'Checking consistency of input data against itself revealed some problem(s).',ch10,&
    5046                 :           0 :      'So, stopping. The details of the problem(s) are given in the error file or the standard output file (= "log" file).',ch10,&
    5047                 :           0 :      'In parallel, the details might not even be printed there. Then, try running in sequential to see the details.'
    5048                 :           0 :    call wrtout(iout,msg)
    5049                 :             :    write(msg,'(a,i0,5a)')&
    5050                 :           0 :      'Checking consistency of input data against itself gave ',ierr,' inconsistency.',ch10,&
    5051                 :           0 :      'The details of the problem can be FOUND ABOVE (or in output or log file).',ch10,&
    5052                 :           0 :      'In parallel, the details might not even be printed there. Then, try running in sequential to see the details.'
    5053                 :           0 :    ABI_ERROR(msg)
    5054                 :             :  end if
    5055         [ -  + ]:        1433 :  if (ierr > 1) then
    5056                 :             :    write(msg,'(a,i0,7a)')&
    5057                 :           0 :      'Checking consistency of input data against itself gave ',ierr,' inconsistencies.',ch10,&
    5058                 :           0 :      'The details of the problems can be FOUND ABOVE (or in output or log file), in an earlier WARNING.',ch10,&
    5059                 :           0 :      'In parallel, the details might not even be printed there. Then, try running in sequential to see the details.',ch10,&
    5060                 :           0 :      "Also, try to run abinit in sequential in dry-run mode with e.g., `abinit INPUT -d` to detect problems in the INPUT."
    5061                 :           0 :    ABI_ERROR(msg)
    5062                 :             :  end if
    5063                 :             : 
    5064         [ -  + ]:        1433 :  ABI_FREE(ierr_dtset)
    5065                 :             : 
    5066   [ +  +  -  + ]:        1433 :  if (ndtset_alloc /= 1 .and. get_timelimit() > zero) then
    5067                 :           0 :    ABI_ERROR("--timelimit option cannot be used when ndtset > 1")
    5068                 :             :  end if
    5069                 :             : 
    5070                 :             :  DBG_EXIT("COLL")
    5071                 :             : 
    5072   [ -  +  -  +  :        2866 : end subroutine chkinp
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
                      + ]
    5073                 :             : !!***
    5074                 :             : 
    5075                 :             : end module m_chkinp
    5076                 :             : !!***
        

Generated by: LCOV version 2.3-1