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 % 2720 1587
Test Date: 2026-11-11 11:17:02 Functions: 100.0 % 2 2
Branches: 65.3 % 3078 2011

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

Generated by: LCOV version 2.3-1