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 % 2715 1583
Test Date: 2026-11-11 08:14:47 Functions: 100.0 % 2 2
Branches: 65.2 % 3074 2005

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

Generated by: LCOV version 2.3-1